@rongcloud/electron 5.8.5-alpha.3 → 5.8.5-alpha.4
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/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,dirname as r}from"path";import{getUUID as s,BasicLogger as i,BasicStatistic as a,appendUrl as c,ErrorCode as u,HTTP_TIMEOUT as p,LogTagId as l,StoreKeys as d,BasicReporter as h,REAT_TIME_LOG_SIZE as f,EConnectProtocol as g,notEmptyObject as C,NAVI_CACHE_DURATION as v,BasicNavi as _,NAVI_REQ_TIMEOUT as S,FORMATED_VERSION as y,getbundleId as m,StatisticsVersion as P,StatisticsTag as E,RCConnectionStatus as T,ProtocalType as I,ConnectType as R,AConnectionMgr as N,AreaCode as O,BasicStaticConfigManager as M,STATIC_CONFIG_IV as U,STATIC_CONFIG_KEY as w,BaseCloudController as b,urlCenter as x,isStartCloudController as L,InvokerType as A,ConversationType as D,SEND_MESSAGE_TYPE_OPTION as k,isObject as J,isUndefined as j,pushJSONToConfigs as B,MessageDirection as H,NotificationStatus as F,MessageType as V,RC_DEFAULT_USER as G,MentionedType as q,pushConfigsToJSON as K,ReceivedStatus as W,isArray as Q,getUploadFileName as Y}from"@rongcloud/engine";import{fork as X}from"child_process";import{app as z,ipcMain as $}from"electron";import{Agent as Z,request as ee}from"http";import{Agent as te,request as ne}from"https";import{parse as oe}from"url";import{isIP as re,Socket as se}from"net";import{EventEmitter as ie}from"events";import{connect as ae}from"tls";import{existsSync as ce,readFileSync as ue,writeFileSync as pe,mkdirSync as le}from"fs";import{createHash as de,createDecipheriv as he}from"crypto";var fe=o(__dirname,"binding","electron-".concat(t(),"-").concat(n(),".node")),ge={addon:null};try{ge.addon=require(fe)}catch(e){console.error("error ->",fe,"\n",e)}ge.addon||console.error("error -> cannot find module: ",fe);var Ce=ge.addon,ve=function(e,t){return ve=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])},ve(e,t)};function _e(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}ve(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Se,ye=function(){return ye=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},ye.apply(this,arguments)};function me(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 Pe(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 Ee(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_ADDON_T="P-call_addon-T",e.P_CALL_ADDON_O="P-call_addon-O",e.P_CALL_ADDON_R="P-call_addon-R",e.P_CALL_EXTRA_E="P-call_extra-E",e.P_CONNECT_S="P-connect-S",e.P_CONNECT_T="P-connect-T",e.P_CONNECT_O="P-connect-O",e.P_CONNECT_ENTRY_S="P-connect_entry-S",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",e.P_PARSE_JSON_E="P-parse_json-E"}(Se||(Se={}));var Te,Ie={flushTimestamp:Date.now(),queue:[],locked:!1};function Re(){Te&&clearInterval(Te)}function Ne(e,t){Re(),Te=setInterval((function(){return Ue(e,t)}),1e4)}function Oe(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=Ie.queue).push.apply(e,t)}var Me=200;function Ue(e,t){var n=Ie.queue,o=Ie.flushTimestamp;if(!(Ie.locked||0===n.length||Date.now()-o<3e4&&n.length<Me)){Ie.locked=!0;var r=t.createTraceId(),s=n.splice(0,Me).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(Se.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(n.length),r);var i=JSON.stringify(s);e.writeLog(i),t.debug(Se.P_WRITE_LOG_R,"write done, queueLen: ".concat(n.length),r),Ie.flushTimestamp=Date.now(),Ie.locked=!1,setTimeout((function(){return Ue(e,t)}))}}var we=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return _e(t,e),t.prototype.flush=function(e){Oe(e)},t}(i),be=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return _e(t,e),t.prototype.flush=function(e){Oe(e)},t}(a),xe=function(e,t){var n,o=Buffer.from(e),r=o.length;for(t.push(r),n=0;n<r;n++)t.push(o[n])},Le=function(e){return"string"==typeof e},Ae=function(e){return Le(e)?e.toUpperCase():""},De=function(e,t){var n="";return 2!==e.length?n="Unexpected number of bytes received.":5!==e[0]?n="Unexpected SOCKS version number: ".concat(e[0],"."):255===e[1]?n="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(n="Unexpected SOCKS authentication method: ".concat(e[1],".")),n},ke=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: ".concat(e[0],"."):0!==e[1]&&(t="Username and password authentication failure: ".concat(e[1],".")),t},Je=function(e){var t=Ae(e.method)||"GET",n=e.pathname||"/",o=e.headers||{},r=e.search||"";o.Host=e.host||"loclahost";var s="";for(var i in s="".concat(t," ").concat(n+r," HTTP/1.1\n"),o)if(Object.hasOwnProperty.call(o,i)){var a=o[i];s+="".concat(i,": ").concat(a,"\n")}return e.body&&(s+="Content-Length: ".concat(e.body.length,"\n")),s+="\n","POST"===t&&e.body&&(s+="".concat(e.body)),s},je=function(e){return new Promise((function(t){var n,o;e.socket.once("data",(function(o){var r,s=De(o,n);if(!s)return 2===o[1]?(e.socket.once("data",(function(n){var o=ke(n);o?e.emit("error",new Error("SOCKS authentication failed. ".concat(o))):t()})),r=[1],xe(e.socksUsername,r),xe(e.socksPassword,r),void e.write(Buffer.from(r))):void t();e.emit("error",new Error("SOCKS authentication failed. ".concat(s)))})),n=[0],e.socksUsername&&n.push(2),(o=Buffer.alloc(2+n.length))[0]=5,o[1]=n.length,n.forEach((function(e,t){o[2+t]=e})),e.write(o)}))},Be=function(e,t,n){return new Promise((function(o){var r,s;switch(e.socket.once("data",(function(t){var n;5!==t[0]?n="Unexpected SOCKS version number: ".concat(t[0],"."):0!==t[1]?n="".concat(function(e){switch(e){case 1:return"General SOCKS server failure";case 2:return"Connection not allowed by ruleset";case 3:return"Network unreachable";case 4:return"Host unreachable";case 5:return"Connection refused";case 6:return"TTL expired";case 7:return"Command not supported";case 8:return"Address type not supported";default:return"Unknown status code ".concat(e)}}(t[1]),"."):0!==t[2]&&(n="The reserved byte must be 0x00."),n?e.emit("error",new Error("SOCKS connection failed. ".concat(n))):o()})),(r=[]).push(5),r.push(1),r.push(0),re(t)){case 0:r.push(3),xe(t,r);break;case 4:r.push(1),function(e,t){var n,o,r=e.split(".");for(n=0;n<4;n++)o=parseInt(r[n],10),t.push(o)}(t,r);break;case 6:e.emit("error",new Error("Does not support IPV6"))}r.length+=2,(s=Buffer.from(r)).writeUInt16BE(n,s.length-2),e.write(s)}))},He=function(e){function t(t){var n=e.call(this)||this;return n.readable=!0,n.socket=new se,n.options=t,n.socksHost=t.socksHost||"localhost",n.socksPort=t.socksPort||1080,n.socksUsername=t.socksUsername||"",n.socksPassword=t.socksPassword||"",n.socket.on("error",(function(e){n.emit("error",e)})),n.on("error",(function(){n.socket.destroyed||n.socket.destroy()})),n.on("end",n.end),n}return _e(t,e),t.prototype.ref=function(){return this.socket.ref()},t.prototype.unref=function(){return this.socket.unref()},t.prototype.setTimeout=function(e,t){return this.socket.setTimeout(e,t)},t.prototype.setNoDelay=function(e){return this.socket.setNoDelay(e)},t.prototype.setKeepAlive=function(e,t){return this.socket.setKeepAlive(e,t)},t.prototype.address=function(){return this.socket.address()},t.prototype.cork=function(){return this.socket.cork()},t.prototype.uncork=function(){return this.socket.uncork()},t.prototype.pause=function(){return this.socket.pause()},t.prototype.resume=function(){return this.socket.resume()},t.prototype.pipe=function(e){return this.socket.pipe(e)},t.prototype.end=function(e,t){var n=this.socket.end(e,t);return this.writable=this.socket.writable,n},t.prototype.destroy=function(e){return this.socket.destroy(e)},t.prototype.setEncoding=function(e){return this.socket.setEncoding(e)},t.prototype.write=function(e,t,n){return this.socket.write(e,t,n)},t.prototype.read=function(e){return this.socket.read(e)},t.prototype.connect=function(e,t){var n=this;if("string"==typeof e&&/^\d+$/.test(e)&&(e=parseInt(e,10)),!Number.isInteger(e)||e<1||e>65535)throw new TypeError("Invalid port: ".concat(e));if(!t||"string"!=typeof t)throw new TypeError("Invalid host: ".concat(t));return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return me(n,void 0,void 0,(function(){var n;return Pe(this,(function(o){switch(o.label){case 0:return[4,je(this)];case 1:return o.sent(),[4,Be(this,t,e)];case 2:return o.sent(),this.onProxied(),n=Je(this.options),this.socket.write(Buffer.from(n)),[2]}}))}))})),this},t.prototype.onProxied=function(){var e=this;this.socket.on("close",(function(t){e.emit("close",t)})),this.socket.on("end",(function(){e.emit("end")})),this.socket.on("data",(function(t){e.emit("data",t)})),this.writable=!0,this.readable=!0,this.emit("connect")},t}(ie),Fe=function(e){var t,n=e.hostname,o=e.port;return!e.host||n&&o||(t=e.host.split(":")),!o&&t&&(o=parseInt(t[1],10)||0),!n&&t&&(n=t[0]),new He(e).connect(o,n)},Ve=function(e){function t(t){var n=e.call(this)||this;return n.createConnection=Fe,n}return _e(t,e),t}(Z),Ge=function(e,t,n){return(t=ye(ye({},t),oe(e))).port||(t.port=80),t.agent=new Ve(t),ee(t,n)},qe=function(e){var t,n;return t=Fe(e),n=t.onProxied,t.onProxied=function(){e.socket=t.socket,e.hostname?e.servername=e.hostname:e.host&&(e.servername=e.host.split(":")[0]),t.socket=ae(e,(function(){t.authorized=t.socket.authorized,n.call(t)})),t.socket.on("error",(function(e){t.emit("error",e)}))},t},Ke=function(e){function t(t,n){var o=e.call(this,n)||this;return o.url=t,o.socksHost=n.socksHost||"localhost",o.socksPort=n.socksPort||1080,o.createConnection=qe,o}return _e(t,e),t}(te),We=function(e,t,n,o){var r,s;return t.protocol="https:",!t.port&&t.host&&(r=t.host.split(":"),t.port=r[0],t.port=r[1]),t.port||(t.port=443),s=new Ke(e,t),t.agent=s,ne(e,t,n)},Qe=null;function Ye(e,t,n){void 0===n&&(n=!1);var o=t.url,r=t.headers,s=t.body,i=t.method,a=t.query,u=t.timeout,l=void 0===u?p:u;return new Promise((function(t){var u=/^https/.test(o),p={headers:r,method:i};u&&(p.rejectUnauthorized=n);var d=null;Qe?((p=ye(ye({},p),Qe)).body=s,d=u?We:Ge):(d=ee,u&&(p.agent=new te(p),d=ne));var h=d(c(o,a),p,(function(e){var n=e.statusCode,o="";e.setEncoding("utf8"),e.on("data",(function(e){o+=e})),e.once("end",(function(){t({status:n||0,data:o})}))}));h.once("timeout",(function(){e.warn(Se.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:o,method:i,query:a,timeout:l})),t({status:0})})),h.setTimeout(l),h.once("error",(function(n){e.warn(Se.P_HTTP_REQ_E,JSON.stringify({msg:n.stack,url:o,method:i,query:a,timeout:l})),t({status:0})})),h.write(s),h.end()}))}function Xe(e,t){return e?(Qe=ye(ye({},Qe),e),t.info(l.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:Qe})),{code:u.SUCCESS}):(Qe=null,t.info(l.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:u.SUCCESS})}function ze(){var e=Qe||void 0;return{code:u.SUCCESS,data:e}}var $e,Ze=[],et=function(e){return me(void 0,void 0,void 0,(function(){return Pe(this,(function(t){return[2,new Promise((function(t){Ze.push({resolve:t,args:e}),nt()}))]}))}))},tt=!1,nt=function(){return me(void 0,void 0,void 0,(function(){var e,t,n,o,r,s,i,a,c,u,p;return Pe(this,(function(l){return tt||0===Ze.length||(tt=!0,e=Ze.shift(),t=e.args,n=e.resolve,o=t.addon,r=t.startTime,s=t.endTime,i=t.level,a=t.realtimeReport,c=0,u=0,p=[],o.setLogEventListener((function(e){c+=e.length;var t=e.split(","),o=t[0],r=t[1],s=t[2],l=t[3],d=t[4],h=t.slice(5);if(c>f&&parseInt(r,10)!==u)n(p);else{u=parseInt(r,10);try{var g=JSON.parse(decodeURIComponent(h.join(","))),C=g.loggerId,v=g.sessionId,_=g.content,S=g.traceId;if(!a&&i<0)return;var y={time:parseInt(r,10),level:parseInt(l,10),sessionId:"".concat(o,":").concat(v),type:s,tag:d,loggerId:C,content:_,traceId:S};p.push(y)}catch(e){console.error(e)}}}),(function(e){n(p),tt=!1,nt()}),(function(e,t,n){})),o.pullFullLog(i,r,s,!1)),[2]}))}))},ot=function(e){function t(t,n,o,r,s){var i=this,a=process.versions.electron,c="Electron|".concat(a,"|").concat(process.arch,"|").concat(process.platform);return(i=e.call(this,n,o,c,{getLogs:function(e,n,o,r){return me(this,void 0,void 0,(function(){return Pe(this,(function(s){switch(s.label){case 0:return[4,et({startTime:e,endTime:n,level:o,realtimeReport:r,addon:t})];case 1:return[2,{logs:s.sent(),dbReady:!0}]}}))}))},getTimestamp4RealtimeLog:function(){var e=t.getStoreValue(d.REALTIME_LOG_TIMESTAMP);return parseInt(e,10)||0},setTimestamp4RealtimeLog:function(e){t.setStoreValue(d.REALTIME_LOG_TIMESTAMP,e.toString())}},r)||this).subProcess=s,i}return _e(t,e),t.prototype.send=function(e){return Ye(this.logger,e)},t.prototype.compressLogs=function(e){return me(this,void 0,void 0,(function(){var t,n,o;return Pe(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}(h),rt=[g.RMTP,g.TLS,g.QUIC],st={NAVI:function(e){return"RongCloud/navis/".concat(e,"/navi-cache.json")},DEVICE_ID:"deviceId",STATIC_CONFIG:function(e){return"RongCloud/caches/".concat(e,"/staticConfig.json")},CLOUD_CONTROL:function(e){return"RongCloud/cloudControl/".concat(e,"/cloudControl.json")}},it=null,at=function(){var e,o=Date.now(),r=[n(),t(),process.pid,o,Math.floor(Math.random()*o)].join("__");return e=r,de("md5").update(e).digest("hex")},ct=function(e){if(it)return it;var t=o(e,st.DEVICE_ID);return ce(t)?it=ue(t).toString():(it=at(),pe(t,it),it)},ut=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(Se.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:o,ext:r})),this._cppProto.setMessageExtension(t,n,o,i,s)},e.prototype.setLocalFromReceiveMsg=function(e,t){var n=t.channelId,o=t.conversationType,r=t.targetId,s=t.messageUId,i=t.expansion,a=t.sentTime,c={};for(var u in i)c[u]={v:"",ts:0},c[u].v=i[u],c[u].ts=a;this._setToProtocol(e,o,r,s,c,n||"")},e.prototype.setLocalFromExtMsg=function(e,t){var n=t.channelId,o=t.conversationType,r=t.targetId,s=t.content,i=t.sentTime,a=s,c=a.put,u=this._cppProto.getMessage(a.mid),p=JSON.parse(u).extMsg,l=JSON.parse(p||"{}");if(c)for(var d in c){var h=l[d];h&&h.ts<i-this._setTime?(h.v=c[d],h.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}(),pt=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 me(this,void 0,void 0,(function(){var n=this;return Pe(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}(),lt=function(e,t,n){return me(void 0,void 0,void 0,(function(){var o,r;return Pe(this,(function(s){return o=he("aes-256-cbc",t,n),r=o.update(e,"base64","utf-8"),[2,r+=o.final("utf8")]}))}))},dt=function(e){if(!ce(e)){var t=o(e,"..");ce(t)||dt(t),le(e)}},ht=function(e){function t(t,n,o,s,i){var a=e.call(this,t,n,o,i)||this;a.naviPath="",a._caches={},a.naviPath="".concat(s,"/").concat(st.NAVI(t));var c=r(a.naviPath);return ce(c)||dt(c),a}return _e(t,e),t.prototype.httpRequest=function(e,t,n,o){return me(this,void 0,void 0,(function(){var r,s,i,a,c;return Pe(this,(function(p){switch(p.label){case 0:return r="token=".concat(encodeURIComponent(n),"&v=").concat(y,"&p=PC&ev=").concat("5.8.5-alpha.3"),s="".concat(e,"/navi.json?r=").concat(Date.now()),this.logger.debug(l.L_REQUEST_T,JSON.stringify({url:s,body:r}),o),[4,Ye(this.logger,{method:"POST",headers:{appId:t},body:r,url:s,timeout:S})];case 1:if(200!==(i=p.sent()).status)return this.logger.warn(l.L_REQUEST_R,JSON.stringify({url:s,code:i.status}),o),[2,{code:this.transHttpCode(i.status)}];try{return a=JSON.parse(i.data),c=/^https/.test(s)?"https":"http",a.protocol=c,[2,{code:u.SUCCESS,data:a}]}catch(e){return this.logger.error(l.L_PARSE_NAVI_E,i.data,o),[2,{code:u.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},t.prototype.httpRequestV2=function(e,t,n,o){return me(this,void 0,void 0,(function(){var r,s,i,a;return Pe(this,(function(c){switch(c.label){case 0:return r=this.getNaviV2RequestOption({appkey:t,token:n,uri:e,platform:"electron",protocol:rt.join(",")}),this.logger.debug(l.L_REQUEST_T,JSON.stringify({url:r.url,body:r.body,headers:r.headers}),o),[4,Ye(this.logger,r)];case 1:if(200!==(s=c.sent()).status)return this.logger.warn(l.L_REQUEST_R,JSON.stringify({url:r.url,code:s.status}),o),[2,{code:this.transHttpCode(s.status)}];try{return i=JSON.parse(s.data),a=/^https/.test(r.url)?"https":"http",i.protocol=a,[2,{code:u.SUCCESS,data:i}]}catch(e){return this.logger.error(l.L_PARSE_NAVI_E,s.data,o),[2,{code:u.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},t.prototype.getNaviCache=function(e){var t=this._caches[e];if(t)return t;if(!ce(this.naviPath))return null;var n=ue(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(n),this._caches[e]}catch(e){this.logger.error(l.L_PARSE_NAVI_E,n)}return null},t.prototype.setNaviCache=function(e,t){var n=Date.now();if(C(this._caches))for(var o in this._caches){var r=this._caches[o];(n-r.timestamp>v||e===r.token)&&delete this._caches[o]}this._caches[e]={token:e,naviInfo:t,timestamp:Date.now()},pe(this.naviPath,JSON.stringify(this._caches))},t}(_);!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.NOT_INIT=-1]="NOT_INIT",e[e.CANCELED=-2]="CANCELED",e[e.REPEAT=-3]="REPEAT"}($e||($e={}));var ft,gt=function(e){function t(t,n,o,r,s,i){var a=e.call(this,t,o,r,s,i)||this;return a.addon=n,a._connectedTime=0,a._naviInfo=null,a.connectResolve=null,a._startTime=0,a._tcpDuration=0,a.pingResolve=null,a.addon.setConnectionStatusListener(a._onConnectionStatusChange.bind(a),(function(e){a.logger.info(Se.P_DB_OPEN_O,e)}),(function(){return a.recvPong(u.SUCCESS)}),a._onConnectionStatusChange.bind(a),a._onTcpConnectResponse.bind(a)),a}return _e(t,e),t.prototype.getConnectedTime=function(){return this._connectedTime},t.prototype.connectWithToken=function(e,t,n,o){var r=this;return new Promise((function(s){r._naviInfo=t,r.connectResolve={resolve:s,traceId:o,userId:t.userId};var i={},a=ze().data;a&&(i={proxy_passwd:a.socksPassword||"",proxy_name:a.socksUsername||"",proxy_port:a.socksPort||1082,proxy_host:a.socksHost||"localhost",proxy_type:0});var c=JSON.stringify(ye(ye({},i),{call_plus:r._openCallPlus})),p=r.getCmpList(t,!0).filter((function(e){return rt.includes(e.protocol)})).sort((function(e,t){return e.weight>t.weight?-1:1})),l=[];p.forEach((function(e){var t=l.find((function(t){return t.addr===e.addr}));t?t.protocol!==g.QUIC&&e.protocol!==g.QUIC||(t.race=!0,t.protocol=g.QUIC):(e.race=!1,l.push(e))})),r.logger.info(Se.P_CONNECT_O,JSON.stringify({use:l,catche:r.cmpWeightCache,proxy:i,FORMATED_VERSION:y,reconnectKickEnable:n}),o),r._startTime=Date.now();try{r.addon.connectWithToken(e,y,JSON.stringify(ye(ye({},t),{serverAddr:l})),n,c)}catch(e){r.logger.error(Se.P_CALL_ADDON_E,null==e?void 0:e.stack,o),r.recvConnectRes(u.RC_SOCKET_NOT_CREATED)}}))},t.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.addon.disconnect(t)},t.prototype.sendPing=function(e){var t=this;return new Promise((function(n){t.pingResolve=n,t.addon.sendHeartbeat(),setTimeout((function(){return t.recvPong(u.TIMEOUT)}),e)}))},t.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},t.prototype._onConnectionStatusChange=function(e,t){switch(this.logger.info(Se.P_CONNECT_S,JSON.stringify({status:e,delay:t})),e){case u.SUCCESS:this.recvConnectRes(u.SUCCESS);break;case u.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(u.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case u.RC_SOCKET_DISCONNECTED:this.recvConnectRes(e,!1);break;case u.RC_SOCKET_NOT_CREATED:case u.RC_CONN_ACK_TIMEOUT:case u.RC_TCP_RESET:this.recvConnectRes(e);break;case u.RC_UDP_DISCONNECTED:this.recvConnectRes(e,!0,t);break;default:this.recvConnectRes(e,!0)}},t.prototype.recvConnectRes=function(e,t,n){if(this.connectResolve){var o=this.connectResolve,r=o.resolve,s=o.userId,i=Date.now()-(this._startTime+this._tcpDuration),a={bid:m(),cod:e,net:this.getNetwork().type,dur:i,spr:0,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:P.CURRENT,count:this.retryCount};return this.statisticLog.__statistics(E.IM_CMP_RMTP,JSON.stringify(a)),e===u.SUCCESS&&(this._connectedTime=Date.now()-this.addon.getDeltaTime()),r({code:e,data:s}),void(this.connectResolve=null)}if(t)this.onDisconnectByServer(e,n);else{if(e===u.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==T.CONNECTED)return;this.onDisconenctUnusual(e)}},t.prototype._onTcpConnectResponse=function(e,t,n,o,r,s,i){var a,c=this.cmpWeightCache.findIndex((function(e){return e.addr==="".concat(t,":").concat(n)})),u={bid:m(),ptc:I.TCP,cod:e,net:this.getNetwork().type,dur:o,spr:0,pr:(null===(a=this._naviInfo)||void 0===a?void 0:a.type)||0,hos:"".concat(t,":").concat(n),idx:c,rct:this.retryCount?R.RECONNECT:R.CONNECT,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:P.CURRENT,rsn:this.reason,ddu:r,count:this.retryCount,weight:c>=0?this.cmpWeightCache[c].weight:-1};this.statisticLog.__statistics(E.IM_CMP,JSON.stringify(u)),this.logger.info(Se.P_CONNECT_ENTRY_S,JSON.stringify({code:e,host:t,port:n,duration:o,dnsDuration:r,index:s,isQuic:i})),e===$e.SUCCESS&&(this.curCmpUrl="".concat(t,":").concat(n),this.updateCmpWeight("".concat(t,":").concat(n),!0,i))},t}(N),Ct=function(e){function t(t,n,o,s){void 0===s&&(s=O.BJ);var i=e.call(this,t,n,s)||this;i.appkey=t,i.logger=n,i.dbpath=o,i._cachePath="",i._cachePath="".concat(o,"/").concat(st.STATIC_CONFIG(t));var a=r(i._cachePath);return ce(a)||dt(a),i}return _e(t,e),t.prototype.getCache=function(){return ce(this._cachePath)&&ue(this._cachePath,{encoding:"utf8"})||null},t.prototype.setCache=function(e){pe(this._cachePath,e)},t.prototype.clearCache=function(){pe(this._cachePath,"")},t.prototype.sendRequest=function(e){return me(this,void 0,void 0,(function(){var t,n,o;return Pe(this,(function(r){switch(r.label){case 0:return[4,Ye(this.logger,{url:e,body:""})];case 1:return t=r.sent(),n=t.status,o=t.data,[2,{code:n,data:o}]}}))}))},t.prototype.decryptData=function(e){return me(this,void 0,void 0,(function(){var t,n;return Pe(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,lt(e,w,U)];case 1:return t=o.sent(),[2,JSON.parse(t)];case 2:return n=o.sent(),this.logger.error(l.L_GET_STATIC_CONF_E,JSON.stringify({error:null==n?void 0:n.stack})),[3,3];case 3:return[2]}}))}))},t}(M),vt=function(e){function t(t,n,o,s,i,a){var c=e.call(this,n,t,o,a)||this;c.deviceId=s,c.model="",c.catchFilePath="",c.model="Electron|".concat(process.platform,"|").concat(process.arch),c.catchFilePath="".concat(i,"/").concat(st.CLOUD_CONTROL(t));var u=r(c.catchFilePath);return ce(u)||dt(u),c.init(),c}return _e(t,e),t.prototype.httpRequest=function(e,t,n,o){return me(this,void 0,void 0,(function(){var r,s,i,a,c,u,p,d;return Pe(this,(function(h){switch(h.label){case 0:return(r=o).deviceId=this.deviceId,r.model=this.model,s={url:e,method:t,headers:n,body:JSON.stringify(r)},this.logger.info(l.L_REQUEST_T,JSON.stringify(s)),[4,Ye(this.logger,s)];case 1:i=h.sent(),a=i.status,c=i.data,u=void 0===c?"":c,this.logger.info(l.L_REQUEST_R,JSON.stringify({status:a,data:u}));try{return p=JSON.parse(u),d=p.data,[2,{code:a,data:d}]}catch(e){return this.logger.warn(l.L_CLOUD_CONFIG_DATA_E,JSON.stringify({status:a,data:u,error:e})),[2,{code:a,msg:e}]}return[2]}}))}))},t.prototype.setCloudControllerCache=function(e){pe(this.catchFilePath,JSON.stringify(e)),this.logger.info(l.L_CLOUD_SET_CACHE_O,JSON.stringify(e))},t.prototype.getLocalCloudControllerCache=function(){if(!ce(this.catchFilePath))return null;var e=ue(this.catchFilePath,{encoding:"utf8"});return this.logger.info(l.L_CLOUD_GET_CACHE_O,JSON.stringify({appkey:this.appkey,data:e})),e},t}(b),_t=function(){function t(e,t,n,r){var i=this;this._appkey=e,this._cppProtocol=t,this._dbpath=n,this._logOutputLevel=r,this._customMessageType={},this.cloudControllerUri="",this.cloudControllerLock=!0,this.cloudControllerMsgs=[],this._senders={},this._chatroomCache=[],this.rtcHeartbeatResolves={};var a=this._dbpath||o(z.getPath("userData")),c=ct(a);this._cppProtocol.initWithAppkey(e,a,y);var p=X(o(__dirname,"sub-process.js"));this.subProxy=new pt(p);var l=o(a,"RongCloud/rclogs",e);dt(l),function(e,t,n){n.initLogModule(t,e,s())}(e,l,this._cppProtocol),this.logger=new we(this._appkey,"RC-M","IM"),this.statisticLog=new be(this._appkey,"RC-M","IM"),this.logger.setOutputLevel(this._logOutputLevel),Ne(this._cppProtocol,this.logger),this.reporter=new ot(this._cppProtocol,e,c,this.logger,this.subProxy),this.logger.info(Se.P_INIT_O,JSON.stringify({appkey:e,dbpath:a,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:c,commit:"825ddc3a28961c22ec8f101474497407edd6217b"})),this._callCppProxy("setDeviceId",c),this._staticConfigManager=new Ct(e,this.logger,a),this.navi=new ht(e,this.logger,this.statisticLog,a,this._staticConfigManager),this.tcpMgr=new gt(e,this._cppProtocol,this.navi,this.logger,this.statisticLog,{onConnected:this.onConnected.bind(this),onSuspend:this.onSuspend.bind(this),onDisconnected:this.onDisconnected.bind(this),onConnecting:this.onConnecting.bind(this)}),this._initCloudController(c,a),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),$.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return me(i,void 0,void 0,(function(){var o,r,s;return Pe(this,(function(i){switch(i.label){case 0:if("function"!=typeof(o=this[t]))return this.logger.error(Se.P_CALL_MAIN_SYNC_E,JSON.stringify({method:t,error:"not found"})),e.returnValue=u.NOT_SUPPORT,[2];r=u.NOT_SUPPORT,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,o.call.apply(o,Ee([this],n,!1))];case 2:return r=i.sent(),[3,4];case 3:return s=i.sent(),this.logger.error(Se.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]}}))}))})),$.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var o=[],r=3;r<arguments.length;r++)o[r-3]=arguments[r];return me(i,void 0,void 0,(function(){var r,s,i,a,c=this;return Pe(this,(function(p){switch(p.label){case 0:if("function"!=typeof(r=this[n]))return this.logger.error(Se.P_CALL_MAIN_E,JSON.stringify({method:n,error:"not found"})),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,u.NOT_SUPPORT),[2];"sendMessage"===n&&(s=o[3],o[3]=function(t){c._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",s,t)}),i=u.NOT_SUPPORT,p.label=1;case 1:return p.trys.push([1,3,,4]),[4,r.call.apply(r,Ee([this],o,!1))];case 2:return i=p.sent(),[3,4];case 3:return a=p.sent(),this.logger.error(Se.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]}}))}))})),$.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,Ee([i],n,!1))}catch(e){i.logger.error(Se.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else i.logger.error(Se.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),$.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new ut(this._cppProtocol)}return t.prototype._initCloudController=function(e,t){var n=x.getCloudControllerUrl();this.cloudControllerUri=n[0],this.cloudController=new vt(this._appkey,this.logger,this.reporter,e,t,this.statisticLog),L()&&this.cloudControllerUri&&this.cloudController.request(this.cloudControllerUri,A.init)},t.prototype.onConnected=function(){var e=this.getNaviInfoFromCache();this.reporter.checkStart(e),this._try2RejoinChatroom(),this._send2AllRenderer("onConnected",this.getMainProcessCache())},t.prototype.onConnecting=function(){this._send2AllRenderer("onConnecting",void 0)},t.prototype.onSuspend=function(e){this._send2AllRenderer("onSuspend",e)},t.prototype.onDisconnected=function(e){this._send2AllRenderer("onDisconnected",e)},t.prototype._callCppProxy=function(e){for(var t,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];var r=this.logger.createTraceId();try{return this.logger.debug(Se.P_CALL_ADDON_O,JSON.stringify({method:e,content:n}),r),(t=this._cppProtocol)[e].apply(t,n)}catch(t){this.logger.error(Se.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),r)}},t.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},t.prototype.sendHTTPRequest=function(e){return Ye(this.logger,e)},t.prototype.onRendererLogsReceived=function(e){Oe.apply(void 0,e)},t.prototype.onRendererNetworkStatusReceived=function(e,t){if(this.tcpMgr.setNetwork(e,t),e.status&&L()&&this.cloudController){var n=this.tcpMgr.getToken();this.cloudController.request(this.cloudControllerUri,A.newWorkChange,n)}},t.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){Re(),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(Se.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:u.NOT_SUPPORT});try{return o.call.apply(o,Ee([this],t,!1))}catch(t){this.logger.error(Se.P_CALL_EXTRA_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return Promise.resolve({code:u.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:u.MAIN_PROCESS_ERROR})}return Promise.resolve({code:u.SUCCESS,data:r})},t.prototype.getUnreadConversationList=function(e){var t,n=this,o=this._callCppProxy("getUnreadConversationList",e);try{t=JSON.parse(o).list.map((function(e){return n._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:u.MAIN_PROCESS_ERROR})}return Promise.resolve({code:u.SUCCESS,data:t})},t.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[D.PRIVATE,D.GROUP,D.SYSTEM,D.APP_PUBLIC_SERVICE,D.PUBLIC_SERVICE],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:u.MAIN_PROCESS_ERROR})}return Promise.resolve({code:u.SUCCESS,data:e})},t.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,o=this,r=[D.PRIVATE,D.GROUP,D.SYSTEM,D.APP_PUBLIC_SERVICE,D.PUBLIC_SERVICE],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:u.MAIN_PROCESS_ERROR})}return Promise.resolve({code:u.SUCCESS,data:n})},t.prototype.getHistoryMessagesByObjectNames=function(e,t,n,o,r,s,i){var a=0===s,c=o+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,c,r,a,i||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var h=0;h<d.length;h++){var f=this._buildMessage(d[h].obj);l[h]=f}}catch(e){return Promise.resolve({code:u.MAIN_PROCESS_ERROR})}return Promise.resolve({code:u.SUCCESS,data:{list:c===l.length?l.slice(1,c):l,hasMore:o<l.length}})},t.prototype.updateMessageReceiptStatus=function(e,t,n,o){void 0===o&&(o="");var r=this._callCppProxy("updateMessageReceiptStatus",e,t,n,o);return Promise.resolve({code:u.SUCCESS,data:r})},t.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==T.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},t.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new we(this._appkey,e,t)},t.prototype.getConnectedTime=function(){return this.tcpMgr.getConnectedTime()},t.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},t.prototype.getCurrentUserId=function(){return this.tcpMgr.getCurrentUserId()},t.prototype._send2Renderer=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,Ee([t],n,!1))},t.prototype._send2AllRenderer=function(e,t,n){var o=this;void 0===n&&(n=[]),Object.keys(this._senders).forEach((function(r){var s=o._senders[r];n.includes(s)||o._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},t.prototype.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),n=this.getNaviInfoFromCache(),o=this.tcpMgr.getCurrentUserId();return{connectedTime:e,deviceId:this.getDeviceId(),crtUserId:o,naviInfo:n,connectionStatus:t}},t.prototype._registerRenderers=function(e,t){var n=this,o=e.sender,r=o.id,s=t.navigators,i=t.areaCode,a=t.logServerUrl;this._staticConfigManager.setAreaCode(i),x.init({areaCode:i,navigators:s,logServerUrl:a}),this._senders[r]||(this._senders[r]=o,o.once("destroyed",(function(){delete n._senders[r]})))},t.prototype._registerMsgTypes=function(){for(var e in k["RC:RcCmd"]={isCounted:!1,isPersited:!1},k){var t=k[e],n=t.isCounted,o=t.isPersited,r=t.searchProps,s=0;o&&(s|=1),n&&(s|=2),"RC:TypSts"===e&&(s=16),this._callCppProxy("registerMessageType",e,s,r||[])}},t.prototype._buildIsMentioned=function(e,t){var n,o=!1;if(J(e))n=e;else try{n=e?JSON.parse(e):e}catch(o){n=e,this.logger.error(Se.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:t}))}return J(n)&&(o=!!n.mentionedInfo),{isMentioned:o,msgContent:n}},t.prototype._buildMsgOption=function(e){var t={isCounted:!1,isPersited:!1};return e in k?t=k[e]:e in this._customMessageType&&(t=this._customMessageType[e]),t},t.prototype._buildSupportExt=function(e,t,n){var o=null;return e&&(o=this._msgExpansionHandler.parseReceiveExpansion(n),"conversation"!==t&&"history"!==t||(o=this._msgExpansionHandler.parseConverOrHisExpansion(n))),o},t.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,o=t.buildFrom,r=JSON.parse(e),s=r.channelId,i=r.conversationType,a=r.targetId,c=r.senderUserId,u=r.content,p=r.objectName,l=r.messageUid,d=r.direction,h=r.status,f=r.messageId,g=r.sentTime,C=r.readReceiptRequest,v=r.supportExt,_=r.pushContent,S=r.pushTitle,y=r.pushId,m=r.pushConfig,P=r.templateId,E=r.disableTitle,T=r.forcePushDetail,I=r.hasMore,R=this._buildIsMentioned(u,f),N=R.isMentioned,O=R.msgContent,M=this._buildMsgOption(p),U=this._buildSupportExt(v,o,r),w=j(n)?g<this.tcpMgr.getConnectedTime():n,b={};m&&(b=B(this.logger,m,y));var x=ye(ye({},b),{pushTitle:S,pushContent:_,pushData:_,disablePushTitle:E,forceShowDetailContent:T,templateId:P}),L={channelId:s,conversationType:i,targetId:a,senderUserId:c,content:O||{},messageType:p,messageUId:l||"",messageDirection:d,isOffLineMessage:w,sentTime:g,receivedTime:0,isPersited:M.isPersited,isCounted:M.isCounted,isMentioned:N,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:v,expansion:v?U:null,receivedStatus:h,messageId:f,pushConfig:x,hasMore:I};if(d===H.RECEIVE?L.receivedStatus=h:d===H.SEND&&(L.sentStatus=h),C){var A=JSON.parse(C),D=A.hasRespond,k=A.readerInfo,J={readCount:A.readCount,totalCount:A.totalCount},F=[];if(k)for(var V in k)F.push({userId:V,readTime:k[V]});var G=this.getNaviInfoFromCache();1===(null==G?void 0:G.grpRRVer)&&(J.readerList=F,J.hasRespond=D),L.readReceiptInfo=J}return L},t.prototype._updateReadReceiptInfo=function(e,t){var n=this._callCppProxy("getMessage",e),o=JSON.parse(n),r=o.readReceiptRequest?JSON.parse(o.readReceiptRequest):{},s=ye(ye({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},t.prototype._processRSMsg=function(e){this.getNaviInfoFromCache();var t=e.conversationType,n=e.targetId,o=e.content,r=e.channelId,s=o.msgId,i=o.rrn,a=o.tmn,c=o.endMsgTime;t===D.PRIVATE?this.updateMessageReceiptStatus(t,n,c,r||""):this._updateReadReceiptInfo(s,{readCount:i,totalCount:a});var u={conversationType:t,targetId:n,channelId:r};this._sendMessageReadReceipt(t===D.PRIVATE?{privateReadReceipt:ye(ye({},u),{endMsgTime:o.endMsgTime})}:{groupReadReceipt:ye(ye({},u),{totalCount:o.tmn,readCount:o.rrn,messageUId:o.msgId})})},t.prototype._processSRSMsg=function(e){var t=this.getNaviInfoFromCache(),n=e.conversationType,o=e.targetId,r=e.content,s=e.channelId,i=e.senderUserId,a=e.sentTime;return i===this.tcpMgr.getCurrentUserId()&&(this._callCppProxy("clearUnreadCountByTimestamp",n,o,r.lastMessageSendTime,s||""),1!==(null==t?void 0:t.sesDriven)||(a>this.tcpMgr.getConnectedTime()||this._sendsyncReadStatus({conversationType:n,targetId:o,channelId:s,timestamp:r.timestamp}),!1))},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.blockStatus,u=t.matchCount,p=t.hasUnreadMention,l=t.conversationTime,d=t.draft,h=c>0?F.OPEN:F.CLOSE;return{channelId:n,conversationType:o,targetId:r,unreadMessageCount:s,latestMessage:-1===JSON.parse(i).messageId?null:this._buildMessage(i),hasMentioned:p,mentionedInfo:null,notificationStatus:h,isTop:a,lastUnreadTime:0,matchCount:u,operationTime:l,notificationLevel:c,draft:d}},t.prototype._convertResultList=function(e,t){var n=JSON.parse(e).list;return n=n.map((function(e){var n=JSON.parse(e.obj);return t?t(n):n}))},t.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,o,r){var s,i=e._buildMessage(t,{isOffLineMessage:o}),a=i.messageType,c=i.channelId,u=void 0===c?"":c,p=i.senderUserId,l=i.content;i.canIncludeExpansion;var d=i.messageUId,h=i.conversationType,f=i.targetId;if(e.getNaviInfoFromCache(),a!==V.LOG_COMMAND||p!==G){if(a===V.CLOUD_CONTROL&&p===G)return e.cloudControllerMsgs.push(i),void e._ccMsgHandler();if(a===V.GROUP_READ_RECEIPT_REQUEST){var g=l.msgId,C=l.rrn,v=l.tmn;e._updateReadReceiptInfo(g,{readCount:C,totalCount:v})}if(a!==V.READ_STATE){if("RC:MsgExMsg"===a)return e._msgExpansionHandler.setLocalFromExtMsg(e.logger,i),void e._sendMessageExpansion(i);if(a===V.READ_RECEIPT&&p===e.tcpMgr.getCurrentUserId()&&e._callCppProxy("clearUnreadCountByTimestamp",h,f,l.lastMessageSendTime,u),a!==V.SYNC_READ_STATUS||e._processSRSMsg(i)){var _=!0;if(0!==n||r||(_=!1),a===V.DELIVERED)return e._callCppProxy("setMessageDeliverTime",JSON.stringify(l)),void e._sendMessageDelivered(l.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}})));if(a!==V.DELIVERED_MSG){if(a===V.RECALL){e.handleRecalledMessage(i);var S=e._fixRecallContentInfo(i);h=S.conversationType,f=S.targetId}e._sendMessageNotification(Object.assign(i,{hasMoreMsg:_,conversationType:h,targetId:f}))}else{var y={totalCount:l.tmn,list:null===(s=l.dl)||void 0===s?void 0:s.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};e._sendGroupMessageDeliveredStatus(y)}}}else e._processRSMsg(i)}else{var m=l.startTime,P=l.endTime,E=l.platform,T=l.logId,I=l.uri;e.reporter.report(parseInt(m,10),parseInt(P,10),E,I,T,d)}}),(function(){e._sendPullOfflineFinished()}))},t.prototype._ccMsgHandler=function(){var e;return me(this,void 0,void 0,(function(){var t,n;return Pe(this,(function(o){switch(o.label){case 0:return this.cloudControllerLock?(this.cloudControllerLock=!1,this.cloudControllerMsgs.shift()?(t=this.tcpMgr.getToken(),[4,null===(e=this.cloudController)||void 0===e?void 0:e.request(this.cloudControllerUri,A.other,t)]):[3,2]):[2];case 1:n=o.sent()||0,this.cloudControllerMsgs=this.cloudControllerMsgs.filter((function(e){return e.sentTime>n})),this.cloudControllerLock=!0,this._ccMsgHandler(),o.label=2;case 2:return[2]}}))}))},t.prototype._fixRecallContentInfo=function(e){var t=e.conversationType,n=e.targetId;return e.senderUserId===this.tcpMgr.getCurrentUserId()&&(t=e.content.conversationType||t,n=e.content.targetId||n),{conversationType:t,targetId:n}},t.prototype.handleRecalledMessage=function(e){var t=e.content,n=t.messageUId,o=t.sentTime;if(n){var r=this._callCppProxy("getMessage",n),s=this._buildMessage(r,{isOffLineMessage:!1});if(e.content.isDelete){if(-1===s.messageId)return;this._callCppProxy("deleteMessages",[s.messageId])}else{var i={recallTime:Date.now(),admin:!!e.content.isAdmin,originalObjectName:s.messageType,originalMessageContent:s.content,recallActionTime:e.sentTime,operatorId:e.senderUserId};if(e.content.user&&(i.user=e.content.user),e.content.extra&&(i.extra=e.content.extra),s.messageType===V.TextMessage&&(i.recallContent=s.content.content),-1!==s.messageId)s.receivedStatus||this.setMessageReceivedStatus(s.messageId,1),this._callCppProxy("setMessageContent",s.messageId,JSON.stringify(i),V.RECALL_NOTIFICATION_MESSAGE);else{var a=e.conversationType,c=e.targetId,u=e.senderUserId,p=e.channelId,l=e.messageDirection;this._callCppProxy("insertMessage",a,c,u,V.RECALL_NOTIFICATION_MESSAGE,JSON.stringify(i),(function(){}),(function(){}),l,1,10,o,"",0,n,!1,!0,JSON.stringify({}),p||"")}}}},t.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var n=e.channelId,o=e.content,r=o.put,s=o.del,i=o.mid,a={};r&&(a.updatedExpansion={channelId:n,messageUId:i,expansion:r}),s&&(a.deletedExpansion={channelId:n,messageUId:i,deletedKeys:s}),this._send2AllRenderer("expansion",a,t)},t.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},t.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},t.prototype._sendMessageDelivered=function(e){this._send2AllRenderer("messageDelivered",e)},t.prototype._sendGroupMessageDeliveredStatus=function(e){this._send2AllRenderer("groupMessageDeliveredStatus",e)},t.prototype._sendChatroomStatus=function(e){this._send2AllRenderer("chatroom",e)},t.prototype._sendMessageReadReceipt=function(e){this._send2AllRenderer("messageReadReceipt",e)},t.prototype._sendsyncReadStatus=function(e){this._send2AllRenderer("syncReadStatus",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)?F.OPEN:F.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)}),(function(t,n,o,r){e._callCppProxy("clearUnreadCountByTimestamp",t,n,r,o||""),e._sendsyncReadStatus({conversationType:t,targetId:n,channelId:o,timestamp:r})}))},t.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._send2AllRenderer("tag",t),e._getRTCProfile()}))},t.prototype._getRTCProfile=function(){var e=this._callCppProxy("getRTCProfile");if(e){var t=this.tcpMgr.getToken();this.navi.updateVoipCallInfo(t,e);var n=this.navi.getNaviInfoFromCache(t);this._send2AllRenderer("onNaviDataChange",n)}},t.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var n=new Uint8Array(t).buffer;e._send2AllRenderer("onRTCDataChange",n)}))},t.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,n){e._sendChatroomStatus({chatroomDestroyed:t})}))},t.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},t.prototype._updateMentionedInfo=function(e,t,n){var o,r,s;return{userIdList:(null===(o=e.mentionedInfo)||void 0===o?void 0:o.userIdList)||t,type:(null===(r=e.mentionedInfo)||void 0===r?void 0:r.type)||n||q.ALL,mentionedContent:(null===(s=e.mentionedInfo)||void 0===s?void 0:s.mentionedContent)||""}},t.prototype.registerMessageType=function(e,t,n,o){void 0===o&&(o=[]);var r=0;t&&(r|=1),n&&(r|=2),this._customMessageType[e]={isCounted:n,isPersited:t},this.logger.info(Se.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){return this.tcpMgr.connect(e,t,n,o)},t.prototype.reportSDKInfo=function(e){var t,n,o=JSON.stringify(ye(ye({},e),{"electron-main":"5.8.5-alpha.3"}));this.logger.info(Se.P_REPORT_VER_O,o),null===(n=(t=this._cppProtocol).uploadSDKVersion)||void 0===n||n.call(t,o,"")},t.prototype.disconnect=function(e){this._chatroomCache.length=0,this.reporter.stop(),Xe(null,this.logger),this.tcpMgr.disconnect(e)},t.prototype.logout=function(){this.disconnect()},t.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,n){t({userId:e,status:n})}));var n=e.userIds||[];n.length&&this.subscribeUserStatus(n)},t.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(n){t._callCppProxy("subscribeUserStatus",e,(function(){n(u.SUCCESS)}),n)}))},t.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n){t._callCppProxy("setUserStatus",e,(function(){n(u.SUCCESS)}),n)}))},t.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getUserStatus",e,(function(e){n({code:u.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},t.prototype.sendMessage=function(e,t,n,o,r){var s=this;void 0===r&&(r=this.logger.createTraceId());var i=n.messageType,a=n.content,c=n.expansion,p=n.pushConfig,l=n.isMentioned,d=n.mentionedType,h=n.mentionedUserIdList,f=void 0===h?[]:h,g=n.pushContent,C=void 0===g?"":g,v=n.pushData,_=void 0===v?"":v,S=n.directionalUserIdList,y=void 0===S?[]:S,m=n.disableNotification,P=void 0!==m&&m,E=n.canIncludeExpansion,T=void 0!==E&&E,I=n.isVoipPush,R=void 0!==I&&I,N=n.channelId,O=void 0===N?"":N,M=n.messageId,U=void 0===M?0:M,w=p||{},b=w.iOSConfig,x=w.androidConfig,L=w.templateId,A=void 0===L?"":L,k=w.pushTitle,J=void 0===k?"":k,j=w.pushContent,B=void 0===j?C:j,H=w.pushData,F=void 0===H?_:H,G=w.disablePushTitle,q=void 0!==G&&G,W=w.forceShowDetailContent,Q=void 0!==W&&W,Y=K(b,x);return new Promise((function(n){C=B,_=F;var p=(null==x?void 0:x.notificationId)||"";e===D.GROUP&&l&&a&&(a.mentionedInfo=s._updateMentionedInfo(a,f,d));var h=e===D.GROUP;if(h&&i===V.READ_RECEIPT_RESPONSE&&a.receiptMessageDic)for(var g in a.receiptMessageDic)y.push(g);h&&i===V.SYNC_READ_STATUS&&(y=[s.getCurrentUserId()]);var v={};for(var g in c)v[g]={v:""},v[g].v=c[g];var S=A;s.logger.info(Se.P_SEND_MSG_T,JSON.stringify({messageType:i,conversationType:e,targetId:t,channelId:O}),r);var m=s._callCppProxy("sendMessage",(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.info(Se.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:o.messageUId}),r),t===u.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:u.SUCCESS,data:o}))}),(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.warn(Se.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),r),o.sentTime=Date.now()-s._cppProtocol.getDeltaTime(),n({code:t,data:o})}),e,t,i,JSON.stringify(a),y,P,q,Q,C,_,p,J,Y,S,T,JSON.stringify(v),R,O,U),E=JSON.parse(m);null==o||o(E.messageId)}))},t.prototype.recallMsg=function(e,t,n,o,r){var s=this;return new Promise((function(i){var a,c=r.user,p=r.pushContent,l=r.channelId,d=r.extra,h=r.pushConfig,f=r.disableNotification,g=r.isDelete,C={conversationType:e,targetId:t,messageUId:n,sentTime:o,user:c,extra:d,channelId:l,isDelete:g||!1};c&&(C.user=c),d&&(C.extra=d);var v={conversationType:e,targetId:t,senderUserId:s.tcpMgr.getCurrentUserId(),content:C,objectName:V.RECALL,messageUid:n,direction:H.SEND,status:W.UNREAD,sentTime:o,channelId:l},_=s._buildMessage(JSON.stringify(v),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){s.handleRecalledMessage(_),i({code:u.SUCCESS,data:_})}),(function(e){i({code:e})}),V.RECALL,JSON.stringify(C),f||!1,(null==h?void 0:h.disablePushTitle)||!1,(null==h?void 0:h.forceShowDetailContent)||!1,p||"",(null==h?void 0:h.pushData)||"",(null===(a=null==h?void 0:h.androidConfig)||void 0===a?void 0:a.notificationId)||"",(null==h?void 0:h.pushTitle)||"",K(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){n=n||0;var p=0===r,l=o+1,d=a._callCppProxy("getHistoryMessages",e,t,n,l,i,p,s),h=JSON.parse(d).list,f=[];h.reverse();for(var g=0;g<h.length;g++){var C=a._buildMessage(h[g].obj);f[g]=C}c({code:u.SUCCESS,data:{list:l===f.length?f.slice(1,l):f,hasMore:o<f.length}})}))},t.prototype.getMessages=function(e,t,n,o,r,s){var i=this;return void 0===n&&(n=0),new Promise((function(a){var c=0===r,p=n,l=0!==n,d=o+1;l&&(p+=c?1:-1,d++);for(var h=i._callCppProxy("getMessages",e,t,p,d,c,s),f=JSON.parse(h).list,g=[],C=0;C<f.length;C++){var v=i._buildMessage(f[C].obj);g[C]=v}var _=i._computeRepairInfo(g,c,n,p,d),S=_.isNeedRepair,y=void 0!==S&&S,m=_.repairTime,P=void 0===m?0:m;if(!y)return l&&(g.shift(),d--),g.reverse(),void a({code:u.SUCCESS,data:{list:d===g.length?g.slice(1,d):g,hasMore:o<g.length}});i._processRepairHisMsg(e,t,n,o,r,s,P,a)}))},t.prototype._computeRepairInfo=function(e,t,n,o,r){var s=!1,i=0,a=this.getNaviInfoFromCache()||{},c=a.repairHisMsg,u=void 0===c?0:c,p=a.historyMsg;if(1!==u||!p)return{isNeedRepair:s,repairTime:i};var l=e.findIndex((function(e){return e.hasMore||0===Object.keys(e.content).length}));return t&&l>=0?(s=!0,i=e[l].hasMore?e[l].sentTime:e[l].sentTime+1):!t&&l>=1?(s=!0,i=e[l-1].sentTime):0===n?(s=!0,i=0):e.length<r?(s=!0,i=n):e.length>0&&e[0].sentTime!==n&&(s=!0,i=o),{isNeedRepair:s,repairTime:i}},t.prototype._processRepairHisMsg=function(e,t,n,o,r,s,i,a){var c=this,u=function(i){for(var u=0===r,p=o+1,l=c._callCppProxy("getMessages",e,t,n,p,u,s),d=JSON.parse(l).list,h=[],f=0;f<d.length;f++){var g=c._buildMessage(d[f].obj);h[f]=g}h.reverse(),a({code:i,data:{list:p<=h.length?h.slice(1,p):h,hasMore:o<h.length}})},p=o+10>100?100:o+10;this._callCppProxy("getRemoteHistoryMessages",e,t,i,p,(function(){return u(0)}),(function(e){u(e)}),r,!0,s,!1)},t.prototype.getRemoteHistoryMessages=function(e,t,n,o,r,s){var i=this;return new Promise((function(a){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:u.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){var i=JSON.stringify(n);r._callCppProxy("deleteRemoteHistoryMessages",e,t,i,!1,o,(function(){s(u.SUCCESS)}),s)}))},t.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){s(u.SUCCESS)}),(function(e){s(e)}),o)}))},t.prototype.clearMessages=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("clearMessages",e,t,n),r(u.SUCCESS)}))},t.prototype.getConversationList=function(e,t,n,o,r){var s=this;return void 0===r&&(r=""),new Promise((function(e){for(var t=s._callCppProxy("getConversationList",[1,3,6,7],r),n=JSON.parse(t).list,o=[],i=0;i<n.length;i++)o.push(s._buildConversation(n[i].obj));e({code:u.SUCCESS,data:o})}))},t.prototype.getConversation=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getConversation",e,t,n);if(s)r({code:u.SUCCESS,data:o._buildConversation(s)});else{var i=o._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),a=void 0;try{a=JSON.parse(i).list}catch(e){o.logger.error(Se.P_PARSE_JSON_MSGS_E,null==e?void 0:e.stack),a=[]}var c=null;a.length>0&&(c=o._buildMessage(a[0].obj));var p=o._callCppProxy("getConversationNotificationStatus",e,t,n),l=o._callCppProxy("getConversationTopStatus",e,t,n);r({code:u.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:c,notificationStatus:p?F.OPEN:F.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?u.SUCCESS:u.CONVER_REMOVE_ERROR)},t.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(o){var r=[];r=Q(e)?e:[D.PRIVATE,D.GROUP,D.SYSTEM,D.PUBLIC_SERVICE],n._callCppProxy("clearConversations",r,t||""),o(u.SUCCESS)}))},t.prototype.getAllConversationUnreadCount=function(e,t,n){var o=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:u.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:u.SUCCESS,data:s})}))},t.prototype.clearConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r){o._callCppProxy("clearUnreadCount",e,t,n),r(u.SUCCESS)}))},t.prototype.clearUnreadCountByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("clearUnreadCountByTimestamp",e,t,n,o),s(u.SUCCESS)}))},t.prototype.getFirstUnreadMessage=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getTheFirstUnreadMessage",e,t,n),i=o._buildMessage(s);r({code:u.SUCCESS,data:-1!==i.messageId?i:null})}))},t.prototype.setConversationToTop=function(e,t,n,o){var r=this;return void 0===o&&(o=""),new Promise((function(s){r._callCppProxy("setConversationToTop",e,t,n,o,!0),s(u.SUCCESS)}))},t.prototype.setConversationHidden=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("setConversationHidden",e,t,n,o),s(u.SUCCESS)}))},t.prototype.setConversationNotificationStatus=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){s(u.SUCCESS)}),s,o)}))},t.prototype.setConversationStatus=function(e,t,n,o,r){var s=this;return new Promise((function(i){s._callCppProxy("setConversationStatus",e,t,n,o,(function(){i(u.SUCCESS)}),i,r,!0)}))},t.prototype.getConversationNotificationStatus=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getConversationNotificationStatus",e,t,n);r({code:u.SUCCESS,data:s?F.OPEN:F.CLOSE})}))},t.prototype.searchConversationByContent=function(e,t,n,o){var r=this;return new Promise((function(s){o=o||[1,3,6,7];for(var i=r._callCppProxy("searchConversationByContent",o,e,t,n),a=JSON.parse(i).list,c=[],p=0;p<a.length;p++)c[p]=r._buildConversation(a[p].obj);s({code:u.SUCCESS,data:c})}))},t.prototype.searchConversationByContentWithAllChannel=function(e,t,n){var o=this;return new Promise((function(r){n=n||[1,3,6,7];for(var s=o._callCppProxy("searchConversationByContentWithAllChannel",n,e,t),i=JSON.parse(s).list,a=[],c=0;c<i.length;c++)a[c]=o._buildConversation(i[c].obj);r({code:u.SUCCESS,data:a})}))},t.prototype.searchMessageByContent=function(e,t,n,o,r,s,i){var a=this;return new Promise((function(s){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:u.SUCCESS,data:{messages:o,count:t}})}),i)}))},t.prototype.searchMessagesByUser=function(e,t,n,o,r,s){var i=this;return new Promise((function(a){i._callCppProxy("getMessageBySender",e,t,n,o,r,s,(function(e){for(var t=e?JSON.parse(e).list:[],n=[],o=0;o<t.length;o++)n[o]=i._buildMessage(t[o].obj);a({code:u.SUCCESS,data:{messages:n}})}))}))},t.prototype.searchMessageByContentWithAllChannel=function(e,t,n,o,r){var s=this;return new Promise((function(i){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:u.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){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:u.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){t._callCppProxy("addToBlacklist",e,(function(){n(u.SUCCESS)}),n)}))},t.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n){t._callCppProxy("removeFromBlacklist",e,(function(){n(u.SUCCESS)}),n)}))},t.prototype.getBlacklist=function(){var e=this;return new Promise((function(t){e._callCppProxy("getBlacklist",(function(e){t({code:u.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},t.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:u.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,p=n.sentStatus,l=n.sentTime,d=n.searchContent,h=n.isUnread,f=n.messageUId,g=n.disableNotification,C=n.canIncludeExpansion,v=n.expansionMsg,_=n.channelId;r=JSON.stringify(r);var S={};if(l=l||0,v){var y=JSON.parse(v);for(var m in y)S[m]={v:"",ts:0},S[m].v=y[m],S[m].ts=l}return new Promise((function(n){var v=h?0:1,y=o._callCppProxy("insertMessage",e,t,s,i,r,(function(){}),(function(e){n({code:e})}),a,c||0,p||10,l,d||"",v,f||"",!!g,!!C,JSON.stringify(S),_||""),m=o._buildMessage(y,{isOffLineMessage:!1});m.messageUId=f,m.sentTime=l,n({code:-1===m.messageId?u.MSG_INSERT_ERROR:u.SUCCESS,data:m})}))},t.prototype.batchInsertMessage=function(e,t){var n=this;return void 0===t&&(t=!1),new Promise((function(o){var r=e.map((function(e){var t=e.content,n=e.senderUserId,o=e.messageType,r=e.messageDirection,s=e.receivedStatus,i=e.sentStatus,a=e.sentTime,c=e.searchContent,u=e.isUnread,p=e.messageUId,l=e.disableNotification,d=e.canIncludeExpansion,h=e.expansion,f=e.channelId,g=e.conversationType,C=e.targetId,v=e.source,_=e.isMentioned,S={};if(a=a||0,h)for(var y in h)S[y]={v:"",ts:0},S[y].v=h[y],S[y].ts=a;return{conversationType:g,targetId:C,channelId:f||"",direction:r,senderUserId:n,status:i||10,sentTime:a,objectName:o,content:JSON.stringify(t),messageUid:p||"",noNotification:!!l,supportExt:!!d,extMsg:JSON.stringify(S),readStatus:s||0,searchContent:c||"",isUnread:!!u,source:v||"",isMention:_}})),s=n._callCppProxy("insertMessages",JSON.stringify(r),t);o({code:s?u.SUCCESS:u.MSG_INSERT_ERROR,data:s||!1})}))},t.prototype.getMessageCount=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getMessageCount",e,t,n);r({code:u.SUCCESS,data:s})}))},t.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n){t._callCppProxy("deleteMessages",e),n(u.SUCCESS)}))},t.prototype.deleteMessagesByTimestamp=function(e,t,n,o,r){var s=this;return new Promise((function(i){s._callCppProxy("deleteMessagesByTimestamp",e,t,n,o,r),i(u.SUCCESS)}))},t.prototype.getMessage=function(e){var t=this;return new Promise((function(n){var o=t._callCppProxy("getMessage",e),r=t._buildMessage(o,{isOffLineMessage:!1});n({code:u.SUCCESS,data:r})}))},t.prototype.setMessageContent=function(e,t,n){var o=this;return new Promise((function(r){t=JSON.stringify(t),o._callCppProxy("setMessageContent",e,t,n),r(u.SUCCESS)}))},t.prototype.setMessageSearchField=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("setMessageSearchField",e,t,n),r(u.SUCCESS)}))},t.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("setMessageSentStatus",e,t),o(u.SUCCESS)}))},t.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("setMessageReceivedStatus",e,t),o(u.SUCCESS)}))},t.prototype.saveConversationMessageDraft=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("saveTextMessageDraft",e,t,n,o||"")&&s(u.SUCCESS),s(u.DRAFT_SAVE_ERROR)}))},t.prototype.getConversationMessageDraft=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getTextMessageDraft",e,t,n||"");r({code:u.SUCCESS,data:s})}))},t.prototype.clearConversationMessageDraft=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("clearTextMessageDraft",e,t,n||"")&&r(u.SUCCESS),r(u.DRAFT_REMOVE_ERROR)}))},t.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},t.prototype.batchSetConversationStatus=function(e){var t=e[0],n=t.conversationType,o=t.targetId,r=t.isTop,s=t.notificationStatus,i=t.channelId,a=this._callCppProxy("getConversationNotificationStatus",n,o,i||""),c=this._callCppProxy("getConversationTopStatus",n,o,i||""),u=j(s)?Boolean(a):s===F.OPEN,p=j(r)?Boolean(c):r;return this.setConversationStatus(n,o,u,p,i)},t.prototype.getConversationNotificationLevel=function(e,t,n){return me(this,void 0,void 0,(function(){var o;return Pe(this,(function(r){return o=this._callCppProxy("getBlockPushLevelForConversation",t,n,e),[2,Promise.resolve({code:u.SUCCESS,data:o})]}))}))},t.prototype.setConversationNotificationLevel=function(e,t,n,o){var r=this;return void 0===o&&(o=""),new Promise((function(s){r._callCppProxy("setBlockPushLevelForConversation",t,o,e,n,(function(){s(u.SUCCESS)}),(function(e){s(e)}))}))},t.prototype.getTotalUnreadCountByLevels=function(e,t,n){if(n){var o=this._callCppProxy("getUnreadMentionedCountByLevel",e,t);return Promise.resolve({code:u.SUCCESS,data:o})}var r=this._callCppProxy("getUnreadCountByLevel",e,t);return Promise.resolve({code:u.SUCCESS,data:r})},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(Se.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),r({code:u.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getMessageReader=function(e,t,n){var o=this;return new Promise((function(r){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:u.SUCCESS,data:{list:s,totalMemberCount:n}})}),(function(e){r({code:e})}))}))},t.prototype.sendReadReceiptMessageV4=function(e,t,n){var o=this;return new Promise((function(r){var s=e.conversationType,i=e.targetId,a=e.channelId;o._callCppProxy("sendMessageReadReceipt",s,i,a||"",t,n,(function(){r({code:u.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getMessageReadReceiptV4=function(e,t){var n=this;return new Promise((function(o){var r=e.targetId,s=e.channelId;n._callCppProxy("getMessageReadReceipt",r,s||"",t,(function(e){var t=[];try{JSON.parse(e).list.forEach((function(e){var n=JSON.parse(e.obj),o=n.id,r=n.time;t.push({userId:o,readTime:r})}))}catch(t){n.logger.error(Se.P_PARSE_JSON_E,"method: getMessageReadReceipt, info: ".concat(e,", error: ").concat(t))}o({code:u.SUCCESS,data:t})}),(function(e){o({code:e})}))}))},t.prototype.updateConversationReadTime=function(e,t){var n=this;return new Promise((function(o){var r=e.conversationType,s=e.targetId,i=e.channelId;n._callCppProxy("updateConversationReadTime",r,s,i||"",t,(function(){o({code:u.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype._addChatroomCache=function(e,t,n){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:n,count:t})},t.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},t.prototype._try2RejoinChatroom=function(){var e=this;if(0!==this._chatroomCache.length){var t=this.logger.createTraceId();this._chatroomCache.forEach((function(n){return me(e,void 0,void 0,(function(){var e,o,r,s,i,a;return Pe(this,(function(c){switch(c.label){case 0:return e=n.chatroomId,o=n.joinExist,r=n.count,this.logger.info(l.L_REJOIN_CHATROOM_T,e,t),[4,this._joinChrm(e,r,o,!1)];case 1:return s=c.sent(),i=s.code,a=s.data,i===u.SUCCESS?(this.logger.info(l.L_REJOIN_CHATROOM_R,e,t),this._sendChatroomStatus({rejoinedRoom:ye({chatroomId:e,count:r},a)}),[2]):(i===u.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(e),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,errorCode:i}}),this.logger.warn(l.L_REJOIN_CHATROOM_R,"chrmId: ".concat(e,", code: ").concat(i),t),[2])}}))}))}))}},t.prototype._joinChrm=function(e,t,n,o){var r=this,s=n?"joinExistChatRoom":"joinChatRoom";return new Promise((function(i){o&&r._callCppProxy("clearMessages",D.CHATROOM,e,""),r._callCppProxy(s,e,t,(function(o,s,a,c,p,l){r._addChatroomCache(e,t,n),i({code:u.SUCCESS,data:{createTime:Number(o),memberCount:s,isAllChatroomBanned:a,isCurrentUserBanned:c,isCurrentChatroomBanned:p,isCurrentChatroomInWhitelist:l}})}),(function(e){i({code:e})}))}))},t.prototype.joinChatroom=function(e,t){return me(this,void 0,void 0,(function(){return Pe(this,(function(n){switch(n.label){case 0:return[4,this._joinChrm(e,t,!1,!0)];case 1:return[2,n.sent().code]}}))}))},t.prototype.joinExistChatroom=function(e,t){return this._joinChrm(e,t,!0,!0)},t.prototype.quitChatroom=function(e){var t=this;return this._rmChatroomCache(e),new Promise((function(n){t._callCppProxy("quitChatRoom",e,(function(){n(u.SUCCESS)}),n)}))},t.prototype.getChatroomInfo=function(e,t,n){var o=this;return new Promise((function(r){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:u.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){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:u.SUCCESS,data:t})}),(function(e){s({code:e})}),"")}))},t.prototype.setChatroomEntry=function(e,t){var n=this;return new Promise((function(o){var r='[{"key":"'.concat(t.key,'", "value":"').concat(t.value,'"}]');n._callCppProxy("setChatroomKV",e,r,!!t.isAutoDelete,!!t.isOverwrite,(function(){o(u.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:u.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.setChatroomEntry(e,t)},t.prototype.removeChatroomEntry=function(e,t){var n=this,o=[t.key];return new Promise((function(r){n._callCppProxy("deleteChatroomKV",e,o,!!t.isOverwrite,(function(){r(u.SUCCESS)}),(function(e){r(e)}))}))},t.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.removeChatroomEntry(e,t)},t.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(o){var r=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){o({code:u.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.getChatroomEntry=function(e,t){return me(this,void 0,void 0,(function(){var n;return Pe(this,(function(o){switch(o.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=o.sent()).code===u.SUCCESS?[2,{code:u.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){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:u.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},t.prototype.getFileToken=function(e,t,n,o,r){var s=this;return void 0===r&&(r=""),n=n||"",o=o||"",new Promise((function(i){var a;a=o&&"uploads"!==o?t||"":Y(e,t),s._callCppProxy("getUploadToken",e,a,n,o,r,(function(e,t,n,o,r,s,c,p,l,d,h,f,g,C,v,_,S,y,m,P,E,T,I){i({code:u.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:o,osskeyId:r,ossPolicy:s,ossSign:c,ossBucketName:p,fileName:a,s3Credential:l,s3Algorithm:d,s3Date:h,s3Policy:f,s3Signature:g,s3BucketName:C,stcAuthorization:v,stcContentSha256:_,stcDate:S,stcBucketName:y,minioAuthorization:m,minioContentSha256:P,minioDate:E,minioBucketName:T,downloadAuthInfo:I?JSON.parse(I):null}})}),(function(e){i({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:u.SUCCESS,data:{downloadUrl:e}})}),(function(e){s({code:e})}))}))},t.prototype.clearData=function(){var e=this;return new Promise((function(t){var n=e._callCppProxy("clearData");t({code:u.SUCCESS,data:n})}))},t.prototype.getDeviceId=function(){var e=this._dbpath||o(z.getPath("userData"));return ct(e)},t.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("getVoIPKey",e,t,"",(function(e){o({code:u.SUCCESS,data:e})}),(function(e){o({code:e})}))}))},t.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n){var o=e.chatRoomId,r=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",o,r,(function(){n(u.SUCCESS)}),(function(e){n(e)}))}))},t.prototype.getGroupMessageDeliverList=function(e,t,n){var o=this;return new Promise((function(r){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:u.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){var r=n._callCppProxy("getMessageDeliverTime",e);if(r)o({code:u.SUCCESS,data:r});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:u.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:u.SUCCESS,buffer:t})}),(function(e){o({code:e})}),30)}))},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],30)}))},t.prototype.createTag=function(e){var t=this;return new Promise((function(n){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:u.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.removeTag=function(e){var t=this;return new Promise((function(n){t._callCppProxy("deleteTag",e,(function(){n({code:u.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.updateTag=function(e){var t=this;return new Promise((function(n){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:u.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.getTagList=function(){var e=this;return new Promise((function(t){var n=e._callCppProxy("getTags"),o=e._convertResultList(n,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:u.SUCCESS,data:o})}))},t.prototype.addTagForConversations=function(e,t){var n=this;return new Promise((function(o){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){o({code:u.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(o){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){o({code:u.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){o({code:u.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 ye(ye({},r._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:u.SUCCESS,data:a})}))},t.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(o){var r=n._callCppProxy("getConversationUnreadCountForTag",e,t);o({code:u.SUCCESS,data:r})}))},t.prototype.setConversationStatusInTag=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.isTop||!1,(function(){r({code:u.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(n){var o=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||""),r=t._convertResultList(o,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:u.SUCCESS,data:r})}))},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=j(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:u.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 me(this,void 0,void 0,(function(){var t;return Pe(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:u.SUCCESS,data:t}]}))}))},t.prototype.getMainProcessInfo=function(){return me(this,void 0,void 0,(function(){return Pe(this,(function(e){return[2,{code:u.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:u.SUCCESS,data:{key:e,value:t}})}),(function(e){r({code:e})}))}))},t.prototype.setProxy=function(e){return this.tcpMgr.getConnectionStatus()!==T.DISCONNECTED?Promise.resolve({code:u.RC_CONN_PROXY_UNAVAILABLE}):Promise.resolve(Xe(e,this.logger))},t.prototype.getProxy=function(){return Promise.resolve(ze())},t.prototype.testProxy=function(e,t){return function(e,t,n){return new Promise((function(o){var r=/^https/.test(t)?We:Ge;n.info(l.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:e,testHost:t}));var s=r(t,e,(function(e){var t=200===e.statusCode?0:e.statusCode;e.setEncoding("utf8");var n="";e.on("data",(function(e){n+=e})),e.once("end",(function(){o({status:t||0,data:n})}))}));s.once("timeout",(function(){return o({status:0})})),s.once("error",(function(e){return o({status:0,data:e.stack})})),s.end()}))}(e,t,this.logger)},t.prototype.checkDuplicateMessage=function(e){var t=this;return new Promise((function(n){var o=t._callCppProxy("checkDuplicateMessage",e);n({code:u.SUCCESS,data:o})}))},t}(),St=function(){function e(e,t,n,o){void 0===n&&(n=""),this._cppService=new _t(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}(),yt=function(e){return function(e,t,n){if(ft)return ft;if(!t)throw new Error("Initializ failed, `appkey` is required!");return ft=new St(t,e,null==n?void 0:n.dbpath,null==n?void 0:n.logOutputLevel)}(Ce,e.appkey,e)};export{yt as default};
|
|
1
|
+
import*as e from"os";import{platform as t,arch as n}from"os";import{resolve as o,dirname as r}from"path";import{getUUID as s,BasicLogger as i,BasicStatistic as a,appendUrl as c,ErrorCode as u,HTTP_TIMEOUT as p,LogTagId as l,StoreKeys as d,BasicReporter as h,REAT_TIME_LOG_SIZE as f,EConnectProtocol as g,notEmptyObject as C,NAVI_CACHE_DURATION as v,BasicNavi as _,NAVI_REQ_TIMEOUT as S,FORMATED_VERSION as y,getbundleId as m,StatisticsVersion as P,StatisticsTag as E,RCConnectionStatus as T,ProtocalType as I,ConnectType as R,AConnectionMgr as N,AreaCode as O,BasicStaticConfigManager as M,STATIC_CONFIG_IV as U,STATIC_CONFIG_KEY as w,BaseCloudController as b,urlCenter as x,isStartCloudController as L,InvokerType as A,ConversationType as D,SEND_MESSAGE_TYPE_OPTION as k,isObject as J,isUndefined as j,pushJSONToConfigs as B,MessageDirection as H,NotificationStatus as F,MessageType as V,RC_DEFAULT_USER as G,MentionedType as q,pushConfigsToJSON as K,ReceivedStatus as W,isArray as Q,getUploadFileName as Y}from"@rongcloud/engine";import{fork as X}from"child_process";import{app as z,ipcMain as $}from"electron";import{Agent as Z,request as ee}from"http";import{Agent as te,request as ne}from"https";import{parse as oe}from"url";import{isIP as re,Socket as se}from"net";import{EventEmitter as ie}from"events";import{connect as ae}from"tls";import{existsSync as ce,readFileSync as ue,writeFileSync as pe,mkdirSync as le}from"fs";import{createHash as de,createDecipheriv as he}from"crypto";var fe=o(__dirname,"binding","electron-".concat(t(),"-").concat(n(),".node")),ge={addon:null};try{ge.addon=require(fe)}catch(e){console.error("error ->",fe,"\n",e)}ge.addon||console.error("error -> cannot find module: ",fe);var Ce=ge.addon,ve=function(e,t){return ve=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])},ve(e,t)};function _e(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}ve(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var Se,ye=function(){return ye=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},ye.apply(this,arguments)};function me(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 Pe(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 Ee(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_ADDON_T="P-call_addon-T",e.P_CALL_ADDON_O="P-call_addon-O",e.P_CALL_ADDON_R="P-call_addon-R",e.P_CALL_EXTRA_E="P-call_extra-E",e.P_CONNECT_S="P-connect-S",e.P_CONNECT_T="P-connect-T",e.P_CONNECT_O="P-connect-O",e.P_CONNECT_ENTRY_S="P-connect_entry-S",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",e.P_PARSE_JSON_E="P-parse_json-E"}(Se||(Se={}));var Te,Ie={flushTimestamp:Date.now(),queue:[],locked:!1};function Re(){Te&&clearInterval(Te)}function Ne(e,t){Re(),Te=setInterval((function(){return Ue(e,t)}),1e4)}function Oe(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];(e=Ie.queue).push.apply(e,t)}var Me=200;function Ue(e,t){var n=Ie.queue,o=Ie.flushTimestamp;if(!(Ie.locked||0===n.length||Date.now()-o<3e4&&n.length<Me)){Ie.locked=!0;var r=t.createTraceId(),s=n.splice(0,Me).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(Se.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(n.length),r);var i=JSON.stringify(s);e.writeLog(i),t.debug(Se.P_WRITE_LOG_R,"write done, queueLen: ".concat(n.length),r),Ie.flushTimestamp=Date.now(),Ie.locked=!1,setTimeout((function(){return Ue(e,t)}))}}var we=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return _e(t,e),t.prototype.flush=function(e){Oe(e)},t}(i),be=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return _e(t,e),t.prototype.flush=function(e){Oe(e)},t}(a),xe=function(e,t){var n,o=Buffer.from(e),r=o.length;for(t.push(r),n=0;n<r;n++)t.push(o[n])},Le=function(e){return"string"==typeof e},Ae=function(e){return Le(e)?e.toUpperCase():""},De=function(e,t){var n="";return 2!==e.length?n="Unexpected number of bytes received.":5!==e[0]?n="Unexpected SOCKS version number: ".concat(e[0],"."):255===e[1]?n="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(n="Unexpected SOCKS authentication method: ".concat(e[1],".")),n},ke=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: ".concat(e[0],"."):0!==e[1]&&(t="Username and password authentication failure: ".concat(e[1],".")),t},Je=function(e){var t=Ae(e.method)||"GET",n=e.pathname||"/",o=e.headers||{},r=e.search||"";o.Host=e.host||"loclahost";var s="";for(var i in s="".concat(t," ").concat(n+r," HTTP/1.1\n"),o)if(Object.hasOwnProperty.call(o,i)){var a=o[i];s+="".concat(i,": ").concat(a,"\n")}return e.body&&(s+="Content-Length: ".concat(e.body.length,"\n")),s+="\n","POST"===t&&e.body&&(s+="".concat(e.body)),s},je=function(e){return new Promise((function(t){var n,o;e.socket.once("data",(function(o){var r,s=De(o,n);if(!s)return 2===o[1]?(e.socket.once("data",(function(n){var o=ke(n);o?e.emit("error",new Error("SOCKS authentication failed. ".concat(o))):t()})),r=[1],xe(e.socksUsername,r),xe(e.socksPassword,r),void e.write(Buffer.from(r))):void t();e.emit("error",new Error("SOCKS authentication failed. ".concat(s)))})),n=[0],e.socksUsername&&n.push(2),(o=Buffer.alloc(2+n.length))[0]=5,o[1]=n.length,n.forEach((function(e,t){o[2+t]=e})),e.write(o)}))},Be=function(e,t,n){return new Promise((function(o){var r,s;switch(e.socket.once("data",(function(t){var n;5!==t[0]?n="Unexpected SOCKS version number: ".concat(t[0],"."):0!==t[1]?n="".concat(function(e){switch(e){case 1:return"General SOCKS server failure";case 2:return"Connection not allowed by ruleset";case 3:return"Network unreachable";case 4:return"Host unreachable";case 5:return"Connection refused";case 6:return"TTL expired";case 7:return"Command not supported";case 8:return"Address type not supported";default:return"Unknown status code ".concat(e)}}(t[1]),"."):0!==t[2]&&(n="The reserved byte must be 0x00."),n?e.emit("error",new Error("SOCKS connection failed. ".concat(n))):o()})),(r=[]).push(5),r.push(1),r.push(0),re(t)){case 0:r.push(3),xe(t,r);break;case 4:r.push(1),function(e,t){var n,o,r=e.split(".");for(n=0;n<4;n++)o=parseInt(r[n],10),t.push(o)}(t,r);break;case 6:e.emit("error",new Error("Does not support IPV6"))}r.length+=2,(s=Buffer.from(r)).writeUInt16BE(n,s.length-2),e.write(s)}))},He=function(e){function t(t){var n=e.call(this)||this;return n.readable=!0,n.socket=new se,n.options=t,n.socksHost=t.socksHost||"localhost",n.socksPort=t.socksPort||1080,n.socksUsername=t.socksUsername||"",n.socksPassword=t.socksPassword||"",n.socket.on("error",(function(e){n.emit("error",e)})),n.on("error",(function(){n.socket.destroyed||n.socket.destroy()})),n.on("end",n.end),n}return _e(t,e),t.prototype.ref=function(){return this.socket.ref()},t.prototype.unref=function(){return this.socket.unref()},t.prototype.setTimeout=function(e,t){return this.socket.setTimeout(e,t)},t.prototype.setNoDelay=function(e){return this.socket.setNoDelay(e)},t.prototype.setKeepAlive=function(e,t){return this.socket.setKeepAlive(e,t)},t.prototype.address=function(){return this.socket.address()},t.prototype.cork=function(){return this.socket.cork()},t.prototype.uncork=function(){return this.socket.uncork()},t.prototype.pause=function(){return this.socket.pause()},t.prototype.resume=function(){return this.socket.resume()},t.prototype.pipe=function(e){return this.socket.pipe(e)},t.prototype.end=function(e,t){var n=this.socket.end(e,t);return this.writable=this.socket.writable,n},t.prototype.destroy=function(e){return this.socket.destroy(e)},t.prototype.setEncoding=function(e){return this.socket.setEncoding(e)},t.prototype.write=function(e,t,n){return this.socket.write(e,t,n)},t.prototype.read=function(e){return this.socket.read(e)},t.prototype.connect=function(e,t){var n=this;if("string"==typeof e&&/^\d+$/.test(e)&&(e=parseInt(e,10)),!Number.isInteger(e)||e<1||e>65535)throw new TypeError("Invalid port: ".concat(e));if(!t||"string"!=typeof t)throw new TypeError("Invalid host: ".concat(t));return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return me(n,void 0,void 0,(function(){var n;return Pe(this,(function(o){switch(o.label){case 0:return[4,je(this)];case 1:return o.sent(),[4,Be(this,t,e)];case 2:return o.sent(),this.onProxied(),n=Je(this.options),this.socket.write(Buffer.from(n)),[2]}}))}))})),this},t.prototype.onProxied=function(){var e=this;this.socket.on("close",(function(t){e.emit("close",t)})),this.socket.on("end",(function(){e.emit("end")})),this.socket.on("data",(function(t){e.emit("data",t)})),this.writable=!0,this.readable=!0,this.emit("connect")},t}(ie),Fe=function(e){var t,n=e.hostname,o=e.port;return!e.host||n&&o||(t=e.host.split(":")),!o&&t&&(o=parseInt(t[1],10)||0),!n&&t&&(n=t[0]),new He(e).connect(o,n)},Ve=function(e){function t(t){var n=e.call(this)||this;return n.createConnection=Fe,n}return _e(t,e),t}(Z),Ge=function(e,t,n){return(t=ye(ye({},t),oe(e))).port||(t.port=80),t.agent=new Ve(t),ee(t,n)},qe=function(e){var t,n;return t=Fe(e),n=t.onProxied,t.onProxied=function(){e.socket=t.socket,e.hostname?e.servername=e.hostname:e.host&&(e.servername=e.host.split(":")[0]),t.socket=ae(e,(function(){t.authorized=t.socket.authorized,n.call(t)})),t.socket.on("error",(function(e){t.emit("error",e)}))},t},Ke=function(e){function t(t,n){var o=e.call(this,n)||this;return o.url=t,o.socksHost=n.socksHost||"localhost",o.socksPort=n.socksPort||1080,o.createConnection=qe,o}return _e(t,e),t}(te),We=function(e,t,n,o){var r,s;return t.protocol="https:",!t.port&&t.host&&(r=t.host.split(":"),t.port=r[0],t.port=r[1]),t.port||(t.port=443),s=new Ke(e,t),t.agent=s,ne(e,t,n)},Qe=null;function Ye(e,t,n){void 0===n&&(n=!1);var o=t.url,r=t.headers,s=t.body,i=t.method,a=t.query,u=t.timeout,l=void 0===u?p:u;return new Promise((function(t){var u=/^https/.test(o),p={headers:r,method:i};u&&(p.rejectUnauthorized=n);var d=null;Qe?((p=ye(ye({},p),Qe)).body=s,d=u?We:Ge):(d=ee,u&&(p.agent=new te(p),d=ne));var h=d(c(o,a),p,(function(e){var n=e.statusCode,o="";e.setEncoding("utf8"),e.on("data",(function(e){o+=e})),e.once("end",(function(){t({status:n||0,data:o})}))}));h.once("timeout",(function(){e.warn(Se.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:o,method:i,query:a,timeout:l})),t({status:0})})),h.setTimeout(l),h.once("error",(function(n){e.warn(Se.P_HTTP_REQ_E,JSON.stringify({msg:n.stack,url:o,method:i,query:a,timeout:l})),t({status:0})})),h.write(s),h.end()}))}function Xe(e,t){return e?(Qe=ye(ye({},Qe),e),t.info(l.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:Qe})),{code:u.SUCCESS}):(Qe=null,t.info(l.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:u.SUCCESS})}function ze(){var e=Qe||void 0;return{code:u.SUCCESS,data:e}}var $e,Ze=[],et=function(e){return me(void 0,void 0,void 0,(function(){return Pe(this,(function(t){return[2,new Promise((function(t){Ze.push({resolve:t,args:e}),nt()}))]}))}))},tt=!1,nt=function(){return me(void 0,void 0,void 0,(function(){var e,t,n,o,r,s,i,a,c,u,p;return Pe(this,(function(l){return tt||0===Ze.length||(tt=!0,e=Ze.shift(),t=e.args,n=e.resolve,o=t.addon,r=t.startTime,s=t.endTime,i=t.level,a=t.realtimeReport,c=0,u=0,p=[],o.setLogEventListener((function(e){c+=e.length;var t=e.split(","),o=t[0],r=t[1],s=t[2],l=t[3],d=t[4],h=t.slice(5);if(c>f&&parseInt(r,10)!==u)n(p);else{u=parseInt(r,10);try{var g=JSON.parse(decodeURIComponent(h.join(","))),C=g.loggerId,v=g.sessionId,_=g.content,S=g.traceId;if(!a&&i<0)return;var y={time:parseInt(r,10),level:parseInt(l,10),sessionId:"".concat(o,":").concat(v),type:s,tag:d,loggerId:C,content:_,traceId:S};p.push(y)}catch(e){console.error(e)}}}),(function(e){n(p),tt=!1,nt()}),(function(e,t,n){})),o.pullFullLog(i,r,s,!1)),[2]}))}))},ot=function(e){function t(t,n,o,r,s){var i=this,a=process.versions.electron,c="Electron|".concat(a,"|").concat(process.arch,"|").concat(process.platform);return(i=e.call(this,n,o,c,{getLogs:function(e,n,o,r){return me(this,void 0,void 0,(function(){return Pe(this,(function(s){switch(s.label){case 0:return[4,et({startTime:e,endTime:n,level:o,realtimeReport:r,addon:t})];case 1:return[2,{logs:s.sent(),dbReady:!0}]}}))}))},getTimestamp4RealtimeLog:function(){var e=t.getStoreValue(d.REALTIME_LOG_TIMESTAMP);return parseInt(e,10)||0},setTimestamp4RealtimeLog:function(e){t.setStoreValue(d.REALTIME_LOG_TIMESTAMP,e.toString())}},r)||this).subProcess=s,i}return _e(t,e),t.prototype.send=function(e){return Ye(this.logger,e)},t.prototype.compressLogs=function(e){return me(this,void 0,void 0,(function(){var t,n,o;return Pe(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}(h),rt=[g.RMTP,g.TLS,g.QUIC],st={NAVI:function(e){return"RongCloud/navis/".concat(e,"/navi-cache.json")},DEVICE_ID:"deviceId",STATIC_CONFIG:function(e){return"RongCloud/caches/".concat(e,"/staticConfig.json")},CLOUD_CONTROL:function(e){return"RongCloud/cloudControl/".concat(e,"/cloudControl.json")}},it=null,at=function(){var e,o=Date.now(),r=[n(),t(),process.pid,o,Math.floor(Math.random()*o)].join("__");return e=r,de("md5").update(e).digest("hex")},ct=function(e){if(it)return it;var t=o(e,st.DEVICE_ID);return ce(t)?it=ue(t).toString():(it=at(),pe(t,it),it)},ut=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(Se.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:o,ext:r})),this._cppProto.setMessageExtension(t,n,o,i,s)},e.prototype.setLocalFromReceiveMsg=function(e,t){var n=t.channelId,o=t.conversationType,r=t.targetId,s=t.messageUId,i=t.expansion,a=t.sentTime,c={};for(var u in i)c[u]={v:"",ts:0},c[u].v=i[u],c[u].ts=a;this._setToProtocol(e,o,r,s,c,n||"")},e.prototype.setLocalFromExtMsg=function(e,t){var n=t.channelId,o=t.conversationType,r=t.targetId,s=t.content,i=t.sentTime,a=s,c=a.put,u=this._cppProto.getMessage(a.mid),p=JSON.parse(u).extMsg,l=JSON.parse(p||"{}");if(c)for(var d in c){var h=l[d];h&&h.ts<i-this._setTime?(h.v=c[d],h.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}(),pt=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 me(this,void 0,void 0,(function(){var n=this;return Pe(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}(),lt=function(e,t,n){return me(void 0,void 0,void 0,(function(){var o,r;return Pe(this,(function(s){return o=he("aes-256-cbc",t,n),r=o.update(e,"base64","utf-8"),[2,r+=o.final("utf8")]}))}))},dt=function(e){if(!ce(e)){var t=o(e,"..");ce(t)||dt(t),le(e)}},ht=function(e){function t(t,n,o,s,i){var a=e.call(this,t,n,o,i)||this;a.naviPath="",a._caches={},a.naviPath="".concat(s,"/").concat(st.NAVI(t));var c=r(a.naviPath);return ce(c)||dt(c),a}return _e(t,e),t.prototype.httpRequest=function(e,t,n,o){return me(this,void 0,void 0,(function(){var r,s,i,a,c;return Pe(this,(function(p){switch(p.label){case 0:return r="token=".concat(encodeURIComponent(n),"&v=").concat(y,"&p=PC&ev=").concat("5.8.5-alpha.4"),s="".concat(e,"/navi.json?r=").concat(Date.now()),this.logger.debug(l.L_REQUEST_T,JSON.stringify({url:s,body:r}),o),[4,Ye(this.logger,{method:"POST",headers:{appId:t},body:r,url:s,timeout:S})];case 1:if(200!==(i=p.sent()).status)return this.logger.warn(l.L_REQUEST_R,JSON.stringify({url:s,code:i.status}),o),[2,{code:this.transHttpCode(i.status)}];try{return a=JSON.parse(i.data),c=/^https/.test(s)?"https":"http",a.protocol=c,[2,{code:u.SUCCESS,data:a}]}catch(e){return this.logger.error(l.L_PARSE_NAVI_E,i.data,o),[2,{code:u.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},t.prototype.httpRequestV2=function(e,t,n,o){return me(this,void 0,void 0,(function(){var r,s,i,a;return Pe(this,(function(c){switch(c.label){case 0:return r=this.getNaviV2RequestOption({appkey:t,token:n,uri:e,platform:"electron",protocol:rt.join(",")}),this.logger.debug(l.L_REQUEST_T,JSON.stringify({url:r.url,body:r.body,headers:r.headers}),o),[4,Ye(this.logger,r)];case 1:if(200!==(s=c.sent()).status)return this.logger.warn(l.L_REQUEST_R,JSON.stringify({url:r.url,code:s.status}),o),[2,{code:this.transHttpCode(s.status)}];try{return i=JSON.parse(s.data),a=/^https/.test(r.url)?"https":"http",i.protocol=a,[2,{code:u.SUCCESS,data:i}]}catch(e){return this.logger.error(l.L_PARSE_NAVI_E,s.data,o),[2,{code:u.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},t.prototype.getNaviCache=function(e){var t=this._caches[e];if(t)return t;if(!ce(this.naviPath))return null;var n=ue(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(n),this._caches[e]}catch(e){this.logger.error(l.L_PARSE_NAVI_E,n)}return null},t.prototype.setNaviCache=function(e,t){var n=Date.now();if(C(this._caches))for(var o in this._caches){var r=this._caches[o];(n-r.timestamp>v||e===r.token)&&delete this._caches[o]}this._caches[e]={token:e,naviInfo:t,timestamp:Date.now()},pe(this.naviPath,JSON.stringify(this._caches))},t}(_);!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.NOT_INIT=-1]="NOT_INIT",e[e.CANCELED=-2]="CANCELED",e[e.REPEAT=-3]="REPEAT"}($e||($e={}));var ft,gt=function(e){function t(t,n,o,r,s,i){var a=e.call(this,t,o,r,s,i)||this;return a.addon=n,a._connectedTime=0,a._naviInfo=null,a.connectResolve=null,a._startTime=0,a._tcpDuration=0,a.pingResolve=null,a.addon.setConnectionStatusListener(a._onConnectionStatusChange.bind(a),(function(e){a.logger.info(Se.P_DB_OPEN_O,e)}),(function(){return a.recvPong(u.SUCCESS)}),a._onConnectionStatusChange.bind(a),a._onTcpConnectResponse.bind(a)),a}return _e(t,e),t.prototype.getConnectedTime=function(){return this._connectedTime},t.prototype.connectWithToken=function(e,t,n,o){var r=this;return new Promise((function(s){r._naviInfo=t,r.connectResolve={resolve:s,traceId:o,userId:t.userId};var i={},a=ze().data;a&&(i={proxy_passwd:a.socksPassword||"",proxy_name:a.socksUsername||"",proxy_port:a.socksPort||1082,proxy_host:a.socksHost||"localhost",proxy_type:0});var c=JSON.stringify(ye(ye({},i),{call_plus:r._openCallPlus})),p=r.getCmpList(t,!0).filter((function(e){return rt.includes(e.protocol)})).sort((function(e,t){return e.weight>t.weight?-1:1})),l=[];p.forEach((function(e){var t=l.find((function(t){return t.addr===e.addr}));t?t.protocol!==g.QUIC&&e.protocol!==g.QUIC||(t.race=!0,t.protocol=g.QUIC):(e.race=!1,l.push(e))})),r.logger.info(Se.P_CONNECT_O,JSON.stringify({use:l,catche:r.cmpWeightCache,proxy:i,FORMATED_VERSION:y,reconnectKickEnable:n}),o),r._startTime=Date.now();try{r.addon.connectWithToken(e,y,JSON.stringify(ye(ye({},t),{serverAddr:l})),n,c)}catch(e){r.logger.error(Se.P_CALL_ADDON_E,null==e?void 0:e.stack,o),r.recvConnectRes(u.RC_SOCKET_NOT_CREATED)}}))},t.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.addon.disconnect(t)},t.prototype.sendPing=function(e){var t=this;return new Promise((function(n){t.pingResolve=n,t.addon.sendHeartbeat(),setTimeout((function(){return t.recvPong(u.TIMEOUT)}),e)}))},t.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},t.prototype._onConnectionStatusChange=function(e,t){switch(this.logger.info(Se.P_CONNECT_S,JSON.stringify({status:e,delay:t})),e){case u.SUCCESS:this.recvConnectRes(u.SUCCESS);break;case u.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(u.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case u.RC_SOCKET_DISCONNECTED:this.recvConnectRes(e,!1);break;case u.RC_SOCKET_NOT_CREATED:case u.RC_CONN_ACK_TIMEOUT:case u.RC_TCP_RESET:this.recvConnectRes(e);break;case u.RC_UDP_DISCONNECTED:this.recvConnectRes(e,!0,t);break;default:this.recvConnectRes(e,!0)}},t.prototype.recvConnectRes=function(e,t,n){if(this.connectResolve){var o=this.connectResolve,r=o.resolve,s=o.userId,i=Date.now()-(this._startTime+this._tcpDuration),a={bid:m(),cod:e,net:this.getNetwork().type,dur:i,spr:0,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:P.CURRENT,count:this.retryCount};return this.statisticLog.__statistics(E.IM_CMP_RMTP,JSON.stringify(a)),e===u.SUCCESS&&(this._connectedTime=Date.now()-this.addon.getDeltaTime()),r({code:e,data:s}),void(this.connectResolve=null)}if(t)this.onDisconnectByServer(e,n);else{if(e===u.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==T.CONNECTED)return;this.onDisconenctUnusual(e)}},t.prototype._onTcpConnectResponse=function(e,t,n,o,r,s,i){var a,c=this.cmpWeightCache.findIndex((function(e){return e.addr==="".concat(t,":").concat(n)})),u={bid:m(),ptc:I.TCP,cod:e,net:this.getNetwork().type,dur:o,spr:0,pr:(null===(a=this._naviInfo)||void 0===a?void 0:a.type)||0,hos:"".concat(t,":").concat(n),idx:c,rct:this.retryCount?R.RECONNECT:R.CONNECT,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:P.CURRENT,rsn:this.reason,ddu:r,count:this.retryCount,weight:c>=0?this.cmpWeightCache[c].weight:-1};this.statisticLog.__statistics(E.IM_CMP,JSON.stringify(u)),this.logger.info(Se.P_CONNECT_ENTRY_S,JSON.stringify({code:e,host:t,port:n,duration:o,dnsDuration:r,index:s,isQuic:i})),e===$e.SUCCESS&&(this.curCmpUrl="".concat(t,":").concat(n),this.updateCmpWeight("".concat(t,":").concat(n),!0,i))},t}(N),Ct=function(e){function t(t,n,o,s){void 0===s&&(s=O.BJ);var i=e.call(this,t,n,s)||this;i.appkey=t,i.logger=n,i.dbpath=o,i._cachePath="",i._cachePath="".concat(o,"/").concat(st.STATIC_CONFIG(t));var a=r(i._cachePath);return ce(a)||dt(a),i}return _e(t,e),t.prototype.getCache=function(){return ce(this._cachePath)&&ue(this._cachePath,{encoding:"utf8"})||null},t.prototype.setCache=function(e){pe(this._cachePath,e)},t.prototype.clearCache=function(){pe(this._cachePath,"")},t.prototype.sendRequest=function(e){return me(this,void 0,void 0,(function(){var t,n,o;return Pe(this,(function(r){switch(r.label){case 0:return[4,Ye(this.logger,{url:e,body:""})];case 1:return t=r.sent(),n=t.status,o=t.data,[2,{code:n,data:o}]}}))}))},t.prototype.decryptData=function(e){return me(this,void 0,void 0,(function(){var t,n;return Pe(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,lt(e,w,U)];case 1:return t=o.sent(),[2,JSON.parse(t)];case 2:return n=o.sent(),this.logger.error(l.L_GET_STATIC_CONF_E,JSON.stringify({error:null==n?void 0:n.stack})),[3,3];case 3:return[2]}}))}))},t}(M),vt=function(e){function t(t,n,o,s,i,a){var c=e.call(this,n,t,o,a)||this;c.deviceId=s,c.model="",c.catchFilePath="",c.model="Electron|".concat(process.platform,"|").concat(process.arch),c.catchFilePath="".concat(i,"/").concat(st.CLOUD_CONTROL(t));var u=r(c.catchFilePath);return ce(u)||dt(u),c.init(),c}return _e(t,e),t.prototype.httpRequest=function(e,t,n,o){return me(this,void 0,void 0,(function(){var r,s,i,a,c,u,p,d;return Pe(this,(function(h){switch(h.label){case 0:return(r=o).deviceId=this.deviceId,r.model=this.model,s={url:e,method:t,headers:n,body:JSON.stringify(r)},this.logger.info(l.L_REQUEST_T,JSON.stringify(s)),[4,Ye(this.logger,s)];case 1:i=h.sent(),a=i.status,c=i.data,u=void 0===c?"":c,this.logger.info(l.L_REQUEST_R,JSON.stringify({status:a,data:u}));try{return p=JSON.parse(u),d=p.data,[2,{code:a,data:d}]}catch(e){return this.logger.warn(l.L_CLOUD_CONFIG_DATA_E,JSON.stringify({status:a,data:u,error:e})),[2,{code:a,msg:e}]}return[2]}}))}))},t.prototype.setCloudControllerCache=function(e){pe(this.catchFilePath,JSON.stringify(e)),this.logger.info(l.L_CLOUD_SET_CACHE_O,JSON.stringify(e))},t.prototype.getLocalCloudControllerCache=function(){if(!ce(this.catchFilePath))return null;var e=ue(this.catchFilePath,{encoding:"utf8"});return this.logger.info(l.L_CLOUD_GET_CACHE_O,JSON.stringify({appkey:this.appkey,data:e})),e},t}(b),_t=function(){function t(e,t,n,r){var i=this;this._appkey=e,this._cppProtocol=t,this._dbpath=n,this._logOutputLevel=r,this._customMessageType={},this.cloudControllerUri="",this.cloudControllerLock=!0,this.cloudControllerMsgs=[],this._senders={},this._chatroomCache=[],this.rtcHeartbeatResolves={};var a=this._dbpath||o(z.getPath("userData")),c=ct(a);this._cppProtocol.initWithAppkey(e,a,y);var p=X(o(__dirname,"sub-process.js"));this.subProxy=new pt(p);var l=o(a,"RongCloud/rclogs",e);dt(l),function(e,t,n){n.initLogModule(t,e,s())}(e,l,this._cppProtocol),this.logger=new we(this._appkey,"RC-M","IM"),this.statisticLog=new be(this._appkey,"RC-M","IM"),this.logger.setOutputLevel(this._logOutputLevel),Ne(this._cppProtocol,this.logger),this.reporter=new ot(this._cppProtocol,e,c,this.logger,this.subProxy),this.logger.info(Se.P_INIT_O,JSON.stringify({appkey:e,dbpath:a,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:c,commit:"23bf7f5f228abc7e8f381662d31522ea85f5d906"})),this._callCppProxy("setDeviceId",c),this._staticConfigManager=new Ct(e,this.logger,a),this.navi=new ht(e,this.logger,this.statisticLog,a,this._staticConfigManager),this.tcpMgr=new gt(e,this._cppProtocol,this.navi,this.logger,this.statisticLog,{onConnected:this.onConnected.bind(this),onSuspend:this.onSuspend.bind(this),onDisconnected:this.onDisconnected.bind(this),onConnecting:this.onConnecting.bind(this)}),this._initCloudController(c,a),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),$.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];return me(i,void 0,void 0,(function(){var o,r,s;return Pe(this,(function(i){switch(i.label){case 0:if("function"!=typeof(o=this[t]))return this.logger.error(Se.P_CALL_MAIN_SYNC_E,JSON.stringify({method:t,error:"not found"})),e.returnValue=u.NOT_SUPPORT,[2];r=u.NOT_SUPPORT,i.label=1;case 1:return i.trys.push([1,3,,4]),[4,o.call.apply(o,Ee([this],n,!1))];case 2:return r=i.sent(),[3,4];case 3:return s=i.sent(),this.logger.error(Se.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]}}))}))})),$.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,n){for(var o=[],r=3;r<arguments.length;r++)o[r-3]=arguments[r];return me(i,void 0,void 0,(function(){var r,s,i,a,c=this;return Pe(this,(function(p){switch(p.label){case 0:if("function"!=typeof(r=this[n]))return this.logger.error(Se.P_CALL_MAIN_E,JSON.stringify({method:n,error:"not found"})),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,u.NOT_SUPPORT),[2];"sendMessage"===n&&(s=o[3],o[3]=function(t){c._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",s,t)}),i=u.NOT_SUPPORT,p.label=1;case 1:return p.trys.push([1,3,,4]),[4,r.call.apply(r,Ee([this],o,!1))];case 2:return i=p.sent(),[3,4];case 3:return a=p.sent(),this.logger.error(Se.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]}}))}))})),$.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,Ee([i],n,!1))}catch(e){i.logger.error(Se.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else i.logger.error(Se.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),$.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new ut(this._cppProtocol)}return t.prototype._initCloudController=function(e,t){var n=x.getCloudControllerUrl();this.cloudControllerUri=n[0],this.cloudController=new vt(this._appkey,this.logger,this.reporter,e,t,this.statisticLog),L()&&this.cloudControllerUri&&this.cloudController.request(this.cloudControllerUri,A.init)},t.prototype.onConnected=function(){var e=this.getNaviInfoFromCache();this.reporter.checkStart(e),this._try2RejoinChatroom(),this._send2AllRenderer("onConnected",this.getMainProcessCache())},t.prototype.onConnecting=function(){this._send2AllRenderer("onConnecting",void 0)},t.prototype.onSuspend=function(e){this._send2AllRenderer("onSuspend",e)},t.prototype.onDisconnected=function(e){this._send2AllRenderer("onDisconnected",e)},t.prototype._callCppProxy=function(e){for(var t,n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];var r=this.logger.createTraceId();try{return this.logger.debug(Se.P_CALL_ADDON_O,JSON.stringify({method:e,content:n}),r),(t=this._cppProtocol)[e].apply(t,n)}catch(t){this.logger.error(Se.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),r)}},t.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},t.prototype.sendHTTPRequest=function(e){return Ye(this.logger,e)},t.prototype.onRendererLogsReceived=function(e){Oe.apply(void 0,e)},t.prototype.onRendererNetworkStatusReceived=function(e,t){if(this.tcpMgr.setNetwork(e,t),e.status&&L()&&this.cloudController){var n=this.tcpMgr.getToken();this.cloudController.request(this.cloudControllerUri,A.newWorkChange,n)}},t.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){Re(),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(Se.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:u.NOT_SUPPORT});try{return o.call.apply(o,Ee([this],t,!1))}catch(t){this.logger.error(Se.P_CALL_EXTRA_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return Promise.resolve({code:u.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:u.MAIN_PROCESS_ERROR})}return Promise.resolve({code:u.SUCCESS,data:r})},t.prototype.getUnreadConversationList=function(e){var t,n=this,o=this._callCppProxy("getUnreadConversationList",e);try{t=JSON.parse(o).list.map((function(e){return n._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:u.MAIN_PROCESS_ERROR})}return Promise.resolve({code:u.SUCCESS,data:t})},t.prototype.getConversationListWithAllChannel=function(){var e,t=this,n=[D.PRIVATE,D.GROUP,D.SYSTEM,D.APP_PUBLIC_SERVICE,D.PUBLIC_SERVICE],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:u.MAIN_PROCESS_ERROR})}return Promise.resolve({code:u.SUCCESS,data:e})},t.prototype.getConversationListWithAllChannelByPage=function(e,t){var n,o=this,r=[D.PRIVATE,D.GROUP,D.SYSTEM,D.APP_PUBLIC_SERVICE,D.PUBLIC_SERVICE],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:u.MAIN_PROCESS_ERROR})}return Promise.resolve({code:u.SUCCESS,data:n})},t.prototype.getHistoryMessagesByObjectNames=function(e,t,n,o,r,s,i){var a=0===s,c=o+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,n,c,r,a,i||""),l=[];try{var d=JSON.parse(p).list;d.reverse();for(var h=0;h<d.length;h++){var f=this._buildMessage(d[h].obj);l[h]=f}}catch(e){return Promise.resolve({code:u.MAIN_PROCESS_ERROR})}return Promise.resolve({code:u.SUCCESS,data:{list:c===l.length?l.slice(1,c):l,hasMore:o<l.length}})},t.prototype.updateMessageReceiptStatus=function(e,t,n,o){void 0===o&&(o="");var r=this._callCppProxy("updateMessageReceiptStatus",e,t,n,o);return Promise.resolve({code:u.SUCCESS,data:r})},t.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==T.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},t.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new we(this._appkey,e,t)},t.prototype.getConnectedTime=function(){return this.tcpMgr.getConnectedTime()},t.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},t.prototype.getCurrentUserId=function(){return this.tcpMgr.getCurrentUserId()},t.prototype._send2Renderer=function(e,t){for(var n=[],o=2;o<arguments.length;o++)n[o-2]=arguments[o];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,Ee([t],n,!1))},t.prototype._send2AllRenderer=function(e,t,n){var o=this;void 0===n&&(n=[]),Object.keys(this._senders).forEach((function(r){var s=o._senders[r];n.includes(s)||o._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},t.prototype.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),n=this.getNaviInfoFromCache(),o=this.tcpMgr.getCurrentUserId();return{connectedTime:e,deviceId:this.getDeviceId(),crtUserId:o,naviInfo:n,connectionStatus:t}},t.prototype._registerRenderers=function(e,t){var n=this,o=e.sender,r=o.id,s=t.navigators,i=t.areaCode,a=t.logServerUrl;this._staticConfigManager.setAreaCode(i),x.init({areaCode:i,navigators:s,logServerUrl:a}),this._senders[r]||(this._senders[r]=o,o.once("destroyed",(function(){delete n._senders[r]})))},t.prototype._registerMsgTypes=function(){for(var e in k["RC:RcCmd"]={isCounted:!1,isPersited:!1},k){var t=k[e],n=t.isCounted,o=t.isPersited,r=t.searchProps,s=0;o&&(s|=1),n&&(s|=2),"RC:TypSts"===e&&(s=16),this._callCppProxy("registerMessageType",e,s,r||[])}},t.prototype._buildIsMentioned=function(e,t){var n,o=!1;if(J(e))n=e;else try{n=e?JSON.parse(e):e}catch(o){n=e,this.logger.error(Se.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:t}))}return J(n)&&(o=!!n.mentionedInfo),{isMentioned:o,msgContent:n}},t.prototype._buildMsgOption=function(e){var t={isCounted:!1,isPersited:!1};return e in k?t=k[e]:e in this._customMessageType&&(t=this._customMessageType[e]),t},t.prototype._buildSupportExt=function(e,t,n){var o=null;return e&&(o=this._msgExpansionHandler.parseReceiveExpansion(n),"conversation"!==t&&"history"!==t||(o=this._msgExpansionHandler.parseConverOrHisExpansion(n))),o},t.prototype._buildMessage=function(e,t){void 0===t&&(t={});var n=t.isOffLineMessage,o=t.buildFrom,r=JSON.parse(e),s=r.channelId,i=r.conversationType,a=r.targetId,c=r.senderUserId,u=r.content,p=r.objectName,l=r.messageUid,d=r.direction,h=r.status,f=r.messageId,g=r.sentTime,C=r.readReceiptRequest,v=r.supportExt,_=r.pushContent,S=r.pushTitle,y=r.pushId,m=r.pushConfig,P=r.templateId,E=r.disableTitle,T=r.forcePushDetail,I=r.hasMore,R=this._buildIsMentioned(u,f),N=R.isMentioned,O=R.msgContent,M=this._buildMsgOption(p),U=this._buildSupportExt(v,o,r),w=j(n)?g<this.tcpMgr.getConnectedTime():n,b={};m&&(b=B(this.logger,m,y));var x=ye(ye({},b),{pushTitle:S,pushContent:_,pushData:_,disablePushTitle:E,forceShowDetailContent:T,templateId:P}),L={channelId:s,conversationType:i,targetId:a,senderUserId:c,content:O||{},messageType:p,messageUId:l||"",messageDirection:d,isOffLineMessage:w,sentTime:g,receivedTime:0,isPersited:M.isPersited,isCounted:M.isCounted,isMentioned:N,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:v,expansion:v?U:null,receivedStatus:h,messageId:f,pushConfig:x,hasMore:I};if(d===H.RECEIVE?L.receivedStatus=h:d===H.SEND&&(L.sentStatus=h),C){var A=JSON.parse(C),D=A.hasRespond,k=A.readerInfo,J={readCount:A.readCount,totalCount:A.totalCount},F=[];if(k)for(var V in k)F.push({userId:V,readTime:k[V]});var G=this.getNaviInfoFromCache();1===(null==G?void 0:G.grpRRVer)&&(J.readerList=F,J.hasRespond=D),L.readReceiptInfo=J}return L},t.prototype._updateReadReceiptInfo=function(e,t){var n=this._callCppProxy("getMessage",e),o=JSON.parse(n),r=o.readReceiptRequest?JSON.parse(o.readReceiptRequest):{},s=ye(ye({},r),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},t.prototype._processRSMsg=function(e){this.getNaviInfoFromCache();var t=e.conversationType,n=e.targetId,o=e.content,r=e.channelId,s=o.msgId,i=o.rrn,a=o.tmn,c=o.endMsgTime;t===D.PRIVATE?this.updateMessageReceiptStatus(t,n,c,r||""):this._updateReadReceiptInfo(s,{readCount:i,totalCount:a});var u={conversationType:t,targetId:n,channelId:r};this._sendMessageReadReceipt(t===D.PRIVATE?{privateReadReceipt:ye(ye({},u),{endMsgTime:o.endMsgTime})}:{groupReadReceipt:ye(ye({},u),{totalCount:o.tmn,readCount:o.rrn,messageUId:o.msgId})})},t.prototype._processSRSMsg=function(e){var t=this.getNaviInfoFromCache(),n=e.conversationType,o=e.targetId,r=e.content,s=e.channelId,i=e.senderUserId,a=e.sentTime;return i===this.tcpMgr.getCurrentUserId()&&(this._callCppProxy("clearUnreadCountByTimestamp",n,o,r.lastMessageSendTime,s||""),1!==(null==t?void 0:t.sesDriven)||(a>this.tcpMgr.getConnectedTime()||this._sendsyncReadStatus({conversationType:n,targetId:o,channelId:s,timestamp:r.timestamp}),!1))},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.blockStatus,u=t.matchCount,p=t.hasUnreadMention,l=t.conversationTime,d=t.draft,h=c>0?F.OPEN:F.CLOSE;return{channelId:n,conversationType:o,targetId:r,unreadMessageCount:s,latestMessage:-1===JSON.parse(i).messageId?null:this._buildMessage(i),hasMentioned:p,mentionedInfo:null,notificationStatus:h,isTop:a,lastUnreadTime:0,matchCount:u,operationTime:l,notificationLevel:c,draft:d}},t.prototype._convertResultList=function(e,t){var n=JSON.parse(e).list;return n=n.map((function(e){var n=JSON.parse(e.obj);return t?t(n):n}))},t.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,n,o,r){var s,i=e._buildMessage(t,{isOffLineMessage:o}),a=i.messageType,c=i.channelId,u=void 0===c?"":c,p=i.senderUserId,l=i.content;i.canIncludeExpansion;var d=i.messageUId,h=i.conversationType,f=i.targetId;if(e.getNaviInfoFromCache(),a!==V.LOG_COMMAND||p!==G){if(a===V.CLOUD_CONTROL&&p===G)return e.cloudControllerMsgs.push(i),void e._ccMsgHandler();if(a===V.GROUP_READ_RECEIPT_REQUEST){var g=l.msgId,C=l.rrn,v=l.tmn;e._updateReadReceiptInfo(g,{readCount:C,totalCount:v})}if(a!==V.READ_STATE){if("RC:MsgExMsg"===a)return e._msgExpansionHandler.setLocalFromExtMsg(e.logger,i),void e._sendMessageExpansion(i);if(a===V.READ_RECEIPT&&p===e.tcpMgr.getCurrentUserId()&&e._callCppProxy("clearUnreadCountByTimestamp",h,f,l.lastMessageSendTime,u),a!==V.SYNC_READ_STATUS||e._processSRSMsg(i)){var _=!0;if(0!==n||r||(_=!1),a===V.DELIVERED)return e._callCppProxy("setMessageDeliverTime",JSON.stringify(l)),void e._sendMessageDelivered(l.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}})));if(a!==V.DELIVERED_MSG){if(a===V.RECALL){e.handleRecalledMessage(i);var S=e._fixRecallContentInfo(i);h=S.conversationType,f=S.targetId}e._sendMessageNotification(Object.assign(i,{hasMoreMsg:_,conversationType:h,targetId:f}))}else{var y={totalCount:l.tmn,list:null===(s=l.dl)||void 0===s?void 0:s.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};e._sendGroupMessageDeliveredStatus(y)}}}else e._processRSMsg(i)}else{var m=l.startTime,P=l.endTime,E=l.platform,T=l.logId,I=l.uri;e.reporter.report(parseInt(m,10),parseInt(P,10),E,I,T,d)}}),(function(){e._sendPullOfflineFinished()}))},t.prototype._ccMsgHandler=function(){var e;return me(this,void 0,void 0,(function(){var t,n;return Pe(this,(function(o){switch(o.label){case 0:return this.cloudControllerLock?(this.cloudControllerLock=!1,this.cloudControllerMsgs.shift()?(t=this.tcpMgr.getToken(),[4,null===(e=this.cloudController)||void 0===e?void 0:e.request(this.cloudControllerUri,A.other,t)]):[3,2]):[2];case 1:n=o.sent()||0,this.cloudControllerMsgs=this.cloudControllerMsgs.filter((function(e){return e.sentTime>n})),this.cloudControllerLock=!0,this._ccMsgHandler(),o.label=2;case 2:return[2]}}))}))},t.prototype._fixRecallContentInfo=function(e){var t=e.conversationType,n=e.targetId;return e.senderUserId===this.tcpMgr.getCurrentUserId()&&(t=e.content.conversationType||t,n=e.content.targetId||n),{conversationType:t,targetId:n}},t.prototype.handleRecalledMessage=function(e){var t=e.content,n=t.messageUId,o=t.sentTime;if(n){var r=this._callCppProxy("getMessage",n),s=this._buildMessage(r,{isOffLineMessage:!1});if(e.content.isDelete){if(-1===s.messageId)return;this._callCppProxy("deleteMessages",[s.messageId])}else{var i={recallTime:Date.now(),admin:!!e.content.isAdmin,originalObjectName:s.messageType,originalMessageContent:s.content,recallActionTime:e.sentTime,operatorId:e.senderUserId};if(e.content.user&&(i.user=e.content.user),e.content.extra&&(i.extra=e.content.extra),s.messageType===V.TextMessage&&(i.recallContent=s.content.content),-1!==s.messageId)s.receivedStatus||this.setMessageReceivedStatus(s.messageId,1),this._callCppProxy("setMessageContent",s.messageId,JSON.stringify(i),V.RECALL_NOTIFICATION_MESSAGE);else{var a=e.conversationType,c=e.targetId,u=e.senderUserId,p=e.channelId,l=e.messageDirection;this._callCppProxy("insertMessage",a,c,u,V.RECALL_NOTIFICATION_MESSAGE,JSON.stringify(i),(function(){}),(function(){}),l,1,10,o,"",0,n,!1,!0,JSON.stringify({}),p||"")}}}},t.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var n=e.channelId,o=e.content,r=o.put,s=o.del,i=o.mid,a={};r&&(a.updatedExpansion={channelId:n,messageUId:i,expansion:r}),s&&(a.deletedExpansion={channelId:n,messageUId:i,deletedKeys:s}),this._send2AllRenderer("expansion",a,t)},t.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},t.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},t.prototype._sendMessageDelivered=function(e){this._send2AllRenderer("messageDelivered",e)},t.prototype._sendGroupMessageDeliveredStatus=function(e){this._send2AllRenderer("groupMessageDeliveredStatus",e)},t.prototype._sendChatroomStatus=function(e){this._send2AllRenderer("chatroom",e)},t.prototype._sendMessageReadReceipt=function(e){this._send2AllRenderer("messageReadReceipt",e)},t.prototype._sendsyncReadStatus=function(e){this._send2AllRenderer("syncReadStatus",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)?F.OPEN:F.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)}),(function(t,n,o,r){e._callCppProxy("clearUnreadCountByTimestamp",t,n,r,o||""),e._sendsyncReadStatus({conversationType:t,targetId:n,channelId:o,timestamp:r})}))},t.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._send2AllRenderer("tag",t),e._getRTCProfile()}))},t.prototype._getRTCProfile=function(){var e=this._callCppProxy("getRTCProfile");if(e){var t=this.tcpMgr.getToken();this.navi.updateVoipCallInfo(t,e);var n=this.navi.getNaviInfoFromCache(t);this._send2AllRenderer("onNaviDataChange",n)}},t.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var n=new Uint8Array(t).buffer;e._send2AllRenderer("onRTCDataChange",n)}))},t.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,n){e._sendChatroomStatus({chatroomDestroyed:t})}))},t.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},t.prototype._updateMentionedInfo=function(e,t,n){var o,r,s;return{userIdList:(null===(o=e.mentionedInfo)||void 0===o?void 0:o.userIdList)||t,type:(null===(r=e.mentionedInfo)||void 0===r?void 0:r.type)||n||q.ALL,mentionedContent:(null===(s=e.mentionedInfo)||void 0===s?void 0:s.mentionedContent)||""}},t.prototype.registerMessageType=function(e,t,n,o){void 0===o&&(o=[]);var r=0;t&&(r|=1),n&&(r|=2),this._customMessageType[e]={isCounted:n,isPersited:t},this.logger.info(Se.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){return this.tcpMgr.connect(e,t,n,o)},t.prototype.reportSDKInfo=function(e){var t,n,o=JSON.stringify(ye(ye({},e),{"electron-main":"5.8.5-alpha.4"}));this.logger.info(Se.P_REPORT_VER_O,o),null===(n=(t=this._cppProtocol).uploadSDKVersion)||void 0===n||n.call(t,o,"")},t.prototype.disconnect=function(e){this._chatroomCache.length=0,this.reporter.stop(),Xe(null,this.logger),this.tcpMgr.disconnect(e)},t.prototype.logout=function(){this.disconnect()},t.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,n){t({userId:e,status:n})}));var n=e.userIds||[];n.length&&this.subscribeUserStatus(n)},t.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(n){t._callCppProxy("subscribeUserStatus",e,(function(){n(u.SUCCESS)}),n)}))},t.prototype.setUserStatus=function(e){var t=this;return new Promise((function(n){t._callCppProxy("setUserStatus",e,(function(){n(u.SUCCESS)}),n)}))},t.prototype.getUserStatus=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getUserStatus",e,(function(e){n({code:u.SUCCESS,data:{status:e}})}),(function(e){n({code:e})}))}))},t.prototype.sendMessage=function(e,t,n,o,r){var s=this;void 0===r&&(r=this.logger.createTraceId());var i=n.messageType,a=n.content,c=n.expansion,p=n.pushConfig,l=n.isMentioned,d=n.mentionedType,h=n.mentionedUserIdList,f=void 0===h?[]:h,g=n.pushContent,C=void 0===g?"":g,v=n.pushData,_=void 0===v?"":v,S=n.directionalUserIdList,y=void 0===S?[]:S,m=n.disableNotification,P=void 0!==m&&m,E=n.canIncludeExpansion,T=void 0!==E&&E,I=n.isVoipPush,R=void 0!==I&&I,N=n.channelId,O=void 0===N?"":N,M=n.messageId,U=void 0===M?0:M,w=p||{},b=w.iOSConfig,x=w.androidConfig,L=w.templateId,A=void 0===L?"":L,k=w.pushTitle,J=void 0===k?"":k,j=w.pushContent,B=void 0===j?C:j,H=w.pushData,F=void 0===H?_:H,G=w.disablePushTitle,q=void 0!==G&&G,W=w.forceShowDetailContent,Q=void 0!==W&&W,Y=K(b,x);return new Promise((function(n){C=B,_=F;var p=(null==x?void 0:x.notificationId)||"";e===D.GROUP&&l&&a&&(a.mentionedInfo=s._updateMentionedInfo(a,f,d));var h=e===D.GROUP;if(h&&i===V.READ_RECEIPT_RESPONSE&&a.receiptMessageDic)for(var g in a.receiptMessageDic)y.push(g);h&&i===V.SYNC_READ_STATUS&&(y=[s.getCurrentUserId()]);var v={};for(var g in c)v[g]={v:""},v[g].v=c[g];var S=A;s.logger.info(Se.P_SEND_MSG_T,JSON.stringify({messageType:i,conversationType:e,targetId:t,channelId:O}),r);var m=s._callCppProxy("sendMessage",(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.info(Se.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:o.messageUId}),r),t===u.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:u.SUCCESS,data:o}))}),(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});return s.logger.warn(Se.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),r),o.sentTime=Date.now()-s._cppProtocol.getDeltaTime(),n({code:t,data:o})}),e,t,i,JSON.stringify(a),y,P,q,Q,C,_,p,J,Y,S,T,JSON.stringify(v),R,O,U),E=JSON.parse(m);null==o||o(E.messageId)}))},t.prototype.recallMsg=function(e,t,n,o,r){var s=this;return new Promise((function(i){var a,c=r.user,p=r.pushContent,l=r.channelId,d=r.extra,h=r.pushConfig,f=r.disableNotification,g=r.isDelete,C={conversationType:e,targetId:t,messageUId:n,sentTime:o,user:c,extra:d,channelId:l,isDelete:g||!1};c&&(C.user=c),d&&(C.extra=d);var v={conversationType:e,targetId:t,senderUserId:s.tcpMgr.getCurrentUserId(),content:C,objectName:V.RECALL,messageUid:n,direction:H.SEND,status:W.UNREAD,sentTime:o,channelId:l},_=s._buildMessage(JSON.stringify(v),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){s.handleRecalledMessage(_),i({code:u.SUCCESS,data:_})}),(function(e){i({code:e})}),V.RECALL,JSON.stringify(C),f||!1,(null==h?void 0:h.disablePushTitle)||!1,(null==h?void 0:h.forceShowDetailContent)||!1,p||"",(null==h?void 0:h.pushData)||"",(null===(a=null==h?void 0:h.androidConfig)||void 0===a?void 0:a.notificationId)||"",(null==h?void 0:h.pushTitle)||"",K(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){n=n||0;var p=0===r,l=o+1,d=a._callCppProxy("getHistoryMessages",e,t,n,l,i,p,s),h=JSON.parse(d).list,f=[];h.reverse();for(var g=0;g<h.length;g++){var C=a._buildMessage(h[g].obj);f[g]=C}c({code:u.SUCCESS,data:{list:l===f.length?f.slice(1,l):f,hasMore:o<f.length}})}))},t.prototype.getMessages=function(e,t,n,o,r,s){var i=this;return void 0===n&&(n=0),new Promise((function(a){var c=0===r,p=n,l=0!==n,d=o+1;l&&(p+=c?1:-1,d++);for(var h=i._callCppProxy("getMessages",e,t,p,d,c,s),f=JSON.parse(h).list,g=[],C=0;C<f.length;C++){var v=i._buildMessage(f[C].obj);g[C]=v}var _=i._computeRepairInfo(g,c,n,p,d),S=_.isNeedRepair,y=void 0!==S&&S,m=_.repairTime,P=void 0===m?0:m;if(!y)return l&&(g.shift(),d--),g.reverse(),void a({code:u.SUCCESS,data:{list:d===g.length?g.slice(1,d):g,hasMore:o<g.length}});i._processRepairHisMsg(e,t,n,o,r,s,P,a)}))},t.prototype._computeRepairInfo=function(e,t,n,o,r){var s=!1,i=0,a=this.getNaviInfoFromCache()||{},c=a.repairHisMsg,u=void 0===c?0:c,p=a.historyMsg;if(1!==u||!p)return{isNeedRepair:s,repairTime:i};var l=e.findIndex((function(e){return e.hasMore||0===Object.keys(e.content).length}));return t&&l>=0?(s=!0,i=e[l].hasMore?e[l].sentTime:e[l].sentTime+1):!t&&l>=1?(s=!0,i=e[l-1].sentTime):0===n?(s=!0,i=0):e.length<r?(s=!0,i=n):e.length>0&&e[0].sentTime!==n&&(s=!0,i=o),{isNeedRepair:s,repairTime:i}},t.prototype._processRepairHisMsg=function(e,t,n,o,r,s,i,a){var c=this,u=function(i){for(var u=0===r,p=o+1,l=c._callCppProxy("getMessages",e,t,n,p,u,s),d=JSON.parse(l).list,h=[],f=0;f<d.length;f++){var g=c._buildMessage(d[f].obj);h[f]=g}h.reverse(),a({code:i,data:{list:p<=h.length?h.slice(1,p):h,hasMore:o<h.length}})},p=o+10>100?100:o+10;this._callCppProxy("getRemoteHistoryMessages",e,t,i,p,(function(){return u(0)}),(function(e){u(e)}),r,!0,s,!1)},t.prototype.getRemoteHistoryMessages=function(e,t,n,o,r,s){var i=this;return new Promise((function(a){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:u.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){var i=JSON.stringify(n);r._callCppProxy("deleteRemoteHistoryMessages",e,t,i,!1,o,(function(){s(u.SUCCESS)}),s)}))},t.prototype.deleteRemoteMessageByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("clearRemoteHistoryMessages",e,t,n,(function(){s(u.SUCCESS)}),(function(e){s(e)}),o)}))},t.prototype.clearMessages=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("clearMessages",e,t,n),r(u.SUCCESS)}))},t.prototype.getConversationList=function(e,t,n,o,r){var s=this;return void 0===r&&(r=""),new Promise((function(e){for(var t=s._callCppProxy("getConversationList",[1,3,6,7],r),n=JSON.parse(t).list,o=[],i=0;i<n.length;i++)o.push(s._buildConversation(n[i].obj));e({code:u.SUCCESS,data:o})}))},t.prototype.getConversation=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getConversation",e,t,n);if(s)r({code:u.SUCCESS,data:o._buildConversation(s)});else{var i=o._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,n),a=void 0;try{a=JSON.parse(i).list}catch(e){o.logger.error(Se.P_PARSE_JSON_MSGS_E,null==e?void 0:e.stack),a=[]}var c=null;a.length>0&&(c=o._buildMessage(a[0].obj));var p=o._callCppProxy("getConversationNotificationStatus",e,t,n),l=o._callCppProxy("getConversationTopStatus",e,t,n);r({code:u.SUCCESS,data:{conversationType:e,targetId:t,channelId:n,unreadMessageCount:0,latestMessage:c,notificationStatus:p?F.OPEN:F.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?u.SUCCESS:u.CONVER_REMOVE_ERROR)},t.prototype.clearConversations=function(e,t){var n=this;return new Promise((function(o){var r=[];r=Q(e)?e:[D.PRIVATE,D.GROUP,D.SYSTEM,D.PUBLIC_SERVICE],n._callCppProxy("clearConversations",r,t||""),o(u.SUCCESS)}))},t.prototype.getAllConversationUnreadCount=function(e,t,n){var o=this._callCppProxy("getTotalUnreadCount",t,n,e);return Promise.resolve({code:u.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:u.SUCCESS,data:s})}))},t.prototype.clearConversationUnreadCount=function(e,t,n){var o=this;return void 0===n&&(n=""),new Promise((function(r){o._callCppProxy("clearUnreadCount",e,t,n),r(u.SUCCESS)}))},t.prototype.clearUnreadCountByTimestamp=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("clearUnreadCountByTimestamp",e,t,n,o),s(u.SUCCESS)}))},t.prototype.getFirstUnreadMessage=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getTheFirstUnreadMessage",e,t,n),i=o._buildMessage(s);r({code:u.SUCCESS,data:-1!==i.messageId?i:null})}))},t.prototype.setConversationToTop=function(e,t,n,o){var r=this;return void 0===o&&(o=""),new Promise((function(s){r._callCppProxy("setConversationToTop",e,t,n,o,!0),s(u.SUCCESS)}))},t.prototype.setConversationHidden=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("setConversationHidden",e,t,n,o),s(u.SUCCESS)}))},t.prototype.setConversationNotificationStatus=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("setConversationNotificationStatus",e,t,n,(function(){s(u.SUCCESS)}),s,o)}))},t.prototype.setConversationStatus=function(e,t,n,o,r){var s=this;return new Promise((function(i){s._callCppProxy("setConversationStatus",e,t,n,o,(function(){i(u.SUCCESS)}),i,r,!0)}))},t.prototype.getConversationNotificationStatus=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getConversationNotificationStatus",e,t,n);r({code:u.SUCCESS,data:s?F.OPEN:F.CLOSE})}))},t.prototype.searchConversationByContent=function(e,t,n,o){var r=this;return new Promise((function(s){o=o||[1,3,6,7];for(var i=r._callCppProxy("searchConversationByContent",o,e,t,n),a=JSON.parse(i).list,c=[],p=0;p<a.length;p++)c[p]=r._buildConversation(a[p].obj);s({code:u.SUCCESS,data:c})}))},t.prototype.searchConversationByContentWithAllChannel=function(e,t,n){var o=this;return new Promise((function(r){n=n||[1,3,6,7];for(var s=o._callCppProxy("searchConversationByContentWithAllChannel",n,e,t),i=JSON.parse(s).list,a=[],c=0;c<i.length;c++)a[c]=o._buildConversation(i[c].obj);r({code:u.SUCCESS,data:a})}))},t.prototype.searchMessageByContent=function(e,t,n,o,r,s,i){var a=this;return new Promise((function(s){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:u.SUCCESS,data:{messages:o,count:t}})}),i)}))},t.prototype.searchMessagesByUser=function(e,t,n,o,r,s){var i=this;return new Promise((function(a){i._callCppProxy("getMessageBySender",e,t,n,o,r,s,(function(e){for(var t=e?JSON.parse(e).list:[],n=[],o=0;o<t.length;o++)n[o]=i._buildMessage(t[o].obj);a({code:u.SUCCESS,data:{messages:n}})}))}))},t.prototype.searchMessageByContentWithAllChannel=function(e,t,n,o,r){var s=this;return new Promise((function(i){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:u.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){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:u.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){t._callCppProxy("addToBlacklist",e,(function(){n(u.SUCCESS)}),n)}))},t.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(n){t._callCppProxy("removeFromBlacklist",e,(function(){n(u.SUCCESS)}),n)}))},t.prototype.getBlacklist=function(){var e=this;return new Promise((function(t){e._callCppProxy("getBlacklist",(function(e){t({code:u.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},t.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(n){t._callCppProxy("getBlacklistStatus",e,(function(e){n({code:u.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,p=n.sentStatus,l=n.sentTime,d=n.searchContent,h=n.isUnread,f=n.messageUId,g=n.disableNotification,C=n.canIncludeExpansion,v=n.expansionMsg,_=n.channelId;r=JSON.stringify(r);var S={};if(l=l||0,v){var y=JSON.parse(v);for(var m in y)S[m]={v:"",ts:0},S[m].v=y[m],S[m].ts=l}return new Promise((function(n){var v=h?0:1,y=o._callCppProxy("insertMessage",e,t,s,i,r,(function(){}),(function(e){n({code:e})}),a,c||0,p||10,l,d||"",v,f||"",!!g,!!C,JSON.stringify(S),_||""),m=o._buildMessage(y,{isOffLineMessage:!1});m.messageUId=f,m.sentTime=l,n({code:-1===m.messageId?u.MSG_INSERT_ERROR:u.SUCCESS,data:m})}))},t.prototype.batchInsertMessage=function(e,t){var n=this;return void 0===t&&(t=!1),new Promise((function(o){var r=e.map((function(e){var t=e.content,n=e.senderUserId,o=e.messageType,r=e.messageDirection,s=e.receivedStatus,i=e.sentStatus,a=e.sentTime,c=e.searchContent,u=e.isUnread,p=e.messageUId,l=e.disableNotification,d=e.canIncludeExpansion,h=e.expansion,f=e.channelId,g=e.conversationType,C=e.targetId,v=e.source,_=e.isMentioned,S={};if(a=a||0,h)for(var y in h)S[y]={v:"",ts:0},S[y].v=h[y],S[y].ts=a;return{conversationType:g,targetId:C,channelId:f||"",direction:r,senderUserId:n,status:i||10,sentTime:a,objectName:o,content:JSON.stringify(t),messageUid:p||"",noNotification:!!l,supportExt:!!d,extMsg:JSON.stringify(S),readStatus:s||0,searchContent:c||"",isUnread:!!u,source:v||"",isMention:_}})),s=n._callCppProxy("insertMessages",JSON.stringify(r),t);o({code:s?u.SUCCESS:u.MSG_INSERT_ERROR,data:s||!1})}))},t.prototype.getMessageCount=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getMessageCount",e,t,n);r({code:u.SUCCESS,data:s})}))},t.prototype.deleteMessages=function(e){var t=this;return new Promise((function(n){t._callCppProxy("deleteMessages",e),n(u.SUCCESS)}))},t.prototype.deleteMessagesByTimestamp=function(e,t,n,o,r){var s=this;return new Promise((function(i){s._callCppProxy("deleteMessagesByTimestamp",e,t,n,o,r),i(u.SUCCESS)}))},t.prototype.getMessage=function(e){var t=this;return new Promise((function(n){var o=t._callCppProxy("getMessage",e),r=t._buildMessage(o,{isOffLineMessage:!1});n({code:u.SUCCESS,data:r})}))},t.prototype.setMessageContent=function(e,t,n){var o=this;return new Promise((function(r){t=JSON.stringify(t),o._callCppProxy("setMessageContent",e,t,n),r(u.SUCCESS)}))},t.prototype.setMessageSearchField=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("setMessageSearchField",e,t,n),r(u.SUCCESS)}))},t.prototype.setMessageSentStatus=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("setMessageSentStatus",e,t),o(u.SUCCESS)}))},t.prototype.setMessageReceivedStatus=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("setMessageReceivedStatus",e,t),o(u.SUCCESS)}))},t.prototype.saveConversationMessageDraft=function(e,t,n,o){var r=this;return new Promise((function(s){r._callCppProxy("saveTextMessageDraft",e,t,n,o||"")&&s(u.SUCCESS),s(u.DRAFT_SAVE_ERROR)}))},t.prototype.getConversationMessageDraft=function(e,t,n){var o=this;return new Promise((function(r){var s=o._callCppProxy("getTextMessageDraft",e,t,n||"");r({code:u.SUCCESS,data:s})}))},t.prototype.clearConversationMessageDraft=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("clearTextMessageDraft",e,t,n||"")&&r(u.SUCCESS),r(u.DRAFT_REMOVE_ERROR)}))},t.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},t.prototype.batchSetConversationStatus=function(e){var t=e[0],n=t.conversationType,o=t.targetId,r=t.isTop,s=t.notificationStatus,i=t.channelId,a=this._callCppProxy("getConversationNotificationStatus",n,o,i||""),c=this._callCppProxy("getConversationTopStatus",n,o,i||""),u=j(s)?Boolean(a):s===F.OPEN,p=j(r)?Boolean(c):r;return this.setConversationStatus(n,o,u,p,i)},t.prototype.getConversationNotificationLevel=function(e,t,n){return me(this,void 0,void 0,(function(){var o;return Pe(this,(function(r){return o=this._callCppProxy("getBlockPushLevelForConversation",t,n,e),[2,Promise.resolve({code:u.SUCCESS,data:o})]}))}))},t.prototype.setConversationNotificationLevel=function(e,t,n,o){var r=this;return void 0===o&&(o=""),new Promise((function(s){r._callCppProxy("setBlockPushLevelForConversation",t,o,e,n,(function(){s(u.SUCCESS)}),(function(e){s(e)}))}))},t.prototype.getTotalUnreadCountByLevels=function(e,t,n){if(n){var o=this._callCppProxy("getUnreadMentionedCountByLevel",e,t);return Promise.resolve({code:u.SUCCESS,data:o})}var r=this._callCppProxy("getUnreadCountByLevel",e,t);return Promise.resolve({code:u.SUCCESS,data:r})},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(Se.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),r({code:u.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getMessageReader=function(e,t,n){var o=this;return new Promise((function(r){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:u.SUCCESS,data:{list:s,totalMemberCount:n}})}),(function(e){r({code:e})}))}))},t.prototype.sendReadReceiptMessageV4=function(e,t,n){var o=this;return new Promise((function(r){var s=e.conversationType,i=e.targetId,a=e.channelId;o._callCppProxy("sendMessageReadReceipt",s,i,a||"",t,n,(function(){r({code:u.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getMessageReadReceiptV4=function(e,t){var n=this;return new Promise((function(o){var r=e.targetId,s=e.channelId;n._callCppProxy("getMessageReadReceipt",r,s||"",t,(function(e){var t=[];try{JSON.parse(e).list.forEach((function(e){var n=JSON.parse(e.obj),o=n.id,r=n.time;t.push({userId:o,readTime:r})}))}catch(t){n.logger.error(Se.P_PARSE_JSON_E,"method: getMessageReadReceipt, info: ".concat(e,", error: ").concat(t))}o({code:u.SUCCESS,data:t})}),(function(e){o({code:e})}))}))},t.prototype.updateConversationReadTime=function(e,t){var n=this;return new Promise((function(o){var r=e.conversationType,s=e.targetId,i=e.channelId;n._callCppProxy("updateConversationReadTime",r,s,i||"",t,(function(){o({code:u.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype._addChatroomCache=function(e,t,n){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:n,count:t})},t.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},t.prototype._try2RejoinChatroom=function(){var e=this;if(0!==this._chatroomCache.length){var t=this.logger.createTraceId();this._chatroomCache.forEach((function(n){return me(e,void 0,void 0,(function(){var e,o,r,s,i,a;return Pe(this,(function(c){switch(c.label){case 0:return e=n.chatroomId,o=n.joinExist,r=n.count,this.logger.info(l.L_REJOIN_CHATROOM_T,e,t),[4,this._joinChrm(e,r,o,!1)];case 1:return s=c.sent(),i=s.code,a=s.data,i===u.SUCCESS?(this.logger.info(l.L_REJOIN_CHATROOM_R,e,t),this._sendChatroomStatus({rejoinedRoom:ye({chatroomId:e,count:r},a)}),[2]):(i===u.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(e),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,errorCode:i}}),this.logger.warn(l.L_REJOIN_CHATROOM_R,"chrmId: ".concat(e,", code: ").concat(i),t),[2])}}))}))}))}},t.prototype._joinChrm=function(e,t,n,o){var r=this,s=n?"joinExistChatRoom":"joinChatRoom";return new Promise((function(i){o&&r._callCppProxy("clearMessages",D.CHATROOM,e,""),r._callCppProxy(s,e,t,(function(o,s,a,c,p,l){r._addChatroomCache(e,t,n),i({code:u.SUCCESS,data:{createTime:Number(o),memberCount:s,isAllChatroomBanned:a,isCurrentUserBanned:c,isCurrentChatroomBanned:p,isCurrentChatroomInWhitelist:l}})}),(function(e){i({code:e})}))}))},t.prototype.joinChatroom=function(e,t){return me(this,void 0,void 0,(function(){return Pe(this,(function(n){switch(n.label){case 0:return[4,this._joinChrm(e,t,!1,!0)];case 1:return[2,n.sent().code]}}))}))},t.prototype.joinExistChatroom=function(e,t){return this._joinChrm(e,t,!0,!0)},t.prototype.quitChatroom=function(e){var t=this;return this._rmChatroomCache(e),new Promise((function(n){t._callCppProxy("quitChatRoom",e,(function(){n(u.SUCCESS)}),n)}))},t.prototype.getChatroomInfo=function(e,t,n){var o=this;return new Promise((function(r){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:u.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){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:u.SUCCESS,data:t})}),(function(e){s({code:e})}),"")}))},t.prototype.setChatroomEntry=function(e,t){var n=this;return new Promise((function(o){var r='[{"key":"'.concat(t.key,'", "value":"').concat(t.value,'"}]');n._callCppProxy("setChatroomKV",e,r,!!t.isAutoDelete,!!t.isOverwrite,(function(){o(u.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:u.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.setChatroomEntry(e,t)},t.prototype.removeChatroomEntry=function(e,t){var n=this,o=[t.key];return new Promise((function(r){n._callCppProxy("deleteChatroomKV",e,o,!!t.isOverwrite,(function(){r(u.SUCCESS)}),(function(e){r(e)}))}))},t.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.removeChatroomEntry(e,t)},t.prototype.removeChatroomEntries=function(e,t){var n=this;return new Promise((function(o){var r=t.entries.map((function(e){return e.key}));n._callCppProxy("deleteChatroomKV",e,r,!!t.isOverwrite,(function(){o({code:u.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.getChatroomEntry=function(e,t){return me(this,void 0,void 0,(function(){var n;return Pe(this,(function(o){switch(o.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(n=o.sent()).code===u.SUCCESS?[2,{code:u.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){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:u.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},t.prototype.getFileToken=function(e,t,n,o,r){var s=this;return void 0===r&&(r=""),n=n||"",o=o||"",new Promise((function(i){var a;a=o&&"uploads"!==o?t||"":Y(e,t),s._callCppProxy("getUploadToken",e,a,n,o,r,(function(e,t,n,o,r,s,c,p,l,d,h,f,g,C,v,_,S,y,m,P,E,T,I){i({code:u.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:n,path:o,osskeyId:r,ossPolicy:s,ossSign:c,ossBucketName:p,fileName:a,s3Credential:l,s3Algorithm:d,s3Date:h,s3Policy:f,s3Signature:g,s3BucketName:C,stcAuthorization:v,stcContentSha256:_,stcDate:S,stcBucketName:y,minioAuthorization:m,minioContentSha256:P,minioDate:E,minioBucketName:T,downloadAuthInfo:I?JSON.parse(I):null}})}),(function(e){i({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:u.SUCCESS,data:{downloadUrl:e}})}),(function(e){s({code:e})}))}))},t.prototype.clearData=function(){var e=this;return new Promise((function(t){var n=e._callCppProxy("clearData");t({code:u.SUCCESS,data:n})}))},t.prototype.getDeviceId=function(){var e=this._dbpath||o(z.getPath("userData"));return ct(e)},t.prototype.getVoIPKey=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("getVoIPKey",e,t,"",(function(e){o({code:u.SUCCESS,data:e})}),(function(e){o({code:e})}))}))},t.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(n){var o=e.chatRoomId,r=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",o,r,(function(){n(u.SUCCESS)}),(function(e){n(e)}))}))},t.prototype.getGroupMessageDeliverList=function(e,t,n){var o=this;return new Promise((function(r){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:u.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){var r=n._callCppProxy("getMessageDeliverTime",e);if(r)o({code:u.SUCCESS,data:r});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:u.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:u.SUCCESS,buffer:t})}),(function(e){o({code:e})}),30)}))},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],30)}))},t.prototype.createTag=function(e){var t=this;return new Promise((function(n){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){n({code:u.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.removeTag=function(e){var t=this;return new Promise((function(n){t._callCppProxy("deleteTag",e,(function(){n({code:u.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.updateTag=function(e){var t=this;return new Promise((function(n){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){n({code:u.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.getTagList=function(){var e=this;return new Promise((function(t){var n=e._callCppProxy("getTags"),o=e._convertResultList(n,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:u.SUCCESS,data:o})}))},t.prototype.addTagForConversations=function(e,t){var n=this;return new Promise((function(o){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));n._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){o({code:u.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.removeTagForConversations=function(e,t){var n=this;return new Promise((function(o){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),n._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){o({code:u.SUCCESS})}),(function(e){o({code:e})}))}))},t.prototype.removeTagsForConversation=function(e,t){var n=this;return new Promise((function(o){n._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){o({code:u.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 ye(ye({},r._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:u.SUCCESS,data:a})}))},t.prototype.getUnreadCountByTag=function(e,t){var n=this;return new Promise((function(o){var r=n._callCppProxy("getConversationUnreadCountForTag",e,t);o({code:u.SUCCESS,data:r})}))},t.prototype.setConversationStatusInTag=function(e,t,n){var o=this;return new Promise((function(r){o._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",n.isTop||!1,(function(){r({code:u.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(n){var o=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||""),r=t._convertResultList(o,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));n({code:u.SUCCESS,data:r})}))},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=j(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:u.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 me(this,void 0,void 0,(function(){var t;return Pe(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:u.SUCCESS,data:t}]}))}))},t.prototype.getMainProcessInfo=function(){return me(this,void 0,void 0,(function(){return Pe(this,(function(e){return[2,{code:u.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:u.SUCCESS,data:{key:e,value:t}})}),(function(e){r({code:e})}))}))},t.prototype.setProxy=function(e){return this.tcpMgr.getConnectionStatus()!==T.DISCONNECTED?Promise.resolve({code:u.RC_CONN_PROXY_UNAVAILABLE}):Promise.resolve(Xe(e,this.logger))},t.prototype.getProxy=function(){return Promise.resolve(ze())},t.prototype.testProxy=function(e,t){return function(e,t,n){return new Promise((function(o){var r=/^https/.test(t)?We:Ge;n.info(l.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:e,testHost:t}));var s=r(t,e,(function(e){var t=200===e.statusCode?0:e.statusCode;e.setEncoding("utf8");var n="";e.on("data",(function(e){n+=e})),e.once("end",(function(){o({status:t||0,data:n})}))}));s.once("timeout",(function(){return o({status:0})})),s.once("error",(function(e){return o({status:0,data:e.stack})})),s.end()}))}(e,t,this.logger)},t.prototype.checkDuplicateMessage=function(e){var t=this;return new Promise((function(n){var o=t._callCppProxy("checkDuplicateMessage",e);n({code:u.SUCCESS,data:o})}))},t}(),St=function(){function e(e,t,n,o){void 0===n&&(n=""),this._cppService=new _t(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}(),yt=function(e){return function(e,t,n){if(ft)return ft;if(!t)throw new Error("Initializ failed, `appkey` is required!");return ft=new St(t,e,null==n?void 0:n.dbpath,null==n?void 0:n.logOutputLevel)}(Ce,e.appkey,e)};export{yt as default};
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("os"),t=require("path"),o=require("@rongcloud/engine"),r=require("child_process"),n=require("electron"),s=require("http"),i=require("https"),a=require("url"),c=require("net"),u=require("events"),d=require("tls"),p=require("fs"),l=require("crypto");function C(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var h=C(e),f=t.resolve(__dirname,"binding","electron-".concat(e.platform(),"-").concat(e.arch(),".node")),g={addon:null};try{g.addon=require(f)}catch(e){console.error("error ->",f,"\n",e)}g.addon||console.error("error -> cannot find module: ",f);var v=g.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 S(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 y,E=function(){return E=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},E.apply(this,arguments)};function m(e,t,o,r){return new(o||(o=Promise))((function(n,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function P(e,t){var o,r,n,s,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(o=1,r&&(n=2&a[0]?r.return:a[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,a[1])).done)return n;switch(r=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){i.label=a[1];break}if(6===a[0]&&i.label<n[1]){i.label=n[1],n=a;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(a);break}n[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{o=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function T(e,t,o){if(o||2===arguments.length)for(var r,n=0,s=t.length;n<s;n++)!r&&n in t||(r||(r=Array.prototype.slice.call(t,0,n)),r[n]=t[n]);return e.concat(r||Array.prototype.slice.call(t))}!function(e){e.P_INIT_O="P-init-O",e.P_DB_OPEN_O="P-db_open-O",e.P_CALL_MAIN_SYNC_E="P-call_main_sync-E",e.P_CALL_MAIN_E="P-call_main-E",e.P_SEND_2_MAIN_E="P-send_2_main-E",e.P_REGTYP_O="P-regtype-O",e.P_CALL_ADDON_E="P-call_addon-E",e.P_CALL_ADDON_T="P-call_addon-T",e.P_CALL_ADDON_O="P-call_addon-O",e.P_CALL_ADDON_R="P-call_addon-R",e.P_CALL_EXTRA_E="P-call_extra-E",e.P_CONNECT_S="P-connect-S",e.P_CONNECT_T="P-connect-T",e.P_CONNECT_O="P-connect-O",e.P_CONNECT_ENTRY_S="P-connect_entry-S",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",e.P_PARSE_JSON_E="P-parse_json-E"}(y||(y={}));var I,R={flushTimestamp:Date.now(),queue:[],locked:!1};function O(){I&&clearInterval(I)}function N(e,t){O(),I=setInterval((function(){return b(e,t)}),1e4)}function M(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=R.queue).push.apply(e,t)}var U=200;function b(e,t){var o=R.queue,r=R.flushTimestamp;if(!(R.locked||0===o.length||Date.now()-r<3e4&&o.length<U)){R.locked=!0;var n=t.createTraceId(),s=o.splice(0,U).map((function(e){var t=e.sessionId,o=e.level,r=e.time,n=e.type,s=e.tag,i=e.loggerId,a=e.content,c=e.traceId;return{level:o,time:r,type:n,tag:s,content:encodeURIComponent(JSON.stringify({loggerId:i,sessionId:t,content:a,traceId:c})).replace(/'/g,"%27")}}));t.debug(y.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(o.length),n);var i=JSON.stringify(s);e.writeLog(i),t.debug(y.P_WRITE_LOG_R,"write done, queueLen: ".concat(o.length),n),R.flushTimestamp=Date.now(),R.locked=!1,setTimeout((function(){return b(e,t)}))}}var L=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return S(t,e),t.prototype.flush=function(e){M(e)},t}(o.BasicLogger),w=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return S(t,e),t.prototype.flush=function(e){M(e)},t}(o.BasicStatistic),x=function(e,t){var o,r=Buffer.from(e),n=r.length;for(t.push(n),o=0;o<n;o++)t.push(r[o])},A=function(e){return"string"==typeof e},D=function(e){return A(e)?e.toUpperCase():""},k=function(e,t){var o="";return 2!==e.length?o="Unexpected number of bytes received.":5!==e[0]?o="Unexpected SOCKS version number: ".concat(e[0],"."):255===e[1]?o="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(o="Unexpected SOCKS authentication method: ".concat(e[1],".")),o},J=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: ".concat(e[0],"."):0!==e[1]&&(t="Username and password authentication failure: ".concat(e[1],".")),t},F=function(e){var t=D(e.method)||"GET",o=e.pathname||"/",r=e.headers||{},n=e.search||"";r.Host=e.host||"loclahost";var s="";for(var i in s="".concat(t," ").concat(o+n," HTTP/1.1\n"),r)if(Object.hasOwnProperty.call(r,i)){var a=r[i];s+="".concat(i,": ").concat(a,"\n")}return e.body&&(s+="Content-Length: ".concat(e.body.length,"\n")),s+="\n","POST"===t&&e.body&&(s+="".concat(e.body)),s},j=function(e){return new Promise((function(t){var o,r;e.socket.once("data",(function(r){var n,s=k(r,o);if(!s)return 2===r[1]?(e.socket.once("data",(function(o){var r=J(o);r?e.emit("error",new Error("SOCKS authentication failed. ".concat(r))):t()})),n=[1],x(e.socksUsername,n),x(e.socksPassword,n),void e.write(Buffer.from(n))):void t();e.emit("error",new Error("SOCKS authentication failed. ".concat(s)))})),o=[0],e.socksUsername&&o.push(2),(r=Buffer.alloc(2+o.length))[0]=5,r[1]=o.length,o.forEach((function(e,t){r[2+t]=e})),e.write(r)}))},B=function(e,t,o){return new Promise((function(r){var n,s;switch(e.socket.once("data",(function(t){var o;5!==t[0]?o="Unexpected SOCKS version number: ".concat(t[0],"."):0!==t[1]?o="".concat(function(e){switch(e){case 1:return"General SOCKS server failure";case 2:return"Connection not allowed by ruleset";case 3:return"Network unreachable";case 4:return"Host unreachable";case 5:return"Connection refused";case 6:return"TTL expired";case 7:return"Command not supported";case 8:return"Address type not supported";default:return"Unknown status code ".concat(e)}}(t[1]),"."):0!==t[2]&&(o="The reserved byte must be 0x00."),o?e.emit("error",new Error("SOCKS connection failed. ".concat(o))):r()})),(n=[]).push(5),n.push(1),n.push(0),c.isIP(t)){case 0:n.push(3),x(t,n);break;case 4:n.push(1),function(e,t){var o,r,n=e.split(".");for(o=0;o<4;o++)r=parseInt(n[o],10),t.push(r)}(t,n);break;case 6:e.emit("error",new Error("Does not support IPV6"))}n.length+=2,(s=Buffer.from(n)).writeUInt16BE(o,s.length-2),e.write(s)}))},H=function(e){function t(t){var o=e.call(this)||this;return o.readable=!0,o.socket=new c.Socket,o.options=t,o.socksHost=t.socksHost||"localhost",o.socksPort=t.socksPort||1080,o.socksUsername=t.socksUsername||"",o.socksPassword=t.socksPassword||"",o.socket.on("error",(function(e){o.emit("error",e)})),o.on("error",(function(){o.socket.destroyed||o.socket.destroy()})),o.on("end",o.end),o}return S(t,e),t.prototype.ref=function(){return this.socket.ref()},t.prototype.unref=function(){return this.socket.unref()},t.prototype.setTimeout=function(e,t){return this.socket.setTimeout(e,t)},t.prototype.setNoDelay=function(e){return this.socket.setNoDelay(e)},t.prototype.setKeepAlive=function(e,t){return this.socket.setKeepAlive(e,t)},t.prototype.address=function(){return this.socket.address()},t.prototype.cork=function(){return this.socket.cork()},t.prototype.uncork=function(){return this.socket.uncork()},t.prototype.pause=function(){return this.socket.pause()},t.prototype.resume=function(){return this.socket.resume()},t.prototype.pipe=function(e){return this.socket.pipe(e)},t.prototype.end=function(e,t){var o=this.socket.end(e,t);return this.writable=this.socket.writable,o},t.prototype.destroy=function(e){return this.socket.destroy(e)},t.prototype.setEncoding=function(e){return this.socket.setEncoding(e)},t.prototype.write=function(e,t,o){return this.socket.write(e,t,o)},t.prototype.read=function(e){return this.socket.read(e)},t.prototype.connect=function(e,t){var o=this;if("string"==typeof e&&/^\d+$/.test(e)&&(e=parseInt(e,10)),!Number.isInteger(e)||e<1||e>65535)throw new TypeError("Invalid port: ".concat(e));if(!t||"string"!=typeof t)throw new TypeError("Invalid host: ".concat(t));return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return m(o,void 0,void 0,(function(){var o;return P(this,(function(r){switch(r.label){case 0:return[4,j(this)];case 1:return r.sent(),[4,B(this,t,e)];case 2:return r.sent(),this.onProxied(),o=F(this.options),this.socket.write(Buffer.from(o)),[2]}}))}))})),this},t.prototype.onProxied=function(){var e=this;this.socket.on("close",(function(t){e.emit("close",t)})),this.socket.on("end",(function(){e.emit("end")})),this.socket.on("data",(function(t){e.emit("data",t)})),this.writable=!0,this.readable=!0,this.emit("connect")},t}(u.EventEmitter),V=function(e){var t,o=e.hostname,r=e.port;return!e.host||o&&r||(t=e.host.split(":")),!r&&t&&(r=parseInt(t[1],10)||0),!o&&t&&(o=t[0]),new H(e).connect(r,o)},G=function(e){function t(t){var o=e.call(this)||this;return o.createConnection=V,o}return S(t,e),t}(s.Agent),q=function(e,t,o){return(t=E(E({},t),a.parse(e))).port||(t.port=80),t.agent=new G(t),s.request(t,o)},K=function(e){var t,o;return t=V(e),o=t.onProxied,t.onProxied=function(){e.socket=t.socket,e.hostname?e.servername=e.hostname:e.host&&(e.servername=e.host.split(":")[0]),t.socket=d.connect(e,(function(){t.authorized=t.socket.authorized,o.call(t)})),t.socket.on("error",(function(e){t.emit("error",e)}))},t},W=function(e){function t(t,o){var r=e.call(this,o)||this;return r.url=t,r.socksHost=o.socksHost||"localhost",r.socksPort=o.socksPort||1080,r.createConnection=K,r}return S(t,e),t}(i.Agent),Y=function(e,t,o,r){var n,s;return t.protocol="https:",!t.port&&t.host&&(n=t.host.split(":"),t.port=n[0],t.port=n[1]),t.port||(t.port=443),s=new W(e,t),t.agent=s,i.request(e,t,o)},Q=null;function X(e,t,r){void 0===r&&(r=!1);var n=t.url,a=t.headers,c=t.body,u=t.method,d=t.query,p=t.timeout,l=void 0===p?o.HTTP_TIMEOUT:p;return new Promise((function(t){var p=/^https/.test(n),C={headers:a,method:u};p&&(C.rejectUnauthorized=r);var h=null;Q?((C=E(E({},C),Q)).body=c,h=p?Y:q):(h=s.request,p&&(C.agent=new i.Agent(C),h=i.request));var f=h(o.appendUrl(n,d),C,(function(e){var o=e.statusCode,r="";e.setEncoding("utf8"),e.on("data",(function(e){r+=e})),e.once("end",(function(){t({status:o||0,data:r})}))}));f.once("timeout",(function(){e.warn(y.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:n,method:u,query:d,timeout:l})),t({status:0})})),f.setTimeout(l),f.once("error",(function(o){e.warn(y.P_HTTP_REQ_E,JSON.stringify({msg:o.stack,url:n,method:u,query:d,timeout:l})),t({status:0})})),f.write(c),f.end()}))}function z(e,t){return e?(Q=E(E({},Q),e),t.info(o.LogTagId.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:Q})),{code:o.ErrorCode.SUCCESS}):(Q=null,t.info(o.LogTagId.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:o.ErrorCode.SUCCESS})}function Z(){var e=Q||void 0;return{code:o.ErrorCode.SUCCESS,data:e}}var $,ee=[],te=function(e){return m(void 0,void 0,void 0,(function(){return P(this,(function(t){return[2,new Promise((function(t){ee.push({resolve:t,args:e}),re()}))]}))}))},oe=!1,re=function(){return m(void 0,void 0,void 0,(function(){var e,t,r,n,s,i,a,c,u,d,p;return P(this,(function(l){return oe||0===ee.length||(oe=!0,e=ee.shift(),t=e.args,r=e.resolve,n=t.addon,s=t.startTime,i=t.endTime,a=t.level,c=t.realtimeReport,u=0,d=0,p=[],n.setLogEventListener((function(e){u+=e.length;var t=e.split(","),n=t[0],s=t[1],i=t[2],l=t[3],C=t[4],h=t.slice(5);if(u>o.REAT_TIME_LOG_SIZE&&parseInt(s,10)!==d)r(p);else{d=parseInt(s,10);try{var f=JSON.parse(decodeURIComponent(h.join(","))),g=f.loggerId,v=f.sessionId,_=f.content,S=f.traceId;if(!c&&a<0)return;var y={time:parseInt(s,10),level:parseInt(l,10),sessionId:"".concat(n,":").concat(v),type:i,tag:C,loggerId:g,content:_,traceId:S};p.push(y)}catch(e){console.error(e)}}}),(function(e){r(p),oe=!1,re()}),(function(e,t,o){})),n.pullFullLog(a,s,i,!1)),[2]}))}))},ne=function(e){function t(t,r,n,s,i){var a=this,c=process.versions.electron,u="Electron|".concat(c,"|").concat(process.arch,"|").concat(process.platform);return(a=e.call(this,r,n,u,{getLogs:function(e,o,r,n){return m(this,void 0,void 0,(function(){return P(this,(function(s){switch(s.label){case 0:return[4,te({startTime:e,endTime:o,level:r,realtimeReport:n,addon:t})];case 1:return[2,{logs:s.sent(),dbReady:!0}]}}))}))},getTimestamp4RealtimeLog:function(){var e=t.getStoreValue(o.StoreKeys.REALTIME_LOG_TIMESTAMP);return parseInt(e,10)||0},setTimestamp4RealtimeLog:function(e){t.setStoreValue(o.StoreKeys.REALTIME_LOG_TIMESTAMP,e.toString())}},s)||this).subProcess=i,a}return S(t,e),t.prototype.send=function(e){return X(this.logger,e)},t.prototype.compressLogs=function(e){return m(this,void 0,void 0,(function(){var t,o,r;return P(this,(function(n){switch(n.label){case 0:return[4,this.subProcess.call("compressLogs",e)];case 1:return t=n.sent(),o=t.success,r=t.data,o?[2,{success:o,data:r}]:[2,{success:o,data:""}]}}))}))},t}(o.BasicReporter),se=[o.EConnectProtocol.RMTP,o.EConnectProtocol.TLS,o.EConnectProtocol.QUIC],ie={NAVI:function(e){return"RongCloud/navis/".concat(e,"/navi-cache.json")},DEVICE_ID:"deviceId",STATIC_CONFIG:function(e){return"RongCloud/caches/".concat(e,"/staticConfig.json")},CLOUD_CONTROL:function(e){return"RongCloud/cloudControl/".concat(e,"/cloudControl.json")}},ae=null,ce=function(){var t,o=Date.now(),r=[e.arch(),e.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return t=r,l.createHash("md5").update(t).digest("hex")},ue=function(e){if(ae)return ae;var o=t.resolve(e,ie.DEVICE_ID);return p.existsSync(o)?ae=p.readFileSync(o).toString():(ae=ce(),p.writeFileSync(o,ae),ae)},de=function(){function e(e){this._cppProto=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,o,r,n,s){var i=JSON.stringify(n);"{}"!==i&&e.info(y.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:r,ext:n})),this._cppProto.setMessageExtension(t,o,r,i,s)},e.prototype.setLocalFromReceiveMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,s=t.messageUId,i=t.expansion,a=t.sentTime,c={};for(var u in i)c[u]={v:"",ts:0},c[u].v=i[u],c[u].ts=a;this._setToProtocol(e,r,n,s,c,o||"")},e.prototype.setLocalFromExtMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,s=t.content,i=t.sentTime,a=s,c=a.put,u=this._cppProto.getMessage(a.mid),d=JSON.parse(u).extMsg,p=JSON.parse(d||"{}");if(c)for(var l in c){var C=p[l];C&&C.ts<i-this._setTime?(C.v=c[l],C.ts=i-this._setTime):(p[l]={v:"",ts:0},p[l].v=c[l],p[l].ts=i-this._setTime)}a.del&&a.del.forEach((function(e){delete p[e]})),this._setToProtocol(e,r,n,a.mid,p,o||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var r in t)o[r]=t[r].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),r={};for(var n in o)r[n]=o[n].v;return r},e}(),pe=function(){function e(e){var t=this;this.p=e,this.count=0,this.maps={},this.p.on("message",(function(e){var o=e.reqId,r=e.success,n=e.data,s=t.maps[o];s&&(s({success:r,data:n}),delete t.maps[o])}))}return e.prototype.call=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return m(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return this.p.killed?[2,{success:!1}]:[2,new Promise((function(r){var n=++o.count;o.maps[n]=r;var s={reqId:n,method:e,args:t};o.p.send(s)}))]}))}))},e.prototype.destroy=function(){this.p.kill()},e}(),le=function(e,t,o){return m(void 0,void 0,void 0,(function(){var r,n;return P(this,(function(s){return r=l.createDecipheriv("aes-256-cbc",t,o),n=r.update(e,"base64","utf-8"),[2,n+=r.final("utf8")]}))}))},Ce=function(e){if(!p.existsSync(e)){var o=t.resolve(e,"..");p.existsSync(o)||Ce(o),p.mkdirSync(e)}},he=function(e){function r(o,r,n,s,i){var a=e.call(this,o,r,n,i)||this;a.naviPath="",a._caches={},a.naviPath="".concat(s,"/").concat(ie.NAVI(o));var c=t.dirname(a.naviPath);return p.existsSync(c)||Ce(c),a}return S(r,e),r.prototype.httpRequest=function(e,t,r,n){return m(this,void 0,void 0,(function(){var s,i,a,c,u;return P(this,(function(d){switch(d.label){case 0:return s="token=".concat(encodeURIComponent(r),"&v=").concat(o.FORMATED_VERSION,"&p=PC&ev=").concat("5.8.5-alpha.3"),i="".concat(e,"/navi.json?r=").concat(Date.now()),this.logger.debug(o.LogTagId.L_REQUEST_T,JSON.stringify({url:i,body:s}),n),[4,X(this.logger,{method:"POST",headers:{appId:t},body:s,url:i,timeout:o.NAVI_REQ_TIMEOUT})];case 1:if(200!==(a=d.sent()).status)return this.logger.warn(o.LogTagId.L_REQUEST_R,JSON.stringify({url:i,code:a.status}),n),[2,{code:this.transHttpCode(a.status)}];try{return c=JSON.parse(a.data),u=/^https/.test(i)?"https":"http",c.protocol=u,[2,{code:o.ErrorCode.SUCCESS,data:c}]}catch(e){return this.logger.error(o.LogTagId.L_PARSE_NAVI_E,a.data,n),[2,{code:o.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},r.prototype.httpRequestV2=function(e,t,r,n){return m(this,void 0,void 0,(function(){var s,i,a,c;return P(this,(function(u){switch(u.label){case 0:return s=this.getNaviV2RequestOption({appkey:t,token:r,uri:e,platform:"electron",protocol:se.join(",")}),this.logger.debug(o.LogTagId.L_REQUEST_T,JSON.stringify({url:s.url,body:s.body,headers:s.headers}),n),[4,X(this.logger,s)];case 1:if(200!==(i=u.sent()).status)return this.logger.warn(o.LogTagId.L_REQUEST_R,JSON.stringify({url:s.url,code:i.status}),n),[2,{code:this.transHttpCode(i.status)}];try{return a=JSON.parse(i.data),c=/^https/.test(s.url)?"https":"http",a.protocol=c,[2,{code:o.ErrorCode.SUCCESS,data:a}]}catch(e){return this.logger.error(o.LogTagId.L_PARSE_NAVI_E,i.data,n),[2,{code:o.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},r.prototype.getNaviCache=function(e){var t=this._caches[e];if(t)return t;if(!p.existsSync(this.naviPath))return null;var r=p.readFileSync(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(r),this._caches[e]}catch(e){this.logger.error(o.LogTagId.L_PARSE_NAVI_E,r)}return null},r.prototype.setNaviCache=function(e,t){var r=Date.now();if(o.notEmptyObject(this._caches))for(var n in this._caches){var s=this._caches[n];(r-s.timestamp>o.NAVI_CACHE_DURATION||e===s.token)&&delete this._caches[n]}this._caches[e]={token:e,naviInfo:t,timestamp:Date.now()},p.writeFileSync(this.naviPath,JSON.stringify(this._caches))},r}(o.BasicNavi);!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.NOT_INIT=-1]="NOT_INIT",e[e.CANCELED=-2]="CANCELED",e[e.REPEAT=-3]="REPEAT"}($||($={}));var fe,ge=function(e){function t(t,r,n,s,i,a){var c=e.call(this,t,n,s,i,a)||this;return c.addon=r,c._connectedTime=0,c._naviInfo=null,c.connectResolve=null,c._startTime=0,c._tcpDuration=0,c.pingResolve=null,c.addon.setConnectionStatusListener(c._onConnectionStatusChange.bind(c),(function(e){c.logger.info(y.P_DB_OPEN_O,e)}),(function(){return c.recvPong(o.ErrorCode.SUCCESS)}),c._onConnectionStatusChange.bind(c),c._onTcpConnectResponse.bind(c)),c}return S(t,e),t.prototype.getConnectedTime=function(){return this._connectedTime},t.prototype.connectWithToken=function(e,t,r,n){var s=this;return new Promise((function(i){s._naviInfo=t,s.connectResolve={resolve:i,traceId:n,userId:t.userId};var a={},c=Z().data;c&&(a={proxy_passwd:c.socksPassword||"",proxy_name:c.socksUsername||"",proxy_port:c.socksPort||1082,proxy_host:c.socksHost||"localhost",proxy_type:0});var u=JSON.stringify(E(E({},a),{call_plus:s._openCallPlus})),d=s.getCmpList(t,!0).filter((function(e){return se.includes(e.protocol)})).sort((function(e,t){return e.weight>t.weight?-1:1})),p=[];d.forEach((function(e){var t=p.find((function(t){return t.addr===e.addr}));t?t.protocol!==o.EConnectProtocol.QUIC&&e.protocol!==o.EConnectProtocol.QUIC||(t.race=!0,t.protocol=o.EConnectProtocol.QUIC):(e.race=!1,p.push(e))})),s.logger.info(y.P_CONNECT_O,JSON.stringify({use:p,catche:s.cmpWeightCache,proxy:a,FORMATED_VERSION:o.FORMATED_VERSION,reconnectKickEnable:r}),n),s._startTime=Date.now();try{s.addon.connectWithToken(e,o.FORMATED_VERSION,JSON.stringify(E(E({},t),{serverAddr:p})),r,u)}catch(e){s.logger.error(y.P_CALL_ADDON_E,null==e?void 0:e.stack,n),s.recvConnectRes(o.ErrorCode.RC_SOCKET_NOT_CREATED)}}))},t.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.addon.disconnect(t)},t.prototype.sendPing=function(e){var t=this;return new Promise((function(r){t.pingResolve=r,t.addon.sendHeartbeat(),setTimeout((function(){return t.recvPong(o.ErrorCode.TIMEOUT)}),e)}))},t.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},t.prototype._onConnectionStatusChange=function(e,t){switch(this.logger.info(y.P_CONNECT_S,JSON.stringify({status:e,delay:t})),e){case o.ErrorCode.SUCCESS:this.recvConnectRes(o.ErrorCode.SUCCESS);break;case o.ErrorCode.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(o.ErrorCode.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case o.ErrorCode.RC_SOCKET_DISCONNECTED:this.recvConnectRes(e,!1);break;case o.ErrorCode.RC_SOCKET_NOT_CREATED:case o.ErrorCode.RC_CONN_ACK_TIMEOUT:case o.ErrorCode.RC_TCP_RESET:this.recvConnectRes(e);break;case o.ErrorCode.RC_UDP_DISCONNECTED:this.recvConnectRes(e,!0,t);break;default:this.recvConnectRes(e,!0)}},t.prototype.recvConnectRes=function(e,t,r){if(this.connectResolve){var n=this.connectResolve,s=n.resolve,i=n.userId,a=Date.now()-(this._startTime+this._tcpDuration),c={bid:o.getbundleId(),cod:e,net:this.getNetwork().type,dur:a,spr:0,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:o.StatisticsVersion.CURRENT,count:this.retryCount};return this.statisticLog.__statistics(o.StatisticsTag.IM_CMP_RMTP,JSON.stringify(c)),e===o.ErrorCode.SUCCESS&&(this._connectedTime=Date.now()-this.addon.getDeltaTime()),s({code:e,data:i}),void(this.connectResolve=null)}if(t)this.onDisconnectByServer(e,r);else{if(e===o.ErrorCode.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==o.RCConnectionStatus.CONNECTED)return;this.onDisconenctUnusual(e)}},t.prototype._onTcpConnectResponse=function(e,t,r,n,s,i,a){var c,u=this.cmpWeightCache.findIndex((function(e){return e.addr==="".concat(t,":").concat(r)})),d={bid:o.getbundleId(),ptc:o.ProtocalType.TCP,cod:e,net:this.getNetwork().type,dur:n,spr:0,pr:(null===(c=this._naviInfo)||void 0===c?void 0:c.type)||0,hos:"".concat(t,":").concat(r),idx:u,rct:this.retryCount?o.ConnectType.RECONNECT:o.ConnectType.CONNECT,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:o.StatisticsVersion.CURRENT,rsn:this.reason,ddu:s,count:this.retryCount,weight:u>=0?this.cmpWeightCache[u].weight:-1};this.statisticLog.__statistics(o.StatisticsTag.IM_CMP,JSON.stringify(d)),this.logger.info(y.P_CONNECT_ENTRY_S,JSON.stringify({code:e,host:t,port:r,duration:n,dnsDuration:s,index:i,isQuic:a})),e===$.SUCCESS&&(this.curCmpUrl="".concat(t,":").concat(r),this.updateCmpWeight("".concat(t,":").concat(r),!0,a))},t}(o.AConnectionMgr),ve=function(e){function r(r,n,s,i){void 0===i&&(i=o.AreaCode.BJ);var a=e.call(this,r,n,i)||this;a.appkey=r,a.logger=n,a.dbpath=s,a._cachePath="",a._cachePath="".concat(s,"/").concat(ie.STATIC_CONFIG(r));var c=t.dirname(a._cachePath);return p.existsSync(c)||Ce(c),a}return S(r,e),r.prototype.getCache=function(){return p.existsSync(this._cachePath)&&p.readFileSync(this._cachePath,{encoding:"utf8"})||null},r.prototype.setCache=function(e){p.writeFileSync(this._cachePath,e)},r.prototype.clearCache=function(){p.writeFileSync(this._cachePath,"")},r.prototype.sendRequest=function(e){return m(this,void 0,void 0,(function(){var t,o,r;return P(this,(function(n){switch(n.label){case 0:return[4,X(this.logger,{url:e,body:""})];case 1:return t=n.sent(),o=t.status,r=t.data,[2,{code:o,data:r}]}}))}))},r.prototype.decryptData=function(e){return m(this,void 0,void 0,(function(){var t,r;return P(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,le(e,o.STATIC_CONFIG_KEY,o.STATIC_CONFIG_IV)];case 1:return t=n.sent(),[2,JSON.parse(t)];case 2:return r=n.sent(),this.logger.error(o.LogTagId.L_GET_STATIC_CONF_E,JSON.stringify({error:null==r?void 0:r.stack})),[3,3];case 3:return[2]}}))}))},r}(o.BasicStaticConfigManager),_e=function(e){function r(o,r,n,s,i,a){var c=e.call(this,r,o,n,a)||this;c.deviceId=s,c.model="",c.catchFilePath="",c.model="Electron|".concat(process.platform,"|").concat(process.arch),c.catchFilePath="".concat(i,"/").concat(ie.CLOUD_CONTROL(o));var u=t.dirname(c.catchFilePath);return p.existsSync(u)||Ce(u),c.init(),c}return S(r,e),r.prototype.httpRequest=function(e,t,r,n){return m(this,void 0,void 0,(function(){var s,i,a,c,u,d,p,l;return P(this,(function(C){switch(C.label){case 0:return(s=n).deviceId=this.deviceId,s.model=this.model,i={url:e,method:t,headers:r,body:JSON.stringify(s)},this.logger.info(o.LogTagId.L_REQUEST_T,JSON.stringify(i)),[4,X(this.logger,i)];case 1:a=C.sent(),c=a.status,u=a.data,d=void 0===u?"":u,this.logger.info(o.LogTagId.L_REQUEST_R,JSON.stringify({status:c,data:d}));try{return p=JSON.parse(d),l=p.data,[2,{code:c,data:l}]}catch(e){return this.logger.warn(o.LogTagId.L_CLOUD_CONFIG_DATA_E,JSON.stringify({status:c,data:d,error:e})),[2,{code:c,msg:e}]}return[2]}}))}))},r.prototype.setCloudControllerCache=function(e){p.writeFileSync(this.catchFilePath,JSON.stringify(e)),this.logger.info(o.LogTagId.L_CLOUD_SET_CACHE_O,JSON.stringify(e))},r.prototype.getLocalCloudControllerCache=function(){if(!p.existsSync(this.catchFilePath))return null;var e=p.readFileSync(this.catchFilePath,{encoding:"utf8"});return this.logger.info(o.LogTagId.L_CLOUD_GET_CACHE_O,JSON.stringify({appkey:this.appkey,data:e})),e},r}(o.BaseCloudController),Se=function(){function e(e,s,i,a){var c=this;this._appkey=e,this._cppProtocol=s,this._dbpath=i,this._logOutputLevel=a,this._customMessageType={},this.cloudControllerUri="",this.cloudControllerLock=!0,this.cloudControllerMsgs=[],this._senders={},this._chatroomCache=[],this.rtcHeartbeatResolves={};var u=this._dbpath||t.resolve(n.app.getPath("userData")),d=ue(u);this._cppProtocol.initWithAppkey(e,u,o.FORMATED_VERSION);var p=r.fork(t.resolve(__dirname,"sub-process.js"));this.subProxy=new pe(p);var l=t.resolve(u,"RongCloud/rclogs",e);Ce(l),function(e,t,r){r.initLogModule(t,e,o.getUUID())}(e,l,this._cppProtocol),this.logger=new L(this._appkey,"RC-M","IM"),this.statisticLog=new w(this._appkey,"RC-M","IM"),this.logger.setOutputLevel(this._logOutputLevel),N(this._cppProtocol,this.logger),this.reporter=new ne(this._cppProtocol,e,d,this.logger,this.subProxy),this.logger.info(y.P_INIT_O,JSON.stringify({appkey:e,dbpath:u,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:d,commit:"825ddc3a28961c22ec8f101474497407edd6217b"})),this._callCppProxy("setDeviceId",d),this._staticConfigManager=new ve(e,this.logger,u),this.navi=new he(e,this.logger,this.statisticLog,u,this._staticConfigManager),this.tcpMgr=new ge(e,this._cppProtocol,this.navi,this.logger,this.statisticLog,{onConnected:this.onConnected.bind(this),onSuspend:this.onSuspend.bind(this),onDisconnected:this.onDisconnected.bind(this),onConnecting:this.onConnecting.bind(this)}),this._initCloudController(d,u),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),n.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return m(c,void 0,void 0,(function(){var n,s,i;return P(this,(function(a){switch(a.label){case 0:if("function"!=typeof(n=this[t]))return this.logger.error(y.P_CALL_MAIN_SYNC_E,JSON.stringify({method:t,error:"not found"})),e.returnValue=o.ErrorCode.NOT_SUPPORT,[2];s=o.ErrorCode.NOT_SUPPORT,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,n.call.apply(n,T([this],r,!1))];case 2:return s=a.sent(),[3,4];case 3:return i=a.sent(),this.logger.error(y.P_CALL_MAIN_SYNC_E,JSON.stringify({error:null==i?void 0:i.stack,method:t})),[3,4];case 4:return e.returnValue=s,[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,r){for(var n=[],s=3;s<arguments.length;s++)n[s-3]=arguments[s];return m(c,void 0,void 0,(function(){var s,i,a,c,u=this;return P(this,(function(d){switch(d.label){case 0:if("function"!=typeof(s=this[r]))return this.logger.error(y.P_CALL_MAIN_E,JSON.stringify({method:r,error:"not found"})),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,o.ErrorCode.NOT_SUPPORT),[2];"sendMessage"===r&&(i=n[3],n[3]=function(t){u._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",i,t)}),a=o.ErrorCode.NOT_SUPPORT,d.label=1;case 1:return d.trys.push([1,3,,4]),[4,s.call.apply(s,T([this],n,!1))];case 2:return a=d.sent(),[3,4];case 3:return c=d.sent(),this.logger.error(y.P_CALL_MAIN_E,JSON.stringify({error:null==c?void 0:c.stack,method:r})),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a),[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];var n=c[t];if("function"==typeof n)try{n.call.apply(n,T([c],o,!1))}catch(e){c.logger.error(y.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else c.logger.error(y.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),n.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new de(this._cppProtocol)}return e.prototype._initCloudController=function(e,t){var r=o.urlCenter.getCloudControllerUrl();this.cloudControllerUri=r[0],this.cloudController=new _e(this._appkey,this.logger,this.reporter,e,t,this.statisticLog),o.isStartCloudController()&&this.cloudControllerUri&&this.cloudController.request(this.cloudControllerUri,o.InvokerType.init)},e.prototype.onConnected=function(){var e=this.getNaviInfoFromCache();this.reporter.checkStart(e),this._try2RejoinChatroom(),this._send2AllRenderer("onConnected",this.getMainProcessCache())},e.prototype.onConnecting=function(){this._send2AllRenderer("onConnecting",void 0)},e.prototype.onSuspend=function(e){this._send2AllRenderer("onSuspend",e)},e.prototype.onDisconnected=function(e){this._send2AllRenderer("onDisconnected",e)},e.prototype._callCppProxy=function(e){for(var t,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];var n=this.logger.createTraceId();try{return this.logger.debug(y.P_CALL_ADDON_O,JSON.stringify({method:e,content:o}),n),(t=this._cppProtocol)[e].apply(t,o)}catch(t){this.logger.error(y.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),n)}},e.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},e.prototype.sendHTTPRequest=function(e){return X(this.logger,e)},e.prototype.onRendererLogsReceived=function(e){M.apply(void 0,e)},e.prototype.onRendererNetworkStatusReceived=function(e,t){if(this.tcpMgr.setNetwork(e,t),e.status&&o.isStartCloudController()&&this.cloudController){var r=this.tcpMgr.getToken();this.cloudController.request(this.cloudControllerUri,o.InvokerType.newWorkChange,r)}},e.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){O(),e.deinitLogModule()}(this._cppProtocol),this._cppProtocol.destroy()},e.prototype.callExtra=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=this[e];if(!n)return this.logger.warn(y.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:o.ErrorCode.NOT_SUPPORT});try{return n.call.apply(n,T([this],t,!1))}catch(t){this.logger.error(y.P_CALL_EXTRA_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,r,n){var s,i=this,a=this._callCppProxy("getConversationListByPage",e,t,r,n||"");try{s=JSON.parse(a).list.map((function(e){return i._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.getUnreadConversationList=function(e){var t,r=this,n=this._callCppProxy("getUnreadConversationList",e);try{t=JSON.parse(n).list.map((function(e){return r._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:t})},e.prototype.getConversationListWithAllChannel=function(){var e,t=this,r=[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.APP_PUBLIC_SERVICE,o.ConversationType.PUBLIC_SERVICE],n=this._callCppProxy("getConversationListWithAllChannel",r);try{e=JSON.parse(n).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:e})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var r,n=this,s=[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.APP_PUBLIC_SERVICE,o.ConversationType.PUBLIC_SERVICE],i=this._callCppProxy("getConversationListWithAllChannelByPage",s,e,t);try{r=JSON.parse(i).list.map((function(e){return n._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:r})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,r,n,s,i,a){var c=0===i,u=n+1,d=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,r,u,s,c,a||""),p=[];try{var l=JSON.parse(d).list;l.reverse();for(var C=0;C<l.length;C++){var h=this._buildMessage(l[C].obj);p[C]=h}}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:{list:u===p.length?p.slice(1,u):p,hasMore:n<p.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,r,n){void 0===n&&(n="");var s=this._callCppProxy("updateMessageReceiptStatus",e,t,r,n);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==o.RCConnectionStatus.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},e.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new L(this._appkey,e,t)},e.prototype.getConnectedTime=function(){return this.tcpMgr.getConnectedTime()},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){return this.tcpMgr.getCurrentUserId()},e.prototype._send2Renderer=function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,T([t],o,!1))},e.prototype._send2AllRenderer=function(e,t,o){var r=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(n){var s=r._senders[n];o.includes(s)||r._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),o=this.getNaviInfoFromCache(),r=this.tcpMgr.getCurrentUserId();return{connectedTime:e,deviceId:this.getDeviceId(),crtUserId:r,naviInfo:o,connectionStatus:t}},e.prototype._registerRenderers=function(e,t){var r=this,n=e.sender,s=n.id,i=t.navigators,a=t.areaCode,c=t.logServerUrl;this._staticConfigManager.setAreaCode(a),o.urlCenter.init({areaCode:a,navigators:i,logServerUrl:c}),this._senders[s]||(this._senders[s]=n,n.once("destroyed",(function(){delete r._senders[s]})))},e.prototype._registerMsgTypes=function(){for(var e in o.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},o.SEND_MESSAGE_TYPE_OPTION){var t=o.SEND_MESSAGE_TYPE_OPTION[e],r=t.isCounted,n=t.isPersited,s=t.searchProps,i=0;n&&(i|=1),r&&(i|=2),"RC:TypSts"===e&&(i=16),this._callCppProxy("registerMessageType",e,i,s||[])}},e.prototype._buildIsMentioned=function(e,t){var r,n=!1;if(o.isObject(e))r=e;else try{r=e?JSON.parse(e):e}catch(o){r=e,this.logger.error(y.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:t}))}return o.isObject(r)&&(n=!!r.mentionedInfo),{isMentioned:n,msgContent:r}},e.prototype._buildMsgOption=function(e){var t={isCounted:!1,isPersited:!1};return e in o.SEND_MESSAGE_TYPE_OPTION?t=o.SEND_MESSAGE_TYPE_OPTION[e]:e in this._customMessageType&&(t=this._customMessageType[e]),t},e.prototype._buildSupportExt=function(e,t,o){var r=null;return e&&(r=this._msgExpansionHandler.parseReceiveExpansion(o),"conversation"!==t&&"history"!==t||(r=this._msgExpansionHandler.parseConverOrHisExpansion(o))),r},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var r=t.isOffLineMessage,n=t.buildFrom,s=JSON.parse(e),i=s.channelId,a=s.conversationType,c=s.targetId,u=s.senderUserId,d=s.content,p=s.objectName,l=s.messageUid,C=s.direction,h=s.status,f=s.messageId,g=s.sentTime,v=s.readReceiptRequest,_=s.supportExt,S=s.pushContent,y=s.pushTitle,m=s.pushId,P=s.pushConfig,T=s.templateId,I=s.disableTitle,R=s.forcePushDetail,O=s.hasMore,N=this._buildIsMentioned(d,f),M=N.isMentioned,U=N.msgContent,b=this._buildMsgOption(p),L=this._buildSupportExt(_,n,s),w=o.isUndefined(r)?g<this.tcpMgr.getConnectedTime():r,x={};P&&(x=o.pushJSONToConfigs(this.logger,P,m));var A=E(E({},x),{pushTitle:y,pushContent:S,pushData:S,disablePushTitle:I,forceShowDetailContent:R,templateId:T}),D={channelId:i,conversationType:a,targetId:c,senderUserId:u,content:U||{},messageType:p,messageUId:l||"",messageDirection:C,isOffLineMessage:w,sentTime:g,receivedTime:0,isPersited:b.isPersited,isCounted:b.isCounted,isMentioned:M,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:_,expansion:_?L:null,receivedStatus:h,messageId:f,pushConfig:A,hasMore:O};if(C===o.MessageDirection.RECEIVE?D.receivedStatus=h:C===o.MessageDirection.SEND&&(D.sentStatus=h),v){var k=JSON.parse(v),J=k.hasRespond,F=k.readerInfo,j={readCount:k.readCount,totalCount:k.totalCount},B=[];if(F)for(var H in F)B.push({userId:H,readTime:F[H]});var V=this.getNaviInfoFromCache();1===(null==V?void 0:V.grpRRVer)&&(j.readerList=B,j.hasRespond=J),D.readReceiptInfo=j}return D},e.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),r=JSON.parse(o),n=r.readReceiptRequest?JSON.parse(r.readReceiptRequest):{},s=E(E({},n),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},e.prototype._processRSMsg=function(e){this.getNaviInfoFromCache();var t=e.conversationType,r=e.targetId,n=e.content,s=e.channelId,i=n.msgId,a=n.rrn,c=n.tmn,u=n.endMsgTime;t===o.ConversationType.PRIVATE?this.updateMessageReceiptStatus(t,r,u,s||""):this._updateReadReceiptInfo(i,{readCount:a,totalCount:c});var d={conversationType:t,targetId:r,channelId:s};this._sendMessageReadReceipt(t===o.ConversationType.PRIVATE?{privateReadReceipt:E(E({},d),{endMsgTime:n.endMsgTime})}:{groupReadReceipt:E(E({},d),{totalCount:n.tmn,readCount:n.rrn,messageUId:n.msgId})})},e.prototype._processSRSMsg=function(e){var t=this.getNaviInfoFromCache(),o=e.conversationType,r=e.targetId,n=e.content,s=e.channelId,i=e.senderUserId,a=e.sentTime;return i===this.tcpMgr.getCurrentUserId()&&(this._callCppProxy("clearUnreadCountByTimestamp",o,r,n.lastMessageSendTime,s||""),1!==(null==t?void 0:t.sesDriven)||(a>this.tcpMgr.getConnectedTime()||this._sendsyncReadStatus({conversationType:o,targetId:r,channelId:s,timestamp:n.timestamp}),!1))},e.prototype._buildConversation=function(e){var t=JSON.parse(e),r=t.channelId,n=t.conversationType,s=t.targetId,i=t.unreadCount,a=t.lastestMsg,c=t.isTop,u=t.blockStatus,d=t.matchCount,p=t.hasUnreadMention,l=t.conversationTime,C=t.draft,h=u>0?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE;return{channelId:r,conversationType:n,targetId:s,unreadMessageCount:i,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:p,mentionedInfo:null,notificationStatus:h,isTop:c,lastUnreadTime:0,matchCount:d,operationTime:l,notificationLevel:u,draft:C}},e.prototype._convertResultList=function(e,t){var o=JSON.parse(e).list;return o=o.map((function(e){var o=JSON.parse(e.obj);return t?t(o):o}))},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,r,n,s){var i,a=e._buildMessage(t,{isOffLineMessage:n}),c=a.messageType,u=a.channelId,d=void 0===u?"":u,p=a.senderUserId,l=a.content;a.canIncludeExpansion;var C=a.messageUId,h=a.conversationType,f=a.targetId;if(e.getNaviInfoFromCache(),c!==o.MessageType.LOG_COMMAND||p!==o.RC_DEFAULT_USER){if(c===o.MessageType.CLOUD_CONTROL&&p===o.RC_DEFAULT_USER)return e.cloudControllerMsgs.push(a),void e._ccMsgHandler();if(c===o.MessageType.GROUP_READ_RECEIPT_REQUEST){var g=l.msgId,v=l.rrn,_=l.tmn;e._updateReadReceiptInfo(g,{readCount:v,totalCount:_})}if(c!==o.MessageType.READ_STATE){if("RC:MsgExMsg"===c)return e._msgExpansionHandler.setLocalFromExtMsg(e.logger,a),void e._sendMessageExpansion(a);if(c===o.MessageType.READ_RECEIPT&&p===e.tcpMgr.getCurrentUserId()&&e._callCppProxy("clearUnreadCountByTimestamp",h,f,l.lastMessageSendTime,d),c!==o.MessageType.SYNC_READ_STATUS||e._processSRSMsg(a)){var S=!0;if(0!==r||s||(S=!1),c===o.MessageType.DELIVERED)return e._callCppProxy("setMessageDeliverTime",JSON.stringify(l)),void e._sendMessageDelivered(l.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}})));if(c!==o.MessageType.DELIVERED_MSG){if(c===o.MessageType.RECALL){e.handleRecalledMessage(a);var y=e._fixRecallContentInfo(a);h=y.conversationType,f=y.targetId}e._sendMessageNotification(Object.assign(a,{hasMoreMsg:S,conversationType:h,targetId:f}))}else{var E={totalCount:l.tmn,list:null===(i=l.dl)||void 0===i?void 0:i.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};e._sendGroupMessageDeliveredStatus(E)}}}else e._processRSMsg(a)}else{var m=l.startTime,P=l.endTime,T=l.platform,I=l.logId,R=l.uri;e.reporter.report(parseInt(m,10),parseInt(P,10),T,R,I,C)}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._ccMsgHandler=function(){var e;return m(this,void 0,void 0,(function(){var t,r;return P(this,(function(n){switch(n.label){case 0:return this.cloudControllerLock?(this.cloudControllerLock=!1,this.cloudControllerMsgs.shift()?(t=this.tcpMgr.getToken(),[4,null===(e=this.cloudController)||void 0===e?void 0:e.request(this.cloudControllerUri,o.InvokerType.other,t)]):[3,2]):[2];case 1:r=n.sent()||0,this.cloudControllerMsgs=this.cloudControllerMsgs.filter((function(e){return e.sentTime>r})),this.cloudControllerLock=!0,this._ccMsgHandler(),n.label=2;case 2:return[2]}}))}))},e.prototype._fixRecallContentInfo=function(e){var t=e.conversationType,o=e.targetId;return e.senderUserId===this.tcpMgr.getCurrentUserId()&&(t=e.content.conversationType||t,o=e.content.targetId||o),{conversationType:t,targetId:o}},e.prototype.handleRecalledMessage=function(e){var t=e.content,r=t.messageUId,n=t.sentTime;if(r){var s=this._callCppProxy("getMessage",r),i=this._buildMessage(s,{isOffLineMessage:!1});if(e.content.isDelete){if(-1===i.messageId)return;this._callCppProxy("deleteMessages",[i.messageId])}else{var a={recallTime:Date.now(),admin:!!e.content.isAdmin,originalObjectName:i.messageType,originalMessageContent:i.content,recallActionTime:e.sentTime,operatorId:e.senderUserId};if(e.content.user&&(a.user=e.content.user),e.content.extra&&(a.extra=e.content.extra),i.messageType===o.MessageType.TextMessage&&(a.recallContent=i.content.content),-1!==i.messageId)i.receivedStatus||this.setMessageReceivedStatus(i.messageId,1),this._callCppProxy("setMessageContent",i.messageId,JSON.stringify(a),o.MessageType.RECALL_NOTIFICATION_MESSAGE);else{var c=e.conversationType,u=e.targetId,d=e.senderUserId,p=e.channelId,l=e.messageDirection;this._callCppProxy("insertMessage",c,u,d,o.MessageType.RECALL_NOTIFICATION_MESSAGE,JSON.stringify(a),(function(){}),(function(){}),l,1,10,n,"",0,r,!1,!0,JSON.stringify({}),p||"")}}}},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var o=e.channelId,r=e.content,n=r.put,s=r.del,i=r.mid,a={};n&&(a.updatedExpansion={channelId:o,messageUId:i,expansion:n}),s&&(a.deletedExpansion={channelId:o,messageUId:i,deletedKeys:s}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._sendMessageDelivered=function(e){this._send2AllRenderer("messageDelivered",e)},e.prototype._sendGroupMessageDeliveredStatus=function(e){this._send2AllRenderer("groupMessageDeliveredStatus",e)},e.prototype._sendChatroomStatus=function(e){this._send2AllRenderer("chatroom",e)},e.prototype._sendMessageReadReceipt=function(e){this._send2AllRenderer("messageReadReceipt",e)},e.prototype._sendsyncReadStatus=function(e){this._send2AllRenderer("syncReadStatus",e)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var r=JSON.parse(t).list,n=[];r.forEach((function(e){var t=JSON.parse(e.obj),r=t.conversationType,s=t.targetId,i=t.status,a=t.channelId,c={notificationStatus:2,isTop:!1};i.forEach((function(e){var t=JSON.parse(e.item);1===t.type?c.notificationStatus=1===Number(t.value)?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE:c.isTop=1===Number(t.value)})),n.push({channelId:a,conversationType:r,targetId:s,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),e._send2AllRenderer("conversation",n)}),(function(t){e._send2AllRenderer("conversationTag",t)}),(function(t,o,r,n){e._callCppProxy("clearUnreadCountByTimestamp",t,o,n,r||""),e._sendsyncReadStatus({conversationType:t,targetId:o,channelId:r,timestamp:n})}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._send2AllRenderer("tag",t),e._getRTCProfile()}))},e.prototype._getRTCProfile=function(){var e=this._callCppProxy("getRTCProfile");if(e){var t=this.tcpMgr.getToken();this.navi.updateVoipCallInfo(t,e);var o=this.navi.getNaviInfoFromCache(t);this._send2AllRenderer("onNaviDataChange",o)}},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var o=new Uint8Array(t).buffer;e._send2AllRenderer("onRTCDataChange",o)}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._sendChatroomStatus({chatroomDestroyed:t})}))},e.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},e.prototype._updateMentionedInfo=function(e,t,r){var n,s,i;return{userIdList:(null===(n=e.mentionedInfo)||void 0===n?void 0:n.userIdList)||t,type:(null===(s=e.mentionedInfo)||void 0===s?void 0:s.type)||r||o.MentionedType.ALL,mentionedContent:(null===(i=e.mentionedInfo)||void 0===i?void 0:i.mentionedContent)||""}},e.prototype.registerMessageType=function(e,t,o,r){void 0===r&&(r=[]);var n=0;t&&(n|=1),o&&(n|=2),this._customMessageType[e]={isCounted:o,isPersited:t},this.logger.info(y.P_REGTYP_O,JSON.stringify({type:e,opt:n,search:r})),this._callCppProxy("registerMessageType",e,n,r)},e.prototype.connect=function(e,t,o,r){return this.tcpMgr.connect(e,t,o,r)},e.prototype.reportSDKInfo=function(e){var t,o,r=JSON.stringify(E(E({},e),{"electron-main":"5.8.5-alpha.3"}));this.logger.info(y.P_REPORT_VER_O,r),null===(o=(t=this._cppProtocol).uploadSDKVersion)||void 0===o||o.call(t,r,"")},e.prototype.disconnect=function(e){this._chatroomCache.length=0,this.reporter.stop(),z(null,this.logger),this.tcpMgr.disconnect(e)},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,o){t({userId:e,status:o})}));var o=e.userIds||[];o.length&&this.subscribeUserStatus(o)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(r){t._callCppProxy("subscribeUserStatus",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(r){t._callCppProxy("setUserStatus",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(r){t._callCppProxy("getUserStatus",e,(function(e){r({code:o.ErrorCode.SUCCESS,data:{status:e}})}),(function(e){r({code:e})}))}))},e.prototype.sendMessage=function(e,t,r,n,s){var i=this;void 0===s&&(s=this.logger.createTraceId());var a=r.messageType,c=r.content,u=r.expansion,d=r.pushConfig,p=r.isMentioned,l=r.mentionedType,C=r.mentionedUserIdList,h=void 0===C?[]:C,f=r.pushContent,g=void 0===f?"":f,v=r.pushData,_=void 0===v?"":v,S=r.directionalUserIdList,E=void 0===S?[]:S,m=r.disableNotification,P=void 0!==m&&m,T=r.canIncludeExpansion,I=void 0!==T&&T,R=r.isVoipPush,O=void 0!==R&&R,N=r.channelId,M=void 0===N?"":N,U=r.messageId,b=void 0===U?0:U,L=d||{},w=L.iOSConfig,x=L.androidConfig,A=L.templateId,D=void 0===A?"":A,k=L.pushTitle,J=void 0===k?"":k,F=L.pushContent,j=void 0===F?g:F,B=L.pushData,H=void 0===B?_:B,V=L.disablePushTitle,G=void 0!==V&&V,q=L.forceShowDetailContent,K=void 0!==q&&q,W=o.pushConfigsToJSON(w,x);return new Promise((function(r){g=j,_=H;var d=(null==x?void 0:x.notificationId)||"";e===o.ConversationType.GROUP&&p&&c&&(c.mentionedInfo=i._updateMentionedInfo(c,h,l));var C=e===o.ConversationType.GROUP;if(C&&a===o.MessageType.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var f in c.receiptMessageDic)E.push(f);C&&a===o.MessageType.SYNC_READ_STATUS&&(E=[i.getCurrentUserId()]);var v={};for(var f in u)v[f]={v:""},v[f].v=u[f];var S=D;i.logger.info(y.P_SEND_MSG_T,JSON.stringify({messageType:a,conversationType:e,targetId:t,channelId:M}),s);var m=i._callCppProxy("sendMessage",(function(e,t){var n=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.info(y.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:n.messageUId}),s),t===o.ErrorCode.SENSITIVE_REPLACE?r({code:t}):("RC:MsgExMsg"===n.messageType&&i._msgExpansionHandler.setLocalFromExtMsg(i.logger,n),n.canIncludeExpansion&&i._msgExpansionHandler.setLocalFromReceiveMsg(i.logger,n),r({code:o.ErrorCode.SUCCESS,data:n}))}),(function(e,t){var o=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.warn(y.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),s),o.sentTime=Date.now()-i._cppProtocol.getDeltaTime(),r({code:t,data:o})}),e,t,a,JSON.stringify(c),E,P,G,K,g,_,d,J,W,S,I,JSON.stringify(v),O,M,b),T=JSON.parse(m);null==n||n(T.messageId)}))},e.prototype.recallMsg=function(e,t,r,n,s){var i=this;return new Promise((function(a){var c,u=s.user,d=s.pushContent,p=s.channelId,l=s.extra,C=s.pushConfig,h=s.disableNotification,f=s.isDelete,g={conversationType:e,targetId:t,messageUId:r,sentTime:n,user:u,extra:l,channelId:p,isDelete:f||!1};u&&(g.user=u),l&&(g.extra=l);var v={conversationType:e,targetId:t,senderUserId:i.tcpMgr.getCurrentUserId(),content:g,objectName:o.MessageType.RECALL,messageUid:r,direction:o.MessageDirection.SEND,status:o.ReceivedStatus.UNREAD,sentTime:n,channelId:p},_=i._buildMessage(JSON.stringify(v),{isOffLineMessage:!1});i._callCppProxy("recallMessage",(function(){i.handleRecalledMessage(_),a({code:o.ErrorCode.SUCCESS,data:_})}),(function(e){a({code:e})}),o.MessageType.RECALL,JSON.stringify(g),h||!1,(null==C?void 0:C.disablePushTitle)||!1,(null==C?void 0:C.forceShowDetailContent)||!1,d||"",(null==C?void 0:C.pushData)||"",(null===(c=null==C?void 0:C.androidConfig)||void 0===c?void 0:c.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)||"",p)}))},e.prototype.getHistoryMessage=function(e,t,r,n,s,i,a){var c=this;return new Promise((function(u){r=r||0;var d=0===s,p=n+1,l=c._callCppProxy("getHistoryMessages",e,t,r,p,a,d,i),C=JSON.parse(l).list,h=[];C.reverse();for(var f=0;f<C.length;f++){var g=c._buildMessage(C[f].obj);h[f]=g}u({code:o.ErrorCode.SUCCESS,data:{list:p===h.length?h.slice(1,p):h,hasMore:n<h.length}})}))},e.prototype.getMessages=function(e,t,r,n,s,i){var a=this;return void 0===r&&(r=0),new Promise((function(c){var u=0===s,d=r,p=0!==r,l=n+1;p&&(d+=u?1:-1,l++);for(var C=a._callCppProxy("getMessages",e,t,d,l,u,i),h=JSON.parse(C).list,f=[],g=0;g<h.length;g++){var v=a._buildMessage(h[g].obj);f[g]=v}var _=a._computeRepairInfo(f,u,r,d,l),S=_.isNeedRepair,y=void 0!==S&&S,E=_.repairTime,m=void 0===E?0:E;if(!y)return p&&(f.shift(),l--),f.reverse(),void c({code:o.ErrorCode.SUCCESS,data:{list:l===f.length?f.slice(1,l):f,hasMore:n<f.length}});a._processRepairHisMsg(e,t,r,n,s,i,m,c)}))},e.prototype._computeRepairInfo=function(e,t,o,r,n){var s=!1,i=0,a=this.getNaviInfoFromCache()||{},c=a.repairHisMsg,u=void 0===c?0:c,d=a.historyMsg;if(1!==u||!d)return{isNeedRepair:s,repairTime:i};var p=e.findIndex((function(e){return e.hasMore||0===Object.keys(e.content).length}));return t&&p>=0?(s=!0,i=e[p].hasMore?e[p].sentTime:e[p].sentTime+1):!t&&p>=1?(s=!0,i=e[p-1].sentTime):0===o?(s=!0,i=0):e.length<n?(s=!0,i=o):e.length>0&&e[0].sentTime!==o&&(s=!0,i=r),{isNeedRepair:s,repairTime:i}},e.prototype._processRepairHisMsg=function(e,t,o,r,n,s,i,a){var c=this,u=function(i){for(var u=0===n,d=r+1,p=c._callCppProxy("getMessages",e,t,o,d,u,s),l=JSON.parse(p).list,C=[],h=0;h<l.length;h++){var f=c._buildMessage(l[h].obj);C[h]=f}C.reverse(),a({code:i,data:{list:d<=C.length?C.slice(1,d):C,hasMore:r<C.length}})},d=r+10>100?100:r+10;this._callCppProxy("getRemoteHistoryMessages",e,t,i,d,(function(){return u(0)}),(function(e){u(e)}),n,!0,s,!1)},e.prototype.getRemoteHistoryMessages=function(e,t,r,n,s,i){var a=this;return new Promise((function(c){r=r||0;a._callCppProxy("getRemoteHistoryMessages",e,t,r,n,(function(e,t){var r=JSON.parse(e).list,n=[];r.reverse();for(var s=0;s<r.length;s++){var i=a._buildMessage(r[s].obj);n[s]=i}c({code:o.ErrorCode.SUCCESS,data:{list:n,hasMore:!!t}})}),(function(e){c({code:e})}),s,!0,i)}))},e.prototype.deleteRemoteMessage=function(e,t,r,n){var s=this;return new Promise((function(i){var a=JSON.stringify(r);s._callCppProxy("deleteRemoteHistoryMessages",e,t,a,!1,n,(function(){i(o.ErrorCode.SUCCESS)}),i)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("clearRemoteHistoryMessages",e,t,r,(function(){i(o.ErrorCode.SUCCESS)}),(function(e){i(e)}),n)}))},e.prototype.clearMessages=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("clearMessages",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.getConversationList=function(e,t,r,n,s){var i=this;return void 0===s&&(s=""),new Promise((function(e){for(var t=i._callCppProxy("getConversationList",[1,3,6,7],s),r=JSON.parse(t).list,n=[],a=0;a<r.length;a++)n.push(i._buildConversation(r[a].obj));e({code:o.ErrorCode.SUCCESS,data:n})}))},e.prototype.getConversation=function(e,t,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getConversation",e,t,r);if(i)s({code:o.ErrorCode.SUCCESS,data:n._buildConversation(i)});else{var a=n._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,r),c=void 0;try{c=JSON.parse(a).list}catch(e){n.logger.error(y.P_PARSE_JSON_MSGS_E,null==e?void 0:e.stack),c=[]}var u=null;c.length>0&&(u=n._buildMessage(c[0].obj));var d=n._callCppProxy("getConversationNotificationStatus",e,t,r),p=n._callCppProxy("getConversationTopStatus",e,t,r);s({code:o.ErrorCode.SUCCESS,data:{conversationType:e,targetId:t,channelId:r,unreadMessageCount:0,latestMessage:u,notificationStatus:d?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE,isTop:Boolean(p),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,r){var n=this._callCppProxy("removeConversation",e,t,r);return Promise.resolve(n?o.ErrorCode.SUCCESS:o.ErrorCode.CONVER_REMOVE_ERROR)},e.prototype.clearConversations=function(e,t){var r=this;return new Promise((function(n){var s=[];s=o.isArray(e)?e:[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.PUBLIC_SERVICE],r._callCppProxy("clearConversations",s,t||""),n(o.ErrorCode.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,r){var n=this._callCppProxy("getTotalUnreadCount",t,r,e);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:n})},e.prototype.getConversationUnreadCount=function(e,t,r){var n=this;return void 0===r&&(r=""),new Promise((function(s){var i=n._callCppProxy("getUnreadCount",e,t,r);s({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.clearConversationUnreadCount=function(e,t,r){var n=this;return void 0===r&&(r=""),new Promise((function(s){n._callCppProxy("clearUnreadCount",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("clearUnreadCountByTimestamp",e,t,r,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getTheFirstUnreadMessage",e,t,r),a=n._buildMessage(i);s({code:o.ErrorCode.SUCCESS,data:-1!==a.messageId?a:null})}))},e.prototype.setConversationToTop=function(e,t,r,n){var s=this;return void 0===n&&(n=""),new Promise((function(i){s._callCppProxy("setConversationToTop",e,t,r,n,!0),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("setConversationHidden",e,t,r,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("setConversationNotificationStatus",e,t,r,(function(){i(o.ErrorCode.SUCCESS)}),i,n)}))},e.prototype.setConversationStatus=function(e,t,r,n,s){var i=this;return new Promise((function(a){i._callCppProxy("setConversationStatus",e,t,r,n,(function(){a(o.ErrorCode.SUCCESS)}),a,s,!0)}))},e.prototype.getConversationNotificationStatus=function(e,t,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getConversationNotificationStatus",e,t,r);s({code:o.ErrorCode.SUCCESS,data:i?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,r,n){var s=this;return new Promise((function(i){n=n||[1,3,6,7];for(var a=s._callCppProxy("searchConversationByContent",n,e,t,r),c=JSON.parse(a).list,u=[],d=0;d<c.length;d++)u[d]=s._buildConversation(c[d].obj);i({code:o.ErrorCode.SUCCESS,data:u})}))},e.prototype.searchConversationByContentWithAllChannel=function(e,t,r){var n=this;return new Promise((function(s){r=r||[1,3,6,7];for(var i=n._callCppProxy("searchConversationByContentWithAllChannel",r,e,t),a=JSON.parse(i).list,c=[],u=0;u<a.length;u++)c[u]=n._buildConversation(a[u].obj);s({code:o.ErrorCode.SUCCESS,data:c})}))},e.prototype.searchMessageByContent=function(e,t,r,n,s,i,a){var c=this;return new Promise((function(i){c._callCppProxy("searchMessageByContent",e,t,r,n,s,1,(function(e,t){for(var r=e?JSON.parse(e).list:[],n=[],s=0;s<r.length;s++)n[s]=c._buildMessage(r[s].obj);i({code:o.ErrorCode.SUCCESS,data:{messages:n,count:t}})}),a)}))},e.prototype.searchMessagesByUser=function(e,t,r,n,s,i){var a=this;return new Promise((function(c){a._callCppProxy("getMessageBySender",e,t,r,n,s,i,(function(e){for(var t=e?JSON.parse(e).list:[],r=[],n=0;n<t.length;n++)r[n]=a._buildMessage(t[n].obj);c({code:o.ErrorCode.SUCCESS,data:{messages:r}})}))}))},e.prototype.searchMessageByContentWithAllChannel=function(e,t,r,n,s){var i=this;return new Promise((function(a){i._callCppProxy("searchMessageByContentWithAllChannel",e,t,r,n,s,1,(function(e,t){for(var r=e?JSON.parse(e).list:[],n=[],s=0;s<r.length;s++)n[s]=i._buildMessage(r[s].obj);a({code:o.ErrorCode.SUCCESS,data:{messages:n,count:t}})}))}))},e.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,r,n,s,i,a){var c=this;return new Promise((function(u){c._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,r,n,s,i,a,(function(e){for(var t=e?JSON.parse(e).list:[],r=[],n=0;n<t.length;n++)r[n]=c._buildMessage(t[n].obj);u({code:o.ErrorCode.SUCCESS,data:{messages:r}})}))}))},e.prototype.getUnreadMentionedMessages=function(e,t,o){for(var r=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,n=0;n<r.length;n++)r[n]=this._buildMessage(r[n].obj);return r},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(r){t._callCppProxy("addToBlacklist",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(r){t._callCppProxy("removeFromBlacklist",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t){e._callCppProxy("getBlacklist",(function(e){t({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(r){t._callCppProxy("getBlacklistStatus",e,(function(e){r({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){r({code:e})}))}))},e.prototype.insertMessage=function(e,t,r){var n=this,s=r.content,i=r.senderUserId,a=r.messageType,c=r.messageDirection,u=r.readStatus,d=r.sentStatus,p=r.sentTime,l=r.searchContent,C=r.isUnread,h=r.messageUId,f=r.disableNotification,g=r.canIncludeExpansion,v=r.expansionMsg,_=r.channelId;s=JSON.stringify(s);var S={};if(p=p||0,v){var y=JSON.parse(v);for(var E in y)S[E]={v:"",ts:0},S[E].v=y[E],S[E].ts=p}return new Promise((function(r){var v=C?0:1,y=n._callCppProxy("insertMessage",e,t,i,a,s,(function(){}),(function(e){r({code:e})}),c,u||0,d||10,p,l||"",v,h||"",!!f,!!g,JSON.stringify(S),_||""),E=n._buildMessage(y,{isOffLineMessage:!1});E.messageUId=h,E.sentTime=p,r({code:-1===E.messageId?o.ErrorCode.MSG_INSERT_ERROR:o.ErrorCode.SUCCESS,data:E})}))},e.prototype.batchInsertMessage=function(e,t){var r=this;return void 0===t&&(t=!1),new Promise((function(n){var s=e.map((function(e){var t=e.content,o=e.senderUserId,r=e.messageType,n=e.messageDirection,s=e.receivedStatus,i=e.sentStatus,a=e.sentTime,c=e.searchContent,u=e.isUnread,d=e.messageUId,p=e.disableNotification,l=e.canIncludeExpansion,C=e.expansion,h=e.channelId,f=e.conversationType,g=e.targetId,v=e.source,_=e.isMentioned,S={};if(a=a||0,C)for(var y in C)S[y]={v:"",ts:0},S[y].v=C[y],S[y].ts=a;return{conversationType:f,targetId:g,channelId:h||"",direction:n,senderUserId:o,status:i||10,sentTime:a,objectName:r,content:JSON.stringify(t),messageUid:d||"",noNotification:!!p,supportExt:!!l,extMsg:JSON.stringify(S),readStatus:s||0,searchContent:c||"",isUnread:!!u,source:v||"",isMention:_}})),i=r._callCppProxy("insertMessages",JSON.stringify(s),t);n({code:i?o.ErrorCode.SUCCESS:o.ErrorCode.MSG_INSERT_ERROR,data:i||!1})}))},e.prototype.getMessageCount=function(e,t,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getMessageCount",e,t,r);s({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(r){t._callCppProxy("deleteMessages",e),r(o.ErrorCode.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,r,n,s){var i=this;return new Promise((function(a){i._callCppProxy("deleteMessagesByTimestamp",e,t,r,n,s),a(o.ErrorCode.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(r){var n=t._callCppProxy("getMessage",e),s=t._buildMessage(n,{isOffLineMessage:!1});r({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.setMessageContent=function(e,t,r){var n=this;return new Promise((function(s){t=JSON.stringify(t),n._callCppProxy("setMessageContent",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("setMessageSearchField",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var r=this;return new Promise((function(n){r._callCppProxy("setMessageSentStatus",e,t),n(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var r=this;return new Promise((function(n){r._callCppProxy("setMessageReceivedStatus",e,t),n(o.ErrorCode.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("saveTextMessageDraft",e,t,r,n||"")&&i(o.ErrorCode.SUCCESS),i(o.ErrorCode.DRAFT_SAVE_ERROR)}))},e.prototype.getConversationMessageDraft=function(e,t,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getTextMessageDraft",e,t,r||"");s({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.clearConversationMessageDraft=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("clearTextMessageDraft",e,t,r||"")&&s(o.ErrorCode.SUCCESS),s(o.ErrorCode.DRAFT_REMOVE_ERROR)}))},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],r=t.conversationType,n=t.targetId,s=t.isTop,i=t.notificationStatus,a=t.channelId,c=this._callCppProxy("getConversationNotificationStatus",r,n,a||""),u=this._callCppProxy("getConversationTopStatus",r,n,a||""),d=o.isUndefined(i)?Boolean(c):i===o.NotificationStatus.OPEN,p=o.isUndefined(s)?Boolean(u):s;return this.setConversationStatus(r,n,d,p,a)},e.prototype.getConversationNotificationLevel=function(e,t,r){return m(this,void 0,void 0,(function(){var n;return P(this,(function(s){return n=this._callCppProxy("getBlockPushLevelForConversation",t,r,e),[2,Promise.resolve({code:o.ErrorCode.SUCCESS,data:n})]}))}))},e.prototype.setConversationNotificationLevel=function(e,t,r,n){var s=this;return void 0===n&&(n=""),new Promise((function(i){s._callCppProxy("setBlockPushLevelForConversation",t,n,e,r,(function(){i(o.ErrorCode.SUCCESS)}),(function(e){i(e)}))}))},e.prototype.getTotalUnreadCountByLevels=function(e,t,r){if(r){var n=this._callCppProxy("getUnreadMentionedCountByLevel",e,t);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:n})}var s=this._callCppProxy("getUnreadCountByLevel",e,t);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("sendReadReceipt",e,r||"",t,(function(){t.forEach((function(e){n._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(n._callCppProxy("getMessage",e)).messageId;n.setMessageReceivedStatus(t,1)}catch(t){n.logger.error(y.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),s({code:o.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},e.prototype.getMessageReader=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("getMessageReader",e,r,t,(function(e,r){var i=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;i.push({userId:o,readTime:r}),a[o]=r}));var c={readerInfo:a,readCount:i.length,totalCount:r};n._updateReadReceiptInfo(t,c),s({code:o.ErrorCode.SUCCESS,data:{list:i,totalMemberCount:r}})}),(function(e){s({code:e})}))}))},e.prototype.sendReadReceiptMessageV4=function(e,t,r){var n=this;return new Promise((function(s){var i=e.conversationType,a=e.targetId,c=e.channelId;n._callCppProxy("sendMessageReadReceipt",i,a,c||"",t,r,(function(){s({code:o.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},e.prototype.getMessageReadReceiptV4=function(e,t){var r=this;return new Promise((function(n){var s=e.targetId,i=e.channelId;r._callCppProxy("getMessageReadReceipt",s,i||"",t,(function(e){var t=[];try{JSON.parse(e).list.forEach((function(e){var o=JSON.parse(e.obj),r=o.id,n=o.time;t.push({userId:r,readTime:n})}))}catch(t){r.logger.error(y.P_PARSE_JSON_E,"method: getMessageReadReceipt, info: ".concat(e,", error: ").concat(t))}n({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},e.prototype.updateConversationReadTime=function(e,t){var r=this;return new Promise((function(n){var s=e.conversationType,i=e.targetId,a=e.channelId;r._callCppProxy("updateConversationReadTime",s,i,a||"",t,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype._addChatroomCache=function(e,t,o){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:o,count:t})},e.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},e.prototype._try2RejoinChatroom=function(){var e=this;if(0!==this._chatroomCache.length){var t=this.logger.createTraceId();this._chatroomCache.forEach((function(r){return m(e,void 0,void 0,(function(){var e,n,s,i,a,c;return P(this,(function(u){switch(u.label){case 0:return e=r.chatroomId,n=r.joinExist,s=r.count,this.logger.info(o.LogTagId.L_REJOIN_CHATROOM_T,e,t),[4,this._joinChrm(e,s,n,!1)];case 1:return i=u.sent(),a=i.code,c=i.data,a===o.ErrorCode.SUCCESS?(this.logger.info(o.LogTagId.L_REJOIN_CHATROOM_R,e,t),this._sendChatroomStatus({rejoinedRoom:E({chatroomId:e,count:s},c)}),[2]):(a===o.ErrorCode.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(e),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,errorCode:a}}),this.logger.warn(o.LogTagId.L_REJOIN_CHATROOM_R,"chrmId: ".concat(e,", code: ").concat(a),t),[2])}}))}))}))}},e.prototype._joinChrm=function(e,t,r,n){var s=this,i=r?"joinExistChatRoom":"joinChatRoom";return new Promise((function(a){n&&s._callCppProxy("clearMessages",o.ConversationType.CHATROOM,e,""),s._callCppProxy(i,e,t,(function(n,i,c,u,d,p){s._addChatroomCache(e,t,r),a({code:o.ErrorCode.SUCCESS,data:{createTime:Number(n),memberCount:i,isAllChatroomBanned:c,isCurrentUserBanned:u,isCurrentChatroomBanned:d,isCurrentChatroomInWhitelist:p}})}),(function(e){a({code:e})}))}))},e.prototype.joinChatroom=function(e,t){return m(this,void 0,void 0,(function(){return P(this,(function(o){switch(o.label){case 0:return[4,this._joinChrm(e,t,!1,!0)];case 1:return[2,o.sent().code]}}))}))},e.prototype.joinExistChatroom=function(e,t){return this._joinChrm(e,t,!0,!0)},e.prototype.quitChatroom=function(e){var t=this;return this._rmChatroomCache(e),new Promise((function(r){t._callCppProxy("quitChatRoom",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getChatroomInfo=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("getChatroomInfo",e,t,r,(function(e,t){var r=e?JSON.parse(e).list:[],n=[];if(r.length>0)for(var i=0;i<r.length;i++)n.push(JSON.parse(r[i].obj));s({code:o.ErrorCode.SUCCESS,data:{userInfos:n,userCount:t}})}),(function(e){s({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("getChatroomHistoryMessage",e,t,r,n,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var r=t.list;if(r&&r.length)try{t.list=r.map((function(e){return s._buildMessage(e.obj)}))}catch(e){t.list=[]}i({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){i({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var r=this;return new Promise((function(n){var s='[{"key":"'.concat(t.key,'", "value":"').concat(t.value,'"}]');r._callCppProxy("setChatroomKV",e,s,!!t.isAutoDelete,!!t.isOverwrite,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var r=this;return new Promise((function(n){r._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var r=this,n=[t.key];return new Promise((function(s){r._callCppProxy("deleteChatroomKV",e,n,!!t.isOverwrite,(function(){s(o.ErrorCode.SUCCESS)}),(function(e){s(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var r=this;return new Promise((function(n){var s=t.entries.map((function(e){return e.key}));r._callCppProxy("deleteChatroomKV",e,s,!!t.isOverwrite,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return m(this,void 0,void 0,(function(){var r;return P(this,(function(n){switch(n.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(r=n.sent()).code===o.ErrorCode.SUCCESS?[2,{code:o.ErrorCode.SUCCESS,data:r.data?r.data[t]:null}]:[2,{code:r.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(r){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}r({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){r({code:e})}))}))},e.prototype.getFileToken=function(e,t,r,n,s){var i=this;return void 0===s&&(s=""),r=r||"",n=n||"",new Promise((function(a){var c;c=n&&"uploads"!==n?t||"":o.getUploadFileName(e,t),i._callCppProxy("getUploadToken",e,c,r,n,s,(function(e,t,r,n,s,i,u,d,p,l,C,h,f,g,v,_,S,y,E,m,P,T,I){a({code:o.ErrorCode.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:r,path:n,osskeyId:s,ossPolicy:i,ossSign:u,ossBucketName:d,fileName:c,s3Credential:p,s3Algorithm:l,s3Date:C,s3Policy:h,s3Signature:f,s3BucketName:g,stcAuthorization:v,stcContentSha256:_,stcDate:S,stcBucketName:y,minioAuthorization:E,minioContentSha256:m,minioDate:P,minioBucketName:T,downloadAuthInfo:I?JSON.parse(I):null}})}),(function(e){a({code:e})}))}))},e.prototype.getFileUrl=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("getDownloadUrl",e,r,n,t-1,(function(e){i({code:o.ErrorCode.SUCCESS,data:{downloadUrl:e}})}),(function(e){i({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t){var r=e._callCppProxy("clearData");t({code:o.ErrorCode.SUCCESS,data:r})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||t.resolve(n.app.getPath("userData"));return ue(e)},e.prototype.getVoIPKey=function(e,t){var r=this;return new Promise((function(n){r._callCppProxy("getVoIPKey",e,t,"",(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(r){var n=e.chatRoomId,s=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",n,s,(function(){r(o.ErrorCode.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.getGroupMessageDeliverList=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("getGroupMessageDeliverList",e,r,t,(function(e,t){var r=JSON.parse(e).list.map((function(e){return{time:JSON.parse(e.obj).time,userId:JSON.parse(e.obj).id}}));s({code:o.ErrorCode.SUCCESS,data:{totalCount:t,list:r}})}),(function(e){s({code:e})}))}))},e.prototype.getPrivateMessageDeliverTime=function(e,t){var r=this;return new Promise((function(n){var s=r._callCppProxy("getMessageDeliverTime",e);if(s)n({code:o.ErrorCode.SUCCESS,data:s});else{r._callCppProxy("getPrivateMessageDeliverList",t,e,(function(e){var t=0,r=JSON.parse(e).list;r.length>0&&(t=JSON.parse(r[0].obj).time);n({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}}))},e.prototype.rtcSignaling=function(e,t,r,n){var s=this,i=Array.prototype.slice.call(new Uint8Array(n));return new Promise((function(n){s._callCppProxy("rtcSignaling",e,t,r,i,(function(e){var t=new Uint8Array(e).buffer;n({code:o.ErrorCode.SUCCESS,buffer:t})}),(function(e){n({code:e})}),30)}))},e.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,o){var r=e.rtcHeartbeatResolves[t];if(r){var n=r.find((function(e){return""===e.seqId}));n&&(n.seqId=o)}}),(function(t,o,r,n){var s=e.rtcHeartbeatResolves[t];if(s){var i=s.findIndex((function(e){return e.seqId===r}));-1!==i&&s.splice(i,1)[0].resolve({code:o,data:{version:Number(n)}})}}))},e.prototype.rtcPing=function(e,t,o){var r=this;return new Promise((function(t){var o={resolve:t,seqId:""},n=r.rtcHeartbeatResolves[e];n?n.push(o):r.rtcHeartbeatResolves[e]=[o],r._callCppProxy("sendRTCHeartbeat",[e],30)}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(r){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(r){t._callCppProxy("deleteTag",e,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(r){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t){var r=e._callCppProxy("getTags"),n=e._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:o.ErrorCode.SUCCESS,data:n})}))},e.prototype.addTagForConversations=function(e,t){var r=this;return new Promise((function(n){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));r._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var r=this;return new Promise((function(n){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),r._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var r=this;return new Promise((function(n){r._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,r,n){var s=this;return new Promise((function(i){var a=s._callCppProxy("getConversationsForTagByPage",e,t,r||20,n||""),c=s._convertResultList(a,(function(e){return E(E({},s._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));i({code:o.ErrorCode.SUCCESS,data:c})}))},e.prototype.getUnreadCountByTag=function(e,t){var r=this;return new Promise((function(n){var s=r._callCppProxy("getConversationUnreadCountForTag",e,t);n({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.setConversationStatusInTag=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",r.isTop||!1,(function(){s({code:o.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(r){var n=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||""),s=t._convertResultList(n,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));r({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(e,t){var r=this;return new Promise((function(n){var s=o.isUndefined(t)?r._callCppProxy("getTopConversations",e):r._callCppProxy("getTopConversations",e,t),i=JSON.parse(s).list.map((function(e){return r._buildConversation(e.obj)}));n({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e.prototype.getOSInfo=function(){return m(this,void 0,void 0,(function(){var e;return P(this,(function(t){return e={arch:h.arch(),platform:h.platform(),type:h.type(),version:h.version(),release:h.release(),uptime:h.uptime(),cpus:h.cpus(),freemem:h.freemem(),totalmem:h.totalmem(),networkInterfaces:h.networkInterfaces()},[2,{code:o.ErrorCode.SUCCESS,data:e}]}))}))},e.prototype.getMainProcessInfo=function(){return m(this,void 0,void 0,(function(){return P(this,(function(e){return[2,{code:o.ErrorCode.SUCCESS,data:{title:process.title,pid:process.pid,ppid:process.ppid,platform:process.platform,arch:process.arch,uptime:process.uptime(),cpuUsage:process.cpuUsage(),memoryUsage:process.memoryUsage(),resourceUsage:process.resourceUsage()}}]}))}))},e.prototype.setCallInfo=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("callInfoSignaling",e,t,r,(function(e,t){s({code:o.ErrorCode.SUCCESS,data:{key:e,value:t}})}),(function(e){s({code:e})}))}))},e.prototype.setProxy=function(e){return this.tcpMgr.getConnectionStatus()!==o.RCConnectionStatus.DISCONNECTED?Promise.resolve({code:o.ErrorCode.RC_CONN_PROXY_UNAVAILABLE}):Promise.resolve(z(e,this.logger))},e.prototype.getProxy=function(){return Promise.resolve(Z())},e.prototype.testProxy=function(e,t){return function(e,t,r){return new Promise((function(n){var s=/^https/.test(t)?Y:q;r.info(o.LogTagId.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:e,testHost:t}));var i=s(t,e,(function(e){var t=200===e.statusCode?0:e.statusCode;e.setEncoding("utf8");var o="";e.on("data",(function(e){o+=e})),e.once("end",(function(){n({status:t||0,data:o})}))}));i.once("timeout",(function(){return n({status:0})})),i.once("error",(function(e){return n({status:0,data:e.stack})})),i.end()}))}(e,t,this.logger)},e.prototype.checkDuplicateMessage=function(e){var t=this;return new Promise((function(r){var n=t._callCppProxy("checkDuplicateMessage",e);r({code:o.ErrorCode.SUCCESS,data:n})}))},e}(),ye=function(){function e(e,t,o,r){void 0===o&&(o=""),this._cppService=new Se(e,t,o,r)}return e.prototype.getCppProto=function(){var e=this;return{destroy:function(){console.warn("`.getCppProto().destroy()` has being deprecated, use `.destroy()` instead."),e.destroy()}}},e.prototype.destroy=function(){this._cppService.destroy()},e.prototype.getDeviceId=function(){return this._cppService.getDeviceId()},e.prototype.getServerTime=function(){return this._cppService.getServerTime()},e}();module.exports=function(e){return function(e,t,o){if(fe)return fe;if(!t)throw new Error("Initializ failed, `appkey` is required!");return fe=new ye(t,e,null==o?void 0:o.dbpath,null==o?void 0:o.logOutputLevel)}(v,e.appkey,e)};
|
|
1
|
+
"use strict";var e=require("os"),t=require("path"),o=require("@rongcloud/engine"),r=require("child_process"),n=require("electron"),s=require("http"),i=require("https"),a=require("url"),c=require("net"),u=require("events"),d=require("tls"),p=require("fs"),l=require("crypto");function C(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(o){if("default"!==o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}})),t.default=e,Object.freeze(t)}var h=C(e),f=t.resolve(__dirname,"binding","electron-".concat(e.platform(),"-").concat(e.arch(),".node")),g={addon:null};try{g.addon=require(f)}catch(e){console.error("error ->",f,"\n",e)}g.addon||console.error("error -> cannot find module: ",f);var v=g.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 S(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 y,E=function(){return E=Object.assign||function(e){for(var t,o=1,r=arguments.length;o<r;o++)for(var n in t=arguments[o])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},E.apply(this,arguments)};function m(e,t,o,r){return new(o||(o=Promise))((function(n,s){function i(e){try{c(r.next(e))}catch(e){s(e)}}function a(e){try{c(r.throw(e))}catch(e){s(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof o?t:new o((function(e){e(t)}))).then(i,a)}c((r=r.apply(e,t||[])).next())}))}function P(e,t){var o,r,n,s,i={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(o)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(i=0)),i;)try{if(o=1,r&&(n=2&a[0]?r.return:a[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,a[1])).done)return n;switch(r=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(n=i.trys,(n=n.length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){i=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){i.label=a[1];break}if(6===a[0]&&i.label<n[1]){i.label=n[1],n=a;break}if(n&&i.label<n[2]){i.label=n[2],i.ops.push(a);break}n[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{o=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function T(e,t,o){if(o||2===arguments.length)for(var r,n=0,s=t.length;n<s;n++)!r&&n in t||(r||(r=Array.prototype.slice.call(t,0,n)),r[n]=t[n]);return e.concat(r||Array.prototype.slice.call(t))}!function(e){e.P_INIT_O="P-init-O",e.P_DB_OPEN_O="P-db_open-O",e.P_CALL_MAIN_SYNC_E="P-call_main_sync-E",e.P_CALL_MAIN_E="P-call_main-E",e.P_SEND_2_MAIN_E="P-send_2_main-E",e.P_REGTYP_O="P-regtype-O",e.P_CALL_ADDON_E="P-call_addon-E",e.P_CALL_ADDON_T="P-call_addon-T",e.P_CALL_ADDON_O="P-call_addon-O",e.P_CALL_ADDON_R="P-call_addon-R",e.P_CALL_EXTRA_E="P-call_extra-E",e.P_CONNECT_S="P-connect-S",e.P_CONNECT_T="P-connect-T",e.P_CONNECT_O="P-connect-O",e.P_CONNECT_ENTRY_S="P-connect_entry-S",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",e.P_PARSE_JSON_E="P-parse_json-E"}(y||(y={}));var I,R={flushTimestamp:Date.now(),queue:[],locked:!1};function O(){I&&clearInterval(I)}function N(e,t){O(),I=setInterval((function(){return b(e,t)}),1e4)}function M(){for(var e,t=[],o=0;o<arguments.length;o++)t[o]=arguments[o];(e=R.queue).push.apply(e,t)}var U=200;function b(e,t){var o=R.queue,r=R.flushTimestamp;if(!(R.locked||0===o.length||Date.now()-r<3e4&&o.length<U)){R.locked=!0;var n=t.createTraceId(),s=o.splice(0,U).map((function(e){var t=e.sessionId,o=e.level,r=e.time,n=e.type,s=e.tag,i=e.loggerId,a=e.content,c=e.traceId;return{level:o,time:r,type:n,tag:s,content:encodeURIComponent(JSON.stringify({loggerId:i,sessionId:t,content:a,traceId:c})).replace(/'/g,"%27")}}));t.debug(y.P_WRITE_LOG_T,"writingLen: ".concat(s.length,", queueLen: ").concat(o.length),n);var i=JSON.stringify(s);e.writeLog(i),t.debug(y.P_WRITE_LOG_R,"write done, queueLen: ".concat(o.length),n),R.flushTimestamp=Date.now(),R.locked=!1,setTimeout((function(){return b(e,t)}))}}var L=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return S(t,e),t.prototype.flush=function(e){M(e)},t}(o.BasicLogger),w=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return S(t,e),t.prototype.flush=function(e){M(e)},t}(o.BasicStatistic),x=function(e,t){var o,r=Buffer.from(e),n=r.length;for(t.push(n),o=0;o<n;o++)t.push(r[o])},A=function(e){return"string"==typeof e},D=function(e){return A(e)?e.toUpperCase():""},k=function(e,t){var o="";return 2!==e.length?o="Unexpected number of bytes received.":5!==e[0]?o="Unexpected SOCKS version number: ".concat(e[0],"."):255===e[1]?o="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(o="Unexpected SOCKS authentication method: ".concat(e[1],".")),o},J=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: ".concat(e[0],"."):0!==e[1]&&(t="Username and password authentication failure: ".concat(e[1],".")),t},F=function(e){var t=D(e.method)||"GET",o=e.pathname||"/",r=e.headers||{},n=e.search||"";r.Host=e.host||"loclahost";var s="";for(var i in s="".concat(t," ").concat(o+n," HTTP/1.1\n"),r)if(Object.hasOwnProperty.call(r,i)){var a=r[i];s+="".concat(i,": ").concat(a,"\n")}return e.body&&(s+="Content-Length: ".concat(e.body.length,"\n")),s+="\n","POST"===t&&e.body&&(s+="".concat(e.body)),s},j=function(e){return new Promise((function(t){var o,r;e.socket.once("data",(function(r){var n,s=k(r,o);if(!s)return 2===r[1]?(e.socket.once("data",(function(o){var r=J(o);r?e.emit("error",new Error("SOCKS authentication failed. ".concat(r))):t()})),n=[1],x(e.socksUsername,n),x(e.socksPassword,n),void e.write(Buffer.from(n))):void t();e.emit("error",new Error("SOCKS authentication failed. ".concat(s)))})),o=[0],e.socksUsername&&o.push(2),(r=Buffer.alloc(2+o.length))[0]=5,r[1]=o.length,o.forEach((function(e,t){r[2+t]=e})),e.write(r)}))},B=function(e,t,o){return new Promise((function(r){var n,s;switch(e.socket.once("data",(function(t){var o;5!==t[0]?o="Unexpected SOCKS version number: ".concat(t[0],"."):0!==t[1]?o="".concat(function(e){switch(e){case 1:return"General SOCKS server failure";case 2:return"Connection not allowed by ruleset";case 3:return"Network unreachable";case 4:return"Host unreachable";case 5:return"Connection refused";case 6:return"TTL expired";case 7:return"Command not supported";case 8:return"Address type not supported";default:return"Unknown status code ".concat(e)}}(t[1]),"."):0!==t[2]&&(o="The reserved byte must be 0x00."),o?e.emit("error",new Error("SOCKS connection failed. ".concat(o))):r()})),(n=[]).push(5),n.push(1),n.push(0),c.isIP(t)){case 0:n.push(3),x(t,n);break;case 4:n.push(1),function(e,t){var o,r,n=e.split(".");for(o=0;o<4;o++)r=parseInt(n[o],10),t.push(r)}(t,n);break;case 6:e.emit("error",new Error("Does not support IPV6"))}n.length+=2,(s=Buffer.from(n)).writeUInt16BE(o,s.length-2),e.write(s)}))},H=function(e){function t(t){var o=e.call(this)||this;return o.readable=!0,o.socket=new c.Socket,o.options=t,o.socksHost=t.socksHost||"localhost",o.socksPort=t.socksPort||1080,o.socksUsername=t.socksUsername||"",o.socksPassword=t.socksPassword||"",o.socket.on("error",(function(e){o.emit("error",e)})),o.on("error",(function(){o.socket.destroyed||o.socket.destroy()})),o.on("end",o.end),o}return S(t,e),t.prototype.ref=function(){return this.socket.ref()},t.prototype.unref=function(){return this.socket.unref()},t.prototype.setTimeout=function(e,t){return this.socket.setTimeout(e,t)},t.prototype.setNoDelay=function(e){return this.socket.setNoDelay(e)},t.prototype.setKeepAlive=function(e,t){return this.socket.setKeepAlive(e,t)},t.prototype.address=function(){return this.socket.address()},t.prototype.cork=function(){return this.socket.cork()},t.prototype.uncork=function(){return this.socket.uncork()},t.prototype.pause=function(){return this.socket.pause()},t.prototype.resume=function(){return this.socket.resume()},t.prototype.pipe=function(e){return this.socket.pipe(e)},t.prototype.end=function(e,t){var o=this.socket.end(e,t);return this.writable=this.socket.writable,o},t.prototype.destroy=function(e){return this.socket.destroy(e)},t.prototype.setEncoding=function(e){return this.socket.setEncoding(e)},t.prototype.write=function(e,t,o){return this.socket.write(e,t,o)},t.prototype.read=function(e){return this.socket.read(e)},t.prototype.connect=function(e,t){var o=this;if("string"==typeof e&&/^\d+$/.test(e)&&(e=parseInt(e,10)),!Number.isInteger(e)||e<1||e>65535)throw new TypeError("Invalid port: ".concat(e));if(!t||"string"!=typeof t)throw new TypeError("Invalid host: ".concat(t));return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return m(o,void 0,void 0,(function(){var o;return P(this,(function(r){switch(r.label){case 0:return[4,j(this)];case 1:return r.sent(),[4,B(this,t,e)];case 2:return r.sent(),this.onProxied(),o=F(this.options),this.socket.write(Buffer.from(o)),[2]}}))}))})),this},t.prototype.onProxied=function(){var e=this;this.socket.on("close",(function(t){e.emit("close",t)})),this.socket.on("end",(function(){e.emit("end")})),this.socket.on("data",(function(t){e.emit("data",t)})),this.writable=!0,this.readable=!0,this.emit("connect")},t}(u.EventEmitter),V=function(e){var t,o=e.hostname,r=e.port;return!e.host||o&&r||(t=e.host.split(":")),!r&&t&&(r=parseInt(t[1],10)||0),!o&&t&&(o=t[0]),new H(e).connect(r,o)},G=function(e){function t(t){var o=e.call(this)||this;return o.createConnection=V,o}return S(t,e),t}(s.Agent),q=function(e,t,o){return(t=E(E({},t),a.parse(e))).port||(t.port=80),t.agent=new G(t),s.request(t,o)},K=function(e){var t,o;return t=V(e),o=t.onProxied,t.onProxied=function(){e.socket=t.socket,e.hostname?e.servername=e.hostname:e.host&&(e.servername=e.host.split(":")[0]),t.socket=d.connect(e,(function(){t.authorized=t.socket.authorized,o.call(t)})),t.socket.on("error",(function(e){t.emit("error",e)}))},t},W=function(e){function t(t,o){var r=e.call(this,o)||this;return r.url=t,r.socksHost=o.socksHost||"localhost",r.socksPort=o.socksPort||1080,r.createConnection=K,r}return S(t,e),t}(i.Agent),Y=function(e,t,o,r){var n,s;return t.protocol="https:",!t.port&&t.host&&(n=t.host.split(":"),t.port=n[0],t.port=n[1]),t.port||(t.port=443),s=new W(e,t),t.agent=s,i.request(e,t,o)},Q=null;function X(e,t,r){void 0===r&&(r=!1);var n=t.url,a=t.headers,c=t.body,u=t.method,d=t.query,p=t.timeout,l=void 0===p?o.HTTP_TIMEOUT:p;return new Promise((function(t){var p=/^https/.test(n),C={headers:a,method:u};p&&(C.rejectUnauthorized=r);var h=null;Q?((C=E(E({},C),Q)).body=c,h=p?Y:q):(h=s.request,p&&(C.agent=new i.Agent(C),h=i.request));var f=h(o.appendUrl(n,d),C,(function(e){var o=e.statusCode,r="";e.setEncoding("utf8"),e.on("data",(function(e){r+=e})),e.once("end",(function(){t({status:o||0,data:r})}))}));f.once("timeout",(function(){e.warn(y.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:n,method:u,query:d,timeout:l})),t({status:0})})),f.setTimeout(l),f.once("error",(function(o){e.warn(y.P_HTTP_REQ_E,JSON.stringify({msg:o.stack,url:n,method:u,query:d,timeout:l})),t({status:0})})),f.write(c),f.end()}))}function z(e,t){return e?(Q=E(E({},Q),e),t.info(o.LogTagId.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:Q})),{code:o.ErrorCode.SUCCESS}):(Q=null,t.info(o.LogTagId.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:o.ErrorCode.SUCCESS})}function Z(){var e=Q||void 0;return{code:o.ErrorCode.SUCCESS,data:e}}var $,ee=[],te=function(e){return m(void 0,void 0,void 0,(function(){return P(this,(function(t){return[2,new Promise((function(t){ee.push({resolve:t,args:e}),re()}))]}))}))},oe=!1,re=function(){return m(void 0,void 0,void 0,(function(){var e,t,r,n,s,i,a,c,u,d,p;return P(this,(function(l){return oe||0===ee.length||(oe=!0,e=ee.shift(),t=e.args,r=e.resolve,n=t.addon,s=t.startTime,i=t.endTime,a=t.level,c=t.realtimeReport,u=0,d=0,p=[],n.setLogEventListener((function(e){u+=e.length;var t=e.split(","),n=t[0],s=t[1],i=t[2],l=t[3],C=t[4],h=t.slice(5);if(u>o.REAT_TIME_LOG_SIZE&&parseInt(s,10)!==d)r(p);else{d=parseInt(s,10);try{var f=JSON.parse(decodeURIComponent(h.join(","))),g=f.loggerId,v=f.sessionId,_=f.content,S=f.traceId;if(!c&&a<0)return;var y={time:parseInt(s,10),level:parseInt(l,10),sessionId:"".concat(n,":").concat(v),type:i,tag:C,loggerId:g,content:_,traceId:S};p.push(y)}catch(e){console.error(e)}}}),(function(e){r(p),oe=!1,re()}),(function(e,t,o){})),n.pullFullLog(a,s,i,!1)),[2]}))}))},ne=function(e){function t(t,r,n,s,i){var a=this,c=process.versions.electron,u="Electron|".concat(c,"|").concat(process.arch,"|").concat(process.platform);return(a=e.call(this,r,n,u,{getLogs:function(e,o,r,n){return m(this,void 0,void 0,(function(){return P(this,(function(s){switch(s.label){case 0:return[4,te({startTime:e,endTime:o,level:r,realtimeReport:n,addon:t})];case 1:return[2,{logs:s.sent(),dbReady:!0}]}}))}))},getTimestamp4RealtimeLog:function(){var e=t.getStoreValue(o.StoreKeys.REALTIME_LOG_TIMESTAMP);return parseInt(e,10)||0},setTimestamp4RealtimeLog:function(e){t.setStoreValue(o.StoreKeys.REALTIME_LOG_TIMESTAMP,e.toString())}},s)||this).subProcess=i,a}return S(t,e),t.prototype.send=function(e){return X(this.logger,e)},t.prototype.compressLogs=function(e){return m(this,void 0,void 0,(function(){var t,o,r;return P(this,(function(n){switch(n.label){case 0:return[4,this.subProcess.call("compressLogs",e)];case 1:return t=n.sent(),o=t.success,r=t.data,o?[2,{success:o,data:r}]:[2,{success:o,data:""}]}}))}))},t}(o.BasicReporter),se=[o.EConnectProtocol.RMTP,o.EConnectProtocol.TLS,o.EConnectProtocol.QUIC],ie={NAVI:function(e){return"RongCloud/navis/".concat(e,"/navi-cache.json")},DEVICE_ID:"deviceId",STATIC_CONFIG:function(e){return"RongCloud/caches/".concat(e,"/staticConfig.json")},CLOUD_CONTROL:function(e){return"RongCloud/cloudControl/".concat(e,"/cloudControl.json")}},ae=null,ce=function(){var t,o=Date.now(),r=[e.arch(),e.platform(),process.pid,o,Math.floor(Math.random()*o)].join("__");return t=r,l.createHash("md5").update(t).digest("hex")},ue=function(e){if(ae)return ae;var o=t.resolve(e,ie.DEVICE_ID);return p.existsSync(o)?ae=p.readFileSync(o).toString():(ae=ce(),p.writeFileSync(o,ae),ae)},de=function(){function e(e){this._cppProto=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,o,r,n,s){var i=JSON.stringify(n);"{}"!==i&&e.info(y.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:r,ext:n})),this._cppProto.setMessageExtension(t,o,r,i,s)},e.prototype.setLocalFromReceiveMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,s=t.messageUId,i=t.expansion,a=t.sentTime,c={};for(var u in i)c[u]={v:"",ts:0},c[u].v=i[u],c[u].ts=a;this._setToProtocol(e,r,n,s,c,o||"")},e.prototype.setLocalFromExtMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,s=t.content,i=t.sentTime,a=s,c=a.put,u=this._cppProto.getMessage(a.mid),d=JSON.parse(u).extMsg,p=JSON.parse(d||"{}");if(c)for(var l in c){var C=p[l];C&&C.ts<i-this._setTime?(C.v=c[l],C.ts=i-this._setTime):(p[l]={v:"",ts:0},p[l].v=c[l],p[l].ts=i-this._setTime)}a.del&&a.del.forEach((function(e){delete p[e]})),this._setToProtocol(e,r,n,a.mid,p,o||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var r in t)o[r]=t[r].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),r={};for(var n in o)r[n]=o[n].v;return r},e}(),pe=function(){function e(e){var t=this;this.p=e,this.count=0,this.maps={},this.p.on("message",(function(e){var o=e.reqId,r=e.success,n=e.data,s=t.maps[o];s&&(s({success:r,data:n}),delete t.maps[o])}))}return e.prototype.call=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return m(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return this.p.killed?[2,{success:!1}]:[2,new Promise((function(r){var n=++o.count;o.maps[n]=r;var s={reqId:n,method:e,args:t};o.p.send(s)}))]}))}))},e.prototype.destroy=function(){this.p.kill()},e}(),le=function(e,t,o){return m(void 0,void 0,void 0,(function(){var r,n;return P(this,(function(s){return r=l.createDecipheriv("aes-256-cbc",t,o),n=r.update(e,"base64","utf-8"),[2,n+=r.final("utf8")]}))}))},Ce=function(e){if(!p.existsSync(e)){var o=t.resolve(e,"..");p.existsSync(o)||Ce(o),p.mkdirSync(e)}},he=function(e){function r(o,r,n,s,i){var a=e.call(this,o,r,n,i)||this;a.naviPath="",a._caches={},a.naviPath="".concat(s,"/").concat(ie.NAVI(o));var c=t.dirname(a.naviPath);return p.existsSync(c)||Ce(c),a}return S(r,e),r.prototype.httpRequest=function(e,t,r,n){return m(this,void 0,void 0,(function(){var s,i,a,c,u;return P(this,(function(d){switch(d.label){case 0:return s="token=".concat(encodeURIComponent(r),"&v=").concat(o.FORMATED_VERSION,"&p=PC&ev=").concat("5.8.5-alpha.4"),i="".concat(e,"/navi.json?r=").concat(Date.now()),this.logger.debug(o.LogTagId.L_REQUEST_T,JSON.stringify({url:i,body:s}),n),[4,X(this.logger,{method:"POST",headers:{appId:t},body:s,url:i,timeout:o.NAVI_REQ_TIMEOUT})];case 1:if(200!==(a=d.sent()).status)return this.logger.warn(o.LogTagId.L_REQUEST_R,JSON.stringify({url:i,code:a.status}),n),[2,{code:this.transHttpCode(a.status)}];try{return c=JSON.parse(a.data),u=/^https/.test(i)?"https":"http",c.protocol=u,[2,{code:o.ErrorCode.SUCCESS,data:c}]}catch(e){return this.logger.error(o.LogTagId.L_PARSE_NAVI_E,a.data,n),[2,{code:o.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},r.prototype.httpRequestV2=function(e,t,r,n){return m(this,void 0,void 0,(function(){var s,i,a,c;return P(this,(function(u){switch(u.label){case 0:return s=this.getNaviV2RequestOption({appkey:t,token:r,uri:e,platform:"electron",protocol:se.join(",")}),this.logger.debug(o.LogTagId.L_REQUEST_T,JSON.stringify({url:s.url,body:s.body,headers:s.headers}),n),[4,X(this.logger,s)];case 1:if(200!==(i=u.sent()).status)return this.logger.warn(o.LogTagId.L_REQUEST_R,JSON.stringify({url:s.url,code:i.status}),n),[2,{code:this.transHttpCode(i.status)}];try{return a=JSON.parse(i.data),c=/^https/.test(s.url)?"https":"http",a.protocol=c,[2,{code:o.ErrorCode.SUCCESS,data:a}]}catch(e){return this.logger.error(o.LogTagId.L_PARSE_NAVI_E,i.data,n),[2,{code:o.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},r.prototype.getNaviCache=function(e){var t=this._caches[e];if(t)return t;if(!p.existsSync(this.naviPath))return null;var r=p.readFileSync(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(r),this._caches[e]}catch(e){this.logger.error(o.LogTagId.L_PARSE_NAVI_E,r)}return null},r.prototype.setNaviCache=function(e,t){var r=Date.now();if(o.notEmptyObject(this._caches))for(var n in this._caches){var s=this._caches[n];(r-s.timestamp>o.NAVI_CACHE_DURATION||e===s.token)&&delete this._caches[n]}this._caches[e]={token:e,naviInfo:t,timestamp:Date.now()},p.writeFileSync(this.naviPath,JSON.stringify(this._caches))},r}(o.BasicNavi);!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.NOT_INIT=-1]="NOT_INIT",e[e.CANCELED=-2]="CANCELED",e[e.REPEAT=-3]="REPEAT"}($||($={}));var fe,ge=function(e){function t(t,r,n,s,i,a){var c=e.call(this,t,n,s,i,a)||this;return c.addon=r,c._connectedTime=0,c._naviInfo=null,c.connectResolve=null,c._startTime=0,c._tcpDuration=0,c.pingResolve=null,c.addon.setConnectionStatusListener(c._onConnectionStatusChange.bind(c),(function(e){c.logger.info(y.P_DB_OPEN_O,e)}),(function(){return c.recvPong(o.ErrorCode.SUCCESS)}),c._onConnectionStatusChange.bind(c),c._onTcpConnectResponse.bind(c)),c}return S(t,e),t.prototype.getConnectedTime=function(){return this._connectedTime},t.prototype.connectWithToken=function(e,t,r,n){var s=this;return new Promise((function(i){s._naviInfo=t,s.connectResolve={resolve:i,traceId:n,userId:t.userId};var a={},c=Z().data;c&&(a={proxy_passwd:c.socksPassword||"",proxy_name:c.socksUsername||"",proxy_port:c.socksPort||1082,proxy_host:c.socksHost||"localhost",proxy_type:0});var u=JSON.stringify(E(E({},a),{call_plus:s._openCallPlus})),d=s.getCmpList(t,!0).filter((function(e){return se.includes(e.protocol)})).sort((function(e,t){return e.weight>t.weight?-1:1})),p=[];d.forEach((function(e){var t=p.find((function(t){return t.addr===e.addr}));t?t.protocol!==o.EConnectProtocol.QUIC&&e.protocol!==o.EConnectProtocol.QUIC||(t.race=!0,t.protocol=o.EConnectProtocol.QUIC):(e.race=!1,p.push(e))})),s.logger.info(y.P_CONNECT_O,JSON.stringify({use:p,catche:s.cmpWeightCache,proxy:a,FORMATED_VERSION:o.FORMATED_VERSION,reconnectKickEnable:r}),n),s._startTime=Date.now();try{s.addon.connectWithToken(e,o.FORMATED_VERSION,JSON.stringify(E(E({},t),{serverAddr:p})),r,u)}catch(e){s.logger.error(y.P_CALL_ADDON_E,null==e?void 0:e.stack,n),s.recvConnectRes(o.ErrorCode.RC_SOCKET_NOT_CREATED)}}))},t.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.addon.disconnect(t)},t.prototype.sendPing=function(e){var t=this;return new Promise((function(r){t.pingResolve=r,t.addon.sendHeartbeat(),setTimeout((function(){return t.recvPong(o.ErrorCode.TIMEOUT)}),e)}))},t.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},t.prototype._onConnectionStatusChange=function(e,t){switch(this.logger.info(y.P_CONNECT_S,JSON.stringify({status:e,delay:t})),e){case o.ErrorCode.SUCCESS:this.recvConnectRes(o.ErrorCode.SUCCESS);break;case o.ErrorCode.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(o.ErrorCode.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case o.ErrorCode.RC_SOCKET_DISCONNECTED:this.recvConnectRes(e,!1);break;case o.ErrorCode.RC_SOCKET_NOT_CREATED:case o.ErrorCode.RC_CONN_ACK_TIMEOUT:case o.ErrorCode.RC_TCP_RESET:this.recvConnectRes(e);break;case o.ErrorCode.RC_UDP_DISCONNECTED:this.recvConnectRes(e,!0,t);break;default:this.recvConnectRes(e,!0)}},t.prototype.recvConnectRes=function(e,t,r){if(this.connectResolve){var n=this.connectResolve,s=n.resolve,i=n.userId,a=Date.now()-(this._startTime+this._tcpDuration),c={bid:o.getbundleId(),cod:e,net:this.getNetwork().type,dur:a,spr:0,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:o.StatisticsVersion.CURRENT,count:this.retryCount};return this.statisticLog.__statistics(o.StatisticsTag.IM_CMP_RMTP,JSON.stringify(c)),e===o.ErrorCode.SUCCESS&&(this._connectedTime=Date.now()-this.addon.getDeltaTime()),s({code:e,data:i}),void(this.connectResolve=null)}if(t)this.onDisconnectByServer(e,r);else{if(e===o.ErrorCode.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==o.RCConnectionStatus.CONNECTED)return;this.onDisconenctUnusual(e)}},t.prototype._onTcpConnectResponse=function(e,t,r,n,s,i,a){var c,u=this.cmpWeightCache.findIndex((function(e){return e.addr==="".concat(t,":").concat(r)})),d={bid:o.getbundleId(),ptc:o.ProtocalType.TCP,cod:e,net:this.getNetwork().type,dur:n,spr:0,pr:(null===(c=this._naviInfo)||void 0===c?void 0:c.type)||0,hos:"".concat(t,":").concat(r),idx:u,rct:this.retryCount?o.ConnectType.RECONNECT:o.ConnectType.CONNECT,cid:"".concat(this.uuid,"_").concat(this.retryCount),v:o.StatisticsVersion.CURRENT,rsn:this.reason,ddu:s,count:this.retryCount,weight:u>=0?this.cmpWeightCache[u].weight:-1};this.statisticLog.__statistics(o.StatisticsTag.IM_CMP,JSON.stringify(d)),this.logger.info(y.P_CONNECT_ENTRY_S,JSON.stringify({code:e,host:t,port:r,duration:n,dnsDuration:s,index:i,isQuic:a})),e===$.SUCCESS&&(this.curCmpUrl="".concat(t,":").concat(r),this.updateCmpWeight("".concat(t,":").concat(r),!0,a))},t}(o.AConnectionMgr),ve=function(e){function r(r,n,s,i){void 0===i&&(i=o.AreaCode.BJ);var a=e.call(this,r,n,i)||this;a.appkey=r,a.logger=n,a.dbpath=s,a._cachePath="",a._cachePath="".concat(s,"/").concat(ie.STATIC_CONFIG(r));var c=t.dirname(a._cachePath);return p.existsSync(c)||Ce(c),a}return S(r,e),r.prototype.getCache=function(){return p.existsSync(this._cachePath)&&p.readFileSync(this._cachePath,{encoding:"utf8"})||null},r.prototype.setCache=function(e){p.writeFileSync(this._cachePath,e)},r.prototype.clearCache=function(){p.writeFileSync(this._cachePath,"")},r.prototype.sendRequest=function(e){return m(this,void 0,void 0,(function(){var t,o,r;return P(this,(function(n){switch(n.label){case 0:return[4,X(this.logger,{url:e,body:""})];case 1:return t=n.sent(),o=t.status,r=t.data,[2,{code:o,data:r}]}}))}))},r.prototype.decryptData=function(e){return m(this,void 0,void 0,(function(){var t,r;return P(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,le(e,o.STATIC_CONFIG_KEY,o.STATIC_CONFIG_IV)];case 1:return t=n.sent(),[2,JSON.parse(t)];case 2:return r=n.sent(),this.logger.error(o.LogTagId.L_GET_STATIC_CONF_E,JSON.stringify({error:null==r?void 0:r.stack})),[3,3];case 3:return[2]}}))}))},r}(o.BasicStaticConfigManager),_e=function(e){function r(o,r,n,s,i,a){var c=e.call(this,r,o,n,a)||this;c.deviceId=s,c.model="",c.catchFilePath="",c.model="Electron|".concat(process.platform,"|").concat(process.arch),c.catchFilePath="".concat(i,"/").concat(ie.CLOUD_CONTROL(o));var u=t.dirname(c.catchFilePath);return p.existsSync(u)||Ce(u),c.init(),c}return S(r,e),r.prototype.httpRequest=function(e,t,r,n){return m(this,void 0,void 0,(function(){var s,i,a,c,u,d,p,l;return P(this,(function(C){switch(C.label){case 0:return(s=n).deviceId=this.deviceId,s.model=this.model,i={url:e,method:t,headers:r,body:JSON.stringify(s)},this.logger.info(o.LogTagId.L_REQUEST_T,JSON.stringify(i)),[4,X(this.logger,i)];case 1:a=C.sent(),c=a.status,u=a.data,d=void 0===u?"":u,this.logger.info(o.LogTagId.L_REQUEST_R,JSON.stringify({status:c,data:d}));try{return p=JSON.parse(d),l=p.data,[2,{code:c,data:l}]}catch(e){return this.logger.warn(o.LogTagId.L_CLOUD_CONFIG_DATA_E,JSON.stringify({status:c,data:d,error:e})),[2,{code:c,msg:e}]}return[2]}}))}))},r.prototype.setCloudControllerCache=function(e){p.writeFileSync(this.catchFilePath,JSON.stringify(e)),this.logger.info(o.LogTagId.L_CLOUD_SET_CACHE_O,JSON.stringify(e))},r.prototype.getLocalCloudControllerCache=function(){if(!p.existsSync(this.catchFilePath))return null;var e=p.readFileSync(this.catchFilePath,{encoding:"utf8"});return this.logger.info(o.LogTagId.L_CLOUD_GET_CACHE_O,JSON.stringify({appkey:this.appkey,data:e})),e},r}(o.BaseCloudController),Se=function(){function e(e,s,i,a){var c=this;this._appkey=e,this._cppProtocol=s,this._dbpath=i,this._logOutputLevel=a,this._customMessageType={},this.cloudControllerUri="",this.cloudControllerLock=!0,this.cloudControllerMsgs=[],this._senders={},this._chatroomCache=[],this.rtcHeartbeatResolves={};var u=this._dbpath||t.resolve(n.app.getPath("userData")),d=ue(u);this._cppProtocol.initWithAppkey(e,u,o.FORMATED_VERSION);var p=r.fork(t.resolve(__dirname,"sub-process.js"));this.subProxy=new pe(p);var l=t.resolve(u,"RongCloud/rclogs",e);Ce(l),function(e,t,r){r.initLogModule(t,e,o.getUUID())}(e,l,this._cppProtocol),this.logger=new L(this._appkey,"RC-M","IM"),this.statisticLog=new w(this._appkey,"RC-M","IM"),this.logger.setOutputLevel(this._logOutputLevel),N(this._cppProtocol,this.logger),this.reporter=new ne(this._cppProtocol,e,d,this.logger,this.subProxy),this.logger.info(y.P_INIT_O,JSON.stringify({appkey:e,dbpath:u,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:d,commit:"23bf7f5f228abc7e8f381662d31522ea85f5d906"})),this._callCppProxy("setDeviceId",d),this._staticConfigManager=new ve(e,this.logger,u),this.navi=new he(e,this.logger,this.statisticLog,u,this._staticConfigManager),this.tcpMgr=new ge(e,this._cppProtocol,this.navi,this.logger,this.statisticLog,{onConnected:this.onConnected.bind(this),onSuspend:this.onSuspend.bind(this),onDisconnected:this.onDisconnected.bind(this),onConnecting:this.onConnecting.bind(this)}),this._initCloudController(d,u),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setUserProfileListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),n.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];return m(c,void 0,void 0,(function(){var n,s,i;return P(this,(function(a){switch(a.label){case 0:if("function"!=typeof(n=this[t]))return this.logger.error(y.P_CALL_MAIN_SYNC_E,JSON.stringify({method:t,error:"not found"})),e.returnValue=o.ErrorCode.NOT_SUPPORT,[2];s=o.ErrorCode.NOT_SUPPORT,a.label=1;case 1:return a.trys.push([1,3,,4]),[4,n.call.apply(n,T([this],r,!1))];case 2:return s=a.sent(),[3,4];case 3:return i=a.sent(),this.logger.error(y.P_CALL_MAIN_SYNC_E,JSON.stringify({error:null==i?void 0:i.stack,method:t})),[3,4];case 4:return e.returnValue=s,[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,r){for(var n=[],s=3;s<arguments.length;s++)n[s-3]=arguments[s];return m(c,void 0,void 0,(function(){var s,i,a,c,u=this;return P(this,(function(d){switch(d.label){case 0:if("function"!=typeof(s=this[r]))return this.logger.error(y.P_CALL_MAIN_E,JSON.stringify({method:r,error:"not found"})),this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,o.ErrorCode.NOT_SUPPORT),[2];"sendMessage"===r&&(i=n[3],n[3]=function(t){u._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",i,t)}),a=o.ErrorCode.NOT_SUPPORT,d.label=1;case 1:return d.trys.push([1,3,,4]),[4,s.call.apply(s,T([this],n,!1))];case 2:return a=d.sent(),[3,4];case 3:return c=d.sent(),this.logger.error(y.P_CALL_MAIN_E,JSON.stringify({error:null==c?void 0:c.stack,method:r})),[3,4];case 4:return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,a),[2]}}))}))})),n.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];var n=c[t];if("function"==typeof n)try{n.call.apply(n,T([c],o,!1))}catch(e){c.logger.error(y.P_SEND_2_MAIN_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}else c.logger.error(y.P_SEND_2_MAIN_E,JSON.stringify({method:t,error:"not found"}))})),n.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),this._msgExpansionHandler=new de(this._cppProtocol)}return e.prototype._initCloudController=function(e,t){var r=o.urlCenter.getCloudControllerUrl();this.cloudControllerUri=r[0],this.cloudController=new _e(this._appkey,this.logger,this.reporter,e,t,this.statisticLog),o.isStartCloudController()&&this.cloudControllerUri&&this.cloudController.request(this.cloudControllerUri,o.InvokerType.init)},e.prototype.onConnected=function(){var e=this.getNaviInfoFromCache();this.reporter.checkStart(e),this._try2RejoinChatroom(),this._send2AllRenderer("onConnected",this.getMainProcessCache())},e.prototype.onConnecting=function(){this._send2AllRenderer("onConnecting",void 0)},e.prototype.onSuspend=function(e){this._send2AllRenderer("onSuspend",e)},e.prototype.onDisconnected=function(e){this._send2AllRenderer("onDisconnected",e)},e.prototype._callCppProxy=function(e){for(var t,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];var n=this.logger.createTraceId();try{return this.logger.debug(y.P_CALL_ADDON_O,JSON.stringify({method:e,content:o}),n),(t=this._cppProtocol)[e].apply(t,o)}catch(t){this.logger.error(y.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),n)}},e.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},e.prototype.sendHTTPRequest=function(e){return X(this.logger,e)},e.prototype.onRendererLogsReceived=function(e){M.apply(void 0,e)},e.prototype.onRendererNetworkStatusReceived=function(e,t){if(this.tcpMgr.setNetwork(e,t),e.status&&o.isStartCloudController()&&this.cloudController){var r=this.tcpMgr.getToken();this.cloudController.request(this.cloudControllerUri,o.InvokerType.newWorkChange,r)}},e.prototype.destroy=function(){this.reporter.stop(),this.subProxy.destroy(),function(e){O(),e.deinitLogModule()}(this._cppProtocol),this._cppProtocol.destroy()},e.prototype.callExtra=function(e){for(var t=[],r=1;r<arguments.length;r++)t[r-1]=arguments[r];var n=this[e];if(!n)return this.logger.warn(y.P_CALL_EXTRA_E,JSON.stringify({method:e,error:"not found"})),Promise.resolve({code:o.ErrorCode.NOT_SUPPORT});try{return n.call.apply(n,T([this],t,!1))}catch(t){this.logger.error(y.P_CALL_EXTRA_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})},e.prototype.getConversationsByPage=function(e,t,r,n){var s,i=this,a=this._callCppProxy("getConversationListByPage",e,t,r,n||"");try{s=JSON.parse(a).list.map((function(e){return i._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.getUnreadConversationList=function(e){var t,r=this,n=this._callCppProxy("getUnreadConversationList",e);try{t=JSON.parse(n).list.map((function(e){return r._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:t})},e.prototype.getConversationListWithAllChannel=function(){var e,t=this,r=[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.APP_PUBLIC_SERVICE,o.ConversationType.PUBLIC_SERVICE],n=this._callCppProxy("getConversationListWithAllChannel",r);try{e=JSON.parse(n).list.map((function(e){return t._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:e})},e.prototype.getConversationListWithAllChannelByPage=function(e,t){var r,n=this,s=[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.APP_PUBLIC_SERVICE,o.ConversationType.PUBLIC_SERVICE],i=this._callCppProxy("getConversationListWithAllChannelByPage",s,e,t);try{r=JSON.parse(i).list.map((function(e){return n._buildConversation(e.obj)}))}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:r})},e.prototype.getHistoryMessagesByObjectNames=function(e,t,r,n,s,i,a){var c=0===i,u=n+1,d=this._callCppProxy("getHistoryMessagesByObjectNames",e,t,r,u,s,c,a||""),p=[];try{var l=JSON.parse(d).list;l.reverse();for(var C=0;C<l.length;C++){var h=this._buildMessage(l[C].obj);p[C]=h}}catch(e){return Promise.resolve({code:o.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:o.ErrorCode.SUCCESS,data:{list:u===p.length?p.slice(1,u):p,hasMore:n<p.length}})},e.prototype.updateMessageReceiptStatus=function(e,t,r,n){void 0===n&&(n="");var s=this._callCppProxy("updateMessageReceiptStatus",e,t,r,n);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==o.RCConnectionStatus.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},e.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new L(this._appkey,e,t)},e.prototype.getConnectedTime=function(){return this.tcpMgr.getConnectedTime()},e.prototype.getServerTime=function(){return Date.now()-this._cppProtocol.getDeltaTime()},e.prototype.getCurrentUserId=function(){return this.tcpMgr.getCurrentUserId()},e.prototype._send2Renderer=function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];e.isDestroyed()?delete this._senders[e.id]:e.send.apply(e,T([t],o,!1))},e.prototype._send2AllRenderer=function(e,t,o){var r=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(n){var s=r._senders[n];o.includes(s)||r._send2Renderer(s,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},e.prototype.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),o=this.getNaviInfoFromCache(),r=this.tcpMgr.getCurrentUserId();return{connectedTime:e,deviceId:this.getDeviceId(),crtUserId:r,naviInfo:o,connectionStatus:t}},e.prototype._registerRenderers=function(e,t){var r=this,n=e.sender,s=n.id,i=t.navigators,a=t.areaCode,c=t.logServerUrl;this._staticConfigManager.setAreaCode(a),o.urlCenter.init({areaCode:a,navigators:i,logServerUrl:c}),this._senders[s]||(this._senders[s]=n,n.once("destroyed",(function(){delete r._senders[s]})))},e.prototype._registerMsgTypes=function(){for(var e in o.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},o.SEND_MESSAGE_TYPE_OPTION){var t=o.SEND_MESSAGE_TYPE_OPTION[e],r=t.isCounted,n=t.isPersited,s=t.searchProps,i=0;n&&(i|=1),r&&(i|=2),"RC:TypSts"===e&&(i=16),this._callCppProxy("registerMessageType",e,i,s||[])}},e.prototype._buildIsMentioned=function(e,t){var r,n=!1;if(o.isObject(e))r=e;else try{r=e?JSON.parse(e):e}catch(o){r=e,this.logger.error(y.P_PARSE_JSON_MSGS_E,JSON.stringify({messageId:t}))}return o.isObject(r)&&(n=!!r.mentionedInfo),{isMentioned:n,msgContent:r}},e.prototype._buildMsgOption=function(e){var t={isCounted:!1,isPersited:!1};return e in o.SEND_MESSAGE_TYPE_OPTION?t=o.SEND_MESSAGE_TYPE_OPTION[e]:e in this._customMessageType&&(t=this._customMessageType[e]),t},e.prototype._buildSupportExt=function(e,t,o){var r=null;return e&&(r=this._msgExpansionHandler.parseReceiveExpansion(o),"conversation"!==t&&"history"!==t||(r=this._msgExpansionHandler.parseConverOrHisExpansion(o))),r},e.prototype._buildMessage=function(e,t){void 0===t&&(t={});var r=t.isOffLineMessage,n=t.buildFrom,s=JSON.parse(e),i=s.channelId,a=s.conversationType,c=s.targetId,u=s.senderUserId,d=s.content,p=s.objectName,l=s.messageUid,C=s.direction,h=s.status,f=s.messageId,g=s.sentTime,v=s.readReceiptRequest,_=s.supportExt,S=s.pushContent,y=s.pushTitle,m=s.pushId,P=s.pushConfig,T=s.templateId,I=s.disableTitle,R=s.forcePushDetail,O=s.hasMore,N=this._buildIsMentioned(d,f),M=N.isMentioned,U=N.msgContent,b=this._buildMsgOption(p),L=this._buildSupportExt(_,n,s),w=o.isUndefined(r)?g<this.tcpMgr.getConnectedTime():r,x={};P&&(x=o.pushJSONToConfigs(this.logger,P,m));var A=E(E({},x),{pushTitle:y,pushContent:S,pushData:S,disablePushTitle:I,forceShowDetailContent:R,templateId:T}),D={channelId:i,conversationType:a,targetId:c,senderUserId:u,content:U||{},messageType:p,messageUId:l||"",messageDirection:C,isOffLineMessage:w,sentTime:g,receivedTime:0,isPersited:b.isPersited,isCounted:b.isCounted,isMentioned:M,disableNotification:!1,isStatusMessage:!1,canIncludeExpansion:_,expansion:_?L:null,receivedStatus:h,messageId:f,pushConfig:A,hasMore:O};if(C===o.MessageDirection.RECEIVE?D.receivedStatus=h:C===o.MessageDirection.SEND&&(D.sentStatus=h),v){var k=JSON.parse(v),J=k.hasRespond,F=k.readerInfo,j={readCount:k.readCount,totalCount:k.totalCount},B=[];if(F)for(var H in F)B.push({userId:H,readTime:F[H]});var V=this.getNaviInfoFromCache();1===(null==V?void 0:V.grpRRVer)&&(j.readerList=B,j.hasRespond=J),D.readReceiptInfo=j}return D},e.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),r=JSON.parse(o),n=r.readReceiptRequest?JSON.parse(r.readReceiptRequest):{},s=E(E({},n),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(s))},e.prototype._processRSMsg=function(e){this.getNaviInfoFromCache();var t=e.conversationType,r=e.targetId,n=e.content,s=e.channelId,i=n.msgId,a=n.rrn,c=n.tmn,u=n.endMsgTime;t===o.ConversationType.PRIVATE?this.updateMessageReceiptStatus(t,r,u,s||""):this._updateReadReceiptInfo(i,{readCount:a,totalCount:c});var d={conversationType:t,targetId:r,channelId:s};this._sendMessageReadReceipt(t===o.ConversationType.PRIVATE?{privateReadReceipt:E(E({},d),{endMsgTime:n.endMsgTime})}:{groupReadReceipt:E(E({},d),{totalCount:n.tmn,readCount:n.rrn,messageUId:n.msgId})})},e.prototype._processSRSMsg=function(e){var t=this.getNaviInfoFromCache(),o=e.conversationType,r=e.targetId,n=e.content,s=e.channelId,i=e.senderUserId,a=e.sentTime;return i===this.tcpMgr.getCurrentUserId()&&(this._callCppProxy("clearUnreadCountByTimestamp",o,r,n.lastMessageSendTime,s||""),1!==(null==t?void 0:t.sesDriven)||(a>this.tcpMgr.getConnectedTime()||this._sendsyncReadStatus({conversationType:o,targetId:r,channelId:s,timestamp:n.timestamp}),!1))},e.prototype._buildConversation=function(e){var t=JSON.parse(e),r=t.channelId,n=t.conversationType,s=t.targetId,i=t.unreadCount,a=t.lastestMsg,c=t.isTop,u=t.blockStatus,d=t.matchCount,p=t.hasUnreadMention,l=t.conversationTime,C=t.draft,h=u>0?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE;return{channelId:r,conversationType:n,targetId:s,unreadMessageCount:i,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:p,mentionedInfo:null,notificationStatus:h,isTop:c,lastUnreadTime:0,matchCount:d,operationTime:l,notificationLevel:u,draft:C}},e.prototype._convertResultList=function(e,t){var o=JSON.parse(e).list;return o=o.map((function(e){var o=JSON.parse(e.obj);return t?t(o):o}))},e.prototype._setOnReceiveMessageListener=function(){var e=this;this._cppProtocol.setOnReceiveMessageListener((function(t,r,n,s){var i,a=e._buildMessage(t,{isOffLineMessage:n}),c=a.messageType,u=a.channelId,d=void 0===u?"":u,p=a.senderUserId,l=a.content;a.canIncludeExpansion;var C=a.messageUId,h=a.conversationType,f=a.targetId;if(e.getNaviInfoFromCache(),c!==o.MessageType.LOG_COMMAND||p!==o.RC_DEFAULT_USER){if(c===o.MessageType.CLOUD_CONTROL&&p===o.RC_DEFAULT_USER)return e.cloudControllerMsgs.push(a),void e._ccMsgHandler();if(c===o.MessageType.GROUP_READ_RECEIPT_REQUEST){var g=l.msgId,v=l.rrn,_=l.tmn;e._updateReadReceiptInfo(g,{readCount:v,totalCount:_})}if(c!==o.MessageType.READ_STATE){if("RC:MsgExMsg"===c)return e._msgExpansionHandler.setLocalFromExtMsg(e.logger,a),void e._sendMessageExpansion(a);if(c===o.MessageType.READ_RECEIPT&&p===e.tcpMgr.getCurrentUserId()&&e._callCppProxy("clearUnreadCountByTimestamp",h,f,l.lastMessageSendTime,d),c!==o.MessageType.SYNC_READ_STATUS||e._processSRSMsg(a)){var S=!0;if(0!==r||s||(S=!1),c===o.MessageType.DELIVERED)return e._callCppProxy("setMessageDeliverTime",JSON.stringify(l)),void e._sendMessageDelivered(l.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}})));if(c!==o.MessageType.DELIVERED_MSG){if(c===o.MessageType.RECALL){e.handleRecalledMessage(a);var y=e._fixRecallContentInfo(a);h=y.conversationType,f=y.targetId}e._sendMessageNotification(Object.assign(a,{hasMoreMsg:S,conversationType:h,targetId:f}))}else{var E={totalCount:l.tmn,list:null===(i=l.dl)||void 0===i?void 0:i.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};e._sendGroupMessageDeliveredStatus(E)}}}else e._processRSMsg(a)}else{var m=l.startTime,P=l.endTime,T=l.platform,I=l.logId,R=l.uri;e.reporter.report(parseInt(m,10),parseInt(P,10),T,R,I,C)}}),(function(){e._sendPullOfflineFinished()}))},e.prototype._ccMsgHandler=function(){var e;return m(this,void 0,void 0,(function(){var t,r;return P(this,(function(n){switch(n.label){case 0:return this.cloudControllerLock?(this.cloudControllerLock=!1,this.cloudControllerMsgs.shift()?(t=this.tcpMgr.getToken(),[4,null===(e=this.cloudController)||void 0===e?void 0:e.request(this.cloudControllerUri,o.InvokerType.other,t)]):[3,2]):[2];case 1:r=n.sent()||0,this.cloudControllerMsgs=this.cloudControllerMsgs.filter((function(e){return e.sentTime>r})),this.cloudControllerLock=!0,this._ccMsgHandler(),n.label=2;case 2:return[2]}}))}))},e.prototype._fixRecallContentInfo=function(e){var t=e.conversationType,o=e.targetId;return e.senderUserId===this.tcpMgr.getCurrentUserId()&&(t=e.content.conversationType||t,o=e.content.targetId||o),{conversationType:t,targetId:o}},e.prototype.handleRecalledMessage=function(e){var t=e.content,r=t.messageUId,n=t.sentTime;if(r){var s=this._callCppProxy("getMessage",r),i=this._buildMessage(s,{isOffLineMessage:!1});if(e.content.isDelete){if(-1===i.messageId)return;this._callCppProxy("deleteMessages",[i.messageId])}else{var a={recallTime:Date.now(),admin:!!e.content.isAdmin,originalObjectName:i.messageType,originalMessageContent:i.content,recallActionTime:e.sentTime,operatorId:e.senderUserId};if(e.content.user&&(a.user=e.content.user),e.content.extra&&(a.extra=e.content.extra),i.messageType===o.MessageType.TextMessage&&(a.recallContent=i.content.content),-1!==i.messageId)i.receivedStatus||this.setMessageReceivedStatus(i.messageId,1),this._callCppProxy("setMessageContent",i.messageId,JSON.stringify(a),o.MessageType.RECALL_NOTIFICATION_MESSAGE);else{var c=e.conversationType,u=e.targetId,d=e.senderUserId,p=e.channelId,l=e.messageDirection;this._callCppProxy("insertMessage",c,u,d,o.MessageType.RECALL_NOTIFICATION_MESSAGE,JSON.stringify(a),(function(){}),(function(){}),l,1,10,n,"",0,r,!1,!0,JSON.stringify({}),p||"")}}}},e.prototype._sendMessageExpansion=function(e,t){void 0===t&&(t=[]);var o=e.channelId,r=e.content,n=r.put,s=r.del,i=r.mid,a={};n&&(a.updatedExpansion={channelId:o,messageUId:i,expansion:n}),s&&(a.deletedExpansion={channelId:o,messageUId:i,deletedKeys:s}),this._send2AllRenderer("expansion",a,t)},e.prototype._sendMessageNotification=function(e,t){void 0===t&&(t=[]),this._send2AllRenderer("batchMessage",e,t)},e.prototype._sendPullOfflineFinished=function(){this._send2AllRenderer("pullFinished",null)},e.prototype._sendMessageDelivered=function(e){this._send2AllRenderer("messageDelivered",e)},e.prototype._sendGroupMessageDeliveredStatus=function(e){this._send2AllRenderer("groupMessageDeliveredStatus",e)},e.prototype._sendChatroomStatus=function(e){this._send2AllRenderer("chatroom",e)},e.prototype._sendMessageReadReceipt=function(e){this._send2AllRenderer("messageReadReceipt",e)},e.prototype._sendsyncReadStatus=function(e){this._send2AllRenderer("syncReadStatus",e)},e.prototype._setConversationStatusListener=function(){var e=this;this._cppProtocol.setConversationStatusListener((function(t){var r=JSON.parse(t).list,n=[];r.forEach((function(e){var t=JSON.parse(e.obj),r=t.conversationType,s=t.targetId,i=t.status,a=t.channelId,c={notificationStatus:2,isTop:!1};i.forEach((function(e){var t=JSON.parse(e.item);1===t.type?c.notificationStatus=1===Number(t.value)?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE:c.isTop=1===Number(t.value)})),n.push({channelId:a,conversationType:r,targetId:s,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),e._send2AllRenderer("conversation",n)}),(function(t){e._send2AllRenderer("conversationTag",t)}),(function(t,o,r,n){e._callCppProxy("clearUnreadCountByTimestamp",t,o,n,r||""),e._sendsyncReadStatus({conversationType:t,targetId:o,channelId:r,timestamp:n})}))},e.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(){}),(function(t){e._send2AllRenderer("tag",t),e._getRTCProfile()}))},e.prototype._getRTCProfile=function(){var e=this._callCppProxy("getRTCProfile");if(e){var t=this.tcpMgr.getToken();this.navi.updateVoipCallInfo(t,e);var o=this.navi.getNaviInfoFromCache(t);this._send2AllRenderer("onNaviDataChange",o)}},e.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){var o=new Uint8Array(t).buffer;e._send2AllRenderer("onRTCDataChange",o)}))},e.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._sendChatroomStatus({chatroomDestroyed:t})}))},e.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){e._send2AllRenderer("callInfo",t)}))},e.prototype._updateMentionedInfo=function(e,t,r){var n,s,i;return{userIdList:(null===(n=e.mentionedInfo)||void 0===n?void 0:n.userIdList)||t,type:(null===(s=e.mentionedInfo)||void 0===s?void 0:s.type)||r||o.MentionedType.ALL,mentionedContent:(null===(i=e.mentionedInfo)||void 0===i?void 0:i.mentionedContent)||""}},e.prototype.registerMessageType=function(e,t,o,r){void 0===r&&(r=[]);var n=0;t&&(n|=1),o&&(n|=2),this._customMessageType[e]={isCounted:o,isPersited:t},this.logger.info(y.P_REGTYP_O,JSON.stringify({type:e,opt:n,search:r})),this._callCppProxy("registerMessageType",e,n,r)},e.prototype.connect=function(e,t,o,r){return this.tcpMgr.connect(e,t,o,r)},e.prototype.reportSDKInfo=function(e){var t,o,r=JSON.stringify(E(E({},e),{"electron-main":"5.8.5-alpha.4"}));this.logger.info(y.P_REPORT_VER_O,r),null===(o=(t=this._cppProtocol).uploadSDKVersion)||void 0===o||o.call(t,r,"")},e.prototype.disconnect=function(e){this._chatroomCache.length=0,this.reporter.stop(),z(null,this.logger),this.tcpMgr.disconnect(e)},e.prototype.logout=function(){this.disconnect()},e.prototype.setUserStatusListener=function(e,t){this._cppProtocol.setOnReceiveStatusListener((function(e,o){t({userId:e,status:o})}));var o=e.userIds||[];o.length&&this.subscribeUserStatus(o)},e.prototype.subscribeUserStatus=function(e){var t=this;return new Promise((function(r){t._callCppProxy("subscribeUserStatus",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.setUserStatus=function(e){var t=this;return new Promise((function(r){t._callCppProxy("setUserStatus",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getUserStatus=function(e){var t=this;return new Promise((function(r){t._callCppProxy("getUserStatus",e,(function(e){r({code:o.ErrorCode.SUCCESS,data:{status:e}})}),(function(e){r({code:e})}))}))},e.prototype.sendMessage=function(e,t,r,n,s){var i=this;void 0===s&&(s=this.logger.createTraceId());var a=r.messageType,c=r.content,u=r.expansion,d=r.pushConfig,p=r.isMentioned,l=r.mentionedType,C=r.mentionedUserIdList,h=void 0===C?[]:C,f=r.pushContent,g=void 0===f?"":f,v=r.pushData,_=void 0===v?"":v,S=r.directionalUserIdList,E=void 0===S?[]:S,m=r.disableNotification,P=void 0!==m&&m,T=r.canIncludeExpansion,I=void 0!==T&&T,R=r.isVoipPush,O=void 0!==R&&R,N=r.channelId,M=void 0===N?"":N,U=r.messageId,b=void 0===U?0:U,L=d||{},w=L.iOSConfig,x=L.androidConfig,A=L.templateId,D=void 0===A?"":A,k=L.pushTitle,J=void 0===k?"":k,F=L.pushContent,j=void 0===F?g:F,B=L.pushData,H=void 0===B?_:B,V=L.disablePushTitle,G=void 0!==V&&V,q=L.forceShowDetailContent,K=void 0!==q&&q,W=o.pushConfigsToJSON(w,x);return new Promise((function(r){g=j,_=H;var d=(null==x?void 0:x.notificationId)||"";e===o.ConversationType.GROUP&&p&&c&&(c.mentionedInfo=i._updateMentionedInfo(c,h,l));var C=e===o.ConversationType.GROUP;if(C&&a===o.MessageType.READ_RECEIPT_RESPONSE&&c.receiptMessageDic)for(var f in c.receiptMessageDic)E.push(f);C&&a===o.MessageType.SYNC_READ_STATUS&&(E=[i.getCurrentUserId()]);var v={};for(var f in u)v[f]={v:""},v[f].v=u[f];var S=D;i.logger.info(y.P_SEND_MSG_T,JSON.stringify({messageType:a,conversationType:e,targetId:t,channelId:M}),s);var m=i._callCppProxy("sendMessage",(function(e,t){var n=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.info(y.P_SEND_MSG_R,JSON.stringify({code:t,messageUId:n.messageUId}),s),t===o.ErrorCode.SENSITIVE_REPLACE?r({code:t}):("RC:MsgExMsg"===n.messageType&&i._msgExpansionHandler.setLocalFromExtMsg(i.logger,n),n.canIncludeExpansion&&i._msgExpansionHandler.setLocalFromReceiveMsg(i.logger,n),r({code:o.ErrorCode.SUCCESS,data:n}))}),(function(e,t){var o=i._buildMessage(e,{isOffLineMessage:!1});return i.logger.warn(y.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),s),o.sentTime=Date.now()-i._cppProtocol.getDeltaTime(),r({code:t,data:o})}),e,t,a,JSON.stringify(c),E,P,G,K,g,_,d,J,W,S,I,JSON.stringify(v),O,M,b),T=JSON.parse(m);null==n||n(T.messageId)}))},e.prototype.recallMsg=function(e,t,r,n,s){var i=this;return new Promise((function(a){var c,u=s.user,d=s.pushContent,p=s.channelId,l=s.extra,C=s.pushConfig,h=s.disableNotification,f=s.isDelete,g={conversationType:e,targetId:t,messageUId:r,sentTime:n,user:u,extra:l,channelId:p,isDelete:f||!1};u&&(g.user=u),l&&(g.extra=l);var v={conversationType:e,targetId:t,senderUserId:i.tcpMgr.getCurrentUserId(),content:g,objectName:o.MessageType.RECALL,messageUid:r,direction:o.MessageDirection.SEND,status:o.ReceivedStatus.UNREAD,sentTime:n,channelId:p},_=i._buildMessage(JSON.stringify(v),{isOffLineMessage:!1});i._callCppProxy("recallMessage",(function(){i.handleRecalledMessage(_),a({code:o.ErrorCode.SUCCESS,data:_})}),(function(e){a({code:e})}),o.MessageType.RECALL,JSON.stringify(g),h||!1,(null==C?void 0:C.disablePushTitle)||!1,(null==C?void 0:C.forceShowDetailContent)||!1,d||"",(null==C?void 0:C.pushData)||"",(null===(c=null==C?void 0:C.androidConfig)||void 0===c?void 0:c.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)||"",p)}))},e.prototype.getHistoryMessage=function(e,t,r,n,s,i,a){var c=this;return new Promise((function(u){r=r||0;var d=0===s,p=n+1,l=c._callCppProxy("getHistoryMessages",e,t,r,p,a,d,i),C=JSON.parse(l).list,h=[];C.reverse();for(var f=0;f<C.length;f++){var g=c._buildMessage(C[f].obj);h[f]=g}u({code:o.ErrorCode.SUCCESS,data:{list:p===h.length?h.slice(1,p):h,hasMore:n<h.length}})}))},e.prototype.getMessages=function(e,t,r,n,s,i){var a=this;return void 0===r&&(r=0),new Promise((function(c){var u=0===s,d=r,p=0!==r,l=n+1;p&&(d+=u?1:-1,l++);for(var C=a._callCppProxy("getMessages",e,t,d,l,u,i),h=JSON.parse(C).list,f=[],g=0;g<h.length;g++){var v=a._buildMessage(h[g].obj);f[g]=v}var _=a._computeRepairInfo(f,u,r,d,l),S=_.isNeedRepair,y=void 0!==S&&S,E=_.repairTime,m=void 0===E?0:E;if(!y)return p&&(f.shift(),l--),f.reverse(),void c({code:o.ErrorCode.SUCCESS,data:{list:l===f.length?f.slice(1,l):f,hasMore:n<f.length}});a._processRepairHisMsg(e,t,r,n,s,i,m,c)}))},e.prototype._computeRepairInfo=function(e,t,o,r,n){var s=!1,i=0,a=this.getNaviInfoFromCache()||{},c=a.repairHisMsg,u=void 0===c?0:c,d=a.historyMsg;if(1!==u||!d)return{isNeedRepair:s,repairTime:i};var p=e.findIndex((function(e){return e.hasMore||0===Object.keys(e.content).length}));return t&&p>=0?(s=!0,i=e[p].hasMore?e[p].sentTime:e[p].sentTime+1):!t&&p>=1?(s=!0,i=e[p-1].sentTime):0===o?(s=!0,i=0):e.length<n?(s=!0,i=o):e.length>0&&e[0].sentTime!==o&&(s=!0,i=r),{isNeedRepair:s,repairTime:i}},e.prototype._processRepairHisMsg=function(e,t,o,r,n,s,i,a){var c=this,u=function(i){for(var u=0===n,d=r+1,p=c._callCppProxy("getMessages",e,t,o,d,u,s),l=JSON.parse(p).list,C=[],h=0;h<l.length;h++){var f=c._buildMessage(l[h].obj);C[h]=f}C.reverse(),a({code:i,data:{list:d<=C.length?C.slice(1,d):C,hasMore:r<C.length}})},d=r+10>100?100:r+10;this._callCppProxy("getRemoteHistoryMessages",e,t,i,d,(function(){return u(0)}),(function(e){u(e)}),n,!0,s,!1)},e.prototype.getRemoteHistoryMessages=function(e,t,r,n,s,i){var a=this;return new Promise((function(c){r=r||0;a._callCppProxy("getRemoteHistoryMessages",e,t,r,n,(function(e,t){var r=JSON.parse(e).list,n=[];r.reverse();for(var s=0;s<r.length;s++){var i=a._buildMessage(r[s].obj);n[s]=i}c({code:o.ErrorCode.SUCCESS,data:{list:n,hasMore:!!t}})}),(function(e){c({code:e})}),s,!0,i)}))},e.prototype.deleteRemoteMessage=function(e,t,r,n){var s=this;return new Promise((function(i){var a=JSON.stringify(r);s._callCppProxy("deleteRemoteHistoryMessages",e,t,a,!1,n,(function(){i(o.ErrorCode.SUCCESS)}),i)}))},e.prototype.deleteRemoteMessageByTimestamp=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("clearRemoteHistoryMessages",e,t,r,(function(){i(o.ErrorCode.SUCCESS)}),(function(e){i(e)}),n)}))},e.prototype.clearMessages=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("clearMessages",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.getConversationList=function(e,t,r,n,s){var i=this;return void 0===s&&(s=""),new Promise((function(e){for(var t=i._callCppProxy("getConversationList",[1,3,6,7],s),r=JSON.parse(t).list,n=[],a=0;a<r.length;a++)n.push(i._buildConversation(r[a].obj));e({code:o.ErrorCode.SUCCESS,data:n})}))},e.prototype.getConversation=function(e,t,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getConversation",e,t,r);if(i)s({code:o.ErrorCode.SUCCESS,data:n._buildConversation(i)});else{var a=n._cppProtocol.getHistoryMessages(e,t,0,1,"",!0,r),c=void 0;try{c=JSON.parse(a).list}catch(e){n.logger.error(y.P_PARSE_JSON_MSGS_E,null==e?void 0:e.stack),c=[]}var u=null;c.length>0&&(u=n._buildMessage(c[0].obj));var d=n._callCppProxy("getConversationNotificationStatus",e,t,r),p=n._callCppProxy("getConversationTopStatus",e,t,r);s({code:o.ErrorCode.SUCCESS,data:{conversationType:e,targetId:t,channelId:r,unreadMessageCount:0,latestMessage:u,notificationStatus:d?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE,isTop:Boolean(p),lastUnreadTime:0}})}}))},e.prototype.removeConversation=function(e,t,r){var n=this._callCppProxy("removeConversation",e,t,r);return Promise.resolve(n?o.ErrorCode.SUCCESS:o.ErrorCode.CONVER_REMOVE_ERROR)},e.prototype.clearConversations=function(e,t){var r=this;return new Promise((function(n){var s=[];s=o.isArray(e)?e:[o.ConversationType.PRIVATE,o.ConversationType.GROUP,o.ConversationType.SYSTEM,o.ConversationType.PUBLIC_SERVICE],r._callCppProxy("clearConversations",s,t||""),n(o.ErrorCode.SUCCESS)}))},e.prototype.getAllConversationUnreadCount=function(e,t,r){var n=this._callCppProxy("getTotalUnreadCount",t,r,e);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:n})},e.prototype.getConversationUnreadCount=function(e,t,r){var n=this;return void 0===r&&(r=""),new Promise((function(s){var i=n._callCppProxy("getUnreadCount",e,t,r);s({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.clearConversationUnreadCount=function(e,t,r){var n=this;return void 0===r&&(r=""),new Promise((function(s){n._callCppProxy("clearUnreadCount",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.clearUnreadCountByTimestamp=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("clearUnreadCountByTimestamp",e,t,r,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.getFirstUnreadMessage=function(e,t,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getTheFirstUnreadMessage",e,t,r),a=n._buildMessage(i);s({code:o.ErrorCode.SUCCESS,data:-1!==a.messageId?a:null})}))},e.prototype.setConversationToTop=function(e,t,r,n){var s=this;return void 0===n&&(n=""),new Promise((function(i){s._callCppProxy("setConversationToTop",e,t,r,n,!0),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationHidden=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("setConversationHidden",e,t,r,n),i(o.ErrorCode.SUCCESS)}))},e.prototype.setConversationNotificationStatus=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("setConversationNotificationStatus",e,t,r,(function(){i(o.ErrorCode.SUCCESS)}),i,n)}))},e.prototype.setConversationStatus=function(e,t,r,n,s){var i=this;return new Promise((function(a){i._callCppProxy("setConversationStatus",e,t,r,n,(function(){a(o.ErrorCode.SUCCESS)}),a,s,!0)}))},e.prototype.getConversationNotificationStatus=function(e,t,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getConversationNotificationStatus",e,t,r);s({code:o.ErrorCode.SUCCESS,data:i?o.NotificationStatus.OPEN:o.NotificationStatus.CLOSE})}))},e.prototype.searchConversationByContent=function(e,t,r,n){var s=this;return new Promise((function(i){n=n||[1,3,6,7];for(var a=s._callCppProxy("searchConversationByContent",n,e,t,r),c=JSON.parse(a).list,u=[],d=0;d<c.length;d++)u[d]=s._buildConversation(c[d].obj);i({code:o.ErrorCode.SUCCESS,data:u})}))},e.prototype.searchConversationByContentWithAllChannel=function(e,t,r){var n=this;return new Promise((function(s){r=r||[1,3,6,7];for(var i=n._callCppProxy("searchConversationByContentWithAllChannel",r,e,t),a=JSON.parse(i).list,c=[],u=0;u<a.length;u++)c[u]=n._buildConversation(a[u].obj);s({code:o.ErrorCode.SUCCESS,data:c})}))},e.prototype.searchMessageByContent=function(e,t,r,n,s,i,a){var c=this;return new Promise((function(i){c._callCppProxy("searchMessageByContent",e,t,r,n,s,1,(function(e,t){for(var r=e?JSON.parse(e).list:[],n=[],s=0;s<r.length;s++)n[s]=c._buildMessage(r[s].obj);i({code:o.ErrorCode.SUCCESS,data:{messages:n,count:t}})}),a)}))},e.prototype.searchMessagesByUser=function(e,t,r,n,s,i){var a=this;return new Promise((function(c){a._callCppProxy("getMessageBySender",e,t,r,n,s,i,(function(e){for(var t=e?JSON.parse(e).list:[],r=[],n=0;n<t.length;n++)r[n]=a._buildMessage(t[n].obj);c({code:o.ErrorCode.SUCCESS,data:{messages:r}})}))}))},e.prototype.searchMessageByContentWithAllChannel=function(e,t,r,n,s){var i=this;return new Promise((function(a){i._callCppProxy("searchMessageByContentWithAllChannel",e,t,r,n,s,1,(function(e,t){for(var r=e?JSON.parse(e).list:[],n=[],s=0;s<r.length;s++)n[s]=i._buildMessage(r[s].obj);a({code:o.ErrorCode.SUCCESS,data:{messages:n,count:t}})}))}))},e.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(e,t,r,n,s,i,a){var c=this;return new Promise((function(u){c._callCppProxy("searchMessageByTimestampWithAllChannel",e,t,r,n,s,i,a,(function(e){for(var t=e?JSON.parse(e).list:[],r=[],n=0;n<t.length;n++)r[n]=c._buildMessage(t[n].obj);u({code:o.ErrorCode.SUCCESS,data:{messages:r}})}))}))},e.prototype.getUnreadMentionedMessages=function(e,t,o){for(var r=JSON.parse(this._callCppProxy("getUnreadMentionedMessages",e,t,o)).list,n=0;n<r.length;n++)r[n]=this._buildMessage(r[n].obj);return r},e.prototype.addToBlacklist=function(e){var t=this;return new Promise((function(r){t._callCppProxy("addToBlacklist",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.removeFromBlacklist=function(e){var t=this;return new Promise((function(r){t._callCppProxy("removeFromBlacklist",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getBlacklist=function(){var e=this;return new Promise((function(t){e._callCppProxy("getBlacklist",(function(e){t({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){t({code:e})}))}))},e.prototype.getBlacklistStatus=function(e){var t=this;return new Promise((function(r){t._callCppProxy("getBlacklistStatus",e,(function(e){r({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){r({code:e})}))}))},e.prototype.insertMessage=function(e,t,r){var n=this,s=r.content,i=r.senderUserId,a=r.messageType,c=r.messageDirection,u=r.readStatus,d=r.sentStatus,p=r.sentTime,l=r.searchContent,C=r.isUnread,h=r.messageUId,f=r.disableNotification,g=r.canIncludeExpansion,v=r.expansionMsg,_=r.channelId;s=JSON.stringify(s);var S={};if(p=p||0,v){var y=JSON.parse(v);for(var E in y)S[E]={v:"",ts:0},S[E].v=y[E],S[E].ts=p}return new Promise((function(r){var v=C?0:1,y=n._callCppProxy("insertMessage",e,t,i,a,s,(function(){}),(function(e){r({code:e})}),c,u||0,d||10,p,l||"",v,h||"",!!f,!!g,JSON.stringify(S),_||""),E=n._buildMessage(y,{isOffLineMessage:!1});E.messageUId=h,E.sentTime=p,r({code:-1===E.messageId?o.ErrorCode.MSG_INSERT_ERROR:o.ErrorCode.SUCCESS,data:E})}))},e.prototype.batchInsertMessage=function(e,t){var r=this;return void 0===t&&(t=!1),new Promise((function(n){var s=e.map((function(e){var t=e.content,o=e.senderUserId,r=e.messageType,n=e.messageDirection,s=e.receivedStatus,i=e.sentStatus,a=e.sentTime,c=e.searchContent,u=e.isUnread,d=e.messageUId,p=e.disableNotification,l=e.canIncludeExpansion,C=e.expansion,h=e.channelId,f=e.conversationType,g=e.targetId,v=e.source,_=e.isMentioned,S={};if(a=a||0,C)for(var y in C)S[y]={v:"",ts:0},S[y].v=C[y],S[y].ts=a;return{conversationType:f,targetId:g,channelId:h||"",direction:n,senderUserId:o,status:i||10,sentTime:a,objectName:r,content:JSON.stringify(t),messageUid:d||"",noNotification:!!p,supportExt:!!l,extMsg:JSON.stringify(S),readStatus:s||0,searchContent:c||"",isUnread:!!u,source:v||"",isMention:_}})),i=r._callCppProxy("insertMessages",JSON.stringify(s),t);n({code:i?o.ErrorCode.SUCCESS:o.ErrorCode.MSG_INSERT_ERROR,data:i||!1})}))},e.prototype.getMessageCount=function(e,t,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getMessageCount",e,t,r);s({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.deleteMessages=function(e){var t=this;return new Promise((function(r){t._callCppProxy("deleteMessages",e),r(o.ErrorCode.SUCCESS)}))},e.prototype.deleteMessagesByTimestamp=function(e,t,r,n,s){var i=this;return new Promise((function(a){i._callCppProxy("deleteMessagesByTimestamp",e,t,r,n,s),a(o.ErrorCode.SUCCESS)}))},e.prototype.getMessage=function(e){var t=this;return new Promise((function(r){var n=t._callCppProxy("getMessage",e),s=t._buildMessage(n,{isOffLineMessage:!1});r({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.setMessageContent=function(e,t,r){var n=this;return new Promise((function(s){t=JSON.stringify(t),n._callCppProxy("setMessageContent",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSearchField=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("setMessageSearchField",e,t,r),s(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageSentStatus=function(e,t){var r=this;return new Promise((function(n){r._callCppProxy("setMessageSentStatus",e,t),n(o.ErrorCode.SUCCESS)}))},e.prototype.setMessageReceivedStatus=function(e,t){var r=this;return new Promise((function(n){r._callCppProxy("setMessageReceivedStatus",e,t),n(o.ErrorCode.SUCCESS)}))},e.prototype.saveConversationMessageDraft=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("saveTextMessageDraft",e,t,r,n||"")&&i(o.ErrorCode.SUCCESS),i(o.ErrorCode.DRAFT_SAVE_ERROR)}))},e.prototype.getConversationMessageDraft=function(e,t,r){var n=this;return new Promise((function(s){var i=n._callCppProxy("getTextMessageDraft",e,t,r||"");s({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.clearConversationMessageDraft=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("clearTextMessageDraft",e,t,r||"")&&s(o.ErrorCode.SUCCESS),s(o.ErrorCode.DRAFT_REMOVE_ERROR)}))},e.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},e.prototype.batchSetConversationStatus=function(e){var t=e[0],r=t.conversationType,n=t.targetId,s=t.isTop,i=t.notificationStatus,a=t.channelId,c=this._callCppProxy("getConversationNotificationStatus",r,n,a||""),u=this._callCppProxy("getConversationTopStatus",r,n,a||""),d=o.isUndefined(i)?Boolean(c):i===o.NotificationStatus.OPEN,p=o.isUndefined(s)?Boolean(u):s;return this.setConversationStatus(r,n,d,p,a)},e.prototype.getConversationNotificationLevel=function(e,t,r){return m(this,void 0,void 0,(function(){var n;return P(this,(function(s){return n=this._callCppProxy("getBlockPushLevelForConversation",t,r,e),[2,Promise.resolve({code:o.ErrorCode.SUCCESS,data:n})]}))}))},e.prototype.setConversationNotificationLevel=function(e,t,r,n){var s=this;return void 0===n&&(n=""),new Promise((function(i){s._callCppProxy("setBlockPushLevelForConversation",t,n,e,r,(function(){i(o.ErrorCode.SUCCESS)}),(function(e){i(e)}))}))},e.prototype.getTotalUnreadCountByLevels=function(e,t,r){if(r){var n=this._callCppProxy("getUnreadMentionedCountByLevel",e,t);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:n})}var s=this._callCppProxy("getUnreadCountByLevel",e,t);return Promise.resolve({code:o.ErrorCode.SUCCESS,data:s})},e.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},e.prototype.sendReadReceiptMessage=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("sendReadReceipt",e,r||"",t,(function(){t.forEach((function(e){n._updateReadReceiptInfo(e,{hasRespond:!0});try{var t=JSON.parse(n._callCppProxy("getMessage",e)).messageId;n.setMessageReceivedStatus(t,1)}catch(t){n.logger.error(y.P_PARSE_JSON_MSGS_E,JSON.stringify({messageUId:e,error:null==t?void 0:t.stack}))}})),s({code:o.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},e.prototype.getMessageReader=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("getMessageReader",e,r,t,(function(e,r){var i=[],a={};(e=JSON.parse(e)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;i.push({userId:o,readTime:r}),a[o]=r}));var c={readerInfo:a,readCount:i.length,totalCount:r};n._updateReadReceiptInfo(t,c),s({code:o.ErrorCode.SUCCESS,data:{list:i,totalMemberCount:r}})}),(function(e){s({code:e})}))}))},e.prototype.sendReadReceiptMessageV4=function(e,t,r){var n=this;return new Promise((function(s){var i=e.conversationType,a=e.targetId,c=e.channelId;n._callCppProxy("sendMessageReadReceipt",i,a,c||"",t,r,(function(){s({code:o.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},e.prototype.getMessageReadReceiptV4=function(e,t){var r=this;return new Promise((function(n){var s=e.targetId,i=e.channelId;r._callCppProxy("getMessageReadReceipt",s,i||"",t,(function(e){var t=[];try{JSON.parse(e).list.forEach((function(e){var o=JSON.parse(e.obj),r=o.id,n=o.time;t.push({userId:r,readTime:n})}))}catch(t){r.logger.error(y.P_PARSE_JSON_E,"method: getMessageReadReceipt, info: ".concat(e,", error: ").concat(t))}n({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}))},e.prototype.updateConversationReadTime=function(e,t){var r=this;return new Promise((function(n){var s=e.conversationType,i=e.targetId,a=e.channelId;r._callCppProxy("updateConversationReadTime",s,i,a||"",t,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype._addChatroomCache=function(e,t,o){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:o,count:t})},e.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},e.prototype._try2RejoinChatroom=function(){var e=this;if(0!==this._chatroomCache.length){var t=this.logger.createTraceId();this._chatroomCache.forEach((function(r){return m(e,void 0,void 0,(function(){var e,n,s,i,a,c;return P(this,(function(u){switch(u.label){case 0:return e=r.chatroomId,n=r.joinExist,s=r.count,this.logger.info(o.LogTagId.L_REJOIN_CHATROOM_T,e,t),[4,this._joinChrm(e,s,n,!1)];case 1:return i=u.sent(),a=i.code,c=i.data,a===o.ErrorCode.SUCCESS?(this.logger.info(o.LogTagId.L_REJOIN_CHATROOM_R,e,t),this._sendChatroomStatus({rejoinedRoom:E({chatroomId:e,count:s},c)}),[2]):(a===o.ErrorCode.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(e),this._sendChatroomStatus({rejoinedRoom:{chatroomId:e,errorCode:a}}),this.logger.warn(o.LogTagId.L_REJOIN_CHATROOM_R,"chrmId: ".concat(e,", code: ").concat(a),t),[2])}}))}))}))}},e.prototype._joinChrm=function(e,t,r,n){var s=this,i=r?"joinExistChatRoom":"joinChatRoom";return new Promise((function(a){n&&s._callCppProxy("clearMessages",o.ConversationType.CHATROOM,e,""),s._callCppProxy(i,e,t,(function(n,i,c,u,d,p){s._addChatroomCache(e,t,r),a({code:o.ErrorCode.SUCCESS,data:{createTime:Number(n),memberCount:i,isAllChatroomBanned:c,isCurrentUserBanned:u,isCurrentChatroomBanned:d,isCurrentChatroomInWhitelist:p}})}),(function(e){a({code:e})}))}))},e.prototype.joinChatroom=function(e,t){return m(this,void 0,void 0,(function(){return P(this,(function(o){switch(o.label){case 0:return[4,this._joinChrm(e,t,!1,!0)];case 1:return[2,o.sent().code]}}))}))},e.prototype.joinExistChatroom=function(e,t){return this._joinChrm(e,t,!0,!0)},e.prototype.quitChatroom=function(e){var t=this;return this._rmChatroomCache(e),new Promise((function(r){t._callCppProxy("quitChatRoom",e,(function(){r(o.ErrorCode.SUCCESS)}),r)}))},e.prototype.getChatroomInfo=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("getChatroomInfo",e,t,r,(function(e,t){var r=e?JSON.parse(e).list:[],n=[];if(r.length>0)for(var i=0;i<r.length;i++)n.push(JSON.parse(r[i].obj));s({code:o.ErrorCode.SUCCESS,data:{userInfos:n,userCount:t}})}),(function(e){s({code:e})}))}))},e.prototype.getChatroomHistoryMessages=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("getChatroomHistoryMessage",e,t,r,n,(function(e){var t;try{t=JSON.parse(e)}catch(e){t={list:[]}}var r=t.list;if(r&&r.length)try{t.list=r.map((function(e){return s._buildMessage(e.obj)}))}catch(e){t.list=[]}i({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){i({code:e})}),"")}))},e.prototype.setChatroomEntry=function(e,t){var r=this;return new Promise((function(n){var s='[{"key":"'.concat(t.key,'", "value":"').concat(t.value,'"}]');r._callCppProxy("setChatroomKV",e,s,!!t.isAutoDelete,!!t.isOverwrite,(function(){n(o.ErrorCode.SUCCESS)}),(function(e){n(e)}))}))},e.prototype.setChatroomEntries=function(e,t){var r=this;return new Promise((function(n){r._callCppProxy("setChatroomKV",e,JSON.stringify(t.entries),!!t.isAutoDelete,!!t.isOverwrite,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.forceSetChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.setChatroomEntry(e,t)},e.prototype.removeChatroomEntry=function(e,t){var r=this,n=[t.key];return new Promise((function(s){r._callCppProxy("deleteChatroomKV",e,n,!!t.isOverwrite,(function(){s(o.ErrorCode.SUCCESS)}),(function(e){s(e)}))}))},e.prototype.forceRemoveChatroomEntry=function(e,t){return t.isOverwrite=!0,t.userId=t.userId||this.tcpMgr.getCurrentUserId(),this.removeChatroomEntry(e,t)},e.prototype.removeChatroomEntries=function(e,t){var r=this;return new Promise((function(n){var s=t.entries.map((function(e){return e.key}));r._callCppProxy("deleteChatroomKV",e,s,!!t.isOverwrite,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getChatroomEntry=function(e,t){return m(this,void 0,void 0,(function(){var r;return P(this,(function(n){switch(n.label){case 0:return[4,this.getAllChatroomEntry(e)];case 1:return(r=n.sent()).code===o.ErrorCode.SUCCESS?[2,{code:o.ErrorCode.SUCCESS,data:r.data?r.data[t]:null}]:[2,{code:r.code}]}}))}))},e.prototype.getAllChatroomEntry=function(e){var t=this;return new Promise((function(r){t._callCppProxy("getChatroomKV",e,(function(e){var t={};try{(e?JSON.parse(e):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){t[e.key]=e.value?e.value:""}))}catch(e){}r({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){r({code:e})}))}))},e.prototype.getFileToken=function(e,t,r,n,s){var i=this;return void 0===s&&(s=""),r=r||"",n=n||"",new Promise((function(a){var c;c=n&&"uploads"!==n?t||"":o.getUploadFileName(e,t),i._callCppProxy("getUploadToken",e,c,r,n,s,(function(e,t,r,n,s,i,u,d,p,l,C,h,f,g,v,_,S,y,E,m,P,T,I){a({code:o.ErrorCode.SUCCESS,data:{token:e,deadline:0,bosToken:t,bosDate:r,path:n,osskeyId:s,ossPolicy:i,ossSign:u,ossBucketName:d,fileName:c,s3Credential:p,s3Algorithm:l,s3Date:C,s3Policy:h,s3Signature:f,s3BucketName:g,stcAuthorization:v,stcContentSha256:_,stcDate:S,stcBucketName:y,minioAuthorization:E,minioContentSha256:m,minioDate:P,minioBucketName:T,downloadAuthInfo:I?JSON.parse(I):null}})}),(function(e){a({code:e})}))}))},e.prototype.getFileUrl=function(e,t,r,n){var s=this;return new Promise((function(i){s._callCppProxy("getDownloadUrl",e,r,n,t-1,(function(e){i({code:o.ErrorCode.SUCCESS,data:{downloadUrl:e}})}),(function(e){i({code:e})}))}))},e.prototype.clearData=function(){var e=this;return new Promise((function(t){var r=e._callCppProxy("clearData");t({code:o.ErrorCode.SUCCESS,data:r})}))},e.prototype.getDeviceId=function(){var e=this._dbpath||t.resolve(n.app.getPath("userData"));return ue(e)},e.prototype.getVoIPKey=function(e,t){var r=this;return new Promise((function(n){r._callCppProxy("getVoIPKey",e,t,"",(function(e){n({code:o.ErrorCode.SUCCESS,data:e})}),(function(e){n({code:e})}))}))},e.prototype.bindRTCRoomForChatroom=function(e){var t=this;return new Promise((function(r){var n=e.chatRoomId,s=e.rtcRoomId;t._callCppProxy("bindRTCRoomForChatroom",n,s,(function(){r(o.ErrorCode.SUCCESS)}),(function(e){r(e)}))}))},e.prototype.getGroupMessageDeliverList=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("getGroupMessageDeliverList",e,r,t,(function(e,t){var r=JSON.parse(e).list.map((function(e){return{time:JSON.parse(e.obj).time,userId:JSON.parse(e.obj).id}}));s({code:o.ErrorCode.SUCCESS,data:{totalCount:t,list:r}})}),(function(e){s({code:e})}))}))},e.prototype.getPrivateMessageDeliverTime=function(e,t){var r=this;return new Promise((function(n){var s=r._callCppProxy("getMessageDeliverTime",e);if(s)n({code:o.ErrorCode.SUCCESS,data:s});else{r._callCppProxy("getPrivateMessageDeliverList",t,e,(function(e){var t=0,r=JSON.parse(e).list;r.length>0&&(t=JSON.parse(r[0].obj).time);n({code:o.ErrorCode.SUCCESS,data:t})}),(function(e){n({code:e})}))}}))},e.prototype.rtcSignaling=function(e,t,r,n){var s=this,i=Array.prototype.slice.call(new Uint8Array(n));return new Promise((function(n){s._callCppProxy("rtcSignaling",e,t,r,i,(function(e){var t=new Uint8Array(e).buffer;n({code:o.ErrorCode.SUCCESS,buffer:t})}),(function(e){n({code:e})}),30)}))},e.prototype._setRTCHeartbeatListener=function(){var e=this;this._cppProtocol.setRTCHeartbeatListener((function(t,o){var r=e.rtcHeartbeatResolves[t];if(r){var n=r.find((function(e){return""===e.seqId}));n&&(n.seqId=o)}}),(function(t,o,r,n){var s=e.rtcHeartbeatResolves[t];if(s){var i=s.findIndex((function(e){return e.seqId===r}));-1!==i&&s.splice(i,1)[0].resolve({code:o,data:{version:Number(n)}})}}))},e.prototype.rtcPing=function(e,t,o){var r=this;return new Promise((function(t){var o={resolve:t,seqId:""},n=r.rtcHeartbeatResolves[e];n?n.push(o):r.rtcHeartbeatResolves[e]=[o],r._callCppProxy("sendRTCHeartbeat",[e],30)}))},e.prototype.createTag=function(e){var t=this;return new Promise((function(r){t._callCppProxy("addTag",e.tagId,e.tagName,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.removeTag=function(e){var t=this;return new Promise((function(r){t._callCppProxy("deleteTag",e,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.updateTag=function(e){var t=this;return new Promise((function(r){t._callCppProxy("renameTag",e.tagId,e.tagName,(function(){r({code:o.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},e.prototype.getTagList=function(){var e=this;return new Promise((function(t){var r=e._callCppProxy("getTags"),n=e._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));t({code:o.ErrorCode.SUCCESS,data:n})}))},e.prototype.addTagForConversations=function(e,t){var r=this;return new Promise((function(n){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));r._callCppProxy("addConversationsForTag",e,JSON.stringify(t),(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTagForConversations=function(e,t){var r=this;return new Promise((function(n){t.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),r._callCppProxy("removeConversationsForTag",e,JSON.stringify(t),(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.removeTagsForConversation=function(e,t){var r=this;return new Promise((function(n){r._callCppProxy("removeTagsForConversation",e.conversationType,e.targetId,e.channelId||"",t,(function(){n({code:o.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},e.prototype.getConversationListByTag=function(e,t,r,n){var s=this;return new Promise((function(i){var a=s._callCppProxy("getConversationsForTagByPage",e,t,r||20,n||""),c=s._convertResultList(a,(function(e){return E(E({},s._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));i({code:o.ErrorCode.SUCCESS,data:c})}))},e.prototype.getUnreadCountByTag=function(e,t){var r=this;return new Promise((function(n){var s=r._callCppProxy("getConversationUnreadCountForTag",e,t);n({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.setConversationStatusInTag=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("setConversationToTopForTag",e,t.conversationType,t.targetId,t.channelId||"",r.isTop||!1,(function(){s({code:o.ErrorCode.SUCCESS})}),(function(e){s({code:e})}))}))},e.prototype.getTagsForConversation=function(e){var t=this;return new Promise((function(r){var n=t._callCppProxy("getTagsForConversation",e.conversationType,e.targetId,e.channelId||""),s=t._convertResultList(n,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));r({code:o.ErrorCode.SUCCESS,data:s})}))},e.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},e.prototype.getTopConversationList=function(e,t){var r=this;return new Promise((function(n){var s=o.isUndefined(t)?r._callCppProxy("getTopConversations",e):r._callCppProxy("getTopConversations",e,t),i=JSON.parse(s).list.map((function(e){return r._buildConversation(e.obj)}));n({code:o.ErrorCode.SUCCESS,data:i})}))},e.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},e.prototype.getAllUnreadMentionedCount=function(){throw new Error("Method not implemented.")},e.prototype.getOSInfo=function(){return m(this,void 0,void 0,(function(){var e;return P(this,(function(t){return e={arch:h.arch(),platform:h.platform(),type:h.type(),version:h.version(),release:h.release(),uptime:h.uptime(),cpus:h.cpus(),freemem:h.freemem(),totalmem:h.totalmem(),networkInterfaces:h.networkInterfaces()},[2,{code:o.ErrorCode.SUCCESS,data:e}]}))}))},e.prototype.getMainProcessInfo=function(){return m(this,void 0,void 0,(function(){return P(this,(function(e){return[2,{code:o.ErrorCode.SUCCESS,data:{title:process.title,pid:process.pid,ppid:process.ppid,platform:process.platform,arch:process.arch,uptime:process.uptime(),cpuUsage:process.cpuUsage(),memoryUsage:process.memoryUsage(),resourceUsage:process.resourceUsage()}}]}))}))},e.prototype.setCallInfo=function(e,t,r){var n=this;return new Promise((function(s){n._callCppProxy("callInfoSignaling",e,t,r,(function(e,t){s({code:o.ErrorCode.SUCCESS,data:{key:e,value:t}})}),(function(e){s({code:e})}))}))},e.prototype.setProxy=function(e){return this.tcpMgr.getConnectionStatus()!==o.RCConnectionStatus.DISCONNECTED?Promise.resolve({code:o.ErrorCode.RC_CONN_PROXY_UNAVAILABLE}):Promise.resolve(z(e,this.logger))},e.prototype.getProxy=function(){return Promise.resolve(Z())},e.prototype.testProxy=function(e,t){return function(e,t,r){return new Promise((function(n){var s=/^https/.test(t)?Y:q;r.info(o.LogTagId.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:e,testHost:t}));var i=s(t,e,(function(e){var t=200===e.statusCode?0:e.statusCode;e.setEncoding("utf8");var o="";e.on("data",(function(e){o+=e})),e.once("end",(function(){n({status:t||0,data:o})}))}));i.once("timeout",(function(){return n({status:0})})),i.once("error",(function(e){return n({status:0,data:e.stack})})),i.end()}))}(e,t,this.logger)},e.prototype.checkDuplicateMessage=function(e){var t=this;return new Promise((function(r){var n=t._callCppProxy("checkDuplicateMessage",e);r({code:o.ErrorCode.SUCCESS,data:n})}))},e}(),ye=function(){function e(e,t,o,r){void 0===o&&(o=""),this._cppService=new Se(e,t,o,r)}return e.prototype.getCppProto=function(){var e=this;return{destroy:function(){console.warn("`.getCppProto().destroy()` has being deprecated, use `.destroy()` instead."),e.destroy()}}},e.prototype.destroy=function(){this._cppService.destroy()},e.prototype.getDeviceId=function(){return this._cppService.getDeviceId()},e.prototype.getServerTime=function(){return this._cppService.getServerTime()},e}();module.exports=function(e){return function(e,t,o){if(fe)return fe;if(!t)throw new Error("Initializ failed, `appkey` is required!");return fe=new ye(t,e,null==o?void 0:o.dbpath,null==o?void 0:o.logOutputLevel)}(v,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.8.5-alpha.
|
|
23
|
+
"version": "5.8.5-alpha.4",
|
|
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.8.5-alpha.
|
|
34
|
+
"@rongcloud/engine": "=5.8.5-alpha.4"
|
|
35
35
|
}
|
|
36
36
|
}
|