1 line
42 KiB
JavaScript
1 line
42 KiB
JavaScript
"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<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 ye(){return!L&&!F}let Fe=0;function Ae(){return ye()?"%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){ye()?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;Fe<=-1&&(e=this.arguments2String(arguments),this._exec("debug",e))},l:function(){var e;Fe<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},log:function(){var e;Fe<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},i:function(){var e;Fe<=1&&(e=this.arguments2String(arguments),this._exec("info",e))},w:function(){var e;Fe<=2&&(e=this.arguments2String(arguments),this._exec("warn",e))},e:function(){var e;Fe<=3&&(e=this.arguments2String(arguments),this._exec("error",e))},setLevel:function(e){e<4&&this._exec("log","set level from "+Fe+" to "+e),Fe=e},getLevel:function(){return Fe}};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};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 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<e&&(this.userIDList.splice(e,1),this.count=this.userIDList.length)}}class Ft{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 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<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 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}; |