@rongcloud/electron 5.12.2 → 5.12.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/binding/electron-darwin-arm64.node +0 -0
- package/binding/electron-darwin-x64.node +0 -0
- package/binding/electron-linux-arm64.node +0 -0
- package/binding/electron-linux-x64.node +0 -0
- package/binding/electron-win32-ia32.node +0 -0
- package/binding/electron-win32-x64.node +0 -0
- package/cppServiceProcess.js +1 -1
- package/index.esm.js +1 -1
- package/index.js +1 -1
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("@rongcloud/engine"),t=require("electron"),o=require("child_process"),r=require("path"),n=require("os"),i=require("http"),s=require("https"),a=require("zlib"),c=require("url"),u=require("net"),p=require("events"),d=require("tls"),l=require("fs"),f=require("crypto");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}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 g=C(n),v=h(a),_=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,m=function(){return m=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},m.apply(this,arguments)};function E(e,t,o,r){return new(o||(o=Promise))((function(n,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(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(s,a)}c((r=r.apply(e,t||[])).next())}))}function P(e,t){var o,r,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,r&&(n=2&i[0]?r.return:i[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,i[1])).done)return n;switch(r=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){s.label=i[1];break}if(6===i[0]&&s.label<n[1]){s.label=n[1],n=i;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(i);break}n[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{o=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function T(e,t,o){if(o||2===arguments.length)for(var r,n=0,i=t.length;n<i;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_DB_UPGRATE_START_S="P-db_upgrate_start-S",e.P_DB_UPGRATING_S="P-db_upgrating-S",e.P_DB_UPGRATE_COMPLETE_S="P-db_upgrate_complete-S",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_PARSE_JSON_MSGS_R="P-parse_json_messsages-R",e.P_RECEIVE_MESSAGE_E="P-receive_message-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_PARSE_JSON_SUBSCRIBE_DATA_E="P-parse_json_subscribe_data-E",e.P_PARSE_JSON_USER_PROFILE_E="P-parse_json_user_profile-E",e.P_PARSE_JSON_USER_PROFILE_LIST_E="P-parse_json_user_profile_list-E",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 U(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 b=200;function U(e,t){var o=R.queue,r=R.flushTimestamp;if(!(R.locked||0===o.length||Date.now()-r<3e4&&o.length<b)){R.locked=!0;var n=t.createTraceId(),i=t.getSessionId(),s=o.splice(0,b).map((function(e){var t=e.sessionId,o=e.level,r=e.time,n=e.type,s=e.tag,a=e.loggerId,c=e.content,u=e.traceId;return{level:o,time:r,type:n,tag:s,sessionId:i+":"+t,content:{loggerId:a,content:c,traceId:u}}}));t.debug(y.P_WRITE_LOG_T,"writingLen: "+s.length+", queueLen: "+o.length,n);var a=JSON.stringify(s);e.writeLog(a),t.debug(y.P_WRITE_LOG_R,"write done, queueLen: "+o.length,n),R.flushTimestamp=Date.now(),R.locked=!1,setTimeout((function(){return U(e,t)}))}}var x,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}(e.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}(e.BasicStatistic),A=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])},k=function(e){return"string"==typeof e},D=function(e){return k(e)?e.toUpperCase():""},J=function(e,t){var o="";return 2!==e.length?o="Unexpected number of bytes received.":5!==e[0]?o="Unexpected SOCKS version number: "+e[0]+".":255===e[1]?o="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(o="Unexpected SOCKS authentication method: "+e[1]+"."),o},G=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: "+e[0]+".":0!==e[1]&&(t="Username and password authentication failure: "+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 i="";for(var s in i=t+" "+(o+n)+" HTTP/1.1\n",r){if(Object.hasOwnProperty.call(r,s))i+=s+": "+r[s]+"\n"}return e.body&&(i+="Content-Length: "+e.body.length+"\n"),i+="\n","POST"===t&&e.body&&(i+=""+e.body),i},B=function(e){return new Promise((function(t){var o,r;e.socket.once("data",(function(r){var n,i=J(r,o);if(!i)return 2===r[1]?(e.socket.once("data",(function(o){var r=G(o);r?e.emit("error",new Error("SOCKS authentication failed. "+r)):t()})),n=[1],A(e.socksUsername,n),A(e.socksPassword,n),void e.write(Buffer.from(n))):void t();e.emit("error",new Error("SOCKS authentication failed. "+i))})),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)}))},j=function(e,t,o){return new Promise((function(r){var n,i;switch(e.socket.once("data",(function(t){var o;5!==t[0]?o="Unexpected SOCKS version number: "+t[0]+".":0!==t[1]?o=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 "+e}}(t[1])+".":0!==t[2]&&(o="The reserved byte must be 0x00."),o?e.emit("error",new Error("SOCKS connection failed. "+o)):r()})),(n=[]).push(5),n.push(1),n.push(0),u.isIP(t)){case 0:n.push(3),A(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,(i=Buffer.from(n)).writeUInt16BE(o,i.length-2),e.write(i)}))},V=function(e){function t(t){var o=e.call(this)||this;return o.readable=!0,o.socket=new u.Socket,o.options=t,o.socksHost=t.socksHost||"localhost",o.socksPort=t.socksPort||1080,o.socksUsername=t.socksUsername||"",o.socksPassword=t.socksPassword||"",o.socket.on("error",(function(e){o.emit("error",e)})),o.on("error",(function(){o.socket.destroyed||o.socket.destroy()})),o.on("end",o.end),o}return 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: "+e);if(!t||"string"!=typeof t)throw new TypeError("Invalid host: "+t);return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return E(o,void 0,void 0,(function(){var o;return P(this,(function(r){switch(r.label){case 0:return[4,B(this)];case 1:return r.sent(),[4,j(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}(p.EventEmitter),q=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 V(e).connect(r,o)},H=function(e){function t(t){var o=e.call(this)||this;return o.createConnection=q,o}return S(t,e),t}(i.Agent),K=function(e,t,o){return(t=m(m({},t),c.parse(e))).port||(t.port=80),t.agent=new H(t),i.request(t,o)},W=function(e){var t,o;return t=q(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},Q=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=W,r}return S(t,e),t}(s.Agent),Y=function(e,t,o,r){var n,i;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),i=new Q(e,t),t.agent=i,s.request(e,t,o)},X=null;function z(t,o,r){void 0===r&&(r=!1);var n=o.url,a=o.headers,c=o.body,u=o.method,p=o.query,d=o.timeout,l=void 0===d?e.HTTP_TIMEOUT:d;return new Promise((function(o){var d=/^https/.test(n),f={headers:m(m({},a),{"Accept-Encoding":"gzip, br"}),method:u};d&&(f.rejectUnauthorized=r);var h=null;X?((f=m(m({},f),X)).body=c,h=d?Y:K):(h=i.request,d&&(f.agent=new s.Agent(f),h=s.request));var C=h(e.appendUrl(n,p),f,(function(e){var t,r,n=e.statusCode,i="";if("gzip"===(null===(t=e.headers)||void 0===t?void 0:t["content-encoding"])){var s=v.default.createGunzip();e.pipe(s),s.on("data",(function(e){i+=e})),s.on("end",(function(){o({status:n,data:i})}))}else if("br"===(null===(r=e.headers)||void 0===r?void 0:r["content-encoding"])){var a=v.default.createBrotliDecompress();e.pipe(a),a.on("data",(function(e){i+=e})),a.on("end",(function(){o({status:n,data:i})}))}else e.setEncoding("utf8"),e.on("data",(function(e){i+=e})),e.once("end",(function(){o({status:n||0,data:i})}))}));C.once("timeout",(function(){t.warn(y.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:n,method:u,query:p,timeout:l})),o({status:0})})),C.setTimeout(l),C.once("error",(function(e){t.warn(y.P_HTTP_REQ_E,JSON.stringify({msg:e.stack,url:n,method:u,query:p,timeout:l})),o({status:0})})),C.write(c),C.end()}))}function $(t,o){return t?(X=m(m({},X),t),o.info(e.LogTagId.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:X})),{code:e.ErrorCode.SUCCESS}):(X=null,o.info(e.LogTagId.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:e.ErrorCode.SUCCESS})}function Z(){var t=X||void 0;return{code:e.ErrorCode.SUCCESS,data:t}}!function(e){e[e.ERROR=-1]="ERROR",e[e.RESPONSE=0]="RESPONSE",e[e.EVENT=1]="EVENT",e[e.CALLBACK=2]="CALLBACK"}(x||(x={}));var ee=function(){function t(t,o,r,n){var i=this;this.p=t,this.emit=o,this.callback=r,this.errorHandle=n,this.count=0,this.maps={},this.p.on("message",(function(e){var t=e.type,s=e.data;switch(t){case x.EVENT:var a=s,c=a.eventName,u=a.data;null==o||o.apply(void 0,T([c],u,!1));break;case x.RESPONSE:var p=s,d=p.reqId,l=p.success,f=p.data,h=i.maps[d];if(!h)return;h({success:l,data:f}),delete i.maps[d];break;case x.CALLBACK:null==r||r(s);break;case x.ERROR:var C=s.msg;null==n||n(C)}})),this.p.on("error",(function(e){null==n||n("SubProcessProxy error "+e)})),this.p.on("exit",(function(t,o){if(0!==t){for(var r in i.maps){if(Object.prototype.hasOwnProperty.call(i.maps,r))(0,i.maps[r])({success:!0,data:{code:e.ErrorCode.SUB_PROCESS_EXIT,msg:"sub process exit"}})}null==n||n("SubProcessProxy exit "+t+" "+o,!0)}})),this.p.on("close",(function(e,t){console.log("SubProcessProxy close",e,t)}))}return t.prototype.call=function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return this.p.killed||this.p.exitCode?[2,Promise.resolve({success:!1,data:{code:e.ErrorCode.SUB_PROCESS_EXIT,msg:"sub process exit"}})]:[2,new Promise((function(e){var n=++r.count;r.maps[n]=e;var i={reqId:n,method:t,args:o,hasResponse:!0};r.p.send(i)}))]}))}))},t.prototype.send=function(e){for(var t,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return E(this,void 0,void 0,(function(){var r;return P(this,(function(n){return(this.p.killed||this.p.exitCode)&&(null===(t=this.errorHandle)||void 0===t||t.call(this,"sub process exit")),r={reqId:-1,method:e,args:o},this.p.send(r),[2]}))}))},t.prototype.destroy=function(){this.send("destroy")},t}(),te=[],oe=!1,re=function(){return E(void 0,void 0,void 0,(function(){var t,o,r,n,i,s,a,c,u,p,d,l,f;return P(this,(function(h){return oe||0===te.length||(oe=!0,t=te.shift(),o=t.args,r=t.resolve,n=o.addon,i=o.startTime,s=o.endTime,a=o.level,c=o.realtimeReport,u=0,p=0,d=[],l=function(t){u+=t.length;var o=t.split(","),n=o[0],i=o[1],s=o[2],l=o[3],f=o[4],h=o.slice(5);if(u>e.REAT_TIME_LOG_SIZE&&parseInt(i,10)!==p)r(d);else{p=parseInt(i,10);try{if(!c&&a<0)return;var C={time:parseInt(i,10),level:parseInt(l,10),sessionId:n,type:s,tag:f,content:h.join(",")};d.push(C)}catch(e){console.error(e)}}},f=function(e){r(d),oe=!1,re()},n.getFullLog(a,i,s,!1,l,f)),[2]}))}))},ne=function(t){function n(o,r,n,i,s){void 0===s&&(s=!1);var a="Electron|"+process.versions.electron+"|"+process.arch+"|"+process.platform;return t.call(this,r,n,a,{getLogs:function(e,t,r,n){return E(this,void 0,void 0,(function(){return P(this,(function(i){switch(i.label){case 0:return[4,(s={startTime:e,endTime:t,level:r,realtimeReport:n,addon:o},E(void 0,void 0,void 0,(function(){return P(this,(function(e){return[2,new Promise((function(e){te.push({resolve:e,args:s}),re()}))]}))})))];case 1:return[2,{logs:i.sent(),dbReady:!0}]}var s}))}))},getTimestamp4RealtimeLog:function(){var t=o.getStoreValue(e.StoreKeys.REALTIME_LOG_TIMESTAMP);return parseInt(t,10)||0},setTimestamp4RealtimeLog:function(t){o.setStoreValue(e.StoreKeys.REALTIME_LOG_TIMESTAMP,t.toString())}},i,s)||this}return S(n,t),n.prototype.send=function(e){return z(this.logger,e)},n.prototype.stop=function(){this._subProcess&&this._subProcess.destroy(),t.prototype.stop.call(this)},n.prototype.compressLogs=function(e){return E(this,void 0,void 0,(function(){var t,n,i,s;return P(this,(function(a){switch(a.label){case 0:return this._subProcess||(t=o.fork(r.resolve(__dirname,"sub-process.js")),this._subProcess=new ee(t)),[4,this._subProcess.call("compressLogs",e)];case 1:return n=a.sent(),i=n.success,s=n.data,i?[2,{success:i,data:s.data}]:[2,{success:i,data:""}]}}))}))},n}(e.BasicReporter),ie=[e.EConnectProtocol.RMTP,e.EConnectProtocol.TLS,e.EConnectProtocol.QUIC],se=function(e){return"RongCloud/navis/"+e+"/navi-cache.json"},ae="deviceId",ce=function(e){return"RongCloud/caches/"+e+"/staticConfig.json"},ue=function(e){return"RongCloud/cloudControl/"+e+"/cloudControl.json"},pe=null,de=function(){var e,t=Date.now(),o=[n.arch(),n.platform(),process.pid,t,Math.floor(Math.random()*t)].join("__");return e=o,f.createHash("md5").update(e).digest("hex")},le=function(e){if(pe)return pe;var t=r.resolve(e,ae);return l.existsSync(t)?pe=l.readFileSync(t).toString():(pe=de(),l.writeFileSync(t,pe),pe)},fe=function(){function e(e){this._callCppProxy=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,o,r,n,i){var s=JSON.stringify(n);"{}"!==s&&e.info(y.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:r,ext:n})),this._callCppProxy("setMessageExtension",t,o,r,s,i)},e.prototype.setLocalFromReceiveMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,i=t.messageUId,s=t.expansion,a=t.sentTime;if(s&&0!==Object.keys(s).length){var c={};for(var u in s)c[u]={v:"",ts:0},c[u].v=s[u],c[u].ts=a;this._setToProtocol(e,r,n,i,c,o||"")}},e.prototype.setLocalFromExtMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,i=t.content,s=t.sentTime,a=i,c=a.put,u=this._callCppProxy("getMessage",a.mid),p=JSON.parse(u).extMsg,d=JSON.parse(p||"{}");if(c)for(var l in c){var f=d[l];f&&f.ts<s-this._setTime?(f.v=c[l],f.ts=s-this._setTime):(d[l]={v:"",ts:0},d[l].v=c[l],d[l].ts=s-this._setTime)}a.del&&a.del.forEach((function(e){delete d[e]})),this._setToProtocol(e,r,n,a.mid,d,o||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var r in t)o[r]=t[r].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),r={};for(var n in o)r[n]=o[n].v;return r},e}();function he(e){void 0===e&&(e="IPv4");for(var t=n.networkInterfaces(),o=[],r=0,i=Object.values(t);r<i.length;r++){var s=i[r];if(s&&-1!==Object.prototype.toString.call(s).indexOf("Array")){var a=s.filter((function(t){return!(t.internal||(o=t.mac,/^(0{1,2}[:-]){5}0{1,2}$/.test(o))||t.family&&t.family!==e);var o})).map((function(e){return e.mac}));o.push.apply(o,a)}}return o.length?T([],o,!0).sort()[0]:""}var Ce,ge=function(e,t,o){return E(void 0,void 0,void 0,(function(){var r,n;return P(this,(function(i){return r=f.createDecipheriv("aes-256-cbc",t,o),n=r.update(e,"base64","utf-8"),[2,n+=r.final("utf8")]}))}))},ve=function(e){if(!l.existsSync(e)){var t=r.resolve(e,"..");l.existsSync(t)||ve(t),l.mkdirSync(e)}},_e=function(e){return Object.entries(e).map((function(e){var t=e[0],o=e[1];return{key:t,value:String(o)}}))},Se=function(e){return{removeMute:!!(null==e?void 0:e.removeMuteStatus),removeWhiteList:!!(null==e?void 0:e.removeWhiteList),removeFavoriteMembers:!!(null==e?void 0:e.removeFollow)}},ye=function(t){function o(e,o,n,i,s){var a=t.call(this,e,o,n,s)||this;a.naviPath="",a._caches={},a.naviPath=i+"/"+se(e);var c=r.dirname(a.naviPath);return l.existsSync(c)||ve(c),a}return S(o,t),o.prototype.httpRequest=function(t,o,r,n){return E(this,void 0,void 0,(function(){var i,s,a,c,u;return P(this,(function(p){switch(p.label){case 0:return i="token="+encodeURIComponent(r)+"&v="+e.FORMATED_VERSION+"&p=PC&ev=5.12.2&m="+he(),s=t+"/navi.json?r="+Date.now()+"&env="+this._environment,this.logger.info(e.LogTagId.L_REQUEST_T,JSON.stringify({url:s,body:i}),n),[4,z(this.logger,{method:"POST",headers:{appId:o},body:i,url:s,timeout:e.NAVI_REQ_TIMEOUT})];case 1:if(200!==(a=p.sent()).status)return this.logger.warn(e.LogTagId.L_REQUEST_R,JSON.stringify({url:s,code:a.status}),n),[2,{code:this.transHttpCode(a.status)}];this.logger.info(e.LogTagId.L_REQUEST_R,JSON.stringify({url:s,data:a.data}),n);try{return c=JSON.parse(a.data),u=/^https/.test(s)?"https":"http",c.protocol=u,c.code&&200!==c.code?[2,{code:this.transHttpCode(c.code)}]:[2,{code:e.ErrorCode.SUCCESS,data:c}]}catch(t){return this.logger.error(e.LogTagId.L_PARSE_NAVI_E,a.data,n),[2,{code:e.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},o.prototype.httpRequestV2=function(t,o,r,n){return E(this,void 0,void 0,(function(){var i,s,a,c;return P(this,(function(u){switch(u.label){case 0:return i=this.getNaviV2RequestOption({appkey:o,token:r,uri:t,platform:"electron",protocol:ie.join(","),mac:he()}),this.logger.info(e.LogTagId.L_REQUEST_T,JSON.stringify({url:i.url,body:i.body,headers:i.headers}),n),[4,z(this.logger,i)];case 1:if(200!==(s=u.sent()).status)return this.logger.warn(e.LogTagId.L_REQUEST_R,JSON.stringify({url:i.url,code:s.status}),n),[2,{code:this.transHttpCode(s.status)}];this.logger.info(e.LogTagId.L_REQUEST_R,JSON.stringify({url:i.url,data:s.data}),n);try{return a=JSON.parse(s.data),c=/^https/.test(i.url)?"https":"http",a.protocol=c,[2,{code:e.ErrorCode.SUCCESS,data:a}]}catch(t){return this.logger.error(e.LogTagId.L_PARSE_NAVI_E,s.data,n),[2,{code:e.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},o.prototype.getNaviCache=function(t){var o=this.getCatchKey(t),r=this._caches[o];if(r)return r;if(!l.existsSync(this.naviPath))return null;var n=l.readFileSync(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(n),this._caches[o]}catch(t){this.logger.error(e.LogTagId.L_PARSE_NAVI_E,n)}return null},o.prototype.setNaviCache=function(t,o){var r=Date.now(),n=this.getCatchKey(t);if(e.notEmptyObject(this._caches))for(var i in this._caches){(r-this._caches[i].timestamp>e.NAVI_CACHE_DURATION||n===i)&&delete this._caches[i]}this._caches[n]={token:t,naviInfo:o,timestamp:Date.now(),environment:this._environment},l.writeFileSync(this.naviPath,JSON.stringify(this._caches))},o.prototype.setEnvironment=function(e){this._environment=e},o}(e.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"}(Ce||(Ce={}));var me,Ee=function(t){function o(o,r,n,i,s,a){var c=t.call(this,o,n,i,s,a)||this;return c.callCppProxy=r,c._connectedTime=0,c._naviInfo=null,c._excludeLogTag=["P-API_RCGetValueForKey-T","P-API_RCGetValueForKey-E","P-API_RCGetValueForKey-R","P-API_RCSetValueForKey-T","P-API_RCSetValueForKey-E","P-API_RCSetValueForKey-R"],c.connectResolve=null,c._startTime=0,c._tcpDuration=0,c.pingResolve=null,c.callCppProxy("setConnectionStatusListener",c._onConnectionStatusChange.bind(c),(function(e){c.logger.info(y.P_DB_OPEN_O,e)}),(function(){return c.recvPong(e.ErrorCode.SUCCESS)}),c._onConnectionStatusChange.bind(c),c._onTcpConnectResponse.bind(c),(function(){var e;c.logger.info(y.P_DB_UPGRATE_START_S),null===(e=a.onDBUpgrateStart)||void 0===e||e.call(a)}),(function(e){var t;c.logger.info(y.P_DB_UPGRATING_S,e),null===(t=a.onDBUpgrading)||void 0===t||t.call(a,e)}),(function(e){var t;c.logger.info(y.P_DB_UPGRATE_COMPLETE_S,e),null===(t=a.onDBUpgradeComplete)||void 0===t||t.call(a,e)})),c}return S(o,t),o.prototype.getConnectedTime=function(){return this._connectedTime},o.prototype.connectWithToken=function(t,o,r,n){var i=this;return new Promise((function(s){i._naviInfo=o,i.connectResolve={resolve:s,traceId:n,userId:o.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(m(m({},a),{call_plus:i._openCallPlus})),p=i.getCmpList(o,!0).filter((function(e){return ie.includes(e.protocol)})).sort((function(e,t){return e.weight>t.weight?-1:1})),d=[];p.forEach((function(t){var o=d.find((function(e){return e.addr===t.addr}));o?o.protocol!==e.EConnectProtocol.QUIC&&t.protocol!==e.EConnectProtocol.QUIC||(o.race=!0,o.protocol=e.EConnectProtocol.QUIC):(t.race=!1,d.push(t))})),i.logger.info(y.P_CONNECT_O,JSON.stringify({use:d,catche:i.cmpWeightCache,proxy:a,FORMATED_VERSION:e.FORMATED_VERSION,reconnectKickEnable:r}),n),i._startTime=Date.now();try{i.callCppProxy("connectWithToken",t,e.FORMATED_VERSION,JSON.stringify(m(m({},o),{serverAddr:d,tagBlacklist:i._excludeLogTag.join(",")})),r,u)}catch(t){i.logger.error(y.P_CALL_ADDON_E,null==t?void 0:t.stack,n),i.recvConnectRes(e.ErrorCode.RC_SOCKET_NOT_CREATED)}}))},o.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.callCppProxy("disconnect",t)},o.prototype.sendPing=function(t){var o=this;return new Promise((function(r){o.pingResolve=r,o.callCppProxy("sendHeartbeat"),setTimeout((function(){return o.recvPong(e.ErrorCode.TIMEOUT)}),t)}))},o.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},o.prototype._onConnectionStatusChange=function(t,o){switch(this.logger.info(y.P_CONNECT_S,JSON.stringify({status:t,delay:o})),t){case e.ErrorCode.SUCCESS:this.recvConnectRes(e.ErrorCode.SUCCESS);break;case e.ErrorCode.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(e.ErrorCode.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case e.ErrorCode.RC_SOCKET_DISCONNECTED:this.recvConnectRes(t,!1);break;case e.ErrorCode.RC_SOCKET_NOT_CREATED:case e.ErrorCode.RC_CONN_ACK_TIMEOUT:case e.ErrorCode.RC_TCP_RESET:this.recvConnectRes(t);break;case e.ErrorCode.RC_UDP_DISCONNECTED:this.recvConnectRes(t,!0,o);break;default:this.recvConnectRes(t,!0)}},o.prototype.recvConnectRes=function(t,o,r){if(this.connectResolve){var n=this.connectResolve,i=n.resolve,s=n.userId,a=Date.now()-(this._startTime+this._tcpDuration),c={bid:e.getbundleId(),cod:t,net:this.getNetwork().type,dur:a,spr:0,cid:this.uuid+"_"+this.retryCount,v:e.StatisticsVersion.CURRENT,count:this.retryCount};return this.statisticLog.record(e.StatisticsTag.IM_CMP_RMTP,JSON.stringify(c)),t===e.ErrorCode.SUCCESS&&(this._connectedTime=Date.now()-this.callCppProxy("getDeltaTime")),i({code:t,data:s}),void(this.connectResolve=null)}if(o)this.onDisconnectByServer(t,r);else{if(t===e.ErrorCode.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return;this.onDisconenctUnusual(t)}},o.prototype._onTcpConnectResponse=function(t,o,r,n,i,s,a){var c,u=this.cmpWeightCache.findIndex((function(e){return e.addr===o+":"+r})),p={bid:e.getbundleId(),ptc:e.ProtocalType.TCP,cod:t,net:this.getNetwork().type,dur:n,spr:0,pr:(null===(c=this._naviInfo)||void 0===c?void 0:c.type)||0,hos:o+":"+r,idx:u,rct:this.retryCount?e.ConnectType.RECONNECT:e.ConnectType.CONNECT,cid:this.uuid+"_"+this.retryCount,v:e.StatisticsVersion.CURRENT,rsn:this.reason,ddu:i,count:this.retryCount,weight:u>=0?this.cmpWeightCache[u].weight:-1};if(this.statisticLog.record(e.StatisticsTag.IM_CMP,JSON.stringify(p)),this.logger.info(y.P_CONNECT_ENTRY_S,JSON.stringify({code:t,host:o,port:r,duration:n,dnsDuration:i,index:s,isQuic:a})),t===Ce.SUCCESS)this.curCmpUrl=o+":"+r,this.updateCmpWeight(o+":"+r,!0,a);else if(t!==Ce.NOT_INIT){var d=r&&0!==r?o+":"+r:""+o;this.updateCmpWeight(d,!1)}},o}(e.AConnectionMgr),Pe=function(t){function o(e,o,n){var i=t.call(this,e,o)||this;i.appkey=e,i.logger=o,i.dbpath=n,i._cachePath="",i._cachePath=n+"/"+ce(e);var s=r.dirname(i._cachePath);return l.existsSync(s)||ve(s),i}return S(o,t),o.prototype.getCache=function(){return l.existsSync(this._cachePath)&&l.readFileSync(this._cachePath,{encoding:"utf8"})||null},o.prototype.setCache=function(e){l.writeFileSync(this._cachePath,e)},o.prototype.clearCache=function(){l.writeFileSync(this._cachePath,"")},o.prototype.sendRequest=function(e){return E(this,void 0,void 0,(function(){var t,o,r;return P(this,(function(n){switch(n.label){case 0:return[4,z(this.logger,{url:e,body:""})];case 1:return t=n.sent(),o=t.status,r=t.data,[2,{code:o,data:r}]}}))}))},o.prototype.decryptData=function(t){return E(this,void 0,void 0,(function(){var o,r;return P(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,ge(t,e.STATIC_CONFIG_KEY,e.STATIC_CONFIG_IV)];case 1:return o=n.sent(),[2,JSON.parse(o)];case 2:return r=n.sent(),this.logger.error(e.LogTagId.L_GET_STATIC_CONF_E,JSON.stringify({error:null==r?void 0:r.stack})),[3,3];case 3:return[2]}}))}))},o}(e.BasicStaticConfigManager),Te=function(t){function o(e,o,n,i,s,a,c){var u=t.call(this,o,e,n,a)||this;u.deviceId=i,u.model="",u.catchFilePath="",u.addon=c,u.model="Electron|"+process.platform+"|"+process.arch,u.catchFilePath=s+"/"+ue(e);var p=r.dirname(u.catchFilePath);return l.existsSync(p)||ve(p),u.init(),u}return S(o,t),o.prototype.httpRequest=function(t,o,r,n){return E(this,void 0,void 0,(function(){var i,s,a,c,u,p,d,l;return P(this,(function(f){switch(f.label){case 0:return(i=n).deviceId=this.deviceId,i.model=this.model,s={url:t,method:o,headers:r,body:JSON.stringify(i)},this.logger.info(e.LogTagId.L_REQUEST_T,JSON.stringify(s)),[4,z(this.logger,s)];case 1:a=f.sent(),c=a.status,u=a.data,p=void 0===u?"":u,this.logger.info(e.LogTagId.L_REQUEST_R,JSON.stringify({status:c,data:p}));try{return d=JSON.parse(p),l=d.data,[2,{code:c,data:l}]}catch(t){return this.logger.warn(e.LogTagId.L_CLOUD_CONFIG_DATA_E,JSON.stringify({status:c,data:p,error:t})),[2,{code:c,msg:t}]}return[2]}}))}))},o.prototype.setCloudControllerCache=function(t){l.writeFileSync(this.catchFilePath,JSON.stringify(t)),this.logger.info(e.LogTagId.L_CLOUD_SET_CACHE_O,JSON.stringify(t))},o.prototype.getLocalCloudControllerCache=function(){if(!l.existsSync(this.catchFilePath))return null;var t=l.readFileSync(this.catchFilePath,{encoding:"utf8"});return this.logger.info(e.LogTagId.L_CLOUD_GET_CACHE_O,JSON.stringify({appkey:this.appkey,data:t})),t},o.prototype.setMRTRConfig=function(t){var o={mrtrChatroom:t.chatroom,mrtrGroup:t.group,mrtrPrivate:t.private,mrtrUltraGroup:t.ultraGroup};this.logger.info(e.LogTagId.L_CLOUD_SET_MRTR_O,JSON.stringify(o)),this.addon.setCloudConfig(JSON.stringify(o))},o}(e.BaseCloudController);!function(e){e[e.cuid=1]="cuid",e[e.uid=2]="uid",e[e.all=4]="all"}(me||(me={}));var Ie,Re=function(){function t(t,o,r,n,i,s,a){var c=this;this._appkey=t,this._cppProtocol=o,this._dbpath=r,this._dispatchEvent=n,this._enableSyncEmptyTopConversation=i,this._logOutputLevel=s,this._customMessageType={},this.cloudControllerUri="",this.cloudControllerLock=!0,this.cloudControllerMsgs=[],this._buildSubscribeEventData=function(t){var o=[];try{JSON.parse(t).list.forEach((function(t){var r=JSON.parse(t.obj),n=r.userId,i=r.subscribeType,s=r.subscribeTime,a=r.duration,u=r.operationType,p=r.details,d=void 0===p?[]:p,l=r.userProfile,f={userId:n,subscribeType:i,subscribeTime:s,expiry:a,operationType:u};[e.SubscribeType.ONLINE_STATUS,e.SubscribeType.FRIEND_ONLINE_STATUS].includes(i)&&(f.details=d.map((function(e){var t=JSON.parse(e);return{changeTime:t.changeTime,eventValue:t.changeValue,platform:t.platform}}))),[e.SubscribeType.USER_PROFILE,e.SubscribeType.FRIEND_USER_PROFILE].includes(i)&&(f.userProfile=c._string2userProfileInfo(l)),o.push(f)}))}catch(e){c.logger.error(y.P_PARSE_JSON_SUBSCRIBE_DATA_E,JSON.stringify({error:null==e?void 0:e.stack,data:t}))}return o},this._chatroomCache=[],this.rtcHeartbeatResolves={};var u=this._dbpath,p=le(u);this.logger=new L(this._appkey,"RC-M","IM"),this._cppProtocol.initWithAppkey(t,u,e.FORMATED_VERSION,this.logger.getSessionId()),this._cppProtocol.setConsoleLogLevel((this._logOutputLevel||e.LogL.WARN)+1),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,t,p,this.logger,a),this.logger.info(y.P_INIT_O,JSON.stringify({appkey:t,dbpath:u,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:p,commit:"0ee6914ce81f879f025bd82bb70811af5c426be9",processName:process.title,processPId:process.pid,disableLogReport:a})),this._callCppProxy("setDeviceId",p),this._staticConfigManager=new Pe(t,this.logger,u),this.navi=new ye(t,this.logger,this.statisticLog,u,this._staticConfigManager),this.tcpMgr=new Ee(t,this._callCppProxy.bind(this),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),onDBUpgrateStart:this.dbUpgradeStart.bind(this),onDBUpgrading:this.dbUpgrading.bind(this),onDBUpgradeComplete:this.dbUpgradeComplete.bind(this)}),this._enableCreateEmptyTopConversation(this._enableSyncEmptyTopConversation),this._initCloudController(p,u),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setPushNotificationListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),this._setSubscribeEventListener(),this._setUserProfileListener(),this._setEntrustGroupListener(),this._setFriendEventListener(),this._msgExpansionHandler=new fe(this._callCppProxy.bind(this))}return t.prototype._initCloudController=function(t,o){var r=e.urlCenter.getCloudControllerUrl();this.cloudControllerUri=r[0],this.cloudController=new Te(this._appkey,this.logger,this.reporter,t,o,this.statisticLog,this._cppProtocol),e.isStartCloudController()&&this.cloudControllerUri&&this.cloudController.request(this.cloudControllerUri,e.InvokerType.init)},t.prototype.callProxy=function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return E(this,void 0,void 0,(function(){var r,n,i;return P(this,(function(s){switch(s.label){case 0:if(!(r=this[t]))return this.logger.warn(y.P_CALL_MAIN_E,JSON.stringify({method:t,error:"not found"})),[2,Promise.resolve({code:e.ErrorCode.NOT_SUPPORT})];n="",s.label=1;case 1:return s.trys.push([1,3,,4]),[4,r.call.apply(r,T([this],o,!1))];case 2:return[2,s.sent()];case 3:return i=s.sent(),n=JSON.stringify({error:null==i?void 0:i.stack,method:t}),this.logger.error(y.P_CALL_MAIN_E,n),[3,4];case 4:return[2,{code:e.ErrorCode.MAIN_PROCESS_ERROR,msg:n}]}}))}))},t.prototype.sendProxy=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return E(this,void 0,void 0,(function(){var o;return P(this,(function(r){if(!(o=this[e]))return this.logger.warn(y.P_CALL_MAIN_E,JSON.stringify({method:e,error:"not found"})),[2];try{o.call.apply(o,T([this],t,!1))}catch(t){this.logger.error(y.P_CALL_MAIN_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return[2]}))}))},t.prototype.registerRenderers=function(t){var o=t.navigators,r=t.areaCode,n=t.logServerUrl,i=t.environment;this._environment=i||"default",this.navi.setEnvironment(i),e.urlCenter.init({areaCode:r,navigators:o,logServerUrl:n})},t.prototype.onConnected=function(){return E(this,void 0,void 0,(function(){var e,t,o;return P(this,(function(r){switch(r.label){case 0:return e=this.getNaviInfoFromCache(),this.reporter.checkStart(e),this._try2RejoinChatroom(),t=this._dispatchEvent,o=["onConnected"],[4,this.getMainProcessCache()];case 1:return t.apply(this,o.concat([r.sent()])),[2]}}))}))},t.prototype.onConnecting=function(){this._dispatchEvent("onConnecting",void 0)},t.prototype.onSuspend=function(e){this._dispatchEvent("onSuspend",e)},t.prototype.onDisconnected=function(e){this._dispatchEvent("onDisconnected",e)},t.prototype.dbUpgradeStart=function(){this._dispatchEvent("databaseUpgradeWillStart")},t.prototype.dbUpgrading=function(e){this._dispatchEvent("databaseUpgrading",e)},t.prototype.dbUpgradeComplete=function(e){this._dispatchEvent("databaseUpgradeDidComplete",e)},t.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){throw this.logger.error(y.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),n),t}},t.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},t.prototype.sendHTTPRequest=function(e){return z(this.logger,e)},t.prototype.onRendererLogsReceived=function(e){M.apply(void 0,e)},t.prototype.onRendererNetworkStatusReceived=function(t,o){if(this.tcpMgr.setNetwork(t,o),t.status&&e.isStartCloudController()&&this.cloudController){var r=this.tcpMgr.getToken();this.cloudController.request(this.cloudControllerUri,e.InvokerType.newWorkChange,r)}},t.prototype.destroy=function(){this.reporter.stop(),this._cppProtocol,O(),this._cppProtocol.destroy(),process.exit(0)},t.prototype.callExtra=function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];var n=this[t];if(!n)return this.logger.warn(y.P_CALL_EXTRA_E,JSON.stringify({method:t,error:"not found"})),Promise.resolve({code:e.ErrorCode.NOT_SUPPORT});try{return n.call.apply(n,T([this],o,!1))}catch(e){this.logger.error(y.P_CALL_EXTRA_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})},t.prototype.getConversationsByPage=function(t,o,r,n,i){var s,a=this,c=this._callCppProxy("getConversationListByPageWithTopPriority",t,o,r,i||!1,n||"");try{s=JSON.parse(c).list.map((function(e){return a._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:s})},t.prototype.getUnreadConversationList=function(t){var o,r=this,n=this._callCppProxy("getUnreadConversationList",t);try{o=JSON.parse(n).list.map((function(e){return r._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:o})},t.prototype.getConversationListWithAllChannel=function(){var t,o=this,r=[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.APP_PUBLIC_SERVICE,e.ConversationType.PUBLIC_SERVICE],n=this._callCppProxy("getConversationListWithAllChannel",r);try{t=JSON.parse(n).list.map((function(e){return o._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})},t.prototype.getConversationListWithAllChannelByPage=function(t,o){var r,n=this,i=[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.APP_PUBLIC_SERVICE,e.ConversationType.PUBLIC_SERVICE],s=this._callCppProxy("getConversationListWithAllChannelByPage",i,t,o);try{r=JSON.parse(s).list.map((function(e){return n._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:r})},t.prototype.getHistoryMessagesByObjectNames=function(t,o,r,n,i,s,a){var c=0===s,u=n+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",t,o,r,u,i,c,a||""),d=[];try{var l=JSON.parse(p).list;l.reverse();for(var f=0;f<l.length;f++){var h=this._buildMessage(l[f].obj);d[f]=h}}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:{list:u===d.length?d.slice(1,u):d,hasMore:n<d.length}})},t.prototype.updateMessageReceiptStatus=function(t,o,r,n){void 0===n&&(n="");var i=this._callCppProxy("updateMessageReceiptStatus",t,o,r,n);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:i})},t.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},t.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new L(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.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),o=this.getNaviInfoFromCache(),r=this.tcpMgr.getCurrentUserId(),n=this.getDeviceId(),i=this._cppProtocol.getDeltaTime();return Promise.resolve({connectedTime:e,deviceId:n,crtUserId:r,naviInfo:o,connectionStatus:t,deltaTime:i})},t.prototype._enableCreateEmptyTopConversation=function(e){this._callCppProxy("enableCreateEmptyTopConversation",e)},t.prototype._registerMsgTypes=function(){for(var t in e.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},e.SEND_MESSAGE_TYPE_OPTION){var o=e.SEND_MESSAGE_TYPE_OPTION[t],r=o.isCounted,n=o.isPersited,i=o.searchProps,s=0;n&&(s|=1),r&&(s|=2),"RC:TypSts"===t&&(s=16),this._callCppProxy("registerMessageType",t,s,i||[])}},t.prototype._buildIsMentioned=function(t,o){var r,n=!1;if(e.isObject(t))r=t;else try{r=t?JSON.parse(t):t}catch(e){r=t,this.logger.error(y.P_PARSE_JSON_MSGS_E,JSON.stringify({content:t}))}return e.isObject(r)&&(n=!!r.mentionedInfo),{isMentioned:n,msgContent:r}},t.prototype._buildMsgOption=function(t){var o={isCounted:!1,isPersited:!1};return t in e.SEND_MESSAGE_TYPE_OPTION?o=e.SEND_MESSAGE_TYPE_OPTION[t]:t in this._customMessageType&&(o=this._customMessageType[t]),o},t.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},t.prototype._handleReadReceiptRequest=function(e){var t=JSON.parse(e),o=this.getNaviInfoFromCache();if(!(null==o?void 0:o.grpRRVer))return t;var r=t,n=r.hasRespond,i=r.readerInfo,s=void 0===i?{}:i,a=r.readCount,c=r.totalCount,u=r.readerList,p=void 0===u?[]:u,d={readCount:a,totalCount:c};if(1===(null==o?void 0:o.grpRRVer)){var l=[];for(var f in s)l.push({userId:f,readTime:s[f]});d.readerList=l,d.hasRespond=n}return 3===(null==o?void 0:o.grpRRVer)&&(d.readerList=p),d},t.prototype._buildMessage=function(t,o){var r;void 0===o&&(o={});var n=o.isOffLineMessage,i=o.buildFrom,s=JSON.parse(t),a=s.channelId,c=s.conversationType,u=s.targetId,p=s.senderUserId,d=s.content,l=s.objectName,f=s.messageUid,h=s.direction,C=s.status,g=s.messageId,v=s.sentTime,_=s.readReceiptRequest,S=s.supportExt,y=s.pushContent,E=s.pushTitle,P=s.pushId,T=s.pushConfig,I=s.templateId,R=s.disableTitle,O=s.forcePushDetail,N=s.hasMore,M=s.directedUsers,b=s.noNotification,U=s.disableUpdateLastMessage,x=this._buildIsMentioned(d,g),L=x.isMentioned,w=x.msgContent,A=this._buildMsgOption(l),k=this._buildSupportExt(S,i,s),D=e.isUndefined(n)?v<this.tcpMgr.getConnectedTime():n,J={};T&&(J=e.pushJSONToConfigs(this.logger,T,P));var G=m(m({},J),{pushTitle:E,pushContent:y,pushData:y,disablePushTitle:R,forceShowDetailContent:O,templateId:I}),F={channelId:a,conversationType:c,targetId:u,senderUserId:p,content:w||{},messageType:l,messageUId:f||"",messageDirection:h,isOffLineMessage:D,sentTime:v,receivedTime:0,isPersited:A.isPersited,isCounted:A.isCounted,isMentioned:L,disableNotification:b,isStatusMessage:(null===(r=this._customMessageType[l])||void 0===r?void 0:r.isStatusMessage)||!1,canIncludeExpansion:S,expansion:S?k:null,receivedStatus:C,receivedStatusInfo:e.transformReceivedStatusInfo(C),messageId:g,pushConfig:G,hasMore:N,directedUserIds:M||[],disableUpdateLastMessage:U};if(h===e.MessageDirection.RECEIVE?F.receivedStatus=this._compatibleReceivedStatus(F.receivedStatusInfo):h===e.MessageDirection.SEND&&(F.sentStatus=C),_){var B=this._handleReadReceiptRequest(_);F.readReceiptInfo=B}return F},t.prototype._compatibleReceivedStatus=function(t){var o=e.ReceivedStatus.UNREAD;return t.isRead?o=e.ReceivedStatus.READ:t.isListened?o=e.ReceivedStatus.LISTENED:t.isDownload?o=e.ReceivedStatus.DOWNLOADED:t.isRetrieved&&(o=e.ReceivedStatus.RETRIEVED),o},t.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),r=JSON.parse(o),n=r.readReceiptRequest?JSON.parse(r.readReceiptRequest):{},i=m(m({},n),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(i))},t.prototype._processRRRspMsg=function(e,t,o){if(t!==this.getCurrentUserId())for(var r=0,n=e[this.getCurrentUserId()]||[];r<n.length;r++){h=n[r];var i=this._callCppProxy("getMessage",h),s=JSON.parse(i),a=s.readReceiptRequest?JSON.parse(s.readReceiptRequest):{},c=a.isReceiptRequestMessage,u=a.readerList,p=void 0===u?[]:u;c&&!p.includes(t)&&(p.push(t),this._callCppProxy("updateReadReceiptRequestInfo",h,JSON.stringify({isReceiptRequestMessage:c,readerList:p})))}else for(var d in e)for(var l=0,f=e[d];l<f.length;l++){var h=f[l];this._callCppProxy("updateReadReceiptRequestInfo",h,JSON.stringify({isReceiptRequestMessage:!0,hasRespond:!0}))}},t.prototype._processRSMsg=function(t){var o=t.conversationType,r=t.targetId,n=t.content,i=t.channelId,s=n.msgId,a=n.rrn,c=n.tmn,u=n.endMsgTime;o===e.ConversationType.PRIVATE?this.updateMessageReceiptStatus(o,r,u,i||""):this._updateReadReceiptInfo(s,{readCount:a,totalCount:c});var p={conversationType:o,targetId:r,channelId:i};this._sendMessageReadReceipt(o===e.ConversationType.PRIVATE?{privateReadReceipt:m(m({},p),{endMsgTime:n.endMsgTime})}:{groupReadReceipt:m(m({},p),{totalCount:n.tmn,readedCount:n.rrn,messageUId:n.msgId})})},t.prototype._processSRSMsg=function(e){var t=this.getNaviInfoFromCache(),o=e.conversationType,r=e.targetId,n=e.content,i=e.channelId,s=e.senderUserId,a=e.sentTime;return s===this.tcpMgr.getCurrentUserId()&&(this._callCppProxy("clearUnreadCountByTimestamp",o,r,n.lastMessageSendTime,i||""),1!==(null==t?void 0:t.sesDriven)||(a>this.tcpMgr.getConnectedTime()||this._sendsyncReadStatus({conversationType:o,targetId:r,channelId:i,timestamp:n.lastMessageSendTime}),!1))},t.prototype._buildConversation=function(t){var o=JSON.parse(t),r=o.channelId,n=o.conversationType,i=o.targetId,s=o.unreadCount,a=o.lastestMsg,c=o.isTop,u=o.blockStatus,p=o.matchCount,d=o.hasUnreadMention,l=o.conversationTime,f=o.draft,h=u>0?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE;return{channelId:r,conversationType:n,targetId:i,unreadMessageCount:s,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:d,mentionedInfo:null,notificationStatus:h,isTop:c,lastUnreadTime:0,matchCount:p,operationTime:l,notificationLevel:u,draft:f}},t.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}))},t.prototype._handleNotNotificationMessage=function(t){var o,r=t.messageType,n=t.senderUserId,i=t.content;if(r===e.MessageType.LOG_COMMAND&&t.senderUserId===e.RC_DEFAULT_USER){var s=t.content,a=s.startTime,c=s.endTime,u=s.platform,p=s.logId,d=s.uri;return this.reporter.report(parseInt(a,10),parseInt(c,10),u,d,p,t.messageUId),!0}if(r===e.MessageType.CLOUD_CONTROL&&n===e.RC_DEFAULT_USER)return this.cloudControllerMsgs.push(t),this._ccMsgHandler(),!0;if(r===e.MessageType.READ_STATE)return this._processRSMsg(t),!0;if("RC:MsgExMsg"===r)return this._msgExpansionHandler.setLocalFromExtMsg(this.logger,t),this._sendMessageExpansion(t),!0;if(r===e.MessageType.SYNC_READ_STATUS&&!this._processSRSMsg(t))return!0;if(r===e.MessageType.DELIVERED)return this._callCppProxy("setMessageDeliverTime",JSON.stringify(i)),this._sendMessageDelivered(t.content.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}}))),!0;if(r===e.MessageType.DELIVERED_MSG){var l={totalCount:t.content.tmn,list:null===(o=t.content.dl)||void 0===o?void 0:o.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};return this._sendGroupMessageDeliveredStatus(l),!0}return!1},t.prototype._setOnReceiveMessageListener=function(){var t=this;this._cppProtocol.setOnReceiveMessageListener((function(o,r,n,i){try{var s=t._buildMessage(o,{isOffLineMessage:n}),a=s.messageType,c=s.channelId,u=void 0===c?"":c,p=s.senderUserId,d=s.content,l=s.sentTime,f=s.conversationType,h=s.targetId;if(t._handleNotNotificationMessage(s))return;if(a===e.MessageType.READ_RECEIPT_REQUEST&&d.messageUId&&t._updateReadReceiptInfo(d.messageUId,{isReceiptRequestMessage:!0,hasRespond:!1}),a===e.MessageType.READ_RECEIPT_RESPONSE&&d.receiptMessageDic&&t._processRRRspMsg(d.receiptMessageDic,p,l),a===e.MessageType.GROUP_READ_RECEIPT_REQUEST){var C=d.msgId,g=d.rrn,v=d.tmn;t._updateReadReceiptInfo(C,{readCount:g,totalCount:v})}s.canIncludeExpansion&&t._msgExpansionHandler.setLocalFromReceiveMsg(t.logger,s),a===e.MessageType.READ_RECEIPT&&p===t.tcpMgr.getCurrentUserId()&&t._callCppProxy("clearUnreadCountByTimestamp",f,h,d.lastMessageSendTime,u);var _=!0;if(0!==r||i||(_=!1),a===e.MessageType.RECALL){if(!t.handleRecalledMessage(s))return;var S=t._fixRecallContentInfo(s);f=S.conversationType,h=S.targetId}t._sendMessageNotification(Object.assign(s,{hasMoreMsg:_,conversationType:f,targetId:h}))}catch(e){t.logger.error(y.P_RECEIVE_MESSAGE_E,JSON.stringify({error:null==e?void 0:e.stack,message:o}))}}),(function(){t._sendPullOfflineFinished()}))},t.prototype._ccMsgHandler=function(){var t;return E(this,void 0,void 0,(function(){var o,r;return P(this,(function(n){switch(n.label){case 0:return this.cloudControllerLock?(this.cloudControllerLock=!1,this.cloudControllerMsgs.shift()?(o=this.tcpMgr.getToken(),[4,null===(t=this.cloudController)||void 0===t?void 0:t.request(this.cloudControllerUri,e.InvokerType.other,o)]):[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]}}))}))},t.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}},t.prototype.handleRecalledMessage=function(t){var o=t.content,r=o.messageUId,n=o.sentTime;if(!r)return!0;var i=this._callCppProxy("getMessage",r),s=this._buildMessage(i,{isOffLineMessage:!1});if(t.content.isDelete)return-1===s.messageId||this._callCppProxy("deleteMessages",[s.messageId]),!0;if(s.messageType===e.MessageType.RECALL_NOTIFICATION_MESSAGE)return!1;var a={recallTime:Date.now(),admin:!!t.content.isAdmin,originalObjectName:s.messageType,originalMessageContent:s.content,recallActionTime:t.sentTime,operatorId:t.senderUserId};if(t.content.user&&(a.user=t.content.user),t.content.extra&&(a.extra=t.content.extra),s.messageType===e.MessageType.TextMessage&&(a.recallContent=s.content.content),-1===s.messageId){var c=t.conversationType,u=t.targetId,p=t.senderUserId,d=t.channelId,l=t.messageDirection;return this._callCppProxy("insertMessage",c,u,p,e.MessageType.RECALL_NOTIFICATION_MESSAGE,JSON.stringify(a),(function(){}),(function(){}),l,1,30,n,"",0,r,!1,!0,JSON.stringify({}),d||""),!0}return s.receivedStatus||this.setMessageReceivedStatus(s.messageId,1),this._callCppProxy("setMessageContent",s.messageId,JSON.stringify(a),e.MessageType.RECALL_NOTIFICATION_MESSAGE),!0},t.prototype._sendMessageExpansion=function(e){var t=e.channelId,o=void 0===t?"":t,r=e.content,n=e.conversationType,i=e.targetId,s=r,a=s.put,c=s.del,u=s.mid,p={};a&&(p.updatedExpansion={channelId:o,messageUId:u,expansion:a,conversationType:n,targetId:i}),c&&(p.deletedExpansion={channelId:o,messageUId:u,deletedKeys:c,conversationType:n,targetId:i}),this._dispatchEvent("expansion",p)},t.prototype._sendMessageNotification=function(e){this._dispatchEvent("batchMessage",e)},t.prototype._sendPullOfflineFinished=function(){this._dispatchEvent("pullFinished",null)},t.prototype._sendMessageDelivered=function(e){this._dispatchEvent("messageDelivered",e)},t.prototype._sendGroupMessageDeliveredStatus=function(e){this._dispatchEvent("groupMessageDeliveredStatus",e)},t.prototype._sendChatroomStatus=function(e){this._dispatchEvent("chatroom",e)},t.prototype._sendMessageReadReceipt=function(e){this._dispatchEvent("messageReadReceipt",e)},t.prototype._sendsyncReadStatus=function(e){this._dispatchEvent("syncReadStatus",e)},t.prototype._setConversationStatusListener=function(){var t=this;this._cppProtocol.setConversationStatusListener((function(o){var r=JSON.parse(o).list,n=[];r.forEach((function(t){var o=JSON.parse(t.obj),r=o.conversationType,i=o.targetId,s=o.status,a=o.channelId,c={notificationStatus:2,isTop:!1};s.forEach((function(t){var o=JSON.parse(t.item);1===o.type?c.notificationStatus=1===Number(o.value)?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE:c.isTop=1===Number(o.value)})),n.push({channelId:a,conversationType:r,targetId:i,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),t._dispatchEvent("conversation",n)}),(function(e){t._dispatchEvent("conversationTag",e)}),(function(e,o,r,n){t._callCppProxy("clearUnreadCountByTimestamp",e,o,n,r||""),t._sendsyncReadStatus({conversationType:e,targetId:o,channelId:r,timestamp:n})}))},t.prototype._setPushNotificationListener=function(){var e=this;this._cppProtocol.setPushNotificationListener((function(){}),(function(t){e._dispatchEvent("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 o=this.navi.getNaviInfoFromCache(t);this._dispatchEvent("onNaviDataChange",o)}},t.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){e._dispatchEvent("onRTCDataChange",Array.prototype.slice.call(t))}))},t.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._sendChatroomStatus({chatroomDestroyed:t})}))},t.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){var o=[];try{JSON.parse(t).list.forEach((function(e){Object.entries(e).forEach((function(e){var t=e[0],r=e[1];o.push({key:t,value:r})}))}))}catch(t){e.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:t}))}e._dispatchEvent("callInfo",JSON.stringify({list:o}))}))},t.prototype._setSubscribeEventListener=function(){var t=this;this._cppProtocol.setSubscribeEventListener((function(){}),(function(e){t._dispatchEvent("syncSubscribedUserStatusFinished",e)}),(function(e){var o=t._buildSubscribeEventData(e).map((function(e){return{userId:e.userId,subscribeType:e.subscribeType,subscribeTime:e.subscribeTime,expiry:e.expiry,operationType:e.operationType}}));t._dispatchEvent("subscribedRelationChange",o)}),(function(o){var r=t._buildSubscribeEventData(o).map((function(t){var o=t.userId,r=t.subscribeType,n=t.subscribeTime,i=t.expiry,s=t.details,a=t.userProfile,c={userId:o,subscribeType:r,subscribeTime:n,expiry:i};return[e.SubscribeType.ONLINE_STATUS,e.SubscribeType.FRIEND_ONLINE_STATUS].includes(r)?c.details=s:[e.SubscribeType.USER_PROFILE,e.SubscribeType.FRIEND_USER_PROFILE].includes(r)&&(c.userProfile=a),c}));t._dispatchEvent("subscribedUserStatusChange",r)}))},t.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(t){e._dispatchEvent("syncSubscribedUserStatusFinished",t)}),(function(t){e._dispatchEvent("ownUserProfileChanged",e._string2userProfileInfo(t))}))},t.prototype._onGroupOperationChanged=function(e,t,o,r,n){var i,s,a=[];try{i=JSON.parse(r),a=JSON.parse(n),s=JSON.parse(e);var c={groupId:i[0]?i[0].groupId:"",operatorInfo:this._convertGroupMemberInfoList([s])[0],operation:t,operationTime:o};0===t?c.groupInfo=this._convertGroupInfoList(i)[0]:c.memberInfos=this._convertGroupMemberInfoList(a),this._dispatchEvent("groupOperation",c)}catch(t){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:t,groupInfoJson:r,membersJson:n,operatorInfo:e}))}},t.prototype._onGroupInfoChanged=function(t,o,r,n,i){try{var s=JSON.parse(r),a=JSON.parse(n);switch(t){case e.GroupInfoChangeSubChangeType.GROUP_INFO_CHANGE:this._dispatchEvent("groupInfoChanged",{operatorInfo:this._convertGroupMemberInfoList([s])[0],operationTime:i,groupInfo:this._convertUpdateGroupInfoList(a)[0]});break;case e.GroupInfoChangeSubChangeType.GROUP_REMARK_DELETE:case e.GroupInfoChangeSubChangeType.GROUP_REMARK_SET:var c=t===e.GroupInfoChangeSubChangeType.GROUP_REMARK_SET?e.GroupOperationType.ADD:e.GroupOperationType.REMOVE;this._dispatchEvent("groupRemarkChangedSync",{groupId:o,operationType:c,operationTime:i,groupRemark:a[0]?a[0].remark:""})}}catch(e){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:e,groupInfoJson:n,operatorInfoJson:r}))}},t.prototype._onGroupMemberInfoChanged=function(e,t,o,r){try{var n=JSON.parse(t),i=JSON.parse(o),s={groupId:e,operatorInfo:this._convertGroupMemberInfoList([n])[0],memberInfo:this._convertGroupMemberInfoList([i])[0],operationTime:r};this._dispatchEvent("groupMemberInfoChanged",s)}catch(e){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:e,operatorInfoJson:t,updateMemberInfoJson:o}))}},t.prototype._onGroupRequestChanged=function(e,t,o,r){try{var n=JSON.parse(o),i=n.groupId,s=n.joinUser,a=n.approverUser,c=n.inviterUser,u=n.type,p=n.status,d=n.direction,l=n.remark,f=m(m(m(m({groupId:i},s&&{joinMemberInfo:this._convertGroupMemberInfoList([s])[0]}),c&&c.userId&&{inviterInfo:this._convertGroupMemberInfoList([c])[0]}),a&&a.userId&&{operatorInfo:this._convertGroupMemberInfoList([a])[0]}),{status:p,direction:d,type:u,operationTime:r,reason:l});this._dispatchEvent("groupApplicationEvent",f)}catch(e){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:e,groupInfo:t,requestInfoJson:o}))}},t.prototype._onFavoriteMembersChanged=function(t,o,r,n){try{var i=JSON.parse(r),s=[];i&&e.isArray(i.list)&&(s=i.list.map((function(e){return e.value}))),this._dispatchEvent("groupFollowsChangedSync",{groupId:t,operationType:o,operationTime:n,userIds:s})}catch(e){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:e,memberIds:r}))}},t.prototype._setEntrustGroupListener=function(){this._cppProtocol.setEntrustGroupListener(this._onGroupOperationChanged.bind(this),this._onGroupInfoChanged.bind(this),this._onGroupMemberInfoChanged.bind(this),this._onGroupRequestChanged.bind(this),this._onFavoriteMembersChanged.bind(this))},t.prototype._onFriendApplicationStatusChanged=function(e,t,o,r,n,i){this._dispatchEvent("friendApplicationStatusChanged",{userId:e,applicationType:t,applicationStatus:o,directionType:r,operationTime:n,extra:null!=i?i:""})},t.prototype._onFriendAdd=function(e,t,o,r,n){this._dispatchEvent("friendAdd",{userId:t,name:o,portraitUri:r,directionType:e,operationTime:n})},t.prototype._onFriendDelete=function(e,t,o){this._dispatchEvent("friendDelete",{userIds:t,directionType:e,operationTime:o})},t.prototype._onFriendsClearedFromServer=function(e){this._dispatchEvent("friendCleared",e)},t.prototype._onFriendInfoChangedSync=function(e,t,o){try{var r=JSON.parse(o);this._dispatchEvent("friendInfoChangedSync",{userId:e,remark:t,extProfile:r.list})}catch(e){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:e,profiles:o}))}},t.prototype._setFriendEventListener=function(){this._cppProtocol.setFriendEventListener(this._onFriendApplicationStatusChanged.bind(this),this._onFriendAdd.bind(this),this._onFriendDelete.bind(this),this._onFriendsClearedFromServer.bind(this),this._onFriendInfoChangedSync.bind(this))},t.prototype.registerMessageType=function(e,t,o,r,n){var i=0;t&&(i|=1),o&&(i|=2),n&&(i=16),this._customMessageType[e]={isCounted:o,isPersited:t,isStatusMessage:n},this.logger.info(y.P_REGTYP_O,JSON.stringify({type:e,opt:i,search:r})),this._callCppProxy("registerMessageType",e,i,r||[])},t.prototype.connect=function(e,t,o,r){return this.tcpMgr.connect(e,t,o,r)},t.prototype.reconnect=function(t,o,r){var n=e.ErrorCode.RC_SOCKET_DISCONNECTED;return this.tcpMgr.reconnect(t,o,r,n)},t.prototype.reportSDKInfo=function(e){var t=JSON.stringify(m(m({},e),{"electron-main":"5.12.2"}));this.logger.info(y.P_REPORT_VER_O,t),this._callCppProxy("uploadSDKVersion",t,"")},t.prototype.disconnect=function(e){e=e||!0,this._chatroomCache.length=0,this.reporter.stop(),$(null,this.logger),this.tcpMgr.disconnect(e)},t.prototype.logout=function(){this.disconnect()},t.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)},t.prototype.subscribeUserStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("subscribeUserStatus",t,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.setUserStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("setUserStatus",t,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.getUserStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("getUserStatus",t,(function(t){setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:{status:t}})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype._handleDirectionalUserIdList=function(t,o){var r=t.messageType,n=t.content,i=t.directionalUserIdList,s=void 0===i?[]:i,a=o===e.ConversationType.GROUP;if(r===e.MessageType.READ_RECEIPT_RESPONSE&&n.receiptMessageDic&&a)for(var c in n.receiptMessageDic)s.push(c);return r===e.MessageType.SYNC_READ_STATUS&&e.isSupportDirectMessage(o)&&(s=[this.getCurrentUserId()]),s},t.prototype._handleMessage2Callback=function(t,o){var r=this;if("RC:MsgExMsg"===t.messageType&&this._msgExpansionHandler.setLocalFromExtMsg(this.logger,t),t.messageType===e.MessageType.READ_RECEIPT_REQUEST)this._updateReadReceiptInfo(o.content.messageUId,{isReceiptRequestMessage:!0,readerList:[]});else if(t.messageType===e.MessageType.READ_RECEIPT_RESPONSE){var n=o.content.receiptMessageDic;if(!n)return;for(var i in n)n[i].forEach((function(e){r._updateReadReceiptInfo(e,{isReceiptRequestMessage:!0,hasRespond:!0})}))}},t.prototype.sendMessage=function(t,o,r,n,i){var s=this;void 0===i&&(i=this.logger.createTraceId());var a=r.messageType,c=r.content,u=r.expansion,p=r.pushConfig,d=r.pushContent,l=void 0===d?"":d,f=r.pushData,h=void 0===f?"":f,C=r.directionalUserIdList,g=void 0===C?[]:C,v=r.disableNotification,_=void 0!==v&&v,S=r.canIncludeExpansion,m=void 0!==S&&S,E=r.isVoipPush,P=void 0!==E&&E,T=r.channelId,I=void 0===T?"":T,R=r.messageId,O=void 0===R?0:R,N=r.disableUpdateLastMessage,M=void 0!==N&&N,b=p||{},U=b.iOSConfig,x=b.androidConfig,L=b.harmonyOSConfig,w=b.templateId,A=void 0===w?"":w,k=b.pushTitle,D=void 0===k?"":k,J=b.pushContent,G=void 0===J?l:J,F=b.pushData,B=void 0===F?h:F,j=b.disablePushTitle,V=void 0!==j&&j,q=b.forceShowDetailContent,H=void 0!==q&&q,K=e.pushConfigsToJSON(U,x,L);return new Promise((function(p){l=G,h=B;var d=(null==x?void 0:x.notificationId)||"";g=s._handleDirectionalUserIdList(r,t);var f={};for(var C in u)f[C]={v:""},f[C].v=u[C];var v=A;s.logger.info(y.P_SEND_MSG_T,JSON.stringify({messageType:a,conversationType:t,targetId:o,channelId:I}),i);var S=s._callCppProxy("sendMessage",(function(t,o){var n=s._buildMessage(t,{isOffLineMessage:!1});if(s.logger.info(y.P_SEND_MSG_R,JSON.stringify({code:o,messageUId:n.messageUId}),i),o===e.ErrorCode.SENSITIVE_REPLACE)return setTimeout((function(){p({code:o})}),0);[e.MessageType.READ_RECEIPT_REQUEST,e.MessageType.READ_RECEIPT_RESPONSE,e.MessageType.EXPANSION_NOTIFY].findIndex((function(e){return e===n.messageType}))>-1&&s._handleMessage2Callback(n,r),n.canIncludeExpansion&&s._msgExpansionHandler.setLocalFromReceiveMsg(s.logger,n),setTimeout((function(){p({code:e.ErrorCode.SUCCESS,data:n})}),0)}),(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});s.logger.warn(y.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),i),o.sentTime=Date.now()-s._cppProtocol.getDeltaTime(),setTimeout((function(){p({code:t,data:o})}),0)}),t,o,a,JSON.stringify(c),g,_,V,H,l,h,d,D,K,v,m,JSON.stringify(f),P,I,O,M),E=JSON.parse(S);null==n||n(E.messageId)}))},t.prototype.recallMsg=function(t,o,r,n,i){var s=this;return new Promise((function(a){var c,u=i.user,p=i.pushContent,d=i.channelId,l=i.extra,f=i.pushConfig,h=i.disableNotification,C=i.isDelete,g=i.directionalUserIdList,v=i.disableUpdateLastMessage,_={conversationType:t,targetId:o,messageUId:r,sentTime:n,user:u,extra:l,channelId:d,isDelete:C||!1};u&&(_.user=u),l&&(_.extra=l);var S={conversationType:t,targetId:o,senderUserId:s.tcpMgr.getCurrentUserId(),content:_,objectName:e.MessageType.RECALL,messageUid:r,direction:e.MessageDirection.SEND,status:e.ReceivedStatus.UNREAD,sentTime:n,channelId:d},y=s._buildMessage(JSON.stringify(S),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){s.handleRecalledMessage(y),y.pushConfig=f,setTimeout((function(){a({code:e.ErrorCode.SUCCESS,data:y})}),0)}),(function(e){setTimeout((function(){a({code:e})}),0)}),e.MessageType.RECALL,JSON.stringify(_),h||!1,(null==f?void 0:f.disablePushTitle)||!1,(null==f?void 0:f.forceShowDetailContent)||!1,p||"",(null==f?void 0:f.pushData)||"",(null===(c=null==f?void 0:f.androidConfig)||void 0===c?void 0:c.notificationId)||"",(null==f?void 0:f.pushTitle)||"",e.pushConfigsToJSON(null==f?void 0:f.iOSConfig,null==f?void 0:f.androidConfig,null==f?void 0:f.harmonyOSConfig),(null==f?void 0:f.templateId)||"",d,g||[],r,null!=v&&v)}))},t.prototype.getHistoryMessage=function(t,o,r,n,i,s,a){var c=this;return new Promise((function(u){r=r||0;var p=0===i,d=n+1,l=c._callCppProxy("getHistoryMessages",t,o,r,d,a,p,s),f=JSON.parse(l).list,h=[];f.reverse();for(var C=0;C<f.length;C++){var g=c._buildMessage(f[C].obj);h[C]=g}u({code:e.ErrorCode.SUCCESS,data:{list:d===h.length?h.slice(1,d):h,hasMore:n<h.length}})}))},t.prototype.getMessages=function(t,o,r,n,i,s){var a=this;return new Promise((function(c){var u=0===i,p=r,d=0!==r,l=n+1;d&&(p+=u?1:-1,l++);for(var f=a._callCppProxy("getMessages",t,o,p,l,u,s),h=JSON.parse(f).list,C=[],g=0;g<h.length;g++){var v=a._buildMessage(h[g].obj);C[g]=v}var _=a._computeRepairInfo(C,u,r,p,l),S=_.isNeedRepair,y=void 0!==S&&S,m=_.repairTime,E=void 0===m?0:m;if(!y)return d&&(C.shift(),l--),C.reverse(),void c({code:e.ErrorCode.SUCCESS,data:{list:l===C.length?C.slice(1,l):C,hasMore:n<C.length}});a._processRepairHisMsg(t,o,r,n,i,s,E,c)}))},t.prototype._computeRepairInfo=function(e,t,o,r,n){var i=!1,s=0,a=this.getNaviInfoFromCache()||{},c=a.repairHisMsg,u=void 0===c?0:c,p=a.historyMsg;if(1!==u||!p)return{isNeedRepair:i,repairTime:s};var d=e.findIndex((function(e){return e.hasMore||0===Object.keys(e.content).length}));return t&&d>=0?(i=!0,s=e[d].hasMore?e[d].sentTime:e[d].sentTime+1):!t&&d>=1?(i=!0,s=e[d-1].sentTime):e.length<n||0===o?(i=!0,s=o):e.length>0&&e[0].sentTime!==o&&(i=!0,s=r),{isNeedRepair:i,repairTime:s}},t.prototype._processRepairHisMsg=function(e,t,o,r,n,i,s,a){var c=this,u=function(s){for(var u=0===n,p=r+1,d=c._callCppProxy("getMessages",e,t,o,p,u,i),l=JSON.parse(d).list,f=[],h=0;h<l.length;h++){var C=c._buildMessage(l[h].obj);f[h]=C}f.reverse(),a({code:s,data:{list:p<=f.length?f.slice(1,p):f,hasMore:r<f.length}})},p=r+10>100?100:r+10;this._callCppProxy("getRemoteHistoryMessages",e,t,s,p,(function(){return u(0)}),(function(e){u(e)}),n,!0,i,!1)},t.prototype.getContinuousMessages=function(t,o,r,n,i,s){var a=this;return new Promise((function(c){r=r||0;var u=0===i;a._callCppProxy("getContinuousMessages",t,o,r,n,(function(t,o,r){var n=JSON.parse(t).list,i=[];n.reverse();for(var s=0;s<n.length;s++){var u=a._buildMessage(n[s].obj);i[s]=u}setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{list:i,timestamp:o,hasMore:r}})}))}),(function(e){setTimeout((function(){c({code:e})}),0)}),u,s)}))},t.prototype.getRemoteHistoryMessages=function(t,o,r,n,i,s){var a=this;return new Promise((function(c){r=r||0;a._callCppProxy("getRemoteHistoryMessages",t,o,r,n,(function(t,o){var r=JSON.parse(t).list,n=[];r.reverse();for(var i=0;i<r.length;i++){var s=a._buildMessage(r[i].obj);n[i]=s}setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{list:n,hasMore:!!o}})}),0)}),(function(e){setTimeout((function(){c({code:e})}),0)}),i,!0,s,!0)}))},t.prototype.deleteRemoteMessage=function(t,o,r,n){var i=this;return new Promise((function(s){var a=JSON.stringify(r);i._callCppProxy("deleteRemoteHistoryMessages",t,o,a,!1,n,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),s)}))},t.prototype.deleteRemoteMessageByTimestamp=function(t,o,r,n){var i=this;return new Promise((function(s){i._callCppProxy("clearRemoteHistoryMessages",t,o,r,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){s(e)}),0)}),n)}))},t.prototype.clearMessages=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("clearMessages",t,o,r),i(e.ErrorCode.SUCCESS)}))},t.prototype.getConversationList=function(t,o,r,n,i){var s=this;return void 0===i&&(i=""),new Promise((function(t){for(var o=s._callCppProxy("getConversationList",[1,3,6,7],i),r=JSON.parse(o).list,n=[],a=0;a<r.length;a++)n.push(s._buildConversation(r[a].obj));t({code:e.ErrorCode.SUCCESS,data:n})}))},t.prototype.getConversation=function(t,o,r){var n=this;return new Promise((function(i){var s=n._callCppProxy("getConversation",t,o,r);if(s)i({code:e.ErrorCode.SUCCESS,data:n._buildConversation(s)});else{var a=n._callCppProxy("getHistoryMessages",t,o,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 p=n._callCppProxy("getConversationNotificationStatus",t,o,r),d=n._callCppProxy("getConversationTopStatus",t,o,r);i({code:e.ErrorCode.SUCCESS,data:{conversationType:t,targetId:o,channelId:r,unreadMessageCount:0,latestMessage:u,notificationStatus:p?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},t.prototype.removeConversation=function(t,o,r){var n=this._callCppProxy("removeConversation",t,o,r);return Promise.resolve(n?e.ErrorCode.SUCCESS:e.ErrorCode.CONVER_REMOVE_ERROR)},t.prototype.batchRemoveConversation=function(t){var o=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId}})),r=this._callCppProxy("removeConversationInBatches",JSON.stringify(o));return Promise.resolve(r?e.ErrorCode.SUCCESS:e.ErrorCode.CONVER_REMOVE_ERROR)},t.prototype.clearConversations=function(t,o){var r=this;return new Promise((function(n){var i=[];i=e.isArray(t)?t:[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.PUBLIC_SERVICE],r._callCppProxy("clearConversations",i,o||""),n(e.ErrorCode.SUCCESS)}))},t.prototype.getAllConversationUnreadCount=function(t,o,r){var n=this._callCppProxy("getTotalUnreadCount",o,r,t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},t.prototype.getConversationUnreadCount=function(t,o,r){var n=this;return void 0===r&&(r=""),new Promise((function(i){var s=n._callCppProxy("getUnreadCount",t,o,r);i({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.clearConversationUnreadCount=function(t,o,r){var n=this;return void 0===r&&(r=""),new Promise((function(i){n._callCppProxy("clearUnreadCount",t,o,r),i(e.ErrorCode.SUCCESS)}))},t.prototype.clearUnreadCountByTimestamp=function(t,o,r,n){var i=this;return new Promise((function(s){i._callCppProxy("clearUnreadCountByTimestamp",t,o,r,n),s(e.ErrorCode.SUCCESS)}))},t.prototype.getFirstUnreadMessage=function(t,o,r){var n=this;return new Promise((function(i){var s=n._callCppProxy("getTheFirstUnreadMessage",t,o,r),a=n._buildMessage(s);i({code:e.ErrorCode.SUCCESS,data:-1!==a.messageId?a:null})}))},t.prototype.getFirstUnreadMessageInfo=function(t,o,r){var n=this;return new Promise((function(i,s){var a=n._callCppProxy("getTheFirstUnreadMessage",t,o,r),c=n._buildMessage(a);i({code:e.ErrorCode.SUCCESS,data:-1!==c.messageId?{messageUId:c.messageUId,sentTime:c.sentTime}:null})}))},t.prototype.batchSetConversationToTop=function(t,o,r){var n=this;return new Promise((function(i,s){var a=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId,is_top:o}}));n._callCppProxy("setIsTopInBatches",JSON.stringify(a),r||!1),i(e.ErrorCode.SUCCESS)}))},t.prototype.setConversationStatus=function(t,o,r,n,i,s){var a=this;return new Promise((function(s){a._callCppProxy("setConversationStatus",t,o,r,n,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){s(e)}),0)}),i,!0)}))},t.prototype.getConversationNotificationStatus=function(t,o,r){var n=this;return new Promise((function(i){var s=n._callCppProxy("getConversationNotificationStatus",t,o,r);i({code:e.ErrorCode.SUCCESS,data:s?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE})}))},t.prototype.setConversationTypeNotificationLevel=function(t,o){var r=this;return new Promise((function(n,i){r._callCppProxy("setBlockPushLevelForType",t,o,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.getConversationTypeNotificationLevel=function(t){var o=this;return new Promise((function(r,n){var i=o._callCppProxy("getBlockPushLevelForType",t);r({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.searchConversationByContent=function(t,o,r,n){var i=this;return new Promise((function(s){n=n||[1,3,6,7];for(var a=i._callCppProxy("searchConversationByContent",n,t,o,r),c=JSON.parse(a).list,u=[],p=0;p<c.length;p++)u[p]=i._buildConversation(c[p].obj);s({code:e.ErrorCode.SUCCESS,data:u})}))},t.prototype.searchConversationByContentWithAllChannel=function(t,o,r){var n=this;return new Promise((function(i){r=r||[1,3,6,7];for(var s=n._callCppProxy("searchConversationByContentWithAllChannel",r,t,o),a=JSON.parse(s).list,c=[],u=0;u<a.length;u++)c[u]=n._buildConversation(a[u].obj);i({code:e.ErrorCode.SUCCESS,data:c})}))},t.prototype.searchMessageByContent=function(t,o,r,n,i,s,a){var c=this;return new Promise((function(s){c._callCppProxy("searchMessageByContent",t,o,r,n,i,1,(function(t,o){for(var r=t?JSON.parse(t).list:[],n=[],i=0;i<r.length;i++)n[i]=c._buildMessage(r[i].obj);setTimeout((function(){s({code:e.ErrorCode.SUCCESS,data:{messages:n,count:o}})}),0)}),a)}))},t.prototype.searchMessageByContentAndMessageType=function(t,o,r,n,i,s,a){var c=this;return new Promise((function(u){c._callCppProxy("searchMessageByContentAndObjectName",o,t,a||"",void 0===a,r,s,i,n,1,(function(t,o){for(var r=t?JSON.parse(t).list:[],n=[],i=0;i<r.length;i++)n[i]=c._buildMessage(r[i].obj);setTimeout((function(){u({code:e.ErrorCode.SUCCESS,data:{messages:n,count:o}})}),0)}))}))},t.prototype.searchMessagesByUser=function(t,o,r,n,i,s){var a=this;return new Promise((function(c){a._callCppProxy("getMessageBySender",t,o,r,n,i,s,(function(t){for(var o=t?JSON.parse(t).list:[],r=[],n=0;n<o.length;n++)r[n]=a._buildMessage(o[n].obj);setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{messages:r}})}),0)}))}))},t.prototype.searchMessageByContentWithAllChannel=function(t,o,r,n,i){var s=this;return new Promise((function(a){s._callCppProxy("searchMessageByContentWithAllChannel",t,o,r,n,i,1,(function(t,o){for(var r=t?JSON.parse(t).list:[],n=[],i=0;i<r.length;i++)n[i]=s._buildMessage(r[i].obj);setTimeout((function(){a({code:e.ErrorCode.SUCCESS,data:{messages:n,count:o}})}),0)}))}))},t.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(t,o,r,n,i,s,a){var c=this;return new Promise((function(u){c._callCppProxy("searchMessageByTimestampWithAllChannel",t,o,r,n,i,s,a,(function(t){for(var o=t?JSON.parse(t).list:[],r=[],n=0;n<o.length;n++)r[n]=c._buildMessage(o[n].obj);setTimeout((function(){u({code:e.ErrorCode.SUCCESS,data:{messages:r}})}),0)}))}))},t.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},t.prototype.addToBlacklist=function(t){var o=this;return new Promise((function(r){o._callCppProxy("addToBlacklist",t,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.removeFromBlacklist=function(t){var o=this;return new Promise((function(r){o._callCppProxy("removeFromBlacklist",t,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.getBlacklist=function(){var t=this;return new Promise((function(o){t._callCppProxy("getBlacklist",(function(t){setTimeout((function(){o({code:e.ErrorCode.SUCCESS,data:t})}),0)}),(function(e){setTimeout((function(){o({code:e})}),0)}))}))},t.prototype.getBlacklistStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("getBlacklistStatus",t,(function(t){setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:t})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.insertMessage=function(t,o,r){var n=this,i=r.content,s=r.senderUserId,a=r.messageType,c=r.messageDirection,u=r.readStatus,p=r.sentStatus,d=r.sentTime,l=r.searchContent,f=r.isUnread,h=r.messageUId,C=r.disableNotification,g=r.canIncludeExpansion,v=r.expansionMsg,_=r.channelId,S=r.directedUserIds,y=r.disableUpdateLastMessage;i=JSON.stringify(i);var m={};if(d=d||0,v){var E=JSON.parse(v);for(var P in E)m[P]={v:"",ts:0},m[P].v=E[P],m[P].ts=d}return new Promise((function(r){var v=f?0:1,E=n._callCppProxy("insertMessage",t,o,s,a,i,(function(){}),(function(e){setTimeout((function(){r({code:e})}),0)}),c,u||0,p||10,d,l||"",v,h||"",!!C,!!g,JSON.stringify(m),_||"",S||[],y||!1),P=n._buildMessage(E,{isOffLineMessage:!1});P.messageUId=h,P.sentTime=d,r({code:-1===P.messageId?e.ErrorCode.MSG_INSERT_ERROR:e.ErrorCode.SUCCESS,data:P})}))},t.prototype.batchInsertMessage=function(t,o){var r=this;return void 0===o&&(o=!1),new Promise((function(n){var i=t.map((function(t){var o=t.content,r=t.senderUserId,n=t.messageType,i=t.messageDirection,s=t.receivedStatus,a=void 0===s?0:s,c=t.sentStatus,u=t.sentTime,p=t.searchContent,d=t.isUnread,l=t.messageUId,f=t.disableNotification,h=t.canIncludeExpansion,C=t.expansion,g=t.channelId,v=t.conversationType,_=t.targetId,S=t.source,y=t.isMentioned,m=t.receivedStatusInfo,E=t.directedUserIds,P=t.disableUpdateLastMessage,T=a;m&&(T=e.transformReceivedStatusFlag(m));var I={};if(u=u||0,C)for(var R in C)I[R]={v:"",ts:0},I[R].v=C[R],I[R].ts=u;return{conversationType:v,targetId:_,channelId:g||"",direction:i,senderUserId:r,status:c||10,sentTime:u,objectName:n,content:JSON.stringify(o),messageUid:l||"",noNotification:!!f,supportExt:!!h,extMsg:JSON.stringify(I),readStatus:T,searchContent:p||"",isUnread:!!d,source:S||"",isMention:y,directedUsers:E,disableUpdateLastMessage:P||!1}})),s=r._callCppProxy("insertMessages",JSON.stringify(i),o);n({code:s?e.ErrorCode.SUCCESS:e.ErrorCode.MSG_INSERT_ERROR,data:s||!1})}))},t.prototype.getMessageCount=function(t,o,r){var n=this;return new Promise((function(i){var s=n._callCppProxy("getMessageCount",t,o,r);i({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.deleteMessages=function(t){var o=this;return new Promise((function(r){o._callCppProxy("deleteMessages",t),r(e.ErrorCode.SUCCESS)}))},t.prototype.deleteMessagesByTimestamp=function(t,o,r,n,i){var s=this;return new Promise((function(a){s._callCppProxy("deleteMessagesByTimestamp",t,o,r,n,i),a(e.ErrorCode.SUCCESS)}))},t.prototype.batchClearMessagesByTimestamp=function(t){var o=this;return new Promise((function(r,n){var i=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId||"",send_time:e.timestamp}}));o._callCppProxy("deleteMessageBySendTimeInBatches",JSON.stringify(i)),r(e.ErrorCode.SUCCESS)}))},t.prototype.batchClearRemoteHistoryMessages=function(t,o){var r=this;return new Promise((function(n,i){var s=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId||"",send_time:e.timestamp}}));r._callCppProxy("deleteRemoteMessageBySendTimeInBatches",JSON.stringify(s),o||!1,(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.getMessage=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getMessage",t),i=o._buildMessage(n,{isOffLineMessage:!1});r({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.setMessageContent=function(t,o,r){var n=this;return new Promise((function(i){o=JSON.stringify(o),n._callCppProxy("setMessageContent",t,o,r),i(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageSearchField=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("setMessageSearchField",t,o,r),i(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageSentStatus=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("setMessageSentStatus",t,o),n(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageReceivedStatus=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("setMessageReceivedStatus",t,o),n(e.ErrorCode.SUCCESS)}))},t.prototype.saveConversationMessageDraft=function(t,o,r,n){var i=this;return new Promise((function(s){i._callCppProxy("saveTextMessageDraft",t,o,r,n||"")&&s(e.ErrorCode.SUCCESS),s(e.ErrorCode.DRAFT_SAVE_ERROR)}))},t.prototype.getConversationMessageDraft=function(t,o,r){var n=this;return new Promise((function(i){var s=n._callCppProxy("getTextMessageDraft",t,o,r||"");i({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.clearConversationMessageDraft=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("clearTextMessageDraft",t,o,r||"")&&i(e.ErrorCode.SUCCESS),i(e.ErrorCode.DRAFT_REMOVE_ERROR)}))},t.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},t.prototype.batchSetConversationStatus=function(t){var o=t[0],r=o.conversationType,n=o.targetId,i=o.isTop,s=o.notificationStatus,a=o.channelId,c=o.isUpdateTime,u=void 0===c||c,p=this._callCppProxy("getConversationNotificationStatus",r,n,a||""),d=this._callCppProxy("getConversationTopStatus",r,n,a||""),l=e.isUndefined(s)?Boolean(p):s===e.NotificationStatus.OPEN,f=e.isUndefined(i)?Boolean(d):i;return this.setConversationStatus(r,n,l,f,a,u)},t.prototype.getConversationNotificationLevel=function(t,o,r){return E(this,void 0,void 0,(function(){var n;return P(this,(function(i){return n=this._callCppProxy("getBlockPushLevelForConversation",o,r,t),[2,Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})]}))}))},t.prototype.setConversationNotificationLevel=function(t,o,r,n){var i=this;return void 0===n&&(n=""),new Promise((function(s){i._callCppProxy("setBlockPushLevelForConversation",o,n,t,r,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){s(e)}),0)}))}))},t.prototype.batchSetConversationNotificationLevel=function(t,o){var r=this;return new Promise((function(n,i){var s=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId,level:o}}));r._callCppProxy("setBlockPushLevelInBatches",JSON.stringify(s),(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.getTotalUnreadCountByLevels=function(t,o,r){if(r){var n=this._callCppProxy("getUnreadMentionedCountByLevel",t,o);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})}var i=this._callCppProxy("getUnreadCountByLevel",t,o);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:i})},t.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},t.prototype.sendReadReceiptMessage=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("sendReadReceipt",t,r||"",o,(function(){o.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}))}})),setTimeout((function(){i({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getMessageReader=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("getMessageReader",t,r,o,(function(t,r){var s=[],a={};(t=JSON.parse(t)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;s.push({userId:o,readTime:r}),a[o]=r}));var c={readerInfo:a,readCount:s.length,totalCount:r};n._updateReadReceiptInfo(o,c),setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{list:s,totalMemberCount:r}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.sendReadReceiptMessageV4=function(t,o,r){var n=this;return new Promise((function(i){var s=t.conversationType,a=t.targetId,c=t.channelId;n._callCppProxy("sendMessageReadReceipt",s,a,c||"",o,r,(function(){setTimeout((function(){i({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getMessageReadReceiptV4=function(t,o){var r=this;return new Promise((function(n){var i=t.targetId,s=t.channelId;r._callCppProxy("getMessageReadReceipt",i,s||"",o,(function(t,i,s){var a=[],c=r._callCppProxy("getMessage",o),u=JSON.parse(c);try{JSON.parse(s).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;a.push({userId:o,readTime:r})}))}catch(e){r.logger.error(y.P_PARSE_JSON_E,"method: getMessageReadReceipt, info: "+s+", error: "+e)}var p=JSON.parse(u.readReceiptRequest||"{}"),d=p.readerList,l=void 0===d?[]:d,f=p.readCount,h=void 0===f?0:f,C=!1;l.length<a.length&&(l=a,C=!0),h<i&&(h=i,C=!0),C&&r._callCppProxy("updateReadReceiptRequestInfo",o,JSON.stringify({readerList:l,readCount:h,totalCount:t})),setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:{list:a,totalCount:t,readCount:h}})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.updateConversationReadTime=function(t,o){var r=this;return new Promise((function(n){var i=t.conversationType,s=t.targetId,a=t.channelId;r._callCppProxy("updateConversationReadTime",i,s,a||"",o,(function(){setTimeout((function(){n({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype._addChatroomCache=function(e,t,o,r){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:o,count:t,extra:r})},t.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},t.prototype._try2RejoinChatroom=function(){var t=this;if(0!==this._chatroomCache.length){var o=this.logger.createTraceId();this._chatroomCache.forEach((function(r){return E(t,void 0,void 0,(function(){var t,n,i,s,a,c,u;return P(this,(function(p){switch(p.label){case 0:return t=r.chatroomId,n=r.joinExist,i=r.count,s=r.extra,this.logger.info(e.LogTagId.L_REJOIN_CHATROOM_T,t,o),[4,this._joinChrm(t,i,n,!1,s)];case 1:return a=p.sent(),c=a.code,u=a.data,c===e.ErrorCode.SUCCESS?(this.logger.info(e.LogTagId.L_REJOIN_CHATROOM_R,t,o),this._sendChatroomStatus({rejoinedRoom:m({chatroomId:t,count:i},u)}),[2]):(c===e.ErrorCode.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(t),this._sendChatroomStatus({rejoinedRoom:{chatroomId:t,errorCode:c}}),this.logger.warn(e.LogTagId.L_REJOIN_CHATROOM_R,"chrmId: "+t+", code: "+c,o),[2])}}))}))}))}},t.prototype._joinChrm=function(t,o,r,n,i){var s=this,a=r?"joinExistChatRoom":"joinChatRoom";return new Promise((function(c){n&&s._callCppProxy("clearMessages",e.ConversationType.CHATROOM,t,""),s._callCppProxy(a,t,o,(function(n,a,u,p,d,l,f){s._addChatroomCache(t,o,r,i||""),setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{createTime:Number(n),memberCount:a,isAllChatroomBanned:u,isCurrentUserBanned:p,isCurrentChatroomBanned:d,isCurrentChatroomInWhitelist:l,joinTime:f}})}),0)}),(function(e){setTimeout((function(){c({code:e})}),0)}),i||"")}))},t.prototype.joinChatroom=function(e,t,o){return E(this,void 0,void 0,(function(){return P(this,(function(r){switch(r.label){case 0:return[4,this._joinChrm(e,t,!1,!0,o)];case 1:return[2,r.sent().code]}}))}))},t.prototype.joinExistChatroom=function(e,t,o){return this._joinChrm(e,t,!0,!0,o)},t.prototype.quitChatroom=function(t){var o=this;return this._rmChatroomCache(t),new Promise((function(r){o._callCppProxy("quitChatRoom",t,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.getChatroomInfo=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("getChatroomInfo",t,o,r,(function(t,o){var r=t?JSON.parse(t).list:[],n=[];if(r.length>0)for(var s=0;s<r.length;s++)n.push(JSON.parse(r[s].obj));setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{userInfos:n,userCount:o}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getChatroomHistoryMessages=function(t,o,r,n){var i=this;return new Promise((function(s){i._callCppProxy("getChatroomHistoryMessage",t,o,r,n,(function(t){var o;try{o=JSON.parse(t)}catch(e){o={list:[],hasMore:!1}}var r=o.list;if(r&&r.length)try{o.list=r.map((function(e){return i._buildMessage(e.obj)}))}catch(e){o.list=[]}setTimeout((function(){s({code:e.ErrorCode.SUCCESS,data:o})}),0)}),(function(e){setTimeout((function(){s({code:e})}),0)}),"")}))},t.prototype.setChatroomEntry=function(t,o){var r=this;return new Promise((function(n){var i='[{"key":"'+o.key+'", "value":"'+o.value+'"}]';r._callCppProxy("setChatroomKV",t,i,!!o.isAutoDelete,!!o.isOverwrite,(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.setChatroomEntries=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("setChatroomKV",t,JSON.stringify(o.entries),!!o.isAutoDelete,!!o.isOverwrite,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({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(t,o){var r=this,n=[o.key];return new Promise((function(i){r._callCppProxy("deleteChatroomKV",t,n,!!o.isOverwrite,(function(){i(e.ErrorCode.SUCCESS)}),(function(e){i(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(t,o){var r=this;return new Promise((function(n){var i=o.entries.map((function(e){return e.key}));r._callCppProxy("deleteChatroomKV",t,i,!!o.isOverwrite,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.getChatroomEntry=function(t,o){return E(this,void 0,void 0,(function(){var r;return P(this,(function(n){switch(n.label){case 0:return[4,this.getAllChatroomEntry(t)];case 1:return(r=n.sent()).code===e.ErrorCode.SUCCESS?[2,{code:e.ErrorCode.SUCCESS,data:r.data?r.data[o]:null}]:[2,{code:r.code}]}}))}))},t.prototype.getAllChatroomEntry=function(t){var o=this;return new Promise((function(r){o._callCppProxy("getChatroomKV",t,(function(t){var o={};try{(t?JSON.parse(t):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){o[e.key]=e.value?e.value:""}))}catch(e){}setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:o})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.removeChatroomFromCatch=function(e){this._rmChatroomCache(e)},t.prototype.getFileToken=function(t,o,r,n,i,s){var a=this;return r=r||"",n=n||"",i=i||"",new Promise((function(c){var u;u=n&&"uploads"!==n?o||"":e.getUploadFileName(t,o);var p=a.getNaviInfoFromCache(),d={uploadDomain:e.getMinionURL(p,a.logger),env:a._environment};s=s?Math.ceil(s):0,a._callCppProxy("getUploadToken",t,u,r,n,i,JSON.stringify(d),s,(function(t,o,r,n,i,s,a,p,d,l,f,h,C,g,v,_,S,y,m,E,P,T,I){setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{token:t,deadline:0,bosToken:o,bosDate:r,path:n,osskeyId:i,ossPolicy:s,ossSign:a,ossBucketName:p,fileName:u,s3Credential:d,s3Algorithm:l,s3Date:f,s3Policy:h,s3Signature:C,s3BucketName:g,stcAuthorization:v,stcContentSha256:_,stcDate:S,stcBucketName:y,minioAuthorization:m,minioContentSha256:E,minioDate:P,minioBucketName:T,downloadAuthInfo:I?JSON.parse(I):null}})}),0)}),(function(e){setTimeout((function(){c({code:e})}),0)}))}))},t.prototype.getFileUrl=function(t,o,r,n){var i=this;return new Promise((function(s){var a=i.getNaviInfoFromCache(),c={url:e.getMinionURL(a,i.logger)};i._callCppProxy("getDownloadUrl",t,r,n,o-1,JSON.stringify(c),-1,(function(t){setTimeout((function(){s({code:e.ErrorCode.SUCCESS,data:{downloadUrl:t}})}),0)}),(function(e){setTimeout((function(){s({code:e})}),0)}))}))},t.prototype.clearData=function(){var t=this;return new Promise((function(o){var r=t._callCppProxy("clearData");o({code:e.ErrorCode.SUCCESS,data:r})}))},t.prototype.getDeviceId=function(){var e=this._dbpath;return le(e)},t.prototype.getVoIPKey=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("getVoIPKey",t,o,"",(function(t){setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:t})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.bindRTCRoomForChatroom=function(t){var o=this;return new Promise((function(r){var n=t.chatRoomId,i=t.rtcRoomId;o._callCppProxy("bindRTCRoomForChatroom",n,i,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.getGroupMessageDeliverList=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("getGroupMessageDeliverList",t,r,o,(function(t,o){var r=JSON.parse(t).list.map((function(e){return{time:JSON.parse(e.obj).time,userId:JSON.parse(e.obj).id}}));setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{totalCount:o,list:r}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getPrivateMessageDeliverTime=function(t,o){var r=this;return new Promise((function(n){var i=r._callCppProxy("getMessageDeliverTime",t);if(i)n({code:e.ErrorCode.SUCCESS,data:i});else{r._callCppProxy("getPrivateMessageDeliverList",o,t,(function(t){var o=0,r=JSON.parse(t).list;if(r.length>0){var i=JSON.parse(r[0].obj).time;o=i}setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:o})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}}))},t.prototype.rtcSignaling=function(t,o,r,n){var i=this;return new Promise((function(s){i._callCppProxy("rtcSignaling",t,o,r,n,(function(t){var o=Array.prototype.slice.call(t);s({code:e.ErrorCode.SUCCESS,buffer:o})}),(function(e){s({code:e})}),30)}))},t.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 i=e.rtcHeartbeatResolves[t];if(i){var s=i.findIndex((function(e){return e.seqId===r}));-1!==s&&i.splice(s,1)[0].resolve({code:o,data:{version:Number(n)}})}}))},t.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)}))},t.prototype.createTag=function(t){var o=this;return new Promise((function(r){o._callCppProxy("addTag",t.tagId,t.tagName,(function(){setTimeout((function(){r({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.removeTag=function(t){var o=this;return new Promise((function(r){o._callCppProxy("deleteTag",t,(function(){setTimeout((function(){r({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.updateTag=function(t){var o=this;return new Promise((function(r){o._callCppProxy("renameTag",t.tagId,t.tagName,(function(){setTimeout((function(){r({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.getTagList=function(){var t=this;return new Promise((function(o){var r=t._callCppProxy("getTags"),n=t._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));o({code:e.ErrorCode.SUCCESS,data:n})}))},t.prototype.addTagForConversations=function(t,o){var r=this;return new Promise((function(n){o.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));r._callCppProxy("addConversationsForTag",t,JSON.stringify(o),(function(){setTimeout((function(){n({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.removeTagForConversations=function(t,o){var r=this;return new Promise((function(n){o.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),r._callCppProxy("removeConversationsForTag",t,JSON.stringify(o),(function(){setTimeout((function(){n({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.removeTagsForConversation=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("removeTagsForConversation",t.conversationType,t.targetId,t.channelId||"",o,(function(){setTimeout((function(){n({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.getConversationListByTag=function(t,o,r,n){var i=this;return new Promise((function(s){var a=i._callCppProxy("getConversationsForTagByPage",t,o,r||20,n||""),c=i._convertResultList(a,(function(e){return m(m({},i._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:e.ErrorCode.SUCCESS,data:c})}))},t.prototype.getUnreadCountByTag=function(t,o){var r=this;return new Promise((function(n){var i=r._callCppProxy("getConversationUnreadCountForTag",t,o);n({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.setConversationStatusInTag=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("setConversationToTopForTag",t,o.conversationType,o.targetId,o.channelId||"",r.isTop||!1,(function(){setTimeout((function(){i({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getTagsForConversation=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getTagsForConversation",t.conversationType,t.targetId,t.channelId||""),i=o._convertResultList(n,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));r({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},t.prototype.getTopConversationList=function(t,o){var r=this;return new Promise((function(n){var i=e.isUndefined(o)?r._callCppProxy("getTopConversations",t):r._callCppProxy("getTopConversations",t,o),s=JSON.parse(i).list.map((function(e){return r._buildConversation(e.obj)}));n({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},t.prototype.getAllUnreadMentionedCount=function(){var t=this;return new Promise((function(o){var r=t._callCppProxy("getUnreadAndMentionCount",[e.ConversationType.GROUP],"");o({code:e.ErrorCode.SUCCESS,data:r})}))},t.prototype.getOSInfo=function(){return E(this,void 0,void 0,(function(){var t;return P(this,(function(o){return t={arch:g.arch(),platform:g.platform(),type:g.type(),version:g.version(),release:g.release(),uptime:g.uptime(),cpus:g.cpus(),freemem:g.freemem(),totalmem:g.totalmem(),networkInterfaces:g.networkInterfaces()},[2,{code:e.ErrorCode.SUCCESS,data:t}]}))}))},t.prototype.getMainProcessInfo=function(){return E(this,void 0,void 0,(function(){return P(this,(function(t){return[2,{code:e.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()}}]}))}))},t.prototype.setCallInfo=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("callInfoSignaling",t,o,r,(function(t,o){setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{key:t,value:o}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.setProxy=function(t){return this.tcpMgr.getConnectionStatus()!==e.RCConnectionStatus.DISCONNECTED?Promise.resolve({code:e.ErrorCode.RC_CONN_PROXY_UNAVAILABLE}):Promise.resolve($(t,this.logger))},t.prototype.getProxy=function(){return Promise.resolve(Z())},t.prototype.testProxy=function(t,o){return function(t,o,r){return new Promise((function(n){var i=/^https/.test(o)?Y:K;r.info(e.LogTagId.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:t,testHost:o}));var s=i(o,t,(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})}))}));s.once("timeout",(function(){return n({status:0})})),s.once("error",(function(e){return n({status:0,data:e.stack})})),s.end()}))}(t,o,this.logger)},t.prototype.checkDuplicateMessage=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("checkDuplicateMessage",t);r({code:e.ErrorCode.SUCCESS,data:n})}))},t.prototype.subscribeUser=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("updateSubscribeStatus",o,e.SubscribeOperationType.SUBSCRIBE,t,(function(){i({code:e.ErrorCode.SUCCESS})}),(function(e,t){i({code:e,data:t})}),r)}))},t.prototype.unSubscribeUser=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("updateSubscribeStatus",o,e.SubscribeOperationType.UNSUBSCRIBE,t,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}),0)}))},t.prototype.getSubscribeUserList=function(t,o,r){var n=this._callCppProxy("getSubscribeUserList",t,o,r),i=this._buildSubscribeEventData(n).map((function(t){var o=t.userId,r=t.subscribeType,n=t.subscribeTime,i=t.expiry,s=t.details,a={userId:o,subscribeType:r,subscribeTime:n,expiry:i};return r===e.SubscribeType.ONLINE_STATUS&&(a.details=e.completeSubscriptionPlatformStatus(s)),a}));return Promise.resolve({code:e.ErrorCode.SUCCESS,data:i})},t.prototype.setDuplicateMessageConfig=function(t){var o=this._callCppProxy("setDuplicateMessageConfig",[e.ConversationType.CHATROOM],me.cuid,t);return Promise.resolve({code:o})},t.prototype.getSubscribeUserStatus=function(t,o){var r=this._callCppProxy("getSubscribeStatusByUserIds",t,o),n=this._buildSubscribeEventData(r).map((function(t){var o=t.userId,r=t.subscribeType,n=t.subscribeTime,i=t.expiry,s=t.details,a={userId:o,subscribeType:r,subscribeTime:n,expiry:i};return r===e.SubscribeType.ONLINE_STATUS&&(a.details=e.completeSubscriptionPlatformStatus(s)),a}));return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},t.prototype.updateMyUserProfile=function(e){var t=this;return new Promise((function(o){var r=[],n=[];Object.keys(e).forEach((function(t){var o;if("extraProfile"===t&&e.extraProfile){if(e.extraProfile){var i=e.extraProfile;Object.keys(i).forEach((function(e){n.push(JSON.stringify({key:e,value:i[e]||""}))}))}}else r.push(JSON.stringify({key:t,value:(null===(o=e[t])||void 0===o?void 0:o.toString())||""}))})),t._callCppProxy("updateUserProfile",r,n,(function(e,t){o({code:e,data:{errorKey:t}})}))}))},t.prototype.getUserProfiles=function(e){var t=this;return new Promise((function(o){t._callCppProxy("getUserProfiles",e,(function(e,r){o({code:e,data:t._string2UserProfileInfoList(r)})}))}))},t.prototype.getMyUserProfile=function(){var e=this;return new Promise((function(t){e._callCppProxy("getOwnUserProfile",(function(o,r){t({code:o,data:e._string2userProfileInfo(r)})}))}))},t.prototype._string2userProfileInfo=function(e){var t;try{var o=JSON.parse(e),r=o.userProfile.reduce((function(e,t){var o=JSON.parse(t);return["gender","role","level"].includes(o.key)?e[o.key]=Number(o.value):e[o.key]=o.value,e}),{});return r.userId=o.userId,r.extraProfile=(null===(t=o.userExtProfile)||void 0===t?void 0:t.reduce((function(e,t){var o=JSON.parse(t);return e[o.key]=o.value,e}),{}))||{},r}catch(t){this.logger.error(y.P_PARSE_JSON_USER_PROFILE_E,JSON.stringify({error:null==t?void 0:t.stack,str:e}))}return{}},t.prototype._string2UserProfileInfoList=function(e){var t=this;try{return JSON.parse(e).list.map((function(e){return t._string2userProfileInfo(e.obj)}))}catch(t){this.logger.error(y.P_PARSE_JSON_USER_PROFILE_E,JSON.stringify({error:null==t?void 0:t.stack,str:e}))}return[]},t.prototype.updateMyUserProfileVisibility=function(t){var o=this;return new Promise((function(r){o._callCppProxy("updateUserProfilePermission",t,(function(){r({code:e.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getMyUserProfileVisibility=function(){var e=this;return new Promise((function(t){e._callCppProxy("getUserProfilePermission",(function(e,o){t({code:e,data:o})}))}))},t.prototype.searchUserProfileByUniqueId=function(e){var t=this;return new Promise((function(o){t._callCppProxy("getUserProfileByUniqueId",e,(function(e,r){o({code:e,data:t._string2userProfileInfo(r)})}))}))},t.prototype.getMatchedMessage=function(t,o,r,n){var i,s=this._callCppProxy("getMatchedMessage",t.conversationType,t.targetId,o,r,n,t.channelId||""),a=[];try{i=JSON.parse(s).list;for(var c=0;c<i.length;c++){var u=this._buildMessage(i[c].obj);a.push(u)}}catch(t){return this.logger.error(y.P_PARSE_JSON_MSGS_E,s),Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:a})},t.prototype.getConversations=function(t){var o,r=this,n=t.map((function(e){var t=e.conversationType,o=e.targetId,r=e.channelId;return{targetId:o,channelId:void 0===r?"":r,type:t}})),i=this._callCppProxy("getConversations",JSON.stringify(n));try{o=JSON.parse(i).list.map((function(e){return r._buildConversation(e.obj)}))}catch(t){return this.logger.error(y.P_PARSE_JSON_MSGS_E,i),Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:o})},t.prototype.handleErrorCode=function(t,o){t!==e.ErrorCode.SUCCESS&&setTimeout((function(){o({code:t})}),0)},t.prototype._convertGroupInfoList=function(t,o){return t&&0!==t.length?t.map((function(t){var o=t.groupId,r=t.baseInfo,n=t.createTime,i=t.createUserId,s=t.extraInfo,a=t.memberCount,c=t.ownerId,u=t.remark,p=t.joinTime,d=t.role,l=e.arrayToKeyValue(r),f=e.arrayToKeyValue(s);return{groupId:o,groupName:l.name||"",portraitUri:l.portraitUrl||"",introduction:l.introduction||"",notice:l.announcement||"",joinPermission:~~l.joinPerm,removeMemberPermission:~~l.removePerm,invitePermission:~~l.memInvitePerm,inviteHandlePermission:~~l.invitePerm,groupInfoEditPermission:~~l.profilePerm,memberInfoEditPermission:~~l.memProfilePerm,extProfile:f,creatorId:i||"",ownerId:c||"",createTime:n||0,membersCount:a||0,remark:u||"",joinedTime:p||0,role:d||e.GroupMemberRole.UNDEF}})):[]},t.prototype._convertUpdateGroupInfoList=function(t){return t&&0!==t.length?t.map((function(t){var o=t.groupId,r=t.baseInfo,n=t.createTime,i=t.createUserId,s=t.extraInfo,a=t.memberCount,c=t.ownerId,u=t.remark,p=t.joinTime,d=t.role,l=e.arrayToKeyValue(r),f=e.arrayToKeyValue(s);return m(m(m(m(m(m(m(m(m({groupId:o},e.formatGroupBaseInfo(l)),s.length>0&&{extProfile:f}),i&&{creatorId:i}),c&&{ownerId:c}),n&&{createTime:n}),a&&{membersCount:a}),u&&{remark:u}),p&&{joinedTime:p}),d&&{role:d})})):[]},t.prototype._convertGroupMemberInfoList=function(e){return e&&0!==e.length?e.map((function(e){var t=e.userId,o=e.nickname,r=e.groupNickname,n=e.portraitUrl,i=e.joinTime;return{userId:t,name:o||"",portraitUri:n||"",nickname:r||"",role:e.role||0,joinedTime:i||0,extra:e.extra||""}})):[]},t.prototype.createGroup=function(t,o,r,n){return E(this,void 0,void 0,(function(){var i=this;return P(this,(function(s){return[2,new Promise((function(s){var a=_e(o),c=_e(r||{}),u=i._callCppProxy("createGroup",t,n,JSON.stringify(a),JSON.stringify(c),(function(t,o,r){t===e.ErrorCode.SUCCESS?setTimeout((function(){s({code:t,data:{processCode:o}})}),0):setTimeout((function(){s({code:t,msg:null!=r?r:""})}),0)}));i.handleErrorCode(u,s)}))]}))}))},t.prototype.updateGroupInfo=function(t,o,r){return E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=_e(o),a=_e(null!=r?r:{}),c=n._callCppProxy("updateGroupInfo",t,JSON.stringify(s),JSON.stringify(a),(function(t,o){t===e.ErrorCode.SUCCESS?setTimeout((function(){i({code:t})}),0):setTimeout((function(){i({code:t,msg:null!=o?o:""})}),0)}));n.handleErrorCode(c,i)}))]}))}))},t.prototype.getGroupsInfo=function(t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=o._callCppProxy("getGroupInfoByIds",t,(function(t,n,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){o.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){r({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:o._convertGroupInfoList(a)})}),0)}else setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))]}))}))},t.prototype.kickGroupMembers=function(e,t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=Se(o),s=r._callCppProxy("kickOutGroupMember",e,t,JSON.stringify(i),(function(e,t){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(s,n)}))]}))}))},t.prototype.quitGroup=function(e,t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=Se(t),i=o._callCppProxy("quitGroup",e,JSON.stringify(n),(function(e,t){setTimeout((function(){r({code:e})}),0)}));o.handleErrorCode(i,r)}))]}))}))},t.prototype.dismissGroup=function(e){return E(this,void 0,void 0,(function(){var t=this;return P(this,(function(o){return[2,new Promise((function(o){var r=t._callCppProxy("disbandGroup",e,(function(e,t){setTimeout((function(){o({code:e})}),0)}));t.handleErrorCode(r,o)}))]}))}))},t.prototype.transferGroupOwner=function(e,t,o,r){return E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=Se(r),a=n._callCppProxy("transferGroup",e,t,o,JSON.stringify(s),(function(e,t){setTimeout((function(){i({code:e})}),0)}));n.handleErrorCode(a,i)}))]}))}))},t.prototype.setGroupManagers=function(e,t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=r._callCppProxy("updateGroupAdmins",t,o,e,(function(e,t){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(i,n)}))]}))}))},t.prototype.getGroupMembersByRole=function(t,o,r){return E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=o===e.GroupMemberRole.UNDEF?[1,2,3]:[o],a=n._callCppProxy("getGroupMembers",t,s,r.pageToken||"",r.count,r.order?1:0,(function(t,o,r,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){n.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){i({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=n._convertGroupMemberInfoList(a);setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{totalCount:null!=r?r:0,data:c,pageToken:null!=o?o:""}})}),0)}else setTimeout((function(){i({code:t})}),0)}));n.handleErrorCode(a,i)}))]}))}))},t.prototype.getGroupMembers=function(t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=r._callCppProxy("getGroupMembersByIds",t,o,(function(t,o,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){r.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){n({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=r._convertGroupMemberInfoList(a);setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:c})}),0)}else setTimeout((function(){n({code:t})}),0)}));r.handleErrorCode(i,n)}))]}))}))},t.prototype.setGroupMemberInfo=function(e,t,o,r){return E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=n._callCppProxy("updateGroupMemberInfo",e,t,o,r||"",(function(e,t){setTimeout((function(){i({code:e})}),0)}));n.handleErrorCode(s,i)}))]}))}))},t.prototype.searchGroupMembers=function(t,o,r){return E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=r.order?1:0,a=n._callCppProxy("getGroupMembersByNickname",t,o,r.pageToken||"",r.count,s,(function(t,o,r,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){n.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){i({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=n._convertGroupMemberInfoList(a);setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:c})}),0)}else setTimeout((function(){i({code:t})}),0)}));n.handleErrorCode(a,i)}))]}))}))},t.prototype.joinGroup=function(t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=o._callCppProxy("joinGroup",t,(function(t,o,n){t===e.ErrorCode.SUCCESS?setTimeout((function(){r({code:t,data:{processCode:o}})}),0):setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))]}))}))},t.prototype.inviteUsersToGroup=function(t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=r._callCppProxy("inviteUsersToGroup",t,o,(function(t,o,r){t===e.ErrorCode.SUCCESS?setTimeout((function(){n({code:t,data:{processCode:o}})}),0):setTimeout((function(){n({code:t})}),0)}));r.handleErrorCode(i,n)}))]}))}))},t.prototype.memberInviteResponse=function(t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=t.groupId,i=t.inviterId,s=t.optType,a=t.optResult,c=t.joinUserId,u=t.reason,p=1===s?1:0,d=p&&c?c:"",l=o._callCppProxy("handleGroupInvite",n,d,i,a,p,null!=u?u:"",(function(t,o,n){t===e.ErrorCode.SUCCESS?setTimeout((function(){r({code:t,data:{processCode:o}})}),0):setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(l,r)}))]}))}))},t.prototype.getGroupApplications=function(t,o,r){return void 0===o&&(o=[]),void 0===r&&(r=[]),E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=t.order?1:0,a=n._callCppProxy("getGroupRequests",o,r,"",t.pageToken||"",t.count,s,(function(t,o,r,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){n.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){i({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=a.map((function(e){var t=e.groupId,o=e.joinUser,r=e.approverUser,n=e.inviterUser,i=e.type;return{groupId:t,joinMemberInfo:o,inviterInfo:n,operatorInfo:r,status:e.status,direction:e.direction,type:i,operationTime:e.operateTime,reason:e.remark}}));setTimeout((function(){i({code:t,data:{totalCount:r,data:c,pageToken:o}})}),0)}else setTimeout((function(){i({code:t})}),0)}));n.handleErrorCode(a,i)}))]}))}))},t.prototype.getJoinedGroupsByRole=function(t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=o.order?1:0,s=t===e.GroupMemberRole.UNDEF?[1,2,3]:[t],a=r._callCppProxy("getGroups",s,o.pageToken||"",o.count,i,(function(t,o,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){r.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){n({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=r._convertGroupInfoList(a);setTimeout((function(){n({code:t,data:{totalCount:i,data:c,pageToken:o}})}),0)}else setTimeout((function(){n({code:t})}),0)}));r.handleErrorCode(a,n)}))]}))}))},t.prototype.searchJoinedGroups=function(t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=o.order?1:0,s=r._callCppProxy("getGroupsByGroupName",t,o.pageToken||"",o.count,i,(function(t,o,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){r.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){n({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=r._convertGroupInfoList(a);setTimeout((function(){n({code:t,data:{totalCount:i,data:c,pageToken:o}})}),0)}else setTimeout((function(){n({code:t})}),0)}));r.handleErrorCode(s,n)}))]}))}))},t.prototype.getJoinedGroups=function(t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=o._callCppProxy("getGroupsByIds",t,(function(t,n,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){o.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){r({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=o._convertGroupInfoList(a);setTimeout((function(){r({code:t,data:c})}),0)}else setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))]}))}))},t.prototype.setGroupRemark=function(t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=o?e.GroupOperationType.ADD:e.GroupOperationType.REMOVE,s=r._callCppProxy("updateGroupRemark",t,o||"",i,(function(e,t){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(s,n)}))]}))}))},t.prototype.setGroupFollows=function(e,t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=r._callCppProxy("updateFavoriteMembers",t,o,e,(function(e,t){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(i,n)}))]}))}))},t.prototype.getGroupFollows=function(t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=o._callCppProxy("getGroupFavoriteMembers",t,"",1e3,0,(function(t,n,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){o.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){r({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=a.map((function(e){return{userId:e.userId,time:e.followTime}}));setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:c})}),0)}else setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))]}))}))},t.prototype.addFriend=function(e,t,o){var r=this;return new Promise((function(n){var i=r._callCppProxy("addFriend",e,t,o,(function(e,t,o){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(i,n)}))},t.prototype.deleteFriends=function(e,t){var o=this;return new Promise((function(r){var n=o._callCppProxy("removeFriends",e,t,(function(e,t){setTimeout((function(){r({code:e})}),0)}));o.handleErrorCode(n,r)}))},t.prototype.acceptFriendApplication=function(e){var t=this;return new Promise((function(o){var r=t._callCppProxy("acceptFriendRequest",e,"",(function(e,t){setTimeout((function(){o({code:e})}),0)}));t.handleErrorCode(r,o)}))},t.prototype.refuseFriendApplication=function(e,t){var o=this;return new Promise((function(r){var n=o._callCppProxy("rejectFriendRequest",e,t||"",(function(e,t){setTimeout((function(){r({code:e})}),0)}));o.handleErrorCode(n,r)}))},t.prototype.setFriendInfo=function(e,t,o){var r=this;return new Promise((function(n){var i=_e(null!=o?o:{}),s=r._callCppProxy("setFriendInfo",e,t,JSON.stringify(i),(function(e,t){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(s,n)}))},t.prototype.checkFriends=function(t,o){var r=this;return new Promise((function(n){var i=r._callCppProxy("checkFriendRelationship",t,o,(function(t,o){if(t===e.ErrorCode.SUCCESS){var r=JSON.parse(o).map((function(e){return{userId:e.userId,relationType:e.status}}));setTimeout((function(){n({code:t,data:r})}),0)}else setTimeout((function(){n({code:t})}),0)}));r.handleErrorCode(i,n)}))},t.prototype.getFriends=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getFriends",t,0,(function(t,n){try{if(t===e.ErrorCode.SUCCESS){var i=JSON.parse(n),s=o._convertFriendInfo(i);setTimeout((function(){r({code:t,data:{data:s,pageToken:""}})}),0)}else setTimeout((function(){r({code:t})}),0)}catch(t){o.logger.error(y.P_PARSE_JSON_MSGS_E,n),setTimeout((function(){r({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}}));o.handleErrorCode(n,r)}))},t.prototype.getFriendApplications=function(t,o,r){var n=this;return new Promise((function(i){var s=t.order?1:0,a=3;o&&1===o.length&&(a=null==o?void 0:o[0]);var c=n._callCppProxy("getFriendRequestListByPage",a,r||[0,1,2,3],t.count,t.pageToken||"",s,(function(t,o,r){if(t===e.ErrorCode.SUCCESS){var s=[];try{s=JSON.parse(r)}catch(t){n.logger.error(y.P_PARSE_JSON_MSGS_E,r),setTimeout((function(){i({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var a=s.map((function(e){return{userId:e.userId,name:e.name,portraitUri:e.portraitUrl,applicationType:e.friendRequestType,applicationStatus:e.friendRequestStatus,operationTime:e.operateTime,remark:e.extra}}));setTimeout((function(){i({code:t,data:{data:a,pageToken:null!=o?o:""}})}),0)}else setTimeout((function(){i({code:t})}),0)}));n.handleErrorCode(c,i)}))},t.prototype.deleteFriendApplication=function(t,o){return Promise.resolve({code:e.ErrorCode.NOT_SUPPORT})},t.prototype._convertFriendInfo=function(e){return e.map((function(e){var t=e.userId,o=e.userName,r=e.remark;return{userId:t,name:o,portraitUri:e.portraitUrl,remark:r,directionType:e.friendType,extProfile:e.extProfiles,addTime:e.addTime,inBlackList:!!e.friendAttribute}}))},t.prototype.getFriendsInfo=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getFriendByIds",t,(function(t,n){if(t===e.ErrorCode.SUCCESS){var i=JSON.parse(n),s=o._convertFriendInfo(i);setTimeout((function(){r({code:t,data:s})}),0)}else setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))},t.prototype.searchFriendsInfo=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getFriendByNickname",t,(function(t,n){if(t===e.ErrorCode.SUCCESS)try{var i=JSON.parse(n),s=o._convertFriendInfo(i);setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:s})}),0)}catch(t){o.logger.error(y.P_PARSE_JSON_MSGS_E,n),setTimeout((function(){r({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}else setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))},t.prototype.setFriendAddPermission=function(e){var t=this;return new Promise((function(o){var r=t._callCppProxy("setFriendAuthPermission",e,(function(e,t){setTimeout((function(){o({code:e})}),0)}));t.handleErrorCode(r,o)}))},t.prototype.getFriendAddPermission=function(){var e=this;return new Promise((function(t){var o=e._callCppProxy("getFriendAuthPermission",(function(e,o){setTimeout((function(){t({code:e,data:o})}),0)}));e.handleErrorCode(o,t)}))},t.prototype.setDataBaseLogConfig=function(e){this._callCppProxy("setDataBaseLogConfig",e)},t}(),Oe=r.resolve(__dirname,"binding","electron-"+n.platform()+"-"+n.arch()+".node"),Ne={addon:null},Me=(Ie=process,{sendError:function(e){Ie.send({type:x.ERROR,data:{msg:e}})},sendEvent:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];Ie.send({type:x.EVENT,data:{eventName:e,data:t}})},sendResponse:function(e){Ie.send({type:x.RESPONSE,data:e})},sendCallback:function(e){Ie.send({type:x.CALLBACK,data:e})}}).sendError;try{Ne.addon=require(Oe)}catch(e){console.error("error ->",Oe,"\n",e),Me(e.toString())}Ne.addon||console.error("error -> cannot find module: ",Oe);var be,Ue=Ne.addon,xe=function(){function e(e,t,o,r,n,i,s){this.sendCallback=i,this._cppService=new Re(e,Ue,t,n,r,o,s)}return e.prototype.call=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return E(this,void 0,void 0,(function(){var o,r=this;return P(this,(function(n){switch(n.label){case 0:return"sendMessage"===e&&(t[3]=function(e){var o=t[3];r.sendCallback({reqId:o,data:e})}),[4,(o=this._cppService).callProxy.apply(o,T([e],t,!1))];case 1:return[2,{success:!0,data:n.sent()}]}}))}))},e.prototype.send=function(e){for(var t,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];(t=this._cppService).sendProxy.apply(t,T([e],o,!1))},e.prototype.destroy=function(){this._cppService.destroy()},e}(),Le=function(){function n(o,r,n,i,s,a){var c=this;void 0===a&&(a=!1),this._appkey=o,this._dbpath=r,this._logOutputLevel=n,this._runInMainProcess=i,this._enableSyncEmptyTopConversation=s,this._disableLogReport=a,this._catch={crtUserId:"",connectedTime:0,naviInfo:null,connectionStatus:2,deviceId:"",deltaTime:0},this._connectionStatus=e.RCConnectionStatus.DISCONNECTED,this._connectInfo={token:"",reconnectKickEnable:!1,openCallPlus:!1,traceId:""},this._registerMessageTypeList=[],this._isProcessQuit=!1,this._rendererInitOptions=null,this._senders={},this._callbackCache={},this._createServiceProxy(),t.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];return E(c,void 0,void 0,(function(){var r,n;return P(this,(function(i){switch(i.label){case 0:return[4,(n=this._cppServiceProcessProxy).call.apply(n,T([t],o,!1))];case 1:return r=i.sent(),e.returnValue=r.data,[2]}}))}))})),t.ipcMain.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,o){for(var r=[],n=3;n<arguments.length;n++)r[n-3]=arguments[n];return E(c,void 0,void 0,(function(){var n,i,s;return P(this,(function(a){switch(a.label){case 0:return"sendMessage"===o&&(n=r[3],this._callbackCache[n]=e.sender),"connect"===o&&(this._connectInfo={token:r[0],reconnectKickEnable:r[1],openCallPlus:r[2],traceId:r[3]}),[4,(s=this._cppServiceProcessProxy).call.apply(s,T([o],r,!1))];case 1:if(!(i=a.sent()).success)throw new Error(i.data.msg);return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,i.data),[2]}}))}))})),t.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o,r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];"registerMessageType"===t&&c._registerMessageTypeList.push({objectName:r[0],isPersited:r[1],isCounted:r[2],searchProps:r[3]}),(o=c._cppServiceProcessProxy).send.apply(o,T([t],r,!1))})),t.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),t.app.on("before-quit",(function(){c._isProcessQuit=!0,c.destroy()})),t.app.on("window-all-closed",(function(){c._isProcessQuit=!0,c.destroy()}))}return n.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))},n.prototype._send2AllRenderer=function(e,t,o){var r=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(n){var i=r._senders[n];o.includes(i)||r._send2Renderer(i,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},n.prototype._registerRenderers=function(e,t){var o=this,r=e.sender,n=r.id;this._rendererInitOptions||(this._rendererInitOptions=t),this._cppServiceProcessProxy.send("registerRenderers",t),this._senders[n]||(this._senders[n]=r,r.once("destroyed",(function(){delete o._senders[n]})))},n.prototype.getMainCache=function(){return this._catch},n.prototype._restartSubProcessProxy=function(){var t=this;if(this._createServiceProxy(),this._connectionStatus!==e.RCConnectionStatus.DISCONNECTED){this._send2AllRenderer("onSuspend",e.ErrorCode.SUB_PROCESS_EXIT),this._registerMessageTypeList.forEach((function(e){t._cppServiceProcessProxy.send("registerMessageType",e.objectName,e.isPersited,e.isCounted,e.searchProps)})),this._cppServiceProcessProxy.send("registerRenderers",this._rendererInitOptions);var o=this._connectInfo,r=o.token,n=o.reconnectKickEnable,i=o.openCallPlus;this._cppServiceProcessProxy.send("reconnect",r,n,i)}},n.prototype._eventNotifyHandler=function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];var n=o[0],i=o[1];switch(t){case"onConnected":this._catch=n,this._connectionStatus=e.RCConnectionStatus.CONNECTED;break;case"onSuspend":this._connectionStatus=e.RCConnectionStatus.SUSPENDED;break;case"onDisconnected":this._connectionStatus=e.RCConnectionStatus.DISCONNECTED;break;case"onConnecting":this._connectionStatus=e.RCConnectionStatus.CONNECTING}this._send2AllRenderer(t,n,i)},n.prototype._callbackHandler=function(e){var t=e.reqId,o=e.data;this._callbackCache[t]&&this._send2Renderer(this._callbackCache[t],"__RC_CHANNEL_RESULT_FROM_MAIN__",t,o)},n.prototype._createServiceProxy=function(){var e=this,n=this._dbpath||r.resolve(t.app.getPath("userData"));if(this._runInMainProcess)this._cppServiceProcessProxy=new xe(this._appkey,n,this._logOutputLevel,this._enableSyncEmptyTopConversation,this._eventNotifyHandler.bind(this),this._callbackHandler.bind(this),this._disableLogReport);else{var i=o.fork(r.resolve(__dirname,"cppServiceProcess.js"),[this._appkey,n,this._enableSyncEmptyTopConversation.toString(),this._logOutputLevel.toString(),this._disableLogReport.toString()]);this._cppServiceProcessProxy=new ee(i,this._eventNotifyHandler.bind(this),this._callbackHandler.bind(this),(function(t,o){void 0===o&&(o=!1);var r="sub process exit, msg: "+t+", isRestart: "+o+", _isProcessQuit: "+e._isProcessQuit;if(console.error(r),o&&!e._isProcessQuit)return e._restartSubProcessProxy()}))}},n.prototype.destroy=function(){this._cppServiceProcessProxy.destroy()},n.prototype.setDataBaseLogConfig=function(e){this._cppServiceProcessProxy.call("setDataBaseLogConfig",e)},n}(),we=function(){function e(e,t,o,r,n,i){this._rcMain=new Le(e,t,o,r,n,i)}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._rcMain.destroy()},e.prototype.getDeviceId=function(){return this._rcMain.getMainCache().deviceId},e.prototype.getServerTime=function(){return this._rcMain.getMainCache().connectedTime},e.prototype.setDatabaseOperationTimeThreshold=function(e){return this._rcMain.setDataBaseLogConfig(e)},e}();module.exports=function(t){return function(t,o){if(be)return be;if(!t)throw new Error("Initializ failed, `appkey` is required!");return be=new we(t,(null==o?void 0:o.dbpath)||"",(null==o?void 0:o.logOutputLevel)||e.LogL.WARN,(null==o?void 0:o.runInMainProcess)||!1,!!(null==o?void 0:o.enableSyncEmptyTopConversation),(null==o?void 0:o.disableLogReport)||!1)}(t.appkey,t)};
|
|
1
|
+
"use strict";var e=require("@rongcloud/engine"),t=require("electron"),o=require("child_process"),r=require("path"),n=require("os"),i=require("http"),s=require("https"),a=require("zlib"),c=require("url"),u=require("net"),p=require("events"),d=require("tls"),l=require("fs"),f=require("crypto");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}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 g=C(n),v=h(a),_=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,m=function(){return m=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},m.apply(this,arguments)};function E(e,t,o,r){return new(o||(o=Promise))((function(n,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(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(s,a)}c((r=r.apply(e,t||[])).next())}))}function P(e,t){var o,r,n,i,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;s;)try{if(o=1,r&&(n=2&i[0]?r.return:i[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,i[1])).done)return n;switch(r=0,n&&(i=[2&i[0],n.value]),i[0]){case 0:case 1:n=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(n=s.trys,(n=n.length>0&&n[n.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!n||i[1]>n[0]&&i[1]<n[3])){s.label=i[1];break}if(6===i[0]&&s.label<n[1]){s.label=n[1],n=i;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(i);break}n[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{o=n=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function T(e,t,o){if(o||2===arguments.length)for(var r,n=0,i=t.length;n<i;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_DB_UPGRATE_START_S="P-db_upgrate_start-S",e.P_DB_UPGRATING_S="P-db_upgrating-S",e.P_DB_UPGRATE_COMPLETE_S="P-db_upgrate_complete-S",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_PARSE_JSON_MSGS_R="P-parse_json_messsages-R",e.P_RECEIVE_MESSAGE_E="P-receive_message-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_PARSE_JSON_SUBSCRIBE_DATA_E="P-parse_json_subscribe_data-E",e.P_PARSE_JSON_USER_PROFILE_E="P-parse_json_user_profile-E",e.P_PARSE_JSON_USER_PROFILE_LIST_E="P-parse_json_user_profile_list-E",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 U(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 b=200;function U(e,t){var o=R.queue,r=R.flushTimestamp;if(!(R.locked||0===o.length||Date.now()-r<3e4&&o.length<b)){R.locked=!0;var n=t.createTraceId(),i=t.getSessionId(),s=o.splice(0,b).map((function(e){var t=e.sessionId,o=e.level,r=e.time,n=e.type,s=e.tag,a=e.loggerId,c=e.content,u=e.traceId;return{level:o,time:r,type:n,tag:s,sessionId:i+":"+t,content:{loggerId:a,content:c,traceId:u}}}));t.debug(y.P_WRITE_LOG_T,"writingLen: "+s.length+", queueLen: "+o.length,n);var a=JSON.stringify(s);e.writeLog(a),t.debug(y.P_WRITE_LOG_R,"write done, queueLen: "+o.length,n),R.flushTimestamp=Date.now(),R.locked=!1,setTimeout((function(){return U(e,t)}))}}var x,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}(e.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}(e.BasicStatistic),A=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])},k=function(e){return"string"==typeof e},D=function(e){return k(e)?e.toUpperCase():""},J=function(e,t){var o="";return 2!==e.length?o="Unexpected number of bytes received.":5!==e[0]?o="Unexpected SOCKS version number: "+e[0]+".":255===e[1]?o="No acceptable authentication methods were offered.":-1===t.indexOf(e[1])&&(o="Unexpected SOCKS authentication method: "+e[1]+"."),o},G=function(e){var t="";return 2!==e.length?t="Unexpected number of bytes received.":1!==e[0]?t="Unexpected authentication method code: "+e[0]+".":0!==e[1]&&(t="Username and password authentication failure: "+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 i="";for(var s in i=t+" "+(o+n)+" HTTP/1.1\n",r){if(Object.hasOwnProperty.call(r,s))i+=s+": "+r[s]+"\n"}return e.body&&(i+="Content-Length: "+e.body.length+"\n"),i+="\n","POST"===t&&e.body&&(i+=""+e.body),i},B=function(e){return new Promise((function(t){var o,r;e.socket.once("data",(function(r){var n,i=J(r,o);if(!i)return 2===r[1]?(e.socket.once("data",(function(o){var r=G(o);r?e.emit("error",new Error("SOCKS authentication failed. "+r)):t()})),n=[1],A(e.socksUsername,n),A(e.socksPassword,n),void e.write(Buffer.from(n))):void t();e.emit("error",new Error("SOCKS authentication failed. "+i))})),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)}))},j=function(e,t,o){return new Promise((function(r){var n,i;switch(e.socket.once("data",(function(t){var o;5!==t[0]?o="Unexpected SOCKS version number: "+t[0]+".":0!==t[1]?o=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 "+e}}(t[1])+".":0!==t[2]&&(o="The reserved byte must be 0x00."),o?e.emit("error",new Error("SOCKS connection failed. "+o)):r()})),(n=[]).push(5),n.push(1),n.push(0),u.isIP(t)){case 0:n.push(3),A(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,(i=Buffer.from(n)).writeUInt16BE(o,i.length-2),e.write(i)}))},V=function(e){function t(t){var o=e.call(this)||this;return o.readable=!0,o.socket=new u.Socket,o.options=t,o.socksHost=t.socksHost||"localhost",o.socksPort=t.socksPort||1080,o.socksUsername=t.socksUsername||"",o.socksPassword=t.socksPassword||"",o.socket.on("error",(function(e){o.emit("error",e)})),o.on("error",(function(){o.socket.destroyed||o.socket.destroy()})),o.on("end",o.end),o}return 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: "+e);if(!t||"string"!=typeof t)throw new TypeError("Invalid host: "+t);return this.socket.connect({port:this.socksPort,host:this.socksHost},(function(){return E(o,void 0,void 0,(function(){var o;return P(this,(function(r){switch(r.label){case 0:return[4,B(this)];case 1:return r.sent(),[4,j(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}(p.EventEmitter),q=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 V(e).connect(r,o)},H=function(e){function t(t){var o=e.call(this)||this;return o.createConnection=q,o}return S(t,e),t}(i.Agent),K=function(e,t,o){return(t=m(m({},t),c.parse(e))).port||(t.port=80),t.agent=new H(t),i.request(t,o)},W=function(e){var t,o;return t=q(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},Q=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=W,r}return S(t,e),t}(s.Agent),Y=function(e,t,o,r){var n,i;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),i=new Q(e,t),t.agent=i,s.request(e,t,o)},X=null;function z(t,o,r){void 0===r&&(r=!1);var n=o.url,a=o.headers,c=o.body,u=o.method,p=o.query,d=o.timeout,l=void 0===d?e.HTTP_TIMEOUT:d;return new Promise((function(o){var d=/^https/.test(n),f={headers:m(m({},a),{"Accept-Encoding":"gzip, br"}),method:u};d&&(f.rejectUnauthorized=r);var h=null;X?((f=m(m({},f),X)).body=c,h=d?Y:K):(h=i.request,d&&(f.agent=new s.Agent(f),h=s.request));var C=h(e.appendUrl(n,p),f,(function(e){var t,r,n=e.statusCode,i="";if("gzip"===(null===(t=e.headers)||void 0===t?void 0:t["content-encoding"])){var s=v.default.createGunzip();e.pipe(s),s.on("data",(function(e){i+=e})),s.on("end",(function(){o({status:n,data:i})}))}else if("br"===(null===(r=e.headers)||void 0===r?void 0:r["content-encoding"])){var a=v.default.createBrotliDecompress();e.pipe(a),a.on("data",(function(e){i+=e})),a.on("end",(function(){o({status:n,data:i})}))}else e.setEncoding("utf8"),e.on("data",(function(e){i+=e})),e.once("end",(function(){o({status:n||0,data:i})}))}));C.once("timeout",(function(){t.warn(y.P_HTTP_REQ_E,JSON.stringify({msg:"timeout",url:n,method:u,query:p,timeout:l})),o({status:0})})),C.setTimeout(l),C.once("error",(function(e){t.warn(y.P_HTTP_REQ_E,JSON.stringify({msg:e.stack,url:n,method:u,query:p,timeout:l})),o({status:0})})),C.write(c),C.end()}))}function $(t,o){return t?(X=m(m({},X),t),o.info(e.LogTagId.A_SET_PROXY_O,JSON.stringify({msg:"set proxy",data:X})),{code:e.ErrorCode.SUCCESS}):(X=null,o.info(e.LogTagId.A_REMOVE_PROXY_O,JSON.stringify({msg:"remove proxy"})),{code:e.ErrorCode.SUCCESS})}function Z(){var t=X||void 0;return{code:e.ErrorCode.SUCCESS,data:t}}!function(e){e[e.ERROR=-1]="ERROR",e[e.RESPONSE=0]="RESPONSE",e[e.EVENT=1]="EVENT",e[e.CALLBACK=2]="CALLBACK"}(x||(x={}));var ee=function(){function t(t,o,r,n){var i=this;this.p=t,this.emit=o,this.callback=r,this.errorHandle=n,this.count=0,this.maps={},this.p.on("message",(function(e){var t=e.type,s=e.data;switch(t){case x.EVENT:var a=s,c=a.eventName,u=a.data;null==o||o.apply(void 0,T([c],u,!1));break;case x.RESPONSE:var p=s,d=p.reqId,l=p.success,f=p.data,h=i.maps[d];if(!h)return;h({success:l,data:f}),delete i.maps[d];break;case x.CALLBACK:null==r||r(s);break;case x.ERROR:var C=s.msg;null==n||n(C)}})),this.p.on("error",(function(e){null==n||n("SubProcessProxy error "+e)})),this.p.on("exit",(function(t,o){if(0!==t){for(var r in i.maps){if(Object.prototype.hasOwnProperty.call(i.maps,r))(0,i.maps[r])({success:!0,data:{code:e.ErrorCode.SUB_PROCESS_EXIT,msg:"sub process exit"}})}null==n||n("SubProcessProxy exit "+t+" "+o,!0)}})),this.p.on("close",(function(e,t){console.log("SubProcessProxy close",e,t)}))}return t.prototype.call=function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return this.p.killed||this.p.exitCode?[2,Promise.resolve({success:!1,data:{code:e.ErrorCode.SUB_PROCESS_EXIT,msg:"sub process exit"}})]:[2,new Promise((function(e){var n=++r.count;r.maps[n]=e;var i={reqId:n,method:t,args:o,hasResponse:!0};r.p.send(i)}))]}))}))},t.prototype.send=function(e){for(var t,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return E(this,void 0,void 0,(function(){var r;return P(this,(function(n){return(this.p.killed||this.p.exitCode)&&(null===(t=this.errorHandle)||void 0===t||t.call(this,"sub process exit")),r={reqId:-1,method:e,args:o},this.p.send(r),[2]}))}))},t.prototype.destroy=function(){this.send("destroy")},t}(),te=[],oe=!1,re=function(){return E(void 0,void 0,void 0,(function(){var t,o,r,n,i,s,a,c,u,p,d,l,f;return P(this,(function(h){return oe||0===te.length||(oe=!0,t=te.shift(),o=t.args,r=t.resolve,n=o.addon,i=o.startTime,s=o.endTime,a=o.level,c=o.realtimeReport,u=0,p=0,d=[],l=function(t){u+=t.length;var o=t.split(","),n=o[0],i=o[1],s=o[2],l=o[3],f=o[4],h=o.slice(5);if(u>e.REAT_TIME_LOG_SIZE&&parseInt(i,10)!==p)r(d);else{p=parseInt(i,10);try{if(!c&&a<0)return;var C={time:parseInt(i,10),level:parseInt(l,10),sessionId:n,type:s,tag:f,content:h.join(",")};d.push(C)}catch(e){console.error(e)}}},f=function(e){r(d),oe=!1,re()},n.getFullLog(a,i,s,!1,l,f)),[2]}))}))},ne=function(t){function n(o,r,n,i,s){void 0===s&&(s=!1);var a="Electron|"+process.versions.electron+"|"+process.arch+"|"+process.platform;return t.call(this,r,n,a,{getLogs:function(e,t,r,n){return E(this,void 0,void 0,(function(){return P(this,(function(i){switch(i.label){case 0:return[4,(s={startTime:e,endTime:t,level:r,realtimeReport:n,addon:o},E(void 0,void 0,void 0,(function(){return P(this,(function(e){return[2,new Promise((function(e){te.push({resolve:e,args:s}),re()}))]}))})))];case 1:return[2,{logs:i.sent(),dbReady:!0}]}var s}))}))},getTimestamp4RealtimeLog:function(){var t=o.getStoreValue(e.StoreKeys.REALTIME_LOG_TIMESTAMP);return parseInt(t,10)||0},setTimestamp4RealtimeLog:function(t){o.setStoreValue(e.StoreKeys.REALTIME_LOG_TIMESTAMP,t.toString())}},i,s)||this}return S(n,t),n.prototype.send=function(e){return z(this.logger,e)},n.prototype.stop=function(){this._subProcess&&this._subProcess.destroy(),t.prototype.stop.call(this)},n.prototype.compressLogs=function(e){return E(this,void 0,void 0,(function(){var t,n,i,s;return P(this,(function(a){switch(a.label){case 0:return this._subProcess||(t=o.fork(r.resolve(__dirname,"sub-process.js")),this._subProcess=new ee(t)),[4,this._subProcess.call("compressLogs",e)];case 1:return n=a.sent(),i=n.success,s=n.data,i?[2,{success:i,data:s.data}]:[2,{success:i,data:""}]}}))}))},n}(e.BasicReporter),ie=[e.EConnectProtocol.RMTP,e.EConnectProtocol.TLS];"darwin"===process.platform&&ie.push(e.EConnectProtocol.QUIC);var se=function(e){return"RongCloud/navis/"+e+"/navi-cache.json"},ae="deviceId",ce=function(e){return"RongCloud/caches/"+e+"/staticConfig.json"},ue=function(e){return"RongCloud/cloudControl/"+e+"/cloudControl.json"},pe=null,de=function(){var e,t=Date.now(),o=[n.arch(),n.platform(),process.pid,t,Math.floor(Math.random()*t)].join("__");return e=o,f.createHash("md5").update(e).digest("hex")},le=function(e){if(pe)return pe;var t=r.resolve(e,ae);return l.existsSync(t)?pe=l.readFileSync(t).toString():(pe=de(),l.writeFileSync(t,pe),pe)},fe=function(){function e(e){this._callCppProxy=e,this._setTime=15962112e5}return e.prototype._setToProtocol=function(e,t,o,r,n,i){var s=JSON.stringify(n);"{}"!==s&&e.info(y.P_SET_MSG_EXTEN_O,JSON.stringify({messageUId:r,ext:n})),this._callCppProxy("setMessageExtension",t,o,r,s,i)},e.prototype.setLocalFromReceiveMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,i=t.messageUId,s=t.expansion,a=t.sentTime;if(s&&0!==Object.keys(s).length){var c={};for(var u in s)c[u]={v:"",ts:0},c[u].v=s[u],c[u].ts=a;this._setToProtocol(e,r,n,i,c,o||"")}},e.prototype.setLocalFromExtMsg=function(e,t){var o=t.channelId,r=t.conversationType,n=t.targetId,i=t.content,s=t.sentTime,a=i,c=a.put,u=this._callCppProxy("getMessage",a.mid),p=JSON.parse(u).extMsg,d=JSON.parse(p||"{}");if(c)for(var l in c){var f=d[l];f&&f.ts<s-this._setTime?(f.v=c[l],f.ts=s-this._setTime):(d[l]={v:"",ts:0},d[l].v=c[l],d[l].ts=s-this._setTime)}a.del&&a.del.forEach((function(e){delete d[e]})),this._setToProtocol(e,r,n,a.mid,d,o||"")},e.prototype.parseReceiveExpansion=function(e){var t=JSON.parse(e.extMsg||"{}"),o={};for(var r in t)o[r]=t[r].v;return o},e.prototype.parseConverOrHisExpansion=function(e){var t=JSON.parse(e.extMsg),o=JSON.parse(t||"{}"),r={};for(var n in o)r[n]=o[n].v;return r},e}();function he(e){void 0===e&&(e="IPv4");for(var t=n.networkInterfaces(),o=[],r=0,i=Object.values(t);r<i.length;r++){var s=i[r];if(s&&-1!==Object.prototype.toString.call(s).indexOf("Array")){var a=s.filter((function(t){return!(t.internal||(o=t.mac,/^(0{1,2}[:-]){5}0{1,2}$/.test(o))||t.family&&t.family!==e);var o})).map((function(e){return e.mac}));o.push.apply(o,a)}}return o.length?T([],o,!0).sort()[0]:""}var Ce,ge=function(e,t,o){return E(void 0,void 0,void 0,(function(){var r,n;return P(this,(function(i){return r=f.createDecipheriv("aes-256-cbc",t,o),n=r.update(e,"base64","utf-8"),[2,n+=r.final("utf8")]}))}))},ve=function(e){if(!l.existsSync(e)){var t=r.resolve(e,"..");l.existsSync(t)||ve(t),l.mkdirSync(e)}},_e=function(e){return Object.entries(e).map((function(e){var t=e[0],o=e[1];return{key:t,value:String(o)}}))},Se=function(e){return{removeMute:!!(null==e?void 0:e.removeMuteStatus),removeWhiteList:!!(null==e?void 0:e.removeWhiteList),removeFavoriteMembers:!!(null==e?void 0:e.removeFollow)}},ye=function(t){function o(e,o,n,i,s){var a=t.call(this,e,o,n,s)||this;a.naviPath="",a._caches={},a.naviPath=i+"/"+se(e);var c=r.dirname(a.naviPath);return l.existsSync(c)||ve(c),a}return S(o,t),o.prototype.httpRequest=function(t,o,r,n){return E(this,void 0,void 0,(function(){var i,s,a,c,u;return P(this,(function(p){switch(p.label){case 0:return i="token="+encodeURIComponent(r)+"&v="+e.FORMATED_VERSION+"&p=PC&ev=5.12.4&m="+he(),s=t+"/navi.json?r="+Date.now()+"&env="+this._environment,this.logger.info(e.LogTagId.L_REQUEST_T,JSON.stringify({url:s,body:i}),n),[4,z(this.logger,{method:"POST",headers:{appId:o},body:i,url:s,timeout:e.NAVI_REQ_TIMEOUT})];case 1:if(200!==(a=p.sent()).status)return this.logger.warn(e.LogTagId.L_REQUEST_R,JSON.stringify({url:s,code:a.status}),n),[2,{code:this.transHttpCode(a.status)}];this.logger.info(e.LogTagId.L_REQUEST_R,JSON.stringify({url:s,data:a.data}),n);try{return c=JSON.parse(a.data),u=/^https/.test(s)?"https":"http",c.protocol=u,c.code&&200!==c.code?[2,{code:this.transHttpCode(c.code)}]:[2,{code:e.ErrorCode.SUCCESS,data:c}]}catch(t){return this.logger.error(e.LogTagId.L_PARSE_NAVI_E,a.data,n),[2,{code:e.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},o.prototype.httpRequestV2=function(t,o,r,n){return E(this,void 0,void 0,(function(){var i,s,a,c;return P(this,(function(u){switch(u.label){case 0:return i=this.getNaviV2RequestOption({appkey:o,token:r,uri:t,platform:"electron",protocol:ie.join(","),mac:he()}),this.logger.info(e.LogTagId.L_REQUEST_T,JSON.stringify({url:i.url,body:i.body,headers:i.headers}),n),[4,z(this.logger,i)];case 1:if(200!==(s=u.sent()).status)return this.logger.warn(e.LogTagId.L_REQUEST_R,JSON.stringify({url:i.url,code:s.status}),n),[2,{code:this.transHttpCode(s.status)}];this.logger.info(e.LogTagId.L_REQUEST_R,JSON.stringify({url:i.url,data:s.data}),n);try{return a=JSON.parse(s.data),c=/^https/.test(i.url)?"https":"http",a.protocol=c,[2,{code:e.ErrorCode.SUCCESS,data:a}]}catch(t){return this.logger.error(e.LogTagId.L_PARSE_NAVI_E,s.data,n),[2,{code:e.ErrorCode.RC_NAVI_REQ_FAILED}]}return[2]}}))}))},o.prototype.getNaviCache=function(t){var o=this.getCatchKey(t),r=this._caches[o];if(r)return r;if(!l.existsSync(this.naviPath))return null;var n=l.readFileSync(this.naviPath,{encoding:"utf8"});try{return this._caches=JSON.parse(n),this._caches[o]}catch(t){this.logger.error(e.LogTagId.L_PARSE_NAVI_E,n)}return null},o.prototype.setNaviCache=function(t,o){var r=Date.now(),n=this.getCatchKey(t);if(e.notEmptyObject(this._caches))for(var i in this._caches){(r-this._caches[i].timestamp>e.NAVI_CACHE_DURATION||n===i)&&delete this._caches[i]}this._caches[n]={token:t,naviInfo:o,timestamp:Date.now(),environment:this._environment},l.writeFileSync(this.naviPath,JSON.stringify(this._caches))},o.prototype.setEnvironment=function(e){this._environment=e},o}(e.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"}(Ce||(Ce={}));var me,Ee=function(t){function o(o,r,n,i,s,a){var c=t.call(this,o,n,i,s,a)||this;return c.callCppProxy=r,c._connectedTime=0,c._naviInfo=null,c._excludeLogTag=["P-API_RCGetValueForKey-T","P-API_RCGetValueForKey-E","P-API_RCGetValueForKey-R","P-API_RCSetValueForKey-T","P-API_RCSetValueForKey-E","P-API_RCSetValueForKey-R"],c.connectResolve=null,c._startTime=0,c._tcpDuration=0,c.pingResolve=null,c.callCppProxy("setConnectionStatusListener",c._onConnectionStatusChange.bind(c),(function(e){c.logger.info(y.P_DB_OPEN_O,e)}),(function(){return c.recvPong(e.ErrorCode.SUCCESS)}),c._onConnectionStatusChange.bind(c),c._onTcpConnectResponse.bind(c),(function(){var e;c.logger.info(y.P_DB_UPGRATE_START_S),null===(e=a.onDBUpgrateStart)||void 0===e||e.call(a)}),(function(e){var t;c.logger.info(y.P_DB_UPGRATING_S,e),null===(t=a.onDBUpgrading)||void 0===t||t.call(a,e)}),(function(e){var t;c.logger.info(y.P_DB_UPGRATE_COMPLETE_S,e),null===(t=a.onDBUpgradeComplete)||void 0===t||t.call(a,e)})),c}return S(o,t),o.prototype.getConnectedTime=function(){return this._connectedTime},o.prototype.connectWithToken=function(t,o,r,n){var i=this;return new Promise((function(s){i._naviInfo=o,i.connectResolve={resolve:s,traceId:n,userId:o.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(m(m({},a),{call_plus:i._openCallPlus})),p=i.getCmpList(o,!0).filter((function(e){return ie.includes(e.protocol)})).sort((function(e,t){return e.weight>t.weight?-1:1})),d=[];p.forEach((function(t){var o=d.find((function(e){return e.addr===t.addr}));o?o.protocol!==e.EConnectProtocol.QUIC&&t.protocol!==e.EConnectProtocol.QUIC||(o.race=!0,o.protocol=e.EConnectProtocol.QUIC):(t.race=!1,d.push(t))})),i.logger.info(y.P_CONNECT_O,JSON.stringify({use:d,catche:i.cmpWeightCache,proxy:a,FORMATED_VERSION:e.FORMATED_VERSION,reconnectKickEnable:r}),n),i._startTime=Date.now();try{i.callCppProxy("connectWithToken",t,e.FORMATED_VERSION,JSON.stringify(m(m({},o),{serverAddr:d,tagBlacklist:i._excludeLogTag.join(",")})),r,u)}catch(t){i.logger.error(y.P_CALL_ADDON_E,null==t?void 0:t.stack,n),i.recvConnectRes(e.ErrorCode.RC_SOCKET_NOT_CREATED)}}))},o.prototype.close=function(e,t){void 0===t&&(t=!0),e||this.callCppProxy("disconnect",t)},o.prototype.sendPing=function(t){var o=this;return new Promise((function(r){o.pingResolve=r,o.callCppProxy("sendHeartbeat"),setTimeout((function(){return o.recvPong(e.ErrorCode.TIMEOUT)}),t)}))},o.prototype.recvPong=function(e){this.pingResolve&&(this.pingResolve(e),this.pingResolve=null)},o.prototype._onConnectionStatusChange=function(t,o){switch(this.logger.info(y.P_CONNECT_S,JSON.stringify({status:t,delay:o})),t){case e.ErrorCode.SUCCESS:this.recvConnectRes(e.ErrorCode.SUCCESS);break;case e.ErrorCode.RC_CONN_REDIRECTED:case 32061:this.recvConnectRes(e.ErrorCode.RC_CONN_REDIRECTED,!0);break;case 11:case 10:case 12:break;case e.ErrorCode.RC_SOCKET_DISCONNECTED:this.recvConnectRes(t,!1);break;case e.ErrorCode.RC_SOCKET_NOT_CREATED:case e.ErrorCode.RC_CONN_ACK_TIMEOUT:case e.ErrorCode.RC_TCP_RESET:this.recvConnectRes(t);break;case e.ErrorCode.RC_UDP_DISCONNECTED:this.recvConnectRes(t,!0,o);break;default:this.recvConnectRes(t,!0)}},o.prototype.recvConnectRes=function(t,o,r){if(this.connectResolve){var n=this.connectResolve,i=n.resolve,s=n.userId,a=Date.now()-(this._startTime+this._tcpDuration),c={bid:e.getbundleId(),cod:t,net:this.getNetwork().type,dur:a,spr:0,cid:this.uuid+"_"+this.retryCount,v:e.StatisticsVersion.CURRENT,count:this.retryCount};return this.statisticLog.record(e.StatisticsTag.IM_CMP_RMTP,JSON.stringify(c)),t===e.ErrorCode.SUCCESS&&(this._connectedTime=Date.now()-this.callCppProxy("getDeltaTime")),i({code:t,data:s}),void(this.connectResolve=null)}if(o)this.onDisconnectByServer(t,r);else{if(t===e.ErrorCode.RC_SOCKET_DISCONNECTED)if(this.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED)return;this.onDisconenctUnusual(t)}},o.prototype._onTcpConnectResponse=function(t,o,r,n,i,s,a){var c,u=this.cmpWeightCache.findIndex((function(e){return e.addr===o+":"+r})),p={bid:e.getbundleId(),ptc:e.ProtocalType.TCP,cod:t,net:this.getNetwork().type,dur:n,spr:0,pr:(null===(c=this._naviInfo)||void 0===c?void 0:c.type)||0,hos:o+":"+r,idx:u,rct:this.retryCount?e.ConnectType.RECONNECT:e.ConnectType.CONNECT,cid:this.uuid+"_"+this.retryCount,v:e.StatisticsVersion.CURRENT,rsn:this.reason,ddu:i,count:this.retryCount,weight:u>=0?this.cmpWeightCache[u].weight:-1};if(this.statisticLog.record(e.StatisticsTag.IM_CMP,JSON.stringify(p)),this.logger.info(y.P_CONNECT_ENTRY_S,JSON.stringify({code:t,host:o,port:r,duration:n,dnsDuration:i,index:s,isQuic:a})),t===Ce.SUCCESS)this.curCmpUrl=o+":"+r,this.updateCmpWeight(o+":"+r,!0,a);else if(t!==Ce.NOT_INIT){var d=r&&0!==r?o+":"+r:""+o;this.updateCmpWeight(d,!1)}},o}(e.AConnectionMgr),Pe=function(t){function o(e,o,n){var i=t.call(this,e,o)||this;i.appkey=e,i.logger=o,i.dbpath=n,i._cachePath="",i._cachePath=n+"/"+ce(e);var s=r.dirname(i._cachePath);return l.existsSync(s)||ve(s),i}return S(o,t),o.prototype.getCache=function(){return l.existsSync(this._cachePath)&&l.readFileSync(this._cachePath,{encoding:"utf8"})||null},o.prototype.setCache=function(e){l.writeFileSync(this._cachePath,e)},o.prototype.clearCache=function(){l.writeFileSync(this._cachePath,"")},o.prototype.sendRequest=function(e){return E(this,void 0,void 0,(function(){var t,o,r;return P(this,(function(n){switch(n.label){case 0:return[4,z(this.logger,{url:e,body:""})];case 1:return t=n.sent(),o=t.status,r=t.data,[2,{code:o,data:r}]}}))}))},o.prototype.decryptData=function(t){return E(this,void 0,void 0,(function(){var o,r;return P(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,ge(t,e.STATIC_CONFIG_KEY,e.STATIC_CONFIG_IV)];case 1:return o=n.sent(),[2,JSON.parse(o)];case 2:return r=n.sent(),this.logger.error(e.LogTagId.L_GET_STATIC_CONF_E,JSON.stringify({error:null==r?void 0:r.stack})),[3,3];case 3:return[2]}}))}))},o}(e.BasicStaticConfigManager),Te=function(t){function o(e,o,n,i,s,a,c){var u=t.call(this,o,e,n,a)||this;u.deviceId=i,u.model="",u.catchFilePath="",u.addon=c,u.model="Electron|"+process.platform+"|"+process.arch,u.catchFilePath=s+"/"+ue(e);var p=r.dirname(u.catchFilePath);return l.existsSync(p)||ve(p),u.init(),u}return S(o,t),o.prototype.httpRequest=function(t,o,r,n){return E(this,void 0,void 0,(function(){var i,s,a,c,u,p,d,l;return P(this,(function(f){switch(f.label){case 0:return(i=n).deviceId=this.deviceId,i.model=this.model,s={url:t,method:o,headers:r,body:JSON.stringify(i)},this.logger.info(e.LogTagId.L_REQUEST_T,JSON.stringify(s)),[4,z(this.logger,s)];case 1:a=f.sent(),c=a.status,u=a.data,p=void 0===u?"":u,this.logger.info(e.LogTagId.L_REQUEST_R,JSON.stringify({status:c,data:p}));try{return d=JSON.parse(p),l=d.data,[2,{code:c,data:l}]}catch(t){return this.logger.warn(e.LogTagId.L_CLOUD_CONFIG_DATA_E,JSON.stringify({status:c,data:p,error:t})),[2,{code:c,msg:t}]}return[2]}}))}))},o.prototype.setCloudControllerCache=function(t){l.writeFileSync(this.catchFilePath,JSON.stringify(t)),this.logger.info(e.LogTagId.L_CLOUD_SET_CACHE_O,JSON.stringify(t))},o.prototype.getLocalCloudControllerCache=function(){if(!l.existsSync(this.catchFilePath))return null;var t=l.readFileSync(this.catchFilePath,{encoding:"utf8"});return this.logger.info(e.LogTagId.L_CLOUD_GET_CACHE_O,JSON.stringify({appkey:this.appkey,data:t})),t},o.prototype.setMRTRConfig=function(t){var o={mrtrChatroom:t.chatroom,mrtrGroup:t.group,mrtrPrivate:t.private,mrtrUltraGroup:t.ultraGroup};this.logger.info(e.LogTagId.L_CLOUD_SET_MRTR_O,JSON.stringify(o)),this.addon.setCloudConfig(JSON.stringify(o))},o}(e.BaseCloudController);!function(e){e[e.cuid=1]="cuid",e[e.uid=2]="uid",e[e.all=4]="all"}(me||(me={}));var Ie,Re=function(){function t(t,o,r,n,i,s,a){var c=this;this._appkey=t,this._cppProtocol=o,this._dbpath=r,this._dispatchEvent=n,this._enableSyncEmptyTopConversation=i,this._logOutputLevel=s,this._customMessageType={},this.cloudControllerUri="",this.cloudControllerLock=!0,this.cloudControllerMsgs=[],this._buildSubscribeEventData=function(t){var o=[];try{JSON.parse(t).list.forEach((function(t){var r=JSON.parse(t.obj),n=r.userId,i=r.subscribeType,s=r.subscribeTime,a=r.duration,u=r.operationType,p=r.details,d=void 0===p?[]:p,l=r.userProfile,f={userId:n,subscribeType:i,subscribeTime:s,expiry:a,operationType:u};[e.SubscribeType.ONLINE_STATUS,e.SubscribeType.FRIEND_ONLINE_STATUS].includes(i)&&(f.details=d.map((function(e){var t=JSON.parse(e);return{changeTime:t.changeTime,eventValue:t.changeValue,platform:t.platform}}))),[e.SubscribeType.USER_PROFILE,e.SubscribeType.FRIEND_USER_PROFILE].includes(i)&&(f.userProfile=c._string2userProfileInfo(l)),o.push(f)}))}catch(e){c.logger.error(y.P_PARSE_JSON_SUBSCRIBE_DATA_E,JSON.stringify({error:null==e?void 0:e.stack,data:t}))}return o},this._chatroomCache=[],this.rtcHeartbeatResolves={};var u=this._dbpath,p=le(u);this.logger=new L(this._appkey,"RC-M","IM"),this._cppProtocol.initWithAppkey(t,u,e.FORMATED_VERSION,this.logger.getSessionId()),this._cppProtocol.setConsoleLogLevel((this._logOutputLevel||e.LogL.WARN)+1),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,t,p,this.logger,a),this.logger.info(y.P_INIT_O,JSON.stringify({appkey:t,dbpath:u,proto_commit:this._cppProtocol.getNodeVersion(),deviceId:p,commit:"15c70e524b4791db3eb5b654a6368fce0d9438ab",processName:process.title,processPId:process.pid,disableLogReport:a})),this._callCppProxy("setDeviceId",p),this._staticConfigManager=new Pe(t,this.logger,u),this.navi=new ye(t,this.logger,this.statisticLog,u,this._staticConfigManager),this.tcpMgr=new Ee(t,this._callCppProxy.bind(this),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),onDBUpgrateStart:this.dbUpgradeStart.bind(this),onDBUpgrading:this.dbUpgrading.bind(this),onDBUpgradeComplete:this.dbUpgradeComplete.bind(this)}),this._enableCreateEmptyTopConversation(this._enableSyncEmptyTopConversation),this._initCloudController(p,u),this._registerMsgTypes(),this._setOnReceiveMessageListener(),this._setConversationStatusListener(),this._setPushNotificationListener(),this._setRTCHeartbeatListener(),this._setRTCLivingRoomEventListener(),this._setChatroomEventListener(),this._setCallInfoListener(),this._setSubscribeEventListener(),this._setUserProfileListener(),this._setEntrustGroupListener(),this._setFriendEventListener(),this._msgExpansionHandler=new fe(this._callCppProxy.bind(this))}return t.prototype._initCloudController=function(t,o){var r=e.urlCenter.getCloudControllerUrl();this.cloudControllerUri=r[0],this.cloudController=new Te(this._appkey,this.logger,this.reporter,t,o,this.statisticLog,this._cppProtocol),e.isStartCloudController()&&this.cloudControllerUri&&this.cloudController.request(this.cloudControllerUri,e.InvokerType.init)},t.prototype.callProxy=function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];return E(this,void 0,void 0,(function(){var r,n,i;return P(this,(function(s){switch(s.label){case 0:if(!(r=this[t]))return this.logger.warn(y.P_CALL_MAIN_E,JSON.stringify({method:t,error:"not found"})),[2,Promise.resolve({code:e.ErrorCode.NOT_SUPPORT})];n="",s.label=1;case 1:return s.trys.push([1,3,,4]),[4,r.call.apply(r,T([this],o,!1))];case 2:return[2,s.sent()];case 3:return i=s.sent(),n=JSON.stringify({error:null==i?void 0:i.stack,method:t}),this.logger.error(y.P_CALL_MAIN_E,n),[3,4];case 4:return[2,{code:e.ErrorCode.MAIN_PROCESS_ERROR,msg:n}]}}))}))},t.prototype.sendProxy=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return E(this,void 0,void 0,(function(){var o;return P(this,(function(r){if(!(o=this[e]))return this.logger.warn(y.P_CALL_MAIN_E,JSON.stringify({method:e,error:"not found"})),[2];try{o.call.apply(o,T([this],t,!1))}catch(t){this.logger.error(y.P_CALL_MAIN_E,JSON.stringify({error:null==t?void 0:t.stack,method:e}))}return[2]}))}))},t.prototype.registerRenderers=function(t){var o=t.navigators,r=t.areaCode,n=t.logServerUrl,i=t.environment;this._environment=i||"default",this.navi.setEnvironment(i),e.urlCenter.init({areaCode:r,navigators:o,logServerUrl:n})},t.prototype.onConnected=function(){return E(this,void 0,void 0,(function(){var e,t,o;return P(this,(function(r){switch(r.label){case 0:return e=this.getNaviInfoFromCache(),this.reporter.checkStart(e),this._try2RejoinChatroom(),t=this._dispatchEvent,o=["onConnected"],[4,this.getMainProcessCache()];case 1:return t.apply(this,o.concat([r.sent()])),[2]}}))}))},t.prototype.onConnecting=function(){this._dispatchEvent("onConnecting",void 0)},t.prototype.onSuspend=function(e){this._dispatchEvent("onSuspend",e)},t.prototype.onDisconnected=function(e){this._dispatchEvent("onDisconnected",e)},t.prototype.dbUpgradeStart=function(){this._dispatchEvent("databaseUpgradeWillStart")},t.prototype.dbUpgrading=function(e){this._dispatchEvent("databaseUpgrading",e)},t.prototype.dbUpgradeComplete=function(e){this._dispatchEvent("databaseUpgradeDidComplete",e)},t.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){throw this.logger.error(y.P_CALL_ADDON_E,JSON.stringify({stack:null==t?void 0:t.stack,method:e}),n),t}},t.prototype.refetchNaviInfo=function(){return this.navi.request(this.tcpMgr.getToken(),!0,!0,this.logger.createTraceId())},t.prototype.sendHTTPRequest=function(e){return z(this.logger,e)},t.prototype.onRendererLogsReceived=function(e){M.apply(void 0,e)},t.prototype.onRendererNetworkStatusReceived=function(t,o){if(this.tcpMgr.setNetwork(t,o),t.status&&e.isStartCloudController()&&this.cloudController){var r=this.tcpMgr.getToken();this.cloudController.request(this.cloudControllerUri,e.InvokerType.newWorkChange,r)}},t.prototype.destroy=function(){this.reporter.stop(),this._cppProtocol,O(),this._cppProtocol.destroy(),process.exit(0)},t.prototype.callExtra=function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];var n=this[t];if(!n)return this.logger.warn(y.P_CALL_EXTRA_E,JSON.stringify({method:t,error:"not found"})),Promise.resolve({code:e.ErrorCode.NOT_SUPPORT});try{return n.call.apply(n,T([this],o,!1))}catch(e){this.logger.error(y.P_CALL_EXTRA_E,JSON.stringify({error:null==e?void 0:e.stack,method:t}))}return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})},t.prototype.getConversationsByPage=function(t,o,r,n,i){var s,a=this,c=this._callCppProxy("getConversationListByPageWithTopPriority",t,o,r,i||!1,n||"");try{s=JSON.parse(c).list.map((function(e){return a._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:s})},t.prototype.getUnreadConversationList=function(t){var o,r=this,n=this._callCppProxy("getUnreadConversationList",t);try{o=JSON.parse(n).list.map((function(e){return r._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:o})},t.prototype.getConversationListWithAllChannel=function(){var t,o=this,r=[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.APP_PUBLIC_SERVICE,e.ConversationType.PUBLIC_SERVICE],n=this._callCppProxy("getConversationListWithAllChannel",r);try{t=JSON.parse(n).list.map((function(e){return o._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:t})},t.prototype.getConversationListWithAllChannelByPage=function(t,o){var r,n=this,i=[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.APP_PUBLIC_SERVICE,e.ConversationType.PUBLIC_SERVICE],s=this._callCppProxy("getConversationListWithAllChannelByPage",i,t,o);try{r=JSON.parse(s).list.map((function(e){return n._buildConversation(e.obj)}))}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:r})},t.prototype.getHistoryMessagesByObjectNames=function(t,o,r,n,i,s,a){var c=0===s,u=n+1,p=this._callCppProxy("getHistoryMessagesByObjectNames",t,o,r,u,i,c,a||""),d=[];try{var l=JSON.parse(p).list;l.reverse();for(var f=0;f<l.length;f++){var h=this._buildMessage(l[f].obj);d[f]=h}}catch(t){return Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:{list:u===d.length?d.slice(1,u):d,hasMore:n<d.length}})},t.prototype.updateMessageReceiptStatus=function(t,o,r,n){void 0===n&&(n="");var i=this._callCppProxy("updateMessageReceiptStatus",t,o,r,n);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:i})},t.prototype.getNaviInfoFromCache=function(){return this.tcpMgr.getConnectionStatus()!==e.RCConnectionStatus.CONNECTED?null:this.navi.getNaviInfoFromCache(this.tcpMgr.getToken())},t.prototype.createLogger=function(e,t){return/^RC/.test(e)?null:new L(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.getMainProcessCache=function(){var e=this.tcpMgr.getConnectedTime(),t=this.tcpMgr.getConnectionStatus(),o=this.getNaviInfoFromCache(),r=this.tcpMgr.getCurrentUserId(),n=this.getDeviceId(),i=this._cppProtocol.getDeltaTime();return Promise.resolve({connectedTime:e,deviceId:n,crtUserId:r,naviInfo:o,connectionStatus:t,deltaTime:i})},t.prototype._enableCreateEmptyTopConversation=function(e){this._callCppProxy("enableCreateEmptyTopConversation",e)},t.prototype._registerMsgTypes=function(){for(var t in e.SEND_MESSAGE_TYPE_OPTION["RC:RcCmd"]={isCounted:!1,isPersited:!1},e.SEND_MESSAGE_TYPE_OPTION){var o=e.SEND_MESSAGE_TYPE_OPTION[t],r=o.isCounted,n=o.isPersited,i=o.searchProps,s=0;n&&(s|=1),r&&(s|=2),"RC:TypSts"===t&&(s=16),this._callCppProxy("registerMessageType",t,s,i||[])}},t.prototype._buildIsMentioned=function(t,o){var r,n=!1;if(e.isObject(t))r=t;else try{r=t?JSON.parse(t):t}catch(e){r=t,this.logger.error(y.P_PARSE_JSON_MSGS_E,JSON.stringify({content:t}))}return e.isObject(r)&&(n=!!r.mentionedInfo),{isMentioned:n,msgContent:r}},t.prototype._buildMsgOption=function(t){var o={isCounted:!1,isPersited:!1};return t in e.SEND_MESSAGE_TYPE_OPTION?o=e.SEND_MESSAGE_TYPE_OPTION[t]:t in this._customMessageType&&(o=this._customMessageType[t]),o},t.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},t.prototype._handleReadReceiptRequest=function(e){var t=JSON.parse(e),o=this.getNaviInfoFromCache();if(!(null==o?void 0:o.grpRRVer))return t;var r=t,n=r.hasRespond,i=r.readerInfo,s=void 0===i?{}:i,a=r.readCount,c=r.totalCount,u=r.readerList,p=void 0===u?[]:u,d={readCount:a,totalCount:c};if(1===(null==o?void 0:o.grpRRVer)){var l=[];for(var f in s)l.push({userId:f,readTime:s[f]});d.readerList=l,d.hasRespond=n}return 3===(null==o?void 0:o.grpRRVer)&&(d.readerList=p),d},t.prototype._buildMessage=function(t,o){var r;void 0===o&&(o={});var n=o.isOffLineMessage,i=o.buildFrom,s=JSON.parse(t),a=s.channelId,c=s.conversationType,u=s.targetId,p=s.senderUserId,d=s.content,l=s.objectName,f=s.messageUid,h=s.direction,C=s.status,g=s.messageId,v=s.sentTime,_=s.readReceiptRequest,S=s.supportExt,y=s.pushContent,E=s.pushTitle,P=s.pushId,T=s.pushConfig,I=s.templateId,R=s.disableTitle,O=s.forcePushDetail,N=s.hasMore,M=s.directedUsers,b=s.noNotification,U=s.disableUpdateLastMessage,x=this._buildIsMentioned(d,g),L=x.isMentioned,w=x.msgContent,A=this._buildMsgOption(l),k=this._buildSupportExt(S,i,s),D=e.isUndefined(n)?v<this.tcpMgr.getConnectedTime():n,J={};T&&(J=e.pushJSONToConfigs(this.logger,T,P));var G=m(m({},J),{pushTitle:E,pushContent:y,pushData:y,disablePushTitle:R,forceShowDetailContent:O,templateId:I}),F={channelId:a,conversationType:c,targetId:u,senderUserId:p,content:w||{},messageType:l,messageUId:f||"",messageDirection:h,isOffLineMessage:D,sentTime:v,receivedTime:0,isPersited:A.isPersited,isCounted:A.isCounted,isMentioned:L,disableNotification:b,isStatusMessage:(null===(r=this._customMessageType[l])||void 0===r?void 0:r.isStatusMessage)||!1,canIncludeExpansion:S,expansion:S?k:null,receivedStatus:C,receivedStatusInfo:e.transformReceivedStatusInfo(C),messageId:g,pushConfig:G,hasMore:N,directedUserIds:M||[],disableUpdateLastMessage:U};if(h===e.MessageDirection.RECEIVE?F.receivedStatus=this._compatibleReceivedStatus(F.receivedStatusInfo):h===e.MessageDirection.SEND&&(F.sentStatus=C),_){var B=this._handleReadReceiptRequest(_);F.readReceiptInfo=B}return F},t.prototype._compatibleReceivedStatus=function(t){var o=e.ReceivedStatus.UNREAD;return t.isRead?o=e.ReceivedStatus.READ:t.isListened?o=e.ReceivedStatus.LISTENED:t.isDownload?o=e.ReceivedStatus.DOWNLOADED:t.isRetrieved&&(o=e.ReceivedStatus.RETRIEVED),o},t.prototype._updateReadReceiptInfo=function(e,t){var o=this._callCppProxy("getMessage",e),r=JSON.parse(o),n=r.readReceiptRequest?JSON.parse(r.readReceiptRequest):{},i=m(m({},n),t);this._callCppProxy("updateReadReceiptRequestInfo",e,JSON.stringify(i))},t.prototype._processRRRspMsg=function(e,t,o){if(t!==this.getCurrentUserId())for(var r=0,n=e[this.getCurrentUserId()]||[];r<n.length;r++){h=n[r];var i=this._callCppProxy("getMessage",h),s=JSON.parse(i),a=s.readReceiptRequest?JSON.parse(s.readReceiptRequest):{},c=a.isReceiptRequestMessage,u=a.readerList,p=void 0===u?[]:u;c&&!p.includes(t)&&(p.push(t),this._callCppProxy("updateReadReceiptRequestInfo",h,JSON.stringify({isReceiptRequestMessage:c,readerList:p})))}else for(var d in e)for(var l=0,f=e[d];l<f.length;l++){var h=f[l];this._callCppProxy("updateReadReceiptRequestInfo",h,JSON.stringify({isReceiptRequestMessage:!0,hasRespond:!0}))}},t.prototype._processRSMsg=function(t){var o=t.conversationType,r=t.targetId,n=t.content,i=t.channelId,s=n.msgId,a=n.rrn,c=n.tmn,u=n.endMsgTime;o===e.ConversationType.PRIVATE?this.updateMessageReceiptStatus(o,r,u,i||""):this._updateReadReceiptInfo(s,{readCount:a,totalCount:c});var p={conversationType:o,targetId:r,channelId:i};this._sendMessageReadReceipt(o===e.ConversationType.PRIVATE?{privateReadReceipt:m(m({},p),{endMsgTime:n.endMsgTime})}:{groupReadReceipt:m(m({},p),{totalCount:n.tmn,readedCount:n.rrn,messageUId:n.msgId})})},t.prototype._processSRSMsg=function(e){var t=this.getNaviInfoFromCache(),o=e.conversationType,r=e.targetId,n=e.content,i=e.channelId,s=e.senderUserId,a=e.sentTime;return s===this.tcpMgr.getCurrentUserId()&&(this._callCppProxy("clearUnreadCountByTimestamp",o,r,n.lastMessageSendTime,i||""),1!==(null==t?void 0:t.sesDriven)||(a>this.tcpMgr.getConnectedTime()||this._sendsyncReadStatus({conversationType:o,targetId:r,channelId:i,timestamp:n.lastMessageSendTime}),!1))},t.prototype._buildConversation=function(t){var o=JSON.parse(t),r=o.channelId,n=o.conversationType,i=o.targetId,s=o.unreadCount,a=o.lastestMsg,c=o.isTop,u=o.blockStatus,p=o.matchCount,d=o.hasUnreadMention,l=o.conversationTime,f=o.draft,h=u>0?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE;return{channelId:r,conversationType:n,targetId:i,unreadMessageCount:s,latestMessage:-1===JSON.parse(a).messageId?null:this._buildMessage(a),hasMentioned:d,mentionedInfo:null,notificationStatus:h,isTop:c,lastUnreadTime:0,matchCount:p,operationTime:l,notificationLevel:u,draft:f}},t.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}))},t.prototype._handleNotNotificationMessage=function(t){var o,r=t.messageType,n=t.senderUserId,i=t.content;if(r===e.MessageType.LOG_COMMAND&&t.senderUserId===e.RC_DEFAULT_USER){var s=t.content,a=s.startTime,c=s.endTime,u=s.platform,p=s.logId,d=s.uri;return this.reporter.report(parseInt(a,10),parseInt(c,10),u,d,p,t.messageUId),!0}if(r===e.MessageType.CLOUD_CONTROL&&n===e.RC_DEFAULT_USER)return this.cloudControllerMsgs.push(t),this._ccMsgHandler(),!0;if(r===e.MessageType.READ_STATE)return this._processRSMsg(t),!0;if("RC:MsgExMsg"===r)return this._msgExpansionHandler.setLocalFromExtMsg(this.logger,t),this._sendMessageExpansion(t),!0;if(r===e.MessageType.SYNC_READ_STATUS&&!this._processSRSMsg(t))return!0;if(r===e.MessageType.DELIVERED)return this._callCppProxy("setMessageDeliverTime",JSON.stringify(i)),this._sendMessageDelivered(t.content.map((function(e){return{deliverTime:e.time,messageUId:e.messageUId,objectName:e.objectName,targetId:e.targetId}}))),!0;if(r===e.MessageType.DELIVERED_MSG){var l={totalCount:t.content.tmn,list:null===(o=t.content.dl)||void 0===o?void 0:o.map((function(e){return{MessageUId:e.msgId,deliveryCount:e.drn}}))};return this._sendGroupMessageDeliveredStatus(l),!0}return!1},t.prototype._setOnReceiveMessageListener=function(){var t=this;this._cppProtocol.setOnReceiveMessageListener((function(o,r,n,i){try{var s=t._buildMessage(o,{isOffLineMessage:n}),a=s.messageType,c=s.channelId,u=void 0===c?"":c,p=s.senderUserId,d=s.content,l=s.sentTime,f=s.conversationType,h=s.targetId;if(t._handleNotNotificationMessage(s))return;if(a===e.MessageType.READ_RECEIPT_REQUEST&&d.messageUId&&t._updateReadReceiptInfo(d.messageUId,{isReceiptRequestMessage:!0,hasRespond:!1}),a===e.MessageType.READ_RECEIPT_RESPONSE&&d.receiptMessageDic&&t._processRRRspMsg(d.receiptMessageDic,p,l),a===e.MessageType.GROUP_READ_RECEIPT_REQUEST){var C=d.msgId,g=d.rrn,v=d.tmn;t._updateReadReceiptInfo(C,{readCount:g,totalCount:v})}s.canIncludeExpansion&&t._msgExpansionHandler.setLocalFromReceiveMsg(t.logger,s),a===e.MessageType.READ_RECEIPT&&p===t.tcpMgr.getCurrentUserId()&&t._callCppProxy("clearUnreadCountByTimestamp",f,h,d.lastMessageSendTime,u);var _=!0;if(0!==r||i||(_=!1),a===e.MessageType.RECALL){if(!t.handleRecalledMessage(s))return;var S=t._fixRecallContentInfo(s);f=S.conversationType,h=S.targetId}t._sendMessageNotification(Object.assign(s,{hasMoreMsg:_,conversationType:f,targetId:h}))}catch(e){t.logger.error(y.P_RECEIVE_MESSAGE_E,JSON.stringify({error:null==e?void 0:e.stack,message:o}))}}),(function(){t._sendPullOfflineFinished()}))},t.prototype._ccMsgHandler=function(){var t;return E(this,void 0,void 0,(function(){var o,r;return P(this,(function(n){switch(n.label){case 0:return this.cloudControllerLock?(this.cloudControllerLock=!1,this.cloudControllerMsgs.shift()?(o=this.tcpMgr.getToken(),[4,null===(t=this.cloudController)||void 0===t?void 0:t.request(this.cloudControllerUri,e.InvokerType.other,o)]):[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]}}))}))},t.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}},t.prototype.handleRecalledMessage=function(t){var o=t.content,r=o.messageUId,n=o.sentTime;if(!r)return!0;var i=this._callCppProxy("getMessage",r),s=this._buildMessage(i,{isOffLineMessage:!1});if(t.content.isDelete)return-1===s.messageId||this._callCppProxy("deleteMessages",[s.messageId]),!0;if(s.messageType===e.MessageType.RECALL_NOTIFICATION_MESSAGE)return!1;var a={recallTime:Date.now(),admin:!!t.content.isAdmin,originalObjectName:s.messageType,originalMessageContent:s.content,recallActionTime:t.sentTime,operatorId:t.senderUserId};if(t.content.user&&(a.user=t.content.user),t.content.extra&&(a.extra=t.content.extra),s.messageType===e.MessageType.TextMessage&&(a.recallContent=s.content.content),-1===s.messageId){var c=t.conversationType,u=t.targetId,p=t.senderUserId,d=t.channelId,l=t.messageDirection;return this._callCppProxy("insertMessage",c,u,p,e.MessageType.RECALL_NOTIFICATION_MESSAGE,JSON.stringify(a),(function(){}),(function(){}),l,1,30,n,"",0,r,!1,!0,JSON.stringify({}),d||""),!0}return s.receivedStatus||this.setMessageReceivedStatus(s.messageId,1),this._callCppProxy("setMessageContent",s.messageId,JSON.stringify(a),e.MessageType.RECALL_NOTIFICATION_MESSAGE),!0},t.prototype._sendMessageExpansion=function(e){var t=e.channelId,o=void 0===t?"":t,r=e.content,n=e.conversationType,i=e.targetId,s=r,a=s.put,c=s.del,u=s.mid,p={};a&&(p.updatedExpansion={channelId:o,messageUId:u,expansion:a,conversationType:n,targetId:i}),c&&(p.deletedExpansion={channelId:o,messageUId:u,deletedKeys:c,conversationType:n,targetId:i}),this._dispatchEvent("expansion",p)},t.prototype._sendMessageNotification=function(e){this._dispatchEvent("batchMessage",e)},t.prototype._sendPullOfflineFinished=function(){this._dispatchEvent("pullFinished",null)},t.prototype._sendMessageDelivered=function(e){this._dispatchEvent("messageDelivered",e)},t.prototype._sendGroupMessageDeliveredStatus=function(e){this._dispatchEvent("groupMessageDeliveredStatus",e)},t.prototype._sendChatroomStatus=function(e){this._dispatchEvent("chatroom",e)},t.prototype._sendMessageReadReceipt=function(e){this._dispatchEvent("messageReadReceipt",e)},t.prototype._sendsyncReadStatus=function(e){this._dispatchEvent("syncReadStatus",e)},t.prototype._setConversationStatusListener=function(){var t=this;this._cppProtocol.setConversationStatusListener((function(o){var r=JSON.parse(o).list,n=[];r.forEach((function(t){var o=JSON.parse(t.obj),r=o.conversationType,i=o.targetId,s=o.status,a=o.channelId,c={notificationStatus:2,isTop:!1};s.forEach((function(t){var o=JSON.parse(t.item);1===o.type?c.notificationStatus=1===Number(o.value)?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE:c.isTop=1===Number(o.value)})),n.push({channelId:a,conversationType:r,targetId:i,updatedItems:{notificationStatus:{val:c.notificationStatus,time:0},isTop:{val:c.isTop,time:0}}})})),t._dispatchEvent("conversation",n)}),(function(e){t._dispatchEvent("conversationTag",e)}),(function(e,o,r,n){t._callCppProxy("clearUnreadCountByTimestamp",e,o,n,r||""),t._sendsyncReadStatus({conversationType:e,targetId:o,channelId:r,timestamp:n})}))},t.prototype._setPushNotificationListener=function(){var e=this;this._cppProtocol.setPushNotificationListener((function(){}),(function(t){e._dispatchEvent("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 o=this.navi.getNaviInfoFromCache(t);this._dispatchEvent("onNaviDataChange",o)}},t.prototype._setRTCLivingRoomEventListener=function(){var e=this;this._cppProtocol.setRTCRoomEventListener((function(t){e._dispatchEvent("onRTCDataChange",Array.prototype.slice.call(t))}))},t.prototype._setChatroomEventListener=function(){var e=this;this._cppProtocol.setChatroomEventListener((function(t,o){e._sendChatroomStatus({chatroomDestroyed:t})}))},t.prototype._setCallInfoListener=function(){var e=this;this._cppProtocol.setCallInfoListener((function(t){var o=[];try{JSON.parse(t).list.forEach((function(e){Object.entries(e).forEach((function(e){var t=e[0],r=e[1];o.push({key:t,value:r})}))}))}catch(t){e.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:t}))}e._dispatchEvent("callInfo",JSON.stringify({list:o}))}))},t.prototype._setSubscribeEventListener=function(){var t=this;this._cppProtocol.setSubscribeEventListener((function(){}),(function(e){t._dispatchEvent("syncSubscribedUserStatusFinished",e)}),(function(e){var o=t._buildSubscribeEventData(e).map((function(e){return{userId:e.userId,subscribeType:e.subscribeType,subscribeTime:e.subscribeTime,expiry:e.expiry,operationType:e.operationType}}));t._dispatchEvent("subscribedRelationChange",o)}),(function(o){var r=t._buildSubscribeEventData(o).map((function(t){var o=t.userId,r=t.subscribeType,n=t.subscribeTime,i=t.expiry,s=t.details,a=t.userProfile,c={userId:o,subscribeType:r,subscribeTime:n,expiry:i};return[e.SubscribeType.ONLINE_STATUS,e.SubscribeType.FRIEND_ONLINE_STATUS].includes(r)?c.details=s:[e.SubscribeType.USER_PROFILE,e.SubscribeType.FRIEND_USER_PROFILE].includes(r)&&(c.userProfile=a),c}));t._dispatchEvent("subscribedUserStatusChange",r)}))},t.prototype._setUserProfileListener=function(){var e=this;this._cppProtocol.setUserProfileListener((function(t){e._dispatchEvent("syncSubscribedUserStatusFinished",t)}),(function(t){e._dispatchEvent("ownUserProfileChanged",e._string2userProfileInfo(t))}))},t.prototype._onGroupOperationChanged=function(e,t,o,r,n){var i,s,a=[];try{i=JSON.parse(r),a=JSON.parse(n),s=JSON.parse(e);var c={groupId:i[0]?i[0].groupId:"",operatorInfo:this._convertGroupMemberInfoList([s])[0],operation:t,operationTime:o};0===t?c.groupInfo=this._convertGroupInfoList(i)[0]:c.memberInfos=this._convertGroupMemberInfoList(a),this._dispatchEvent("groupOperation",c)}catch(t){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:t,groupInfoJson:r,membersJson:n,operatorInfo:e}))}},t.prototype._onGroupInfoChanged=function(t,o,r,n,i){try{var s=JSON.parse(r),a=JSON.parse(n);switch(t){case e.GroupInfoChangeSubChangeType.GROUP_INFO_CHANGE:this._dispatchEvent("groupInfoChanged",{operatorInfo:this._convertGroupMemberInfoList([s])[0],operationTime:i,groupInfo:this._convertUpdateGroupInfoList(a)[0]});break;case e.GroupInfoChangeSubChangeType.GROUP_REMARK_DELETE:case e.GroupInfoChangeSubChangeType.GROUP_REMARK_SET:var c=t===e.GroupInfoChangeSubChangeType.GROUP_REMARK_SET?e.GroupOperationType.ADD:e.GroupOperationType.REMOVE;this._dispatchEvent("groupRemarkChangedSync",{groupId:o,operationType:c,operationTime:i,groupRemark:a[0]?a[0].remark:""})}}catch(e){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:e,groupInfoJson:n,operatorInfoJson:r}))}},t.prototype._onGroupMemberInfoChanged=function(e,t,o,r){try{var n=JSON.parse(t),i=JSON.parse(o),s={groupId:e,operatorInfo:this._convertGroupMemberInfoList([n])[0],memberInfo:this._convertGroupMemberInfoList([i])[0],operationTime:r};this._dispatchEvent("groupMemberInfoChanged",s)}catch(e){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:e,operatorInfoJson:t,updateMemberInfoJson:o}))}},t.prototype._onGroupRequestChanged=function(e,t,o,r){try{var n=JSON.parse(o),i=n.groupId,s=n.joinUser,a=n.approverUser,c=n.inviterUser,u=n.type,p=n.status,d=n.direction,l=n.remark,f=m(m(m(m({groupId:i},s&&{joinMemberInfo:this._convertGroupMemberInfoList([s])[0]}),c&&c.userId&&{inviterInfo:this._convertGroupMemberInfoList([c])[0]}),a&&a.userId&&{operatorInfo:this._convertGroupMemberInfoList([a])[0]}),{status:p,direction:d,type:u,operationTime:r,reason:l});this._dispatchEvent("groupApplicationEvent",f)}catch(e){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:e,groupInfo:t,requestInfoJson:o}))}},t.prototype._onFavoriteMembersChanged=function(t,o,r,n){try{var i=JSON.parse(r),s=[];i&&e.isArray(i.list)&&(s=i.list.map((function(e){return e.value}))),this._dispatchEvent("groupFollowsChangedSync",{groupId:t,operationType:o,operationTime:n,userIds:s})}catch(e){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:e,memberIds:r}))}},t.prototype._setEntrustGroupListener=function(){this._cppProtocol.setEntrustGroupListener(this._onGroupOperationChanged.bind(this),this._onGroupInfoChanged.bind(this),this._onGroupMemberInfoChanged.bind(this),this._onGroupRequestChanged.bind(this),this._onFavoriteMembersChanged.bind(this))},t.prototype._onFriendApplicationStatusChanged=function(e,t,o,r,n,i){this._dispatchEvent("friendApplicationStatusChanged",{userId:e,applicationType:t,applicationStatus:o,directionType:r,operationTime:n,extra:null!=i?i:""})},t.prototype._onFriendAdd=function(e,t,o,r,n){this._dispatchEvent("friendAdd",{userId:t,name:o,portraitUri:r,directionType:e,operationTime:n})},t.prototype._onFriendDelete=function(e,t,o){this._dispatchEvent("friendDelete",{userIds:t,directionType:e,operationTime:o})},t.prototype._onFriendsClearedFromServer=function(e){this._dispatchEvent("friendCleared",e)},t.prototype._onFriendInfoChangedSync=function(e,t,o){try{var r=JSON.parse(o);this._dispatchEvent("friendInfoChangedSync",{userId:e,remark:t,extProfile:r.list})}catch(e){this.logger.error(y.P_PARSE_JSON_E,JSON.stringify({error:e,profiles:o}))}},t.prototype._setFriendEventListener=function(){this._cppProtocol.setFriendEventListener(this._onFriendApplicationStatusChanged.bind(this),this._onFriendAdd.bind(this),this._onFriendDelete.bind(this),this._onFriendsClearedFromServer.bind(this),this._onFriendInfoChangedSync.bind(this))},t.prototype.registerMessageType=function(e,t,o,r,n){var i=0;t&&(i|=1),o&&(i|=2),n&&(i=16),this._customMessageType[e]={isCounted:o,isPersited:t,isStatusMessage:n},this.logger.info(y.P_REGTYP_O,JSON.stringify({type:e,opt:i,search:r})),this._callCppProxy("registerMessageType",e,i,r||[])},t.prototype.connect=function(e,t,o,r){return this.tcpMgr.connect(e,t,o,r)},t.prototype.reconnect=function(t,o,r){var n=e.ErrorCode.RC_SOCKET_DISCONNECTED;return this.tcpMgr.reconnect(t,o,r,n)},t.prototype.reportSDKInfo=function(e){var t=JSON.stringify(m(m({},e),{"electron-main":"5.12.4"}));this.logger.info(y.P_REPORT_VER_O,t),this._callCppProxy("uploadSDKVersion",t,"")},t.prototype.disconnect=function(e){e=e||!0,this._chatroomCache.length=0,this.reporter.stop(),$(null,this.logger),this.tcpMgr.disconnect(e)},t.prototype.logout=function(){this.disconnect()},t.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)},t.prototype.subscribeUserStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("subscribeUserStatus",t,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.setUserStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("setUserStatus",t,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.getUserStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("getUserStatus",t,(function(t){setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:{status:t}})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype._handleDirectionalUserIdList=function(t,o){var r=t.messageType,n=t.content,i=t.directionalUserIdList,s=void 0===i?[]:i,a=o===e.ConversationType.GROUP;if(r===e.MessageType.READ_RECEIPT_RESPONSE&&n.receiptMessageDic&&a)for(var c in n.receiptMessageDic)s.push(c);return r===e.MessageType.SYNC_READ_STATUS&&e.isSupportDirectMessage(o)&&(s=[this.getCurrentUserId()]),s},t.prototype._handleMessage2Callback=function(t,o){var r=this;if("RC:MsgExMsg"===t.messageType&&this._msgExpansionHandler.setLocalFromExtMsg(this.logger,t),t.messageType===e.MessageType.READ_RECEIPT_REQUEST)this._updateReadReceiptInfo(o.content.messageUId,{isReceiptRequestMessage:!0,readerList:[]});else if(t.messageType===e.MessageType.READ_RECEIPT_RESPONSE){var n=o.content.receiptMessageDic;if(!n)return;for(var i in n)n[i].forEach((function(e){r._updateReadReceiptInfo(e,{isReceiptRequestMessage:!0,hasRespond:!0})}))}},t.prototype.sendMessage=function(t,o,r,n,i){var s=this;void 0===i&&(i=this.logger.createTraceId());var a=r.messageType,c=r.content,u=r.expansion,p=r.pushConfig,d=r.pushContent,l=void 0===d?"":d,f=r.pushData,h=void 0===f?"":f,C=r.directionalUserIdList,g=void 0===C?[]:C,v=r.disableNotification,_=void 0!==v&&v,S=r.canIncludeExpansion,m=void 0!==S&&S,E=r.isVoipPush,P=void 0!==E&&E,T=r.channelId,I=void 0===T?"":T,R=r.messageId,O=void 0===R?0:R,N=r.disableUpdateLastMessage,M=void 0!==N&&N,b=p||{},U=b.iOSConfig,x=b.androidConfig,L=b.harmonyOSConfig,w=b.templateId,A=void 0===w?"":w,k=b.pushTitle,D=void 0===k?"":k,J=b.pushContent,G=void 0===J?l:J,F=b.pushData,B=void 0===F?h:F,j=b.disablePushTitle,V=void 0!==j&&j,q=b.forceShowDetailContent,H=void 0!==q&&q,K=e.pushConfigsToJSON(U,x,L);return new Promise((function(p){l=G,h=B;var d=(null==x?void 0:x.notificationId)||"";g=s._handleDirectionalUserIdList(r,t);var f={};for(var C in u)f[C]={v:""},f[C].v=u[C];var v=A;s.logger.info(y.P_SEND_MSG_T,JSON.stringify({messageType:a,conversationType:t,targetId:o,channelId:I}),i);var S=s._callCppProxy("sendMessage",(function(t,o){var n=s._buildMessage(t,{isOffLineMessage:!1});if(s.logger.info(y.P_SEND_MSG_R,JSON.stringify({code:o,messageUId:n.messageUId}),i),o===e.ErrorCode.SENSITIVE_REPLACE)return setTimeout((function(){p({code:o})}),0);[e.MessageType.READ_RECEIPT_REQUEST,e.MessageType.READ_RECEIPT_RESPONSE,e.MessageType.EXPANSION_NOTIFY].findIndex((function(e){return e===n.messageType}))>-1&&s._handleMessage2Callback(n,r),n.canIncludeExpansion&&s._msgExpansionHandler.setLocalFromReceiveMsg(s.logger,n),setTimeout((function(){p({code:e.ErrorCode.SUCCESS,data:n})}),0)}),(function(e,t){var o=s._buildMessage(e,{isOffLineMessage:!1});s.logger.warn(y.P_SEND_MSG_R,JSON.stringify({code:t,messageId:o.messageId}),i),o.sentTime=Date.now()-s._cppProtocol.getDeltaTime(),setTimeout((function(){p({code:t,data:o})}),0)}),t,o,a,JSON.stringify(c),g,_,V,H,l,h,d,D,K,v,m,JSON.stringify(f),P,I,O,M),E=JSON.parse(S);null==n||n(E.messageId)}))},t.prototype.recallMsg=function(t,o,r,n,i){var s=this;return new Promise((function(a){var c,u=i.user,p=i.pushContent,d=i.channelId,l=i.extra,f=i.pushConfig,h=i.disableNotification,C=i.isDelete,g=i.directionalUserIdList,v=i.disableUpdateLastMessage,_={conversationType:t,targetId:o,messageUId:r,sentTime:n,user:u,extra:l,channelId:d,isDelete:C||!1};u&&(_.user=u),l&&(_.extra=l);var S={conversationType:t,targetId:o,senderUserId:s.tcpMgr.getCurrentUserId(),content:_,objectName:e.MessageType.RECALL,messageUid:r,direction:e.MessageDirection.SEND,status:e.ReceivedStatus.UNREAD,sentTime:n,channelId:d},y=s._buildMessage(JSON.stringify(S),{isOffLineMessage:!1});s._callCppProxy("recallMessage",(function(){s.handleRecalledMessage(y),y.pushConfig=f,setTimeout((function(){a({code:e.ErrorCode.SUCCESS,data:y})}),0)}),(function(e){setTimeout((function(){a({code:e})}),0)}),e.MessageType.RECALL,JSON.stringify(_),h||!1,(null==f?void 0:f.disablePushTitle)||!1,(null==f?void 0:f.forceShowDetailContent)||!1,p||"",(null==f?void 0:f.pushData)||"",(null===(c=null==f?void 0:f.androidConfig)||void 0===c?void 0:c.notificationId)||"",(null==f?void 0:f.pushTitle)||"",e.pushConfigsToJSON(null==f?void 0:f.iOSConfig,null==f?void 0:f.androidConfig,null==f?void 0:f.harmonyOSConfig),(null==f?void 0:f.templateId)||"",d,g||[],r,null!=v&&v)}))},t.prototype.getHistoryMessage=function(t,o,r,n,i,s,a){var c=this;return new Promise((function(u){r=r||0;var p=0===i,d=n+1,l=c._callCppProxy("getHistoryMessages",t,o,r,d,a,p,s),f=JSON.parse(l).list,h=[];f.reverse();for(var C=0;C<f.length;C++){var g=c._buildMessage(f[C].obj);h[C]=g}u({code:e.ErrorCode.SUCCESS,data:{list:d===h.length?h.slice(1,d):h,hasMore:n<h.length}})}))},t.prototype.getMessages=function(t,o,r,n,i,s){var a=this;return new Promise((function(c){var u=0===i,p=r,d=0!==r,l=n+1;d&&(p+=u?1:-1,l++);for(var f=a._callCppProxy("getMessages",t,o,p,l,u,s),h=JSON.parse(f).list,C=[],g=0;g<h.length;g++){var v=a._buildMessage(h[g].obj);C[g]=v}var _=a._computeRepairInfo(C,u,r,p,l),S=_.isNeedRepair,y=void 0!==S&&S,m=_.repairTime,E=void 0===m?0:m;if(!y)return d&&(C.shift(),l--),C.reverse(),void c({code:e.ErrorCode.SUCCESS,data:{list:l===C.length?C.slice(1,l):C,hasMore:n<C.length}});a._processRepairHisMsg(t,o,r,n,i,s,E,c)}))},t.prototype._computeRepairInfo=function(e,t,o,r,n){var i=!1,s=0,a=this.getNaviInfoFromCache()||{},c=a.repairHisMsg,u=void 0===c?0:c,p=a.historyMsg;if(1!==u||!p)return{isNeedRepair:i,repairTime:s};var d=e.findIndex((function(e){return e.hasMore||0===Object.keys(e.content).length}));return t&&d>=0?(i=!0,s=e[d].hasMore?e[d].sentTime:e[d].sentTime+1):!t&&d>=1?(i=!0,s=e[d-1].sentTime):e.length<n||0===o?(i=!0,s=o):e.length>0&&e[0].sentTime!==o&&(i=!0,s=r),{isNeedRepair:i,repairTime:s}},t.prototype._processRepairHisMsg=function(e,t,o,r,n,i,s,a){var c=this,u=function(s){for(var u=0===n,p=r+1,d=c._callCppProxy("getMessages",e,t,o,p,u,i),l=JSON.parse(d).list,f=[],h=0;h<l.length;h++){var C=c._buildMessage(l[h].obj);f[h]=C}f.reverse(),a({code:s,data:{list:p<=f.length?f.slice(1,p):f,hasMore:r<f.length}})},p=r+10>100?100:r+10;this._callCppProxy("getRemoteHistoryMessages",e,t,s,p,(function(){return u(0)}),(function(e){u(e)}),n,!0,i,!1)},t.prototype.getContinuousMessages=function(t,o,r,n,i,s){var a=this;return new Promise((function(c){r=r||0;var u=0===i;a._callCppProxy("getContinuousMessages",t,o,r,n,(function(t,o,r){var n=JSON.parse(t).list,i=[];n.reverse();for(var s=0;s<n.length;s++){var u=a._buildMessage(n[s].obj);i[s]=u}setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{list:i,timestamp:o,hasMore:r}})}))}),(function(e){setTimeout((function(){c({code:e})}),0)}),u,s)}))},t.prototype.getRemoteHistoryMessages=function(t,o,r,n,i,s){var a=this;return new Promise((function(c){r=r||0;a._callCppProxy("getRemoteHistoryMessages",t,o,r,n,(function(t,o){var r=JSON.parse(t).list,n=[];r.reverse();for(var i=0;i<r.length;i++){var s=a._buildMessage(r[i].obj);n[i]=s}setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{list:n,hasMore:!!o}})}),0)}),(function(e){setTimeout((function(){c({code:e})}),0)}),i,!0,s,!0)}))},t.prototype.deleteRemoteMessage=function(t,o,r,n){var i=this;return new Promise((function(s){var a=JSON.stringify(r);i._callCppProxy("deleteRemoteHistoryMessages",t,o,a,!1,n,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),s)}))},t.prototype.deleteRemoteMessageByTimestamp=function(t,o,r,n){var i=this;return new Promise((function(s){i._callCppProxy("clearRemoteHistoryMessages",t,o,r,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){s(e)}),0)}),n)}))},t.prototype.clearMessages=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("clearMessages",t,o,r),i(e.ErrorCode.SUCCESS)}))},t.prototype.getConversationList=function(t,o,r,n,i){var s=this;return void 0===i&&(i=""),new Promise((function(t){for(var o=s._callCppProxy("getConversationList",[1,3,6,7],i),r=JSON.parse(o).list,n=[],a=0;a<r.length;a++)n.push(s._buildConversation(r[a].obj));t({code:e.ErrorCode.SUCCESS,data:n})}))},t.prototype.getConversation=function(t,o,r){var n=this;return new Promise((function(i){var s=n._callCppProxy("getConversation",t,o,r);if(s)i({code:e.ErrorCode.SUCCESS,data:n._buildConversation(s)});else{var a=n._callCppProxy("getHistoryMessages",t,o,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 p=n._callCppProxy("getConversationNotificationStatus",t,o,r),d=n._callCppProxy("getConversationTopStatus",t,o,r);i({code:e.ErrorCode.SUCCESS,data:{conversationType:t,targetId:o,channelId:r,unreadMessageCount:0,latestMessage:u,notificationStatus:p?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE,isTop:Boolean(d),lastUnreadTime:0}})}}))},t.prototype.removeConversation=function(t,o,r){var n=this._callCppProxy("removeConversation",t,o,r);return Promise.resolve(n?e.ErrorCode.SUCCESS:e.ErrorCode.CONVER_REMOVE_ERROR)},t.prototype.batchRemoveConversation=function(t){var o=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId}})),r=this._callCppProxy("removeConversationInBatches",JSON.stringify(o));return Promise.resolve(r?e.ErrorCode.SUCCESS:e.ErrorCode.CONVER_REMOVE_ERROR)},t.prototype.clearConversations=function(t,o){var r=this;return new Promise((function(n){var i=[];i=e.isArray(t)?t:[e.ConversationType.PRIVATE,e.ConversationType.GROUP,e.ConversationType.SYSTEM,e.ConversationType.PUBLIC_SERVICE],r._callCppProxy("clearConversations",i,o||""),n(e.ErrorCode.SUCCESS)}))},t.prototype.getAllConversationUnreadCount=function(t,o,r){var n=this._callCppProxy("getTotalUnreadCount",o,r,t);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},t.prototype.getConversationUnreadCount=function(t,o,r){var n=this;return void 0===r&&(r=""),new Promise((function(i){var s=n._callCppProxy("getUnreadCount",t,o,r);i({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.clearConversationUnreadCount=function(t,o,r){var n=this;return void 0===r&&(r=""),new Promise((function(i){n._callCppProxy("clearUnreadCount",t,o,r),i(e.ErrorCode.SUCCESS)}))},t.prototype.clearUnreadCountByTimestamp=function(t,o,r,n){var i=this;return new Promise((function(s){i._callCppProxy("clearUnreadCountByTimestamp",t,o,r,n),s(e.ErrorCode.SUCCESS)}))},t.prototype.getFirstUnreadMessage=function(t,o,r){var n=this;return new Promise((function(i){var s=n._callCppProxy("getTheFirstUnreadMessage",t,o,r),a=n._buildMessage(s);i({code:e.ErrorCode.SUCCESS,data:-1!==a.messageId?a:null})}))},t.prototype.getFirstUnreadMessageInfo=function(t,o,r){var n=this;return new Promise((function(i,s){var a=n._callCppProxy("getTheFirstUnreadMessage",t,o,r),c=n._buildMessage(a);i({code:e.ErrorCode.SUCCESS,data:-1!==c.messageId?{messageUId:c.messageUId,sentTime:c.sentTime}:null})}))},t.prototype.batchSetConversationToTop=function(t,o,r){var n=this;return new Promise((function(i,s){var a=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId,is_top:o}}));n._callCppProxy("setIsTopInBatches",JSON.stringify(a),r||!1),i(e.ErrorCode.SUCCESS)}))},t.prototype.setConversationStatus=function(t,o,r,n,i,s){var a=this;return new Promise((function(s){a._callCppProxy("setConversationStatus",t,o,r,n,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){s(e)}),0)}),i,!0)}))},t.prototype.setConversationToTop=function(t,o,r,n,i){var s=this;return new Promise((function(i){i(s._callCppProxy("setConversationToTop",t,o,r,n,!0,!0)?e.ErrorCode.SUCCESS:e.ErrorCode.RC_MSG_DATA_INCOMPLETE)}))},t.prototype.getConversationNotificationStatus=function(t,o,r){var n=this;return new Promise((function(i){var s=n._callCppProxy("getConversationNotificationStatus",t,o,r);i({code:e.ErrorCode.SUCCESS,data:s?e.NotificationStatus.OPEN:e.NotificationStatus.CLOSE})}))},t.prototype.setConversationTypeNotificationLevel=function(t,o){var r=this;return new Promise((function(n,i){r._callCppProxy("setBlockPushLevelForType",t,o,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.getConversationTypeNotificationLevel=function(t){var o=this;return new Promise((function(r,n){var i=o._callCppProxy("getBlockPushLevelForType",t);r({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.searchConversationByContent=function(t,o,r,n){var i=this;return new Promise((function(s){n=n||[1,3,6,7];for(var a=i._callCppProxy("searchConversationByContent",n,t,o,r),c=JSON.parse(a).list,u=[],p=0;p<c.length;p++)u[p]=i._buildConversation(c[p].obj);s({code:e.ErrorCode.SUCCESS,data:u})}))},t.prototype.searchConversationByContentWithAllChannel=function(t,o,r){var n=this;return new Promise((function(i){r=r||[1,3,6,7];for(var s=n._callCppProxy("searchConversationByContentWithAllChannel",r,t,o),a=JSON.parse(s).list,c=[],u=0;u<a.length;u++)c[u]=n._buildConversation(a[u].obj);i({code:e.ErrorCode.SUCCESS,data:c})}))},t.prototype.searchMessageByContent=function(t,o,r,n,i,s,a){var c=this;return new Promise((function(s){c._callCppProxy("searchMessageByContent",t,o,r,n,i,1,(function(t,o){for(var r=t?JSON.parse(t).list:[],n=[],i=0;i<r.length;i++)n[i]=c._buildMessage(r[i].obj);setTimeout((function(){s({code:e.ErrorCode.SUCCESS,data:{messages:n,count:o}})}),0)}),a)}))},t.prototype.searchMessageByContentAndMessageType=function(t,o,r,n,i,s,a){var c=this;return new Promise((function(u){c._callCppProxy("searchMessageByContentAndObjectName",o,t,a||"",void 0===a,r,s,i,n,1,(function(t,o){for(var r=t?JSON.parse(t).list:[],n=[],i=0;i<r.length;i++)n[i]=c._buildMessage(r[i].obj);setTimeout((function(){u({code:e.ErrorCode.SUCCESS,data:{messages:n,count:o}})}),0)}))}))},t.prototype.searchMessagesByUser=function(t,o,r,n,i,s){var a=this;return new Promise((function(c){a._callCppProxy("getMessageBySender",t,o,r,n,i,s,(function(t){for(var o=t?JSON.parse(t).list:[],r=[],n=0;n<o.length;n++)r[n]=a._buildMessage(o[n].obj);setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{messages:r}})}),0)}))}))},t.prototype.searchMessageByContentWithAllChannel=function(t,o,r,n,i){var s=this;return new Promise((function(a){s._callCppProxy("searchMessageByContentWithAllChannel",t,o,r,n,i,1,(function(t,o){for(var r=t?JSON.parse(t).list:[],n=[],i=0;i<r.length;i++)n[i]=s._buildMessage(r[i].obj);setTimeout((function(){a({code:e.ErrorCode.SUCCESS,data:{messages:n,count:o}})}),0)}))}))},t.prototype.searchMessageByContentInTimeRangeWithAllChannel=function(t,o,r,n,i,s,a){var c=this;return new Promise((function(u){c._callCppProxy("searchMessageByTimestampWithAllChannel",t,o,r,n,i,s,a,(function(t){for(var o=t?JSON.parse(t).list:[],r=[],n=0;n<o.length;n++)r[n]=c._buildMessage(o[n].obj);setTimeout((function(){u({code:e.ErrorCode.SUCCESS,data:{messages:r}})}),0)}))}))},t.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},t.prototype.addToBlacklist=function(t){var o=this;return new Promise((function(r){o._callCppProxy("addToBlacklist",t,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.removeFromBlacklist=function(t){var o=this;return new Promise((function(r){o._callCppProxy("removeFromBlacklist",t,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.getBlacklist=function(){var t=this;return new Promise((function(o){t._callCppProxy("getBlacklist",(function(t){setTimeout((function(){o({code:e.ErrorCode.SUCCESS,data:t})}),0)}),(function(e){setTimeout((function(){o({code:e})}),0)}))}))},t.prototype.getBlacklistStatus=function(t){var o=this;return new Promise((function(r){o._callCppProxy("getBlacklistStatus",t,(function(t){setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:t})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.insertMessage=function(t,o,r){var n=this,i=r.content,s=r.senderUserId,a=r.messageType,c=r.messageDirection,u=r.readStatus,p=r.sentStatus,d=r.sentTime,l=r.searchContent,f=r.isUnread,h=r.messageUId,C=r.disableNotification,g=r.canIncludeExpansion,v=r.expansionMsg,_=r.channelId,S=r.directedUserIds,y=r.disableUpdateLastMessage;i=JSON.stringify(i);var m={};if(d=d||0,v){var E=JSON.parse(v);for(var P in E)m[P]={v:"",ts:0},m[P].v=E[P],m[P].ts=d}return new Promise((function(r){var v=f?0:1,E=n._callCppProxy("insertMessage",t,o,s,a,i,(function(){}),(function(e){setTimeout((function(){r({code:e})}),0)}),c,u||0,p||10,d,l||"",v,h||"",!!C,!!g,JSON.stringify(m),_||"",S||[],y||!1),P=n._buildMessage(E,{isOffLineMessage:!1});P.messageUId=h,P.sentTime=d,r({code:-1===P.messageId?e.ErrorCode.MSG_INSERT_ERROR:e.ErrorCode.SUCCESS,data:P})}))},t.prototype.batchInsertMessage=function(t,o){var r=this;return void 0===o&&(o=!1),new Promise((function(n){var i=t.map((function(t){var o=t.content,r=t.senderUserId,n=t.messageType,i=t.messageDirection,s=t.receivedStatus,a=void 0===s?0:s,c=t.sentStatus,u=t.sentTime,p=t.searchContent,d=t.isUnread,l=t.messageUId,f=t.disableNotification,h=t.canIncludeExpansion,C=t.expansion,g=t.channelId,v=t.conversationType,_=t.targetId,S=t.source,y=t.isMentioned,m=t.receivedStatusInfo,E=t.directedUserIds,P=t.disableUpdateLastMessage,T=a;m&&(T=e.transformReceivedStatusFlag(m));var I={};if(u=u||0,C)for(var R in C)I[R]={v:"",ts:0},I[R].v=C[R],I[R].ts=u;return{conversationType:v,targetId:_,channelId:g||"",direction:i,senderUserId:r,status:c||10,sentTime:u,objectName:n,content:JSON.stringify(o),messageUid:l||"",noNotification:!!f,supportExt:!!h,extMsg:JSON.stringify(I),readStatus:T,searchContent:p||"",isUnread:!!d,source:S||"",isMention:y,directedUsers:E,disableUpdateLastMessage:P||!1}})),s=r._callCppProxy("insertMessages",JSON.stringify(i),o);n({code:s?e.ErrorCode.SUCCESS:e.ErrorCode.MSG_INSERT_ERROR,data:s||!1})}))},t.prototype.getMessageCount=function(t,o,r){var n=this;return new Promise((function(i){var s=n._callCppProxy("getMessageCount",t,o,r);i({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.deleteMessages=function(t){var o=this;return new Promise((function(r){o._callCppProxy("deleteMessages",t),r(e.ErrorCode.SUCCESS)}))},t.prototype.deleteMessagesByTimestamp=function(t,o,r,n,i){var s=this;return new Promise((function(a){s._callCppProxy("deleteMessagesByTimestamp",t,o,r,n,i),a(e.ErrorCode.SUCCESS)}))},t.prototype.batchClearMessagesByTimestamp=function(t){var o=this;return new Promise((function(r,n){var i=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId||"",send_time:e.timestamp}}));o._callCppProxy("deleteMessageBySendTimeInBatches",JSON.stringify(i)),r(e.ErrorCode.SUCCESS)}))},t.prototype.batchClearRemoteHistoryMessages=function(t,o){var r=this;return new Promise((function(n,i){var s=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId||"",send_time:e.timestamp}}));r._callCppProxy("deleteRemoteMessageBySendTimeInBatches",JSON.stringify(s),o||!1,(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.getMessage=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getMessage",t),i=o._buildMessage(n,{isOffLineMessage:!1});r({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.setMessageContent=function(t,o,r){var n=this;return new Promise((function(i){o=JSON.stringify(o),n._callCppProxy("setMessageContent",t,o,r),i(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageSearchField=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("setMessageSearchField",t,o,r),i(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageSentStatus=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("setMessageSentStatus",t,o),n(e.ErrorCode.SUCCESS)}))},t.prototype.setMessageReceivedStatus=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("setMessageReceivedStatus",t,o),n(e.ErrorCode.SUCCESS)}))},t.prototype.saveConversationMessageDraft=function(t,o,r,n){var i=this;return new Promise((function(s){i._callCppProxy("saveTextMessageDraft",t,o,r,n||"")&&s(e.ErrorCode.SUCCESS),s(e.ErrorCode.DRAFT_SAVE_ERROR)}))},t.prototype.getConversationMessageDraft=function(t,o,r){var n=this;return new Promise((function(i){var s=n._callCppProxy("getTextMessageDraft",t,o,r||"");i({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.clearConversationMessageDraft=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("clearTextMessageDraft",t,o,r||"")&&i(e.ErrorCode.SUCCESS),i(e.ErrorCode.DRAFT_REMOVE_ERROR)}))},t.prototype.pullConversationStatus=function(e){throw new Error("Method not implemented.")},t.prototype.batchSetConversationStatus=function(t){var o=t[0],r=o.conversationType,n=o.targetId,i=o.isTop,s=o.notificationStatus,a=o.channelId,c=o.isUpdateTime,u=void 0===c||c,p=this._callCppProxy("getConversationNotificationStatus",r,n,a||""),d=this._callCppProxy("getConversationTopStatus",r,n,a||""),l=e.isUndefined(s)?Boolean(p):s===e.NotificationStatus.OPEN,f=e.isUndefined(i)?Boolean(d):i;return this.setConversationStatus(r,n,l,f,a,u)},t.prototype.getConversationNotificationLevel=function(t,o,r){return E(this,void 0,void 0,(function(){var n;return P(this,(function(i){return n=this._callCppProxy("getBlockPushLevelForConversation",o,r,t),[2,Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})]}))}))},t.prototype.setConversationNotificationLevel=function(t,o,r,n){var i=this;return void 0===n&&(n=""),new Promise((function(s){i._callCppProxy("setBlockPushLevelForConversation",o,n,t,r,(function(){setTimeout((function(){s(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){s(e)}),0)}))}))},t.prototype.batchSetConversationNotificationLevel=function(t,o){var r=this;return new Promise((function(n,i){var s=t.map((function(e){return{conversation_type:e.conversationType,target_id:e.targetId,channel_id:e.channelId,level:o}}));r._callCppProxy("setBlockPushLevelInBatches",JSON.stringify(s),(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.getTotalUnreadCountByLevels=function(t,o,r){if(r){var n=this._callCppProxy("getUnreadMentionedCountByLevel",t,o);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})}var i=this._callCppProxy("getUnreadCountByLevel",t,o);return Promise.resolve({code:e.ErrorCode.SUCCESS,data:i})},t.prototype.pullUserSettings=function(e){throw new Error("Method not implemented.")},t.prototype.sendReadReceiptMessage=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("sendReadReceipt",t,r||"",o,(function(){o.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}))}})),setTimeout((function(){i({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getMessageReader=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("getMessageReader",t,r,o,(function(t,r){var s=[],a={};(t=JSON.parse(t)).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;s.push({userId:o,readTime:r}),a[o]=r}));var c={readerInfo:a,readCount:s.length,totalCount:r};n._updateReadReceiptInfo(o,c),setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{list:s,totalMemberCount:r}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.sendReadReceiptMessageV4=function(t,o,r){var n=this;return new Promise((function(i){var s=t.conversationType,a=t.targetId,c=t.channelId;n._callCppProxy("sendMessageReadReceipt",s,a,c||"",o,r,(function(){setTimeout((function(){i({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getMessageReadReceiptV4=function(t,o){var r=this;return new Promise((function(n){var i=t.targetId,s=t.channelId;r._callCppProxy("getMessageReadReceipt",i,s||"",o,(function(t,i,s){var a=[],c=r._callCppProxy("getMessage",o),u=JSON.parse(c);try{JSON.parse(s).list.forEach((function(e){var t=JSON.parse(e.obj),o=t.id,r=t.time;a.push({userId:o,readTime:r})}))}catch(e){r.logger.error(y.P_PARSE_JSON_E,"method: getMessageReadReceipt, info: "+s+", error: "+e)}var p=JSON.parse(u.readReceiptRequest||"{}"),d=p.readerList,l=void 0===d?[]:d,f=p.readCount,h=void 0===f?0:f,C=!1;l.length<a.length&&(l=a,C=!0),h<i&&(h=i,C=!0),C&&r._callCppProxy("updateReadReceiptRequestInfo",o,JSON.stringify({readerList:l,readCount:h,totalCount:t})),setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:{list:a,totalCount:t,readCount:h}})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.updateConversationReadTime=function(t,o){var r=this;return new Promise((function(n){var i=t.conversationType,s=t.targetId,a=t.channelId;r._callCppProxy("updateConversationReadTime",i,s,a||"",o,(function(){setTimeout((function(){n({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype._addChatroomCache=function(e,t,o,r){this._rmChatroomCache(e),this._chatroomCache.push({chatroomId:e,joinExist:o,count:t,extra:r})},t.prototype._rmChatroomCache=function(e){this._chatroomCache=this._chatroomCache.filter((function(t){return t.chatroomId!==e}))},t.prototype._try2RejoinChatroom=function(){var t=this;if(0!==this._chatroomCache.length){var o=this.logger.createTraceId();this._chatroomCache.forEach((function(r){return E(t,void 0,void 0,(function(){var t,n,i,s,a,c,u;return P(this,(function(p){switch(p.label){case 0:return t=r.chatroomId,n=r.joinExist,i=r.count,s=r.extra,this.logger.info(e.LogTagId.L_REJOIN_CHATROOM_T,t,o),[4,this._joinChrm(t,i,n,!1,s)];case 1:return a=p.sent(),c=a.code,u=a.data,c===e.ErrorCode.SUCCESS?(this.logger.info(e.LogTagId.L_REJOIN_CHATROOM_R,t,o),this._sendChatroomStatus({rejoinedRoom:m({chatroomId:t,count:i},u)}),[2]):(c===e.ErrorCode.RC_CHATROOM_USER_KICKED&&this._rmChatroomCache(t),this._sendChatroomStatus({rejoinedRoom:{chatroomId:t,errorCode:c}}),this.logger.warn(e.LogTagId.L_REJOIN_CHATROOM_R,"chrmId: "+t+", code: "+c,o),[2])}}))}))}))}},t.prototype._joinChrm=function(t,o,r,n,i){var s=this,a=r?"joinExistChatRoom":"joinChatRoom";return new Promise((function(c){n&&s._callCppProxy("clearMessages",e.ConversationType.CHATROOM,t,""),s._callCppProxy(a,t,o,(function(n,a,u,p,d,l,f){s._addChatroomCache(t,o,r,i||""),setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{createTime:Number(n),memberCount:a,isAllChatroomBanned:u,isCurrentUserBanned:p,isCurrentChatroomBanned:d,isCurrentChatroomInWhitelist:l,joinTime:f}})}),0)}),(function(e){setTimeout((function(){c({code:e})}),0)}),i||"")}))},t.prototype.joinChatroom=function(e,t,o){return E(this,void 0,void 0,(function(){return P(this,(function(r){switch(r.label){case 0:return[4,this._joinChrm(e,t,!1,!0,o)];case 1:return[2,r.sent().code]}}))}))},t.prototype.joinExistChatroom=function(e,t,o){return this._joinChrm(e,t,!0,!0,o)},t.prototype.quitChatroom=function(t){var o=this;return this._rmChatroomCache(t),new Promise((function(r){o._callCppProxy("quitChatRoom",t,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.getChatroomInfo=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("getChatroomInfo",t,o,r,(function(t,o){var r=t?JSON.parse(t).list:[],n=[];if(r.length>0)for(var s=0;s<r.length;s++)n.push(JSON.parse(r[s].obj));setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{userInfos:n,userCount:o}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getChatroomHistoryMessages=function(t,o,r,n){var i=this;return new Promise((function(s){i._callCppProxy("getChatroomHistoryMessage",t,o,r,n,(function(t){var o;try{o=JSON.parse(t)}catch(e){o={list:[],hasMore:!1}}var r=o.list;if(r&&r.length)try{o.list=r.map((function(e){return i._buildMessage(e.obj)}))}catch(e){o.list=[]}setTimeout((function(){s({code:e.ErrorCode.SUCCESS,data:o})}),0)}),(function(e){setTimeout((function(){s({code:e})}),0)}),"")}))},t.prototype.setChatroomEntry=function(t,o){var r=this;return new Promise((function(n){var i='[{"key":"'+o.key+'", "value":"'+o.value+'"}]';r._callCppProxy("setChatroomKV",t,i,!!o.isAutoDelete,!!o.isOverwrite,(function(){setTimeout((function(){n(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){n(e)}),0)}))}))},t.prototype.setChatroomEntries=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("setChatroomKV",t,JSON.stringify(o.entries),!!o.isAutoDelete,!!o.isOverwrite,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({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(t,o){var r=this,n=[o.key];return new Promise((function(i){r._callCppProxy("deleteChatroomKV",t,n,!!o.isOverwrite,(function(){i(e.ErrorCode.SUCCESS)}),(function(e){i(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(t,o){var r=this;return new Promise((function(n){var i=o.entries.map((function(e){return e.key}));r._callCppProxy("deleteChatroomKV",t,i,!!o.isOverwrite,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}))}))},t.prototype.getChatroomEntry=function(t,o){return E(this,void 0,void 0,(function(){var r;return P(this,(function(n){switch(n.label){case 0:return[4,this.getAllChatroomEntry(t)];case 1:return(r=n.sent()).code===e.ErrorCode.SUCCESS?[2,{code:e.ErrorCode.SUCCESS,data:r.data?r.data[o]:null}]:[2,{code:r.code}]}}))}))},t.prototype.getAllChatroomEntry=function(t){var o=this;return new Promise((function(r){o._callCppProxy("getChatroomKV",t,(function(t){var o={};try{(t?JSON.parse(t):{list:[]}).list.map((function(e){return JSON.parse(e.obj)})).forEach((function(e){o[e.key]=e.value?e.value:""}))}catch(e){}setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:o})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.removeChatroomFromCatch=function(e){this._rmChatroomCache(e)},t.prototype.getFileToken=function(t,o,r,n,i,s){var a=this;return r=r||"",n=n||"",i=i||"",new Promise((function(c){var u;u=n&&"uploads"!==n?o||"":e.getUploadFileName(t,o);var p=a.getNaviInfoFromCache(),d={uploadDomain:e.getMinionURL(p,a.logger),env:a._environment};s=s?Math.ceil(s):0,a._callCppProxy("getUploadToken",t,u,r,n,i,JSON.stringify(d),s,(function(t,o,r,n,i,s,a,p,d,l,f,h,C,g,v,_,S,y,m,E,P,T,I){setTimeout((function(){c({code:e.ErrorCode.SUCCESS,data:{token:t,deadline:0,bosToken:o,bosDate:r,path:n,osskeyId:i,ossPolicy:s,ossSign:a,ossBucketName:p,fileName:u,s3Credential:d,s3Algorithm:l,s3Date:f,s3Policy:h,s3Signature:C,s3BucketName:g,stcAuthorization:v,stcContentSha256:_,stcDate:S,stcBucketName:y,minioAuthorization:m,minioContentSha256:E,minioDate:P,minioBucketName:T,downloadAuthInfo:I?JSON.parse(I):null}})}),0)}),(function(e){setTimeout((function(){c({code:e})}),0)}))}))},t.prototype.getFileUrl=function(t,o,r,n){var i=this;return new Promise((function(s){var a=i.getNaviInfoFromCache(),c={url:e.getMinionURL(a,i.logger)};i._callCppProxy("getDownloadUrl",t,r,n,o-1,JSON.stringify(c),-1,(function(t){setTimeout((function(){s({code:e.ErrorCode.SUCCESS,data:{downloadUrl:t}})}),0)}),(function(e){setTimeout((function(){s({code:e})}),0)}))}))},t.prototype.clearData=function(){var t=this;return new Promise((function(o){var r=t._callCppProxy("clearData");o({code:e.ErrorCode.SUCCESS,data:r})}))},t.prototype.getDeviceId=function(){var e=this._dbpath;return le(e)},t.prototype.getVoIPKey=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("getVoIPKey",t,o,"",(function(t){setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:t})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.bindRTCRoomForChatroom=function(t){var o=this;return new Promise((function(r){var n=t.chatRoomId,i=t.rtcRoomId;o._callCppProxy("bindRTCRoomForChatroom",n,i,(function(){setTimeout((function(){r(e.ErrorCode.SUCCESS)}),0)}),(function(e){setTimeout((function(){r(e)}),0)}))}))},t.prototype.getGroupMessageDeliverList=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("getGroupMessageDeliverList",t,r,o,(function(t,o){var r=JSON.parse(t).list.map((function(e){return{time:JSON.parse(e.obj).time,userId:JSON.parse(e.obj).id}}));setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{totalCount:o,list:r}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getPrivateMessageDeliverTime=function(t,o){var r=this;return new Promise((function(n){var i=r._callCppProxy("getMessageDeliverTime",t);if(i)n({code:e.ErrorCode.SUCCESS,data:i});else{r._callCppProxy("getPrivateMessageDeliverList",o,t,(function(t){var o=0,r=JSON.parse(t).list;if(r.length>0){var i=JSON.parse(r[0].obj).time;o=i}setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:o})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}}))},t.prototype.rtcSignaling=function(t,o,r,n){var i=this;return new Promise((function(s){i._callCppProxy("rtcSignaling",t,o,r,n,(function(t){var o=Array.prototype.slice.call(t);s({code:e.ErrorCode.SUCCESS,buffer:o})}),(function(e){s({code:e})}),30)}))},t.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 i=e.rtcHeartbeatResolves[t];if(i){var s=i.findIndex((function(e){return e.seqId===r}));-1!==s&&i.splice(s,1)[0].resolve({code:o,data:{version:Number(n)}})}}))},t.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)}))},t.prototype.createTag=function(t){var o=this;return new Promise((function(r){o._callCppProxy("addTag",t.tagId,t.tagName,(function(){setTimeout((function(){r({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.removeTag=function(t){var o=this;return new Promise((function(r){o._callCppProxy("deleteTag",t,(function(){setTimeout((function(){r({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.updateTag=function(t){var o=this;return new Promise((function(r){o._callCppProxy("renameTag",t.tagId,t.tagName,(function(){setTimeout((function(){r({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){r({code:e})}),0)}))}))},t.prototype.getTagList=function(){var t=this;return new Promise((function(o){var r=t._callCppProxy("getTags"),n=t._convertResultList(r,(function(e){return{tagId:e.tagId,tagName:e.tagName,conversationCount:e.conversationCount,createdTime:e.tagTime}}));o({code:e.ErrorCode.SUCCESS,data:n})}))},t.prototype.addTagForConversations=function(t,o){var r=this;return new Promise((function(n){o.forEach((function(e){e.conversationType&&(e.type=e.conversationType)}));r._callCppProxy("addConversationsForTag",t,JSON.stringify(o),(function(){setTimeout((function(){n({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.removeTagForConversations=function(t,o){var r=this;return new Promise((function(n){o.forEach((function(e){e.conversationType&&(e.type=e.conversationType)})),r._callCppProxy("removeConversationsForTag",t,JSON.stringify(o),(function(){setTimeout((function(){n({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.removeTagsForConversation=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("removeTagsForConversation",t.conversationType,t.targetId,t.channelId||"",o,(function(){setTimeout((function(){n({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){n({code:e})}),0)}))}))},t.prototype.getConversationListByTag=function(t,o,r,n){var i=this;return new Promise((function(s){var a=i._callCppProxy("getConversationsForTagByPage",t,o,r||20,n||""),c=i._convertResultList(a,(function(e){return m(m({},i._buildConversation(JSON.stringify(e))),{isTopInTag:e.topForTag})}));s({code:e.ErrorCode.SUCCESS,data:c})}))},t.prototype.getUnreadCountByTag=function(t,o){var r=this;return new Promise((function(n){var i=r._callCppProxy("getConversationUnreadCountForTag",t,o);n({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.setConversationStatusInTag=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("setConversationToTopForTag",t,o.conversationType,o.targetId,o.channelId||"",r.isTop||!1,(function(){setTimeout((function(){i({code:e.ErrorCode.SUCCESS})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.getTagsForConversation=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getTagsForConversation",t.conversationType,t.targetId,t.channelId||""),i=o._convertResultList(n,(function(e){return{tagId:e.tagId,tagName:e.tagName,isTop:e.isTop,createdTime:e.tagTime}}));r({code:e.ErrorCode.SUCCESS,data:i})}))},t.prototype.getBlockConversationList=function(){throw new Error("Method not implemented.")},t.prototype.getTopConversationList=function(t,o){var r=this;return new Promise((function(n){var i=e.isUndefined(o)?r._callCppProxy("getTopConversations",t):r._callCppProxy("getTopConversations",t,o),s=JSON.parse(i).list.map((function(e){return r._buildConversation(e.obj)}));n({code:e.ErrorCode.SUCCESS,data:s})}))},t.prototype.getUnreadMentionedCount=function(e){throw new Error("Method not implemented.")},t.prototype.getAllUnreadMentionedCount=function(){var t=this;return new Promise((function(o){var r=t._callCppProxy("getUnreadAndMentionCount",[e.ConversationType.GROUP],"");o({code:e.ErrorCode.SUCCESS,data:r})}))},t.prototype.getOSInfo=function(){return E(this,void 0,void 0,(function(){var t;return P(this,(function(o){return t={arch:g.arch(),platform:g.platform(),type:g.type(),version:g.version(),release:g.release(),uptime:g.uptime(),cpus:g.cpus(),freemem:g.freemem(),totalmem:g.totalmem(),networkInterfaces:g.networkInterfaces()},[2,{code:e.ErrorCode.SUCCESS,data:t}]}))}))},t.prototype.getMainProcessInfo=function(){return E(this,void 0,void 0,(function(){return P(this,(function(t){return[2,{code:e.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()}}]}))}))},t.prototype.setCallInfo=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("callInfoSignaling",t,o,r,(function(t,o){setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{key:t,value:o}})}),0)}),(function(e){setTimeout((function(){i({code:e})}),0)}))}))},t.prototype.setProxy=function(t){return this.tcpMgr.getConnectionStatus()!==e.RCConnectionStatus.DISCONNECTED?Promise.resolve({code:e.ErrorCode.RC_CONN_PROXY_UNAVAILABLE}):Promise.resolve($(t,this.logger))},t.prototype.getProxy=function(){return Promise.resolve(Z())},t.prototype.testProxy=function(t,o){return function(t,o,r){return new Promise((function(n){var i=/^https/.test(o)?Y:K;r.info(e.LogTagId.A_TEST_PROXY_O,JSON.stringify({msg:"test proxy",proxy:t,testHost:o}));var s=i(o,t,(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})}))}));s.once("timeout",(function(){return n({status:0})})),s.once("error",(function(e){return n({status:0,data:e.stack})})),s.end()}))}(t,o,this.logger)},t.prototype.checkDuplicateMessage=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("checkDuplicateMessage",t);r({code:e.ErrorCode.SUCCESS,data:n})}))},t.prototype.subscribeUser=function(t,o,r){var n=this;return new Promise((function(i){n._callCppProxy("updateSubscribeStatus",o,e.SubscribeOperationType.SUBSCRIBE,t,(function(){i({code:e.ErrorCode.SUCCESS})}),(function(e,t){i({code:e,data:t})}),r)}))},t.prototype.unSubscribeUser=function(t,o){var r=this;return new Promise((function(n){r._callCppProxy("updateSubscribeStatus",o,e.SubscribeOperationType.UNSUBSCRIBE,t,(function(){n({code:e.ErrorCode.SUCCESS})}),(function(e){n({code:e})}),0)}))},t.prototype.getSubscribeUserList=function(t,o,r){var n=this._callCppProxy("getSubscribeUserList",t,o,r),i=this._buildSubscribeEventData(n).map((function(t){var o=t.userId,r=t.subscribeType,n=t.subscribeTime,i=t.expiry,s=t.details,a={userId:o,subscribeType:r,subscribeTime:n,expiry:i};return r===e.SubscribeType.ONLINE_STATUS&&(a.details=e.completeSubscriptionPlatformStatus(s)),a}));return Promise.resolve({code:e.ErrorCode.SUCCESS,data:i})},t.prototype.setDuplicateMessageConfig=function(t){var o=this._callCppProxy("setDuplicateMessageConfig",[e.ConversationType.CHATROOM],me.cuid,t);return Promise.resolve({code:o})},t.prototype.getSubscribeUserStatus=function(t,o){var r=this._callCppProxy("getSubscribeStatusByUserIds",t,o),n=this._buildSubscribeEventData(r).map((function(t){var o=t.userId,r=t.subscribeType,n=t.subscribeTime,i=t.expiry,s=t.details,a={userId:o,subscribeType:r,subscribeTime:n,expiry:i};return r===e.SubscribeType.ONLINE_STATUS&&(a.details=e.completeSubscriptionPlatformStatus(s)),a}));return Promise.resolve({code:e.ErrorCode.SUCCESS,data:n})},t.prototype.updateMyUserProfile=function(e){var t=this;return new Promise((function(o){var r=[],n=[];Object.keys(e).forEach((function(t){var o;if("extraProfile"===t&&e.extraProfile){if(e.extraProfile){var i=e.extraProfile;Object.keys(i).forEach((function(e){n.push(JSON.stringify({key:e,value:i[e]||""}))}))}}else r.push(JSON.stringify({key:t,value:(null===(o=e[t])||void 0===o?void 0:o.toString())||""}))})),t._callCppProxy("updateUserProfile",r,n,(function(e,t){o({code:e,data:{errorKey:t}})}))}))},t.prototype.getUserProfiles=function(e){var t=this;return new Promise((function(o){t._callCppProxy("getUserProfiles",e,(function(e,r){o({code:e,data:t._string2UserProfileInfoList(r)})}))}))},t.prototype.getMyUserProfile=function(){var e=this;return new Promise((function(t){e._callCppProxy("getOwnUserProfile",(function(o,r){t({code:o,data:e._string2userProfileInfo(r)})}))}))},t.prototype._string2userProfileInfo=function(e){var t;try{var o=JSON.parse(e),r=o.userProfile.reduce((function(e,t){var o=JSON.parse(t);return["gender","role","level"].includes(o.key)?e[o.key]=Number(o.value):e[o.key]=o.value,e}),{});return r.userId=o.userId,r.extraProfile=(null===(t=o.userExtProfile)||void 0===t?void 0:t.reduce((function(e,t){var o=JSON.parse(t);return e[o.key]=o.value,e}),{}))||{},r}catch(t){this.logger.error(y.P_PARSE_JSON_USER_PROFILE_E,JSON.stringify({error:null==t?void 0:t.stack,str:e}))}return{}},t.prototype._string2UserProfileInfoList=function(e){var t=this;try{return JSON.parse(e).list.map((function(e){return t._string2userProfileInfo(e.obj)}))}catch(t){this.logger.error(y.P_PARSE_JSON_USER_PROFILE_E,JSON.stringify({error:null==t?void 0:t.stack,str:e}))}return[]},t.prototype.updateMyUserProfileVisibility=function(t){var o=this;return new Promise((function(r){o._callCppProxy("updateUserProfilePermission",t,(function(){r({code:e.ErrorCode.SUCCESS})}),(function(e){r({code:e})}))}))},t.prototype.getMyUserProfileVisibility=function(){var e=this;return new Promise((function(t){e._callCppProxy("getUserProfilePermission",(function(e,o){t({code:e,data:o})}))}))},t.prototype.searchUserProfileByUniqueId=function(e){var t=this;return new Promise((function(o){t._callCppProxy("getUserProfileByUniqueId",e,(function(e,r){o({code:e,data:t._string2userProfileInfo(r)})}))}))},t.prototype.getMatchedMessage=function(t,o,r,n){var i,s=this._callCppProxy("getMatchedMessage",t.conversationType,t.targetId,o,r,n,t.channelId||""),a=[];try{i=JSON.parse(s).list;for(var c=0;c<i.length;c++){var u=this._buildMessage(i[c].obj);a.push(u)}}catch(t){return this.logger.error(y.P_PARSE_JSON_MSGS_E,s),Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:a})},t.prototype.getConversations=function(t){var o,r=this,n=t.map((function(e){var t=e.conversationType,o=e.targetId,r=e.channelId;return{targetId:o,channelId:void 0===r?"":r,type:t}})),i=this._callCppProxy("getConversations",JSON.stringify(n));try{o=JSON.parse(i).list.map((function(e){return r._buildConversation(e.obj)}))}catch(t){return this.logger.error(y.P_PARSE_JSON_MSGS_E,i),Promise.resolve({code:e.ErrorCode.MAIN_PROCESS_ERROR})}return Promise.resolve({code:e.ErrorCode.SUCCESS,data:o})},t.prototype.handleErrorCode=function(t,o){t!==e.ErrorCode.SUCCESS&&setTimeout((function(){o({code:t})}),0)},t.prototype._convertGroupInfoList=function(t,o){return t&&0!==t.length?t.map((function(t){var o=t.groupId,r=t.baseInfo,n=t.createTime,i=t.createUserId,s=t.extraInfo,a=t.memberCount,c=t.ownerId,u=t.remark,p=t.joinTime,d=t.role,l=e.arrayToKeyValue(r),f=e.arrayToKeyValue(s);return{groupId:o,groupName:l.name||"",portraitUri:l.portraitUrl||"",introduction:l.introduction||"",notice:l.announcement||"",joinPermission:~~l.joinPerm,removeMemberPermission:~~l.removePerm,invitePermission:~~l.memInvitePerm,inviteHandlePermission:~~l.invitePerm,groupInfoEditPermission:~~l.profilePerm,memberInfoEditPermission:~~l.memProfilePerm,extProfile:f,creatorId:i||"",ownerId:c||"",createTime:n||0,membersCount:a||0,remark:u||"",joinedTime:p||0,role:d||e.GroupMemberRole.UNDEF}})):[]},t.prototype._convertUpdateGroupInfoList=function(t){return t&&0!==t.length?t.map((function(t){var o=t.groupId,r=t.baseInfo,n=t.createTime,i=t.createUserId,s=t.extraInfo,a=t.memberCount,c=t.ownerId,u=t.remark,p=t.joinTime,d=t.role,l=e.arrayToKeyValue(r),f=e.arrayToKeyValue(s);return m(m(m(m(m(m(m(m(m({groupId:o},e.formatGroupBaseInfo(l)),s.length>0&&{extProfile:f}),i&&{creatorId:i}),c&&{ownerId:c}),n&&{createTime:n}),a&&{membersCount:a}),u&&{remark:u}),p&&{joinedTime:p}),d&&{role:d})})):[]},t.prototype._convertGroupMemberInfoList=function(e){return e&&0!==e.length?e.map((function(e){var t=e.userId,o=e.nickname,r=e.groupNickname,n=e.portraitUrl,i=e.joinTime;return{userId:t,name:o||"",portraitUri:n||"",nickname:r||"",role:e.role||0,joinedTime:i||0,extra:e.extra||""}})):[]},t.prototype.createGroup=function(t,o,r,n){return E(this,void 0,void 0,(function(){var i=this;return P(this,(function(s){return[2,new Promise((function(s){var a=_e(o),c=_e(r||{}),u=i._callCppProxy("createGroup",t,n,JSON.stringify(a),JSON.stringify(c),(function(t,o,r){t===e.ErrorCode.SUCCESS?setTimeout((function(){s({code:t,data:{processCode:o}})}),0):setTimeout((function(){s({code:t,msg:null!=r?r:""})}),0)}));i.handleErrorCode(u,s)}))]}))}))},t.prototype.updateGroupInfo=function(t,o,r){return E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=_e(o),a=_e(null!=r?r:{}),c=n._callCppProxy("updateGroupInfo",t,JSON.stringify(s),JSON.stringify(a),(function(t,o){t===e.ErrorCode.SUCCESS?setTimeout((function(){i({code:t})}),0):setTimeout((function(){i({code:t,msg:null!=o?o:""})}),0)}));n.handleErrorCode(c,i)}))]}))}))},t.prototype.getGroupsInfo=function(t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=o._callCppProxy("getGroupInfoByIds",t,(function(t,n,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){o.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){r({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:o._convertGroupInfoList(a)})}),0)}else setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))]}))}))},t.prototype.kickGroupMembers=function(e,t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=Se(o),s=r._callCppProxy("kickOutGroupMember",e,t,JSON.stringify(i),(function(e,t){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(s,n)}))]}))}))},t.prototype.quitGroup=function(e,t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=Se(t),i=o._callCppProxy("quitGroup",e,JSON.stringify(n),(function(e,t){setTimeout((function(){r({code:e})}),0)}));o.handleErrorCode(i,r)}))]}))}))},t.prototype.dismissGroup=function(e){return E(this,void 0,void 0,(function(){var t=this;return P(this,(function(o){return[2,new Promise((function(o){var r=t._callCppProxy("disbandGroup",e,(function(e,t){setTimeout((function(){o({code:e})}),0)}));t.handleErrorCode(r,o)}))]}))}))},t.prototype.transferGroupOwner=function(e,t,o,r){return E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=Se(r),a=n._callCppProxy("transferGroup",e,t,o,JSON.stringify(s),(function(e,t){setTimeout((function(){i({code:e})}),0)}));n.handleErrorCode(a,i)}))]}))}))},t.prototype.setGroupManagers=function(e,t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=r._callCppProxy("updateGroupAdmins",t,o,e,(function(e,t){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(i,n)}))]}))}))},t.prototype.getGroupMembersByRole=function(t,o,r){return E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=o===e.GroupMemberRole.UNDEF?[1,2,3]:[o],a=n._callCppProxy("getGroupMembers",t,s,r.pageToken||"",r.count,r.order?1:0,(function(t,o,r,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){n.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){i({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=n._convertGroupMemberInfoList(a);setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{totalCount:null!=r?r:0,data:c,pageToken:null!=o?o:""}})}),0)}else setTimeout((function(){i({code:t})}),0)}));n.handleErrorCode(a,i)}))]}))}))},t.prototype.getGroupMembers=function(t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=r._callCppProxy("getGroupMembersByIds",t,o,(function(t,o,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){r.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){n({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=r._convertGroupMemberInfoList(a);setTimeout((function(){n({code:e.ErrorCode.SUCCESS,data:c})}),0)}else setTimeout((function(){n({code:t})}),0)}));r.handleErrorCode(i,n)}))]}))}))},t.prototype.setGroupMemberInfo=function(e,t,o,r){return E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=n._callCppProxy("updateGroupMemberInfo",e,t,o,r||"",(function(e,t){setTimeout((function(){i({code:e})}),0)}));n.handleErrorCode(s,i)}))]}))}))},t.prototype.searchGroupMembers=function(t,o,r){return E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=r.order?1:0,a=n._callCppProxy("getGroupMembersByNickname",t,o,r.pageToken||"",r.count,s,(function(t,o,r,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){n.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){i({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=n._convertGroupMemberInfoList(a);setTimeout((function(){i({code:e.ErrorCode.SUCCESS,data:{data:c,pageToken:o,totalCount:r}})}),0)}else setTimeout((function(){i({code:t})}),0)}));n.handleErrorCode(a,i)}))]}))}))},t.prototype.joinGroup=function(t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=o._callCppProxy("joinGroup",t,(function(t,o,n){t===e.ErrorCode.SUCCESS?setTimeout((function(){r({code:t,data:{processCode:o}})}),0):setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))]}))}))},t.prototype.inviteUsersToGroup=function(t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=r._callCppProxy("inviteUsersToGroup",t,o,(function(t,o,r){t===e.ErrorCode.SUCCESS?setTimeout((function(){n({code:t,data:{processCode:o}})}),0):setTimeout((function(){n({code:t})}),0)}));r.handleErrorCode(i,n)}))]}))}))},t.prototype.memberInviteResponse=function(t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=t.groupId,i=t.inviterId,s=t.optType,a=t.optResult,c=t.joinUserId,u=t.reason,p=1===s?1:0,d=p&&c?c:"",l=o._callCppProxy("handleGroupInvite",n,d,i,a,p,null!=u?u:"",(function(t,o,n){t===e.ErrorCode.SUCCESS?setTimeout((function(){r({code:t,data:{processCode:o}})}),0):setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(l,r)}))]}))}))},t.prototype.getGroupApplications=function(t,o,r){return void 0===o&&(o=[]),void 0===r&&(r=[]),E(this,void 0,void 0,(function(){var n=this;return P(this,(function(i){return[2,new Promise((function(i){var s=t.order?1:0,a=n._callCppProxy("getGroupRequests",o,r,"",t.pageToken||"",t.count,s,(function(t,o,r,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){n.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){i({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=a.map((function(e){var t=e.groupId,o=e.joinUser,r=e.approverUser,n=e.inviterUser,i=e.type;return{groupId:t,joinMemberInfo:o,inviterInfo:n,operatorInfo:r,status:e.status,direction:e.direction,type:i,operationTime:e.operateTime,reason:e.remark}}));setTimeout((function(){i({code:t,data:{totalCount:r,data:c,pageToken:o}})}),0)}else setTimeout((function(){i({code:t})}),0)}));n.handleErrorCode(a,i)}))]}))}))},t.prototype.getJoinedGroupsByRole=function(t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=o.order?1:0,s=t===e.GroupMemberRole.UNDEF?[1,2,3]:[t],a=r._callCppProxy("getGroups",s,o.pageToken||"",o.count,i,(function(t,o,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){r.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){n({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=r._convertGroupInfoList(a);setTimeout((function(){n({code:t,data:{totalCount:i,data:c,pageToken:o}})}),0)}else setTimeout((function(){n({code:t})}),0)}));r.handleErrorCode(a,n)}))]}))}))},t.prototype.searchJoinedGroups=function(t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=o.order?1:0,s=r._callCppProxy("getGroupsByGroupName",t,o.pageToken||"",o.count,i,(function(t,o,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){r.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){n({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=r._convertGroupInfoList(a);setTimeout((function(){n({code:t,data:{totalCount:i,data:c,pageToken:o}})}),0)}else setTimeout((function(){n({code:t})}),0)}));r.handleErrorCode(s,n)}))]}))}))},t.prototype.getJoinedGroups=function(t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=o._callCppProxy("getGroupsByIds",t,(function(t,n,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){o.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){r({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=o._convertGroupInfoList(a);setTimeout((function(){r({code:t,data:c})}),0)}else setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))]}))}))},t.prototype.setGroupRemark=function(t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=o?e.GroupOperationType.ADD:e.GroupOperationType.REMOVE,s=r._callCppProxy("updateGroupRemark",t,o||"",i,(function(e,t){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(s,n)}))]}))}))},t.prototype.setGroupFollows=function(e,t,o){return E(this,void 0,void 0,(function(){var r=this;return P(this,(function(n){return[2,new Promise((function(n){var i=r._callCppProxy("updateFavoriteMembers",t,o,e,(function(e,t){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(i,n)}))]}))}))},t.prototype.getGroupFollows=function(t){return E(this,void 0,void 0,(function(){var o=this;return P(this,(function(r){return[2,new Promise((function(r){var n=o._callCppProxy("getGroupFavoriteMembers",t,"",1e3,0,(function(t,n,i,s){if(t===e.ErrorCode.SUCCESS){var a=[];try{a=JSON.parse(s)}catch(t){o.logger.error(y.P_PARSE_JSON_MSGS_E,s),setTimeout((function(){r({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var c=a.map((function(e){return{userId:e.userId,time:e.followTime}}));setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:c})}),0)}else setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))]}))}))},t.prototype.addFriend=function(e,t,o){var r=this;return new Promise((function(n){var i=r._callCppProxy("addFriend",e,t,o,(function(e,t,o){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(i,n)}))},t.prototype.deleteFriends=function(e,t){var o=this;return new Promise((function(r){var n=o._callCppProxy("removeFriends",e,t,(function(e,t){setTimeout((function(){r({code:e})}),0)}));o.handleErrorCode(n,r)}))},t.prototype.acceptFriendApplication=function(e){var t=this;return new Promise((function(o){var r=t._callCppProxy("acceptFriendRequest",e,"",(function(e,t){setTimeout((function(){o({code:e})}),0)}));t.handleErrorCode(r,o)}))},t.prototype.refuseFriendApplication=function(e,t){var o=this;return new Promise((function(r){var n=o._callCppProxy("rejectFriendRequest",e,t||"",(function(e,t){setTimeout((function(){r({code:e})}),0)}));o.handleErrorCode(n,r)}))},t.prototype.setFriendInfo=function(e,t,o){var r=this;return new Promise((function(n){var i=_e(null!=o?o:{}),s=r._callCppProxy("setFriendInfo",e,t,JSON.stringify(i),(function(e,t){setTimeout((function(){n({code:e})}),0)}));r.handleErrorCode(s,n)}))},t.prototype.checkFriends=function(t,o){var r=this;return new Promise((function(n){var i=r._callCppProxy("checkFriendRelationship",t,o,(function(t,o){if(t===e.ErrorCode.SUCCESS){var r=JSON.parse(o).map((function(e){return{userId:e.userId,relationType:e.status}}));setTimeout((function(){n({code:t,data:r})}),0)}else setTimeout((function(){n({code:t})}),0)}));r.handleErrorCode(i,n)}))},t.prototype.getFriends=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getFriends",t,0,(function(t,n){try{if(t===e.ErrorCode.SUCCESS){var i=JSON.parse(n),s=o._convertFriendInfo(i);setTimeout((function(){r({code:t,data:{data:s,pageToken:""}})}),0)}else setTimeout((function(){r({code:t})}),0)}catch(t){o.logger.error(y.P_PARSE_JSON_MSGS_E,n),setTimeout((function(){r({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}}));o.handleErrorCode(n,r)}))},t.prototype.getFriendApplications=function(t,o,r){var n=this;return new Promise((function(i){var s=t.order?1:0,a=3;o&&1===o.length&&(a=null==o?void 0:o[0]);var c=n._callCppProxy("getFriendRequestListByPage",a,r||[0,1,2,3],t.count,t.pageToken||"",s,(function(t,o,r){if(t===e.ErrorCode.SUCCESS){var s=[];try{s=JSON.parse(r)}catch(t){n.logger.error(y.P_PARSE_JSON_MSGS_E,r),setTimeout((function(){i({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}var a=s.map((function(e){return{userId:e.userId,name:e.name,portraitUri:e.portraitUrl,applicationType:e.friendRequestType,applicationStatus:e.friendRequestStatus,operationTime:e.operateTime,remark:e.extra}}));setTimeout((function(){i({code:t,data:{data:a,pageToken:null!=o?o:""}})}),0)}else setTimeout((function(){i({code:t})}),0)}));n.handleErrorCode(c,i)}))},t.prototype.deleteFriendApplication=function(t,o){return Promise.resolve({code:e.ErrorCode.NOT_SUPPORT})},t.prototype._convertFriendInfo=function(e){return e.map((function(e){var t=e.userId,o=e.userName,r=e.remark;return{userId:t,name:o,portraitUri:e.portraitUrl,remark:r,directionType:e.friendType,extProfile:e.extProfiles,addTime:e.addTime,inBlackList:!!e.friendAttribute}}))},t.prototype.getFriendsInfo=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getFriendByIds",t,(function(t,n){if(t===e.ErrorCode.SUCCESS){var i=JSON.parse(n),s=o._convertFriendInfo(i);setTimeout((function(){r({code:t,data:s})}),0)}else setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))},t.prototype.searchFriendsInfo=function(t){var o=this;return new Promise((function(r){var n=o._callCppProxy("getFriendByNickname",t,(function(t,n){if(t===e.ErrorCode.SUCCESS)try{var i=JSON.parse(n),s=o._convertFriendInfo(i);setTimeout((function(){r({code:e.ErrorCode.SUCCESS,data:s})}),0)}catch(t){o.logger.error(y.P_PARSE_JSON_MSGS_E,n),setTimeout((function(){r({code:e.ErrorCode.MAIN_PROCESS_ERROR})}),0)}else setTimeout((function(){r({code:t})}),0)}));o.handleErrorCode(n,r)}))},t.prototype.setFriendAddPermission=function(e){var t=this;return new Promise((function(o){var r=t._callCppProxy("setFriendAuthPermission",e,(function(e,t){setTimeout((function(){o({code:e})}),0)}));t.handleErrorCode(r,o)}))},t.prototype.getFriendAddPermission=function(){var e=this;return new Promise((function(t){var o=e._callCppProxy("getFriendAuthPermission",(function(e,o){setTimeout((function(){t({code:e,data:o})}),0)}));e.handleErrorCode(o,t)}))},t.prototype.setDataBaseLogConfig=function(e){this._callCppProxy("setDataBaseLogConfig",e)},t}(),Oe=r.resolve(__dirname,"binding","electron-"+n.platform()+"-"+n.arch()+".node"),Ne={addon:null},Me=(Ie=process,{sendError:function(e){Ie.send({type:x.ERROR,data:{msg:e}})},sendEvent:function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];Ie.send({type:x.EVENT,data:{eventName:e,data:t}})},sendResponse:function(e){Ie.send({type:x.RESPONSE,data:e})},sendCallback:function(e){Ie.send({type:x.CALLBACK,data:e})}}).sendError;try{Ne.addon=require(Oe)}catch(e){console.error("error ->",Oe,"\n",e),Me(e.toString())}Ne.addon||console.error("error -> cannot find module: ",Oe);var be,Ue=Ne.addon,xe=function(){function e(e,t,o,r,n,i,s){this.sendCallback=i,this._cppService=new Re(e,Ue,t,n,r,o,s)}return e.prototype.call=function(e){for(var t=[],o=1;o<arguments.length;o++)t[o-1]=arguments[o];return E(this,void 0,void 0,(function(){var o,r=this;return P(this,(function(n){switch(n.label){case 0:return"sendMessage"===e&&(t[3]=function(e){var o=t[3];r.sendCallback({reqId:o,data:e})}),[4,(o=this._cppService).callProxy.apply(o,T([e],t,!1))];case 1:return[2,{success:!0,data:n.sent()}]}}))}))},e.prototype.send=function(e){for(var t,o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];(t=this._cppService).sendProxy.apply(t,T([e],o,!1))},e.prototype.destroy=function(){this._cppService.destroy()},e}(),Le=function(){function n(o,r,n,i,s,a){var c=this;void 0===a&&(a=!1),this._appkey=o,this._dbpath=r,this._logOutputLevel=n,this._runInMainProcess=i,this._enableSyncEmptyTopConversation=s,this._disableLogReport=a,this._catch={crtUserId:"",connectedTime:0,naviInfo:null,connectionStatus:2,deviceId:"",deltaTime:0},this._connectionStatus=e.RCConnectionStatus.DISCONNECTED,this._connectInfo={token:"",reconnectKickEnable:!1,openCallPlus:!1,traceId:""},this._registerMessageTypeList=[],this._isProcessQuit=!1,this._rendererInitOptions=null,this._senders={},this._callbackCache={},this._createServiceProxy(),t.ipcMain.on("__RC_CHANNEL_CALL_MAIN_SYNC__",(function(e,t){for(var o=[],r=2;r<arguments.length;r++)o[r-2]=arguments[r];return E(c,void 0,void 0,(function(){var r,n;return P(this,(function(i){switch(i.label){case 0:return[4,(n=this._cppServiceProcessProxy).call.apply(n,T([t],o,!1))];case 1:return r=i.sent(),e.returnValue=r.data,[2]}}))}))})),t.ipcMain.on("__RC_CHANNEL_CALL_MAIN__",(function(e,t,o){for(var r=[],n=3;n<arguments.length;n++)r[n-3]=arguments[n];return E(c,void 0,void 0,(function(){var n,i,s;return P(this,(function(a){switch(a.label){case 0:return"sendMessage"===o&&(n=r[3],this._callbackCache[n]=e.sender),"connect"===o&&(this._connectInfo={token:r[0],reconnectKickEnable:r[1],openCallPlus:r[2],traceId:r[3]}),[4,(s=this._cppServiceProcessProxy).call.apply(s,T([o],r,!1))];case 1:if(!(i=a.sent()).success)throw new Error(i.data.msg);return this._send2Renderer(e.sender,"__RC_CHANNEL_RESULT_FROM_MAIN__",t,i.data),[2]}}))}))})),t.ipcMain.on("__RC_CHANNEL_SEND_2_MAIN__",(function(e,t){for(var o,r=[],n=2;n<arguments.length;n++)r[n-2]=arguments[n];"registerMessageType"===t&&c._registerMessageTypeList.push({objectName:r[0],isPersited:r[1],isCounted:r[2],searchProps:r[3]}),(o=c._cppServiceProcessProxy).send.apply(o,T([t],r,!1))})),t.ipcMain.on("__RC_INNER_COMMAND_INIT__",this._registerRenderers.bind(this)),t.app.on("before-quit",(function(){c._isProcessQuit=!0,c.destroy()})),t.app.on("window-all-closed",(function(){c._isProcessQuit=!0,c.destroy()}))}return n.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))},n.prototype._send2AllRenderer=function(e,t,o){var r=this;void 0===o&&(o=[]),Object.keys(this._senders).forEach((function(n){var i=r._senders[n];o.includes(i)||r._send2Renderer(i,"__RC_CHANNEL_NOTIFICATION_FROM_MAIN__",e,t)}))},n.prototype._registerRenderers=function(e,t){var o=this,r=e.sender,n=r.id;this._rendererInitOptions||(this._rendererInitOptions=t),this._cppServiceProcessProxy.send("registerRenderers",t),this._senders[n]||(this._senders[n]=r,r.once("destroyed",(function(){delete o._senders[n]})))},n.prototype.getMainCache=function(){return this._catch},n.prototype._restartSubProcessProxy=function(){var t=this;if(this._createServiceProxy(),this._connectionStatus!==e.RCConnectionStatus.DISCONNECTED){this._send2AllRenderer("onSuspend",e.ErrorCode.SUB_PROCESS_EXIT),this._registerMessageTypeList.forEach((function(e){t._cppServiceProcessProxy.send("registerMessageType",e.objectName,e.isPersited,e.isCounted,e.searchProps)})),this._cppServiceProcessProxy.send("registerRenderers",this._rendererInitOptions);var o=this._connectInfo,r=o.token,n=o.reconnectKickEnable,i=o.openCallPlus;this._cppServiceProcessProxy.send("reconnect",r,n,i)}},n.prototype._eventNotifyHandler=function(t){for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];var n=o[0],i=o[1];switch(t){case"onConnected":this._catch=n,this._connectionStatus=e.RCConnectionStatus.CONNECTED;break;case"onSuspend":this._connectionStatus=e.RCConnectionStatus.SUSPENDED;break;case"onDisconnected":this._connectionStatus=e.RCConnectionStatus.DISCONNECTED;break;case"onConnecting":this._connectionStatus=e.RCConnectionStatus.CONNECTING}this._send2AllRenderer(t,n,i)},n.prototype._callbackHandler=function(e){var t=e.reqId,o=e.data;this._callbackCache[t]&&this._send2Renderer(this._callbackCache[t],"__RC_CHANNEL_RESULT_FROM_MAIN__",t,o)},n.prototype._createServiceProxy=function(){var e=this,n=this._dbpath||r.resolve(t.app.getPath("userData"));if(this._runInMainProcess)this._cppServiceProcessProxy=new xe(this._appkey,n,this._logOutputLevel,this._enableSyncEmptyTopConversation,this._eventNotifyHandler.bind(this),this._callbackHandler.bind(this),this._disableLogReport);else{var i=o.fork(r.resolve(__dirname,"cppServiceProcess.js"),[this._appkey,n,this._enableSyncEmptyTopConversation.toString(),this._logOutputLevel.toString(),this._disableLogReport.toString()]);this._cppServiceProcessProxy=new ee(i,this._eventNotifyHandler.bind(this),this._callbackHandler.bind(this),(function(t,o){void 0===o&&(o=!1);var r="sub process exit, msg: "+t+", isRestart: "+o+", _isProcessQuit: "+e._isProcessQuit;if(console.error(r),o&&!e._isProcessQuit)return e._restartSubProcessProxy()}))}},n.prototype.destroy=function(){this._cppServiceProcessProxy.destroy()},n.prototype.setDataBaseLogConfig=function(e){this._cppServiceProcessProxy.call("setDataBaseLogConfig",e)},n}(),we=function(){function e(e,t,o,r,n,i){this._rcMain=new Le(e,t,o,r,n,i)}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._rcMain.destroy()},e.prototype.getDeviceId=function(){return this._rcMain.getMainCache().deviceId},e.prototype.getServerTime=function(){return this._rcMain.getMainCache().connectedTime},e.prototype.setDatabaseOperationTimeThreshold=function(e){return this._rcMain.setDataBaseLogConfig(e)},e}();module.exports=function(t){return function(t,o){if(be)return be;if(!t)throw new Error("Initializ failed, `appkey` is required!");return be=new we(t,(null==o?void 0:o.dbpath)||"",(null==o?void 0:o.logOutputLevel)||e.LogL.WARN,(null==o?void 0:o.runInMainProcess)||!1,!!(null==o?void 0:o.enableSyncEmptyTopConversation),(null==o?void 0:o.disableLogReport)||!1)}(t.appkey,t)};
|