@tencentcloud/chat
Version:
Tencent Cloud Chat SDK for Web/Mini Program/uni-app/React Native/Donut
1 lines • 19.8 kB
JavaScript
let 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}}let 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:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.tim.qq.com",BACKUP_WEB:"wss://*w4c.my-cpaas.com",STAT:"https://events.im.qcloud.com",ANYCAST:"wss://162.14.13.203"},OVERSEA:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",IPV6:"wss://wssv6.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",BACKUP_WEB:"wss://*w4c.my-cpaas.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT0:"wss://*w4s.my-imcloud.com",DEFAULT:"wss://wsssgp.im.qcloud.com",IPV6:"wss://wsssgpv6.im.qcloud.com",BACKUP:"wss://wsssgp.my-imcloud.com",BACKUP_WEB:"wss://*w4s.my-cpaas.com",STAT:"https://apisgp.my-imcloud.com",ANYCAST:"wss://162.14.19.159"},KOREA:{DEFAULT0:"wss://*w4k.my-imcloud.com",DEFAULT:"wss://wsskr.im.qcloud.com",IPV6:"wss://wsskrv6.im.qcloud.com",BACKUP:"wss://wsskr.my-imcloud.com",BACKUP_WEB:"wss://*w4k.my-cpaas.com",STAT:"https://apikr.my-imcloud.com",ANYCAST:"wss://162.14.13.104"},GERMANY:{DEFAULT0:"wss://*w4g.my-imcloud.com",DEFAULT:"wss://wssger.im.qcloud.com",IPV6:"wss://wssgerv6.im.qcloud.com",BACKUP:"wss://wssger.my-imcloud.com",BACKUP_WEB:"wss://*w4g.my-cpaas.com",STAT:"https://apiger.my-imcloud.com",ANYCAST:"wss://162.14.3.17"},IND:{DEFAULT0:"wss://*w4i.my-imcloud.com",DEFAULT:"wss://wssind.my-imcloud.com",IPV6:"wss://wssindv6.im.qcloud.com",BACKUP:"wss://wssind.im.qcloud.com",BACKUP_WEB:"wss://*w4i.my-cpaas.com",STAT:"https://apiind.my-imcloud.com",ANYCAST:"wss://162.14.19.46"},JPN:{DEFAULT0:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",IPV6:"wss://wssjpnv6.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",BACKUP_WEB:"wss://*w4j.my-cpaas.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT0:"wss://*w4u.my-imcloud.com",DEFAULT:"wss://wssusa.im.qcloud.com",IPV6:"wss://wssusav6.im.qcloud.com",BACKUP:"wss://wssusa.my-imcloud.com",BACKUP_WEB:"wss://*w4u.my-cpaas.com",STAT:"https://apiusa.my-imcloud.com",ANYCAST:"wss://162.14.10.42"},INDONESIA:{DEFAULT0:"wss://*w4y.my-imcloud.com",DEFAULT:"wss://wssidn.im.qcloud.com",IPV6:"wss://wssidnv6.im.qcloud.com",BACKUP:"wss://wssidn.my-imcloud.com",BACKUP_WEB:"wss://*w4y.my-cpaas.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,DONUT_NATIVE_APP:19,NS_NATIVE_APP:20,RN_NATIVE_APP:21},l="CHINA",c={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",GRP_SEARCH:"group_search",GRP_MEMBER_SEARCH:"group_member_search",USER_SEARCH:"user_search",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report",IM_MSG_LOGIC:"im_msg_db_logic"}},u={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()},a=(c.HOST.setCurrent(l),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform)),_="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||a,m=(_&&wx.createGamePortal,"undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting)),g="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),h="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),w="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,d="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,p=_&&"object"==typeof wx.miniapp,I=_||m||g||h||w||d||f,T="undefined"==typeof window&&!I&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,A="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),y="undefined"!=typeof uni?!I:"undefined"!=typeof window&&!I&&!A,S=(m?qq:g?tt:h?swan:w?my:_?wx:d?uni:f&&jd,y&&window&&window.navigator&&window.navigator.userAgent||""),E=/(micromessenger|webbrowser)/i.test(S),M=function(){let t="WEB";return E?t="WEB":m?t="QQ_MP":g?t="TT_MP":h?t="BAIDU_MP":w?t="ALI_MP":_?t=p?"DONUT_NATIVE_APP":"WX_MP":d?t="UNI_NATIVE_APP":T?t="NS_NATIVE_APP":A&&(t="RN_NATIVE_APP"),r[t]}(),L=(!function(){var t=S.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),function(){var t,e,s=S.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])}(),/MSIE/.test(S)||-1<S.indexOf("Trident")&&-1<S.indexOf("rv:11.0")),U,P,O=(!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)}(),U="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{},function(){}),N=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],C=N.length;for(;C--;)P=N[C],console[P]||(U[P]=O);var F=U;let D=function(){return(new Date).getTime()+0},v="Tag_Profile_IM_Nick",R="Tag_Profile_IM_Gender",b="Tag_Profile_IM_BirthDay",k="Tag_Profile_IM_Location",q="Tag_Profile_IM_SelfSignature",G="Tag_Profile_IM_AllowType",B="Tag_Profile_IM_Language",x="Tag_Profile_IM_Image",W="Tag_Profile_IM_MsgSettings",$="Tag_Profile_IM_AdminForbidType",V="Tag_Profile_IM_Level",j="Tag_Profile_IM_Role",K=Object.prototype.hasOwnProperty,H=function(t){return"map"===et(t)},Y=function(t){return"set"===et(t)},X=function(t){return"file"===et(t)},z=function(t){return null!==t&&("number"==typeof t&&!isNaN(+t)||"object"==typeof t&&t.constructor===Number)},J=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},Q=function(t){return void 0===t},Z=function(t){return e=t,("function"==typeof Array.isArray?Array.isArray(e):"array"===et(e))||null!==t&&"object"==typeof t;var e},et=function(t){return Object.prototype.toString.call(t).match(/^\[object (.*)\]$/)[1].toLowerCase()};function st(){return!L&&!I}Date.now||(Date.now=function(){return(new Date).getTime()});let ot=0;function nt(){return st()?"%c Chat %c":"Chat"}function it(){(t=new Date).setTime(D());var 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())}let rt={arguments2String(s){let o="";if(1===s.length)o=s[0];else for(let t=0,e=s.length;t<e;t++){if(Z(s[t]))try{o+=s[t]instanceof Error?JSON.stringify(s[t],["message","code"]):JSON.stringify(s[t])}catch(t){o+=t?t.message:"";break}else o+=s[t];o+=" "}return o},_exec(t,e){st()?F[t](nt(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",it(),e):F[t](`${nt()} ${it()} `+e)},d:function(){var t;ot<=-1&&(t=this.arguments2String(arguments),this._exec("debug",t))},l:function(){var t;ot<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},log:function(){var t;ot<=0&&(t=this.arguments2String(arguments),this._exec("log",t))},i:function(){var t;ot<=1&&(t=this.arguments2String(arguments),this._exec("info",t))},w:function(){var t;ot<=2&&(t=this.arguments2String(arguments),this._exec("warn",t))},e:function(){var t;ot<=3&&(t=this.arguments2String(arguments),this._exec("error",t))},setLevel:function(t){t<4&&this._exec("log","set level from "+ot+" to "+t),ot=t},getLevel:function(){return ot}},lt=function(t){return{code:0,data:t||{}}};class ct extends Error{constructor(t){super();var{code:t,message:e,data:s}=t;this.code=t,e?this.message=e:this._getErrMsg&&(this.message=this._getErrMsg(this.code)),this.data=s||{}}}let ut=2805,at=2903,_t=3122,mt="onMyFollowersListUpdated",gt="onMyFollowingListUpdated",ht="onMutualFollowersListUpdated",wt="error",ft=null,dt=function(t,e=!1){if(t instanceof ct)return e&&null!==ft&&ft.emit(wt,t),Promise.reject(t);if(t instanceof Error){let t=new ct({code:at});return e&&null!==ft&&ft.emit(wt,t),Promise.reject(t)}return Q(t)||Q(t.code)?Promise.reject(new ct({code:at})):(t=new ct(t),e&&null!==ft&&ft.emit(wt,t),Promise.reject(t))},pt="follow_add",It="follow_delete",Tt="follow_get",At="follow_get_info",yt="follow_check",St={info:4,warning:5,error:6},Et={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},Mt={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,tui_key_features:16};class Lt{constructor(t){this._n="SSOLogData",this.eventType=Mt[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=D()}static bindEventStatModule(t){Lt.prototype._eventStatModule=t}static bindNetMonitorModule(t){Lt.prototype._netMonitorModule=t}updateTimeStamp(){this.timestamp=D()}start(t){return this._startts=t,this}end(t=!1){if(!this._sentFlag){if(this._netMonitorModule){let t=this._netMonitorModule.getNetworkType();this.setNetworkType(t)}var e=D();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(e){if(e instanceof Error){if(!this._sentFlag){let t=!0;if(t=this._netMonitorModule?this._netMonitorModule.isOnline():t)e.code&&this.setCode(e.code),e.message&&this.setMoreMessage(e.message);else{let t=ut;this.setCode(t)}this.setLevel("error")}}else rt.w(this._n+".setError value not instanceof Error, please check!");return this}setCode(t){return Q(t)||this._sentFlag||("ECONNABORTED"===t&&(this.code=103),z(t)?this.code=t:rt.w(this._n+".setCode value not a number, please check!",t,typeof t)),this}setMessage(t){return Q(t)||this._sentFlag||(z(t)&&(this.message=t.toString()),"string"==typeof t&&(this.message=t)),this}setCostTime(t){return this.costTime=t,this}setLevel(t){return Q(t)||this._sentFlag||(this.level=St[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(J(t)){for(var e in t)if(K.call(t,e))return;return 1}return(H(t)||Y(t)||X(t))&&0===t.size}}(this.moreMessage)?this.moreMessage=""+t:this.moreMessage+=" "+t,this}setNetworkType(t){return Q(t)?rt.w(this._n+".setNetworkType value is undefined, please check!"):(t=Et[t.toLowerCase()],Q(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}}let Ut={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"},Pt={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(){var e=this._m.get(t);return e.isPrivateNetWork()&&!e.getFileDownloadProxy()}getFileDownloadProxy(){return this._m.get(t).getFileDownloadProxy()}getDownloadFileAuthKey(){return this._m.get(t).getDownloadFileAuthKey()}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 M}getCloudConfig(t){return this._m.get(s).getCloudConfig(t)}emitOEvt(t,e){this._m.getOEmitInst().emit(t,e)}emitIEvt(t,e){this._m.getIEmitInst().emit(t,e)}getIEmitInst(){return this._m.getIEmitInst()}req(t){return this._m.get(e).req(t)}canIUse(t){return this._m.get(o).canIUse(t)}getErrMsg(t,e,s){return this._m.getErrMsg(t,e,s)}warn(t,e,s){t=this.getErrMsg(t,e,s);t&&rt.w(t)}noUse(t){var e=_t;return dt({code:e,message:this.getErrMsg(e,t)})}}{constructor(t){super(t),this._n="FollowModule",this.DEFAULT_COUNT=500,this.MAX_COUNT=1e3,this.getIEmitInst().on(Ut.CLOUD_CONFIG,this._onCloudConfig,this)}_onCloudConfig(){var t=this.getCloudConfig("follow_req_count");Q(t)||(t=Number(t),this.DEFAULT_COUNT=t>this.MAX_COUNT?this.MAX_COUNT:t)}onFollowNotify(t){t=t.dataList||[];rt.l(this._n+".onFollowNotify followChangeList:"+t.length),t.forEach(t=>{let{followDiffList:e=[],...s}=t,{from:o,...n}=s;e.forEach(t=>{var{isAdd:t,followType:e=0}=t,s=this._initFollowInfo();1===t?(n.userID=o,s[e].userInfoList.push(n),s[e].isAdd=!0):(s[e].userInfoList.push(o),s[e].isAdd=!1),this._emitEvent(s)})})}_initFollowInfo(){let e={};return Object.values(Pt).forEach(t=>{t!==Pt.NONE&&(e[t]={userInfoList:[],isAdd:!1})}),e}_emitEvent(s){Object.keys(s).forEach(t=>{var t=Number(t),e=s[t];0<e.userInfoList.length&&(t===Pt.FOLLOWERS&&this.emitOEvt(mt,e),t===Pt.FOLLOWING&&this.emitOEvt(gt,e),t===Pt.MUTUAL)&&this.emitOEvt(ht,e)})}followUser(t){if(!this.canIUse(u.FOLLOW))return this.noUse("followUser");let e=this._n+".followUser",s="userIDList:"+t.length,o=new Lt("followUser");return o.setMessage(s),rt.l(e+" "+s),this.req({P:pt,data:{fromAccount:this.getMyUserID(),userIDList:t.map(t=>({userID:t}))}}).then(t=>(o.end(),rt.l(e+" ok."),lt(t.data.resultList))).catch(t=>(o.setError(t).end(),rt.e(e+" failed. error:",t),dt(t)))}unfollowUser(t){if(!this.canIUse(u.FOLLOW))return this.noUse("unfollowUser");let e=this._n+".unfollowUser",s="userIDList:"+t.length,o=new Lt("unfollowUser");return o.setMessage(s),rt.l(e+" "+s),this.req({P:It,data:{fromAccount:this.getMyUserID(),userIDList:t}}).then(t=>(o.end(),rt.l(e+" ok."),lt(t.data.resultList))).catch(t=>(o.setError(t).end(),rt.e(e+" failed. error:",t),dt(t)))}getMyFollowersList(t=""){return this.canIUse(u.FOLLOW)?this._getFollowList(t,Pt.FOLLOWERS).then(t=>{var{nextCursor:e,resultList:s=[]}=t;return rt.l(`${this._n}.getMyFollowersList ok, count:${s.length} nextCursor:`+e),lt(t)}):this.noUse("getMyFollowersList")}getMyFollowingList(t=""){return this.canIUse(u.FOLLOW)?this._getFollowList(t,Pt.FOLLOWING).then(t=>{var{nextCursor:e,resultList:s=[]}=t;return rt.l(`${this._n}.getMyFollowingList ok, count:${s.length} nextCursor:`+e),lt(t)}):this.noUse("getMyFollowingList")}getMutualFollowersList(t=""){return this.canIUse(u.FOLLOW)?this._getFollowList(t,Pt.MUTUAL).then(t=>{var{nextCursor:e,resultList:s=[]}=t;return rt.l(`${this._n}.getMutualFollowersList ok, count:${s.length} nextCursor:`+e),lt(t)}):this.noUse("getMutualFollowersList")}_getFollowList(t,e){let n=new Lt("_getFollowList");return n.setMessage(`nextCursor:${t} type:`+e),this.req({P:Tt,data:{fromAccount:this.getMyUserID(),count:this.DEFAULT_COUNT,nextCursor:t,type:e}}).then(t=>{n.end();let{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(),rt.e(this._n+"._getFollowList failed. error:",t),dt(t)))}_handleProfileItem(t){let e={};return t.forEach(t=>{switch(t.tag){case v:e.nick=t.value;break;case R:e.gender=t.value;break;case b:e.birthday=t.value;break;case k:e.location=t.value;break;case q:e.selfSignature=t.value;break;case G:e.allowType=t.value;break;case B:e.language=t.value;break;case x:e.avatar=t.value;break;case W:e.messageSettings=t.value;break;case $:e.adminForbidType=t.value;break;case V:e.level=t.value;break;case j:e.role=t.value;break;default:e[t.tag]=t.value}}),e}getUserFollowInfo(t){if(!this.canIUse(u.FOLLOW))return this.noUse("getUserFollowInfo");let e=t,s=!1,n=(Q(t)&&(e=[this.getMyUserID()],s=!0),this._n+".getUserFollowInfo"),o=`userIDList:${e.length} isGetMyFollowInfo:`+s,r=new Lt("getUserFollowInfo");return r.setMessage(o),rt.l(n+" "+o),this.req({P:At,data:{fromAccount:this.getMyUserID(),userIDList:e}}).then(t=>{r.end(),rt.l(n+" ok.");let{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})}),lt(o)}).catch(t=>(r.setError(t).end(),rt.e(n+" failed. error:",t),dt(t)))}checkFollowType(t){if(!this.canIUse(u.FOLLOW))return this.noUse("checkFollowType");100<t.length&&(t=t.slice(0,100),rt.w(o+" "+"the length of userIDList cannot exceed 100"));let o=this._n+".checkFollowType",e=`userIDList length:${t.length} `,n=new Lt("checkFollowType");return n.setMessage(e),rt.l(o+" "+e),this.req({P:yt,data:{fromAccount:this.getMyUserID(),userIDList:t}}).then(t=>{n.end(),rt.l(o+" ok.");let{resultList:e=[]}=t.data,s=[];return e.forEach(t=>{var{userID:t,followType:e}=t;s.push({userID:t,followType:e})}),lt(s)}).catch(t=>(n.setError(t).end(),rt.e(o+" failed. error:",t),dt(t)))}reset(){rt.l(this._n+".reset")}}export{Ot as default};