@rongcloud/electron 5.12.2 → 5.12.3

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