"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"}},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,y="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,F=h||f||_||m||g||y||M,A=("undefined"!=typeof uni||"undefined"!=typeof window)&&!F,I=(f?qq:_?tt:m?swan:g?my:h?wx:y?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":y&&(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{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",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{n.push(e.key)});for(let e=0,t=r.length;e{e.key===i&&(e.value=s)}):this.friendCustomField.push({key:i,value:s});else if(-1{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{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{var t=this._friendMap.get(e);0{var t;this._friendMap.has(e)?(t=this._friendMap.get(e),Date.now()-t.timestamp{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{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{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{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{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 yt{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{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 yt(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 yt({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{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 Ft(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};