Socket
Socket
Sign inDemoInstall

@tencentcloud/chat

Package Overview
Dependencies
Maintainers
13
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tencentcloud/chat - npm Package Compare versions

Comparing version 3.2.5 to 3.2.6

2

modules/follow-module.js

@@ -1,1 +0,1 @@

"use strict";const t=12,e=20,o=23,s=27;class n{constructor(t=0,e=0){this.high=t,this.low=e}equal(t){return null!==t&&this.low===t.low&&this.high===t.high}toString(){var t=Number(this.high).toString(16);let e=Number(this.low).toString(16);if(e.length<8){let t=8-e.length;for(;t;)e="0"+e,t--}return t+e}}const i={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},r={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15},l="CHINA",u={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(t=l){this.CURRENT=i.PRODUCTION[t]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report"}},a=(new n(0,Math.pow(2,0)).toString(),new n(0,Math.pow(2,1)).toString(),new n(0,Math.pow(2,2)).toString(),new n(0,Math.pow(2,3)).toString(),new n(0,Math.pow(2,4)).toString(),new n(0,Math.pow(2,6)).toString(),new n(0,Math.pow(2,7)).toString(),new n(0,Math.pow(2,9)).toString(),new n(0,Math.pow(2,10)).toString(),new n(0,Math.pow(2,11)).toString(),new n(0,Math.pow(2,13)).toString(),new n(0,Math.pow(2,15)).toString(),new n(Math.pow(2,6)).toString(),new n(Math.pow(2,7)).toString(),new n(Math.pow(2,8)).toString(),new n(Math.pow(2,9)).toString(),new n(Math.pow(2,10)).toString(),new n(Math.pow(2,16)).toString(),u.HOST.setCurrent(l),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),c=(a&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),h="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),_="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),g="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,m="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,w=a||c||h||_||g||m||f,d=("undefined"!=typeof uni||"undefined"!=typeof window)&&!w,p=(c?qq:h?tt:_?swan:g?my:a?wx:m?uni:f&&jd,d&&window&&window.navigator&&window.navigator.userAgent||""),L=/(micromessenger|webbrowser)/i.test(p),I=/AppleWebKit\/([\d.]+)/i.exec(p),T=(I&&parseFloat(I.pop()),function(){let t="WEB";return L?t="WEB":c?t="QQ_MP":h?t="TT_MP":_?t="BAIDU_MP":g?t="ALI_MP":a?t="WX_MP":m&&(t="UNI_NATIVE_APP"),r[t]}()),M=(!function(){var t=p.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),function(){var t,e,o=p.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);o&&(t=o[1]&&parseFloat(o[1]),e=o[2]&&parseFloat(o[2]),t&&e&&parseFloat(o[1]+"."+o[2]))}(),function(){var t=p.match(/Chrome\/(\d+)/);t&&t[1]&&parseFloat(t[1])}(),/MSIE/.test(p)||-1<p.indexOf("Trident")&&-1<p.indexOf("rv:11.0"));let y,A;!function(){var t=/MSIE\s(\d+)\.\d/.exec(p),t=t&&parseFloat(t[1]);!t&&/Trident\/7.0/i.test(p)&&/rv:11.0/.test(p)}(),function(){var t=p.match(/TBS\/(\d+)/i);t&&t[1]&&t[1]}(),y="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const S=function(){},E=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let F=E.length;for(;F--;)A=E[F],console[A]||(y[A]=S);var O=y;const U=function(){return(new Date).getTime()+0},C="Tag_Profile_IM_Nick",D="Tag_Profile_IM_Gender",N="Tag_Profile_IM_BirthDay",P="Tag_Profile_IM_Location",v="Tag_Profile_IM_SelfSignature",R="Tag_Profile_IM_AllowType",b="Tag_Profile_IM_Language",G="Tag_Profile_IM_Image",q="Tag_Profile_IM_MsgSettings",k="Tag_Profile_IM_AdminForbidType",x="Tag_Profile_IM_Level",W="Tag_Profile_IM_Role",$=Object.prototype.hasOwnProperty,B=function(t){return"map"===z(t)},j=function(t){return"set"===z(t)},H=function(t){return"file"===z(t)},K=function(t){return null!==t&&("number"==typeof t&&!isNaN(+t)||"object"==typeof t&&t.constructor===Number)},Y=function(t){if("object"!=typeof t||null===t)return!1;t=Object.getPrototypeOf(t);if(null===t)return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return t===e},X=function(t){return void 0===t},V=function(t){return e=t,("function"==typeof Array.isArray?Array.isArray(e):"array"===z(e))||null!==t&&"object"==typeof t;var e},z=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()},J=(Date.now||(Date.now=function(){return(new Date).getTime()}),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),Q=J.length;function Z(){return!M&&!w}let et=0;function ot(){return Z()?"%c Chat %c":"Chat"}function st(){const t=function(){const t=new Date;return t.setTime(U()),t}();return t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(t){let e;switch(t.toString().length){case 1:e="00"+t;break;case 2:e="0"+t;break;default:e=t}return e}(t.getMilliseconds())}const nt={arguments2String(o){let s="";if(1===o.length)s=o[0];else for(let t=0,e=o.length;t<e;t++)V(o[t])?o[t]instanceof Error?s+=(n=o[t],JSON.stringify(n,["message","code"])):s+=JSON.stringify(o[t]):s+=o[t],s+=" ";var n;return s},_exec(t,e){Z()?O[t](ot(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",st(),e):O[t](`${ot()} ${st()} `+e)},d:function(){var t;et<=-1&&(t=this.arguments2String(arguments),this._exec("debug",t))},l:function(){var t;et<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},log:function(){var t;et<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},i:function(){var t;et<=1&&(t=this.arguments2String(arguments),this._exec("info",t))},w:function(){var t;et<=2&&(t=this.arguments2String(arguments),this._exec("warn",t))},e:function(){var t;et<=3&&(t=this.arguments2String(arguments),this._exec("error",t))},setLevel:function(t){t<4&&this._exec("log","set level from "+et+" to "+t),et=t},getLevel:function(){return et}},it=function(t){return{code:0,data:t||{}}};class rt extends Error{constructor(t){super();var{code:t,message:e,data:o}=t;this.code=t,this.message=e||this._getErrorMessage(this.code),this.data=o||{}}}const lt=2805,ut=2903,at=3122,ct="onMyFollowersListUpdated",ht="onMyFollowingListUpdated",_t="onMutualFollowersListUpdated",gt="error";let ft=null;const mt=function(t){return Promise.resolve(it(t))},wt=function(t,e=!1){if(t instanceof rt)return e&&null!==ft&&ft.emit(gt,t),Promise.reject(t);if(t instanceof Error){const t=new rt({code:ut});return e&&null!==ft&&ft.emit(gt,t),Promise.reject(t)}if(X(t)||X(t.code))return Promise.reject(new rt({code:ut}));t=new rt(t);return e&&null!==ft&&ft.emit(gt,t),Promise.reject(t)},dt="follow_add",pt="follow_delete",Lt="follow_get",It="follow_get_info",Tt={info:4,warning:5,error:6},Mt={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},yt={login:4,plugin_translate:16,plugin_voice_to_text:16,plugin_cs:16,plugin_push:16,plugin_bot:16,plugin_emoji_reaction:16};class At{constructor(t){this._n="SSOLogData",this.eventType=yt[t]||0,this.timestamp=0,this.networkType=8,this.code=0,this.message="",this.moreMessage="",this.extension=t,this.costTime=0,this.duplicate=!1,this.level=4,this.uiPlatform=void 0,this._sentFlag=!1,this._startts=U()}static bindEventStatModule(t){At.prototype._eventStatModule=t}static bindNetMonitorModule(t){At.prototype._netMonitorModule=t}updateTimeStamp(){this.timestamp=U()}start(t){return this._startts=t,this}end(t=!1){if(!this._sentFlag){if(this._netMonitorModule){const t=this._netMonitorModule.getNetworkType();this.setNetworkType(t)}var e=U();0===this.costTime&&(this.costTime=e-this._startts),this.setMoreMessage(`startts:${this._startts} endts:`+e),t?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout(()=>{this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)},0)}}setError(t){if(!(t instanceof Error))return nt.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;let e=!0;if(e=this._netMonitorModule?this._netMonitorModule.isOnline():e)t.code&&this.setCode(t.code),t.message&&this.setMoreMessage(t.message);else{const t=lt;this.setCode(t)}return this.setLevel("error"),this}setCode(t){return X(t)||this._sentFlag||("ECONNABORTED"===t&&(this.code=103),K(t)?this.code=t:nt.w(this._n+".setCode value not a number, please check!",t,typeof t)),this}setMessage(t){return X(t)||this._sentFlag||(K(t)&&(this.message=t.toString()),"string"==typeof t&&(this.message=t)),this}setCostTime(t){return this.costTime=t,this}setLevel(t){return X(t)||this._sentFlag||(this.level=Tt[t]),this}setMoreMessage(t){return function(t){if(null==t)return 1;if("boolean"!=typeof t){if("number"==typeof t)return 0===t;if("string"==typeof t)return 0===t.length;if("function"==typeof t)return 0===t.length;if(Array.isArray(t))return 0===t.length;if(t instanceof Error)return""===t.message;if(Y(t)){for(const e in t)if($.call(t,e))return;return 1}return(B(t)||j(t)||H(t))&&0===t.size}}(this.moreMessage)?this.moreMessage=""+t:this.moreMessage+=" "+t,this}setNetworkType(t){return X(t)?nt.w(this._n+".setNetworkType value is undefined, please check!"):(t=Mt[t.toLowerCase()],X(t)||(this.networkType=t)),this}getStartTs(){return this._startts}setUIPlatform(t){return this.uiPlatform=t,this}setExtension(t){return this.extension=t,this}setEventType(t){return this.eventType=t,this}}const St={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"},Et={NONE:0,FOLLOWERS:1,FOLLOWING:2,MUTUAL:3};class Ft extends class{constructor(t){this._m=t,this._n=""}isLoggedIn(){return this._m.get(t).isLoggedIn()}isOversea(){return this._m.get(t).isOversea()}isPrivateNetWork(){return this._m.get(t).isPrivateNetWork()}getFileDownloadProxy(){return this._m.get(t).getFileDownloadProxy()}getMyUserID(){return this._m.get(t).getUserID()}getMyTinyID(){return this._m.get(t).getTinyID()}getSDKAppID(){return this._m.get(t).getSDKAppID()}isIntl(){return this._m.get(t).isIntl()}isUsingChatCore(){return this._m.get(t).isUsingChatCore()}isDevMode(){return this._m.get(t).isDevMode()}get(t){return this._m.get(t)}getPlatform(){return T}getCloudConfig(t){return this._m.get(o).getCloudConfig(t)}emitOuterEvent(t,e){this._m.getOuterEmitterInstance().emit(t,e)}emitInnerEvent(t,e){this._m.getInnerEmitterInstance().emit(t,e)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(e){return this._m.get(t).getTinyID()+"-"+e.random}req(t){return this._m.get(e).req(t)}canIUse(t){return this._m.get(s).canIUse(t)}getErrorMessage(t,e,o){return this._m.getErrorMessage(t,e,o)}outputWarning(t,e,o){t=this.getErrorMessage(t,e,o);t&&nt.w(t)}cannotUseCommercialAbility(t){var e=at;return wt({code:e,message:this.getErrorMessage(e,t)})}}{constructor(t){super(t),this._n="FollowModule",this._myFollowersList=new Map,this._myFollowingList=new Map,this._myMutualFollowersList=new Map,this._myFollowInfo=new Map,this.MAX_CATCH_TIME=6e5,this.FIRST_PAGE_INDEX=function(){let e="";for(let t=32;0<t;--t)e+=J[Math.floor(Math.random()*Q)];return e}(),this.DEFAULT_COUNT=100,this.MAX_COUNT=1e3;const e=this.getInnerEmitterInstance();e.on(St.A2KEY_AND_TINYID_UPDATED,this._init,this),e.on(St.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_init(){this.getUserFollowInfo()}_onCloudConfigUpdated(){var t=this.getCloudConfig("follow_req_count");X(t)||(t=Number(t),this.DEFAULT_COUNT=t>this.MAX_COUNT?this.MAX_COUNT:t,this._myFollowersList.clear(),this._myFollowingList.clear(),this._myMutualFollowersList.clear())}getMyFollowInfoOnReconnected(){this.getUserFollowInfo()}onFollowInfoNotify(t){var{followAddList:t=[],followDeleteList:e=[],pushType:o,from:s}=t.dataList||{},n=this._initFollowInfo();1===o?this._handleFollowAddList({from:s,followAddList:t,followInfo:n}):this._handleFollowDeleteList({from:s,followDeleteList:e,followInfo:n}),this._setMyFollowInfo({followersCount:n[Et.FOLLOWERS].count,followingCount:n[Et.FOLLOWING].count,mutualFollowersCount:n[Et.MUTUAL].count}),this._emitEvent(n),nt.l(`${this._n}.onFollowInfoNotify from:${s} pushType:${o} followAddList:${t.length} followDeleteList:`+e.length)}_initFollowInfo(){var{followersCount:t=0,followingCount:e=0,mutualFollowersCount:o=0}=this._getMyFollowInfo();return{[Et.FOLLOWERS]:{count:t,addList:[],deleteList:[]},[Et.FOLLOWING]:{count:e,addList:[],deleteList:[]},[Et.MUTUAL]:{count:o,addList:[],deleteList:[]}}}_handleFollowAddList(t){const{from:e,followAddList:o,followInfo:s}=t;o.forEach(t=>{t.followType===Et.MUTUAL&&(e===this.getMyUserID()?(s[Et.FOLLOWERS].count--,s[Et.FOLLOWERS].deleteList.push(t.userID)):(s[Et.FOLLOWING].count--,s[Et.FOLLOWING].deleteList.push(t.userID))),s[t.followType].count++,s[t.followType].addList.push(t)})}_handleFollowDeleteList(t){const{from:e,followDeleteList:o,followInfo:s}=t;o.forEach(t=>{t.followType===Et.NONE&&(e===this.getMyUserID()?(s[Et.FOLLOWING].count--,s[Et.FOLLOWING].deleteList.push(t.userID)):(s[Et.FOLLOWERS].count--,s[Et.FOLLOWERS].deleteList.push(t.userID))),t.followType!==Et.FOLLOWERS&&t.followType!==Et.FOLLOWING||(e===this.getMyUserID()?(s[Et.FOLLOWERS].count++,s[Et.FOLLOWERS].addList.push(t)):(s[Et.FOLLOWING].count++,s[Et.FOLLOWING].addList.push(t)),s[Et.MUTUAL].count--,s[Et.MUTUAL].deleteList.push(t.userID))})}_emitEvent(o){Object.values(Et).forEach(t=>{var e={totalCount:o[t].count<0?0:o[t].count,addUserInfoList:o[t].addList,deleteUserIDList:o[t].deleteList};(0<e.addUserInfoList.length||0<e.deleteUserIDList.length)&&(t===Et.FOLLOWERS&&this.emitOuterEvent(ct,e),t===Et.FOLLOWING&&this.emitOuterEvent(ht,e),t===Et.MUTUAL&&this.emitOuterEvent(_t,e))})}followUser(t){const e=this._n+".followUser",o="userIDList:"+t.length,s=new At("followUser");return s.setMessage(o),nt.l(e+" "+o),this.req({proto:dt,data:{fromAccount:this.getMyUserID(),userIDList:t.map(t=>({userID:t}))}}).then(t=>(s.end(),nt.l(e+" ok."),it(t.data.resultList))).catch(t=>(s.setError(t).end(),nt.e(e+" failed. error:",t),wt(t)))}unfollowUser(t){const e=this._n+".unfollowUser",o="userIDList:"+t.length,s=new At("unfollowUser");return s.setMessage(o),nt.l(e+" "+o),this.req({proto:pt,data:{fromAccount:this.getMyUserID(),userIDList:t}}).then(t=>(s.end(),nt.l(e+" ok."),it(t.data.resultList))).catch(t=>(s.setError(t).end(),nt.e(e+" failed. error:",t),wt(t)))}getMyFollowersList(t=""){const e=t||this.FIRST_PAGE_INDEX;if(this._myFollowersList.has(e)){const{resultList:t,nextCursor:o="",lastUpdateTime:s}=this._myFollowersList.get(e);if(Date.now()-s<this.MAX_CATCH_TIME&&0<t.length)return nt.l(`${this._n}.getMyFollowersList startCursor:${e} from cache.`),mt({resultList:t,nextCursor:o})}return this._getFollowList(t,Et.FOLLOWERS).then(t=>(this._myFollowersList.set(e,{...t,lastUpdateTime:Date.now()}),nt.l(`${this._n}.getMyFollowersList startCursor:${e} from remote.`),it(t)))}getMyFollowingList(t=""){const e=t||this.FIRST_PAGE_INDEX;if(this._myFollowingList.has(e)){const{resultList:t,nextCursor:o,lastUpdateTime:s}=this._myFollowingList.get(e);if(Date.now()-s<this.MAX_CATCH_TIME&&0<t.length)return nt.l(`${this._n}.getMyFollowingList startCursor:${e} from cache.`),mt({resultList:t,nextCursor:o})}return this._getFollowList(t,Et.FOLLOWING).then(t=>(this._myFollowingList.set(e,{...t,lastUpdateTime:Date.now()}),nt.l(`${this._n}.getMyFollowingList startCursor:${e} from remote.`),it(t)))}getMutualFollowersList(t=""){const e=t||this.FIRST_PAGE_INDEX;if(this._myMutualFollowersList.has(e)){const{resultList:t,nextCursor:o,lastUpdateTime:s}=this._myMutualFollowersList.get(e);if(Date.now()-s<this.MAX_CATCH_TIME&&0<t.length)return nt.l(`${this._n}.getMutualFollowersList startCursor:${e} from cache.`),mt({resultList:t,nextCursor:o})}return this._getFollowList(t,Et.MUTUAL).then(t=>(this._myMutualFollowersList.set(e,{...t,lastUpdateTime:Date.now()}),nt.l(`${this._n}.getMutualFollowersList startCursor:${e} from remote.`),it(t)))}_getFollowList(t,e){const n=new At("_getFollowList");return n.setMessage(`startCursor:${t} type:`+e),this.req({proto:Lt,data:{fromAccount:this.getMyUserID(),count:this.DEFAULT_COUNT,startCursor:t,type:e}}).then(t=>{n.end();const{resultList:e=[],nextCursor:o=""}=t.data,s=[];return e.forEach(t=>{var{userID:t,followTime:e,profileList:o=[]}=t;s.push({userID:t,followTime:e,...this._handleProfileItem(o)})}),{resultList:s,nextCursor:o}}).catch(t=>(n.setError(t).end(),nt.e(this._n+"._getFollowList failed. error:",t),wt(t)))}_handleProfileItem(t){const e={};return t.forEach(t=>{switch(t.tag){case C:e.nick=t.value;break;case D:e.gender=t.value;break;case N:e.birthday=t.value;break;case P:e.location=t.value;break;case v:e.selfSignature=t.value;break;case R:e.allowType=t.value;break;case b:e.language=t.value;break;case G:e.avatar=t.value;break;case q:e.messageSettings=t.value;break;case k:e.adminForbidType=t.value;break;case x:e.level=t.value;break;case W:e.role=t.value;break;default:e[t.tag]=t.value}}),e}getUserFollowInfo(t){let e=t,o=!1;X(t)&&(e=[this.getMyUserID()],o=!0);const n=this._n+".getUserFollowInfo",s=`userIDList:${e.length} isGetMyFollowInfo:`+o,i=new At("getUserFollowInfo");return i.setMessage(s),nt.l(n+" "+s),this.req({proto:It,data:{fromAccount:this.getMyUserID(),userIDList:e}}).then(t=>{i.end(),nt.l(n+" ok.");const{followInfoList:e=[]}=t.data;if(o){const{followersCount:t,followingCount:o,mutualFollowersCount:n}=e[0];this._setMyFollowInfo({followersCount:t,followingCount:o,mutualFollowersCount:n})}const s=[];return e.forEach(t=>{var{followersCount:t,followingCount:e,mutualFollowersCount:o}=t;s.push({followersCount:t,followingCount:e,mutualFollowersCount:o})}),it(s)}).catch(t=>(i.setError(t).end(),nt.e(n+" failed. error:",t),wt(t)))}_getMyFollowInfo(){var t=this.getMyUserID();return this._myFollowInfo.get(t)}_setMyFollowInfo(t){var e=this.getMyUserID();this._myFollowInfo.set(e,t)}reset(){nt.l(this._n+".reset"),this._myFollowersList.clear(),this._myFollowingList.clear(),this._myMutualFollowersList.clear(),this._myFollowInfo.clear()}}export{Ft as default};
"use strict";const t=12,e=20,s=23,o=27;class n{constructor(t=0,e=0){this.high=t,this.low=e}equal(t){return null!==t&&this.low===t.low&&this.high===t.high}toString(){var t=Number(this.high).toString(16);let e=Number(this.low).toString(16);if(e.length<8){let t=8-e.length;for(;t;)e="0"+e,t--}return t+e}}const i={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},r={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15},l="CHINA",a={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(t=l){this.CURRENT=i.PRODUCTION[t]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report"}},c={SEARCH_MSG:new n(0,Math.pow(2,0)).toString(),SEARCH_GRP_SNS:new n(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new n(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new n(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new n(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new n(0,Math.pow(2,6)).toString(),USER_STATUS:new n(0,Math.pow(2,7)).toString(),CONV_MARK:new n(0,Math.pow(2,9)).toString(),CONV_GROUP:new n(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new n(0,Math.pow(2,11)).toString(),MSG_EXT:new n(0,Math.pow(2,13)).toString(),GRP_COUNTER:new n(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new n(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new n(Math.pow(2,7)).toString(),PLUGIN_CS:new n(Math.pow(2,8)).toString(),PLUGIN_PUSH:new n(Math.pow(2,9)).toString(),PLUGIN_BOT:new n(Math.pow(2,10)).toString(),MSG_REACTION:new n(Math.pow(2,16)).toString(),FOLLOW:new n(Math.pow(2,20)).toString()},u=(a.HOST.setCurrent(l),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),h=(u&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),_="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),g="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),m="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,w="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,d=u||h||_||g||f||w||m,p=("undefined"!=typeof uni||"undefined"!=typeof window)&&!d,T=(h?qq:_?tt:g?swan:f?my:u?wx:w?uni:m&&jd,p&&window&&window.navigator&&window.navigator.userAgent||""),I=/(micromessenger|webbrowser)/i.test(T),L=/AppleWebKit\/([\d.]+)/i.exec(T),y=(L&&parseFloat(L.pop()),function(){let t="WEB";return I?t="WEB":h?t="QQ_MP":_?t="TT_MP":g?t="BAIDU_MP":f?t="ALI_MP":u?t="WX_MP":w&&(t="UNI_NATIVE_APP"),r[t]}()),A=(!function(){var t=T.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),function(){var t,e,s=T.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);s&&(t=s[1]&&parseFloat(s[1]),e=s[2]&&parseFloat(s[2]),t&&e&&parseFloat(s[1]+"."+s[2]))}(),function(){var t=T.match(/Chrome\/(\d+)/);t&&t[1]&&parseFloat(t[1])}(),/MSIE/.test(T)||-1<T.indexOf("Trident")&&-1<T.indexOf("rv:11.0"));let M,S;!function(){var t=/MSIE\s(\d+)\.\d/.exec(T),t=t&&parseFloat(t[1]);!t&&/Trident\/7.0/i.test(T)&&/rv:11.0/.test(T)}(),function(){var t=T.match(/TBS\/(\d+)/i);t&&t[1]&&t[1]}(),M="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const E=function(){},U=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let F=U.length;for(;F--;)S=U[F],console[S]||(M[S]=E);var O=M;const C=function(){return(new Date).getTime()+0},D="Tag_Profile_IM_Nick",N="Tag_Profile_IM_Gender",P="Tag_Profile_IM_BirthDay",v="Tag_Profile_IM_Location",R="Tag_Profile_IM_SelfSignature",b="Tag_Profile_IM_AllowType",G="Tag_Profile_IM_Language",k="Tag_Profile_IM_Image",$="Tag_Profile_IM_MsgSettings",q="Tag_Profile_IM_AdminForbidType",x="Tag_Profile_IM_Level",B="Tag_Profile_IM_Role",W=Object.prototype.hasOwnProperty,j=function(t){return"map"===J(t)},H=function(t){return"set"===J(t)},K=function(t){return"file"===J(t)},X=function(t){return null!==t&&("number"==typeof t&&!isNaN(+t)||"object"==typeof t&&t.constructor===Number)},V=function(t){if("object"!=typeof t||null===t)return!1;t=Object.getPrototypeOf(t);if(null===t)return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return t===e},Y=function(t){return void 0===t},z=function(t){return e=t,("function"==typeof Array.isArray?Array.isArray(e):"array"===J(e))||null!==t&&"object"==typeof t;var e},J=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()},Q=(Date.now||(Date.now=function(){return(new Date).getTime()}),"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),Z=Q.length;function et(){return!A&&!d}let st=0;function ot(){return et()?"%c Chat %c":"Chat"}function nt(){const t=function(){const t=new Date;return t.setTime(C()),t}();return t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(t){let e;switch(t.toString().length){case 1:e="00"+t;break;case 2:e="0"+t;break;default:e=t}return e}(t.getMilliseconds())}const it={arguments2String(s){let o="";if(1===s.length)o=s[0];else for(let t=0,e=s.length;t<e;t++)z(s[t])?s[t]instanceof Error?o+=(n=s[t],JSON.stringify(n,["message","code"])):o+=JSON.stringify(s[t]):o+=s[t],o+=" ";var n;return o},_exec(t,e){et()?O[t](ot(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",nt(),e):O[t](`${ot()} ${nt()} `+e)},d:function(){var t;st<=-1&&(t=this.arguments2String(arguments),this._exec("debug",t))},l:function(){var t;st<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},log:function(){var t;st<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},i:function(){var t;st<=1&&(t=this.arguments2String(arguments),this._exec("info",t))},w:function(){var t;st<=2&&(t=this.arguments2String(arguments),this._exec("warn",t))},e:function(){var t;st<=3&&(t=this.arguments2String(arguments),this._exec("error",t))},setLevel:function(t){t<4&&this._exec("log","set level from "+st+" to "+t),st=t},getLevel:function(){return st}},rt=function(t){return{code:0,data:t||{}}};class lt extends Error{constructor(t){super();var{code:t,message:e,data:s}=t;this.code=t,e?this.message=e:this._getErrorMessage&&(this.message=this._getErrorMessage(this.code)),this.data=s||{}}}const at=2805,ct=2903,ut=3122,ht="onMyFollowersListUpdated",_t="onMyFollowingListUpdated",gt="onMutualFollowersListUpdated",ft="error";let mt=null;const wt=function(t){return Promise.resolve(rt(t))},dt=function(t,e=!1){if(t instanceof lt)return e&&null!==mt&&mt.emit(ft,t),Promise.reject(t);if(t instanceof Error){const t=new lt({code:ct});return e&&null!==mt&&mt.emit(ft,t),Promise.reject(t)}if(Y(t)||Y(t.code))return Promise.reject(new lt({code:ct}));t=new lt(t);return e&&null!==mt&&mt.emit(ft,t),Promise.reject(t)},pt="follow_add",Tt="follow_delete",It="follow_get",Lt="follow_get_info",yt="follow_check",At={info:4,warning:5,error:6},Mt={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},St={login:4,plugin_search:16,plugin_translate:16,plugin_voice_to_text:16,plugin_cs:16,plugin_push:16,plugin_bot:16,plugin_emoji_reaction:16};class Et{constructor(t){this._n="SSOLogData",this.eventType=St[t]||0,this.timestamp=0,this.networkType=8,this.code=0,this.message="",this.moreMessage="",this.extension=t,this.costTime=0,this.duplicate=!1,this.level=4,this.uiPlatform=void 0,this._sentFlag=!1,this._startts=C()}static bindEventStatModule(t){Et.prototype._eventStatModule=t}static bindNetMonitorModule(t){Et.prototype._netMonitorModule=t}updateTimeStamp(){this.timestamp=C()}start(t){return this._startts=t,this}end(t=!1){if(!this._sentFlag){if(this._netMonitorModule){const t=this._netMonitorModule.getNetworkType();this.setNetworkType(t)}var e=C();0===this.costTime&&(this.costTime=e-this._startts),this.setMoreMessage(`startts:${this._startts} endts:`+e),t?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout(()=>{this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)},0)}}setError(t){if(!(t instanceof Error))return it.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;let e=!0;if(e=this._netMonitorModule?this._netMonitorModule.isOnline():e)t.code&&this.setCode(t.code),t.message&&this.setMoreMessage(t.message);else{const t=at;this.setCode(t)}return this.setLevel("error"),this}setCode(t){return Y(t)||this._sentFlag||("ECONNABORTED"===t&&(this.code=103),X(t)?this.code=t:it.w(this._n+".setCode value not a number, please check!",t,typeof t)),this}setMessage(t){return Y(t)||this._sentFlag||(X(t)&&(this.message=t.toString()),"string"==typeof t&&(this.message=t)),this}setCostTime(t){return this.costTime=t,this}setLevel(t){return Y(t)||this._sentFlag||(this.level=At[t]),this}setMoreMessage(t){return function(t){if(null==t)return 1;if("boolean"!=typeof t){if("number"==typeof t)return 0===t;if("string"==typeof t)return 0===t.length;if("function"==typeof t)return 0===t.length;if(Array.isArray(t))return 0===t.length;if(t instanceof Error)return""===t.message;if(V(t)){for(const e in t)if(W.call(t,e))return;return 1}return(j(t)||H(t)||K(t))&&0===t.size}}(this.moreMessage)?this.moreMessage=""+t:this.moreMessage+=" "+t,this}setNetworkType(t){return Y(t)?it.w(this._n+".setNetworkType value is undefined, please check!"):(t=Mt[t.toLowerCase()],Y(t)||(this.networkType=t)),this}getStartTs(){return this._startts}setUIPlatform(t){return this.uiPlatform=t,this}setExtension(t){return this.extension=t,this}setEventType(t){return this.eventType=t,this}}const Ut={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"},Ft={NONE:0,FOLLOWERS:1,FOLLOWING:2,MUTUAL:3};class Ot extends class{constructor(t){this._m=t,this._n=""}isLoggedIn(){return this._m.get(t).isLoggedIn()}isOversea(){return this._m.get(t).isOversea()}isPrivateNetWork(){return this._m.get(t).isPrivateNetWork()}getFileDownloadProxy(){return this._m.get(t).getFileDownloadProxy()}getMyUserID(){return this._m.get(t).getUserID()}getMyTinyID(){return this._m.get(t).getTinyID()}getSDKAppID(){return this._m.get(t).getSDKAppID()}isIntl(){return this._m.get(t).isIntl()}isUsingChatCore(){return this._m.get(t).isUsingChatCore()}isDevMode(){return this._m.get(t).isDevMode()}get(t){return this._m.get(t)}getPlatform(){return y}getCloudConfig(t){return this._m.get(s).getCloudConfig(t)}emitOuterEvent(t,e){this._m.getOuterEmitterInstance().emit(t,e)}emitInnerEvent(t,e){this._m.getInnerEmitterInstance().emit(t,e)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(e){return this._m.get(t).getTinyID()+"-"+e.random}req(t){return this._m.get(e).req(t)}canIUse(t){return this._m.get(o).canIUse(t)}getErrorMessage(t,e,s){return this._m.getErrorMessage(t,e,s)}outputWarning(t,e,s){t=this.getErrorMessage(t,e,s);t&&it.w(t)}cannotUseCommercialAbility(t){var e=ut;return dt({code:e,message:this.getErrorMessage(e,t)})}}{constructor(t){super(t),this._n="FollowModule",this._myFollowersList=new Map,this._myFollowingList=new Map,this._myMutualFollowersList=new Map,this._followType=new Map,this.MAX_CATCH_TIME=6e5,this.FIRST_PAGE_INDEX=function(){let e="";for(let t=32;0<t;--t)e+=Q[Math.floor(Math.random()*Z)];return e}(),this.DEFAULT_COUNT=500,this.MAX_COUNT=1e3,this.getInnerEmitterInstance().on(Ut.CLOUD_CONFIG_UPDATED,this._onCloudConfigUpdated,this)}_onCloudConfigUpdated(){var t=this.getCloudConfig("follow_req_count");Y(t)||(t=Number(t),this.DEFAULT_COUNT=t>this.MAX_COUNT?this.MAX_COUNT:t,this._clearFollowList())}clearCacheOnReconnected(){this._clearFollowList(),this._followType.clear()}onFollowInfoNotify(t){var{followAddList:t=[],followDeleteList:e=[],pushType:s}=t.dataList||{},o=this._initFollowInfo();1===s?this._handleFollowAddList({followAddList:t,followInfo:o}):this._handleFollowDeleteList({followDeleteList:e,followInfo:o}),this._emitEvent(o),it.l(`${this._n}.onFollowInfoNotify pushType:${s} followAddList:${t.length} followDeleteList:`+e.length)}_initFollowInfo(){const e={};return Object.values(Ft).forEach(t=>{t!==Ft.NONE&&(e[t]={userInfoList:[],isAdd:!1})}),e}_handleFollowAddList(t){const{followAddList:e,followInfo:o}=t;e.forEach(t=>{const{followTypeList:e=[],...s}=t;e.forEach(t=>{o[t].userInfoList.push(s),o[t].isAdd=!0}),this._setFollowType(t.userID,t.followType)})}_handleFollowDeleteList(t){const{followDeleteList:e,followInfo:o}=t;e.forEach(t=>{const{followTypeList:e=[],userID:s}=t;e.forEach(t=>{o[t].userInfoList.push(s),o[t].isAdd=!1}),this._setFollowType(t.userID,t.followType)})}_emitEvent(s){Object.keys(s).forEach(t=>{var t=Number(t),e=s[t];0<e.userInfoList.length&&(t===Ft.FOLLOWERS&&(this._clearFollowList(Ft.FOLLOWERS),this.emitOuterEvent(ht,e)),t===Ft.FOLLOWING&&(this._clearFollowList(Ft.FOLLOWING),this.emitOuterEvent(_t,e)),t===Ft.MUTUAL&&(this._clearFollowList(Ft.MUTUAL),this.emitOuterEvent(gt,e)))})}followUser(t){if(!this.canIUse(c.FOLLOW))return this.cannotUseCommercialAbility("followUser");const e=this._n+".followUser",s="userIDList:"+t.length,o=new Et("followUser");return o.setMessage(s),it.l(e+" "+s),this.req({proto:pt,data:{fromAccount:this.getMyUserID(),userIDList:t.map(t=>({userID:t}))}}).then(t=>(o.end(),it.l(e+" ok."),rt(t.data.resultList))).catch(t=>(o.setError(t).end(),it.e(e+" failed. error:",t),dt(t)))}unfollowUser(t){if(!this.canIUse(c.FOLLOW))return this.cannotUseCommercialAbility("unfollowUser");const e=this._n+".unfollowUser",s="userIDList:"+t.length,o=new Et("unfollowUser");return o.setMessage(s),it.l(e+" "+s),this.req({proto:Tt,data:{fromAccount:this.getMyUserID(),userIDList:t}}).then(t=>(o.end(),it.l(e+" ok."),rt(t.data.resultList))).catch(t=>(o.setError(t).end(),it.e(e+" failed. error:",t),dt(t)))}getMyFollowersList(t=""){const e="getMyFollowersList";if(!this.canIUse(c.FOLLOW))return this.cannotUseCommercialAbility(e);const s=t||this.FIRST_PAGE_INDEX;if(this._myFollowersList.has(s)){const{resultList:t,nextCursor:o="",lastUpdateTime:n}=this._myFollowersList.get(s);if(Date.now()-n<this.MAX_CATCH_TIME&&0<t.length)return it.l(`${this._n}.${e} startCursor:${s} from local.`),wt({resultList:t,nextCursor:o})}return this._getFollowList(t,Ft.FOLLOWERS).then(t=>(this._myFollowersList.set(s,{...t,lastUpdateTime:Date.now()}),it.l(`${this._n}.${e} startCursor:${s} from remote.`),rt(t)))}getMyFollowingList(t=""){const e="getMyFollowingList";if(!this.canIUse(c.FOLLOW))return this.cannotUseCommercialAbility(e);const s=t||this.FIRST_PAGE_INDEX;if(this._myFollowingList.has(s)){const{resultList:t,nextCursor:o,lastUpdateTime:n}=this._myFollowingList.get(s);if(Date.now()-n<this.MAX_CATCH_TIME&&0<t.length)return it.l(`${this._n}.${e} startCursor:${s} from local.`),wt({resultList:t,nextCursor:o})}return this._getFollowList(t,Ft.FOLLOWING).then(t=>(this._myFollowingList.set(s,{...t,lastUpdateTime:Date.now()}),it.l(`${this._n}.${e} startCursor:${s} from remote.`),rt(t)))}getMutualFollowersList(t=""){const e="getMutualFollowersList";if(!this.canIUse(c.FOLLOW))return this.cannotUseCommercialAbility(e);const s=t||this.FIRST_PAGE_INDEX;if(this._myMutualFollowersList.has(s)){const{resultList:t,nextCursor:o,lastUpdateTime:n}=this._myMutualFollowersList.get(s);if(Date.now()-n<this.MAX_CATCH_TIME&&0<t.length)return it.l(`${this._n}.${e} startCursor:${s} from local.`),wt({resultList:t,nextCursor:o})}return this._getFollowList(t,Ft.MUTUAL).then(t=>(this._myMutualFollowersList.set(s,{...t,lastUpdateTime:Date.now()}),it.l(`${this._n}.${e} startCursor:${s} from remote.`),rt(t)))}_getFollowList(t,e){const n=new Et("_getFollowList");return n.setMessage(`startCursor:${t} type:`+e),this.req({proto:It,data:{fromAccount:this.getMyUserID(),count:this.DEFAULT_COUNT,startCursor:t,type:e}}).then(t=>{n.end();const{resultList:e=[],nextCursor:s=""}=t.data,o=[];return e.forEach(t=>{var{userID:t,followTime:e,profileList:s=[]}=t;o.push({userID:t,followTime:e,...this._handleProfileItem(s)})}),{resultList:o,nextCursor:s}}).catch(t=>(n.setError(t).end(),it.e(this._n+"._getFollowList failed. error:",t),dt(t)))}_handleProfileItem(t){const e={};return t.forEach(t=>{switch(t.tag){case D:e.nick=t.value;break;case N:e.gender=t.value;break;case P:e.birthday=t.value;break;case v:e.location=t.value;break;case R:e.selfSignature=t.value;break;case b:e.allowType=t.value;break;case G:e.language=t.value;break;case k:e.avatar=t.value;break;case $:e.messageSettings=t.value;break;case q:e.adminForbidType=t.value;break;case x:e.level=t.value;break;case B:e.role=t.value;break;default:e[t.tag]=t.value}}),e}getUserFollowInfo(t){if(!this.canIUse(c.FOLLOW))return this.cannotUseCommercialAbility("getUserFollowInfo");let e=t,s=!1;Y(t)&&(e=[this.getMyUserID()],s=!0);const n=this._n+".getUserFollowInfo",o=`userIDList:${e.length} isGetMyFollowInfo:`+s,i=new Et("getUserFollowInfo");return i.setMessage(o),it.l(n+" "+o),this.req({proto:Lt,data:{fromAccount:this.getMyUserID(),userIDList:e}}).then(t=>{i.end(),it.l(n+" ok.");const{followInfoList:e=[]}=t.data,o=[];return e.forEach(t=>{var{followersCount:t,followingCount:e,mutualFollowersCount:s}=t;o.push({followersCount:t,followingCount:e,mutualFollowersCount:s})}),rt(o)}).catch(t=>(i.setError(t).end(),it.e(n+" failed. error:",t),dt(t)))}checkFollowType(t){if(!this.canIUse(c.FOLLOW))return this.cannotUseCommercialAbility("checkFollowType");100<t.length&&(t=t.slice(0,100),it.w(s+" "+"the length of userIDList cannot exceed 100"));const s=this._n+".checkFollowType",e=`userIDList length:${t.length} `,o=new Et("checkFollowType"),n=(o.setMessage(e),it.l(s+" "+e),[]),i=[];return t.forEach(t=>{var e;this._followType.has(t)?(e=this._followType.get(t),n.push({userID:t,followType:e})):i.push(t)}),it.l(`${s} from local count:${n.length}, from remote count:${i.length}.`),0===i.length?wt(n):this.req({proto:yt,data:{fromAccount:this.getMyUserID(),userIDList:i}}).then(t=>{o.end(),it.l(s+" ok.");const{resultList:e=[]}=t.data;return e.forEach(t=>{var{userID:t,followType:e}=t;this._setFollowType(t,e),n.push({userID:t,followType:e})}),rt(n)}).catch(t=>(o.setError(t).end(),it.e(s+" failed. error:",t),dt(t)))}_setFollowType(t,e){this._followType.set(t,e)}_clearFollowList(t){if(Y(t))return this._myFollowersList.clear(),this._myFollowingList.clear(),void this._myMutualFollowersList.clear();t!==Ft.FOLLOWERS?t!==Ft.FOLLOWING?t!==Ft.MUTUAL||this._myMutualFollowersList.clear():this._myFollowingList.clear():this._myFollowersList.clear()}reset(){it.l(this._n+".reset"),this._clearFollowList(),this._followType.clear()}}export{Ot as default};

@@ -1,1 +0,1 @@

"use strict";const e={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};let t,s;t="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const i=function(){},r=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let n=r.length;for(;n--;)s=r[n],console[s]||(t[s]=i);var o=t;class a{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&this.low===e.low&&this.high===e.high}toString(){var e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}const d={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},u={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15},c="CHINA",l={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=c){this.CURRENT=d.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report"}},p=(new a(0,Math.pow(2,0)).toString(),new a(0,Math.pow(2,1)).toString(),new a(0,Math.pow(2,2)).toString(),new a(0,Math.pow(2,3)).toString(),new a(0,Math.pow(2,4)).toString(),new a(0,Math.pow(2,6)).toString(),new a(0,Math.pow(2,7)).toString(),new a(0,Math.pow(2,9)).toString(),new a(0,Math.pow(2,10)).toString(),new a(0,Math.pow(2,11)).toString(),new a(0,Math.pow(2,13)).toString(),new a(0,Math.pow(2,15)).toString(),new a(Math.pow(2,6)).toString(),new a(Math.pow(2,7)).toString(),new a(Math.pow(2,8)).toString(),new a(Math.pow(2,9)).toString(),new a(Math.pow(2,10)).toString(),new a(Math.pow(2,16)).toString(),"sns"),h=(l.HOST.setCurrent(c),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),f=(h&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),_="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),m="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),g="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),M="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,F="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,y=h||f||_||m||g||F||M,A=("undefined"!=typeof uni||"undefined"!=typeof window)&&!y,I=(f?qq:_?tt:m?swan:g?my:h?wx:F?uni:M&&jd,A&&window&&window.navigator&&window.navigator.userAgent||""),w=/(micromessenger|webbrowser)/i.test(I),D=/AppleWebKit\/([\d.]+)/i.exec(I),T=(D&&parseFloat(D.pop()),function(){let e="WEB";return w?e="WEB":f?e="QQ_MP":_?e="TT_MP":m?e="BAIDU_MP":g?e="ALI_MP":h?e="WX_MP":F&&(e="UNI_NATIVE_APP"),u[e]}()),L=(!function(){var e=I.match(/OS (\d+)_/i);e&&e[1]&&e[1]}(),function(){var e,t,r=I.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);r&&(e=r[1]&&parseFloat(r[1]),t=r[2]&&parseFloat(r[2]),e&&t&&parseFloat(r[1]+"."+r[2]))}(),function(){var e=I.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),/MSIE/.test(I)||-1<I.indexOf("Trident")&&-1<I.indexOf("rv:11.0")),S=(!function(){var e=/MSIE\s(\d+)\.\d/.exec(I),e=e&&parseFloat(e[1]);!e&&/Trident\/7.0/i.test(I)&&/rv:11.0/.test(I)}(),function(){var e=I.match(/TBS\/(\d+)/i);e&&e[1]&&e[1]}(),"C2C"),E="AllowType_Type_AllowAny",k="AdminForbid_Type_None",v="Add_Type_Single",b="Add_Type_Both",G="Delete_Type_Single",C="Delete_Type_Both",U="Pendency_Type_Both",N="Pendency_Type_ComeIn",P="Pendency_Type_SendOut",O="Response_Action_Agree",$="Response_Action_AgreeAndAdd",R="CheckResult_Type_Both",q="CheckResult_Type_Single",x=function(){return(new Date).getTime()+0},H="Tag_Profile_IM_Nick",W="Tag_Profile_IM_Gender",B="Tag_Profile_IM_BirthDay",j="Tag_Profile_IM_Location",K="Tag_Profile_IM_SelfSignature",Y="Tag_Profile_IM_AllowType",J="Tag_Profile_IM_Language",V="Tag_Profile_IM_Image",z="Tag_Profile_IM_MsgSettings",Q="Tag_Profile_IM_AdminForbidType",X="Tag_Profile_IM_Level",Z="Tag_Profile_IM_Role",ee={GROUP:"Tag_SNS_IM_Group",REMARK:"Tag_SNS_IM_Remark",ADDSOURCE:"Tag_SNS_IM_AddSource",ADDWORDING:"Tag_SNS_IM_Wording",ADDTIME:"Tag_SNS_IM_AddTime"},te="Gender_Type_",se={UNKNOWN:te+"Unknown",FEMALE:te+"Female",MALE:te+"Male"},ie={NONE:"AdminForbid_Type_None",SEND_OUT:"AdminForbid_Type_SendOut"},re={NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_ANY:"AllowType_Type_AllowAny",DENY_ANY:"AllowType_Type_DenyAny"},ne=Object.prototype.hasOwnProperty;function oe(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(pe(e)){for(const t in e)if(ne.call(e,t))return!1;return!0}return!!(ae(e)||de(e)||ue(e))&&0===e.size}const ae=function(e){return"map"===me(e)},de=function(e){return"set"===me(e)},ue=function(e){return"file"===me(e)},ce=function(e){return null!==e&&("number"==typeof e&&!isNaN(+e)||"object"==typeof e&&e.constructor===Number)},le=function(e){return"string"==typeof e},pe=function(e){if("object"!=typeof e||null===e)return!1;e=Object.getPrototypeOf(e);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t},he=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===me(e)},fe=function(e){return void 0===e},_e=function(e){return e instanceof Error},me=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},ge=(Date.now||(Date.now=function(){return(new Date).getTime()}),function(e){if(0===e.length)return 0;let t=0,r=0,i;for(var s="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";void 0!==e[t];)i=e[t++].charCodeAt[t]<=255?1:!1===s?3:2,r+=i;return r}),Me=function(e,t){for(const r in e)if(e[r]===t)return!0;return!1};function Fe(){return!L&&!y}let ye=0;function Ae(){return Fe()?"%c Chat %c":"Chat"}function Ie(){const e=function(){const e=new Date;return e.setTime(x()),e}();return e.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){let t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(e.getMilliseconds())}const we={arguments2String(r){let i="";if(1===r.length)i=r[0];else for(let e=0,t=r.length;e<t;e++)s=r[e],he(s)||null!==s&&"object"==typeof s?_e(r[e])?i+=(s=r[e],JSON.stringify(s,["message","code"])):i+=JSON.stringify(r[e]):i+=r[e],i+=" ";var s;return i},_exec(e,t){Fe()?o[e](Ae(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",Ie(),t):o[e](`${Ae()} ${Ie()} `+t)},d:function(){var e;ye<=-1&&(e=this.arguments2String(arguments),this._exec("debug",e))},l:function(){var e;ye<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},log:function(){var e;ye<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},i:function(){var e;ye<=1&&(e=this.arguments2String(arguments),this._exec("info",e))},w:function(){var e;ye<=2&&(e=this.arguments2String(arguments),this._exec("warn",e))},e:function(){var e;ye<=3&&(e=this.arguments2String(arguments),this._exec("error",e))},setLevel:function(e){e<4&&this._exec("log","set level from "+ye+" to "+e),ye=e},getLevel:function(){return ye}};class De{constructor(e){oe(e)||(this.userID=e.userID||"",this.nick=e.nick||"",this.avatar=e.avatar||"",this.time=e.time||0,this.source=e.source||"",this.wording=e.wording||"",this.type=e.type||"")}}const Te=function(e){return{code:0,data:e||{}}};class Le extends Error{constructor(e){super();var{code:e,message:t,data:r}=e;this.code=e,this.message=t||this._getErrorMessage(this.code),this.data=r||{}}}const Se=2700,Ee=2701,ke=2710,ve=2711,be=2716,Ge=2805,Ce=2903,Ue=3122,Ne=3123,Pe="onFriendListUpdated",Oe="onFriendGroupListUpdated",$e="onFriendApplicationListUpdated",Re="error";let qe=null;const xe=function(e){return Promise.resolve(Te(e))},He=function(e,t=!1){if(e instanceof Le)return t&&null!==qe&&qe.emit(Re,e),Promise.reject(e);if(e instanceof Error){const e=new Le({code:Ce});return t&&null!==qe&&qe.emit(Re,e),Promise.reject(e)}if(fe(e)||fe(e.code))return Promise.reject(new Le({code:Ce}));e=new Le(e);return t&&null!==qe&&qe.emit(Re,e),Promise.reject(e)},We="friend_get",Be="friend_get_specified",je="friend_check",Ke="friend_delete",Ye="friend_add",Je="friend_update",Ve="friend_response",ze="pendency_get",Qe="pendency_delete",Xe="pendency_report",Ze="group_get",et="group_add",st="group_delete",it="group_update",rt={info:4,warning:5,error:6},nt={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},ot={login:4,plugin_translate:16,plugin_voice_to_text:16,plugin_cs:16,plugin_push:16,plugin_bot:16,plugin_emoji_reaction:16};class at{constructor(e){this._n="SSOLogData",this.eventType=ot[e]||0,this.timestamp=0,this.networkType=8,this.code=0,this.message="",this.moreMessage="",this.extension=e,this.costTime=0,this.duplicate=!1,this.level=4,this.uiPlatform=void 0,this._sentFlag=!1,this._startts=x()}static bindEventStatModule(e){at.prototype._eventStatModule=e}static bindNetMonitorModule(e){at.prototype._netMonitorModule=e}updateTimeStamp(){this.timestamp=x()}start(e){return this._startts=e,this}end(e=!1){if(!this._sentFlag){if(this._netMonitorModule){const e=this._netMonitorModule.getNetworkType();this.setNetworkType(e)}var t=x();0===this.costTime&&(this.costTime=t-this._startts),this.setMoreMessage(`startts:${this._startts} endts:`+t),e?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout(()=>{this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)},0)}}setError(e){if(!(e instanceof Error))return we.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;let t=!0;if(t=this._netMonitorModule?this._netMonitorModule.isOnline():t)e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message);else{const e=Ge;this.setCode(e)}return this.setLevel("error"),this}setCode(e){return fe(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),ce(e)?this.code=e:we.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return fe(e)||this._sentFlag||(ce(e)&&(this.message=e.toString()),le(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return fe(e)||this._sentFlag||(this.level=rt[e]),this}setMoreMessage(e){return oe(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){return fe(e)?we.w(this._n+".setNetworkType value is undefined, please check!"):(e=nt[e.toLowerCase()],fe(e)||(this.networkType=e)),this}getStartTs(){return this._startts}setUIPlatform(e){return this.uiPlatform=e,this}setExtension(e){return this.extension=e,this}setEventType(e){return this.eventType=e,this}}class dt{constructor(e){this._snsM=e,this._n="FriendApplicationHandler",this._startTime=0,this._maxLimited=100,this._currentSequence=0,this._friendApplicationMap=new Map,this._unreadCount=0}getLocalFriendApplicationList(){return{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount}}_onFriendApplicationListUpdated(){this._snsM.emitOuterEvent($e,{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount})}onFriendApplicationRead(){this._unreadCount=0,this._onFriendApplicationListUpdated()}onFriendApplicationAdded(e,t){if(!oe(e)){let r,i=(r=t===this._snsM.getMyUserID()?P:N,!1);e.forEach(e=>{var t=e.userID+"_"+r;r!==N||this._friendApplicationMap.has(t)||(this._unreadCount+=1),this._friendApplicationMap.set(t,new De({...e,type:r})),i=!0}),i&&this._onFriendApplicationListUpdated()}}onFriendApplicationDeleted(e){oe(e)||(this._startTime=0,this._currentSequence=0,this.getFriendApplicationList())}getFriendApplicationList(){const n=this._n+".getFriendApplicationList",o=new at("getFriendApplicationList");return this._snsM.req({proto:ze,data:{applicationType:U,fromAccount:this._snsM.getMyUserID(),maxLimited:this._maxLimited,startTime:this._startTime,lastSequence:this._currentSequence}}).then(e=>{const{resultList:t,unreadCount:r,startTime:i,currentSequence:s}=e.data;this._startTime=i,this._currentSequence=s,this._unreadCount=r;e=`applicationCount:${he(t)?t.length:0} unreadCount:${r} startTime:${i} currentSequence:`+s;o.setMessage(e).end(),we.i(n+" ok. "+e),this._friendApplicationMap.clear(),he(t)&&t.forEach(e=>{var{userID:t,type:r}=e,e=new De(e);this._friendApplicationMap.set(t+"_"+r,e)}),this._onFriendApplicationListUpdated()}).catch(e=>(o.setError(e).end(),we.w(n+" failed. error:",e),He(e)))}deleteFriendApplication(e){const s=this._n+".deleteFriendApplication",{userID:n,type:t}=e;let o=t;if(o&&(o===P||o===N)||(o=N),!this._friendApplicationMap.has(n+"_"+o))return He({code:be});const a=new at("deleteFriendApplication");return a.setMessage(`userID:${n} type:`+o),this._snsM.req({proto:Qe,data:{fromAccount:this._snsM.getMyUserID(),userIDList:[n],type:o}}).then(e=>{var e=e.data["resultList"],{to:t,resultCode:r,resultInfo:i}=e[0];return a.setMoreMessage("resultList:"+JSON.stringify(e)).end(),we.i(s+` ok. userID:${n} type:`+o),0===r?Te():He({userID:t,code:r,message:i})}).catch(e=>(a.setError(e).end(),we.w(s+" failed. error:",e),He(e)))}acceptFriendApplication(e){const r=this._n+".acceptFriendApplication",{userID:i,remark:t,tag:s,type:n}=e;let o=n;o&&(o===O||o===$)||(o=$);const a=new at("acceptFriendApplication");return a.setMessage(`userID:${i} type:`+o),this._snsM.req({proto:Ve,data:{fromAccount:this._snsM.getMyUserID(),responseFriendItem:[{userID:i,remark:t,tag:s,action:o}]}}).then(e=>{a.end();var e=e.data["resultList"],{resultCode:e,resultInfo:t}=e[0];if(0!==e)return He({code:e,message:t});we.i(r+` ok. userID:${i} type:`+o)}).catch(e=>(a.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}refuseFriendApplication(e){const r=this._n+".refuseFriendApplication",i=e["userID"],s=new at("refuseFriendApplication");return s.setMessage("userID:"+i),this._snsM.req({proto:Ve,data:{fromAccount:this._snsM.getMyUserID(),responseFriendItem:[{userID:i,action:"Response_Action_Reject"}]}}).then(e=>{s.end();var e=e.data["resultList"],{resultCode:e,resultInfo:t}=e[0];if(0!==e)return He({code:e,message:t});we.i(r+" ok. userID:"+i)}).catch(e=>(s.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}_onFriendApplicationProcessed(e){if(0!==e.length){let t=!1;e.forEach(e=>{e=e.to+"_"+N;this._friendApplicationMap.has(e)&&(this._friendApplicationMap.delete(e),--this._unreadCount,t=!0)}),this._unreadCount<0&&(this._unreadCount=0),t&&this._onFriendApplicationListUpdated()}}setFriendApplicationRead(){const t=this._n+".setFriendApplicationRead",r=new at("setFriendApplicationRead");var e;return this._snsM.req({proto:Xe,data:{fromAccount:this._snsM.getMyUserID(),latestTimeStamp:(e=x()/1e3,Math.round(Number(e)*Math.pow(10,0))/Math.pow(10,0))}}).then(e=>{r.end(),we.i(t+" ok"),this._unreadCount=0}).catch(e=>(r.setError(e).end(),we.w(t+" failed. error:",e),He(e)))}reset(){this._startIndex=0,this._maxLimited=100,this._currentSequence=0,this._unreadCount=0,this._friendApplicationMap.clear()}}class ut{constructor(e){oe(e)||(this.userID=e.userID||"",this.nick=e.nick||"",this.gender=e.gender||"",this.birthday=e.birthday||0,this.location=e.location||"",this.selfSignature=e.selfSignature||"",this.allowType=e.allowType||E,this.language=e.language||0,this.avatar=e.avatar||"",this.messageSettings=e.messageSettings||0,this.adminForbidType=e.adminForbidType||k,this.level=e.level||0,this.role=e.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],oe(e.profileCustomField)||e.profileCustomField.forEach(e=>{this.profileCustomField.push({key:e.key,value:e.value})}))}validate(r){let i=!0,e="";if(oe(r))return{valid:!1,tips:"empty options"};if(r.profileCustomField){const i=r.profileCustomField.length;let t=null;for(let e=0;e<i;e++){if(t=r.profileCustomField[e],!le(t.key)||-1===t.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!le(t.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}}for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if("profileCustomField"===t)continue;if(oe(r[t])&&!le(r[t])&&!ce(r[t])){e="key:"+t+", invalid value:"+r[t],i=!1;continue}switch(t){case"nick":le(r[t])||(e="nick must be a string",i=!1),500<ge(r[t])&&(e=`nick name limited: must less than or equal to 500 bytes, current size: ${ge(r[t])} bytes`,i=!1);break;case"gender":Me(se,r.gender)||(e="key:gender, invalid value:"+r.gender,i=!1);break;case"birthday":ce(r.birthday)||(e="birthday must be a number",i=!1);break;case"location":le(r.location)||(e="location must be a string",i=!1);break;case"selfSignature":le(r.selfSignature)||(e="selfSignature must be a string",i=!1);break;case"allowType":Me(re,r.allowType)||(e="key:allowType, invalid value:"+r.allowType,i=!1);break;case"language":ce(r.language)||(e="language must be a number",i=!1);break;case"avatar":le(r.avatar)||(e="avatar must be a string",i=!1);break;case"messageSettings":0!==r.messageSettings&&1!==r.messageSettings&&(e="messageSettings must be 0 or 1",i=!1);break;case"adminForbidType":Me(ie,r.adminForbidType)||(e="key:adminForbidType, invalid value:"+r.adminForbidType,i=!1);break;case"level":ce(r.level)||(e="level must be a number",i=!1);break;case"role":ce(r.role)||(e="role must be a number",i=!1);break;default:e="unknown key:"+t+" "+r[t],i=!1}}return{valid:i,tips:e}}}class ct{constructor(e,s){this.userID=e,this.remark="",this.groupList=[],this.source="",this.addTime=0,this.friendCustomField=[],this.timestamp=0;const n={},o=[];if(n.userID=e,!oe(s)){let r="",i;for(let e=0,t=s.length;e<t;e++)if(r=s[e].tag,i=s[e].value,-1<r.indexOf("Tag_SNS_Custom"))this.friendCustomField.push({key:r,value:i});else if(-1<r.indexOf("Tag_Profile_Custom"))o.push({key:r,value:i});else switch(r){case H:n.nick=i;break;case W:n.gender=i;break;case B:n.birthday=i;break;case j:n.location=i;break;case K:n.selfSignature=i;break;case Y:n.allowType=i;break;case J:n.language=i;break;case V:n.avatar=i;break;case z:n.messageSettings=i;break;case Q:n.adminForbidType=i;break;case X:n.level=i;break;case Z:n.role=i;break;case ee.REMARK:this.remark=i;break;case ee.ADDTIME:this.addTime=i;break;case ee.GROUP:this.groupList=JSON.parse(JSON.stringify(i));break;case ee.ADDSOURCE:this.source=i;break;case ee.ADDWORDING:break;default:we.l("snsProfileItem unknown tag->",s[e].tag)}}this.profile=new ut({...n,profileCustomField:o})}validate(r){let i=!0,e="";if(oe(r))return{valid:!1,tips:"empty options"};if(r.profileCustomField){const i=r.profileCustomField.length;let t=null;for(let e=0;e<i;e++){if(t=r.profileCustomField[e],!le(t.key)||-1===t.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!le(t.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}}for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if("profileCustomField"===t)continue;if(oe(r[t])&&!le(r[t])&&!ce(r[t])){e="key:"+t+", invalid value:"+r[t],i=!1;continue}switch(t){case"nick":le(r[t])||(e="nick must be a string",i=!1),500<ge(r[t])&&(e=`nick name limited: must less than or equal to 500 bytes, current size: ${ge(r[t])} bytes`,i=!1);break;case"gender":Me(se,r.gender)||(e="key:gender, invalid value:"+r.gender,i=!1);break;case"birthday":ce(r.birthday)||(e="birthday must be a number",i=!1);break;case"location":le(r.location)||(e="location must be a string",i=!1);break;case"selfSignature":le(r.selfSignature)||(e="selfSignature must be a string",i=!1);break;case"allowType":Me(re,r.allowType)||(e="key:allowType, invalid value:"+r.allowType,i=!1);break;case"language":ce(r.language)||(e="language must be a number",i=!1);break;case"avatar":le(r.avatar)||(e="avatar must be a string",i=!1);break;case"messageSettings":0!==r.messageSettings&&1!==r.messageSettings&&(e="messageSettings must be 0 or 1",i=!1);break;case"adminForbidType":Me(ie,r.adminForbidType)||(e="key:adminForbidType, invalid value:"+r.adminForbidType,i=!1);break;case"level":ce(r.level)||(e="level must be a number",i=!1);break;case"role":ce(r.role)||(e="role must be a number",i=!1);break;default:e="unknown key:"+t+" "+r[t],i=!1}}return{valid:i,tips:e}}update(r){let i="",s;const n=[];this.friendCustomField.forEach(e=>{n.push(e.key)});for(let e=0,t=r.length;e<t;e++)if(i=r[e].tag,s=r[e].value,-1<i.indexOf("Tag_SNS_Custom"))-1<n.indexOf(i)?this.friendCustomField.forEach(e=>{e.key===i&&(e.value=s)}):this.friendCustomField.push({key:i,value:s});else if(-1<i.indexOf("Tag_Profile_Custom")){let t=!1;this.profile.profileCustomField.forEach(e=>{e.key===i&&(e.value=s,t=!0)}),t||this.profile.profileCustomField.push({key:i,value:s})}else switch(i){case H:this.profile.nick=s;break;case W:this.profile.gender=s;break;case B:this.profile.birthday=s;break;case j:this.profile.location=s;break;case K:this.profile.selfSignature=s;break;case Y:this.profile.allowType=s;break;case J:this.profile.language=s;break;case V:this.profile.avatar=s;break;case z:this.profile.messageSettings=s;break;case Q:this.profile.adminForbidType=s;break;case X:this.profile.level=s;break;case Z:this.profile.role=s;break;case ee.REMARK:this.remark=s;break;case ee.ADDTIME:this.addTime=s;break;case ee.GROUP:this.groupList=JSON.parse(JSON.stringify(s));break;case ee.ADDSOURCE:this.source=s;break;case ee.ADDWORDING:break;default:we.d("snsProfileItem unkown tag->",r[e].tag)}this.timestamp=Date.now(),n.length=0}updateProfile(e){this.profile=JSON.parse(JSON.stringify(e)),this.timestamp=Date.now()}addToGroupList(e){-1===this.groupList.indexOf(e)&&(this.groupList.push(e),this.count=this.groupList.length)}removeFromGroupList(e){e=this.groupList.indexOf(e);-1<e&&(this.groupList.splice(e,1),this.count=this.groupList.length)}}const lt=4,pt=11,ht=12,ft=20,_t=23,mt=27,gt=29;class Mt{constructor(e){this._snsM=e,this._n="FriendHandler",this._friendMap=new Map,this._startIndex=0,this._standardSequence=0,this._customSequence=0,this._expirationTime=18e4}getLocalFriendList(){return[...this._friendMap.values()]}getFriendRemark(e){return this._friendMap.has(e)?this._friendMap.get(e).remark:""}onFriendProfileModified(e){const t=e["dataList"];if(!oe(t)){const i=this._snsM.get(pt);t.forEach(e=>{var{userID:t,profileList:r}=e;if(this.isMyFriend(t)){we.l(this._n+`.onFriendProfileModified. friend account:${t}, profileList:`+JSON.stringify(r));const e=this._friendMap.get(t);e.update(r),i.modifyMessageSentByPeer({conversationID:""+S+t,latestNick:e.profile.nick,latestAvatar:e.profile.avatar})}}),this._onFriendListUpdated()}}onFriendAdded(t){0!==t.length&&(we.l(this._n+".onFriendAdded userIDList:"+t),t.forEach(e=>{this._friendMap.set(e,new ct(e))}),this.getFriendProfile({userIDList:t}).then(e=>{t.forEach(e=>{var t=this._friendMap.get(e);0<t.groupList.length&&this._snsM.updateWhenFriendAdded({nameList:t.groupList,userID:e})}),this._onFriendListUpdated()}))}onFriendDeleted(e){0!==e.length&&(we.l(this._n+".onFriendDeleted userIDList:"+e),e.forEach(e=>{var t=this._friendMap.get(e);0<t.groupList.length&&this._snsM.updateWhenFriendDeleted({nameList:t.groupList,userID:e}),this._friendMap.delete(e)}),this._onFriendListUpdated())}_onFriendListUpdated(){this._snsM.emitOuterEvent(Pe),this._snsM.get(pt).checkAndPatchRemark()}getFriendProfile(e){const r=this._n+".getFriendProfile",t=e["userIDList"],s=[],n=[],i=[];if(t.forEach(e=>{var t;this._friendMap.has(e)?(t=this._friendMap.get(e),Date.now()-t.timestamp<this._expirationTime?n.push(t):i.push(e)):s.push({userID:e,code:Se,message:this._snsM.getErrorMessage(Se)})}),0===i.length)return we.i(r+" newUserIDList is empty"),xe({friendList:n,failureUserIDList:s});const o=new at("getFriendProfile");return o.setMessage("userIDList:"+i),we.i(r+" userIDList:"+i),this._snsM.req({proto:Be,data:{fromAccount:this._snsM.getMyUserID(),userIDList:i}}).then(e=>{o.end(),we.i(r+" ok");const t=e.data["resultList"];return t.forEach(t=>{var{to:t,resultCode:e,resultInfo:r,tagValueList:i}=t;if(fe(e)||0===e){let e;this._friendMap.has(t)?(e=this._friendMap.get(t)).update(i):(e=new ct(t,i),this._friendMap.set(t,e)),n.push(e)}else s.push({userID:t,code:e,message:r})}),Te({friendList:n,failureUserIDList:s})}).catch(e=>(o.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}isMyFriend(e){return this._friendMap.has(e)}pagingGetFriendList(){const a=this._n+".getFriendList",d=new at("getFriendList"),u=Date.now();this._snsM.req({proto:We,data:{fromAccount:this._snsM.getMyUserID(),startIndex:this._startIndex,standardSequence:this._standardSequence,customSequence:this._customSequence}}).then(e=>{const{friendCount:t,resultList:r,nextStartIndex:i,standardSequence:s,customSequence:n,completeFlag:o}=e.data;e=`friendCount:${t} nextStartIndex:${this._startIndex=i} standardSequence:${this._standardSequence=s} customSequence:${this._customSequence=n} completeFlag:${o} cost:`+(e=u,Date.now()-e+" ms");d.setMessage(e).end(),we.i(a+" ok.",e),oe(r)||r.forEach(e=>{var{to:e,tagValueList:t}=e;this._friendMap.set(e,new ct(e,t))}),0===o?this.pagingGetFriendList():(this._snsM.emitOuterEvent(Pe),this._pagingGetFriendProfile())}).catch(e=>(d.setError(e).end(),we.w(a+" failed. error:",e),He(e)))}_pagingGetFriendProfile(){const t=[...this._friendMap.keys()],r=this._snsM.get(lt),e=t.length,i=e<=100?1:Math.ceil(e/100);we.l(this._n+`._pagingGetFriendProfile friendCount:${e} pageCount:`+i);for(let e=0;e<i;e++)r.getUserProfile({userIDList:t.slice(100*e,100*(e+1))}).then(e=>{e.data.forEach(e=>{const t=this._friendMap.get(e.userID);t&&t.updateProfile(e)}),this._onFriendListUpdated()})}addFriend(e){const i=this._n+".addFriend";if(this._friendMap.has(e.to))return He({code:Ee});if(e.wording&&!1===this._snsM.filterProfanity("wording",e))return He({code:Ne});var{to:e,source:t,type:r,wording:s,remark:n,groupName:o}=e;let a=r;a&&(a===v||a===b)||(a=b);const d=new at("addFriend");return d.setMessage(`to:${e} source:${t} type:`+a),this._snsM.req({proto:Ye,data:{fromAccount:this._snsM.getMyUserID(),addFriendItem:[{to:e,source:t,wording:s,remark:n,groupName:o}],type:a}}).then(e=>{var e=e.data["resultList"],{to:e,resultCode:t,resultInfo:r}=(d.setMoreMessage("resultList:"+JSON.stringify(e)).end(),e[0]);return we.i(i+` ok. to:${e} type:${a} code:`+t),fe(t)||0===t?Te({userID:e,code:0}):30539===t?Te({userID:e,code:t,message:this._snsM.getErrorMessage(t)}):He({userID:e,code:t,message:this._snsM.getErrorMessage(t)||r})}).catch(e=>(d.setError(e).end(),we.w(i+" failed. error:",e),He(e)))}deleteFriend(e){const r=this._n+".deleteFriend",{userIDList:t,type:i}=e;1e3<t.length&&(we.w(r+" "+"the length of userIDList cannot exceed 1000"),t.length=1e3);const s=[],n=[],o=[];if(t.forEach(e=>{this._friendMap.has(e)?o.push(e):s.push({userID:e,code:Se,message:this._snsM.getErrorMessage(Se)})}),0===o.length)return xe({successUserIDList:n,failureUserIDList:s});let a=i;a&&(a===G||a===C)||(a=C);const d=new at("deleteFriend");return d.setMessage(`userIDList:${o} type:`+a),this._snsM.req({proto:Ke,data:{fromAccount:this._snsM.getMyUserID(),userIDList:o,type:a}}).then(e=>{d.end(),we.i(r+" ok");const t=e.data["resultList"];return oe(t)||t.forEach(e=>{var{to:e,resultCode:t,resultInfo:r}=e;fe(t)||0===t?n.push({userID:e}):s.push({userID:e,code:t,message:r})}),Te({successUserIDList:n,failureUserIDList:s})}).catch(e=>(d.setError(e).end(),we.w(r+" error:",e),He(e)))}updateFriend(e){const{userID:t,remark:i,friendCustomField:n}=e;if(!this._friendMap.has(t))return He({code:Se});const o=this._n+".updateFriend",a=new at("updateFriend"),r=(a.setMessage(`userID:${t} remark:${i} friendCustomField:`+n),[]);return fe(i)||r.push({tag:ee.REMARK,value:i}),he(n)&&0<n.length&&n.forEach(e=>{r.push({tag:e.key,value:e.value})}),this._snsM.req({proto:Je,data:{fromAccount:this._snsM.getMyUserID(),updateItem:[{to:t,snsItem:r}]}}).then(e=>{a.end(),we.i(o+" ok");var e=e.data["resultList"],{to:t,resultCode:e,resultInfo:r}=e[0];if(fe(e)||0===e){const e=this._friendMap.get(t);if(e){fe(i)||(e.remark=i);if(he(n)&&0<n.length){var s=e.friendCustomField;t=n;if(he(s)&&he(t)){let i=!1;t.forEach(({key:t,value:e})=>{const r=s.find(e=>e.key===t);r?r.value!==e&&(r.value=e,i=!0):(s.push({key:t,value:e}),i=!0)})}}this._onFriendListUpdated()}return Te(e)}return He({code:e,message:r})}).catch(e=>(a.setError(e).end(),we.w(o+" failed. error:",e),He(e)))}checkFriend(e){const r=this._n+".checkFriend",{userIDList:i,type:t}=e;let o=t;o&&(o===q||o===R)||(o=R);const a=new at("checkFriend");return a.setMessage(`userIDList:${i} type:`+o),this._snsM.req({proto:je,data:{fromAccount:this._snsM.getMyUserID(),userIDList:i,type:o}}).then(e=>{a.end(),we.i(r+` ok. userIDList:${i} type:`+o);const s=[],n=[],t=e.data["resultList"];return he(t)&&t.forEach(e=>{var{to:e,relation:t,resultCode:r,resultInfo:i}=e;fe(r)||0===r?s.push({userID:e,code:0,relation:t}):n.push({userID:e,code:r,message:i})}),Te({successUserIDList:s,failureUserIDList:n})}).catch(e=>(a.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}updateWhenAddedToFriendGroup(e){const{name:t,userIDList:r}=e;we.l(`${this._n}.updateWhenAddedToFriendGroup groupName:${t} userIDList:`+r),t&&!oe(r)&&r.forEach(e=>{this._friendMap.has(e)&&this._friendMap.get(e).addToGroupList(t)})}updateWhenRemovedFromFriendGroup(e){const{name:t,userIDList:r}=e;we.l(`${this._n}.updateWhenRemovedFromFriendGroup groupName:${t} userIDList:`+r),t&&!oe(r)&&r.forEach(e=>{this._friendMap.has(e)&&this._friendMap.get(e).removeFromGroupList(t)})}reset(){this._friendMap.clear(),this._startIndex=0,this._standardSequence=0,this._customSequence=0}}class Ft{constructor(e){oe(e)||(this.name=e.name||"",this.userIDList=e.userIDList||[],this.count=this.userIDList.length||0)}addToUserIDList(e){-1===this.userIDList.indexOf(e)&&(this.userIDList.push(e),this.count=this.userIDList.length)}removeFromUserIDList(e){e=this.userIDList.indexOf(e);-1<e&&(this.userIDList.splice(e,1),this.count=this.userIDList.length)}}class yt{constructor(e){this._snsM=e,this._n="FriendGroupHandler",this._friendGroupMap=new Map}getLocalFriendGroupList(){return[...this._friendGroupMap.values()]}_emitFriendGroupListUpdated(){var e=[...this._friendGroupMap.values()];this._snsM.emitOuterEvent(Oe,e)}getFriendGroupList(){const r=this._n+".getFriendGroupList",i=new at("getFriendGroupList");return this._snsM.req({proto:Ze,data:{fromAccount:this._snsM.getMyUserID()}}).then(e=>{i.end();const t=e.data["resultList"];oe(t)?we.i(r+" ok. friend group count:0"):(we.i(r+" ok. friend group count:"+t.length),this._friendGroupMap.clear(),t.forEach(e=>{var t=new Ft(e);this._friendGroupMap.set(e.name,t)}),this._emitFriendGroupListUpdated())}).catch(e=>(i.setError(e).end(),we.w(r+" error:",e),He(e)))}createFriendGroup(e){const r=this._n+".createFriendGroup",{name:i,userIDList:o}=e;if(this._friendGroupMap.has(i))return He({code:ke});const a=new at("createFriendGroup");return a.setMessage(`name:${i} userIDList:`+o),this._snsM.req({proto:et,data:{fromAccount:this._snsM.getMyUserID(),groupName:[i],userIDList:he(o)?o:void 0}}).then(e=>{a.end(),we.l(r+` ok. name:${i} userIDList:`+o);const t=e.data["resultList"],s=[],n=[];t&&t.forEach(e=>{const{to:t,resultCode:r,resultInfo:i}=e;if(fe(r)||0===r)s.push(t);else{const t={userID:e.to,code:r,message:i};n.push(t)}});e=new Ft({name:i,userIDList:s});return this._friendGroupMap.set(i,e),this._snsM.updateWhenAddedToFriendGroup({name:i,userIDList:s}),this._emitFriendGroupListUpdated(),Te({friendGroup:e,failureUserIDList:n})}).catch(e=>(a.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}deleteFriendGroup(e){const r=this._n+".deleteFriendGroup",i=e["name"];if(!this._friendGroupMap.has(i))return He({code:ve});const s=new at("deleteFriendGroup");return s.setMessage("name:"+i),this._snsM.req({proto:st,data:{fromAccount:this._snsM.getMyUserID(),nameList:[i]}}).then(e=>{s.end(),we.l(r+" ok. name:"+i);const t=this._friendGroupMap.get(i);return t&&(this._snsM.updateWhenRemovedFromFriendGroup({name:i,userIDList:t.userIDList}),this._friendGroupMap.delete(i),t.userIDList.length=0),this._emitFriendGroupListUpdated(),Te(t)}).catch(e=>(s.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}renameFriendGroup(e){const t=this._n+".renameFriendGroup",{oldName:r,newName:i}=e;if(!this._friendGroupMap.has(r))return He({code:ve});const s=new at("renameFriendGroup");return s.setMessage(`oldName:${r} newName:`+i),this._snsM.req({proto:it,data:{fromAccount:this._snsM.getMyUserID(),oldName:r,newName:i}}).then(()=>{if(s.end(),we.l(t+` ok. oldName:${r} newName:`+i),this._friendGroupMap.has(r)){const e=this._friendGroupMap.get(r);return e.name=i,this._friendGroupMap.delete(r),this._friendGroupMap.set(i,e),this._snsM.updateWhenRemovedFromFriendGroup({name:r,userIDList:e.userIDList}),this._snsM.updateWhenAddedToFriendGroup({name:i,userIDList:e.userIDList}),this._emitFriendGroupListUpdated(),Te(e)}return Te()}).catch(e=>(s.setError(e).end(),we.w(t+" failed. error:",e),He(e)))}addToFriendGroup(e){const t=this._n+".addToFriendGroup",{name:r,userIDList:i}=e;if(!this._friendGroupMap.has(r))return this._onFriendGroupNotExist(r);const s=new at("addToFriendGroup");return s.setMessage(`name:${r} userIDList:`+i),we.l(t+` name:${r} userIDList:`+i),this._snsM.req({proto:it,data:{fromAccount:this._snsM.getMyUserID(),oldName:r,updateGroupItem:i.filter(e=>this._snsM.isMyFriend(e)).map(e=>({to:e,updateType:"Update_Type_Add"}))}}).then(e=>(s.end(),this._onFriendGroupUpdated(r,e))).catch(e=>(s.setError(e).end(),we.w(t+" failed. error:",e),He(e)))}removeFromFriendGroup(e){const t=this._n+".removeFromFriendGroup",{name:r,userIDList:i}=e;if(!this._friendGroupMap.has(r))return this._onFriendGroupNotExist(r);const s=new at("removeFromFriendGroup");return s.setMessage(`name:${r} userIDList:`+i),we.l(t+` name:${r} userIDList:`+i),this._snsM.req({proto:it,data:{fromAccount:this._snsM.getMyUserID(),oldName:r,updateGroupItem:i.filter(e=>this._snsM.isMyFriend(e)).map(e=>({to:e,updateType:"Update_Type_Delete"}))}}).then(e=>(s.end(),this._onFriendGroupUpdated(r,e))).catch(e=>(s.setError(e).end(),we.w(t+" failed. error:",e),He(e)))}_onFriendGroupUpdated(e,t){const r=t.data["resultList"],n=this._friendGroupMap.get(e),o=[],a=[],d=[];return he(r)&&r.forEach(e=>{var{to:t,resultCode:r,resultInfo:i,type:s}=e;0===r?"Update_Type_Add"===s?n&&(n.addToUserIDList(t),a.push(t)):"Update_Type_Delete"===s&&n&&(n.removeFromUserIDList(t),d.push(t)):o.push({to:e.to,code:r,message:i})}),we.l(this._n+`._onFriendGroupUpdated name:${e} userIDList:`+n.userIDList),0<a.length&&this._snsM.updateWhenAddedToFriendGroup({name:e,userIDList:a}),0<d.length&&this._snsM.updateWhenRemovedFromFriendGroup({name:e,userIDList:d}),Te({friendGroup:n,failureUserIDList:o})}updateWhenFriendAdded(e){const{nameList:t,userID:r}=e;we.l(`${this._n}.updateWhenFriendAdded userID:${r} nameList:`+t),oe(t)||t.forEach(e=>{this._friendGroupMap.has(e)&&this._friendGroupMap.get(e).addToUserIDList(r)})}updateWhenFriendDeleted(e){const{nameList:t,userID:r}=e;we.l(`${this._n}.updateWhenFriendDeleted userID:${r} nameList:`+t),oe(t)||t.forEach(e=>{this._friendGroupMap.has(e)&&this._friendGroupMap.get(e).removeFromUserIDList(r)})}reset(){this._friendGroupMap.clear()}}class At extends class{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.get(ht).isLoggedIn()}isOversea(){return this._m.get(ht).isOversea()}isPrivateNetWork(){return this._m.get(ht).isPrivateNetWork()}getFileDownloadProxy(){return this._m.get(ht).getFileDownloadProxy()}getMyUserID(){return this._m.get(ht).getUserID()}getMyTinyID(){return this._m.get(ht).getTinyID()}getSDKAppID(){return this._m.get(ht).getSDKAppID()}isIntl(){return this._m.get(ht).isIntl()}isUsingChatCore(){return this._m.get(ht).isUsingChatCore()}isDevMode(){return this._m.get(ht).isDevMode()}get(e){return this._m.get(e)}getPlatform(){return T}getCloudConfig(e){return this._m.get(_t).getCloudConfig(e)}emitOuterEvent(e,t){this._m.getOuterEmitterInstance().emit(e,t)}emitInnerEvent(e,t){this._m.getInnerEmitterInstance().emit(e,t)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(e){return this._m.get(ht).getTinyID()+"-"+e.random}req(e){return this._m.get(ft).req(e)}canIUse(e){return this._m.get(mt).canIUse(e)}getErrorMessage(e,t,r){return this._m.getErrorMessage(e,t,r)}outputWarning(e,t,r){e=this.getErrorMessage(e,t,r);e&&we.w(e)}cannotUseCommercialAbility(e){var t=Ue;return He({code:t,message:this.getErrorMessage(t,e)})}}{constructor(t){super(t),this._n="SnsModule",this._friendHandler=new Mt(this),this._friendApplicationHandler=new dt(this),this._friendGroupHandler=new yt(this),this.getInnerEmitterInstance().on(e.A2KEY_AND_TINYID_UPDATED,this.onContextUpdated,this)}onContextUpdated(e){this._friendHandler.pagingGetFriendList(),this._friendGroupHandler.getFriendGroupList(),this._friendApplicationHandler.getFriendApplicationList()}onRelationChainModified(e){const t=e["dataList"];if(!oe(t)){const s=[],n=[],o=[],a=[];let r=!1,i="";t.forEach(e=>{if(3!==e.pushType&&4!==e.pushType||!e.from||(i=e.from),e.friendAddAccount&&(s.push(...e.friendAddAccount),a.push(...e.friendAddAccount)),e.friendDelAccount&&n.push(...e.friendDelAccount),e.friendApplicationAdded&&o.push(...e.friendApplicationAdded),e.friendApplicationDeletedUserIDList&&a.push(...e.friendApplicationDeletedUserIDList),e.reportTime&&7===e.pushType&&(r=!0),e.friendUpInfo){const t={dataList:[]};e.friendUpInfo.forEach(e=>{t.dataList.push({userID:e.friendAccount,profileList:[...e.sns]})}),this.onFriendProfileModified(t)}}),r&&this._friendApplicationHandler.onFriendApplicationRead(),this._friendApplicationHandler.onFriendApplicationAdded(o,i),this._friendApplicationHandler.onFriendApplicationDeleted(a),this._friendHandler.onFriendAdded(s),this._friendHandler.onFriendDeleted(n)}}isMyFriend(e){return this._friendHandler.isMyFriend(e)}filterProfanity(e,t){const r=this.get(gt);if(!r)return!0;var{isAllowedToSend:i,modifiedText:s}=r.filterText(t[e],p);return!0===i&&(t[e]=s,!0)}onFriendProfileModified(e){this._friendHandler.onFriendProfileModified(e)}getLocalFriendList(e=!0){var t=this._friendHandler.getLocalFriendList();return e?xe(t):t}getFriendRemark(e){return this._friendHandler.getFriendRemark(e)}getFriendList(){return this._friendHandler.pagingGetFriendList()}addFriend(e){return this._friendHandler.addFriend(e)}deleteFriend(e){return this._friendHandler.deleteFriend(e)}checkFriend(e){return this._friendHandler.checkFriend(e)}getFriendProfile(e){return this._friendHandler.getFriendProfile(e)}updateFriend(e){return this._friendHandler.updateFriend(e)}updateWhenAddedToFriendGroup(e){this._friendHandler.updateWhenAddedToFriendGroup(e)}updateWhenRemovedFromFriendGroup(e){this._friendHandler.updateWhenRemovedFromFriendGroup(e)}getLocalFriendApplicationList(){var e=this._friendApplicationHandler.getLocalFriendApplicationList();return xe(e)}deleteFriendApplication(e){return this._friendApplicationHandler.deleteFriendApplication(e)}refuseFriendApplication(e){return this._friendApplicationHandler.refuseFriendApplication(e)}acceptFriendApplication(e){return this._friendApplicationHandler.acceptFriendApplication(e)}setFriendApplicationRead(e){return this._friendApplicationHandler.setFriendApplicationRead(e)}getLocalFriendGroupList(){var e=this._friendGroupHandler.getLocalFriendGroupList();return xe(e)}createFriendGroup(e){return this._friendGroupHandler.createFriendGroup(e)}deleteFriendGroup(e){return this._friendGroupHandler.deleteFriendGroup(e)}addToFriendGroup(e){return this._friendGroupHandler.addToFriendGroup(e)}removeFromFriendGroup(e){return this._friendGroupHandler.removeFromFriendGroup(e)}renameFriendGroup(e){return this._friendGroupHandler.renameFriendGroup(e)}onAddToFriendGroup(e){return this._friendGroupHandler.onAddToFriendGroup(e)}updateWhenFriendAdded(e){this._friendGroupHandler.updateWhenFriendAdded(e)}updateWhenFriendDeleted(e){this._friendGroupHandler.updateWhenFriendDeleted(e)}reset(){we.l(this._n+".reset"),this._friendHandler.reset(),this._friendGroupHandler.reset(),this._friendApplicationHandler.reset()}}export{At as default};
"use strict";const e={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};let t,s;t="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const i=function(){},r=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let n=r.length;for(;n--;)s=r[n],console[s]||(t[s]=i);var o=t;class a{constructor(e=0,t=0){this.high=e,this.low=t}equal(e){return null!==e&&this.low===e.low&&this.high===e.high}toString(){var e=Number(this.high).toString(16);let t=Number(this.low).toString(16);if(t.length<8){let e=8-t.length;for(;e;)t="0"+t,e--}return e+t}}const d={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},u={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15},c="CHINA",l={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=c){this.CURRENT=d.PRODUCTION[e]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report"}},p=(new a(0,Math.pow(2,0)).toString(),new a(0,Math.pow(2,1)).toString(),new a(0,Math.pow(2,2)).toString(),new a(0,Math.pow(2,3)).toString(),new a(0,Math.pow(2,4)).toString(),new a(0,Math.pow(2,6)).toString(),new a(0,Math.pow(2,7)).toString(),new a(0,Math.pow(2,9)).toString(),new a(0,Math.pow(2,10)).toString(),new a(0,Math.pow(2,11)).toString(),new a(0,Math.pow(2,13)).toString(),new a(0,Math.pow(2,15)).toString(),new a(Math.pow(2,6)).toString(),new a(Math.pow(2,7)).toString(),new a(Math.pow(2,8)).toString(),new a(Math.pow(2,9)).toString(),new a(Math.pow(2,10)).toString(),new a(Math.pow(2,16)).toString(),new a(Math.pow(2,20)).toString(),"sns"),h=(l.HOST.setCurrent(c),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),f=(h&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),_="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),m="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),g="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),M="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,F="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,y=h||f||_||m||g||F||M,A=("undefined"!=typeof uni||"undefined"!=typeof window)&&!y,I=(f?qq:_?tt:m?swan:g?my:h?wx:F?uni:M&&jd,A&&window&&window.navigator&&window.navigator.userAgent||""),w=/(micromessenger|webbrowser)/i.test(I),D=/AppleWebKit\/([\d.]+)/i.exec(I),T=(D&&parseFloat(D.pop()),function(){let e="WEB";return w?e="WEB":f?e="QQ_MP":_?e="TT_MP":m?e="BAIDU_MP":g?e="ALI_MP":h?e="WX_MP":F&&(e="UNI_NATIVE_APP"),u[e]}()),L=(!function(){var e=I.match(/OS (\d+)_/i);e&&e[1]&&e[1]}(),function(){var e,t,r=I.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);r&&(e=r[1]&&parseFloat(r[1]),t=r[2]&&parseFloat(r[2]),e&&t&&parseFloat(r[1]+"."+r[2]))}(),function(){var e=I.match(/Chrome\/(\d+)/);e&&e[1]&&parseFloat(e[1])}(),/MSIE/.test(I)||-1<I.indexOf("Trident")&&-1<I.indexOf("rv:11.0")),S=(!function(){var e=/MSIE\s(\d+)\.\d/.exec(I),e=e&&parseFloat(e[1]);!e&&/Trident\/7.0/i.test(I)&&/rv:11.0/.test(I)}(),function(){var e=I.match(/TBS\/(\d+)/i);e&&e[1]&&e[1]}(),"C2C"),E="AllowType_Type_AllowAny",k="AdminForbid_Type_None",v="Add_Type_Single",b="Add_Type_Both",G="Delete_Type_Single",C="Delete_Type_Both",U="Pendency_Type_Both",N="Pendency_Type_ComeIn",P="Pendency_Type_SendOut",O="Response_Action_Agree",$="Response_Action_AgreeAndAdd",R="CheckResult_Type_Both",q="CheckResult_Type_Single",x=function(){return(new Date).getTime()+0},H="Tag_Profile_IM_Nick",W="Tag_Profile_IM_Gender",B="Tag_Profile_IM_BirthDay",j="Tag_Profile_IM_Location",K="Tag_Profile_IM_SelfSignature",Y="Tag_Profile_IM_AllowType",J="Tag_Profile_IM_Language",V="Tag_Profile_IM_Image",z="Tag_Profile_IM_MsgSettings",Q="Tag_Profile_IM_AdminForbidType",X="Tag_Profile_IM_Level",Z="Tag_Profile_IM_Role",ee={GROUP:"Tag_SNS_IM_Group",REMARK:"Tag_SNS_IM_Remark",ADDSOURCE:"Tag_SNS_IM_AddSource",ADDWORDING:"Tag_SNS_IM_Wording",ADDTIME:"Tag_SNS_IM_AddTime"},te="Gender_Type_",se={UNKNOWN:te+"Unknown",FEMALE:te+"Female",MALE:te+"Male"},ie={NONE:"AdminForbid_Type_None",SEND_OUT:"AdminForbid_Type_SendOut"},re={NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_ANY:"AllowType_Type_AllowAny",DENY_ANY:"AllowType_Type_DenyAny"},ne=Object.prototype.hasOwnProperty;function oe(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(pe(e)){for(const t in e)if(ne.call(e,t))return!1;return!0}return!!(ae(e)||de(e)||ue(e))&&0===e.size}const ae=function(e){return"map"===me(e)},de=function(e){return"set"===me(e)},ue=function(e){return"file"===me(e)},ce=function(e){return null!==e&&("number"==typeof e&&!isNaN(+e)||"object"==typeof e&&e.constructor===Number)},le=function(e){return"string"==typeof e},pe=function(e){if("object"!=typeof e||null===e)return!1;e=Object.getPrototypeOf(e);if(null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t},he=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===me(e)},fe=function(e){return void 0===e},_e=function(e){return e instanceof Error},me=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},ge=(Date.now||(Date.now=function(){return(new Date).getTime()}),function(e){if(0===e.length)return 0;let t=0,r=0,i;for(var s="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";void 0!==e[t];)i=e[t++].charCodeAt[t]<=255?1:!1===s?3:2,r+=i;return r}),Me=function(e,t){for(const r in e)if(e[r]===t)return!0;return!1};function Fe(){return!L&&!y}let ye=0;function Ae(){return Fe()?"%c Chat %c":"Chat"}function Ie(){const e=function(){const e=new Date;return e.setTime(x()),e}();return e.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){let t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(e.getMilliseconds())}const we={arguments2String(r){let i="";if(1===r.length)i=r[0];else for(let e=0,t=r.length;e<t;e++)s=r[e],he(s)||null!==s&&"object"==typeof s?_e(r[e])?i+=(s=r[e],JSON.stringify(s,["message","code"])):i+=JSON.stringify(r[e]):i+=r[e],i+=" ";var s;return i},_exec(e,t){Fe()?o[e](Ae(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",Ie(),t):o[e](`${Ae()} ${Ie()} `+t)},d:function(){var e;ye<=-1&&(e=this.arguments2String(arguments),this._exec("debug",e))},l:function(){var e;ye<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},log:function(){var e;ye<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},i:function(){var e;ye<=1&&(e=this.arguments2String(arguments),this._exec("info",e))},w:function(){var e;ye<=2&&(e=this.arguments2String(arguments),this._exec("warn",e))},e:function(){var e;ye<=3&&(e=this.arguments2String(arguments),this._exec("error",e))},setLevel:function(e){e<4&&this._exec("log","set level from "+ye+" to "+e),ye=e},getLevel:function(){return ye}};class De{constructor(e){oe(e)||(this.userID=e.userID||"",this.nick=e.nick||"",this.avatar=e.avatar||"",this.time=e.time||0,this.source=e.source||"",this.wording=e.wording||"",this.type=e.type||"")}}const Te=function(e){return{code:0,data:e||{}}};class Le extends Error{constructor(e){super();var{code:e,message:t,data:r}=e;this.code=e,t?this.message=t:this._getErrorMessage&&(this.message=this._getErrorMessage(this.code)),this.data=r||{}}}const Se=2700,Ee=2701,ke=2710,ve=2711,be=2716,Ge=2805,Ce=2903,Ue=3122,Ne=3123,Pe="onFriendListUpdated",Oe="onFriendGroupListUpdated",$e="onFriendApplicationListUpdated",Re="error";let qe=null;const xe=function(e){return Promise.resolve(Te(e))},He=function(e,t=!1){if(e instanceof Le)return t&&null!==qe&&qe.emit(Re,e),Promise.reject(e);if(e instanceof Error){const e=new Le({code:Ce});return t&&null!==qe&&qe.emit(Re,e),Promise.reject(e)}if(fe(e)||fe(e.code))return Promise.reject(new Le({code:Ce}));e=new Le(e);return t&&null!==qe&&qe.emit(Re,e),Promise.reject(e)},We="friend_get",Be="friend_get_specified",je="friend_check",Ke="friend_delete",Ye="friend_add",Je="friend_update",Ve="friend_response",ze="pendency_get",Qe="pendency_delete",Xe="pendency_report",Ze="group_get",et="group_add",st="group_delete",it="group_update",rt={info:4,warning:5,error:6},nt={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},ot={login:4,plugin_search:16,plugin_translate:16,plugin_voice_to_text:16,plugin_cs:16,plugin_push:16,plugin_bot:16,plugin_emoji_reaction:16};class at{constructor(e){this._n="SSOLogData",this.eventType=ot[e]||0,this.timestamp=0,this.networkType=8,this.code=0,this.message="",this.moreMessage="",this.extension=e,this.costTime=0,this.duplicate=!1,this.level=4,this.uiPlatform=void 0,this._sentFlag=!1,this._startts=x()}static bindEventStatModule(e){at.prototype._eventStatModule=e}static bindNetMonitorModule(e){at.prototype._netMonitorModule=e}updateTimeStamp(){this.timestamp=x()}start(e){return this._startts=e,this}end(e=!1){if(!this._sentFlag){if(this._netMonitorModule){const e=this._netMonitorModule.getNetworkType();this.setNetworkType(e)}var t=x();0===this.costTime&&(this.costTime=t-this._startts),this.setMoreMessage(`startts:${this._startts} endts:`+t),e?(this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)):setTimeout(()=>{this._sentFlag=!0,this._eventStatModule&&this._eventStatModule.pushIn(this)},0)}}setError(e){if(!(e instanceof Error))return we.w(this._n+".setError value not instanceof Error, please check!"),this;if(this._sentFlag)return this;let t=!0;if(t=this._netMonitorModule?this._netMonitorModule.isOnline():t)e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message);else{const e=Ge;this.setCode(e)}return this.setLevel("error"),this}setCode(e){return fe(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),ce(e)?this.code=e:we.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return fe(e)||this._sentFlag||(ce(e)&&(this.message=e.toString()),le(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return fe(e)||this._sentFlag||(this.level=rt[e]),this}setMoreMessage(e){return oe(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){return fe(e)?we.w(this._n+".setNetworkType value is undefined, please check!"):(e=nt[e.toLowerCase()],fe(e)||(this.networkType=e)),this}getStartTs(){return this._startts}setUIPlatform(e){return this.uiPlatform=e,this}setExtension(e){return this.extension=e,this}setEventType(e){return this.eventType=e,this}}class dt{constructor(e){this._snsM=e,this._n="FriendApplicationHandler",this._startTime=0,this._maxLimited=100,this._currentSequence=0,this._friendApplicationMap=new Map,this._unreadCount=0}getLocalFriendApplicationList(){return{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount}}_onFriendApplicationListUpdated(){this._snsM.emitOuterEvent($e,{friendApplicationList:[...this._friendApplicationMap.values()],unreadCount:this._unreadCount})}onFriendApplicationRead(){this._unreadCount=0,this._onFriendApplicationListUpdated()}onFriendApplicationAdded(e,t){if(!oe(e)){let r,i=(r=t===this._snsM.getMyUserID()?P:N,!1);e.forEach(e=>{var t=e.userID+"_"+r;r!==N||this._friendApplicationMap.has(t)||(this._unreadCount+=1),this._friendApplicationMap.set(t,new De({...e,type:r})),i=!0}),i&&this._onFriendApplicationListUpdated()}}onFriendApplicationDeleted(e){oe(e)||(this._startTime=0,this._currentSequence=0,this.getFriendApplicationList())}getFriendApplicationList(){const n=this._n+".getFriendApplicationList",o=new at("getFriendApplicationList");return this._snsM.req({proto:ze,data:{applicationType:U,fromAccount:this._snsM.getMyUserID(),maxLimited:this._maxLimited,startTime:this._startTime,lastSequence:this._currentSequence}}).then(e=>{const{resultList:t,unreadCount:r,startTime:i,currentSequence:s}=e.data;this._startTime=i,this._currentSequence=s,this._unreadCount=r;e=`applicationCount:${he(t)?t.length:0} unreadCount:${r} startTime:${i} currentSequence:`+s;o.setMessage(e).end(),we.i(n+" ok. "+e),this._friendApplicationMap.clear(),he(t)&&t.forEach(e=>{var{userID:t,type:r}=e,e=new De(e);this._friendApplicationMap.set(t+"_"+r,e)}),this._onFriendApplicationListUpdated()}).catch(e=>(o.setError(e).end(),we.w(n+" failed. error:",e),He(e)))}deleteFriendApplication(e){const s=this._n+".deleteFriendApplication",{userID:n,type:t}=e;let o=t;if(o&&(o===P||o===N)||(o=N),!this._friendApplicationMap.has(n+"_"+o))return He({code:be});const a=new at("deleteFriendApplication");return a.setMessage(`userID:${n} type:`+o),this._snsM.req({proto:Qe,data:{fromAccount:this._snsM.getMyUserID(),userIDList:[n],type:o}}).then(e=>{var e=e.data["resultList"],{to:t,resultCode:r,resultInfo:i}=e[0];return a.setMoreMessage("resultList:"+JSON.stringify(e)).end(),we.i(s+` ok. userID:${n} type:`+o),0===r?Te():He({userID:t,code:r,message:i})}).catch(e=>(a.setError(e).end(),we.w(s+" failed. error:",e),He(e)))}acceptFriendApplication(e){const r=this._n+".acceptFriendApplication",{userID:i,remark:t,tag:s,type:n}=e;let o=n;o&&(o===O||o===$)||(o=$);const a=new at("acceptFriendApplication");return a.setMessage(`userID:${i} type:`+o),this._snsM.req({proto:Ve,data:{fromAccount:this._snsM.getMyUserID(),responseFriendItem:[{userID:i,remark:t,tag:s,action:o}]}}).then(e=>{a.end();var e=e.data["resultList"],{resultCode:e,resultInfo:t}=e[0];if(0!==e)return He({code:e,message:t});we.i(r+` ok. userID:${i} type:`+o)}).catch(e=>(a.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}refuseFriendApplication(e){const r=this._n+".refuseFriendApplication",i=e["userID"],s=new at("refuseFriendApplication");return s.setMessage("userID:"+i),this._snsM.req({proto:Ve,data:{fromAccount:this._snsM.getMyUserID(),responseFriendItem:[{userID:i,action:"Response_Action_Reject"}]}}).then(e=>{s.end();var e=e.data["resultList"],{resultCode:e,resultInfo:t}=e[0];if(0!==e)return He({code:e,message:t});we.i(r+" ok. userID:"+i)}).catch(e=>(s.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}_onFriendApplicationProcessed(e){if(0!==e.length){let t=!1;e.forEach(e=>{e=e.to+"_"+N;this._friendApplicationMap.has(e)&&(this._friendApplicationMap.delete(e),--this._unreadCount,t=!0)}),this._unreadCount<0&&(this._unreadCount=0),t&&this._onFriendApplicationListUpdated()}}setFriendApplicationRead(){const t=this._n+".setFriendApplicationRead",r=new at("setFriendApplicationRead");var e;return this._snsM.req({proto:Xe,data:{fromAccount:this._snsM.getMyUserID(),latestTimeStamp:(e=x()/1e3,Math.round(Number(e)*Math.pow(10,0))/Math.pow(10,0))}}).then(e=>{r.end(),we.i(t+" ok"),this._unreadCount=0}).catch(e=>(r.setError(e).end(),we.w(t+" failed. error:",e),He(e)))}reset(){this._startIndex=0,this._maxLimited=100,this._currentSequence=0,this._unreadCount=0,this._friendApplicationMap.clear()}}class ut{constructor(e){oe(e)||(this.userID=e.userID||"",this.nick=e.nick||"",this.gender=e.gender||"",this.birthday=e.birthday||0,this.location=e.location||"",this.selfSignature=e.selfSignature||"",this.allowType=e.allowType||E,this.language=e.language||0,this.avatar=e.avatar||"",this.messageSettings=e.messageSettings||0,this.adminForbidType=e.adminForbidType||k,this.level=e.level||0,this.role=e.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],oe(e.profileCustomField)||e.profileCustomField.forEach(e=>{this.profileCustomField.push({key:e.key,value:e.value})}))}validate(r){let i=!0,e="";if(oe(r))return{valid:!1,tips:"empty options"};if(r.profileCustomField){const i=r.profileCustomField.length;let t=null;for(let e=0;e<i;e++){if(t=r.profileCustomField[e],!le(t.key)||-1===t.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!le(t.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}}for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if("profileCustomField"===t)continue;if(oe(r[t])&&!le(r[t])&&!ce(r[t])){e="key:"+t+", invalid value:"+r[t],i=!1;continue}switch(t){case"nick":le(r[t])||(e="nick must be a string",i=!1),500<ge(r[t])&&(e=`nick name limited: must less than or equal to 500 bytes, current size: ${ge(r[t])} bytes`,i=!1);break;case"gender":Me(se,r.gender)||(e="key:gender, invalid value:"+r.gender,i=!1);break;case"birthday":ce(r.birthday)||(e="birthday must be a number",i=!1);break;case"location":le(r.location)||(e="location must be a string",i=!1);break;case"selfSignature":le(r.selfSignature)||(e="selfSignature must be a string",i=!1);break;case"allowType":Me(re,r.allowType)||(e="key:allowType, invalid value:"+r.allowType,i=!1);break;case"language":ce(r.language)||(e="language must be a number",i=!1);break;case"avatar":le(r.avatar)||(e="avatar must be a string",i=!1);break;case"messageSettings":0!==r.messageSettings&&1!==r.messageSettings&&(e="messageSettings must be 0 or 1",i=!1);break;case"adminForbidType":Me(ie,r.adminForbidType)||(e="key:adminForbidType, invalid value:"+r.adminForbidType,i=!1);break;case"level":ce(r.level)||(e="level must be a number",i=!1);break;case"role":ce(r.role)||(e="role must be a number",i=!1);break;default:e="unknown key:"+t+" "+r[t],i=!1}}return{valid:i,tips:e}}}class ct{constructor(e,s){this.userID=e,this.remark="",this.groupList=[],this.source="",this.addTime=0,this.friendCustomField=[],this.timestamp=0;const n={},o=[];if(n.userID=e,!oe(s)){let r="",i;for(let e=0,t=s.length;e<t;e++)if(r=s[e].tag,i=s[e].value,-1<r.indexOf("Tag_SNS_Custom"))this.friendCustomField.push({key:r,value:i});else if(-1<r.indexOf("Tag_Profile_Custom"))o.push({key:r,value:i});else switch(r){case H:n.nick=i;break;case W:n.gender=i;break;case B:n.birthday=i;break;case j:n.location=i;break;case K:n.selfSignature=i;break;case Y:n.allowType=i;break;case J:n.language=i;break;case V:n.avatar=i;break;case z:n.messageSettings=i;break;case Q:n.adminForbidType=i;break;case X:n.level=i;break;case Z:n.role=i;break;case ee.REMARK:this.remark=i;break;case ee.ADDTIME:this.addTime=i;break;case ee.GROUP:this.groupList=JSON.parse(JSON.stringify(i));break;case ee.ADDSOURCE:this.source=i;break;case ee.ADDWORDING:break;default:we.l("snsProfileItem unknown tag->",s[e].tag)}}this.profile=new ut({...n,profileCustomField:o})}validate(r){let i=!0,e="";if(oe(r))return{valid:!1,tips:"empty options"};if(r.profileCustomField){const i=r.profileCustomField.length;let t=null;for(let e=0;e<i;e++){if(t=r.profileCustomField[e],!le(t.key)||-1===t.key.indexOf("Tag_Profile_Custom"))return{valid:!1,tips:"The prefix of keys of the custom profile key-value pairs (which is profileCustomField) must be Tag_Profile_Custom"};if(!le(t.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}}for(const t in r)if(Object.prototype.hasOwnProperty.call(r,t)){if("profileCustomField"===t)continue;if(oe(r[t])&&!le(r[t])&&!ce(r[t])){e="key:"+t+", invalid value:"+r[t],i=!1;continue}switch(t){case"nick":le(r[t])||(e="nick must be a string",i=!1),500<ge(r[t])&&(e=`nick name limited: must less than or equal to 500 bytes, current size: ${ge(r[t])} bytes`,i=!1);break;case"gender":Me(se,r.gender)||(e="key:gender, invalid value:"+r.gender,i=!1);break;case"birthday":ce(r.birthday)||(e="birthday must be a number",i=!1);break;case"location":le(r.location)||(e="location must be a string",i=!1);break;case"selfSignature":le(r.selfSignature)||(e="selfSignature must be a string",i=!1);break;case"allowType":Me(re,r.allowType)||(e="key:allowType, invalid value:"+r.allowType,i=!1);break;case"language":ce(r.language)||(e="language must be a number",i=!1);break;case"avatar":le(r.avatar)||(e="avatar must be a string",i=!1);break;case"messageSettings":0!==r.messageSettings&&1!==r.messageSettings&&(e="messageSettings must be 0 or 1",i=!1);break;case"adminForbidType":Me(ie,r.adminForbidType)||(e="key:adminForbidType, invalid value:"+r.adminForbidType,i=!1);break;case"level":ce(r.level)||(e="level must be a number",i=!1);break;case"role":ce(r.role)||(e="role must be a number",i=!1);break;default:e="unknown key:"+t+" "+r[t],i=!1}}return{valid:i,tips:e}}update(r){let i="",s;const n=[];this.friendCustomField.forEach(e=>{n.push(e.key)});for(let e=0,t=r.length;e<t;e++)if(i=r[e].tag,s=r[e].value,-1<i.indexOf("Tag_SNS_Custom"))-1<n.indexOf(i)?this.friendCustomField.forEach(e=>{e.key===i&&(e.value=s)}):this.friendCustomField.push({key:i,value:s});else if(-1<i.indexOf("Tag_Profile_Custom")){let t=!1;this.profile.profileCustomField.forEach(e=>{e.key===i&&(e.value=s,t=!0)}),t||this.profile.profileCustomField.push({key:i,value:s})}else switch(i){case H:this.profile.nick=s;break;case W:this.profile.gender=s;break;case B:this.profile.birthday=s;break;case j:this.profile.location=s;break;case K:this.profile.selfSignature=s;break;case Y:this.profile.allowType=s;break;case J:this.profile.language=s;break;case V:this.profile.avatar=s;break;case z:this.profile.messageSettings=s;break;case Q:this.profile.adminForbidType=s;break;case X:this.profile.level=s;break;case Z:this.profile.role=s;break;case ee.REMARK:this.remark=s;break;case ee.ADDTIME:this.addTime=s;break;case ee.GROUP:this.groupList=JSON.parse(JSON.stringify(s));break;case ee.ADDSOURCE:this.source=s;break;case ee.ADDWORDING:break;default:we.d("snsProfileItem unkown tag->",r[e].tag)}this.timestamp=Date.now(),n.length=0}updateProfile(e){this.profile=JSON.parse(JSON.stringify(e)),this.timestamp=Date.now()}addToGroupList(e){-1===this.groupList.indexOf(e)&&(this.groupList.push(e),this.count=this.groupList.length)}removeFromGroupList(e){e=this.groupList.indexOf(e);-1<e&&(this.groupList.splice(e,1),this.count=this.groupList.length)}}const lt=4,pt=11,ht=12,ft=20,_t=23,mt=27,gt=29;class Mt{constructor(e){this._snsM=e,this._n="FriendHandler",this._friendMap=new Map,this._startIndex=0,this._standardSequence=0,this._customSequence=0,this._expirationTime=18e4}getLocalFriendList(){return[...this._friendMap.values()]}getFriendRemark(e){return this._friendMap.has(e)?this._friendMap.get(e).remark:""}onFriendProfileModified(e){const t=e["dataList"];if(!oe(t)){const i=this._snsM.get(pt);t.forEach(e=>{var{userID:t,profileList:r}=e;if(this.isMyFriend(t)){we.l(this._n+`.onFriendProfileModified. friend account:${t}, profileList:`+JSON.stringify(r));const e=this._friendMap.get(t);e.update(r),i.modifyMessageSentByPeer({conversationID:""+S+t,latestNick:e.profile.nick,latestAvatar:e.profile.avatar})}}),this._onFriendListUpdated()}}onFriendAdded(t){0!==t.length&&(we.l(this._n+".onFriendAdded userIDList:"+t),t.forEach(e=>{this._friendMap.set(e,new ct(e))}),this.getFriendProfile({userIDList:t}).then(e=>{t.forEach(e=>{var t=this._friendMap.get(e);0<t.groupList.length&&this._snsM.updateWhenFriendAdded({nameList:t.groupList,userID:e})}),this._onFriendListUpdated()}))}onFriendDeleted(e){0!==e.length&&(we.l(this._n+".onFriendDeleted userIDList:"+e),e.forEach(e=>{var t=this._friendMap.get(e);0<t.groupList.length&&this._snsM.updateWhenFriendDeleted({nameList:t.groupList,userID:e}),this._friendMap.delete(e)}),this._onFriendListUpdated())}_onFriendListUpdated(){this._snsM.emitOuterEvent(Pe),this._snsM.get(pt).checkAndPatchRemark()}getFriendProfile(e){const r=this._n+".getFriendProfile",t=e["userIDList"],s=[],n=[],i=[];if(t.forEach(e=>{var t;this._friendMap.has(e)?(t=this._friendMap.get(e),Date.now()-t.timestamp<this._expirationTime?n.push(t):i.push(e)):s.push({userID:e,code:Se,message:this._snsM.getErrorMessage(Se)})}),0===i.length)return we.i(r+" newUserIDList is empty"),xe({friendList:n,failureUserIDList:s});const o=new at("getFriendProfile");return o.setMessage("userIDList:"+i),we.i(r+" userIDList:"+i),this._snsM.req({proto:Be,data:{fromAccount:this._snsM.getMyUserID(),userIDList:i}}).then(e=>{o.end(),we.i(r+" ok");const t=e.data["resultList"];return t.forEach(t=>{var{to:t,resultCode:e,resultInfo:r,tagValueList:i}=t;if(fe(e)||0===e){let e;this._friendMap.has(t)?(e=this._friendMap.get(t)).update(i):(e=new ct(t,i),this._friendMap.set(t,e)),n.push(e)}else s.push({userID:t,code:e,message:r})}),Te({friendList:n,failureUserIDList:s})}).catch(e=>(o.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}isMyFriend(e){return this._friendMap.has(e)}pagingGetFriendList(){const a=this._n+".getFriendList",d=new at("getFriendList"),u=Date.now();this._snsM.req({proto:We,data:{fromAccount:this._snsM.getMyUserID(),startIndex:this._startIndex,standardSequence:this._standardSequence,customSequence:this._customSequence}}).then(e=>{const{friendCount:t,resultList:r,nextStartIndex:i,standardSequence:s,customSequence:n,completeFlag:o}=e.data;e=`friendCount:${t} nextStartIndex:${this._startIndex=i} standardSequence:${this._standardSequence=s} customSequence:${this._customSequence=n} completeFlag:${o} cost:`+(e=u,Date.now()-e+" ms");d.setMessage(e).end(),we.i(a+" ok.",e),oe(r)||r.forEach(e=>{var{to:e,tagValueList:t}=e;this._friendMap.set(e,new ct(e,t))}),0===o?this.pagingGetFriendList():(this._snsM.emitOuterEvent(Pe),this._pagingGetFriendProfile())}).catch(e=>(d.setError(e).end(),we.w(a+" failed. error:",e),He(e)))}_pagingGetFriendProfile(){const t=[...this._friendMap.keys()],r=this._snsM.get(lt),e=t.length,i=e<=100?1:Math.ceil(e/100);we.l(this._n+`._pagingGetFriendProfile friendCount:${e} pageCount:`+i);for(let e=0;e<i;e++)r.getUserProfile({userIDList:t.slice(100*e,100*(e+1))}).then(e=>{e.data.forEach(e=>{const t=this._friendMap.get(e.userID);t&&t.updateProfile(e)}),this._onFriendListUpdated()})}addFriend(e){const i=this._n+".addFriend";if(this._friendMap.has(e.to))return He({code:Ee});if(e.wording&&!1===this._snsM.filterProfanity("wording",e))return He({code:Ne});var{to:e,source:t,type:r,wording:s,remark:n,groupName:o}=e;let a=r;a&&(a===v||a===b)||(a=b);const d=new at("addFriend");return d.setMessage(`to:${e} source:${t} type:`+a),this._snsM.req({proto:Ye,data:{fromAccount:this._snsM.getMyUserID(),addFriendItem:[{to:e,source:t,wording:s,remark:n,groupName:o}],type:a}}).then(e=>{var e=e.data["resultList"],{to:e,resultCode:t,resultInfo:r}=(d.setMoreMessage("resultList:"+JSON.stringify(e)).end(),e[0]);return we.i(i+` ok. to:${e} type:${a} code:`+t),fe(t)||0===t?Te({userID:e,code:0}):30539===t?Te({userID:e,code:t,message:this._snsM.getErrorMessage(t)}):He({userID:e,code:t,message:this._snsM.getErrorMessage(t)||r})}).catch(e=>(d.setError(e).end(),we.w(i+" failed. error:",e),He(e)))}deleteFriend(e){const r=this._n+".deleteFriend",{userIDList:t,type:i}=e;1e3<t.length&&(we.w(r+" "+"the length of userIDList cannot exceed 1000"),t.length=1e3);const s=[],n=[],o=[];if(t.forEach(e=>{this._friendMap.has(e)?o.push(e):s.push({userID:e,code:Se,message:this._snsM.getErrorMessage(Se)})}),0===o.length)return xe({successUserIDList:n,failureUserIDList:s});let a=i;a&&(a===G||a===C)||(a=C);const d=new at("deleteFriend");return d.setMessage(`userIDList:${o} type:`+a),this._snsM.req({proto:Ke,data:{fromAccount:this._snsM.getMyUserID(),userIDList:o,type:a}}).then(e=>{d.end(),we.i(r+" ok");const t=e.data["resultList"];return oe(t)||t.forEach(e=>{var{to:e,resultCode:t,resultInfo:r}=e;fe(t)||0===t?n.push({userID:e}):s.push({userID:e,code:t,message:r})}),Te({successUserIDList:n,failureUserIDList:s})}).catch(e=>(d.setError(e).end(),we.w(r+" error:",e),He(e)))}updateFriend(e){const{userID:t,remark:i,friendCustomField:n}=e;if(!this._friendMap.has(t))return He({code:Se});const o=this._n+".updateFriend",a=new at("updateFriend"),r=(a.setMessage(`userID:${t} remark:${i} friendCustomField:`+n),[]);return fe(i)||r.push({tag:ee.REMARK,value:i}),he(n)&&0<n.length&&n.forEach(e=>{r.push({tag:e.key,value:e.value})}),this._snsM.req({proto:Je,data:{fromAccount:this._snsM.getMyUserID(),updateItem:[{to:t,snsItem:r}]}}).then(e=>{a.end(),we.i(o+" ok");var e=e.data["resultList"],{to:t,resultCode:e,resultInfo:r}=e[0];if(fe(e)||0===e){const e=this._friendMap.get(t);if(e){fe(i)||(e.remark=i);if(he(n)&&0<n.length){var s=e.friendCustomField;t=n;if(he(s)&&he(t)){let i=!1;t.forEach(({key:t,value:e})=>{const r=s.find(e=>e.key===t);r?r.value!==e&&(r.value=e,i=!0):(s.push({key:t,value:e}),i=!0)})}}this._onFriendListUpdated()}return Te(e)}return He({code:e,message:r})}).catch(e=>(a.setError(e).end(),we.w(o+" failed. error:",e),He(e)))}checkFriend(e){const r=this._n+".checkFriend",{userIDList:i,type:t}=e;let o=t;o&&(o===q||o===R)||(o=R);const a=new at("checkFriend");return a.setMessage(`userIDList:${i} type:`+o),this._snsM.req({proto:je,data:{fromAccount:this._snsM.getMyUserID(),userIDList:i,type:o}}).then(e=>{a.end(),we.i(r+` ok. userIDList:${i} type:`+o);const s=[],n=[],t=e.data["resultList"];return he(t)&&t.forEach(e=>{var{to:e,relation:t,resultCode:r,resultInfo:i}=e;fe(r)||0===r?s.push({userID:e,code:0,relation:t}):n.push({userID:e,code:r,message:i})}),Te({successUserIDList:s,failureUserIDList:n})}).catch(e=>(a.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}updateWhenAddedToFriendGroup(e){const{name:t,userIDList:r}=e;we.l(`${this._n}.updateWhenAddedToFriendGroup groupName:${t} userIDList:`+r),t&&!oe(r)&&r.forEach(e=>{this._friendMap.has(e)&&this._friendMap.get(e).addToGroupList(t)})}updateWhenRemovedFromFriendGroup(e){const{name:t,userIDList:r}=e;we.l(`${this._n}.updateWhenRemovedFromFriendGroup groupName:${t} userIDList:`+r),t&&!oe(r)&&r.forEach(e=>{this._friendMap.has(e)&&this._friendMap.get(e).removeFromGroupList(t)})}reset(){this._friendMap.clear(),this._startIndex=0,this._standardSequence=0,this._customSequence=0}}class Ft{constructor(e){oe(e)||(this.name=e.name||"",this.userIDList=e.userIDList||[],this.count=this.userIDList.length||0)}addToUserIDList(e){-1===this.userIDList.indexOf(e)&&(this.userIDList.push(e),this.count=this.userIDList.length)}removeFromUserIDList(e){e=this.userIDList.indexOf(e);-1<e&&(this.userIDList.splice(e,1),this.count=this.userIDList.length)}}class yt{constructor(e){this._snsM=e,this._n="FriendGroupHandler",this._friendGroupMap=new Map}getLocalFriendGroupList(){return[...this._friendGroupMap.values()]}_emitFriendGroupListUpdated(){var e=[...this._friendGroupMap.values()];this._snsM.emitOuterEvent(Oe,e)}getFriendGroupList(){const r=this._n+".getFriendGroupList",i=new at("getFriendGroupList");return this._snsM.req({proto:Ze,data:{fromAccount:this._snsM.getMyUserID()}}).then(e=>{i.end();const t=e.data["resultList"];oe(t)?we.i(r+" ok. friend group count:0"):(we.i(r+" ok. friend group count:"+t.length),this._friendGroupMap.clear(),t.forEach(e=>{var t=new Ft(e);this._friendGroupMap.set(e.name,t)}),this._emitFriendGroupListUpdated())}).catch(e=>(i.setError(e).end(),we.w(r+" error:",e),He(e)))}createFriendGroup(e){const r=this._n+".createFriendGroup",{name:i,userIDList:o}=e;if(this._friendGroupMap.has(i))return He({code:ke});const a=new at("createFriendGroup");return a.setMessage(`name:${i} userIDList:`+o),this._snsM.req({proto:et,data:{fromAccount:this._snsM.getMyUserID(),groupName:[i],userIDList:he(o)?o:void 0}}).then(e=>{a.end(),we.l(r+` ok. name:${i} userIDList:`+o);const t=e.data["resultList"],s=[],n=[];t&&t.forEach(e=>{const{to:t,resultCode:r,resultInfo:i}=e;if(fe(r)||0===r)s.push(t);else{const t={userID:e.to,code:r,message:i};n.push(t)}});e=new Ft({name:i,userIDList:s});return this._friendGroupMap.set(i,e),this._snsM.updateWhenAddedToFriendGroup({name:i,userIDList:s}),this._emitFriendGroupListUpdated(),Te({friendGroup:e,failureUserIDList:n})}).catch(e=>(a.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}deleteFriendGroup(e){const r=this._n+".deleteFriendGroup",i=e["name"];if(!this._friendGroupMap.has(i))return He({code:ve});const s=new at("deleteFriendGroup");return s.setMessage("name:"+i),this._snsM.req({proto:st,data:{fromAccount:this._snsM.getMyUserID(),nameList:[i]}}).then(e=>{s.end(),we.l(r+" ok. name:"+i);const t=this._friendGroupMap.get(i);return t&&(this._snsM.updateWhenRemovedFromFriendGroup({name:i,userIDList:t.userIDList}),this._friendGroupMap.delete(i),t.userIDList.length=0),this._emitFriendGroupListUpdated(),Te(t)}).catch(e=>(s.setError(e).end(),we.w(r+" failed. error:",e),He(e)))}renameFriendGroup(e){const t=this._n+".renameFriendGroup",{oldName:r,newName:i}=e;if(!this._friendGroupMap.has(r))return He({code:ve});const s=new at("renameFriendGroup");return s.setMessage(`oldName:${r} newName:`+i),this._snsM.req({proto:it,data:{fromAccount:this._snsM.getMyUserID(),oldName:r,newName:i}}).then(()=>{if(s.end(),we.l(t+` ok. oldName:${r} newName:`+i),this._friendGroupMap.has(r)){const e=this._friendGroupMap.get(r);return e.name=i,this._friendGroupMap.delete(r),this._friendGroupMap.set(i,e),this._snsM.updateWhenRemovedFromFriendGroup({name:r,userIDList:e.userIDList}),this._snsM.updateWhenAddedToFriendGroup({name:i,userIDList:e.userIDList}),this._emitFriendGroupListUpdated(),Te(e)}return Te()}).catch(e=>(s.setError(e).end(),we.w(t+" failed. error:",e),He(e)))}addToFriendGroup(e){const t=this._n+".addToFriendGroup",{name:r,userIDList:i}=e;if(!this._friendGroupMap.has(r))return this._onFriendGroupNotExist(r);const s=new at("addToFriendGroup");return s.setMessage(`name:${r} userIDList:`+i),we.l(t+` name:${r} userIDList:`+i),this._snsM.req({proto:it,data:{fromAccount:this._snsM.getMyUserID(),oldName:r,updateGroupItem:i.filter(e=>this._snsM.isMyFriend(e)).map(e=>({to:e,updateType:"Update_Type_Add"}))}}).then(e=>(s.end(),this._onFriendGroupUpdated(r,e))).catch(e=>(s.setError(e).end(),we.w(t+" failed. error:",e),He(e)))}removeFromFriendGroup(e){const t=this._n+".removeFromFriendGroup",{name:r,userIDList:i}=e;if(!this._friendGroupMap.has(r))return this._onFriendGroupNotExist(r);const s=new at("removeFromFriendGroup");return s.setMessage(`name:${r} userIDList:`+i),we.l(t+` name:${r} userIDList:`+i),this._snsM.req({proto:it,data:{fromAccount:this._snsM.getMyUserID(),oldName:r,updateGroupItem:i.filter(e=>this._snsM.isMyFriend(e)).map(e=>({to:e,updateType:"Update_Type_Delete"}))}}).then(e=>(s.end(),this._onFriendGroupUpdated(r,e))).catch(e=>(s.setError(e).end(),we.w(t+" failed. error:",e),He(e)))}_onFriendGroupUpdated(e,t){const r=t.data["resultList"],n=this._friendGroupMap.get(e),o=[],a=[],d=[];return he(r)&&r.forEach(e=>{var{to:t,resultCode:r,resultInfo:i,type:s}=e;0===r?"Update_Type_Add"===s?n&&(n.addToUserIDList(t),a.push(t)):"Update_Type_Delete"===s&&n&&(n.removeFromUserIDList(t),d.push(t)):o.push({to:e.to,code:r,message:i})}),we.l(this._n+`._onFriendGroupUpdated name:${e} userIDList:`+n.userIDList),0<a.length&&this._snsM.updateWhenAddedToFriendGroup({name:e,userIDList:a}),0<d.length&&this._snsM.updateWhenRemovedFromFriendGroup({name:e,userIDList:d}),Te({friendGroup:n,failureUserIDList:o})}updateWhenFriendAdded(e){const{nameList:t,userID:r}=e;we.l(`${this._n}.updateWhenFriendAdded userID:${r} nameList:`+t),oe(t)||t.forEach(e=>{this._friendGroupMap.has(e)&&this._friendGroupMap.get(e).addToUserIDList(r)})}updateWhenFriendDeleted(e){const{nameList:t,userID:r}=e;we.l(`${this._n}.updateWhenFriendDeleted userID:${r} nameList:`+t),oe(t)||t.forEach(e=>{this._friendGroupMap.has(e)&&this._friendGroupMap.get(e).removeFromUserIDList(r)})}reset(){this._friendGroupMap.clear()}}class At extends class{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.get(ht).isLoggedIn()}isOversea(){return this._m.get(ht).isOversea()}isPrivateNetWork(){return this._m.get(ht).isPrivateNetWork()}getFileDownloadProxy(){return this._m.get(ht).getFileDownloadProxy()}getMyUserID(){return this._m.get(ht).getUserID()}getMyTinyID(){return this._m.get(ht).getTinyID()}getSDKAppID(){return this._m.get(ht).getSDKAppID()}isIntl(){return this._m.get(ht).isIntl()}isUsingChatCore(){return this._m.get(ht).isUsingChatCore()}isDevMode(){return this._m.get(ht).isDevMode()}get(e){return this._m.get(e)}getPlatform(){return T}getCloudConfig(e){return this._m.get(_t).getCloudConfig(e)}emitOuterEvent(e,t){this._m.getOuterEmitterInstance().emit(e,t)}emitInnerEvent(e,t){this._m.getInnerEmitterInstance().emit(e,t)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(e){return this._m.get(ht).getTinyID()+"-"+e.random}req(e){return this._m.get(ft).req(e)}canIUse(e){return this._m.get(mt).canIUse(e)}getErrorMessage(e,t,r){return this._m.getErrorMessage(e,t,r)}outputWarning(e,t,r){e=this.getErrorMessage(e,t,r);e&&we.w(e)}cannotUseCommercialAbility(e){var t=Ue;return He({code:t,message:this.getErrorMessage(t,e)})}}{constructor(t){super(t),this._n="SnsModule",this._friendHandler=new Mt(this),this._friendApplicationHandler=new dt(this),this._friendGroupHandler=new yt(this),this.getInnerEmitterInstance().on(e.A2KEY_AND_TINYID_UPDATED,this.onContextUpdated,this)}onContextUpdated(e){this._friendHandler.pagingGetFriendList(),this._friendGroupHandler.getFriendGroupList(),this._friendApplicationHandler.getFriendApplicationList()}onRelationChainModified(e){const t=e["dataList"];if(!oe(t)){const s=[],n=[],o=[],a=[];let r=!1,i="";t.forEach(e=>{if(3!==e.pushType&&4!==e.pushType||!e.from||(i=e.from),e.friendAddAccount&&(s.push(...e.friendAddAccount),a.push(...e.friendAddAccount)),e.friendDelAccount&&n.push(...e.friendDelAccount),e.friendApplicationAdded&&o.push(...e.friendApplicationAdded),e.friendApplicationDeletedUserIDList&&a.push(...e.friendApplicationDeletedUserIDList),e.reportTime&&7===e.pushType&&(r=!0),e.friendUpInfo){const t={dataList:[]};e.friendUpInfo.forEach(e=>{t.dataList.push({userID:e.friendAccount,profileList:[...e.sns]})}),this.onFriendProfileModified(t)}}),r&&this._friendApplicationHandler.onFriendApplicationRead(),this._friendApplicationHandler.onFriendApplicationAdded(o,i),this._friendApplicationHandler.onFriendApplicationDeleted(a),this._friendHandler.onFriendAdded(s),this._friendHandler.onFriendDeleted(n)}}isMyFriend(e){return this._friendHandler.isMyFriend(e)}filterProfanity(e,t){const r=this.get(gt);if(!r)return!0;var{isAllowedToSend:i,modifiedText:s}=r.filterText(t[e],p);return!0===i&&(t[e]=s,!0)}onFriendProfileModified(e){this._friendHandler.onFriendProfileModified(e)}getLocalFriendList(e=!0){var t=this._friendHandler.getLocalFriendList();return e?xe(t):t}getFriendRemark(e){return this._friendHandler.getFriendRemark(e)}getFriendList(){return this._friendHandler.pagingGetFriendList()}addFriend(e){return this._friendHandler.addFriend(e)}deleteFriend(e){return this._friendHandler.deleteFriend(e)}checkFriend(e){return this._friendHandler.checkFriend(e)}getFriendProfile(e){return this._friendHandler.getFriendProfile(e)}updateFriend(e){return this._friendHandler.updateFriend(e)}updateWhenAddedToFriendGroup(e){this._friendHandler.updateWhenAddedToFriendGroup(e)}updateWhenRemovedFromFriendGroup(e){this._friendHandler.updateWhenRemovedFromFriendGroup(e)}getLocalFriendApplicationList(){var e=this._friendApplicationHandler.getLocalFriendApplicationList();return xe(e)}deleteFriendApplication(e){return this._friendApplicationHandler.deleteFriendApplication(e)}refuseFriendApplication(e){return this._friendApplicationHandler.refuseFriendApplication(e)}acceptFriendApplication(e){return this._friendApplicationHandler.acceptFriendApplication(e)}setFriendApplicationRead(e){return this._friendApplicationHandler.setFriendApplicationRead(e)}getLocalFriendGroupList(){var e=this._friendGroupHandler.getLocalFriendGroupList();return xe(e)}createFriendGroup(e){return this._friendGroupHandler.createFriendGroup(e)}deleteFriendGroup(e){return this._friendGroupHandler.deleteFriendGroup(e)}addToFriendGroup(e){return this._friendGroupHandler.addToFriendGroup(e)}removeFromFriendGroup(e){return this._friendGroupHandler.removeFromFriendGroup(e)}renameFriendGroup(e){return this._friendGroupHandler.renameFriendGroup(e)}onAddToFriendGroup(e){return this._friendGroupHandler.onAddToFriendGroup(e)}updateWhenFriendAdded(e){this._friendGroupHandler.updateWhenFriendAdded(e)}updateWhenFriendDeleted(e){this._friendGroupHandler.updateWhenFriendDeleted(e)}reset(){we.l(this._n+".reset"),this._friendHandler.reset(),this._friendGroupHandler.reset(),this._friendApplicationHandler.reset()}}export{At as default};

@@ -1,1 +0,1 @@

"use strict";var t=function(t){return s=t={exports:{}},a=Object.prototype.hasOwnProperty,_="~",Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(_=!1)),e.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)a.call(t,e)&&i.push(_?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},e.prototype.listeners=function(t){var t=_?_+t:t,e=this._events[t];if(!e)return[];if(e.fn)return[e.fn];for(var i=0,n=e.length,s=new Array(n);i<n;i++)s[i]=e[i].fn;return s},e.prototype.listenerCount=function(t){t=_?_+t:t,t=this._events[t];return t?t.fn?1:t.length:0},e.prototype.emit=function(t,e,i,n,l,c){var h=_?_+t:t;if(!this._events[h])return!1;var s,o=this._events[h],a=arguments.length;if(o.fn){switch(o.once&&this.removeListener(t,o.fn,void 0,!0),a){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,e),!0;case 3:return o.fn.call(o.context,e,i),!0;case 4:return o.fn.call(o.context,e,i,n),!0;case 5:return o.fn.call(o.context,e,i,n,l),!0;case 6:return o.fn.call(o.context,e,i,n,l,c),!0}for(g=1,s=new Array(a-1);g<a;g++)s[g-1]=arguments[g];o.fn.apply(o.context,s)}else for(var r,u=o.length,g=0;g<u;g++)switch(o[g].once&&this.removeListener(t,o[g].fn,void 0,!0),a){case 1:o[g].fn.call(o[g].context);break;case 2:o[g].fn.call(o[g].context,e);break;case 3:o[g].fn.call(o[g].context,e,i);break;case 4:o[g].fn.call(o[g].context,e,i,n);break;default:if(!s)for(r=1,s=new Array(a-1);r<a;r++)s[r-1]=arguments[r];o[g].fn.apply(o[g].context,s)}return!0},e.prototype.on=function(t,e,i){return n(this,t,e,i,!1)},e.prototype.once=function(t,e,i){return n(this,t,e,i,!0)},e.prototype.removeListener=function(t,e,i,n){t=_?_+t:t;if(!this._events[t])return this;if(!e)return g(this,t),this;var s=this._events[t];if(s.fn)s.fn!==e||n&&!s.once||i&&s.context!==i||g(this,t);else{for(var o=0,a=[],r=s.length;o<r;o++)(s[o].fn!==e||n&&!s[o].once||i&&s[o].context!==i)&&a.push(s[o]);a.length?this._events[t]=1===a.length?a[0]:a:g(this,t)}return this},e.prototype.removeAllListeners=function(t){return t?(t=_?_+t:t,this._events[t]&&g(this,t)):(this._events=new i,this._eventsCount=0),this},e.prototype.off=e.prototype.removeListener,e.prototype.addListener=e.prototype.on,e.prefixed=_,s.exports=e.EventEmitter=e,t.exports;function i(){}function o(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function n(t,e,i,n,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");i=new o(i,n||t,s),n=_?_+e:e;return t._events[n]?t._events[n].fn?t._events[n]=[t._events[n],i]:t._events[n].push(i):(t._events[n]=i,t._eventsCount++),t}function g(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function e(){this._events=new i,this._eventsCount=0}var s,a,_}();const e=2,n=11,i=12,s=20,o=23,r=27;class a{constructor(t=0,e=0){this.high=t,this.low=e}equal(t){return null!==t&&this.low===t.low&&this.high===t.high}toString(){var t=Number(this.high).toString(16);let e=Number(this.low).toString(16);if(e.length<8){let t=8-e.length;for(;t;)e="0"+e,t--}return t+e}}const c={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},g={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15},l="CHINA",h={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(t=l){this.CURRENT=c.PRODUCTION[t]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report"}},u=(new a(0,Math.pow(2,0)).toString(),new a(0,Math.pow(2,1)).toString(),new a(0,Math.pow(2,2)).toString(),new a(0,Math.pow(2,3)).toString(),new a(0,Math.pow(2,4)).toString(),new a(0,Math.pow(2,6)).toString(),new a(0,Math.pow(2,7)).toString(),new a(0,Math.pow(2,9)).toString(),new a(0,Math.pow(2,10)).toString(),new a(0,Math.pow(2,11)).toString(),new a(0,Math.pow(2,13)).toString(),new a(0,Math.pow(2,15)).toString(),new a(Math.pow(2,6)).toString(),new a(Math.pow(2,7)).toString(),new a(Math.pow(2,8)).toString(),new a(Math.pow(2,9)).toString(),new a(Math.pow(2,10)).toString(),new a(Math.pow(2,16)).toString(),h.HOST.setCurrent(l),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),_=(u&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),d="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),m="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),I="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,v="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,p=u||_||d||m||I||v||f,D=("undefined"!=typeof uni||"undefined"!=typeof window)&&!p,S=(_?qq:d?tt:m?swan:I?my:u?wx:v?uni:f&&jd,D&&window&&window.navigator&&window.navigator.userAgent||""),y=/(micromessenger|webbrowser)/i.test(S),M=/AppleWebKit\/([\d.]+)/i.exec(S),w=(M&&parseFloat(M.pop()),function(){let t="WEB";return y?t="WEB":_?t="QQ_MP":d?t="TT_MP":m?t="BAIDU_MP":I?t="ALI_MP":u?t="WX_MP":v&&(t="UNI_NATIVE_APP"),g[t]}()),C=(!function(){var t=S.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),function(){var t,e,i=S.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);i&&(t=i[1]&&parseFloat(i[1]),e=i[2]&&parseFloat(i[2]),t&&e&&parseFloat(i[1]+"."+i[2]))}(),function(){var t=S.match(/Chrome\/(\d+)/);t&&t[1]&&parseFloat(t[1])}(),/MSIE/.test(S)||-1<S.indexOf("Trident")&&-1<S.indexOf("rv:11.0"));let T,E;!function(){var t=/MSIE\s(\d+)\.\d/.exec(S),t=t&&parseFloat(t[1]);!t&&/Trident\/7.0/i.test(S)&&/rv:11.0/.test(S)}(),function(){var t=S.match(/TBS\/(\d+)/i);t&&t[1]&&t[1]}(),T="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const L=function(){},A=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let N=A.length;for(;N--;)E=A[N],console[E]||(T[E]=L);var O=T;const $="TIMCustomElem",P="High",U="C2C",R="GROUP",H="@TIM#SYSTEM",x=function(){const t=new Date;return t.setTime((new Date).getTime()+0),t},b=Object.prototype.hasOwnProperty;function F(t){if(null==t)return!0;if("boolean"==typeof t)return!1;if("number"==typeof t)return 0===t;if("string"==typeof t)return 0===t.length;if("function"==typeof t)return 0===t.length;if(Array.isArray(t))return 0===t.length;if(t instanceof Error)return""===t.message;if(B(t)){for(const e in t)if(b.call(t,e))return!1;return!0}return!!(q(t)||j(t)||G(t))&&0===t.size}const q=function(t){return"map"===K(t)},j=function(t){return"set"===K(t)},G=function(t){return"file"===K(t)},B=function(t){if("object"!=typeof t||null===t)return!1;t=Object.getPrototypeOf(t);if(null===t)return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return t===e},k=function(t){return void 0===t},J=function(t){return e=t,("function"==typeof Array.isArray?Array.isArray(e):"array"===K(e))||null!==t&&"object"==typeof t;var e},K=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()};function Y(){return!C&&!p}Date.now||(Date.now=function(){return(new Date).getTime()});let V=0;function W(){return Y()?"%c Chat %c":"Chat"}function z(){const t=x();return t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(t){let e;switch(t.toString().length){case 1:e="00"+t;break;case 2:e="0"+t;break;default:e=t}return e}(t.getMilliseconds())}const X={arguments2String(i){let n="";if(1===i.length)n=i[0];else for(let t=0,e=i.length;t<e;t++)J(i[t])?i[t]instanceof Error?n+=(s=i[t],JSON.stringify(s,["message","code"])):n+=JSON.stringify(i[t]):n+=i[t],n+=" ";var s;return n},_exec(t,e){Y()?O[t](W(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",z(),e):O[t](`${W()} ${z()} `+e)},d:function(){var t;V<=-1&&(t=this.arguments2String(arguments),this._exec("debug",t))},l:function(){var t;V<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},log:function(){var t;V<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},i:function(){var t;V<=1&&(t=this.arguments2String(arguments),this._exec("info",t))},w:function(){var t;V<=2&&(t=this.arguments2String(arguments),this._exec("warn",t))},e:function(){var t;V<=3&&(t=this.arguments2String(arguments),this._exec("error",t))},setLevel:function(t){t<4&&this._exec("log","set level from "+V+" to "+t),V=t},getLevel:function(){return V}};class Q extends Error{constructor(t){super();var{code:t,message:e,data:i}=t;this.code=t,this.message=e||this._getErrorMessage(this.code),this.data=i||{}}}const Z=2903,et=3122,nt=8010,it=8011,st=8020,ot="error";let rt=null;const at=function(t,e=!1){if(t instanceof Q)return e&&null!==rt&&rt.emit(ot,t),Promise.reject(t);if(t instanceof Error){const t=new Q({code:Z});return e&&null!==rt&&rt.emit(ot,t),Promise.reject(t)}if(k(t)||k(t.code))return Promise.reject(new Q({code:Z}));t=new Q(t);return e&&null!==rt&&rt.emit(ot,t),Promise.reject(t)},ct="newInvitationReceived",gt="ts_invitee_accepted",lt="ts_invitee_rejected",ht="ts_invitation_cancelled",ut="ts_invitation_timeout",_t="ts_invitation_modified",dt=1,mt=2,It=3,ft=4,vt=5;class pt{constructor(t){this._n="RemoteSignalingHandler",this._sigM=t}onNewMessageList(t){const e=this._sigM.filterMessageList(t);0<e.length&&e.forEach(t=>{var e=this.getPayloadData(t);e&&this._handleActionType(e,t)})}onMessageModified(t){const e=this._sigM.filterMessageList(t);0<e.length&&e.forEach(t=>{var e=this.getPayloadData(t);e&&this._onInvitationModified(e,t)})}getPayloadData(e){var i=this._n+".getPayloadData",e=e.payload["data"];try{return JSON.parse(e)}catch(t){return X.e(i+" JSON parse error. signalingData:"+e),null}}_handleActionType(t,e){var i=t["actionType"];switch(i){case dt:this._onNewInvitationReceived(t,e);break;case ft:this._onInviteeRejected(t);break;case It:this._onInviteeAccepted(t);break;case mt:this._onInvitationCancelled(t);break;case vt:this._onInvitationTimeout(t)}}_createDefaultEmitData(t){var{inviteID:t,inviter:e,groupID:i,data:n}=t;return{inviteID:t,inviter:e,groupID:i,data:n||""}}_onNewInvitationReceived(t,e){const i=this._n+"._onNewInvitationReceived",{inviteID:n,inviteeList:s,groupID:o,inviter:c}=t,a=this._sigM.getMyUserID(),r=s.includes(a);let g=t.timeout;var l=(x().getTime()-1e3*e.time)/1e3,h=(0<g&&0<l&&g>l&&(g-=l),i+` myselfIncluded:${r} groupID:${o} signalObj:`+JSON.stringify(t));if(X.l(h+` timeout:${g}s delta:${l}s`),o&&r||!o){const i=this._sigM.getInviteInfo(n);i&&i===t||(i||this._sigM.setInviteInfo(n,{...t,message:e}),this._sigM.emitEvent(ct,{...this._createDefaultEmitData(t),inviteeList:s}),c!==a&&this._sigM.startTimer({...t,timeout:g}))}}_onInviteeRejected(t){var e=this._n+"._onInviteeRejected",{inviteID:i,inviter:n,groupID:s}=t,o=this._sigM.hasInviteInfo(i);X.l(e+` inviteID:${i} hasInviteID:${o} inviter:${n} groupID:`+s),(s&&o||!s)&&(this._sigM.updateInviteInfo(t),this._sigM.emitEvent(lt,{...this._createDefaultEmitData(t),invitee:t.inviteeList[0]}))}_onInviteeAccepted(t){var e=this._n+"._onInviteeAccepted",{inviteID:i,inviter:n,groupID:s}=t,o=this._sigM.hasInviteInfo(i);X.l(e+` inviteID:${i} hasInviteID:${o} inviter:${n} groupID:`+s),(s&&o||!s)&&(this._sigM.updateInviteInfo(t),this._sigM.emitEvent(gt,{...this._createDefaultEmitData(t),invitee:t.inviteeList[0]}))}_onInvitationCancelled(t){var e=this._n+"._onInvitationCancelled",{inviteID:i,inviter:n,groupID:s}=t,o=this._sigM.hasInviteInfo(i);X.l(e+` inviteID:${i} hasInviteID:${o} inviter:${n} groupID:`+s),(s&&o||!s)&&(this._sigM.deleteInviteInfo(i),this._sigM.emitEvent(ht,this._createDefaultEmitData(t)))}_onInvitationTimeout(t){var e=this._n+"._onInvitationTimeout",{inviteID:i,inviter:n,groupID:s,inviteeList:o}=t,a=this._sigM.hasInviteInfo(i);X.l(e+` inviteID:${i} hasInviteID:${a} inviter:${n} groupID:${s} data:`+t.data),(s&&a||!s)&&(this._sigM.updateInviteInfo(t),this._sigM.emitEvent(ut,{...this._createDefaultEmitData(t),inviteeList:o,isSelfTimeout:!1}))}_onInvitationModified(t,e){var i=this._n+"._onInvitationModified",{inviteID:n,data:s}=t;X.l(i+` inviteID:${n} data:`+s),this._sigM.setInviteInfo(n,{...t,message:e}),this._sigM.emitEvent(_t,{inviteID:n,data:s})}}const Dt=function(t){if(t<0||53<t)return NaN;var e=0|1073741824*Math.random();return 30<t?e+1073741824*(0|Math.random()*(1<<t-30)):e>>>30-t},St=function(t,e){let i=t.toString(16),n=e-i.length,s="0";for(;0<n;n>>>=1,s+=s)1&n&&(i=s+i);return i};class yt{constructor(t){this._n="LocalSignalingHandler",this._sigM=t}generateInviteID(){var t=function(){const t=Dt,e=St;return e(t(32),8)+"-"+e(t(16),4)+"-"+e(16384|t(12),4)+"-"+e(32768|t(14),4)+"-"+e(t(48),12)}();return X.l(this._n+".generateInviteID inviteID:"+t),t}createInviteInfo(t){var e=this.generateInviteID(),t=this.createInviteCustomData({...t,inviteID:e}),{groupID:i,inviteeList:n}=t,i=i||n[0];return{customData:t,message:this.createSignalingMessage(t,i),inviteID:e}}_createDefaultCustomData(t){var{data:t="",inviteID:e="",groupID:i=""}=t;return{businessID:1,timeout:0,data:t,inviteID:e,groupID:i}}createInviteCustomData(t){var{userID:e,timeout:i=0,groupID:n=""}=t,s=this._sigM.getMyUserID(),s={...this._createDefaultCustomData(t),actionType:dt,inviter:s,inviteeList:n?t.inviteeList:[e],timeout:i};return X.l(this._n+".createInviteCustomData customData:"+JSON.stringify(s)),s}createCancelCustomData(t){var e=this._n+".createCancelCustomData",i=t["inviteID"];let n;var s=this._sigM.getMyUserID(),{inviteeList:i,groupID:o,inviter:a}=this._sigM.getInviteInfo(i);return a===s?n={...this._createDefaultCustomData(t),actionType:mt,groupID:o,inviter:s,inviteeList:i}:X.e(e+` unmatched inviter:${a} and my userID:`+s),X.l(e+" customData:"+JSON.stringify(n)),n}createAcceptCustomData(t){var e=this._n+".createAcceptCustomData",i=t["inviteID"];let n;const s=this._sigM.getMyUserID(),{inviter:o,groupID:a,inviteeList:r}=this._sigM.getInviteInfo(i);return r.includes(s)?n={...this._createDefaultCustomData(t),actionType:It,groupID:a,inviter:o,inviteeList:[s]}:X.e(e+` userID:${s} not in inviteeList. inviteID:${i} groupID:`+a),X.l(e+" customData:"+JSON.stringify(n)),n}createRejectCustomData(t){var e=this._n+".createRejectCustomData",i=t["inviteID"];let n;const s=this._sigM.getMyUserID(),{inviter:o,groupID:a,inviteeList:r}=this._sigM.getInviteInfo(i);return r.includes(s)?n={...this._createDefaultCustomData(t),actionType:ft,groupID:a,inviter:o,inviteeList:[s]}:X.e(e+` userID:${s} not in inviteeList. inviteID:${i} groupID:`+a),X.l(e+" customData:"+JSON.stringify(n)),n}createTimeoutCustomData(t){var e=this._n+".createTimeoutCustomData",{inviteeList:i,inviter:n,isInviter:s=!1}=t,o=this._sigM.getMyUserID(),t={...this._createDefaultCustomData(t),actionType:vt,inviter:n,inviteeList:s?i:[o]};return X.l(e+" customData:"+JSON.stringify(t)),t}createSignalingMessage(t,i){const{groupID:n,inviter:s}=t,o=this._sigM.get(e),a={to:i||n||s,conversationType:n?R:U,priority:P,payload:{data:JSON.stringify(t)}},r=o.createCustomMessage(a);return X.d(this._n+".createSignalingMessage. message:"+JSON.stringify(r)),r}}class Mt{constructor(t){this._n="HistorySignalingHandler",this._sigM=t,this.EXPIRED_TIME=3e4,this.COUNT=20,this._signalingMap=new Map,this._signalingRelatedToMeMap=new Map}getHistorySignaling(){var t=this._sigM.get(n).getLocalConversationList();F(t)||this._getSignalingList(t).then(t=>{this._handleSignalingList(t)})}_getSignalingList(t){t=this._getValidConversationList(t),t=this._createPromiseList(t);return F(t)?Promise.resolve([]):this._concurrentGetMessageList(t).then(t=>{let e=new Map;return t.forEach(t=>{t=t.signalingList,t=this._getSignalingRelatedToMeMap(t);e=new Map([...e,...t])}),this._sortSignaling(e)})}_handleSignalingList(t){F(t)||(X.d(this._n+"._handleSignalingList signalingList:"+JSON.stringify(t)),this._sigM.onNewMessageList(t))}_isSignalingNotExpired(t,e){return t[e]&&1e3*t[e]>(new Date).getTime()-this.EXPIRED_TIME}_getValidConversationList(e){const i=[];for(let t=0;t<e.length;t++){var{type:n,unreadCount:s,lastMessage:o}=e[t],o=this._isSignalingNotExpired(o,"lastTime");n!==H&&0<s&&o&&i.push(e[t])}return i}_createPromiseList(e){const i=[];for(let t=0;t<e.length;t++){var{conversationID:s,unreadCount:o,type:a}=e[t],a=a===U?o:this.COUNT,o=(this._signalingMap.set(s,{needMessageCount:a,signalingList:[]}),this._sigM.get(n).getMessageList({conversationID:s}));i.push(o)}return i}_concurrentGetMessageList(t){const s=[];return Promise.all(t).then(e=>{for(let t=0;t<e.length;t++){var{code:i,data:n}=e[t];0===i&&0!==n.messageList.length&&(this._handleMessageList(n.messageList),(i=this._relayGetMessageList(n))&&s.push(i))}return 0<s.length?this._concurrentGetMessageList(s):this._signalingMap})}_relayGetMessageList(t){var{messageList:t,nextReqMessageID:e,isCompleted:i}=t,s=t.length;if(0===s)return null;var{conversationID:o,conversationType:a}=t[0],r=this._signalingMap.get(o)["needMessageCount"],a=a===R,i=0===r||i,t=this._isSignalingNotExpired(t[s-1],"time");return a||i||!t?null:this._sigM.get(n).getMessageList({conversationID:o,nextReqMessageID:e,count:r})}_handleMessageList(e){const i=e.length,t=e[0]["conversationID"],{needMessageCount:n,signalingList:s}=this._signalingMap.get(t),o=0<n-i?n-i:0,a=[];for(let t=0;t<e.length;t++){const i=e[t];this._isSignalingNotExpired(i,"time")&&a.push(i)}var r=this._sigM.filterMessageList(a);this._signalingMap.set(t,{needMessageCount:o,signalingList:s.concat(r)})}_getSignalingRelatedToMeMap(e){for(let t=0;t<e.length;t++){var i=e[t];this._saveSignalingRelatedToMe(i)}return this._signalingRelatedToMeMap}_saveSignalingRelatedToMe(t){const e=this._sigM.getRemoteSignalingHandler().getPayloadData(t)||{},{actionType:i="",inviteID:n="",inviteeList:s=[]}=e,o=this._sigM.getMyUserID();switch(i){case dt:s.includes(o)&&this._signalingRelatedToMeMap.set(n,{...e,messageList:[t]});break;case ft:case It:this.updateHistoryInviteInfo(t);break;case mt:this.deleteHistoryInviteInfo(n);break;case vt:this.updateHistoryInviteInfo(t)}}deleteHistoryInviteInfo(t){this._signalingRelatedToMeMap.has(t)&&this._signalingRelatedToMeMap.delete(t)}updateHistoryInviteInfo(t){const e=this._sigM.getRemoteSignalingHandler().getPayloadData(t)||{},{inviteID:i="",inviteeList:n=[]}=e;if(this._signalingRelatedToMeMap.has(i)){const{inviteeList:e,messageList:s}=this._signalingRelatedToMeMap.get(i);for(let t=0;t<n.length;t++){const i=n[t];e.includes(i)&&e.splice(e.indexOf(i),1)}0===e.length?this.deleteHistoryInviteInfo(i):s.push(t)}else this.deleteHistoryInviteInfo(i)}_sortSignaling(t){let e=[];return t.forEach(t=>{e=[...e,...t.messageList]}),e.sort(function(t,e){return(t.time||0)-(e.time||0)})}reset(){this._signalingMap.clear(),this._signalingRelatedToMeMap.clear()}}class wt{constructor(t,e){this.businessID=t.businessID||1,this.inviteID=t.inviteID,this.groupID=t.groupID||"",this.inviter=t.inviter||"",this.inviteeList=t.inviteeList||[],this.data=t.data||"",this.actionType=t.actionType||dt,this.timeout=t.timeout||0}}const Ct={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};class Tt extends class{constructor(t){this._m=t,this._n=""}isLoggedIn(){return this._m.get(i).isLoggedIn()}isOversea(){return this._m.get(i).isOversea()}isPrivateNetWork(){return this._m.get(i).isPrivateNetWork()}getFileDownloadProxy(){return this._m.get(i).getFileDownloadProxy()}getMyUserID(){return this._m.get(i).getUserID()}getMyTinyID(){return this._m.get(i).getTinyID()}getSDKAppID(){return this._m.get(i).getSDKAppID()}isIntl(){return this._m.get(i).isIntl()}isUsingChatCore(){return this._m.get(i).isUsingChatCore()}isDevMode(){return this._m.get(i).isDevMode()}get(t){return this._m.get(t)}getPlatform(){return w}getCloudConfig(t){return this._m.get(o).getCloudConfig(t)}emitOuterEvent(t,e){this._m.getOuterEmitterInstance().emit(t,e)}emitInnerEvent(t,e){this._m.getInnerEmitterInstance().emit(t,e)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(t){return this._m.get(i).getTinyID()+"-"+t.random}req(t){return this._m.get(s).req(t)}canIUse(t){return this._m.get(r).canIUse(t)}getErrorMessage(t,e,i){return this._m.getErrorMessage(t,e,i)}outputWarning(t,e,i){t=this.getErrorMessage(t,e,i);t&&X.w(t)}cannotUseCommercialAbility(t){var e=et;return at({code:e,message:this.getErrorMessage(e,t)})}}{constructor(e){super(e),this._n="SignalingModule",this._inviteInfoMap=new Map,this._outerEmitter=new t,this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(...t){t=[t[0],{name:t[0],data:t[1]}];this._outerEmitter._emit.apply(this._outerEmitter,[...t])}.bind(this),this._canIUseSignaling=!1,this._isHandling=!1,this._remoteSignalingHandler=new pt(this),this._localSignalingHandler=new yt(this),this._historySignalingHandler=new Mt(this),this._isC2CUnreadHandleCompleted=!1,this._isConvSyncCompleted=!1,this._isSyncCompleted=!1,this.getInnerEmitterInstance().on(Ct.C2C_UNREAD_HANDLE_COMPLETED,this.onC2CUnreadHandleCompleted,this),this.getInnerEmitterInstance().on(Ct.CONV_SYNC_COMPLETED,this.onConvSyncCompleted,this)}onC2CUnreadHandleCompleted(){this._isC2CUnreadHandleCompleted=!0,this._isC2CUnreadHandleCompleted&&this._isConvSyncCompleted&&!this._isSyncCompleted&&this.onReady()}onConvSyncCompleted(){this._isConvSyncCompleted=!0,this._isC2CUnreadHandleCompleted&&this._isConvSyncCompleted&&!this._isSyncCompleted&&this.onReady()}onReady(){X.l(this._n+".onReady"),this._isSyncCompleted=!0,this._historySignalingHandler.getHistorySignaling()}onNewMessageList(t){return this._remoteSignalingHandler.onNewMessageList(t)}onMessageModified(t){return this._remoteSignalingHandler.onMessageModified(t)}hasInviteInfo(t){return this._inviteInfoMap.has(t)}getInviteInfo(t){return this._inviteInfoMap.get(t)}setInviteInfo(t,e){const{message:i,...n}=e;X.l(this._n+`.setInviteInfo inviteID:${t} data:`+JSON.stringify(n)),this._inviteInfoMap.set(t,{...n,message:i})}deleteInviteInfo(t){this.hasInviteInfo(t)&&(X.l(this._n+`.deleteInviteInfo inviteID:${t}.`),this._inviteInfoMap.delete(t))}updateInviteInfo(t){const e=this._n+".updateInviteInfo",{inviteID:i,inviter:n,inviteeList:s,groupID:o}=t;if(X.l(e+` inviteID:${i} inviter:${n} groupID:`+o),o&&this.hasInviteInfo(i)){const t=s[0],n=this.getInviteInfo(i)["inviteeList"];n.includes(t)&&(n.splice(n.indexOf(t),1),X.l(e+` remove ${t}. localInviteeList.length:`+n.length)),0===n.length&&this.deleteInviteInfo(i)}else this.deleteInviteInfo(i)}getLocalSignalingHandler(){return this._localSignalingHandler}getRemoteSignalingHandler(){return this._remoteSignalingHandler}canIUseSignaling(){return this._canIUseSignaling}emitEvent(t,e){this._outerEmitter.emit(t,e)}addSignalingListener(t,e,i){this._canIUseSignaling||(this._canIUseSignaling=!0),this._outerEmitter.on(t,e,i)}removeSignalingListener(t,e,i){this._outerEmitter.off(t,e,i),0===this._outerEmitter.eventNames().length&&(this._canIUseSignaling=!1)}invite(t){const e=this._n+".invite",{message:i,customData:n,inviteID:s}=this._localSignalingHandler.createInviteInfo(t);return X.l(e+` options:${JSON.stringify(t)} inviteID:`+s),this.sendSignaling(i,t).then(t=>t&&0===t.code?(this.setInviteInfo(s,{...n,message:i}),this.startTimer({...n,inviteID:s}),{...t,inviteID:s}):t).catch(t=>at(t))}inviteSync(t,e,i){const n=this._n+".inviteSync",{message:s,customData:o,inviteID:a}=this._localSignalingHandler.createInviteInfo(t);return X.l(n+` options:${JSON.stringify(t)} inviteID:`+a),this.sendSignaling(s,t).then(t=>{if(t&&0===t.code)return this.setInviteInfo(a,{...o,message:s}),this.startTimer({...o,inviteID:a}),e&&e({inviteID:a}),{inviteID:a};i&&i(0===t.code,t.message||"")}).catch(t=>(i&&i(t.code,t.message),at(t))),a}_handleImResponse(t,e,i){e&&0===e.code&&(this._isHandling=!1,i?this.deleteInviteInfo(t.inviteID):this.updateInviteInfo(t))}cancel(e){var t=this._n+".cancel";if(X.l(t+" options:"+JSON.stringify(e)),!this.hasInviteInfo(e.inviteID)||this._isHandling)return at({code:st});this._isHandling=!0;const i=this._localSignalingHandler.createCancelCustomData(e);if(!i)return this._isHandling=!1,at({code:it});var{groupID:t,inviteeList:n}=i,t=t||n[0],n=this._localSignalingHandler.createSignalingMessage(i,t);return this.sendSignaling(n,e).then(t=>(this._handleImResponse(i,t,!0),0===t.code?{...t,inviteID:e.inviteID}:t)).catch(t=>at(t))}accept(e){var t=this._n+".accept";if(X.l(t+" options:"+JSON.stringify(e)),!this.hasInviteInfo(e.inviteID)||this._isHandling)return at({code:nt});this._isHandling=!0;const i=this._localSignalingHandler.createAcceptCustomData(e);if(!i)return this._isHandling=!1,at({code:it});t=this._localSignalingHandler.createSignalingMessage(i);return this.sendSignaling(t,e).then(t=>(this._handleImResponse(i,t),0===t.code?{...t,inviteID:e.inviteID}:t)).catch(t=>at(t))}reject(e){var t=this._n+".reject";if(X.l(t+" options:"+JSON.stringify(e)),!this.hasInviteInfo(e.inviteID)||this._isHandling)return at({code:nt});this._isHandling=!0;const i=this._localSignalingHandler.createRejectCustomData(e);if(!i)return this._isHandling=!1,at({code:it});t=this._localSignalingHandler.createSignalingMessage(i);return this.sendSignaling(t,e).then(t=>(this._handleImResponse(i,t,!0),0===t.code?{...t,inviteID:e.inviteID}:t)).catch(t=>at(t))}getSignalingInfo(t){const e=this._n+".getSignalingInfo",{ID:i,from:n,to:s}=t,o=this._filterSignalingMessage(t);let a=null;if(o){const e=this._remoteSignalingHandler.getPayloadData(t);a=new wt(e)}t=o?"actionType:"+a.actionType:"";return X.l(e+` messageID:${i} from:${n} to:${s} ${t} isSignaling:`+o),a}modifyInvitation(t){const{inviteID:i,data:n}=t;if(!this.hasInviteInfo(t.inviteID)||this._isHandling)return at({code:nt});this._isHandling=!0;const{message:s,...o}=this.getInviteInfo(i),a=s.payload.data;return o.data=n,s.payload.data=JSON.stringify(o),this.get(e).modifyRemoteMessage(s).then(t=>(this.setInviteInfo(i,{...o,message:s}),this._isHandling=!1,t)).catch(t=>(this._isHandling=!1,s.payload.data=a,at(t)))}_genMessageControlInfo(t={}){const{data:e="",onlineUserOnly:i,inviteID:n="",offlinePushInfo:s,actionType:o}=t;let a={_onlineOnlyFlag:!1};const r={onlineUserOnly:(a=n&&this.getInviteInfo(n)?this.getInviteInfo(n).message:a)._onlineOnlyFlag||i||!1,offlinePushInfo:s,messageControlInfo:{excludedFromContentModeration:!0,excludedFromUnreadCount:!1,excludedFromLastMessage:!1}};if(o===vt){const t=!!e.match(/excludeTimeoutSignalingFromHistoryMessage/);return r.messageControlInfo.excludedFromUnreadCount=t,r.messageControlInfo.excludedFromLastMessage=t,r}var t=!!e.match(/excludeFromHistoryMessage/),g=!!e.match(/excludeOriginalSignalingFromHistoryMessage/);return r.messageControlInfo.excludedFromUnreadCount=t||g,r.messageControlInfo.excludedFromLastMessage=t||g,r}sendSignaling(t,i){return this.get(e).sendMessageInstance(t,this._genMessageControlInfo(i)).catch(t=>(this._isHandling=!1,at(t)))}filterMessageList(t){return t.filter(t=>this._filterSignalingMessage(t))}_filterSignalingMessage(t){let e=!1;if(t.type&&t.type===$){const{cloudCustomData:i="",payload:{data:n=""}}=t,s=i.match(/"type":"tsignaling"/),o=n.match(/inviteID/),a=n.match(/actionType/);e=s||o&&a}return!!e}startTimer(i){const n=this._n+".startTimer",{timeout:t,inviteID:s,inviter:e,groupID:o}=i,a=e===this.getMyUserID();if(X.l(n+` timeout:${t} isInviter:${a} groupID:`+o),!(t<=0)){const r=a?t+5:t;let e=1;const g=setInterval(()=>{var t=this._hasLocalInviteInfo(i,a);e<r&&t?++e:(t&&this._sendTimeoutNotice(s,a),X.l(n+" end."),clearInterval(g))},1e3)}}_hasLocalInviteInfo(t,e){var{inviteID:t,groupID:i}=t;if(!this.hasInviteInfo(t))return!1;const n=this._n+"._hasLocalInviteInfo",s=this.getInviteInfo(t)["inviteeList"];return X.l(n+` inviteID:${t} inviteeList:${s} groupID:`+i),!i||(e?0<s.length:0<s.length&&s.includes(this.getMyUserID()))}_getReceiver(t,e){var{groupID:e,inviteeList:i,inviter:n}=e;return t?e||i[0]:e||n}_sendTimeoutNotice(s,o){var t=this.getInviteInfo(s),e=this._getReceiver(o,t);X.l(this._n+`._sendTimeoutNotice inviteID:${s} to:${e} isInviter:`+o);const a=this._localSignalingHandler.createTimeoutCustomData({...t,isInviter:o}),r=this._localSignalingHandler.createSignalingMessage(a,e);return this.sendSignaling(r,a).then(t=>{if(t&&0===t.code){const{data:t,groupID:e,inviteeList:i,inviter:n}=a;this.emitEvent(ut,{data:t,groupID:e,inviteID:s,inviteeList:i,inviter:n,isSelfTimeout:!0,message:r}),o?this.deleteInviteInfo(s):this.updateInviteInfo(a)}})}reset(){X.l(this._n+".reset"),this._inviteInfoMap.clear(),this._canIUseSignaling=!1,this._isHandling=!1,this._historySignalingHandler.reset(),this._isC2CUnreadHandleCompleted=!1,this._isConvSyncCompleted=!1,this._isSyncCompleted=!1}}export{Tt as default};
"use strict";var t=function(t){return s=t={exports:{}},a=Object.prototype.hasOwnProperty,_="~",Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(_=!1)),e.prototype.eventNames=function(){var t,e,i=[];if(0===this._eventsCount)return i;for(e in t=this._events)a.call(t,e)&&i.push(_?e.slice(1):e);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(t)):i},e.prototype.listeners=function(t){var t=_?_+t:t,e=this._events[t];if(!e)return[];if(e.fn)return[e.fn];for(var i=0,n=e.length,s=new Array(n);i<n;i++)s[i]=e[i].fn;return s},e.prototype.listenerCount=function(t){t=_?_+t:t,t=this._events[t];return t?t.fn?1:t.length:0},e.prototype.emit=function(t,e,i,n,l,c){var h=_?_+t:t;if(!this._events[h])return!1;var s,o=this._events[h],a=arguments.length;if(o.fn){switch(o.once&&this.removeListener(t,o.fn,void 0,!0),a){case 1:return o.fn.call(o.context),!0;case 2:return o.fn.call(o.context,e),!0;case 3:return o.fn.call(o.context,e,i),!0;case 4:return o.fn.call(o.context,e,i,n),!0;case 5:return o.fn.call(o.context,e,i,n,l),!0;case 6:return o.fn.call(o.context,e,i,n,l,c),!0}for(g=1,s=new Array(a-1);g<a;g++)s[g-1]=arguments[g];o.fn.apply(o.context,s)}else for(var r,u=o.length,g=0;g<u;g++)switch(o[g].once&&this.removeListener(t,o[g].fn,void 0,!0),a){case 1:o[g].fn.call(o[g].context);break;case 2:o[g].fn.call(o[g].context,e);break;case 3:o[g].fn.call(o[g].context,e,i);break;case 4:o[g].fn.call(o[g].context,e,i,n);break;default:if(!s)for(r=1,s=new Array(a-1);r<a;r++)s[r-1]=arguments[r];o[g].fn.apply(o[g].context,s)}return!0},e.prototype.on=function(t,e,i){return n(this,t,e,i,!1)},e.prototype.once=function(t,e,i){return n(this,t,e,i,!0)},e.prototype.removeListener=function(t,e,i,n){t=_?_+t:t;if(!this._events[t])return this;if(!e)return g(this,t),this;var s=this._events[t];if(s.fn)s.fn!==e||n&&!s.once||i&&s.context!==i||g(this,t);else{for(var o=0,a=[],r=s.length;o<r;o++)(s[o].fn!==e||n&&!s[o].once||i&&s[o].context!==i)&&a.push(s[o]);a.length?this._events[t]=1===a.length?a[0]:a:g(this,t)}return this},e.prototype.removeAllListeners=function(t){return t?(t=_?_+t:t,this._events[t]&&g(this,t)):(this._events=new i,this._eventsCount=0),this},e.prototype.off=e.prototype.removeListener,e.prototype.addListener=e.prototype.on,e.prefixed=_,s.exports=e.EventEmitter=e,t.exports;function i(){}function o(t,e,i){this.fn=t,this.context=e,this.once=i||!1}function n(t,e,i,n,s){if("function"!=typeof i)throw new TypeError("The listener must be a function");i=new o(i,n||t,s),n=_?_+e:e;return t._events[n]?t._events[n].fn?t._events[n]=[t._events[n],i]:t._events[n].push(i):(t._events[n]=i,t._eventsCount++),t}function g(t,e){0==--t._eventsCount?t._events=new i:delete t._events[e]}function e(){this._events=new i,this._eventsCount=0}var s,a,_}();const e=2,n=11,i=12,s=20,o=23,r=27;class a{constructor(t=0,e=0){this.high=t,this.low=e}equal(t){return null!==t&&this.low===t.low&&this.high===t.high}toString(){var t=Number(this.high).toString(16);let e=Number(this.low).toString(16);if(e.length<8){let t=8-e.length;for(;t;)e="0"+e,t--}return t+e}}const c={TEST:{CHINA:{DEFAULT:"wss://wss-dev.tim.qq.com"},OVERSEA:{DEFAULT:"wss://wss-dev.tim.qq.com"},SINGAPORE:{DEFAULT:"wss://wsssgp-dev.im.qcloud.com"},KOREA:{DEFAULT:"wss://wsskr-dev.im.qcloud.com"},GERMANY:{DEFAULT:"wss://wssger-dev.im.qcloud.com"},IND:{DEFAULT:"wss://wssind-dev.im.qcloud.com"},JPN:{DEFAULT:"wss://wssjpn-dev.im.qcloud.com"},USA:{DEFAULT:"wss://wssusa-dev.im.qcloud.com"},INDONESIA:{DEFAULT:"wss://wssidn-dev.im.qcloud.com"}},PRODUCTION:{CHINA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT:"wss://wsssgp.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT:"wss://wsskr.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT:"wss://wssger.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT:"wss://wssind.my-imcloud.com",BACKUP:"wss://wssind.im.qcloud.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.18.188"},JPN:{DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT:"wss://wssusa.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT:"wss://wssidn.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",STAT:"https://apiidn.my-imcloud.com",ANYCAST:"wss://43.129.34.169"}}},g={ANDROID:2,IOS:3,MAC:4,WEB:7,WX_MP:8,QQ_MP:9,TT_MP:10,BAIDU_MP:11,ALI_MP:12,IPAD:13,UNI_NATIVE_APP:15},l="CHINA",h={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(t=l){this.CURRENT=c.PRODUCTION[t]}},NAME:{OPEN_IM:"openim",OPEN_IM_MSG_EXT:"openim_msg_ext_http_svc",GRP:"group_open_http_svc",GRP_AV:"group_open_avchatroom_http_svc",GRP_COMMUNITY:"million_group_open_http_svc",GRP_ATTR:"group_open_attr_http_svc",FD:"sns",PROFILE:"profile",RECENT_CONTACT:"recentcontact",PIC:"openpic",BIG_GRP_NO_AUTH:"group_open_http_noauth_svc",BIG_GRP_POLLING:"group_open_long_polling_http_svc",BIG_GRP_POLLING_NO_AUTH:"group_open_long_polling_http_noauth_svc",IM_OPEN_STAT:"imopenstat",WEB_IM:"webim",IM_COS_SIGN:"im_cos_sign_svr",CUSTOM_UPLOAD:"im_cos_msg",HEARTBEAT:"heartbeat",IM_OPEN_PUSH:"im_open_push",IM_OPEN_STATUS:"im_open_status",IM_LONG_MSG:"im_long_msg",IM_CONFIG_MANAGER:"im_sdk_config_mgr",STAT_SERVICE:"StatSvc",OVERLOAD_PUSH:"OverLoadPush",IM_MSG_AUDIT_MGR:"im_msg_audit_mgr",TUIROOM_SVR:"tui_room_svr",IM_OPEN_TRANSLATE:"im_open_translate",IM_OPEN_SPEECH:"im_open_speech",MSG_SEARCH:"message_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report"}},u=(new a(0,Math.pow(2,0)).toString(),new a(0,Math.pow(2,1)).toString(),new a(0,Math.pow(2,2)).toString(),new a(0,Math.pow(2,3)).toString(),new a(0,Math.pow(2,4)).toString(),new a(0,Math.pow(2,6)).toString(),new a(0,Math.pow(2,7)).toString(),new a(0,Math.pow(2,9)).toString(),new a(0,Math.pow(2,10)).toString(),new a(0,Math.pow(2,11)).toString(),new a(0,Math.pow(2,13)).toString(),new a(0,Math.pow(2,15)).toString(),new a(Math.pow(2,6)).toString(),new a(Math.pow(2,7)).toString(),new a(Math.pow(2,8)).toString(),new a(Math.pow(2,9)).toString(),new a(Math.pow(2,10)).toString(),new a(Math.pow(2,16)).toString(),new a(Math.pow(2,20)).toString(),h.HOST.setCurrent(l),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),_=(u&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),d="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),m="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),I="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,v="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,p=u||_||d||m||I||v||f,D=("undefined"!=typeof uni||"undefined"!=typeof window)&&!p,S=(_?qq:d?tt:m?swan:I?my:u?wx:v?uni:f&&jd,D&&window&&window.navigator&&window.navigator.userAgent||""),y=/(micromessenger|webbrowser)/i.test(S),M=/AppleWebKit\/([\d.]+)/i.exec(S),w=(M&&parseFloat(M.pop()),function(){let t="WEB";return y?t="WEB":_?t="QQ_MP":d?t="TT_MP":m?t="BAIDU_MP":I?t="ALI_MP":u?t="WX_MP":v&&(t="UNI_NATIVE_APP"),g[t]}()),C=(!function(){var t=S.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),function(){var t,e,i=S.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);i&&(t=i[1]&&parseFloat(i[1]),e=i[2]&&parseFloat(i[2]),t&&e&&parseFloat(i[1]+"."+i[2]))}(),function(){var t=S.match(/Chrome\/(\d+)/);t&&t[1]&&parseFloat(t[1])}(),/MSIE/.test(S)||-1<S.indexOf("Trident")&&-1<S.indexOf("rv:11.0"));let T,E;!function(){var t=/MSIE\s(\d+)\.\d/.exec(S),t=t&&parseFloat(t[1]);!t&&/Trident\/7.0/i.test(S)&&/rv:11.0/.test(S)}(),function(){var t=S.match(/TBS\/(\d+)/i);t&&t[1]&&t[1]}(),T="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{};const L=function(){},A=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"];let N=A.length;for(;N--;)E=A[N],console[E]||(T[E]=L);var O=T;const $="TIMCustomElem",P="High",U="C2C",R="GROUP",H="@TIM#SYSTEM",x=function(){const t=new Date;return t.setTime((new Date).getTime()+0),t},b=Object.prototype.hasOwnProperty;function F(t){if(null==t)return!0;if("boolean"==typeof t)return!1;if("number"==typeof t)return 0===t;if("string"==typeof t)return 0===t.length;if("function"==typeof t)return 0===t.length;if(Array.isArray(t))return 0===t.length;if(t instanceof Error)return""===t.message;if(B(t)){for(const e in t)if(b.call(t,e))return!1;return!0}return!!(q(t)||j(t)||G(t))&&0===t.size}const q=function(t){return"map"===K(t)},j=function(t){return"set"===K(t)},G=function(t){return"file"===K(t)},B=function(t){if("object"!=typeof t||null===t)return!1;t=Object.getPrototypeOf(t);if(null===t)return!0;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return t===e},k=function(t){return void 0===t},J=function(t){return e=t,("function"==typeof Array.isArray?Array.isArray(e):"array"===K(e))||null!==t&&"object"==typeof t;var e},K=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()};function Y(){return!C&&!p}Date.now||(Date.now=function(){return(new Date).getTime()});let V=0;function W(){return Y()?"%c Chat %c":"Chat"}function z(){const t=x();return t.toLocaleTimeString("en-US",{hour12:!1})+"."+function(t){let e;switch(t.toString().length){case 1:e="00"+t;break;case 2:e="0"+t;break;default:e=t}return e}(t.getMilliseconds())}const X={arguments2String(i){let n="";if(1===i.length)n=i[0];else for(let t=0,e=i.length;t<e;t++)J(i[t])?i[t]instanceof Error?n+=(s=i[t],JSON.stringify(s,["message","code"])):n+=JSON.stringify(i[t]):n+=i[t],n+=" ";var s;return n},_exec(t,e){Y()?O[t](W(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",z(),e):O[t](`${W()} ${z()} `+e)},d:function(){var t;V<=-1&&(t=this.arguments2String(arguments),this._exec("debug",t))},l:function(){var t;V<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},log:function(){var t;V<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},i:function(){var t;V<=1&&(t=this.arguments2String(arguments),this._exec("info",t))},w:function(){var t;V<=2&&(t=this.arguments2String(arguments),this._exec("warn",t))},e:function(){var t;V<=3&&(t=this.arguments2String(arguments),this._exec("error",t))},setLevel:function(t){t<4&&this._exec("log","set level from "+V+" to "+t),V=t},getLevel:function(){return V}};class Q extends Error{constructor(t){super();var{code:t,message:e,data:i}=t;this.code=t,e?this.message=e:this._getErrorMessage&&(this.message=this._getErrorMessage(this.code)),this.data=i||{}}}const Z=2903,et=3122,nt=8010,it=8011,st=8020,ot="error";let rt=null;const at=function(t,e=!1){if(t instanceof Q)return e&&null!==rt&&rt.emit(ot,t),Promise.reject(t);if(t instanceof Error){const t=new Q({code:Z});return e&&null!==rt&&rt.emit(ot,t),Promise.reject(t)}if(k(t)||k(t.code))return Promise.reject(new Q({code:Z}));t=new Q(t);return e&&null!==rt&&rt.emit(ot,t),Promise.reject(t)},ct="newInvitationReceived",gt="ts_invitee_accepted",lt="ts_invitee_rejected",ht="ts_invitation_cancelled",ut="ts_invitation_timeout",_t="ts_invitation_modified",dt=1,mt=2,It=3,ft=4,vt=5;class pt{constructor(t){this._n="RemoteSignalingHandler",this._sigM=t}onNewMessageList(t){const e=this._sigM.filterMessageList(t);0<e.length&&e.forEach(t=>{var e=this.getPayloadData(t);e&&this._handleActionType(e,t)})}onMessageModified(t){const e=this._sigM.filterMessageList(t);0<e.length&&e.forEach(t=>{var e=this.getPayloadData(t);e&&this._onInvitationModified(e,t)})}getPayloadData(e){var i=this._n+".getPayloadData",e=e.payload["data"];try{return JSON.parse(e)}catch(t){return X.e(i+" JSON parse error. signalingData:"+e),null}}_handleActionType(t,e){var i=t["actionType"];switch(i){case dt:this._onNewInvitationReceived(t,e);break;case ft:this._onInviteeRejected(t);break;case It:this._onInviteeAccepted(t);break;case mt:this._onInvitationCancelled(t);break;case vt:this._onInvitationTimeout(t)}}_createDefaultEmitData(t){var{inviteID:t,inviter:e,groupID:i,data:n}=t;return{inviteID:t,inviter:e,groupID:i,data:n||""}}_onNewInvitationReceived(t,e){const i=this._n+"._onNewInvitationReceived",{inviteID:n,inviteeList:s,groupID:o,inviter:c}=t,a=this._sigM.getMyUserID(),r=s.includes(a);let g=t.timeout;var l=(x().getTime()-1e3*e.time)/1e3,h=(0<g&&0<l&&g>l&&(g-=l),i+` myselfIncluded:${r} groupID:${o} signalObj:`+JSON.stringify(t));if(X.l(h+` timeout:${g}s delta:${l}s`),o&&r||!o){const i=this._sigM.getInviteInfo(n);i&&i===t||(i||this._sigM.setInviteInfo(n,{...t,message:e}),this._sigM.emitEvent(ct,{...this._createDefaultEmitData(t),inviteeList:s}),c!==a&&this._sigM.startTimer({...t,timeout:g}))}}_onInviteeRejected(t){var e=this._n+"._onInviteeRejected",{inviteID:i,inviter:n,groupID:s}=t,o=this._sigM.hasInviteInfo(i);X.l(e+` inviteID:${i} hasInviteID:${o} inviter:${n} groupID:`+s),(s&&o||!s)&&(this._sigM.updateInviteInfo(t),this._sigM.emitEvent(lt,{...this._createDefaultEmitData(t),invitee:t.inviteeList[0]}))}_onInviteeAccepted(t){var e=this._n+"._onInviteeAccepted",{inviteID:i,inviter:n,groupID:s}=t,o=this._sigM.hasInviteInfo(i);X.l(e+` inviteID:${i} hasInviteID:${o} inviter:${n} groupID:`+s),(s&&o||!s)&&(this._sigM.updateInviteInfo(t),this._sigM.emitEvent(gt,{...this._createDefaultEmitData(t),invitee:t.inviteeList[0]}))}_onInvitationCancelled(t){var e=this._n+"._onInvitationCancelled",{inviteID:i,inviter:n,groupID:s}=t,o=this._sigM.hasInviteInfo(i);X.l(e+` inviteID:${i} hasInviteID:${o} inviter:${n} groupID:`+s),(s&&o||!s)&&(this._sigM.deleteInviteInfo(i),this._sigM.emitEvent(ht,this._createDefaultEmitData(t)))}_onInvitationTimeout(t){var e=this._n+"._onInvitationTimeout",{inviteID:i,inviter:n,groupID:s,inviteeList:o}=t,a=this._sigM.hasInviteInfo(i);X.l(e+` inviteID:${i} hasInviteID:${a} inviter:${n} groupID:${s} data:`+t.data),(s&&a||!s)&&(this._sigM.updateInviteInfo(t),this._sigM.emitEvent(ut,{...this._createDefaultEmitData(t),inviteeList:o,isSelfTimeout:!1}))}_onInvitationModified(t,e){var i=this._n+"._onInvitationModified",{inviteID:n,data:s}=t;X.l(i+` inviteID:${n} data:`+s),this._sigM.setInviteInfo(n,{...t,message:e}),this._sigM.emitEvent(_t,{inviteID:n,data:s})}}const Dt=function(t){if(t<0||53<t)return NaN;var e=0|1073741824*Math.random();return 30<t?e+1073741824*(0|Math.random()*(1<<t-30)):e>>>30-t},St=function(t,e){let i=t.toString(16),n=e-i.length,s="0";for(;0<n;n>>>=1,s+=s)1&n&&(i=s+i);return i};class yt{constructor(t){this._n="LocalSignalingHandler",this._sigM=t}generateInviteID(){var t=function(){const t=Dt,e=St;return e(t(32),8)+"-"+e(t(16),4)+"-"+e(16384|t(12),4)+"-"+e(32768|t(14),4)+"-"+e(t(48),12)}();return X.l(this._n+".generateInviteID inviteID:"+t),t}createInviteInfo(t){var e=this.generateInviteID(),t=this.createInviteCustomData({...t,inviteID:e}),{groupID:i,inviteeList:n}=t,i=i||n[0];return{customData:t,message:this.createSignalingMessage(t,i),inviteID:e}}_createDefaultCustomData(t){var{data:t="",inviteID:e="",groupID:i=""}=t;return{businessID:1,timeout:0,data:t,inviteID:e,groupID:i}}createInviteCustomData(t){var{userID:e,timeout:i=0,groupID:n=""}=t,s=this._sigM.getMyUserID(),s={...this._createDefaultCustomData(t),actionType:dt,inviter:s,inviteeList:n?t.inviteeList:[e],timeout:i};return X.l(this._n+".createInviteCustomData customData:"+JSON.stringify(s)),s}createCancelCustomData(t){var e=this._n+".createCancelCustomData",i=t["inviteID"];let n;var s=this._sigM.getMyUserID(),{inviteeList:i,groupID:o,inviter:a}=this._sigM.getInviteInfo(i);return a===s?n={...this._createDefaultCustomData(t),actionType:mt,groupID:o,inviter:s,inviteeList:i}:X.e(e+` unmatched inviter:${a} and my userID:`+s),X.l(e+" customData:"+JSON.stringify(n)),n}createAcceptCustomData(t){var e=this._n+".createAcceptCustomData",i=t["inviteID"];let n;const s=this._sigM.getMyUserID(),{inviter:o,groupID:a,inviteeList:r}=this._sigM.getInviteInfo(i);return r.includes(s)?n={...this._createDefaultCustomData(t),actionType:It,groupID:a,inviter:o,inviteeList:[s]}:X.e(e+` userID:${s} not in inviteeList. inviteID:${i} groupID:`+a),X.l(e+" customData:"+JSON.stringify(n)),n}createRejectCustomData(t){var e=this._n+".createRejectCustomData",i=t["inviteID"];let n;const s=this._sigM.getMyUserID(),{inviter:o,groupID:a,inviteeList:r}=this._sigM.getInviteInfo(i);return r.includes(s)?n={...this._createDefaultCustomData(t),actionType:ft,groupID:a,inviter:o,inviteeList:[s]}:X.e(e+` userID:${s} not in inviteeList. inviteID:${i} groupID:`+a),X.l(e+" customData:"+JSON.stringify(n)),n}createTimeoutCustomData(t){var e=this._n+".createTimeoutCustomData",{inviteeList:i,inviter:n,isInviter:s=!1}=t,o=this._sigM.getMyUserID(),t={...this._createDefaultCustomData(t),actionType:vt,inviter:n,inviteeList:s?i:[o]};return X.l(e+" customData:"+JSON.stringify(t)),t}createSignalingMessage(t,i){const{groupID:n,inviter:s}=t,o=this._sigM.get(e),a={to:i||n||s,conversationType:n?R:U,priority:P,payload:{data:JSON.stringify(t)}},r=o.createCustomMessage(a);return X.d(this._n+".createSignalingMessage. message:"+JSON.stringify(r)),r}}class Mt{constructor(t){this._n="HistorySignalingHandler",this._sigM=t,this.EXPIRED_TIME=3e4,this.COUNT=20,this._signalingMap=new Map,this._signalingRelatedToMeMap=new Map}getHistorySignaling(){var t=this._sigM.get(n).getLocalConversationList();F(t)||this._getSignalingList(t).then(t=>{this._handleSignalingList(t)})}_getSignalingList(t){t=this._getValidConversationList(t),t=this._createPromiseList(t);return F(t)?Promise.resolve([]):this._concurrentGetMessageList(t).then(t=>{let e=new Map;return t.forEach(t=>{t=t.signalingList,t=this._getSignalingRelatedToMeMap(t);e=new Map([...e,...t])}),this._sortSignaling(e)})}_handleSignalingList(t){F(t)||(X.d(this._n+"._handleSignalingList signalingList:"+JSON.stringify(t)),this._sigM.onNewMessageList(t))}_isSignalingNotExpired(t,e){return t[e]&&1e3*t[e]>(new Date).getTime()-this.EXPIRED_TIME}_getValidConversationList(e){const i=[];for(let t=0;t<e.length;t++){var{type:n,unreadCount:s,lastMessage:o}=e[t],o=this._isSignalingNotExpired(o,"lastTime");n!==H&&0<s&&o&&i.push(e[t])}return i}_createPromiseList(e){const i=[];for(let t=0;t<e.length;t++){var{conversationID:s,unreadCount:o,type:a}=e[t],a=a===U?o:this.COUNT,o=(this._signalingMap.set(s,{needMessageCount:a,signalingList:[]}),this._sigM.get(n).getMessageList({conversationID:s}));i.push(o)}return i}_concurrentGetMessageList(t){const s=[];return Promise.all(t).then(e=>{for(let t=0;t<e.length;t++){var{code:i,data:n}=e[t];0===i&&0!==n.messageList.length&&(this._handleMessageList(n.messageList),(i=this._relayGetMessageList(n))&&s.push(i))}return 0<s.length?this._concurrentGetMessageList(s):this._signalingMap})}_relayGetMessageList(t){var{messageList:t,nextReqMessageID:e,isCompleted:i}=t,s=t.length;if(0===s)return null;var{conversationID:o,conversationType:a}=t[0],r=this._signalingMap.get(o)["needMessageCount"],a=a===R,i=0===r||i,t=this._isSignalingNotExpired(t[s-1],"time");return a||i||!t?null:this._sigM.get(n).getMessageList({conversationID:o,nextReqMessageID:e,count:r})}_handleMessageList(e){const i=e.length,t=e[0]["conversationID"],{needMessageCount:n,signalingList:s}=this._signalingMap.get(t),o=0<n-i?n-i:0,a=[];for(let t=0;t<e.length;t++){const i=e[t];this._isSignalingNotExpired(i,"time")&&a.push(i)}var r=this._sigM.filterMessageList(a);this._signalingMap.set(t,{needMessageCount:o,signalingList:s.concat(r)})}_getSignalingRelatedToMeMap(e){for(let t=0;t<e.length;t++){var i=e[t];this._saveSignalingRelatedToMe(i)}return this._signalingRelatedToMeMap}_saveSignalingRelatedToMe(t){const e=this._sigM.getRemoteSignalingHandler().getPayloadData(t)||{},{actionType:i="",inviteID:n="",inviteeList:s=[]}=e,o=this._sigM.getMyUserID();switch(i){case dt:s.includes(o)&&this._signalingRelatedToMeMap.set(n,{...e,messageList:[t]});break;case ft:case It:this.updateHistoryInviteInfo(t);break;case mt:this.deleteHistoryInviteInfo(n);break;case vt:this.updateHistoryInviteInfo(t)}}deleteHistoryInviteInfo(t){this._signalingRelatedToMeMap.has(t)&&this._signalingRelatedToMeMap.delete(t)}updateHistoryInviteInfo(t){const e=this._sigM.getRemoteSignalingHandler().getPayloadData(t)||{},{inviteID:i="",inviteeList:n=[]}=e;if(this._signalingRelatedToMeMap.has(i)){const{inviteeList:e,messageList:s}=this._signalingRelatedToMeMap.get(i);for(let t=0;t<n.length;t++){const i=n[t];e.includes(i)&&e.splice(e.indexOf(i),1)}0===e.length?this.deleteHistoryInviteInfo(i):s.push(t)}else this.deleteHistoryInviteInfo(i)}_sortSignaling(t){let e=[];return t.forEach(t=>{e=[...e,...t.messageList]}),e.sort(function(t,e){return(t.time||0)-(e.time||0)})}reset(){this._signalingMap.clear(),this._signalingRelatedToMeMap.clear()}}class wt{constructor(t,e){this.businessID=t.businessID||1,this.inviteID=t.inviteID,this.groupID=t.groupID||"",this.inviter=t.inviter||"",this.inviteeList=t.inviteeList||[],this.data=t.data||"",this.actionType=t.actionType||dt,this.timeout=t.timeout||0}}const Ct={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG_UPDATED:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};class Tt extends class{constructor(t){this._m=t,this._n=""}isLoggedIn(){return this._m.get(i).isLoggedIn()}isOversea(){return this._m.get(i).isOversea()}isPrivateNetWork(){return this._m.get(i).isPrivateNetWork()}getFileDownloadProxy(){return this._m.get(i).getFileDownloadProxy()}getMyUserID(){return this._m.get(i).getUserID()}getMyTinyID(){return this._m.get(i).getTinyID()}getSDKAppID(){return this._m.get(i).getSDKAppID()}isIntl(){return this._m.get(i).isIntl()}isUsingChatCore(){return this._m.get(i).isUsingChatCore()}isDevMode(){return this._m.get(i).isDevMode()}get(t){return this._m.get(t)}getPlatform(){return w}getCloudConfig(t){return this._m.get(o).getCloudConfig(t)}emitOuterEvent(t,e){this._m.getOuterEmitterInstance().emit(t,e)}emitInnerEvent(t,e){this._m.getInnerEmitterInstance().emit(t,e)}getInnerEmitterInstance(){return this._m.getInnerEmitterInstance()}generateTjgID(t){return this._m.get(i).getTinyID()+"-"+t.random}req(t){return this._m.get(s).req(t)}canIUse(t){return this._m.get(r).canIUse(t)}getErrorMessage(t,e,i){return this._m.getErrorMessage(t,e,i)}outputWarning(t,e,i){t=this.getErrorMessage(t,e,i);t&&X.w(t)}cannotUseCommercialAbility(t){var e=et;return at({code:e,message:this.getErrorMessage(e,t)})}}{constructor(e){super(e),this._n="SignalingModule",this._inviteInfoMap=new Map,this._outerEmitter=new t,this._outerEmitter._emit=this._outerEmitter.emit,this._outerEmitter.emit=function(...t){t=[t[0],{name:t[0],data:t[1]}];this._outerEmitter._emit.apply(this._outerEmitter,[...t])}.bind(this),this._canIUseSignaling=!1,this._isHandling=!1,this._remoteSignalingHandler=new pt(this),this._localSignalingHandler=new yt(this),this._historySignalingHandler=new Mt(this),this._isC2CUnreadHandleCompleted=!1,this._isConvSyncCompleted=!1,this._isSyncCompleted=!1,this.getInnerEmitterInstance().on(Ct.C2C_UNREAD_HANDLE_COMPLETED,this.onC2CUnreadHandleCompleted,this),this.getInnerEmitterInstance().on(Ct.CONV_SYNC_COMPLETED,this.onConvSyncCompleted,this)}onC2CUnreadHandleCompleted(){this._isC2CUnreadHandleCompleted=!0,this._isC2CUnreadHandleCompleted&&this._isConvSyncCompleted&&!this._isSyncCompleted&&this.onReady()}onConvSyncCompleted(){this._isConvSyncCompleted=!0,this._isC2CUnreadHandleCompleted&&this._isConvSyncCompleted&&!this._isSyncCompleted&&this.onReady()}onReady(){X.l(this._n+".onReady"),this._isSyncCompleted=!0,this._historySignalingHandler.getHistorySignaling()}onNewMessageList(t){return this._remoteSignalingHandler.onNewMessageList(t)}onMessageModified(t){return this._remoteSignalingHandler.onMessageModified(t)}hasInviteInfo(t){return this._inviteInfoMap.has(t)}getInviteInfo(t){return this._inviteInfoMap.get(t)}setInviteInfo(t,e){const{message:i,...n}=e;X.l(this._n+`.setInviteInfo inviteID:${t} data:`+JSON.stringify(n)),this._inviteInfoMap.set(t,{...n,message:i})}deleteInviteInfo(t){this.hasInviteInfo(t)&&(X.l(this._n+`.deleteInviteInfo inviteID:${t}.`),this._inviteInfoMap.delete(t))}updateInviteInfo(t){const e=this._n+".updateInviteInfo",{inviteID:i,inviter:n,inviteeList:s,groupID:o}=t;if(X.l(e+` inviteID:${i} inviter:${n} groupID:`+o),o&&this.hasInviteInfo(i)){const t=s[0],n=this.getInviteInfo(i)["inviteeList"];n.includes(t)&&(n.splice(n.indexOf(t),1),X.l(e+` remove ${t}. localInviteeList.length:`+n.length)),0===n.length&&this.deleteInviteInfo(i)}else this.deleteInviteInfo(i)}getLocalSignalingHandler(){return this._localSignalingHandler}getRemoteSignalingHandler(){return this._remoteSignalingHandler}canIUseSignaling(){return this._canIUseSignaling}emitEvent(t,e){this._outerEmitter.emit(t,e)}addSignalingListener(t,e,i){this._canIUseSignaling||(this._canIUseSignaling=!0),this._outerEmitter.on(t,e,i)}removeSignalingListener(t,e,i){this._outerEmitter.off(t,e,i),0===this._outerEmitter.eventNames().length&&(this._canIUseSignaling=!1)}invite(t){const e=this._n+".invite",{message:i,customData:n,inviteID:s}=this._localSignalingHandler.createInviteInfo(t);return X.l(e+` options:${JSON.stringify(t)} inviteID:`+s),this.sendSignaling(i,t).then(t=>t&&0===t.code?(this.setInviteInfo(s,{...n,message:i}),this.startTimer({...n,inviteID:s}),{...t,inviteID:s}):t).catch(t=>at(t))}inviteSync(t,e,i){const n=this._n+".inviteSync",{message:s,customData:o,inviteID:a}=this._localSignalingHandler.createInviteInfo(t);return X.l(n+` options:${JSON.stringify(t)} inviteID:`+a),this.sendSignaling(s,t).then(t=>{if(t&&0===t.code)return this.setInviteInfo(a,{...o,message:s}),this.startTimer({...o,inviteID:a}),e&&e({inviteID:a}),{inviteID:a};i&&i(0===t.code,t.message||"")}).catch(t=>(i&&i(t.code,t.message),at(t))),a}_handleImResponse(t,e,i){e&&0===e.code&&(this._isHandling=!1,i?this.deleteInviteInfo(t.inviteID):this.updateInviteInfo(t))}cancel(e){var t=this._n+".cancel";if(X.l(t+" options:"+JSON.stringify(e)),!this.hasInviteInfo(e.inviteID)||this._isHandling)return at({code:st});this._isHandling=!0;const i=this._localSignalingHandler.createCancelCustomData(e);if(!i)return this._isHandling=!1,at({code:it});var{groupID:t,inviteeList:n}=i,t=t||n[0],n=this._localSignalingHandler.createSignalingMessage(i,t);return this.sendSignaling(n,e).then(t=>(this._handleImResponse(i,t,!0),0===t.code?{...t,inviteID:e.inviteID}:t)).catch(t=>at(t))}accept(e){var t=this._n+".accept";if(X.l(t+" options:"+JSON.stringify(e)),!this.hasInviteInfo(e.inviteID)||this._isHandling)return at({code:nt});this._isHandling=!0;const i=this._localSignalingHandler.createAcceptCustomData(e);if(!i)return this._isHandling=!1,at({code:it});t=this._localSignalingHandler.createSignalingMessage(i);return this.sendSignaling(t,e).then(t=>(this._handleImResponse(i,t),0===t.code?{...t,inviteID:e.inviteID}:t)).catch(t=>at(t))}reject(e){var t=this._n+".reject";if(X.l(t+" options:"+JSON.stringify(e)),!this.hasInviteInfo(e.inviteID)||this._isHandling)return at({code:nt});this._isHandling=!0;const i=this._localSignalingHandler.createRejectCustomData(e);if(!i)return this._isHandling=!1,at({code:it});t=this._localSignalingHandler.createSignalingMessage(i);return this.sendSignaling(t,e).then(t=>(this._handleImResponse(i,t,!0),0===t.code?{...t,inviteID:e.inviteID}:t)).catch(t=>at(t))}getSignalingInfo(t){const e=this._n+".getSignalingInfo",{ID:i,from:n,to:s}=t,o=this._filterSignalingMessage(t);let a=null;if(o){const e=this._remoteSignalingHandler.getPayloadData(t);a=new wt(e)}t=o?"actionType:"+a.actionType:"";return X.l(e+` messageID:${i} from:${n} to:${s} ${t} isSignaling:`+o),a}modifyInvitation(t){const{inviteID:i,data:n}=t;if(!this.hasInviteInfo(t.inviteID)||this._isHandling)return at({code:nt});this._isHandling=!0;const{message:s,...o}=this.getInviteInfo(i),a=s.payload.data;return o.data=n,s.payload.data=JSON.stringify(o),this.get(e).modifyRemoteMessage(s).then(t=>(this.setInviteInfo(i,{...o,message:s}),this._isHandling=!1,t)).catch(t=>(this._isHandling=!1,s.payload.data=a,at(t)))}_genMessageControlInfo(t={}){const{data:e="",onlineUserOnly:i,inviteID:n="",offlinePushInfo:s,actionType:o}=t;let a={_onlineOnlyFlag:!1};const r={onlineUserOnly:(a=n&&this.getInviteInfo(n)?this.getInviteInfo(n).message:a)._onlineOnlyFlag||i||!1,offlinePushInfo:s,messageControlInfo:{excludedFromContentModeration:!0,excludedFromUnreadCount:!1,excludedFromLastMessage:!1}};if(o===vt){const t=!!e.match(/excludeTimeoutSignalingFromHistoryMessage/);return r.messageControlInfo.excludedFromUnreadCount=t,r.messageControlInfo.excludedFromLastMessage=t,r}var t=!!e.match(/excludeFromHistoryMessage/),g=!!e.match(/excludeOriginalSignalingFromHistoryMessage/);return r.messageControlInfo.excludedFromUnreadCount=t||g,r.messageControlInfo.excludedFromLastMessage=t||g,r}sendSignaling(t,i){return this.get(e).sendMessageInstance(t,this._genMessageControlInfo(i)).catch(t=>(this._isHandling=!1,at(t)))}filterMessageList(t){return t.filter(t=>this._filterSignalingMessage(t))}_filterSignalingMessage(t){let e=!1;if(t.type&&t.type===$){const{cloudCustomData:i="",payload:{data:n=""}}=t,s=i.match(/"type":"tsignaling"/),o=n.match(/inviteID/),a=n.match(/actionType/);e=s||o&&a}return!!e}startTimer(i){const n=this._n+".startTimer",{timeout:t,inviteID:s,inviter:e,groupID:o}=i,a=e===this.getMyUserID();if(X.l(n+` timeout:${t} isInviter:${a} groupID:`+o),!(t<=0)){const r=a?t+5:t;let e=1;const g=setInterval(()=>{var t=this._hasLocalInviteInfo(i,a);e<r&&t?++e:(t&&this._sendTimeoutNotice(s,a),X.l(n+" end."),clearInterval(g))},1e3)}}_hasLocalInviteInfo(t,e){var{inviteID:t,groupID:i}=t;if(!this.hasInviteInfo(t))return!1;const n=this._n+"._hasLocalInviteInfo",s=this.getInviteInfo(t)["inviteeList"];return X.l(n+` inviteID:${t} inviteeList:${s} groupID:`+i),!i||(e?0<s.length:0<s.length&&s.includes(this.getMyUserID()))}_getReceiver(t,e){var{groupID:e,inviteeList:i,inviter:n}=e;return t?e||i[0]:e||n}_sendTimeoutNotice(s,o){var t=this.getInviteInfo(s),e=this._getReceiver(o,t);X.l(this._n+`._sendTimeoutNotice inviteID:${s} to:${e} isInviter:`+o);const a=this._localSignalingHandler.createTimeoutCustomData({...t,isInviter:o}),r=this._localSignalingHandler.createSignalingMessage(a,e);return this.sendSignaling(r,a).then(t=>{if(t&&0===t.code){const{data:t,groupID:e,inviteeList:i,inviter:n}=a;this.emitEvent(ut,{data:t,groupID:e,inviteID:s,inviteeList:i,inviter:n,isSelfTimeout:!0,message:r}),o?this.deleteInviteInfo(s):this.updateInviteInfo(a)}})}reset(){X.l(this._n+".reset"),this._inviteInfoMap.clear(),this._canIUseSignaling=!1,this._isHandling=!1,this._historySignalingHandler.reset(),this._isC2CUnreadHandleCompleted=!1,this._isConvSyncCompleted=!1,this._isSyncCompleted=!1}}export{Tt as default};
{
"name": "@tencentcloud/chat",
"version": "3.2.5",
"version": "3.2.6",
"description": "Tencent Cloud Chat SDK for Web",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc