"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:{DEFAULT0:"wss://*w4c.my-imcloud.com",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:{DEFAULT0:"wss://*w4c.my-imcloud.com",DEFAULT:"wss://wss.im.qcloud.com",BACKUP:"wss://wss.my-imcloud.com",STAT:"https://api.my-imcloud.com"},SINGAPORE:{DEFAULT0:"wss://*w4s.my-imcloud.com",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:{DEFAULT0:"wss://*w4k.my-imcloud.com",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:{DEFAULT0:"wss://*w4g.my-imcloud.com",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:{DEFAULT0:"wss://*w4i.my-imcloud.com",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:{DEFAULT0:"wss://*w4j.my-imcloud.com",DEFAULT:"wss://wssjpn.im.qcloud.com",BACKUP:"wss://wssjpn.my-imcloud.com",STAT:"https://apijpn.my-imcloud.com"},USA:{DEFAULT0:"wss://*w4u.my-imcloud.com",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:{DEFAULT0:"wss://*w4y.my-imcloud.com",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,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",FOLLOW:"follow",OFFLINE_PUSH_REPORT:"offline_push_report",IM_MSG_LOGIC:"im_msg_db_logic"}},a={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=(c.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)),h="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),g="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),m="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),f="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,w="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,d=u&&"object"==typeof wx.miniapp,p=u||_||h||g||m||w||f,T="undefined"==typeof window&&!p&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,I="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),y="undefined"!=typeof uni?!p:"undefined"!=typeof window&&!p&&!I,L=(_?qq:h?tt:g?swan:m?my:u?wx:w?uni:f&&jd,y&&window&&window.navigator&&window.navigator.userAgent||""),A=/(micromessenger|webbrowser)/i.test(L),M=function(){let t="WEB";return A?t="WEB":_?t="QQ_MP":h?t="TT_MP":g?t="BAIDU_MP":m?t="ALI_MP":u?t=d?"DONUT_NATIVE_APP":"WX_MP":w?t="UNI_NATIVE_APP":T?t="NS_NATIVE_APP":I&&(t="RN_NATIVE_APP"),r[t]}(),E=(!function(){var t=L.match(/OS (\d+)_/i);t&&t[1]&&t[1]}(),function(){var t,e,s=L.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(L)||-1{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{const e=ut;this.setCode(e)}this.setLevel("error")}}else lt.w(this._n+".setError value not instanceof Error, please check!");return this}setCode(t){return J(t)||this._sentFlag||("ECONNABORTED"===t&&(this.code=103),Y(t)?this.code=t:lt.w(this._n+".setCode value not a number, please check!",t,typeof t)),this}setMessage(t){return J(t)||this._sentFlag||(Y(t)&&(this.message=t.toString()),"string"==typeof t&&(this.message=t)),this}setCostTime(t){return this.costTime=t,this}setLevel(t){return J(t)||this._sentFlag||(this.level=Et[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(z(t)){for(const e in t)if(H.call(t,e))return;return 1}return(V(t)||K(t)||X(t))&&0===t.size}}(this.moreMessage)?this.moreMessage=""+t:this.moreMessage+=" "+t,this}setNetworkType(t){return J(t)?lt.w(this._n+".setNetworkType value is undefined, please check!"):(t=St[t.toLowerCase()],J(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 Ot={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"},Nt={NONE:0,FOLLOWERS:1,FOLLOWING:2,MUTUAL:3};class Pt 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()}getDowloadFileAuthKey(){return this._m.get(t).getDowloadFileAuthKey()}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&<.w(t)}noUse(t){var e=ht;return Tt({code:e,message:this.getErrMsg(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;0this.MAX_COUNT?this.MAX_COUNT:t,this._clearFollowList())}clearCacheOnReconnected(){this._clearFollowList(),this._followType.clear()}onFollowNotify(t){t=t.dataList||[];lt.l(this._n+".onFollowNotify followChangeList:"+t.length),t.forEach(t=>{const{followDiffList:e=[],...o}=t;e.forEach(t=>{var{isAdd:t,followType:e=[]}=t,s=this._initFollowInfo();s[e].userInfoList.push(o),s[e].isAdd=1===t,this._emitEvent(s)})})}_initFollowInfo(){const e={};return Object.values(Nt).forEach(t=>{t!==Nt.NONE&&(e[t]={userInfoList:[],isAdd:!1})}),e}_emitEvent(s){Object.keys(s).forEach(t=>{var t=Number(t),e=s[t];0({userID:t}))}}).then(t=>(o.end(),lt.l(e+" ok."),ct(t.data.resultList))).catch(t=>(o.setError(t).end(),lt.e(e+" failed. error:",t),Tt(t)))}unfollowUser(t){if(!this.canIUse(a.FOLLOW))return this.noUse("unfollowUser");const e=this._n+".unfollowUser",s="userIDList:"+t.length,o=new Ft("unfollowUser");return o.setMessage(s),lt.l(e+" "+s),this.req({P:yt,data:{fromAccount:this.getMyUserID(),userIDList:t}}).then(t=>(o.end(),lt.l(e+" ok."),ct(t.data.resultList))).catch(t=>(o.setError(t).end(),lt.e(e+" failed. error:",t),Tt(t)))}getMyFollowersList(e=""){const s="getMyFollowersList";if(!this.canIUse(a.FOLLOW))return this.noUse(s);const o=e||this.FIRST_PAGE_INDEX;if(this._myFollowersList.has(o)){var{resultList:t,nextCursor:n,lastUpdateTime:i}=this._myFollowersList.get(o);if(Date.now()-i(this._myFollowersList.set(o,{...t,lastUpdateTime:Date.now()}),lt.l(`${this._n}.${s} nextCursor:${e} from remote.`),ct(t)))}getMyFollowingList(e=""){const s="getMyFollowingList";if(!this.canIUse(a.FOLLOW))return this.noUse(s);const o=e||this.FIRST_PAGE_INDEX;if(this._myFollowingList.has(o)){var{resultList:t,nextCursor:n,lastUpdateTime:i}=this._myFollowingList.get(o);if(Date.now()-i(this._myFollowingList.set(o,{...t,lastUpdateTime:Date.now()}),lt.l(`${this._n}.${s} nextCursor:${e} from remote.`),ct(t)))}getMutualFollowersList(e=""){const s="getMutualFollowersList";if(!this.canIUse(a.FOLLOW))return this.noUse(s);const o=e||this.FIRST_PAGE_INDEX;if(this._myMutualFollowersList.has(o)){var{resultList:t,nextCursor:n,lastUpdateTime:i}=this._myMutualFollowersList.get(o);if(Date.now()-i(this._myMutualFollowersList.set(o,{...t,lastUpdateTime:Date.now()}),lt.l(`${this._n}.${s} nextCursor:${e} from remote.`),ct(t)))}_getFollowList(t,e){const n=new Ft("_getFollowList");return n.setMessage(`nextCursor:${t} type:`+e),this.req({P:Lt,data:{fromAccount:this.getMyUserID(),count:this.DEFAULT_COUNT,nextCursor: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(),lt.e(this._n+"._getFollowList failed. error:",t),Tt(t)))}_handleProfileItem(t){const e={};return t.forEach(t=>{switch(t.tag){case D:e.nick=t.value;break;case v:e.gender=t.value;break;case R:e.birthday=t.value;break;case b:e.location=t.value;break;case G:e.selfSignature=t.value;break;case x:e.allowType=t.value;break;case k:e.language=t.value;break;case q:e.avatar=t.value;break;case $:e.messageSettings=t.value;break;case B:e.adminForbidType=t.value;break;case W:e.level=t.value;break;case j:e.role=t.value;break;default:e[t.tag]=t.value}}),e}getUserFollowInfo(t){if(!this.canIUse(a.FOLLOW))return this.noUse("getUserFollowInfo");let e=t,s=!1;J(t)&&(e=[this.getMyUserID()],s=!0);const n=this._n+".getUserFollowInfo",o=`userIDList:${e.length} isGetMyFollowInfo:`+s,i=new Ft("getUserFollowInfo");return i.setMessage(o),lt.l(n+" "+o),this.req({P:At,data:{fromAccount:this.getMyUserID(),userIDList:e}}).then(t=>{i.end(),lt.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})}),ct(o)}).catch(t=>(i.setError(t).end(),lt.e(n+" failed. error:",t),Tt(t)))}checkFollowType(t){if(!this.canIUse(a.FOLLOW))return this.noUse("checkFollowType");100{var e;this._followType.has(t)?(e=this._followType.get(t),n.push({userID:t,followType:e})):i.push(t)}),lt.l(`${e} from local count:${n.length}, from remote count:${i.length}.`),0===i.length?pt(n):this.req({P:Mt,data:{fromAccount:this.getMyUserID(),userIDList:i}}).then(t=>{o.end(),lt.l(e+" ok.");var{resultList:t=[]}=t.data;return t.forEach(t=>{var{userID:t,followType:e}=t;this._setFollowType(t,e),n.push({userID:t,followType:e})}),ct(n)}).catch(t=>(o.setError(t).end(),lt.e(e+" failed. error:",t),Tt(t)))}_setFollowType(t,e){this._followType.set(t,e)}_clearFollowList(t){J(t)?(this._myFollowersList.clear(),this._myFollowingList.clear(),this._myMutualFollowersList.clear()):t!==Nt.FOLLOWERS?t!==Nt.FOLLOWING?t===Nt.MUTUAL&&this._myMutualFollowersList.clear():this._myFollowingList.clear():this._myFollowersList.clear()}reset(){lt.l(this._n+".reset"),this._clearFollowList(),this._followType.clear()}}export{Pt as default};