isdata-customer-sdk 0.1.57 → 0.1.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +0 -5937
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +132 -6069
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +4 -4
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +2 -6
- package/dist/index.247.js +0 -12
- package/dist/index.247.js.map +0 -1
- package/dist/index.260.js +0 -17
- package/dist/index.260.js.map +0 -1
- package/dist/index.802.js +0 -17
- package/dist/index.802.js.map +0 -1
- package/dist/index.995.js +0 -17
- package/dist/index.995.js.map +0 -1
- package/dist/index.umd.247.js +0 -12
- package/dist/index.umd.247.js.map +0 -1
- package/dist/index.umd.260.js +0 -17
- package/dist/index.umd.260.js.map +0 -1
- package/dist/index.umd.802.js +0 -17
- package/dist/index.umd.802.js.map +0 -1
- package/dist/index.umd.995.js +0 -17
- package/dist/index.umd.995.js.map +0 -1
- package/dist/index.umd.min.247.js +0 -2
- package/dist/index.umd.min.247.js.map +0 -1
- package/dist/index.umd.min.260.js +0 -2
- package/dist/index.umd.min.260.js.map +0 -1
- package/dist/index.umd.min.802.js +0 -2
- package/dist/index.umd.min.802.js.map +0 -1
- package/dist/index.umd.min.995.js +0 -2
- package/dist/index.umd.min.995.js.map +0 -1
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";(("undefined"!==typeof self?self:this)["webpackChunkindex"]=("undefined"!==typeof self?self:this)["webpackChunkindex"]||[]).push([[260],{9260:function(e,t,s){s.r(t),s.d(t,{default:function(){return Gr}});let i={SDK_READY:"sdkStateReady",SDK_NOT_READY:"sdkStateNotReady",SDK_DESTROY:"sdkDestroy",MESSAGE_RECEIVED:"onMessageReceived",ROOM_CUSTOM_DATA_RECEIVED:"onRoomCustomDataReceived",MESSAGE_MODIFIED:"onMessageModified",MESSAGE_REVOKED:"onMessageRevoked",MESSAGE_READ_BY_PEER:"onMessageReadByPeer",MESSAGE_READ_RECEIPT_RECEIVED:"onMessageReadReceiptReceived",MESSAGE_EXTENSIONS_UPDATED:"onMessageExtensionsUpdated",MESSAGE_EXTENSIONS_DELETED:"onMessageExtensionsDeleted",MESSAGE_REACTIONS_UPDATED:"onMessageReactionsUpdated",CONVERSATION_LIST_UPDATED:"onConversationListUpdated",TOTAL_UNREAD_MESSAGE_COUNT_UPDATED:"onTotalUnreadMessageCountUpdated",CONVERSATION_GROUP_LIST_UPDATED:"onConversationGroupListUpdated",CONVERSATION_IN_GROUP_UPDATED:"onConversationInGroupUpdated",GROUP_LIST_UPDATED:"onGroupListUpdated",GROUP_ATTRIBUTES_UPDATED:"groupAttributesUpdated",GROUP_COUNTER_UPDATED:"onGroupCounterUpdated",TOPIC_CREATED:"onTopicCreated",TOPIC_DELETED:"onTopicDeleted",TOPIC_UPDATED:"onTopicUpdated",PROFILE_UPDATED:"onProfileUpdated",USER_STATUS_UPDATED:"onUserStatusUpdated",BLACKLIST_UPDATED:"blacklistUpdated",FRIEND_LIST_UPDATED:"onFriendListUpdated",FRIEND_GROUP_LIST_UPDATED:"onFriendGroupListUpdated",FRIEND_APPLICATION_LIST_UPDATED:"onFriendApplicationListUpdated",MY_FOLLOWERS_LIST_UPDATED:"onMyFollowersListUpdated",MY_FOLLOWING_LIST_UPDATED:"onMyFollowingListUpdated",MUTUAL_FOLLOWERS_LIST_UPDATED:"onMutualFollowersListUpdated",KICKED_OUT:"kickedOut",ERROR:"error",NET_STATE_CHANGE:"netStateChange",ALL_RECEIVE_MESSAGE_OPT_UPDATED:"onAllReceiveMessageOptUpdated"},o={MSG_TEXT:"TIMTextElem",MSG_IMAGE:"TIMImageElem",MSG_SOUND:"TIMSoundElem",MSG_AUDIO:"TIMSoundElem",MSG_FILE:"TIMFileElem",MSG_FACE:"TIMFaceElem",MSG_VIDEO:"TIMVideoFileElem",MSG_GEO:"TIMLocationElem",MSG_LOCATION:"TIMLocationElem",MSG_GRP_TIP:"TIMGroupTipElem",MSG_GRP_SYS_NOTICE:"TIMGroupSystemNoticeElem",MSG_CUSTOM:"TIMCustomElem",MSG_MERGER:"TIMRelayElem",MSG_PRIORITY_HIGH:"High",MSG_PRIORITY_NORMAL:"Normal",MSG_PRIORITY_LOW:"Low",MSG_PRIORITY_LOWEST:"Lowest",CONV_C2C:"C2C",CONV_GROUP:"GROUP",CONV_TOPIC:"TOPIC",CONV_SYSTEM:"@TIM#SYSTEM",CONV_AT_ME:1,CONV_AT_ALL:2,CONV_AT_ALL_AT_ME:3,CONV_MARK_TYPE_STAR:1,CONV_MARK_TYPE_UNREAD:2,CONV_MARK_TYPE_FOLD:4,CONV_MARK_TYPE_HIDE:8,GRP_PRIVATE:"Private",GRP_WORK:"Private",GRP_PUBLIC:"Public",GRP_CHATROOM:"ChatRoom",GRP_MEETING:"ChatRoom",GRP_AVCHATROOM:"AVChatRoom",GRP_COMMUNITY:"Community",GRP_ROOM:"Room",GRP_LIVE:"Live",GRP_MBR_ROLE_OWNER:"Owner",GRP_MBR_ROLE_ADMIN:"Admin",GRP_MBR_ROLE_MEMBER:"Member",GRP_MBR_ROLE_CUSTOM:"Custom",GRP_TIP_MBR_JOIN:1,GRP_TIP_MBR_QUIT:2,GRP_TIP_MBR_KICKED_OUT:3,GRP_TIP_MBR_SET_ADMIN:4,GRP_TIP_MBR_CANCELED_ADMIN:5,GRP_TIP_GRP_PROFILE_UPDATED:6,GRP_TIP_MBR_PROFILE_UPDATED:7,GRP_TIP_BAN_AVCHATROOM_MEMBER:10,GRP_TIP_UNBAN_AVCHATROOM_MEMBER:11,MSG_REMIND_ACPT_AND_NOTE:"AcceptAndNotify",MSG_REMIND_ACPT_NOT_NOTE:"AcceptNotNotify",MSG_REMIND_DISCARD:"Discard",RECEIVE_WITH_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT:"AcceptNotNotifyExceptAt",NOT_RECEIVE_MSG_EXCEPT_AT:"NotReceiveMsgExceptAt",GENDER_UNKNOWN:"Gender_Type_Unknown",GENDER_FEMALE:"Gender_Type_Female",GENDER_MALE:"Gender_Type_Male",KICKED_OUT_MULT_ACCOUNT:"multipleAccount",KICKED_OUT_MULT_DEVICE:"multipleDevice",KICKED_OUT_USERSIG_EXPIRED:"userSigExpired",KICKED_OUT_REST_API:"REST_API_Kick",ALLOW_TYPE_ALLOW_ANY:"AllowType_Type_AllowAny",ALLOW_TYPE_NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_TYPE_DENY_ANY:"AllowType_Type_DenyAny",FORBID_TYPE_NONE:"AdminForbid_Type_None",FORBID_TYPE_SEND_OUT:"AdminForbid_Type_SendOut",JOIN_OPTIONS_FREE_ACCESS:"FreeAccess",JOIN_OPTIONS_NEED_PERMISSION:"NeedPermission",JOIN_OPTIONS_DISABLE_APPLY:"DisableApply",JOIN_STATUS_SUCCESS:"JoinedSuccess",JOIN_STATUS_ALREADY_IN_GROUP:"AlreadyInGroup",JOIN_STATUS_WAIT_APPROVAL:"WaitAdminApproval",INVITE_OPTIONS_DISABLE_INVITE:"DisableInvite",INVITE_OPTIONS_NEED_PERMISSION:"NeedPermission",INVITE_OPTIONS_FREE_ACCESS:"FreeAccess",GRP_PROFILE_OWNER_ID:"ownerID",GRP_PROFILE_CREATE_TIME:"createTime",GRP_PROFILE_LAST_INFO_TIME:"lastInfoTime",GRP_PROFILE_MEMBER_NUM:"memberNum",GRP_PROFILE_MAX_MEMBER_NUM:"maxMemberNum",GRP_PROFILE_JOIN_OPTION:"joinOption",GRP_PROFILE_INVITE_OPTION:"inviteOption",GRP_PROFILE_INTRODUCTION:"introduction",GRP_PROFILE_NOTIFICATION:"notification",GRP_PROFILE_MUTE_ALL_MBRS:"muteAllMembers",SNS_ADD_TYPE_SINGLE:"Add_Type_Single",SNS_ADD_TYPE_BOTH:"Add_Type_Both",SNS_DELETE_TYPE_SINGLE:"Delete_Type_Single",SNS_DELETE_TYPE_BOTH:"Delete_Type_Both",SNS_APPLICATION_TYPE_BOTH:"Pendency_Type_Both",SNS_APPLICATION_SENT_TO_ME:"Pendency_Type_ComeIn",SNS_APPLICATION_SENT_BY_ME:"Pendency_Type_SendOut",SNS_APPLICATION_AGREE:"Response_Action_Agree",SNS_APPLICATION_AGREE_AND_ADD:"Response_Action_AgreeAndAdd",SNS_CHECK_TYPE_BOTH:"CheckResult_Type_Both",SNS_CHECK_TYPE_SINGLE:"CheckResult_Type_Single",SNS_TYPE_NO_RELATION:"CheckResult_Type_NoRelation",SNS_TYPE_A_WITH_B:"CheckResult_Type_AWithB",SNS_TYPE_B_WITH_A:"CheckResult_Type_BWithA",SNS_TYPE_BOTH_WAY:"CheckResult_Type_BothWay",NET_STATE_CONNECTED:"connected",NET_STATE_CONNECTING:"connecting",NET_STATE_DISCONNECTED:"disconnected",MSG_AT_ALL:"__kImSDK_MesssageAtALL__",READ_ALL_C2C_MSG:"readAllC2CMessage",READ_ALL_GROUP_MSG:"readAllGroupMessage",READ_ALL_MSG:"readAllMessage",USER_STATUS_UNKNOWN:0,USER_STATUS_ONLINE:1,USER_STATUS_OFFLINE:2,USER_STATUS_UNLOGINED:3,IOS_OFFLINE_PUSH_NO_SOUND:"push.no_sound",IOS_OFFLINE_PUSH_DEFAULT_SOUND:"default"};class n{constructor(){this.cache=[],this.options=null}use(e){if("function"!=typeof e)throw"middleware must be a function";return this.cache.push(e),this}next(e){if(this.middlewares&&0<this.middlewares.length)return this.middlewares.shift().call(this,this.options,this.next.bind(this))}run(e){return this.middlewares=this.cache.map((function(e){return e})),this.options=e,this.next()}}class r{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}}let a,l,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:{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"}}},c={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},_="1.7.3",u=537048168,h="CHINA",p="OVERSEA",g="SINGAPORE",m="KOREA",M="GERMANY",f="IND",I="JPN",C="USA",v="INDONESIA",T={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=h){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",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"}},y={SEARCH_GRP_SNS:new r(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new r(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new r(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new r(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new r(0,Math.pow(2,6)).toString(),USER_STATUS:new r(0,Math.pow(2,7)).toString(),CONV_MARK:new r(0,Math.pow(2,9)).toString(),CONV_GROUP:new r(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new r(0,Math.pow(2,11)).toString(),MSG_EXT:new r(0,Math.pow(2,13)).toString(),GRP_COUNTER:new r(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new r(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new r(Math.pow(2,7)).toString(),PLUGIN_CS:new r(Math.pow(2,8)).toString(),PLUGIN_PUSH:new r(Math.pow(2,9)).toString(),PLUGIN_BOT:new r(Math.pow(2,10)).toString(),MSG_REACTION:new r(Math.pow(2,16)).toString(),FOLLOW:new r(Math.pow(2,20)).toString()},E="c2c_text_message",S="c2c_custom_message",D="group_text_message",R="group_custom_message",L="user_profile",A="group_profile",O=(T.HOST.setCurrent(h),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)),N=O&&"function"==typeof wx.createGamePortal,P="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),U="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),G="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),k="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),w="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,b="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,F=O&&"object"==typeof wx.miniapp,q="undefined"!=typeof uni,x=O||P||U||G||k||b||w,V="undefined"==typeof window&&!x&&"undefined"!=typeof s.g&&void 0!==s.g.NativeScriptGlobals,B="undefined"!=typeof s.g&&(void 0!==s.g.nativeModuleProxy||void 0!==s.g.ReactNative),K="undefined"!=typeof uni?!x:"undefined"!=typeof window&&!x&&!B,H=P?qq:U?tt:G?swan:k?my:O?wx:b?uni:w?jd:{},$=K&&window&&window.navigator&&window.navigator.userAgent||"",W=/(micromessenger|webbrowser)/i.test($),Y=function(){let e="WEB";return W?e="WEB":P?e="QQ_MP":U?e="TT_MP":G?e="BAIDU_MP":k?e="ALI_MP":O?e=F?"DONUT_NATIVE_APP":"WX_MP":b?e="UNI_NATIVE_APP":V?e="NS_NATIVE_APP":B&&(e="RN_NATIVE_APP"),c[e]}(),z=/iPad/i.test($),j=/iPhone/i.test($)&&!z,J=/iPod/i.test($),X=j||z||J,Z=function(){var e=$.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Q=/Android/i.test($),ee=function(){var e,t,s=$.match(/Android (\d+)(?:\.(\d+))?(?:\.(\d+))*/i);return s?(e=s[1]&&parseFloat(s[1]),t=s[2]&&parseFloat(s[2]),e&&t?parseFloat(s[1]+"."+s[2]):e||null):null}(),te=/Edge/i.test($),se=!te&&/Chrome/i.test($),ie=/MSIE/.test($)||-1<$.indexOf("Trident")&&-1<$.indexOf("rv:11.0"),oe=function(){var e=/MSIE\s(\d+)\.\d/.exec($);let t=e&&parseFloat(e[1]);return!t&&/Trident\/7.0/i.test($)&&/rv:11.0/.test($)?11:t}(),ne=/Safari/i.test($)&&!se&&!Q&&!te,re=/Windows/i.test($),ae=/MAC OS X/i.test($),le=K&&"undefined"!=typeof Worker&&!ie,de=Q||X,ce=K&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,_e=function(){var e;return"undefined"!=typeof window&&void 0!==window.navigator&&(e=window.navigator.standalone,!(!X||e||ne))}(),ue=(a="undefined"!=typeof console?console:"undefined"!=typeof s.g&&s.g.console?s.g.console:"undefined"!=typeof window&&window.console?window.console:{},function(){}),he=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],pe=he.length;for(;pe--;)l=he[pe],console[l]||(a[l]=ue);var ge=a;let me=0,Me=function(){return(new Date).getTime()+me},fe=function(){me=0},Ie=function(){return Math.floor(Me()/1e3)},Ce=0;function ve(){return Rt()?"%c Chat %c":"Chat"}function Te(){var e;return(e=new Date).setTime(Me()),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())}let ye={arguments2String(e){let t="";if(1===e.length)t=e[0];else for(let s=0,o=e.length;s<o;s++){if(Ke(e[s]))try{t+=$e(e[s])?JSON.stringify(e[s],["message","code"]):JSON.stringify(e[s])}catch(i){t+=i?i.message:"";break}else t+=e[s];t+=" "}return t},_exec(e,t){Rt()?ge[e](ve(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",Te(),t):ge[e](`${ve()} ${Te()} `+t)},d:function(){var e;Ce<=-1&&(e=this.arguments2String(arguments),this._exec("debug",e))},l:function(){var e;Ce<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},log:function(){var e;Ce<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},i:function(){var e;Ce<=1&&(e=this.arguments2String(arguments),this._exec("info",e))},w:function(){var e;Ce<=2&&(e=this.arguments2String(arguments),this._exec("warn",e))},e:function(){var e;Ce<=3&&(e=this.arguments2String(arguments),this._exec("error",e))},setLevel:function(e){e<4&&this._exec("log","set level from "+Ce+" to "+e),Ce=e},getLevel:function(){return Ce}},Ee={JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255},Se={NICK:"Tag_Profile_IM_Nick",GENDER:"Tag_Profile_IM_Gender",BIRTHDAY:"Tag_Profile_IM_BirthDay",LOCATION:"Tag_Profile_IM_Location",SELFSIGNATURE:"Tag_Profile_IM_SelfSignature",ALLOWTYPE:"Tag_Profile_IM_AllowType",LANGUAGE:"Tag_Profile_IM_Language",AVATAR:"Tag_Profile_IM_Image",MESSAGESETTINGS:"Tag_Profile_IM_MsgSettings",ADMINFORBIDTYPE:"Tag_Profile_IM_AdminForbidType",LEVEL:"Tag_Profile_IM_Level",ROLE:"Tag_Profile_IM_Role"},De="Gender_Type_",Re={UNKNOWN:De+"Unknown",FEMALE:De+"Female",MALE:De+"Male"},Le={NONE:"AdminForbid_Type_None",SEND_OUT:"AdminForbid_Type_SendOut"},Ae={NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_ANY:"AllowType_Type_AllowAny",DENY_ANY:"AllowType_Type_DenyAny"},Oe="@TGS#_",Ne="@TOPIC#_",Pe=Object.prototype.hasOwnProperty;function Ue(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(xe(e)){for(var t in e)if(Pe.call(e,t))return!1;return!0}return!!(Ge(e)||ke(e)||we(e))&&0===e.size}let Ge=function(e){return"map"===Ye(e)},ke=function(e){return"set"===Ye(e)},we=function(e){return"file"===Ye(e)},be=function(e){return null!==e&&("number"==typeof e&&!isNaN(+e)||"object"==typeof e&&e.constructor===Number)},Fe=function(e){return"string"==typeof e},qe=function(e){return null!==e&&"object"==typeof e},xe=function(e){if("object"!=typeof e||null===e)return!1;if(e=Object.getPrototypeOf(e),null===e)return!0;let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return e===t},Ve=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"array"===Ye(e)},Be=function(e){return void 0===e},Ke=function(e){return Ve(e)||qe(e)},He=function(e){return"function"==typeof e},$e=function(e){return e instanceof Error},We=function(e){return"filelist"===Ye(e)},Ye=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},ze=function(e){return"string"==typeof e&&(e=e[0],!/[^a-zA-Z0-9]/.test(e))},je=(Date.now||(Date.now=function(){return(new Date).getTime()}),function(e,t,s,i){if(!Ke(e)||!Ke(t))return 0;let o=0;var n,r=Object.keys(t);for(let a=0,l=r.length;a<l;a++)if(n=r[a],!(Be(t[n])||s&&s.includes(n)))if(Ke(e[n])&&Ke(t[n]))o+=je(e[n],t[n],s,i);else{if(i&&i.includes(t[n]))continue;e[n]!==t[n]&&(e[n]=t[n],o+=1)}return o}),Je=function(e,t){var s,i,o=new Map;for([s,i]of e.entries())i&&o.set(s,t?JSON.stringify(i):JSON.parse(JSON.stringify(i)));return o},Xe=function(e){if(0===e.length)return 0;let t,s=0,i=0;for(var o="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";void 0!==e[s];)t=e[s++].charCodeAt[s]<=255?1:!1===o?3:2,i+=t;return i},Ze=function(e){return e=e||99999999,Math.round(Math.random()*e)},Qe="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",et=Qe.length,st=function(e,t){for(var s in e)if(e[s]===t)return!0;return!1},it={},ot=function(e){return-1===e.indexOf("http://")||-1===e.indexOf("https://")?"https://"+e:e.replace(/https|http/,"https")};function nt(e,t){if(!Ve(e)||!Ve(t))return!1;let s=!1;return t.forEach((({key:t,value:i})=>{var o=e.find((e=>e.key===t));o?o.value!==i&&(o.value=i,s=!0):(e.push({key:t,value:i}),s=!0)})),s}function rt(e){var t;if(xe(e)&&xe(e.webhookInfo))return t=[],e.webhookInfo.disableCloudMessagePreHook&&t.push("ForbidBeforeSendMsgCallback"),e.webhookInfo.disableCloudMessagePostHook&&t.push("ForbidAfterSendMsgCallback"),0!==t.length?t:void 0}let at=e=>e===o.GRP_AVCHATROOM,lt=({type:e,groupID:t})=>e===o.GRP_COMMUNITY||(""+t).startsWith(Oe)&&!(""+t).includes(Ne),dt=e=>(""+e).startsWith(Oe)&&(""+e).includes(Ne),ct=e=>Fe(e)&&e.slice(0,3)===o.CONV_C2C,_t=e=>Fe(e)&&e.slice(0,5)===o.CONV_GROUP,ut=e=>Fe(e)&&e===o.CONV_SYSTEM;function ht(e,t){let s={};return Object.keys(e).forEach((i=>{s[i]=t(e[i],i)})),s}function pt(e){return B?Promise.resolve({width:0,height:0}):x?new Promise(((t,s)=>{H.getImageInfo({src:e,success(e){t({width:e.width,height:e.height})},fail(){t({width:0,height:0})}})})):ie&&9===oe?Promise.resolve({width:0,height:0}):new Promise(((t,s)=>{let i=new Image;i.onload=function(){t({width:this.width,height:this.height}),i=null},i.onerror=function(){t({width:0,height:0}),i=null},i.src=e}))}function gt(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return""+(e()+e())+e()+e()+e()+e()+e()+e()}function mt(){let e="unknown";if(ae&&(e="mac"),re&&(e="windows"),X&&(e="ios"),Q&&(e="android"),x)try{var t=H.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(e){}return e}function Mt(e,t){e=e.split("."),t=t.split(".");let s=Math.max(e.length,t.length);for(;e.length<s;)e.push("0");for(;t.length<s;)t.push("0");for(let i=0;i<s;i++){let s=parseInt(e[i]),o=parseInt(t[i]);if(s>o)return 1;if(s<o)return-1}return 0}function ft(e){let{originUrl:t,originWidth:s,originHeight:i,min:o=198}=e,n=parseInt(s),r=parseInt(i),a={url:void 0,width:0,height:0};if((n<=r?n:r)<=o)a.url=t,a.width=n,a.height=r;else{r<=n?(a.width=Math.ceil(n*o/r),a.height=o):(a.width=o,a.height=Math.ceil(r*o/n));let e=t&&-1<t.indexOf("?")?t+"&":t+"?";a.url=198===o?e+"imageView2/3/w/198/h/198":e+"imageView2/3/w/720/h/720"}if(Be(t)){let{url:e,...t}=a;return t}return a}function It(e){var t=e[2];e[2]=e[1],e[1]=t;for(let s=0;s<e.length;s++)e[s].setType(s)}function Ct(e){return e=e.servcmd,e.slice(e.indexOf(".")+1)}function vt(e,t){return Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)}function Tt(e,t){return e.includes(t)}function yt(e,t){return e.includes(t)}function Et(e){return e.split(Ne)[0]}let St=function(e,t,s){if(Be(t))return"";switch(e){case o.MSG_TEXT:return t.text;case o.MSG_IMAGE:return s?"[Image]":"[图片]";case o.MSG_LOCATION:return s?"[Location]":"[位置]";case o.MSG_AUDIO:return s?"[Voice]":"[语音]";case o.MSG_VIDEO:return s?"[Video]":"[视频]";case o.MSG_FILE:return s?"[File]":"[文件]";case o.MSG_CUSTOM:return s?"[Custom Messages]":"[自定义消息]";case o.MSG_GRP_TIP:return s?"[Group Notification]":"[群提示消息]";case o.MSG_GRP_SYS_NOTICE:return s?"[Group System Message]":"[群系统通知]";case o.MSG_FACE:return s?"[Animated Sticker]":"[动画表情]";case o.MSG_MERGER:return s?"[Chat Record]":"[聊天记录]";default:return""}};function Dt(e){var t=[];if(Fe(e)){var s=e.length;if(0!==s)for(let i=s-1;0<=i;i--)"1"===e[i]&&t.push(Math.pow(2,s-i-1))}return t}function Rt(){return!ie&&!x}function Lt(e){return"the length of userIDList cannot exceed "+e}function At(e,t=!0,s=!0){var i=Date.now();return t?s?i-e+" ms":Math.round((i-e)/1e3)+" s":s?i-e:Math.round((i-e)/1e3)}function Ot(e){let t=!!(e&&1<e);return t}function Nt(e,t,s){if(void 0===t)return!0;let i=!0;if(xe(t))Object.keys(t).forEach((o=>{var n=1===e.length?e[0][o]:void 0;i=!!Pt(n,t[o],s,o)&&i}));else if(Ve(t))for(let o=0;o<t.length;o++)i=!!Pt(e[o],t[o],s,t[o].name)&&i;if(i)return i;throw new Error("Params validate failed.")}function Pt(e,t,s,i){if(void 0===t)return!0;let o=!0;var n,r;return t.required&&Ue(e)&&(ye.e(`[${s}] Missing required params: "${i}".`),o=!1),Ue(e)||(n=Ye(e))===(r=t.type.toLowerCase())||"asyncfunction"===n&&"function"===r||(ye.e(`[${s}] Invalid params: type check failed for "${i}". Expected ${t.type}.`),o=!1),t.validator&&!t.validator(e,s,i)&&(ye.e(`[${s}] Invalid params: custom validator check failed for "${i}".`),o=!1),o}let Ut="unSend",Gt="success",kt="fail",wt="notStart",bt="pending",Ft="resolved",qt="rejected",xt=function(e){return!(!e||!(ct(e)||_t(e)||ut(e))&&((e=fs("InvalidConversationID",e))&&ye.w(e),1))},Vt=function(e){""!==e.desc&&""!==fs("API_REFER")&&ye.w(`[${e.api}] | ${e.paramName} | ${e.desc}, `+fs("API_REFER")+e.api)},Bt=function(){return fs("StringRequiredLog")},Kt=function(e){return fs("NonEmptyStringRequiredLog",e)},Ht=function(){return fs("NumberRequiredLog")},$t=function(){return fs("UndefinedNotAllowedLog")},Wt=function(){return fs("FileRequiredLog")},Yt=function(){return fs("FunctionRequiredLog")},zt=function(){return fs("ArrayRequiredLog")},jt=function(){return fs("NonEmptyArrayLog")},Jt=function(){return fs("CallbackMissingLog")},Xt=function(){return fs("PositiveIntegerRequiredLog")},Zt=function(e,t){return fs("StringNotLongerThanLog",e,t)},Qt=function(e,t){return fs("NumberGreaterThanLog",e,t)},es=function(e,t){return fs("NumberGreaterOrEqualLog",e,t)},ts=function(e){return fs("KeyValueStringRequiredLog",e)},ss=function(){return fs("PlainObjectRequiredLog")},is=function(){return fs("NonEmptyContentRequiredLog")},os=function(){return fs("FileNotSelectedLog")},ns=function(){return fs("MessageInstanceRequiredLog")},rs=function(){return fs("NonAnonymousFunctionLog")},as=function(){return fs("MessageExtensionNotAvailableLog")},ls=function(){return fs("MessageReactionRequiredLog")},ds=function(e,t){return fs("ContainsUnsupportedTypeLog",e,t)},cs={type:"String",required:!0},_s={type:"Array",required:!0},us={type:"Object",required:!0},hs={type:"Boolean",required:!0},ps={type:"number",required:!0},gs=function(e,t,s,{allowUndefined:i,allowEmpty:o,maxLength:n}){return Be(e)?!!i||(Vt({api:t,paramName:s,desc:$t()}),!1):Ve(e)?!(0===e.length&&(Vt({api:t,paramName:s,desc:jt()}),!o)||n&&e.length>n&&(Vt({api:t,paramName:s,desc:(i=s,o=n,fs("MaximumArrayLengthLog",i,o))}),1)):(Vt({api:t,paramName:s,desc:zt()}),!1)},ms=function(e,t,s,{allowUndefined:i,min:o,max:n}){return Be(e)?!!i||(Vt({api:t,paramName:s,desc:$t()}),!1):be(e)?be(o)&&e<o?(Vt({api:t,paramName:s,desc:0===o?es(s,o):Qt(s,o-1)}),!1):!(be(n)&&n<e&&(Vt({api:t,paramName:s,desc:(i=s,o=n,fs("MaximumNumberLog",i,o))}),1)):(Vt({api:t,paramName:s,desc:Ht()}),!1)},Ms={keywordListForMsg:{type:"Array",required:!1,validator:(e,t,s)=>gs(e,t,s,{allowUndefined:!0,allowEmpty:!0,maxLength:5})},keywordListExceptMsg:{type:"Array",required:!0,validator:(e,t,s)=>gs(e,t,s,{allowUndefined:!1,allowEmpty:!1,maxLength:5})},keywordListMatchType:{type:"String",required:!1,validator:(e,t,s)=>!e||"or"===e||"and"===e||Vt({api:t,paramName:s,desc:e+" is invalid match type"})},cursor:{type:"String",required:!1},count:{type:"Number",required:!1,validator:(e,t,s)=>ms(e,t,s,{allowUndefined:!0,min:1,max:100})},groupTypeList:{type:"Array",required:!1,validator:(e,t,s)=>{if(!e)return!0;if(!gs(e,t,s,{allowUndefined:!0,allowEmpty:!0}))return!1;let i=[o.GRP_PUBLIC,o.GRP_COMMUNITY,o.GRP_WORK,o.GRP_MEETING];return!(0<e.filter((e=>-1===i.indexOf(e))).length&&(Vt({api:t,paramName:s,desc:ds(s,"group")}),1))}}},fs=null,Is={hookGetAPITips:function(e){fs=e},login:{userID:cs,userSig:cs},addToBlacklist:{userIDList:_s},removeFromBlacklist:{userIDList:_s},on:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Vt({api:t,paramName:s,desc:Kt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Vt({api:t,paramName:s,desc:Yt()}),!1):(""===e.name&&Vt({api:t,paramName:s,desc:rs()}),!0)}],once:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Vt({api:t,paramName:s,desc:Kt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Vt({api:t,paramName:s,desc:Yt()}),!1):(""===e.name&&Vt({api:t,paramName:s,desc:rs()}),!0)}],off:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Vt({api:t,paramName:s,desc:Kt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Vt({api:t,paramName:s,desc:Yt()}),!1):(""===e.name&&Vt({api:t,paramName:s,desc:rs()}),!0)}],sendMessage:[{name:"message",...us}],setMessageExtensions:[{name:"message",...us,validator:(e,t,s)=>e.status===Gt&&!0===e.isSupportExtension||(Vt({api:t,paramName:s,desc:as()}),!1)},{name:"extensions",..._s}],getMessageExtensions:[{name:"message",...us,validator:(e,t,s)=>e.status===Gt&&!0===e.isSupportExtension||(Vt({api:t,paramName:s,desc:as()}),!1)}],deleteMessageExtensions:[{name:"message",...us,validator:(e,t,s)=>e.status===Gt&&!0===e.isSupportExtension||(Vt({api:t,paramName:s,desc:as()}),!1)}],addMessageReaction:[{name:"message",...us,validator:(e,t,s)=>e.status===Gt||(Vt({api:t,paramName:s,desc:ls()}),!1)},{name:"reactionID",...cs}],removeMessageReaction:[{name:"message",...us,validator:(e,t,s)=>e.status===Gt||(Vt({api:t,paramName:s,desc:ls()}),!1)},{name:"reactionID",...cs}],getMessageReactions:{messageList:{..._s}},getAllUserListOfMessageReaction:{message:{...us,validator:(e,t,s)=>e.status===Gt||(Vt({api:t,paramName:s,desc:ls()}),!1)},reactionID:{...cs},nextSeq:{type:"Number"},count:{type:"Number"}},getMessageList:{conversationID:{...cs,validator:e=>xt(e)},nextReqMessageID:{type:"String"},count:{type:"Number",validator:(e,t,s)=>!(!Be(e)&&!/^[1-9][0-9]*$/.test(e)&&(Vt({api:t,paramName:s,desc:Xt()}),1))}},getMessageListHopping:{conversationID:{...cs,validator:e=>xt(e)},sequence:{type:"Number"},time:{type:"Number"},direction:{type:"Number",validator:(e,t,s)=>!(!Be(e)&&0!==e&&1!==e&&(Vt({api:t,paramName:s,desc:fs("0Or1RequiredLog")}),1))},count:{type:"Number",validator:(e,t,s)=>!(!Be(e)&&!/^[1-9][0-9]*$/.test(e)&&(Vt({api:t,paramName:s,desc:Xt}),1))}},setMessageRead:{conversationID:{...cs,validator:e=>xt(e)}},setAllMessageRead:{scope:{type:"String",required:!1,validator:(e,t,s)=>!e||-1!==[o.READ_ALL_C2C_MSG,o.READ_ALL_GROUP_MSG,o.READ_ALL_MSG].indexOf(e)||(Vt({api:t,paramName:s,desc:fs("ValidScopeRequired")}),!1)}},getConversationProfile:[{name:"conversationID",...cs,validator:e=>xt(e)}],clearHistoryMessage:[{name:"conversationID",...cs,validator:e=>xt(e)}],pinConversation:{conversationID:{...cs,validator:e=>xt(e)},isPinned:{...hs}},setConversationDraft:{conversationID:{...cs,validator:e=>xt(e)},draftText:{type:"String",validator:(e,t,s)=>!!Fe(e)||(Vt({api:t,paramName:s,desc:Bt()}),!1)}},setConversationCustomData:{conversationIDList:{..._s},customData:{type:"String",validator:(e,t,s)=>Fe(e)?!(256<e.length&&(Vt({api:t,paramName:s,desc:Zt(s,256)}),1)):(Vt({api:t,paramName:s,desc:Bt()}),!1)}},markConversation:{conversationIDList:{..._s},markType:{type:"number",validator:(e,t,s)=>be(e)?e<=0?(Vt({api:t,paramName:s,desc:Qt(s,0)}),!1):!(e>=Math.pow(2,64)&&(Vt({api:t,paramName:s,desc:(e=s,fs("NumberLessThanLog",e,"Math.pow(2,64)"))}),1)):(Vt({api:t,paramName:s,desc:Ht()}),!1)},enableMark:{...hs}},createConversationGroup:{conversationIDList:{..._s},groupName:{...cs,validator:(e,t,s)=>!(!e||32<e.length&&(Vt({api:t,paramName:s,desc:Zt(s,32)}),1))}},deleteConversationGroup:[{name:"groupName",...cs}],renameConversationGroup:{oldName:{...cs},newName:{...cs,validator:(e,t,s)=>!(!e||32<e.length&&(Vt({api:t,paramName:s,desc:Zt(s,32)}),1))}},addConversationsToGroup:{conversationIDList:{..._s},groupName:{...cs}},deleteConversationsFromGroup:{conversationIDList:{..._s},groupName:{...cs}},getGroupList:{groupProfileFilter:{type:"Array"}},getGroupProfile:{groupID:cs,groupCustomFieldFilter:{type:"Array"},memberCustomFieldFilter:{type:"Array"}},getGroupProfileAdvance:{groupIDList:_s},createGroup:{name:cs},joinGroup:{groupID:cs,type:{type:"String"},applyMessage:{type:"String"}},quitGroup:[{name:"groupID",...cs}],handleApplication:{message:us,handleAction:cs,handleMessage:{type:"String"}},changeGroupOwner:{groupID:cs,newOwnerID:cs},updateGroupProfile:{groupID:cs,muteAllMembers:{type:"Boolean"}},dismissGroup:[{name:"groupID",...cs}],searchGroupByID:[{name:"groupID",...cs}],getGroupOnlineMemberCount:[{name:"groupID",...cs}],initGroupAttributes:{groupID:cs,groupAttributes:{...us,validator:(e,t,s)=>{let i=!0;return Object.keys(e).forEach((o=>{if(!Fe(e[o]))return Vt({api:t,paramName:s,desc:ts("value")}),i=!1})),i}}},setGroupAttributes:{groupID:cs,groupAttributes:{...us,validator:(e,t,s)=>{let i=!0;return Object.keys(e).forEach((o=>{if(!Fe(e[o]))return Vt({api:t,paramName:s,desc:ts("value")}),i=!1})),i}}},deleteGroupAttributes:{groupID:cs,keyList:{type:"Array",validator:(e,t,s)=>{if(Be(e)||!Ve(e))return Vt({api:t,paramName:s,desc:zt()}),!1;if(Ue(e))return!0;{let i=!0;return e.forEach((e=>{if(!Fe(e))return Vt({api:t,paramName:s,desc:fs("StringArrayRequiredLog")}),i=!1})),i}}}},getGroupAttributes:{groupID:cs,keyList:{type:"Array",validator:(e,t,s)=>{if(Be(e)||!Ve(e))return Vt({api:t,paramName:s,desc:zt()}),!1;if(Ue(e))return!0;{let i=!0;return e.forEach((e=>{if(!Fe(e))return Vt({api:t,paramName:s,desc:ts("key")}),i=!1})),i}}}},setGroupCounters:{groupID:cs,counters:us},increaseGroupCounter:{groupID:cs,key:cs,value:ps},decreaseGroupCounter:{groupID:cs,key:cs,value:ps},getGroupCounters:{groupID:cs},getGroupMemberList:{groupID:cs,count:{type:"Number"}},getGroupMemberProfile:{groupID:cs,userIDList:_s,memberCustomFieldFilter:{type:"Array"}},addGroupMember:{groupID:cs,userIDList:_s},setGroupMemberRole:{groupID:cs,userID:cs,role:cs},setGroupMemberMuteTime:{groupID:cs,userID:cs,muteTime:{type:"Number",validator:e=>0<=e}},setGroupMemberNameCard:{groupID:cs,userID:{type:"String"},nameCard:{type:"String",validator:(e,t,s)=>Fe(e)?(e.length,!0):(Vt({api:t,paramName:s,desc:Bt()}),!1)}},setGroupMemberCustomField:{groupID:cs,userID:{type:"String"},memberCustomField:_s},deleteGroupMember:{groupID:cs},markGroupMemberList:{groupID:cs,markType:{type:"number",validator:(e,t,s)=>be(e)?!(e<1e3&&(Vt({api:t,paramName:s,desc:es(s,1e3)}),1)):(Vt({api:t,paramName:s,desc:Ht()}),!1)},userIDList:{..._s},enableMark:{...hs}},createTextMessage:{to:cs,conversationType:cs,payload:{...us,validator:(e,t,s)=>xe(e)?Fe(e.text)?0!==e.text.length||(Vt({api:t,paramName:"payload.text",desc:is()}),!1):(Vt({api:t,paramName:"payload.text",desc:Bt()}),!1):(Vt({api:t,paramName:s,desc:ss()}),!1)}},createTextAtMessage:{to:cs,conversationType:cs,payload:{...us,validator:(e,t,s)=>xe(e)?Fe(e.text)?0===e.text.length?(Vt({api:t,paramName:"payload.text",desc:is()}),!1):!(e.atUserList&&!Ve(e.atUserList)&&(Vt({api:t,paramName:"payload.atUserList",desc:zt()}),1)):(Vt({api:t,paramName:"payload.text",desc:Bt()}),!1):(Vt({api:t,paramName:s,desc:ss()}),!1)}},createCustomMessage:{to:cs,conversationType:cs,payload:{...us,validator:(e,t,s)=>xe(e)?e.data&&!Fe(e.data)?(Vt({api:t,paramName:"payload.data",desc:Bt()}),!1):e.description&&!Fe(e.description)?(Vt({api:t,paramName:"payload.description",desc:Bt()}),!1):!(e.extension&&!Fe(e.extension)&&(Vt({api:t,paramName:"payload.extension",desc:Bt()}),1)):(Vt({api:t,paramName:"payload",desc:ss()}),!1)}},createImageMessage:{to:cs,conversationType:cs,payload:{...us,validator:(e,t,s)=>{if(!xe(e))return Vt({api:t,paramName:s,desc:ss()}),!1;if(Be(e.file))return Vt({api:t,paramName:"payload.file",desc:$t()}),!1;if(K){if(!(e.file instanceof HTMLInputElement||we(e.file)))return xe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(Vt({api:t,paramName:"payload.file",desc:os()}),!1):(Vt({api:t,paramName:"payload.file",desc:Wt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Vt({api:t,paramName:"payload.file",desc:os()}),!1}return!0},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:Jt()}),!0)}}},createAudioMessage:{to:cs,conversationType:cs,payload:{...us,validator:(e,t,s)=>!!xe(e)||(Vt({api:t,paramName:s,desc:ss()}),!1)},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:Jt()}),!0)}},createVideoMessage:{to:cs,conversationType:cs,payload:{...us,validator:(e,t,s)=>{if(!xe(e))return Vt({api:t,paramName:s,desc:ss()}),!1;if(Be(e.file))return Vt({api:t,paramName:"payload.file",desc:$t()}),!1;if(K){if(!(e.file instanceof HTMLInputElement||we(e.file)))return xe(e.file)&&"undefined"!=typeof uni?!!we(e.file.tempFile)||(Vt({api:t,paramName:"payload.file",desc:os()}),!1):(Vt({api:t,paramName:"payload.file",desc:Wt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Vt({api:t,paramName:"payload.file",desc:os()}),!1}return!0}},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:Jt()}),!0)}},createFaceMessage:{to:cs,conversationType:cs,payload:{...us,validator:(e,t,s)=>xe(e)?be(e.index)?!!Fe(e.data)||(Vt({api:t,paramName:"payload.data",desc:Bt()}),!1):(Vt({api:t,paramName:"payload.index",desc:Ht()}),!1):(Vt({api:t,paramName:s,desc:ss()}),!1)}},createFileMessage:{to:cs,conversationType:cs,payload:{...us,validator:(e,t,s)=>{if(!xe(e))return Vt({api:t,paramName:s,desc:ss()}),!1;if(Be(e.file))return Vt({api:t,paramName:"payload.file",desc:$t()}),!1;if(K){if(!(e.file instanceof HTMLInputElement||we(e.file)))return xe(e.file)&&"undefined"!=typeof uni?0!==e.file.tempFilePaths.length&&0!==e.file.tempFiles.length||(Vt({api:t,paramName:"payload.file",desc:os()}),!1):(Vt({api:t,paramName:"payload.file",desc:Wt()}),!1);if(e.file instanceof HTMLInputElement&&0===e.file.files.length)return Vt({api:t,paramName:"payload.file",desc:os()}),!1}return!0}},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:Jt()}),!0)}},createLocationMessage:{to:cs,conversationType:cs,payload:{...us,validator:(e,t,s)=>xe(e)?Fe(e.description)?be(e.longitude)?!!be(e.latitude)||(Vt({api:t,paramName:"payload.latitude",desc:Ht()}),!1):(Vt({api:t,paramName:"payload.longitude",desc:Ht()}),!1):(Vt({api:t,paramName:"payload.description",desc:Bt()}),!1):(Vt({api:t,paramName:s,desc:ss()}),!1)}},createMergerMessage:{to:cs,conversationType:cs,payload:{...us,validator:(e,t,s)=>{if(Ue(e.messageList))return Vt({api:t,paramName:"payload.messageList",desc:jt()}),!1;if(Ue(e.compatibleText))return Vt({api:t,paramName:"payload.compatibleText",desc:Kt("compatibleText")}),!1;let i=!1;return e.messageList.forEach((e=>{e.status===kt&&(i=!0)})),!i||(Vt({api:t,paramName:"payload.messageList",desc:fs("MergeFailedMessageLog")}),!1)}}},revokeMessage:[{name:"message",...us,validator:(e,t,s)=>Ue(e)?(Vt({api:t,paramName:s,desc:ns()}),!1):e.conversationType===o.CONV_SYSTEM?(Vt({api:t,paramName:s,desc:fs("MessageCanBeRevokedDesc")}),!1):!0!==e.isRevoked||(Vt({api:t,paramName:s,desc:fs("MessageRevokedLog")}),!1)}],deleteMessage:[{name:"messageList",..._s,validator:(e,t,s)=>!Ue(e)||(Vt({api:t,paramName:s,desc:jt()}),!1)}],translateText:{sourceTextList:_s,sourceLanguage:cs,targetLanguage:cs},convertVoiceToText:{message:{...us,validator:(e,t,s)=>Ue(e)?(Vt({api:t,paramName:s,desc:ns()}),!1):e.type===o.MSG_AUDIO&&e.status===Gt||(Vt({api:t,paramName:s,desc:fs("AudioMessageRequiredLog")}),!1)}},modifyMessage:[{name:"message",...us,validator:(e,t,s)=>Ue(e)?(Vt({api:t,paramName:s,desc:ns()}),!1):e.conversationType===o.CONV_SYSTEM?(Vt({api:t,paramName:s,desc:fs("MessageCanBeModifiedLog")}),!1):!0!==e._onlineOnlyFlag||(Vt({api:t,paramName:s,desc:fs("OnlineMessageNotSupportLog")}),!1)}],searchCloudMessages:{keywordList:Ms.keywordListForMsg,keywordListMatchType:Ms.keywordListMatchType,cursor:Ms.cursor,senderUserIDList:{type:"Array",required:!1,validator:(e,t,s)=>gs(e,t,s,{allowUndefined:!0,allowEmpty:!0,maxLength:5})},messageTypeList:{type:"Array",required:!1,validator:(e,t,s)=>{if(!e)return!0;if(!gs(e,t,s,{allowUndefined:!0,allowEmpty:!0}))return!1;let i=[o.MSG_TEXT,o.MSG_IMAGE,o.MSG_AUDIO,o.MSG_FILE,o.MSG_VIDEO,o.MSG_LOCATION,o.MSG_CUSTOM,o.MSG_MERGER];return!(0<e.filter((e=>-1===i.indexOf(e))).length&&(Vt({api:t,paramName:s,desc:ds(s,"message")}),1))}},conversationID:{type:"String",required:!1,validator:e=>!e||xt(e)},timePosition:{type:"number",required:!1,validator:(e,t,s)=>ms(e,t,s,{allowUndefined:!0,min:0})},timePeriod:{type:"number",required:!1,validator:(e,t,s)=>ms(e,t,s,{allowUndefined:!0,min:0})}},searchCloudUsers:{keywordList:Ms.keywordListExceptMsg,keywordListMatchType:Ms.keywordListMatchType,cursor:Ms.cursor,count:Ms.count,miniBirthday:{type:"Number",required:!1,validator:(e,t,s)=>ms(e,t,s,{allowUndefined:!0,min:0})},maxBirthday:{type:"Number",required:!1,validator:(e,t,s)=>ms(e,t,s,{allowUndefined:!0,min:0})},gender:{type:"String",required:!1,validator:(e,t,s)=>!e||e===o.GENDER_FEMALE||e===o.GENDER_MALE||Vt({api:t,paramName:s,desc:e+" is invalid match type"})}},searchCloudGroups:{keywordList:Ms.keywordListExceptMsg,keywordListMatchType:Ms.keywordListMatchType,cursor:Ms.cursor,count:Ms.count,groupTypeList:Ms.groupTypeList},searchCloudGroupMembers:{keywordList:Ms.keywordListExceptMsg,keywordListMatchType:Ms.keywordListMatchType,cursor:Ms.cursor,count:Ms.count,groupTypeList:Ms.groupTypeList,groupIDList:{type:"Array",required:!1,validator:(e,t,s)=>gs(e,t,s,{allowUndefined:!0,allowEmpty:!0})}},getUserProfile:{userIDList:{type:"Array",validator:(e,t,s)=>Ve(e)?(0===e.length&&Vt({api:t,paramName:s,desc:jt()}),!0):(Vt({api:t,paramName:s,desc:zt()}),!1)}},updateMyProfile:{profileCustomField:{type:"Array",validator:(e,t,s)=>!!Be(e)||!!Ve(e)||(Vt({api:t,paramName:s,desc:zt()}),!1)}},setSelfStatus:{customStatus:{type:"String",validator:(e,t,s)=>!!Fe(e)||(Vt({api:t,paramName:s,desc:Bt()}),!1)}},getUserStatus:{userIDList:{type:"Array",validator:(e,t,s)=>Ve(e)?0!==e.length||(Vt({api:t,paramName:s,desc:jt()}),!1):(Vt({api:t,paramName:s,desc:zt()}),!1)}},subscribeUserStatus:{userIDList:{type:"Array",validator:(e,t,s)=>Ve(e)?0!==e.length||(Vt({api:t,paramName:s,desc:jt()}),!1):(Vt({api:t,paramName:s,desc:zt()}),!1)}},unsubscribeUserStatus:{userIDList:{type:"Array",validator:(e,t,s)=>!e||!!Ve(e)||(Vt({api:t,paramName:s,desc:zt()}),!1)}},addFriend:{to:cs,source:{type:"String",required:!0,validator:(e,t,s)=>!(!e||(e.startsWith("AddSource_Type_")?8<e.replace("AddSource_Type_","").length&&(Vt({api:t,paramName:s,desc:Zt("keyword",8)}),1):(Vt({api:t,paramName:s,desc:fs("SourcePrefixLog")}),1)))},remark:{type:"String",required:!1,validator:(e,t,s)=>!(Fe(e)&&96<e.length&&(Vt({api:t,paramName:s,desc:Zt(s,96)}),1))}},deleteFriend:{userIDList:_s},checkFriend:{userIDList:_s},getFriendProfile:{userIDList:_s},updateFriend:{userID:cs,remark:{type:"String",required:!1,validator:(e,t,s)=>!(Fe(e)&&96<e.length&&(Vt({api:t,paramName:s,desc:Zt(s,96)}),1))},friendCustomField:{type:"Array",required:!1,validator:(e,t,s)=>{if(e){if(!Ve(e))return Vt({api:t,paramName:s,desc:zt()}),!1;let i=!0;return e.forEach((e=>Fe(e.key)&&-1!==e.key.indexOf("Tag_SNS_Custom")?Fe(e.value)?8<e.key.replace("Tag_SNS_Custom_","").length?(Vt({api:t,paramName:s,desc:Zt("keyword",8)}),i=!1):void 0:(Vt({api:t,paramName:s,desc:ts("value")}),i=!1):(Vt({api:t,paramName:s,desc:fs("FriendCustomFieldPrefixLog")}),i=!1))),i}return!0}}},acceptFriendApplication:{userID:cs},refuseFriendApplication:{userID:cs},deleteFriendApplication:{userID:cs},createFriendGroup:{name:cs},deleteFriendGroup:{name:cs},addToFriendGroup:{name:cs,userIDList:_s},removeFromFriendGroup:{name:cs,userIDList:_s},renameFriendGroup:{oldName:cs,newName:cs},sendMessageReadReceipt:[{name:"messageList",type:"Array",validator:(e,t,s)=>Ve(e)?0!==e.length||(Vt({api:t,paramName:s,desc:jt()}),!1):(Vt({api:t,paramName:s,desc:zt()}),!1)}],getMessageReadReceiptList:[{name:"messageList",type:"Array",validator:(e,t,s)=>Ve(e)?0!==e.length||(Vt({api:t,paramName:s,desc:jt()}),!1):(Vt({api:t,paramName:s,desc:zt()}),!1)}],createTopicInCommunity:{groupID:cs,topicName:cs},deleteTopicFromCommunity:{groupID:cs,topicIDList:{type:"Array",validator:(e,t,s)=>!e||!!Ve(e)||(Vt({api:t,paramName:s,desc:zt()}),!1)}},updateTopicProfile:{groupID:cs,topicID:cs},getTopicList:{groupID:cs,topicIDList:{type:"Array",validator:(e,t,s)=>!e||!!Ve(e)||(Vt({api:t,paramName:s,desc:zt()}),!1)}},followUser:[{name:"userIDList",..._s}],unfollowUser:[{name:"userIDList",..._s}],getMyFollowingList:[{name:"startIndex",...cs,required:!1}],getMyFollowersList:[{name:"startIndex",...cs,required:!1}],getMutualFollowersList:[{name:"startIndex",...cs,required:!1}],getUserFollowInfo:[{name:"userIDList",..._s,required:!1}],checkFollowType:[{name:"userIDList",..._s}],addSignalingListener:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Vt({api:t,paramName:s,desc:Kt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Vt({api:t,paramName:s,desc:Yt()}),!1):(""===e.name&&Vt({api:t,paramName:s,desc:rs()}),!0)}],removeSignalingListener:[{name:"eventName",type:"String",validator:(e,t,s)=>"string"==typeof e&&0!==e.length||(Vt({api:t,paramName:s,desc:Kt(s)}),!1)},{name:"handler",type:"Function",validator:(e,t,s)=>"function"!=typeof e?(Vt({api:t,paramName:s,desc:Yt()}),!1):(""===e.name&&Vt({api:t,paramName:s,desc:rs()}),!0)}],invite:{userID:cs},inviteSync:[{...us,validator:(e,t,s)=>xe(e)?!!Fe(e.userID)||(Vt({api:t,paramName:"options.userID",desc:Bt()}),!1):(Vt({api:t,paramName:"options",desc:ss()}),!1)},{name:"successCb",type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:Yt()}),!0)},{name:"errorCb",type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:Yt()}),!0)}],inviteInGroup:{groupID:cs,inviteeList:_s},inviteInGroupSync:[{...us,validator:(e,t,s)=>xe(e)?Fe(e.groupID)?!!Ve(e.inviteeList)||(Vt({api:t,paramName:"options.inviteeList",desc:zt()}),!1):(Vt({api:t,paramName:"options.groupID",desc:Bt()}),!1):(Vt({api:t,paramName:"options",desc:ss()}),!1)},{name:"successCb",type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:Yt()}),!0)},{name:"errorCb",type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:Yt()}),!0)}],accept:{inviteID:cs},reject:{inviteID:cs},getSignalingInfo:[{name:"message",...us,validator:(e,t,s)=>!Ue(e)||(Vt({api:t,paramName:s,desc:ns()}),!1)}],modifyInvitation:{inviteID:cs,data:cs}},Cs={login:1,logout:1,getLoginUser:1,getServerTime:1,on:1,once:1,off:1,setLogLevel:1,registerPlugin:1,destroy:1,isReady:1,createTextMessage:1,createTextAtMessage:1,createImageMessage:1,createAudioMessage:1,createVideoMessage:1,createCustomMessage:1,createFaceMessage:1,createFileMessage:1,createLocationMessage:1,createMergerMessage:1,downloadMergerMessage:1,createForwardMessage:1,sendMessage:1,resendMessage:1,revokeMessage:1,deleteMessage:1,translateText:1,convertVoiceToText:1,modifyMessage:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageReadReceiptList:1,setMessageExtensions:1,getMessageExtensions:1,deleteMessageExtensions:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1,getMessageList:1,findMessage:1,getMessageListHopping:1,setMessageRead:1,setAllMessageRead:1,getConversationList:1,getConversationProfile:1,deleteConversation:1,setConversationDraft:1,pinConversation:1,getTotalUnreadMessageCount:1,setConversationCustomData:1,markConversation:1,createConversationGroup:1,getConversationGroupList:1,deleteConversationGroup:1,renameConversationGroup:1,addConversationsToGroup:1,deleteConversationsFromGroup:1,clearHistoryMessage:1,setMessageRemindType:1,setAllReceiveMessageOpt:1,getAllReceiveMessageOpt:1,getGroupList:1,getGroupProfile:1,createGroup:1,joinGroup:1,updateGroupProfile:1,quitGroup:1,dismissGroup:1,changeGroupOwner:1,searchGroupByID:1,getGroupApplicationList:1,handleGroupApplication:1,initGroupAttributes:1,setGroupAttributes:1,deleteGroupAttributes:1,getGroupAttributes:1,setGroupCounters:1,increaseGroupCounter:1,decreaseGroupCounter:1,getGroupCounters:1,getJoinedCommunityList:1,createTopicInCommunity:1,deleteTopicFromCommunity:1,updateTopicProfile:1,getTopicList:1,getGroupMemberProfile:1,getGroupMemberList:1,addGroupMember:1,deleteGroupMember:1,setGroupMemberNameCard:1,setGroupMemberMuteTime:1,setGroupMemberRole:1,setGroupMemberCustomField:1,getGroupOnlineMemberCount:1,markGroupMemberList:1,getMyProfile:1,getUserProfile:1,updateMyProfile:1,setSelfStatus:1,getUserStatus:1,subscribeUserStatus:1,unsubscribeUserStatus:1,getBlacklist:1,addToBlacklist:1,removeFromBlacklist:1,searchCloudMessages:1,searchCloudUsers:1,searchCloudGroups:1,searchCloudGroupMembers:1,getFriendList:1,addFriend:1,deleteFriend:1,checkFriend:1,updateFriend:1,getFriendProfile:1,getFriendApplicationList:1,refuseFriendApplication:1,deleteFriendApplication:1,acceptFriendApplication:1,setFriendApplicationRead:1,getFriendGroupList:1,createFriendGroup:1,renameFriendGroup:1,deleteFriendGroup:1,addToFriendGroup:1,removeFromFriendGroup:1,followUser:1,unfollowUser:1,getMyFollowingList:1,getMyFollowersList:1,getMutualFollowersList:1,getUserFollowInfo:1,checkFollowType:1,callExperimentalAPI:1,addSignalingListener:1,removeSignalingListener:1,invite:1,inviteSync:1,inviteInGroup:1,inviteInGroupSync:1,cancel:1,accept:1,reject:1,getSignalingInfo:1,modifyInvitation:1},vs=1,Ts=2,ys=3,Es=4,Ss=6,Ds=7,Rs=8,Ls=10,As=11,Os=12,Ns=13,Ps=14,Us=15,Gs=17,ks=18,ws=19,bs=20,Fs=21,qs=23,xs=24,Vs=25,Bs=26,Ks=27,Hs=28,$s=29,Ws=30,Ys=31,zs=32,js=33,Js=34,Xs=35,Zs=36,Qs=37,ei=38,ti=function(e){return{code:0,data:e||{}}};class si extends Error{constructor(e){super();var{code:e,message:t,data:s}=e;this.code=e,t?this.message=t:this._getErrMsg&&(this.message=this._getErrMsg(this.code)),this.data=s||{}}}let ii={NO_SDKAPPID:2e3,NO_ACCOUNT_TYPE:2001,NO_IDENTIFIER:2002,NO_USERSIG:2003,NO_TINYID:2022,NO_A2KEY:2023,USER_NOT_LOGGED_IN:2024,REPEAT_LOGIN:2025,COS_UNDETECTED:2040,COS_GET_SIG_FAIL:2041,MSG_SEND_FAIL:2100,MSG_SEND_FAIL_NOT_IN_AV:2101,MSG_INSTANCE_REQUIRED:2105,MSG_INVALID_CONV_TYPE:2106,MSG_F_IS_EMPTY:2108,MSG_ONPROGRESS_ERR:2109,MSG_REVOKE_FAIL:2110,MSG_DELETE_FAIL:2111,MSG_UNREAD_ALL_FAIL:2112,READ_RECEIPT_MSG_LIST_EMPTY:2114,MSG_SEND_GRP_WITH_TOPIC_FAIL:2115,CANNOT_DELETE_GRP_SYSTEM_NOTICE:2116,TRANSLATE_TEXT_FAIL:2117,VOICE_TO_TEXT_FAIL:2118,UNSUPPORTED_VOICE_FORMAT:2119,MSG_I_SELECT_F_FIRST:2251,MSG_I_TYPES_LIMIT:2252,MSG_I_SIZE_LIMIT:2253,MSG_A_UPLOAD_FAIL:2300,MSG_A_SIZE_LIMIT:2301,MSG_V_UPLOAD_FAIL:2350,MSG_V_SIZE_LIMIT:2351,MSG_V_TYPES_LIMIT:2352,MSG_F_UPLOAD_FAIL:2400,MSG_F_SELECT_F_FIRST:2401,MSG_F_SIZE_LIMIT:2402,MSG_F_URL_IS_EMPTY:2403,MSG_MERGER_TYPE_INVALID:2450,MSG_MERGER_KEY_INVALID:2451,MSG_MERGER_DOWNLOAD_FAIL:2452,MSG_FORWARD_TYPE_INVALID:2453,MSG_FORWARD_INVALID_ELEMENTS:2454,MSG_MODIFY_CONFLICT:2480,MSG_MODIFY_DISABLED_IN_AV:2481,CONV_NOT_FOUND:2500,USER_OR_GRP_NOT_FOUND:2501,CONV_UN_RECORDED_TYPE:2502,INVALID_CONV_ID:2503,ILLEGAL_GRP_TYPE:2600,ILLEGAL_GRP_ID:2602,CANNOT_FIND_GRP:2603,CANNOT_CHANGE_OWNER_IN_AV:2620,CANNOT_CHANGE_OWNER_TO_SELF:2621,MEMBER_NOT_IN_GRP:2623,JOIN_GRP_FAIL:2660,CANNOT_ADD_MEMBER_IN_AV:2661,CANNOT_JOIN_NON_AV_WITHOUT_LOGIN:2662,NOT_OWNER:2681,INVALID_MEMBER_ROLE:2683,CANNOT_SET_SELF_MEMBER_ROLE:2684,CANNOT_MUTE_SELF:2685,BAN_DURATION_INVALID:2686,OPERATION_NOT_SUPPORTED_IN_AV:2687,NOT_MY_FRIEND:2700,ALREADY_MY_FRIEND:2701,FRIEND_GRP_EXISTED:2710,FRIEND_GRP_NOT_EXIST:2711,FRIEND_APPLICATION_NOT_EXIST:2716,UPDATE_PROFILE_INVALID_PARAM:2721,UPDATE_PROFILE_NO_KEY:2722,CANNOT_ADD_SELF_TO_BLACKLIST:2742,NETWORK_ERROR:2800,NETWORK_TIMEOUT:2801,NO_NETWORK:2805,UNCAUGHT_ERROR:2903,INVALID_OPERATION:2905,INVALID_TRTC_CMD:2995,OVER_FREQUENCY_LIMIT:2996,NO_PROTOCOL:2997,NO_MODULE:2998,SDK_IS_NOT_READY:2999,LOGGING_IN:3e3,LOGIN_FAILED:3001,KICKED_OUT_MULT_DEVICE:3002,KICKED_OUT_MULT_ACCOUNT:3003,KICKED_OUT_USERSIG_EXPIRED:3004,LOGGED_OUT:3005,KICKED_OUT_REST_API:3006,ILLEGAL_TOPIC_ID:3021,NO_USE:3122,PROFANITY_FOUND:3123,OPTIONS_IS_EMPTY:3153,MSG_A2KEY_EXPIRED:20002,ACCOUNT_A2KEY_EXPIRED:70001,HELLO_ANSWER_KICKED_OUT:1002,OPEN_SERVICE_OVERLOAD_ERROR:60022,SIGNALING_INVALID_INVITE_ID:8010,SIGNALING_NO_PERMISSION:8011,SIGNALING_ALREADY_EXISTS:8012,INVALID_CANCEL_MESSAGE:8020},oi=null,ni=function(e){oi=e},ri=function(e){return Promise.resolve(ti(e))},ai=function(e,t=!1){if(e instanceof si)return t&&null!==oi&&oi.emit(i.ERROR,e),Promise.reject(e);if(e instanceof Error){let e=new si({code:ii.UNCAUGHT_ERROR});return t&&null!==oi&&oi.emit(i.ERROR,e),Promise.reject(e)}return Be(e)||Be(e.code)?Promise.reject(new si({code:ii.UNCAUGHT_ERROR})):(e=new si(e),t&&null!==oi&&oi.emit(i.ERROR,e),Promise.reject(e))};class li{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.get(Os).isLoggedIn()}isOversea(){return this._m.get(Os).isOversea()}isPrivateNetWork(){var e=this._m.get(Os);return e.isPrivateNetWork()&&!e.getFileDownloadProxy()}getFileDownloadProxy(){return this._m.get(Os).getFileDownloadProxy()}getDownloadFileAuthKey(){return this._m.get(Os).getDownloadFileAuthKey()}getMyUserID(){return this._m.get(Os).getUserID()}getMyTinyID(){return this._m.get(Os).getTinyID()}getSDKAppID(){return this._m.get(Os).getSDKAppID()}isIntl(){return this._m.get(Os).isIntl()}isUsingChatCore(){return this._m.get(Os).isUsingChatCore()}isDevMode(){return this._m.get(Os).isDevMode()}get(e){return this._m.get(e)}getPlatform(){return Y}getCloudConfig(e){return this._m.get(qs).getCloudConfig(e)}emitOEvt(e,t){this._m.getOEmitInst().emit(e,t)}emitIEvt(e,t){this._m.getIEmitInst().emit(e,t)}getIEmitInst(){return this._m.getIEmitInst()}req(e){return this._m.get(bs).req(e)}canIUse(e){return this._m.get(Ks).canIUse(e)}getErrMsg(e,t,s){return this._m.getErrMsg(e,t,s)}warn(e,t,s){e=this.getErrMsg(e,t,s),e&&ye.w(e)}noUse(e){var t=ii.NO_USE;return ai({code:t,message:this.getErrMsg(t,e)})}}let di={LOGIN:"wslogin",LOGOUT:"wslogout",HELLO:"wshello",KICK_OTHER:"KickOther",SYNC_UNREAD_MSG:"getmsg",SEND_C2C_MSG:"sendmsg",SEND_GRP_MSG:"send_group_msg",GET_USER_PROFILE:"portrait_get_all",UPDATE_MY_PROFILE:"portrait_set",GET_BL:"black_list_get",ADD_TO_BL:"black_list_add",RM_FROM_BL:"black_list_delete",GET_FD_LIST:"friend_get",GET_FD_PROFILE:"friend_get_specified",CHECK_FD:"friend_check",DEL_FD:"friend_delete",ADD_FD:"friend_add",UPDATE_FD:"friend_update",RESPOND_FD_APPLICATION:"friend_response",GET_FD_APPLICATION_LIST:"pendency_get",DEL_FD_APPLICATION:"pendency_delete",REFUSE_FD_APPLICATION:"pendency_refuse",REPORT_FD_APPLICATION:"pendency_report",GET_FD_GRP_LIST:"group_get",CREATE_FD_GRP:"group_add",DEL_FD_GRP:"group_delete",UPDATE_FD_GRP:"group_update",REVOKE_C2C_MSG:"msgwithdraw",SET_C2C_MSG_READ:"msgreaded",SET_C2C_PEER_MUTE_NOTIFICATIONS:"set_c2c_peer_mute_notifications",GET_C2C_PEER_MUTE_NOTIFICATIONS:"get_c2c_peer_mute_notifications",GET_C2C_ROAMING_MSG:"getroammsg",GET_C2C_PEER_READ_TIME:"get_peer_read_time",DEL_C2C_MSG:"delete_c2c_msg_ramble",MODIFY_C2C_MSG:"modify_c2c_msg",MODIFY_C2C_MSG_EXT:"set_key_values",GET_C2C_MSG_EXT:"get_key_values",ADD_C2C_MSG_REACTION:"reaction_add",RM_C2C_MSG_REACTION:"reaction_del",GET_C2C_MSG_REACTIONS:"reaction_multi_stat",GET_C2C_MSG_REACTION_USER_LIST:"reaction_iterate",PAGING_GET_CONV_LIST:"page_get",DEL_CONV:"batch_delete",CLEAR_HISTORY_MSG:"clear_msg",PIN_CONV:"top",DEL_GROUP_AT_TIPS:"deletemsg",SET_CONV_CUSTOM_DATA:"set_conv_custom_data",MARK_CONV:"mark_contact",CREATE_CONV_GRP:"create_contact_group",DEL_CONV_GRP:"del_contact_group",RENAME_CONV_GRP:"update_contact_group",ADD_CONV_TO_GRP:"add_conv_to_group",DEL_CONV_FROM_GRP:"del_conv_from_group",GET_CONV_GRP_LIST:"get_contact_group",SEARCH_CONV_GRP_MARK:"search_contact_group",GET_GRP_LIST:"get_joined_group_list",GET_GRP_PROFILE:"get_group_self_member_info",CREATE_GRP:"create_group",DISMISS_GRP:"destroy_group",UPDATE_GRP_PROFILE:"modify_group_base_info",APPLY_JOIN_GRP:"apply_join_group",APPLY_JOIN_GRP_NOAUTH:"apply_join_group_noauth",QUIT_GRP:"quit_group",SEARCH_GRP:"get_group_public_info",CHANGE_GRP_OWNER:"change_group_owner",HANDLE_GRP_APPLICATION:"handle_apply_join_group",HANDLE_INVITE_JOIN_GRP:"handle_invite_join_permission_group",HANDLE_GRP_INVITATION:"handle_invite_join_group",REVOKE_GRP_MSG:"group_msg_recall",SET_GRP_MSG_READ:"msg_read_report",SET_ALL_MSG_READ:"read_all_unread_msg",GET_GRP_ROAMING_MSG:"group_msg_get",GET_READ_RECEIPT:"get_group_msg_receipt",SEND_READ_RECEIPT:"group_msg_receipt",SEND_C2C_READ_RECEIPT:"c2c_msg_read_receipt",GET_READ_RECEIPT_DETAIL:"get_group_msg_receipt_detail",GET_GRP_RECEIPTS_BY_USERS:"get_group_msg_receipts_by_users",GET_GRP_PENDENCY:"get_pendency",DEL_GRP_SYSTEM_NOTICE:"deletemsg",AV_POLLING:"get_msg",AV_NOAUTH_POLLING:"get_msg_noauth",GET_ONLINE_MBR_NUM:"get_online_member_num",DEL_GRP_MSG:"delete_group_ramble_msg_by_seq",MODIFY_GRP_MSG:"modify_group_msg",SET_GRP_ATTR:"set_group_attr",MODIFY_GRP_ATTR:"modify_group_attr",DEL_GRP_ATTR:"delete_group_attr",CLEAR_GRP_ATTR:"clear_group_attr",GET_GRP_ATTR:"get_group_attr",MODIFY_GRP_MSG_EXT:"group_set_key_values",GET_GRP_MSG_EXT:"group_get_key_values",GET_GRP_NOTIFY:"batch_get_group_notify",UPDATE_GRP_COUNTER:"update_group_counter",GET_GRP_COUNTER:"get_group_counter",ADD_GRP_MSG_REACTION:"group_reaction_add",RM_GRP_MSG_REACTION:"group_reaction_del",GET_GRP_MSG_REACTIONS:"group_reaction_multi_stat",GET_GRP_MSG_REACTION_USER_LIST:"group_reaction_iterate",GET_GRP_MBR_LIST:"get_group_member_info",GET_AV_MBR_LIST:"get_members",GET_GRP_MBR_PROFILE:"get_specified_group_member_info",ADD_GRP_MBR:"add_group_member",DEL_GRP_MBR:"delete_group_member",BAN_AV_MBR:"ban_group_member",MODIFY_GRP_MBR_INFO:"modify_group_member_info",MARK_AV_MBR_INFO:"modify_user_info",COS_SIGN:"cos",COS_PRE_SIG:"pre_sig",SIMPLE_COS_PRE_SIG:"simple_sig",GET_IMAGE_INFO:"get_imageinfo",GET_IP:"get_final_ip",VIDEO_COVER:"video_cover",SSO_STAT:"tim_web_report_v2",PING:"alive",MSG_PUSH:"msg_push",CS:"query",GRP_CS:"query_grp",MBR_CS:"query_grp_member",USER_CS:"query_user",MULTI_MSG_PUSH:"multi_msg_push_ws",MSG_PUSH_ACK:"ws_msg_push_ack",STATUS_FORCE_OFFLINE:"stat_forceoffline",UPLOAD_MERGER_MSG:"save_relay_json_msg",DOWNLOAD_MERGER_MSG:"get_relay_json_msg",FETCH_CLOUD_CTRL_CONFIG:"fetch_config",PUSHED_CLOUD_CTRL_CONFIG:"push_configv2",FETCH_COMMERCIAL_CONFIG:"fetch_imsdk_purchase_bitsv2",PUSHED_COMMERCIAL_CONFIG:"push_imsdk_purchase_bitsv2",OVERLOAD_NOTIFY:"notify2",CREATE_TOPIC:"create_topic",DEL_TOPIC:"destroy_topic",UPDATE_TOPIC_PROFILE:"modify_topic",GET_TOPIC_LIST:"get_topic",SET_SELF_STATUS:"ws_set_custom_status",GET_USER_STATUS:"ws_get_user_status",SUB_USER_STATUS:"ws_status_subscribe",UNSUB_USER_STATUS:"ws_status_unsubscribe",STAT_BACKGROUND:"ws_stat_background",STAT_FOREGROUND:"ws_stat_foreground",SET_TOKEN:"ws_stat_settoken",PUSH_REPORT:"uniapp_sdk_report",GET_PROFANITY_LIST:"get_local_words",TRANSLATE_TEXT:"ws_batch_trans_text",VOICE_TO_TEXT:"ws_sentence_recognition",FOLLOW:"follow_add",UNFOLLOW:"follow_delete",GET_FOLLOW:"follow_get",GET_FOLLOW_INFO:"follow_get_info",CHECK_FOLLOW_TYPE:"follow_check",SET_ALL_RECEIVE_MSG_OPT:"ws_set_do_not_disturb",GET_ALL_RECEIVE_MSG_OPT:"ws_get_do_not_disturb"},ci="networkRTT",_i="messageE2EDelay",ui="sendMessageC2C",hi="sendMessageGroup",pi="sendMessageGroupAV",gi="sendMessageRichMedia",mi="cosUpload",Mi="messageReceivedGroup",fi="messageReceivedGroupAVPush",Ii="messageReceivedGroupAVPull",Ci={[ci]:2,[_i]:3,[ui]:4,[hi]:5,[pi]:6,[gi]:7,[Mi]:8,[fi]:9,[Ii]:10,[mi]:11},vi={info:4,warning:5,error:6},Ti={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},yi={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 Ei{constructor(e){this._n="SSOLogData",this.eventType=yi[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=Me()}static bindEventStatModule(e){Ei.prototype._eventStatModule=e}static bindNetMonitorModule(e){Ei.prototype._netMonitorModule=e}updateTimeStamp(){this.timestamp=Me()}start(e){return this._startts=e,this}end(e=!1){if(!this._sentFlag){if(this._netMonitorModule){let e=this._netMonitorModule.getNetworkType();this.setNetworkType(e)}var t=Me();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){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 e=ii.NO_NETWORK;this.setCode(e)}this.setLevel("error")}}else ye.w(this._n+".setError value not instanceof Error, please check!");return this}setCode(e){return Be(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),be(e)?this.code=e:ye.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return Be(e)||this._sentFlag||(be(e)&&(this.message=e.toString()),Fe(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return Be(e)||this._sentFlag||(this.level=vi[e]),this}setMoreMessage(e){return Ue(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){return Be(e)?ye.w(this._n+".setNetworkType value is undefined, please check!"):(e=Ti[e.toLowerCase()],Be(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 Si{constructor(e){this.type=o.MSG_TEXT,this.content={text:e.text||""}}setText(e){this.content.text=e}sendable(){return 0!==this.content.text.length}}function Di(e,t,s,i=[]){if(!e)return e;let o=e;return t&&(e.startsWith("http://")?o=e.replace(/^http:\/\/[^/]+/,t):e.startsWith("https://")&&(o=e.replace(/^https:\/\/[^/]+/,t))),s&&-1===o.indexOf("authKey=")&&Ai(o,i)?-1<o.indexOf("?")?o+"&authKey="+s:o+"?authKey="+s:o}function Ri(e,t,s=[]){var i=t[0].content||t[0].payload;if(e===o.MSG_IMAGE)i.imageInfoArray.forEach((e=>{Ai(e.imageUrl,s)&&(e.imageUrl=Li(e.imageUrl))}));else if(e===o.MSG_VIDEO)Ai(i.snapshotUrl,s)&&(i.snapshotUrl=Li(i.snapshotUrl),i.thumbUrl=Li(i.thumbUrl)),Ai(i.remoteVideoUrl,s)&&(i.remoteVideoUrl=Li(i.remoteVideoUrl));else if(e===o.MSG_AUDIO)Ai(i.remoteAudioUrl,s)&&(i.remoteAudioUrl=Li(i.remoteAudioUrl));else if(e===o.MSG_FILE)Ai(i.fileUrl,s)&&(i.fileUrl=Li(i.fileUrl));else if(e===o.MSG_MERGER){let{downloadKey:e="",messageList:i=[]}=t[0].content||t[0].payload;Ue(e)&&i.forEach((e=>{Ri(e.messageBody[0].type,e.messageBody,s)}))}return t}function Li(e){if(!e)return e;if(-1===e.indexOf("authKey="))return e;e=e.split("?");var t=e[1].split("&");let s=0;for(let i=0;i<t.length;i++)if(-1<t[i].indexOf("authKey=")){s=i;break}return t.splice(s,1),0<t.length?e[0]+"?"+t.join("&"):e[0]}function Ai(e,t){let s=!1;if(e){e=e.match(/:\/\/([0-9]?\.)?(.[^/:]+)/);var i=e&&e[2]||"";if(i.includes("rich-dev"))return!0;for(let e=0;e<t.length;e++)if(i.endsWith(t[e])){s=!0;break}}return s}class Oi{constructor(e,t,s,i){this._imageMemoryURL="",this._fileDownloadProxy=t,this._authKey=s,this._fileDNList=i,x||B?this.createImageDataASURL(e.file):this.createImageDataASURLInWeb(e.file),this._initImageInfoModel(),this.type=o.MSG_IMAGE,this._percent=0,this.content={imageFormat:e.imageFormat||Ee.UNKNOWN,uuid:e.uuid,imageInfoArray:[]},this.initImageInfoArray(e.imageInfoArray),this._autoFixUrl()}_initImageInfoModel(){let e=this;this._ImageInfoModel=function(t){this.instanceID=Ze(9999999),this.sizeType=t.type||0,this.type=0,this.size=t.size||0,this.width=t.width||0,this.height=t.height||0,this.imageUrl=t.imageUrl||t.url||"",this.url=Di(t.url||e._imageMemoryURL,e._fileDownloadProxy,e._authKey,e._fileDNList)},this._ImageInfoModel.prototype={setSizeType(e){this.sizeType=e},setType(e){this.type=e},setImageUrl(t){t&&(this.imageUrl=Di(t,e._fileDownloadProxy,e._authKey,e._fileDNList))},getImageUrl(){return this.imageUrl}}}initImageInfoArray(e){let t,s=0,i=null;for(;s<=2;)t=Be(e)||Be(e[s])?{type:0,size:0,width:0,height:0,url:""}:e[s],(i=new this._ImageInfoModel(t)).setSizeType(s+1),i.setType(s),this.addImageInfo(i),s++;this.updateAccessSideImageInfoArray()}updateImageInfoArray(e){var t,s=this.content.imageInfoArray.length;for(let i=0;i<s;i++)t=this.content.imageInfoArray[i],e[i].size&&(t.size=e[i].size),e[i].url&&t.setImageUrl(e[i].url),e[i].width&&(t.width=e[i].width),e[i].height&&(t.height=e[i].height)}_autoFixUrl(){var e=this.content.imageInfoArray.length;let t="",s="";var i=["http","https"],o=null;for(let n=0;n<e;n++)this.content.imageInfoArray[n].url&&""!==(o=this.content.imageInfoArray[n]).imageUrl&&(s=o.imageUrl.slice(0,o.imageUrl.indexOf("://")+1),t=o.imageUrl.slice(o.imageUrl.indexOf("://")+1),i.indexOf(s)<0&&(s="https:"),this.content.imageInfoArray[n].setImageUrl([s,t].join("")))}updatePercent(e){this._percent=e,1<this._percent&&(this._percent=1)}updateImageFormat(e){this.content.imageFormat=Ee[e.toUpperCase()]||Ee.UNKNOWN}createImageDataASURLInWeb(e){void 0!==e&&0<e.files.length&&(this._imageMemoryURL=window.URL.createObjectURL(e.files[0]))}createImageDataASURL(e){e&&e.url&&(this._imageMemoryURL=e.url)}replaceImageInfo(e,t){this.content.imageInfoArray[t]instanceof this._ImageInfoModel||(this.content.imageInfoArray[t]=e)}addImageInfo(e){3<=this.content.imageInfoArray.length||this.content.imageInfoArray.push(e)}updateAccessSideImageInfoArray(){var e=this.content.imageInfoArray,{width:t=0,height:s=0}=e[0];0!==t&&0!==s&&(It(e),Object.assign(e[2],ft({originWidth:t,originHeight:s,min:720})))}sendable(){return 0!==this.content.imageInfoArray.length&&""!==this.content.imageInfoArray[0].imageUrl&&0!==this.content.imageInfoArray[0].size}}class Ni{constructor(e){this.type=o.MSG_FACE,this.content=e||null}sendable(){return null!==this.content}}class Pi{constructor(e,t,s,i){this.type=o.MSG_AUDIO,this._percent=0,this._fileDownloadProxy=t,this._authKey=s,this._fileDNList=i,this.content={downloadFlag:2,second:e.second,size:e.size,url:Di(e.url,this._fileDownloadProxy,this._authKey,this._fileDNList),remoteAudioUrl:Di(e.url||"",this._fileDownloadProxy,this._authKey,this._fileDNList),uuid:e.uuid}}updatePercent(e){this._percent=e,1<this._percent&&(this._percent=1)}updateAudioUrl(e){this.content.remoteAudioUrl=Di(e,this._fileDownloadProxy,this._authKey,this._fileDNList)}sendable(){return""!==this.content.remoteAudioUrl}}let Ui={from:!0,groupID:!0,groupName:!0,to:!0};class Gi{constructor(e){this.type=o.MSG_GRP_TIP,this.content={},this._initContent(e)}_initContent(e){Object.keys(e).forEach((t=>{switch(t){case"remarkInfo":break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(e[t]);break;case"operatorInfo":this.content.operatorInfo={},this._initOperatorInfo(e[t]);break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(e[t]);break;case"memberExtraInfo":case"onlineMemberInfo":break;case"memberNum":this.content[t]=e[t],this.content.memberCount=e[t];break;case"newGroupProfile":this.content.newGroupProfile={},this._initNewGroupProfile(e[t]);break;default:this.content[t]=e[t]}})),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(e){var t=Object.keys(e);for(let i=0;i<t.length;i++){var s=t[i];Ui[s]&&(this.content.groupProfile[s]=e[s])}}_initOperatorInfo(e){var t=Object.keys(e);for(let i=0;i<t.length;i++){var s=t[i];this.content.operatorInfo[s]=e[s]}}_updateMemberList(e){Ue(this.content.memberList)?this.content.memberList=e:this.content.memberList.forEach((t=>{e.forEach((e=>{t.userID===e.userID&&Object.assign(t,e)}))}))}_initNewGroupProfile(e){var t=Object.keys(e);for(let i=0;i<t.length;i++){var s=t[i];this.content.newGroupProfile[s]="muteAllMembers"!==s?e[s]:1===e[s]}}}let ki={from:!0,groupID:!0,groupName:!0,to:!0,groupType:!0};class wi{constructor(e){this.type=o.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(e)}_initContent(e){Object.keys(e).forEach((t=>{switch(t){case"memberInfoList":break;case"remarkInfo":this.content.handleMessage=e[t];break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(e[t]);break;default:this.content[t]=e[t]}}))}_initGroupProfile(e){var t=Object.keys(e);for(let i=0;i<t.length;i++){var s=t[i];ki[s]&&("groupName"===s?this.content.groupProfile.name=e[s]:this.content.groupProfile[s]=e[s])}}}class bi{constructor(e,t,s,i){this.type=o.MSG_FILE,this._percent=0;var n=this._getFileInfo(e);this.content={downloadFlag:2,fileUrl:Di(e.url||e.fileUrl,t,s,i)||"",uuid:e.uuid,fileName:n.name||"",fileSize:n.size||0}}_getFileInfo(e){if(!Be(e.fileName)&&!Be(e.fileSize))return{size:e.fileSize,name:e.fileName};var t=e.file.files[0];if(b){if(t.path&&-1!==t.path.indexOf(".")){let e=t.path.slice(t.path.lastIndexOf(".")+1).toLowerCase();t.type=e,t.name||(t.name=Ze(999999)+"."+e)}t.name||(t.type="",t.name=t.path.slice(t.path.lastIndexOf("/")+1).toLowerCase()),t.suffix&&(t.type=t.suffix),t.url||(t.url=t.path)}return{size:t.size,name:t.name}}updatePercent(e){this._percent=e,1<this._percent&&(this._percent=1)}updateFileUrl(e){this.content.fileUrl=e}sendable(){return""!==this.content.fileUrl&&""!==this.content.fileName&&0!==this.content.fileSize}}class Fi{constructor(e){this.type=o.MSG_CUSTOM,this.content={data:e.data||"",description:e.description||"",extension:e.extension||""}}setData(e){return this.content.data=e,this}setDescription(e){return this.content.description=e,this}setExtension(e){return this.content.extension=e,this}sendable(){return 0!==this.content.data.length||0!==this.content.description.length||0!==this.content.extension.length}}class qi{constructor(e,t,s,i){this.type=o.MSG_VIDEO,this._percent=0,this._fileDownloadProxy=t,this._authKey=s,this._fileDNList=i,this.content={remoteVideoUrl:Di(e.remoteVideoUrl||e.videoUrl||"",this._fileDownloadProxy,this._authKey,this._fileDNList),videoFormat:e.videoFormat,videoSecond:parseInt(e.videoSecond,10),videoSize:e.videoSize,videoUrl:Di(e.videoUrl,this._fileDownloadProxy,this._authKey,this._fileDNList),videoDownloadFlag:2,videoUUID:e.videoUUID,thumbUUID:e.thumbUUID,thumbFormat:e.thumbFormat,thumbWidth:e.thumbWidth,snapshotWidth:e.thumbWidth,thumbHeight:e.thumbHeight,snapshotHeight:e.thumbHeight,thumbSize:e.thumbSize,snapshotSize:e.thumbSize,thumbDownloadFlag:2,thumbUrl:Di(e.thumbUrl,this._fileDownloadProxy,this._authKey,this._fileDNList),snapshotUrl:Di(e.thumbUrl,this._fileDownloadProxy,this._authKey,this._fileDNList)}}updatePercent(e){this._percent=e,1<this._percent&&(this._percent=1)}updateVideoUrl(e){e&&(this.content.remoteVideoUrl=Di(e,this._fileDownloadProxy,this._authKey,this._fileDNList))}updateSnapshotInfo(e){var{snapshotUrl:e,snapshotWidth:t,snapshotHeight:s}=e;Ue(e)||(this.content.thumbUrl=this.content.snapshotUrl=e),Ue(t)||(this.content.thumbWidth=this.content.snapshotWidth=Number(t)),Ue(s)||(this.content.thumbHeight=this.content.snapshotHeight=Number(s))}sendable(){return""!==this.content.remoteVideoUrl}}class xi{constructor(e){this.type=o.MSG_LOCATION;var{description:e,longitude:t,latitude:s}=e;this.content={description:e,longitude:t,latitude:s}}sendable(){return!0}}class Vi{constructor(e,t,s,i){var n,r;this.from=e.from,this.messageSender=e.from,this.time=e.time,this.messageSequence=e.sequence,this.clientSequence=e.clientSequence||e.sequence,this.messageRandom=e.random,this.cloudCustomData=e.cloudCustomData||"",this.clientTime=e.clientTime||void 0,e.ID?(this.ID=e.ID||"",this.nick=e.nick||"",this.avatar=e.avatar||"",e.messageBody?this.messageBody=JSON.parse(JSON.stringify(e.messageBody)):this.messageBody=[{type:e.type,payload:e.payload}],e.conversationType?e.conversationType.startsWith(o.CONV_C2C)?this.receiverUserID=e.to:e.conversationType.startsWith(o.CONV_GROUP)&&(this.receiverGroupID=e.to):e.receiverGroupID?this.receiverGroupID=e.receiverGroupID:e.receiverUserID&&(this.receiverUserID=e.receiverUserID),this.messageReceiver=e.to||e.messageReceiver):(this.nick=e.nick||"",this.avatar=e.avatar||"",this.messageBody=[],n=e.elements[0].type,r=e.elements[0].content,this._patchRichMediaPayload(n,r),this._updateRichMediaDownloadUrl(n,r,t,s,i),n===o.MSG_MERGER?this.messageBody.push({type:n,payload:new Bi(r,t,s,i).content}):this.messageBody.push({type:n,payload:r}),e.groupID&&(this.receiverGroupID=e.groupID,this.messageReceiver=e.groupID),e.to&&(this.receiverUserID=e.to,this.messageReceiver=e.to),this.ID=`${e.tinyID}-${e.clientTime}-`+e.random)}_patchRichMediaPayload(e,t){e===o.MSG_IMAGE?t.imageInfoArray.forEach((e=>{!e.imageUrl&&e.url&&(e.imageUrl=e.url,e.sizeType=e.type,1===e.type?e.type=0:3===e.type&&(e.type=1))})):e===o.MSG_VIDEO?!t.remoteVideoUrl&&t.videoUrl&&(t.remoteVideoUrl=t.videoUrl):e===o.MSG_AUDIO?!t.remoteAudioUrl&&t.url&&(t.remoteAudioUrl=t.url):e===o.MSG_FILE&&!t.fileUrl&&t.url&&(t.fileUrl=t.url,t.url=void 0)}_updateRichMediaDownloadUrl(e,t,s,i,n){(s||i)&&(e===o.MSG_IMAGE?t.imageInfoArray.forEach((e=>{e.imageUrl=Di(e.imageUrl,s,i,n),e.url=Di(e.url,s,i,n)})):e===o.MSG_VIDEO?(t.remoteVideoUrl=Di(t.remoteVideoUrl,s,i,n),t.videoUrl=Di(t.videoUrl,s,i,n),t.thumbUrl=Di(t.thumbUrl,s,i,n),t.snapshotUrl=Di(t.thumbUrl,s,i,n),t.snapshotHeight=t.thumbHeight,t.snapshotWidth=t.thumbWidth):e===o.MSG_AUDIO?(t.remoteAudioUrl=Di(t.remoteAudioUrl,s,i,n),t.url=Di(t.url,s,i,n)):e===o.MSG_FILE&&(t.fileUrl=Di(t.fileUrl,s,i,n)))}}var Bi=class{constructor(e,t,s,i){if(this.type=o.MSG_MERGER,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},e.downloadKey){let{downloadKey:t,pbDownloadKey:s,title:i,abstractList:o,compatibleText:n,version:r}=e;this.content.downloadKey=t,this.content.pbDownloadKey=s,this.content.title=i,this.content.abstractList=o,this.content.compatibleText=n,this.content.version=r||0}else if(Ue(e.messageList))1===e.layersOverLimit&&(this.content.layersOverLimit=!0);else{let{messageList:o,title:n,abstractList:r,compatibleText:a,version:l}=e,d=[];o.forEach((e=>{Ue(e)||(e=new Vi(e,t,s,i),d.push(e))})),this.content.messageList=d,this.content.title=n,this.content.abstractList=r,this.content.compatibleText=a,this.content.version=l||0}}sendable(){return!Ue(this.content.messageList)||!Ue(this.content.downloadKey)}};let Ki={1:o.MSG_PRIORITY_HIGH,2:o.MSG_PRIORITY_NORMAL,3:o.MSG_PRIORITY_LOW,4:o.MSG_PRIORITY_LOWEST};class Hi{constructor(e){this.ID="",this.conversationID=e.conversationID||null,this.conversationType=e.conversationType||o.CONV_C2C,this.conversationSubType=e.conversationSubType,this.time=e.time||Math.ceil(Date.now()/1e3),this.sequence=e.sequence||0,this.clientSequence=e.clientSequence||e.sequence||0,this.random=e.random||0===e.random?e.random:Ze(),this.priority=this._computePriority(e.priority),this.nick=e.nick||"",this.avatar=e.avatar||"",this.isPeerRead=!1,this.nameCard="",this.hasRiskContent=Ot(e.checkResult),this._elements=[],this.isPlaceMessage=e.isPlaceMessage||0,this.isRevoked=2===e.isPlaceMessage||8===e.msgFlagBits,this.from=e.from||null,this.to=e.to||null,this.flow="",this.isSystemMessage=e.isSystemMessage||!1,this.protocol=e.protocol||"JSON",this.isResend=!1,this.isRead=!1,this.status=e.status||Gt,this._onlineOnlyFlag=!1,this._groupAtInfoList=[],this._relayFlag=!1,this.atUserList=[],this.cloudCustomData=e.cloudCustomData||"",this.isDeleted=!1,this.isModified=!!e.messageVersion,this._isExcludedFromUnreadCount=!(!e.messageControlInfo||1!==e.messageControlInfo.excludedFromUnreadCount),this._isExcludedFromLastMessage=!(!e.messageControlInfo||1!==e.messageControlInfo.excludedFromLastMessage),this.clientTime=e.clientTime||Ie()||0,this.senderTinyID=e.senderTinyID||e.tinyID||"",this.readReceiptInfo=e.readReceiptInfo||{readCount:void 0,unreadCount:void 0,isPeerRead:void 0,timestamp:0},this.needReadReceipt=!0===e.needReadReceipt||1===e.needReadReceipt,this.version=e.messageVersion||0,this.isBroadcastMessage=e.isBroadcastMessage||!1,this._receiverList=e.receiverList||void 0,this.isSupportExtension=!0===e.isSupportExtension||1===e.isSupportExtension,this._cmConfigID=e.customModerationConfigurationID,this.revoker=e.revokerInfo&&e.revokerInfo.revoker||"",this.revokerInfo=e.revokerInfo||{userID:"",nick:"",avatar:""},this.revokeReason=e.revokeReason||"",this.reInitialize(e.currentUser),this.extractGroupInfo(e.groupProfile||null),this.handleGroupAtInfo(e),this.initC2CReadReceiptInfo(e)}get elements(){return this._elements}getElements(){return this._elements}extractGroupInfo(e){null!==e&&(Fe(e.nick)&&(this.nick=e.nick),Fe(e.avatar)&&(this.avatar=e.avatar),e=e.messageFromAccountExtraInformation,xe(e))&&Fe(e.nameCard)&&(this.nameCard=e.nameCard)}handleGroupAtInfo(e){e.payload&&e.payload.atUserList&&e.payload.atUserList.forEach((e=>{e!==o.MSG_AT_ALL?(this._groupAtInfoList.push({groupAtAllFlag:0,groupAtUserID:e}),this.atUserList.push(e)):(this._groupAtInfoList.push({groupAtAllFlag:1}),this.atUserList.push(o.MSG_AT_ALL))})),Ve(e.groupAtInfo)&&e.groupAtInfo.forEach((e=>{0===e.groupAtAllFlag?this.atUserList.push(e.groupAtUserID):1===e.groupAtAllFlag&&this.atUserList.push(o.MSG_AT_ALL)}))}getGroupAtInfoList(){return this._groupAtInfoList}_initProxy(){this._elements[0]&&(this.payload=this._elements[0].content,this.type=this._elements[0].type)}reInitialize(e){e&&(this.status=this.from?Gt:Ut,!this.from)&&(this.from=e),this._initFlow(e),this._initSequence(e),this._concatConversationID(e),this.generateMessageID()}isSendable(){return 0!==this._elements.length&&(!0===this._relayFlag||"function"==typeof this._elements[0].sendable&&this._elements[0].sendable())}_initTo(e){this.conversationType===o.CONV_GROUP&&(this.to=e.groupID)}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=function(e){if(!e)return!1;if(void 0===it[e]){var t=new Date;let s=("3"+t.getHours()).slice(-2),i=("0"+t.getMinutes()).slice(-2),o=("0"+t.getSeconds()).slice(-2);it[e]=parseInt([s,i,o,"0001"].join("")),s=null,i=null,o=null,ye.l("autoIncrementIndex start index:"+it[e])}return it[e]++}(e)),0===this.sequence&&this.conversationType===o.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===o.CONV_SYSTEM&&(this.senderTinyID="144115198244471703"),this.ID=`${this.senderTinyID}-${this.clientTime}-`+this.random}_initFlow(e){""!==e&&(e===this.from?(this.flow="out",this.isRead=!0):this.flow="in")}_concatConversationID(e){var t=this["to"],s=this.conversationType;s!==o.CONV_SYSTEM?(e=s===o.CONV_C2C?e===this.from?t:this.from:this.to,this.conversationID=e?""+s+e:null):this.conversationID=o.CONV_SYSTEM}isElement(e){return e instanceof Si||e instanceof Oi||e instanceof Ni||e instanceof Pi||e instanceof bi||e instanceof qi||e instanceof Gi||e instanceof wi||e instanceof Fi||e instanceof xi||e instanceof Bi}setElement(e,t,s,i){if(this.isElement(e))this._elements=[e];else{var n=e=>{if(e.type&&e.content)switch(e.type){case o.MSG_TEXT:this.setTextElement(e.content);break;case o.MSG_IMAGE:this.setImageElement(e.content,t,s,i);break;case o.MSG_AUDIO:this.setAudioElement(e.content,t,s,i);break;case o.MSG_FILE:this.setFileElement(e.content,t,s,i);break;case o.MSG_VIDEO:this.setVideoElement(e.content,t,s,i);break;case o.MSG_CUSTOM:this.setCustomElement(e.content);break;case o.MSG_LOCATION:this.setLocationElement(e.content);break;case o.MSG_GRP_TIP:this.setGroupTipElement(e.content);break;case o.MSG_GRP_SYS_NOTICE:this.setGroupSystemNoticeElement(e.content);break;case o.MSG_FACE:this.setFaceElement(e.content);break;case o.MSG_MERGER:this.setMergerElement(e.content,t,s,i)}};if(Ve(e))for(let t=0;t<e.length;t++)n(e[t]);else n(e)}this._initProxy()}clearElement(){this._elements.length=0}setTextElement(e){e="string"==typeof e?e:e.text,e=new Si({text:e}),this._elements.push(e)}setImageElement(e,t,s,i){e=new Oi(e,t,s,i),this._elements.push(e)}setAudioElement(e,t,s,i){e=new Pi(e,t,s,i),this._elements.push(e)}setFileElement(e,t,s,i){e=new bi(e,t,s,i),this._elements.push(e)}setVideoElement(e,t,s,i){e=new qi(e,t,s,i),this._elements.push(e)}setLocationElement(e){e=new xi(e),this._elements.push(e)}setCustomElement(e){e=new Fi(e),this._elements.push(e)}setGroupTipElement(e){let t={};var s=e.operationType;if(Ue(e.memberInfoList)?e.operatorInfo&&(t=e.operatorInfo):s!==o.GRP_TIP_MBR_JOIN&&s!==o.GRP_TIP_MBR_KICKED_OUT&&s!==o.GRP_TIP_MBR_SET_ADMIN&&s!==o.GRP_TIP_MBR_CANCELED_ADMIN||(t=e.memberInfoList[0]),!Ue(e.memberExtraInfo)){let t=e.memberExtraInfo["reason"];e.msgMemberInfo.forEach((e=>{e.reason=t}))}var{nick:s,avatar:i}=t;Fe(s)&&(this.nick=s),Fe(i)&&(this.avatar=i),s=new Gi(e);this._elements.push(s)}setGroupSystemNoticeElement(e){e=new wi(e),this._elements.push(e)}setFaceElement(e){e=new Ni(e),this._elements.push(e)}setMergerElement(e,t,s,i){e=new Bi(e,t,s,i),this._elements.push(e)}setIsRead(e){this.isRead=e}setRelayFlag(e){this._relayFlag=e}_computePriority(e){if(!Be(e)){if(Fe(e)&&-1!==Object.values(Ki).indexOf(e))return e;if(be(e)){let t=""+e;if(-1!==Object.keys(Ki).indexOf(t))return Ki[t]}}return o.MSG_PRIORITY_NORMAL}setNickAndAvatar(e){var{nick:e,avatar:t}=e;Fe(e)&&(this.nick=e),Fe(t)&&(this.avatar=t)}setNameCard(e){Fe(e)&&(this.nameCard=e)}initC2CReadReceiptInfo(e){var{readReceiptSentByPeer:e,timestamp:t=0}=e;this.conversationType===o.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e,this.readReceiptInfo.timestamp=t)}}function $i(e){var t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function Wi(e){let{androidInfo:t={},androidOPPOChannelID:s=""}=e,i=t.OPPOChannelID||s,{sound:o="",FCMChannelID:n="",...r}=t;return{...r,Sound:$i(o),OPPOChannelID:i,GoogleChannelID:n}}function Yi(e){var{apnsInfo:e={},ignoreIOSBadge:t=!1,disableVoipPush:s}=e,t=!0===e.ignoreIOSBadge||!0===t?1:0;let i;return Be(s)||(i=!1===s?1:0),Be(e.disableVoipPush)||(i=!1===e.disableVoipPush?1:0),{...e,badgeMode:t,isVoipPush:i}}function zi(e){if(xe(e))return{pushFlag:!0===e.disablePush?1:0,title:e.title||"",desc:e.description||"",ext:e.extension||"",apnsInfo:Yi(e),androidInfo:Wi(e)}}class ji extends li{constructor(e){super(e),this._n="C2CModule",this._msgFromUnreadDBMap=new Map,this._noticeFromUnreadDBList=[]}onNewMessage(e){var{dataList:e,isInstantMessage:t,C2CRemainingUnreadList:s,C2CPairUnreadList:o,isSyncingEnded:n}=e,{conversationOptionsList:e,messageList:s,isUnreadC2CMessage:o}=(t||ye.l(this._n+".onNewMessage C2CPairUnreadList:",o,"C2CRemainingUnreadList:",s),this._assembly({dataList:e,C2CRemainingUnreadList:s,C2CPairUnreadList:o,isInstantMessage:t})),r=Ue(r=s)?[]:r.filter((e=>!0===e.isModified));0<r.length&&this.emitOEvt(i.MESSAGE_MODIFIED,r),this.get(As).onNewMessage({conversationOptionsList:e,isInstantMessage:t,isUnreadC2CMessage:o,isSyncingEnded:n}),e=Ue(r=s)?[]:r.filter((e=>!1===e.isModified));t&&0<e.length&&this.emitOEvt(i.MESSAGE_RECEIVED,e),s.length=0}_assembly({dataList:e,C2CRemainingUnreadList:t,C2CPairUnreadList:s,isInstantMessage:i}){var n=null,r=[],a=[],l={},d=this.get(Bs);let c=!1;var _=this.get(As),u=this.get(Es),h=this.get(Gs),p=this.getFileDownloadProxy(),g=this.getDownloadFileAuthKey(),m=h.getFileDNList();for(let f=0,I=e.length;f<I;f++)if(this._isC2CNotice(e[f]))this._noticeFromUnreadDBList.push(e[f].eventArray[0].c2CNotifyMsgArray[0]);else{let t=e[f],s=(t.currentUser=this.getMyUserID(),t.conversationType=o.CONV_C2C,t.isSystemMessage=!!t.isSystemMessage,(Be(t.nick)||Be(t.avatar))&&(c=!0),(n=new Hi(t)).setElement(t.elements,p,g,m),n.setNickAndAvatar({nick:t.nick,avatar:t.avatar}),n)["conversationID"];if(i){if(this._msgFromUnreadDBMap.get(n.ID))continue;let o=!1;if(n.from!==this.getMyUserID()){let e=_.getLatestMessageSentByPeer(s);if(e){let{nick:t,avatar:s}=e;c?n.setNickAndAvatar({nick:t,avatar:s}):t===n.nick&&s===n.avatar||(o=!0)}}else{let e=_.getLatestMessageSentByMe(s);if(e){let{nick:t,avatar:i}=e;t===n.nick&&i===n.avatar||(_.modifyMessageSentByMe({conversationID:s,latestNick:n.nick,latestAvatar:n.avatar}),u.mockOnNickAvatarModified(n.nick,n.avatar))}}let r=1===e[f].isModified;if(_.isMessageSentByCurrentInstance(n)?n.isModified=r:r=!1,0===t.msgLifeTime)n._onlineOnlyFlag=!0,_.isMessageSentByCurrentInstance(n)||a.push(n);else{if(!_.pushIntoMessageList(a,n,r))continue;o&&(_.modifyMessageSentByPeer({conversationID:s,latestNick:n.nick,latestAvatar:n.avatar}),_.updateUserProfileSpecifiedKey({conversationID:s,nick:n.nick,avatar:n.avatar}))}i&&0<n.clientTime&&d.addMessageDelay(n.clientTime)}else this._msgFromUnreadDBMap.set(n.ID,n);if(0!==t.msgLifeTime){if(!1===n._onlineOnlyFlag){let e=_.getLastMessageTime(s);if(!(be(e)&&n.time<e)&&i)if(Be(l[s])){let e=0;"in"!==n.flow||n._isExcludedFromUnreadCount||(e=1),l[s]=r.push({conversationID:s,unreadCount:e,type:n.conversationType,subType:n.conversationSubType,lastMessage:n._isExcludedFromLastMessage?"":n})-1}else{let e=l[s];r[e].type=n.conversationType,r[e].subType=n.conversationSubType,r[e].lastMessage=n._isExcludedFromLastMessage?"":n,"in"!==n.flow||n._isExcludedFromUnreadCount||r[e].unreadCount++}}}else n._onlineOnlyFlag=!0}this._handleNoticeFromUnreadDB();let M=!1;if(Ve(s)&&0<s.length)for(let f=0,I=s.length;f<I;f++)if(s[f].from!==o.CONV_SYSTEM){M=!0;let e=r.find((({conversationID:e})=>e===""+o.CONV_C2C+s[f].from));e?e.unreadCount=s[f].unreadCount:r.push({conversationID:""+o.CONV_C2C+s[f].from,unreadCount:s[f].unreadCount,type:o.CONV_C2C})}if(Ve(t))for(let f=0,I=t.length;f<I;f++)r.find((({conversationID:e})=>e===""+o.CONV_C2C+t[f].from))||r.push({conversationID:""+o.CONV_C2C+t[f].from,type:o.CONV_C2C,lastMsgTime:t[f].lastMsgTime});return{conversationOptionsList:r,messageList:a,isUnreadC2CMessage:M}}getMessageListFromUnreadDB(){return[...this._msgFromUnreadDBMap.values()]}_isC2CNotice(e){return e=e.eventArray,!(!Ve(e)||10!==e[0].event)}_handleNoticeFromUnreadDB(){var e=this._noticeFromUnreadDBList.length;if(0!==e){ye.l(this._n+"._handleNoticeFromUnreadDB count:"+e);let t=[];this._noticeFromUnreadDBList.forEach((e=>{e.hasOwnProperty("c2cMessageRevokedNotify")&&t.push(e)})),this.onMsgRevoked({dataList:t}),this._noticeFromUnreadDBList.length=0,t.length=0}}onMsgRevoked(e,t){let s,n=this.get(As),r=[];e.dataList.forEach((e=>{e.c2cMessageRevokedNotify&&(e=e.c2cMessageRevokedNotify["revokedInfos"],Be(e)||e.forEach((e=>{var t=this.getMyUserID()===e.from?""+o.CONV_C2C+e.to:""+o.CONV_C2C+e.from,i=(s=n.revoke(t,e.sequence,e.random),e.revokerInfo&&e.revokerInfo.revoker),a=e.revokerInfo&&e.revokerInfo.reason||"";let l;s?l=s:(l={conversationID:t,sequence:e.sequence},e.tinyID&&e.clientTime&&e.random&&(l.ID=`${e.tinyID}-${e.clientTime}-`+e.random),e.time&&(l.time=e.time)),l&&(l.revoker=i,l.revokeReason=a,l.revokerInfo={userID:i,nick:"",avatar:""},r.push(l))})))})),0!==r.length&&(ye.l(`${this._n}.onMsgRevoked count:${r.length} updateUnreadCount:`+t),n.onMessageRevoked(r,t),n.updateRevokerInfo(r).then((e=>{this.emitOEvt(i.MESSAGE_REVOKED,e)})))}onMsgReadReceipt(e){e.dataList.forEach((e=>{if(!Ue(e.c2cMessageReadReceipt)){let t=e.c2cMessageReadReceipt["to"];e.c2cMessageReadReceipt.uinPairReadArray.forEach((e=>{e=e["peerReadTime"];var s=(ye.l(`${this._n}.onMsgReadReceipt to:${t} peerReadTime:`+e),""+o.CONV_C2C+t),i=this.get(As);i.recordPeerReadTime(s,e),i.updateMsgIsPeerReadProp(s,e)}))}}))}onMsgReadNotice(e){e.dataList.forEach((e=>{if(!Ue(e.c2cMessageReadNotice)){let t=this.get(As);e.c2cMessageReadNotice.uinPairReadArray.forEach((e=>{var{from:e,peerReadTime:s}=e;ye.l(this._n+`.onMsgReadNotice from:${e} lastReadTime:`+s),e=""+o.CONV_C2C+e;t.updateIsReadAfterReadReport({conversationID:e,lastMessageTime:s}),t.updateUnreadCount(e)}))}}))}onMsgModified(e){ye.l(this._n+".onMsgModified options:",e);let t=this.get(As);e.dataList.forEach((e=>{t.onMessageModified({...e,conversationType:o.CONV_C2C})}))}onReadReceiptList(e){ye.l(this._n+".onReadReceiptList options:",e),this.get(As).updateReadReceiptInfo(e.dataList)}sendMessage(e,t){return e=this._createC2CMessagePack(e,t),this.req(e)}_createC2CMessagePack(e,t){let s=null,i=(t&&(t.offlinePushInfo&&(s=t.offlinePushInfo),!0===t.onlineUserOnly)&&(s?s.disablePush=!0:s={disablePush:!0}),"");Fe(e.cloudCustomData)&&0<e.cloudCustomData.length&&(i=e.cloudCustomData);var o=[];if(xe(t)&&xe(t.messageControlInfo)){let{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:i}=t.messageControlInfo;!0===e&&o.push("NoUnread"),!0===s&&o.push("NoLastMsg"),!0===i&&o.push("NoMsgCheck")}var n=this.isOnlineMessage(e,t)?0:void 0,r=JSON.parse(JSON.stringify(e.getElements())),a=this.get(Gs).getFileDNList();return{P:di.SEND_C2C_MSG,data:{fromAccount:this.getMyUserID(),toAccount:e.to,msgBody:Ri(e.type,r,a),cloudCustomData:i,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:n,nick:e.nick,avatar:e.avatar,offlinePushInfo:zi(s),messageControlInfo:0!==n?o:void 0,clientTime:e.clientTime,needReadReceipt:!0===e.needReadReceipt?1:0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0,cmConfigID:e._cmConfigID,forbidCallbackControl:rt(t)}}}isOnlineMessage(e,t){return!(!t||!0!==t.onlineUserOnly)}revokeMessage(e){return this.req({P:di.REVOKE_C2C_MSG,data:{msgInfo:{fromAccount:e.from,toAccount:e.to,msgSeq:e.sequence,msgRandom:e.random,msgTimeStamp:e.time}}})}deleteMessage(e){var{to:e,keyList:t}=e;return ye.l(this._n+`.deleteMessage toAccount:${e} count:`+t.length),this.req({P:di.DEL_C2C_MSG,data:{fromAccount:this.getMyUserID(),to:e,keyList:t}})}modifyRemoteMessage(e){var t,{from:e,to:s,version:i=0,sequence:n,random:r,time:a,payload:l,type:d,cloudCustomData:c,_elements:_}=e;let u;return(t=d)!==o.MSG_TEXT&&t!==o.MSG_CUSTOM&&t!==o.MSG_LOCATION&&t!==o.MSG_FACE||(1<_.length&&_.splice(0,1,{type:d,content:l}),u=_),this.req({P:di.MODIFY_C2C_MSG,data:{from:e,to:s,version:i,sequence:n,random:r,time:a,elements:u,cloudCustomData:c}})}setMessageRead({conversationID:e,lastMessageTime:t}){let s=this._n+".setMessageRead",i=`convID:${e} lastMessageTime:`+t,o=(ye.l(s+" "+i),be(t)||this.warn("DoNotModifyLastTime"),new Ei("setMessageRead"));return o.setMessage(i),this.req({P:di.SET_C2C_MSG_READ,data:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:e.replace("C2C",""),lastMessageTime:t,receipt:1}]}}}).then((()=>{o.end(),ye.l(s+" ok");var i=this.get(As);return i.updateIsReadAfterReadReport({conversationID:e,lastMessageTime:t}),i.updateUnreadCount(e),ti()})).catch((e=>(o.setError(e).end(),ye.l(s+" failed. error:",e),ai(e))))}getRoamingMessage(e){let t=this._n+".getRoamingMessage",{peerAccount:s,conversationID:i,count:n,lastMessageTime:r,messageKey:a}=e,l=`peerAccount:${s} count:${n||15} lastMessageTime:${r||0} messageKey:`+a,d=(ye.l(t+" "+l),new Ei("getRoamingMessage"));return this.req({P:di.GET_C2C_ROAMING_MSG,data:{peerAccount:s,count:n||15,lastMessageTime:r||0,messageKey:a}}).then((e=>{var{complete:e,messageList:s,messageKey:n,lastMessageTime:r}=e.data;Be(s)?ye.l(t+` ok. complete:${e} but messageList is undefined!`):ye.l(t+` ok. complete:${e} count:`+s.length),d.setMessage(l+` complete:${e} length:`+s.length).end();let a=this.get(As),c=1===e;if(c&&a.setCompleted(i),e=[],s=a.onRoamingMessage(s,i,!0,e),a.modifyMessageList(i),a.updateIsRead(i),a.updateRoamingMsgKeyAndTime(i,n,r),n=a.getPeerReadTime(i),ye.l(t+` update isPeerRead property. convID:${i} peerReadTime:`+n),n)a.updateMsgIsPeerReadProp(i,n);else{let e=i.replace(o.CONV_C2C,"");this.getRemotePeerReadTime([e]).then((()=>{a.updateMsgIsPeerReadProp(i,a.getPeerReadTime(i))}))}let _="";if(0<s.length)_=s[0].ID;else{let e=a.getLocalOldestMessage(i);e&&(_=e.ID)}return ye.l(t+` nextReqID:${_} storedMsgCount:`+s.length),{nextReqID:_,storedMessageList:s,assembledMessageList:e,isPullingCompleted:c}})).catch((e=>(d.setMessage(l).setError(e).end(),ye.w(t+" failed. error:",e),ai(e))))}getRoamingMessagesHopping(e){let t=this._n+".getRoamingMessagesHopping",{peerAccount:s,time:i=0,count:n,direction:r}=e,a=""+o.CONV_C2C+s,l=`peerAccount:${s} count:${n} time:${i} direction:`+r,d=(ye.l(t+" "+l),new Ei("getRoamingMessagesHopping"));return this.req({P:di.GET_C2C_ROAMING_MSG,data:{peerAccount:s,count:n+1,lastMessageTime:i,direction:r}}).then((e=>{var{complete:e,messageList:s=[],lastMessageTime:i}=e.data,n=`complete:${e} count:`+s.length;ye.l(t+" ok. "+n),d.setMessage(l+" "+n).end(),1!==e&&(1===r?s.pop():s.shift());let c=this.get(As),_=c.onRoamingMessage(s,a,!1);if(this._modifyMessageList(a,_),n=this._computeResult({complete:e,lastMessageTime:i,resultList:_}),c.storeHoppingMessageList(n.messageList),s=c.getPeerReadTime(a),ye.l(t+` update isPeerRead property. convID:${a} peerReadTime:`+s),s)c.updateMsgIsPeerReadProp(a,s);else{let e=a.replace(o.CONV_C2C,"");this.getRemotePeerReadTime([e]).then((()=>{c.updateMsgIsPeerReadProp(a,c.getPeerReadTime(a))}))}return ti(n)})).catch((e=>(d.setMessage(l).setError(e).end(),ye.w(t+" failed. error:",e),ai(e))))}_computeResult(e){var{complete:e=0,lastMessageTime:t,resultList:s=[]}=e,s={messageList:[...s],isCompleted:!1,nextMessageTime:""};return 1===e?s.isCompleted=!0:s.nextMessageTime=t,s}_modifyMessageList(e,t){if(e=this.get(As).getLocalConversation(e),e){var s=e.userProfile.nick,i=e.userProfile.avatar,o=(e=this.get(Es).getNickAndAvatarByUserID(this.getMyUserID()),e.nick),n=e.avatar;for(let e=t.length-1;0<=e;e--){let r=t[e];"in"===r.flow&&(r.nick!==s&&r.setNickAndAvatar({nick:s}),r.avatar!==i)&&r.setNickAndAvatar({avatar:i}),"out"===r.flow&&(r.nick!==o&&r.setNickAndAvatar({nick:o}),r.avatar!==n)&&r.setNickAndAvatar({avatar:n})}}}getRemotePeerReadTime(e){let t=this._n+".getRemotePeerReadTime";if(Ue(e))return Promise.resolve();let s=new Ei("getRemotePeerReadTime");return ye.l(t+" userIDList:"+e),this.req({P:di.GET_C2C_PEER_READ_TIME,data:{userIDList:e}}).then((i=>{var n=i.data["peerReadTimeList"];ye.l(t+" ok. peerReadTimeList:"+n);let r="";var a=this.get(As);for(let t=0;t<e.length;t++)r+=`${e[t]}-${n[t]} `,0<n[t]&&a.recordPeerReadTime(""+o.CONV_C2C+e[t],n[t]);s.setMessage(r).end()})).catch((e=>{s.setError(e).end(),ye.w(t+" failed. error:",e)}))}sendReadReceipt(e){let t=e[0].conversationID.replace(o.CONV_C2C,""),s=new Ei("sendReadReceipt"),i=(s.setMessage("peerAccount:"+t),this.getMyUserID()),n=e.filter((e=>e.from!==i&&!0===e.needReadReceipt)).map((e=>{var{from:e,to:t,sequence:s,random:i,time:o,clientTime:n}=e;return{fromAccount:e,toAccount:t,sequence:s,random:i,time:o,clientTime:n}}));if(0===n.length)return ai({code:ii.READ_RECEIPT_MSG_LIST_EMPTY});let r=this._n+".sendReadReceipt";return ye.l(r+`. peerAccount:${t} length:`+n.length),this.req({P:di.SEND_C2C_READ_RECEIPT,data:{peerAccount:t,messageInfoList:n}}).then((e=>(s.end(),ye.l(r+" ok"),ti()))).catch((e=>(s.setError(e).end(),ye.w(r+" failed. error:",e),ai(e))))}getReadReceiptList(e){var t=e[0].conversationID.replace(o.CONV_C2C,"");return ye.l(this._n+`.getReadReceiptList peerAccount:${t} msgCount:`+e.length),ri({messageList:e})}getMessageExtensions(e,t){return ye.l(this._n+".getMessageExtensions startSequence:"+t),this.req({P:di.GET_C2C_MSG_EXT,data:{from:e.from,to:e.to,messageKey:this.getMessageKey(e),startSequence:t}})}modifyMsgExts(e,t,s=1){return ye.l(this._n+".modifyMsgExts operateType:"+s),this.req({P:di.MODIFY_C2C_MSG_EXT,data:{from:e.from,to:e.to,messageKey:this.getMessageKey(e),extensionList:t,operateType:s}})}getMessageKey(e){var{clientSequence:e,random:t,time:s}=e;return e+`_${t}_`+s}reset(){ye.l(this._n+".reset"),this._msgFromUnreadDBMap.clear(),this._noticeFromUnreadDBList.length=0}}let Ji={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};class Xi{constructor(e){this._convM=e,this._map=new Map,this._n="MsgListHandler",this._latestMsgSentByPeerMap=new Map,this._latestMsgSentByMeMap=new Map,this._hoppingMsgMap=new Map,this.TOPIC_MSG_LIMIT=1e3,this._convM.getIEmitInst().on(Ji.CLOUD_CONFIG,this._onCloudConfig,this)}_onCloudConfig(){var e=this._convM.getCloudConfig("topic_msg_limit");Be(e)||(this.TOPIC_MSG_LIMIT=Number(e)),ye.l(this._n+"._onCloudConfig topicMsgLimit:"+this.TOPIC_MSG_LIMIT)}onCheckTimer(e){if(e%20==0&&0<this._map.size)for(var[t,s]of this._map)t.includes(Ne)&&s.size>=this.TOPIC_MSG_LIMIT&&this._convM.clearMemMsg(t,!0)}pushIn(e,t=!1){var s=e["conversationID"];let i=!0;this._map.has(s)||this._map.set(s,new Map);var o=this._getUniqueIDOfMsg(e);if(this._map.get(s).has(o)){let e=this._map.get(s).get(o);if(!t||!0===e.isModified)return!1}return this._map.get(s).set(o,e),this._setLatestMsgSentByPeer(s,e),this._setLatestMsgSentByMe(s,e),i}unshift(e,t){let s;if(Ve(e)?0<e.length&&(s=e[0].conversationID,this._unshiftMultipleMsgs(e,t)):(s=e.conversationID,this._unshiftSingleMsg(e,t)),s){let e=Array.from(this._map.get(s).values()),t=e.length;if(0!==t){for(let i=t-1;0<=i;i--)if("out"===e[i].flow){this._setLatestMsgSentByMe(s,e[i]);break}if(s.startsWith(o.CONV_C2C))for(let i=t-1;0<=i;i--)if("in"===e[i].flow){this._setLatestMsgSentByPeer(s,e[i]);break}}}}_unshiftSingleMsg(e,t){var s,i,o=e["conversationID"],n=this._getUniqueIDOfMsg(e);this._map.has(o)?(s=this._map.get(o),i=Array.from(s),s.has(n)||(i.unshift([n,e]),this._map.set(o,new Map(i)),t.push(e))):(this._map.set(o,new Map),this._map.get(o).set(n,e),t.push(e))}_unshiftMultipleMsgs(e,t){let s=e.length,i=[],o=e[0].conversationID,n=this._map.get(o),r=this._map.has(o)?Array.from(n):[];for(let a=0;a<s;a++){let s=this._getUniqueIDOfMsg(e[a]);n&&n.has(s)||(i.push([s,e[a]]),t.push(e[a]))}this._map.set(o,new Map(i.concat(r)))}remove(e){var t=e["conversationID"];e=this._getUniqueIDOfMsg(e);this._map.has(t)&&this._map.get(t).delete(e)}revoke(e,t,s){var i;return this._map.has(e)?(i=this._map.get(e),this._updateMsgIsRevoked(i,t,s)):this._hoppingMsgMap.has(e)?(i=this._hoppingMsgMap.get(e),this._updateMsgIsRevoked(i,t,s)):null}_updateMsgIsRevoked(e,t,s){for(var[,i]of e)if(i.sequence===t&&(Be(s)||i.random===s))return i.isRevoked||(i.isRevoked=!0),i}removeByConvID(e){var t=this._map.has(e);ye.l(this._n+`.removeByConvID convID:${e} has:`+t),t&&(this._map.delete(e),this._latestMsgSentByPeerMap.delete(e),this._latestMsgSentByMeMap.delete(e))}findMessage(e){let t=null;return(t=this._findMsg(e,this._map))||this._findMsg(e,this._hoppingMsgMap)}_findMsg(e,t){let s=null;for(var[,i]of t){let t=[...i.values()],o=t.length;for(let i=0;i<o;i++)if(t[i].ID===e){s=t[i];break}}return s}updateMsgIsPeerReadProp(e,t){let s=[];var i;return this._map.has(e)?(i=this._map.get(e),s=this._updateMsgIsPeerReadProp(i,t)):this._hoppingMsgMap.has(e)&&(i=this._hoppingMsgMap.get(e),s=this._updateMsgIsPeerReadProp(i,t)),ye.l(this._n+`.updateMsgIsPeerReadProp convID:${e} peerReadTime:${t} count:`+s.length),s}_updateMsgIsPeerReadProp(e,t){var s,i=[];for([,s]of e)s.time<=t&&!s.isPeerRead&&"out"===s.flow&&(s.isPeerRead=!0,i.push(s));return i}updateMsgIsModifiedProp(e){var t=e["conversationID"];this._map.has(t)&&(e=this._getUniqueIDOfMsg(e),t=this._map.get(t).get(e))&&(t.isModified=!0)}hasLocalMsgList(e){return this._map.has(e)}getLocalMsgList(e){return this.hasLocalMsgList(e)?[...this._map.get(e).values()]:[]}getLocalMaxSeq(e){return this.hasLocalMsgList(e)?(e=[...this._map.get(e).values()].map((e=>e.sequence)),Math.max(...e)):0}getLocalMaxTime(e){return this.hasLocalMsgList(e)?(e=[...this._map.get(e).values()].map((e=>e.time)),Math.max(...e)):0}hasLocalMsg(e,t){let s=!1;var i=this.getLocalMsgList(e),o=i.length;for(let n=0;n<o;n++)i[n].ID===t&&(s=!0);return s}getLocalMsg(e,t){let s=null;var i=this.getLocalMsgList(e),o=i.length;for(let n=0;n<o;n++)if(i[n].ID===t){s=i[n];break}return s}getLocalLastMsg(e){return e=this.getLocalMsgList(e),e[e.length-1]}getLocalSecondLastMsg(e){return e=this.getLocalMsgList(e),e[e.length-2]}getLocalOldestMsg(e){return this.getLocalMsgList(e)[0]}_setLatestMsgSentByPeer(e,t){e.startsWith(o.CONV_C2C)&&"in"===t.flow&&this._latestMsgSentByPeerMap.set(e,t)}_setLatestMsgSentByMe(e,t){"out"===t.flow&&this._latestMsgSentByMeMap.set(e,t)}getLatestMsgSentByPeer(e){return this._latestMsgSentByPeerMap.get(e)}getLatestMsgSentByMe(e){return this._latestMsgSentByMeMap.get(e)}modifyMsgSentByPeer(e){var{conversationID:e,latestNick:t,latestAvatar:s}=e,i=this._map.get(e);if(!Ue(i)){var o=Array.from(i.values());i=o.length;if(0!==i){let n=null,r=0,a=!1;for(let e=i-1;0<=e;e--)"in"===o[e].flow&&((n=o[e]).nick!==t&&(n.setNickAndAvatar({nick:t}),a=!0),n.avatar!==s&&(n.setNickAndAvatar({avatar:s}),a=!0),a)&&(r+=1);ye.l(this._n+`.modifyMsgSentByPeer convID:${e} count:`+r)}}}modifyMsgSentByMe(e){var{conversationID:e,latestNick:t,latestAvatar:s}=e,i=this._map.get(e);if(!Ue(i)){var o=Array.from(i.values());i=o.length;if(0!==i){let n=null,r=0,a=!1;for(let e=i-1;0<=e;e--)"out"===o[e].flow&&((n=o[e]).nick!==t&&(n.setNickAndAvatar({nick:t}),a=!0),n.avatar!==s&&(n.setNickAndAvatar({avatar:s}),a=!0),a)&&(r+=1);ye.l(this._n+`.modifyMsgSentByMe convID:${e} count:`+r)}}}getTopicConvIDList(e){return[...this._map.keys()].filter((t=>t.startsWith(""+o.CONV_GROUP+e)))}onMsgModified(e,t){if(this._map.has(e)||this._hoppingMsgMap.has(e)){let s=this._n+".onMsgModified",i=this._getUniqueIDOfMsg(t),o=this._getTargetMsg(e,i),n=!!o;if(ye.l(s+` convID:${e} uniqueID:${i} has:`+n),n){let{messageVersion:e,elements:i,cloudCustomData:n,checkResult:r}=t;return ye.l(s+` localVersion:${o.version} remoteVersion:`+e),o.version<e?(o.version=e,o._elements=JSON.parse(JSON.stringify(i)),o.payload=o._elements[0].content,o.type=o._elements[0].type,o.cloudCustomData=n,o.isModified=!0,o.hasRiskContent=Ot(r),{isUpdated:!0,message:o}):{isUpdated:!1,message:o}}}return{isUpdated:!1,message:null}}_getUniqueIDOfMsg(e){var{from:e,to:t,random:s,sequence:i,time:o}=e;return e+`-${t}-${s}-${i}-`+o}_getTargetMsg(e,t){if(this._map.has(e))return this._map.get(e).get(t);let s;if(this._hoppingMsgMap.has(e)){var i=[...this._hoppingMsgMap.get(e).values()];for(let e=0;e<i.length;e++)if(this._getUniqueIDOfMsg(i[e])===t){s=i[e];break}}return s}storeHoppingMsgList(e){if(0!==e.length){let s=e[0]["conversationID"],i=e.length;this._hoppingMsgMap.has(s)||this._hoppingMsgMap.set(s,new Map);var t=this._hoppingMsgMap.get(s);for(let o=0;o<i;o++){let s=e[o];t.has(s.ID)||t.set(s.ID,s)}}}getHoppingMsg(e,t){if(this._hoppingMsgMap.has(e))return this._hoppingMsgMap.get(e).get(t)}reset(){this._map.clear(),this._latestMsgSentByPeerMap.clear(),this._latestMsgSentByMeMap.clear(),this._hoppingMsgMap.clear()}}function Zi(e){this.mixin(e)}Zi.mixin=function(e){e=e.prototype||e,e._isReady=!1,e.ready=function(e,t=!1){if(e)return this._isReady?void(t?e.call(this):setTimeout(e,1)):(this._readyQueue=this._readyQueue||[],void this._readyQueue.push(e))},e.triggerReady=function(){this._isReady=!0,setTimeout((()=>{var e=this._readyQueue;this._readyQueue=[],e&&0<e.length&&e.forEach((function(e){e.call(this)}),this)}),1)},e.resetReady=function(){this._isReady=!1,this._readyQueue=[]},e.isReady=function(){return this._isReady}};let Qi=["jpg","jpeg","gif","png","bmp","image","webp"],eo=["mp4","quicktime","mov"],to=1,so=2,io=3,oo=255;class no{constructor(e){Ue(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||o.ALLOW_TYPE_ALLOW_ANY,this.language=e.language||0,this.avatar=e.avatar||"",this.messageSettings=e.messageSettings||0,this.adminForbidType=e.adminForbidType||o.FORBID_TYPE_NONE,this.level=e.level||0,this.role=e.role||0,this.lastUpdatedTime=0,this.profileCustomField=[],Ue(e.profileCustomField))||e.profileCustomField.forEach((e=>{this.profileCustomField.push({key:e.key,value:e.value})}))}validate(e){let t=!0,s="";if(Ue(e))return{valid:!1,tips:"empty options"};if(e.profileCustomField){let t=e.profileCustomField.length;var i=null;for(let s=0;s<t;s++){if(i=e.profileCustomField[s],!Fe(i.key)||-1===i.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(!Fe(i.value))return{valid:!1,tips:"The type of values of the custom profile key-value pairs (which is profileCustomField) must be String"}}}for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){if("profileCustomField"===o)continue;if(Ue(e[o])&&!Fe(e[o])&&!be(e[o])){s="key:"+o+", invalid value:"+e[o],t=!1;continue}switch(o){case"nick":Fe(e[o])||(s="nick must be a string",t=!1),500<Xe(e[o])&&(s=`nick name limited: must less than or equal to 500 bytes, current size: ${Xe(e[o])} bytes`,t=!1);break;case"gender":st(Re,e.gender)||(s="key:gender, invalid value:"+e.gender,t=!1);break;case"birthday":be(e.birthday)||(s="birthday must be a number",t=!1);break;case"location":Fe(e.location)||(s="location must be a string",t=!1);break;case"selfSignature":Fe(e.selfSignature)||(s="selfSignature must be a string",t=!1);break;case"allowType":st(Ae,e.allowType)||(s="key:allowType, invalid value:"+e.allowType,t=!1);break;case"language":be(e.language)||(s="language must be a number",t=!1);break;case"avatar":Fe(e.avatar)||(s="avatar must be a string",t=!1);break;case"messageSettings":0!==e.messageSettings&&1!==e.messageSettings&&(s="messageSettings must be 0 or 1",t=!1);break;case"adminForbidType":st(Le,e.adminForbidType)||(s="key:adminForbidType, invalid value:"+e.adminForbidType,t=!1);break;case"level":be(e.level)||(s="level must be a number",t=!1);break;case"role":be(e.role)||(s="role must be a number",t=!1);break;default:s="unknown key:"+o+" "+e[o],t=!1}}return{valid:t,tips:s}}}class ro{constructor(e){this.MAX_LENGTH=e,this.map=new Map}set(e){if(this.map.size>=this.MAX_LENGTH){let e=this.map.entries().next().value[0];this.map.delete(e)}this.map.set(e,1)}has(e){return this.map.has(e)}delete(e){this.has(e)&&this.map.delete(e)}reset(){this.map.clear()}}let ao=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];class lo{constructor(e){this.groupID="",this.name="",this.avatar="",this.type="",this.introduction="",this.notification="",this.ownerID="",this.createTime="",this.infoSequence="",this.lastInfoTime="",this.selfInfo={messageRemindType:"",joinTime:"",nameCard:"",role:"",userID:"",memberCustomField:void 0,readedSequence:0,excludedUnreadSequenceList:void 0},this.lastMessage={lastTime:"",lastSequence:"",fromAccount:"",messageForShow:""},this.nextMessageSeq="",this.memberNum="",this.memberCount="",this.maxMemberNum="",this.maxMemberCount="",this.joinOption="",this.inviteOption="",this.groupCustomField=[],this.muteAllMembers=!1,this.isSupportTopic=!1,this._lastRevokedTime=0,this._initGroup(e)}set memberNum(e){}set maxMemberNum(e){}get memberNum(){return this.memberCount}get maxMemberNum(){return this.maxMemberCount}_initGroup(e){for(var t in e)ao.indexOf(t)<0||("selfInfo"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),"isSupportTopic"!==t?this[t]=e[t]:this.isSupportTopic=1===e[t]):this.updateSelfInfo(e[t]))}updateGroup(e){e.appid=void 0,e.grossTopicNextMsgSeq=void 0,e.selfInfo&&(e.selfInfo.grossTopicReadSeq=void 0),e=JSON.parse(JSON.stringify(e)),e.lastMsgTime&&(this.lastMessage.lastTime=e.lastMsgTime),Be(e.muteAllMembers)||("On"===e.muteAllMembers?e.muteAllMembers=!0:e.muteAllMembers=!1),e.groupCustomField&&nt(this.groupCustomField,e.groupCustomField),Be(e.memberNum)||(this.memberCount=e.memberNum),Be(e.maxMemberNum)||(this.maxMemberCount=e.maxMemberNum),Be(e.isSupportTopic)||(this.isSupportTopic=be(e.isSupportTopic)?1===e.isSupportTopic:e.isSupportTopic),je(this,e,["members","errorCode","lastMsgTime","groupCustomField","memberNum","maxMemberNum","isSupportTopic"]),Ve(e.members)&&0<e.members.length&&e.members.forEach((e=>{e.userID===this.selfInfo.userID&&je(this.selfInfo,e,["sequence"])}))}updateSelfInfo({nameCard:e,joinTime:t,role:s,messageRemindType:i,readedSequence:o,excludedUnreadSequenceList:n}){e={nameCard:e,joinTime:t,role:s,messageRemindType:i,readedSequence:o,excludedUnreadSequenceList:n},je(this.selfInfo,{...e},[],["",null,void 0,0,NaN])}setSelfNameCard(e){this.selfInfo.nameCard=e}}let co=function(e,t,s){return Be(e)?{lastTime:0,lastSequence:0,fromAccount:"",messageForShow:"",payload:null,type:"",isRevoked:!1,cloudCustomData:"",onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:!1,revoker:null}:s&&e.ID||e instanceof Hi?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:St(e.type,e.payload,t),payload:e.payload||null,type:e.type||null,isRevoked:e.isRevoked||!1,cloudCustomData:e.cloudCustomData||"",onlineOnlyFlag:e._onlineOnlyFlag||!1,nick:e.nick||"",nameCard:e.nameCard||"",version:e.version||0,isPeerRead:e.isPeerRead||!1,revoker:e.revoker||null}:{...e,messageForShow:St(e.type,e.payload,t)}};class _o{constructor(e,t,s=!1){this.conversationID=e.conversationID||"",this.unreadCount=e.unreadCount||0,this.type=e.type||"",this.lastMessage=co(e.lastMessage,t,s),e.lastMsgTime&&(this.lastMessage.lastTime=e.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=e.peerReadTime||0,this.groupAtInfoList=[],this.remark="",this.isPinned=e.isPinned||!1,this.messageRemindType=e.messageRemindType,this.markList=e.markList||[],this.customData=e.customData||"",this.conversationGroupList=e.conversationGroupList||[],this.draftText=e.draftText||"",this._initProfile(e),this.subType=this.groupProfile?this.groupProfile.type:""}get toAccount(){return this.conversationID.startsWith(o.CONV_C2C)?this.conversationID.replace(o.CONV_C2C,""):this.conversationID.startsWith(o.CONV_GROUP)?this.conversationID.replace(o.CONV_GROUP,""):""}_initProfile(e){Object.keys(e).forEach((t=>{switch(t){case"userProfile":this.userProfile=e.userProfile;break;case"groupProfile":this.groupProfile=e.groupProfile}})),Be(this.userProfile)&&this.type===o.CONV_C2C?this.userProfile=new no({userID:e.conversationID.replace("C2C","")}):Be(this.groupProfile)&&this.type===o.CONV_GROUP&&(this.groupProfile=new lo({groupID:e.conversationID.replace("GROUP","")}))}updateUnreadCount(e){var{nextUnreadCount:e,isFromGetConversations:t,isUnreadC2CMessage:s}=e;Be(e)||(at(this.subType)?this.unreadCount=0:t&&this.type===o.CONV_GROUP||t&&this.type===o.CONV_TOPIC||s&&this.type===o.CONV_C2C?this.unreadCount=e:this.unreadCount=this.unreadCount+e)}updateLastMessage(e){this.lastMessage=co(e)}updateGroupAtInfoList(e){if(!this._isNeedMergeGroupAtInfo(e)){let[...t]=e.groupAtType;-1!==t.indexOf(o.CONV_AT_ME)&&-1!==t.indexOf(o.CONV_AT_ALL)&&(t=[o.CONV_AT_ALL_AT_ME]),e={from:e.from,groupID:e.groupID,topicID:e.topicID,messageSequence:e.sequence,atTypeArray:t,__random:e.__random,__sequence:e.__sequence},this.groupAtInfoList.push(e)}}_isNeedMergeGroupAtInfo(e){let{groupID:t,sequence:s}=e;if(!lt({groupID:t}))return!1;let i=!1;return this.groupAtInfoList.forEach((t=>{t.messageSequence===s&&(-1<t.atTypeArray.indexOf(o.CONV_AT_ME)&&-1<e.groupAtType.indexOf(o.CONV_AT_ALL)&&(t.atTypeArray=[o.CONV_AT_ALL_AT_ME]),-1<t.atTypeArray.indexOf(o.CONV_AT_ALL)&&-1<e.groupAtType.indexOf(o.CONV_AT_ME)&&(t.atTypeArray=[o.CONV_AT_ALL_AT_ME],t.__random=e.__random,t.__sequence=e.__sequence),i=!0)})),i}clearGroupAtInfoList(){this.groupAtInfoList.length=0}reduceUnreadCount(){return 1<=this.unreadCount&&(--this.unreadCount,!0)}isLastMessageRevoked({sequence:e,time:t}){return this.type===o.CONV_C2C&&e===this.lastMessage.lastSequence&&t===this.lastMessage.lastTime||this.type===o.CONV_GROUP&&e===this.lastMessage.lastSequence}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}setDraftText(e){this.draftText=e}}let uo={[o.MSG_REMIND_ACPT_AND_NOTE]:0,[o.MSG_REMIND_DISCARD]:1,[o.MSG_REMIND_ACPT_NOT_NOTE]:2};class ho{constructor(e){this._convM=e,this._n="MsgRemindHandler"}onAllRcvMsgOptNotify(e){e=this._handleResult(e),this._convM.emitOEvt(i.ALL_RECEIVE_MESSAGE_OPT_UPDATED,e)}getC2CMsgRemindType(e){let t=this._n+".getC2CMsgRemindType";return this._convM.req({P:di.GET_C2C_PEER_MUTE_NOTIFICATIONS,data:{toAccount:this._convM.getMyUserID(),userIDList:e}}).then((s=>{ye.l(t+" ok. userIDList:"+e),s=s.data.muteFlagList,this._convM.onC2CMsgRemindTypeFetched(s)})).catch((e=>{ye.e(t+" failed. error:",e)}))}set(e){return e.groupID?this._setGroupMsgRemindType(e):Ve(e.userIDList)?this._setC2CMsgRemindType(e):void 0}_setGroupMsgRemindType(e){let t=this._n+"._setGroupMsgRemindType",{groupID:s,messageRemindType:i}=e,o=`groupID:${s} messageRemindType:`+i,n=new Ei("_setGroupMsgRemindType");n.setMessage(o);var r=this._get(Ds);return r?r.modifyGroupMemberInfo({groupID:s,messageRemindType:i,userID:this._convM.getMyUserID()}).then((()=>{n.end(),ye.l(t+" ok. "+o);var s=this.onGroupMsgRemindTypeUpdated(e);return this._convM.onTotalUnreadCountUpdate(),ti(s)})).catch((e=>(n.setError(e).end(),ye.e(t+" failed. error:",e),ai(e)))):ai({code:ii.NO_MODULE})}onGroupMsgRemindTypeUpdated(e){var{groupID:t,messageRemindType:s}=e;ye.l(this._n+`.onGroupMsgRemindTypeUpdated groupID:${t} messageRemindType:`+s);let o=this._get(Ds).getLocalGroupProfile(t);if(o&&(o.selfInfo.messageRemindType=s),dt(t)){let e=t,o=Et(e),n=this._get(Ls).getLocalTopic(o,e);return n&&n.updateSelfInfo({messageRemindType:s})&&this._convM.emitOEvt(i.TOPIC_UPDATED,{groupID:o,topic:n}),{topic:n}}return this._convM.patchMsgRemindType({ID:t,isC2CConversation:!1,messageRemindType:s})&&this._emitConvUpdate(),{group:o}}_setC2CMsgRemindType(e){let t=this._n+"._setC2CMsgRemindType",{userIDList:s,messageRemindType:i}=e,o=s.slice(0,30),n=uo[i]||0,r=`userIDList:${o} messageRemindType:`+i,a=new Ei("_setC2CMsgRemindType");return a.setMessage(r),this._convM.req({P:di.SET_C2C_PEER_MUTE_NOTIFICATIONS,data:{userIDList:o,muteFlag:n}}).then((e=>{a.end();let s=e.data["errorList"],n=[],l=[];Ve(s)&&s.forEach((e=>{n.push(e.userID),l.push({userID:e.userID,code:e.errorCode})})),e=o.filter((e=>-1===n.indexOf(e))),ye.l(t+` ok. ${r} successUserIDList:${e} failureUserIDList:`+JSON.stringify(l));let d=0;return e.forEach((e=>{this._convM.patchMsgRemindType({ID:e,isC2CConversation:!0,messageRemindType:i})&&(d+=1)})),1<=d&&this._emitConvUpdate(),o.length=n.length=0,this._convM.onTotalUnreadCountUpdate(),ri({successUserIDList:e.map((e=>({userID:e}))),failureUserIDList:l})})).catch((e=>(a.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}_get(e){return this._convM.get(e)}_emitConvUpdate(){this._convM.emitConvUpdate(!0,!1)}setAllRcvMsgOpt(e){let t=this._n+".setAllRcvMsgOpt",{messageRemindType:s=o.MSG_REMIND_ACPT_NOT_NOTE,isRepeated:i=!0}=e,{startTime:n=0,endTime:r=0}=this._calcStartAndEndTime(e),a=JSON.stringify(e),l=new Ei("setAllRcvMsgOpt");return l.setMessage(a),ye.l(t+" options:"+a),this._convM.req({P:di.SET_ALL_RECEIVE_MSG_OPT,data:{messageRemindType:uo[s],startTime:n,endTime:r,isRepeated:i?1:0}}).then((e=>(l.end(),ye.l(t+" ok."),ti(e)))).catch((e=>(l.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}_calcStartAndEndTime(e){var{startHour:e=0,startMinute:t=0,startSecond:s=0,duration:i=0,isRepeated:o=!0}=e,n=new Date,r=n.getFullYear(),a=n.getMonth();n=n.getDate(),r=Math.round(new Date(r,a,n,e,t,s).getTime()/1e3);let l=o&&86400<=i?r+86400:r+i;return{startTime:r,endTime:l}}getAllRcvMsgOpt(){let e=this._n+".getAllRcvMsgOpt",t=new Ei("getAllRcvMsgOpt");return this._convM.req({P:di.GET_ALL_RECEIVE_MSG_OPT,data:{toAccount:this._convM.getMyUserID()}}).then((s=>(s=s.data,t.setMessage(JSON.stringify(s)).end(),ye.l(e+" ok. data:"+JSON.stringify(s)),s=this._handleResult(s),ti(s)))).catch((s=>(t.setError(s).end(),ye.e(e+" failed. error:",s),ai(s))))}_handleResult(e){var{messageRemindType:e,startTime:t,endTime:s,isRepeated:i}=e;let n=o.MSG_REMIND_ACPT_AND_NOTE;return 1===e&&(n=o.MSG_REMIND_DISCARD),{messageRemindType:n=2===e?o.MSG_REMIND_ACPT_NOT_NOTE:n,startTime:t,endTime:s,isRepeated:1===i}}reset(){ye.l(this._n+".reset")}}class po{constructor(e){this._convM=e,this._n="ConvGroupHandler",this._convGroupMap=new Map,this._startIndex=0,this._pagingStatus=wt}setConvCustomData(e){let t=this._n+".setConvCustomData",{conversationIDList:s,customData:i}=e,n=(ye.l(t+" options:",e),new Ei("setConvCustomData")),r=(n.setMessage(JSON.stringify(e)),{fromAccount:this._getMyUserID(),itemList:[]}),a=[],l=[];return s.forEach((e=>{var t;return this._hasLocalConv(e)?ct(e)||_t(e)?(t={operationType:2,contactItem:void 0,customMark:i},ct(e)?t.contactItem={type:1,toAccount:e.replace(o.CONV_C2C,"")}:_t(e)&&(t.contactItem={type:2,groupID:e.replace(o.CONV_GROUP,"")}),void r.itemList.push(t)):(this._onConvIDInvalid(l,e),!0):(this._onConvNotFound(l,e),!0)})),l.length===s.length?ri({successConversationIDList:a,failureConversationIDList:l}):this._convM.req({P:di.SET_CONV_CUSTOM_DATA,data:r}).then((e=>{if(n.end(),ye.l(t+" ok"),e=e.data.resultItem,Ve(e)){let t,s,o=!1;e.forEach((e=>{t=this._concatConvID(e.contactItem),0===e.resultCode?(a.push(t),(s=this._getLocalConv(t))&&s.customData!==i&&(s.customData=i,o=!0)):l.push({conversationID:t,code:e.resultCode,message:e.resultInfo})})),!0===o&&this._emitConvUpdate()}return ti({successConversationIDList:a,failureConversationIDList:l})})).catch((e=>(n.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}markConv(e){if(!this._convM.canIUse(y.CONV_MARK))return this._convM.noUse("markConv");let t,s=this._n+".markConv",{conversationIDList:i,markType:n,enableMark:r}=e,a=(ye.l(s+" options:",e),new Ei("markConv")),l=void a.setMessage(JSON.stringify(e));e=this._getFlagBit(n),!0===r?t=[e]:l=[e];let d={fromAccount:this._getMyUserID(),itemList:[]},c=[],_=[];return i.forEach((e=>{var s;return this._hasLocalConv(e)?ct(e)||_t(e)?(s={operationType:1,contactItem:void 0,clearMark:l,setMark:t},ct(e)?s.contactItem={type:1,toAccount:e.replace(o.CONV_C2C,"")}:_t(e)&&(s.contactItem={type:2,groupID:e.replace(o.CONV_GROUP,"")}),void d.itemList.push(s)):(this._onConvIDInvalid(_,e),!0):(this._onConvNotFound(_,e),!0)})),_.length===i.length?ri({successConversationIDList:c,failureConversationIDList:_}):this._convM.req({P:di.MARK_CONV,data:d}).then((e=>{if(a.end(),ye.l(s+" ok"),e=e.data.resultItem,Ve(e)){let t,s,i=!1;e.forEach((e=>{if(t=this._concatConvID(e.contactItem),0===e.resultCode){if(c.push(t),s=this._getLocalConv(t)){let e=s.markList.indexOf(n);!0===r?-1===e&&(s.markList.push(n),i=!0):-1!==e&&(s.markList.splice(e,1),i=!0)}}else _.push({conversationID:t,code:e.resultCode,message:e.resultInfo})})),!0===i&&this._emitConvUpdate()}return ti({successConversationIDList:c,failureConversationIDList:_})})).catch((e=>(a.setError(e).end(),ye.e(s+" failed. error:",e),ai(e))))}getLocalConvGroupList(){return ye.l(this._n+".getLocalConvGroupList pagingStatus:"+this._pagingStatus),this._pagingStatus===qt?this.getRemoteConvGroupList().then((()=>ti([...this._convGroupMap.values()]))):ri([...this._convGroupMap.values()])}searchConvGroupAndMark(e,t){let s=this._n+".searchConvGroupAndMark",i=[];return e.forEach((e=>{1===t?i.push({type:1,toAccount:e}):2===t&&i.push({type:2,groupID:e})})),ye.l(s+` type:${t} list:`,e),this._convM.req({P:di.SEARCH_CONV_GRP_MARK,data:{fromAccount:this._getMyUserID(),contactItem:i}}).then((e=>{var{contactItem:e,groupItem:t}=e.data;ye.l(s+" ok. contactItem:",e,"groupItem:",t),this._fillConvGroupMap(t),this._handleContactItem(e),this._emitConvUpdate()})).catch((e=>{ye.w(s+" failed. error:",e)}))}_fillConvGroupMap(e){Ve(e)&&e.forEach((e=>{var{convGroupID:e,groupName:t}=e;this._convGroupMap.set(e,t)}))}_handleContactItem(e){if(Ve(e)){let t,s;e.forEach((e=>{let i=[],{standardMark:o,customData:n,convGroupIDList:r}=e;Ve(r)&&r.forEach((e=>{this._convGroupMap.has(e)&&i.push(this._convGroupMap.get(e))})),s=this._concatConvID(e),(t=this._getLocalConv(s))&&(t.markList=Dt(o),t.customData=n||"",t.conversationGroupList=[...i])}))}}getRemoteConvGroupList(){let e=this._n+".getRemoteConvGroupList";return this._pagingStatus=bt,this._convM.req({P:di.GET_CONV_GRP_LIST,data:{fromAccount:this._getMyUserID(),startIndex:this._startIndex}}).then((t=>{var{completeFlag:t,contactItem:s,nextStartIndex:i=0,groupItem:o}=t.data;if(this._startIndex=i,ye.l(e+` completeFlag:${t} nextStartIndex:${i}, groupItem:`,o,"contactItem:",s),this._fillConvGroupMap(o),this._handleContactItem(s),0===t)return this.getRemoteConvGroupList();1===t&&(this._pagingStatus=Ft,this._emitConvUpdate(),this._emitConvGroupListUpdate())})).catch((t=>{this._pagingStatus=qt,ye.w(e+" failed. error:",t)}))}createConvGroup(e){if(!this._convM.canIUse(y.CONV_GROUP))return this._convM.noUse("createConvGroup");let t=this._n+".createConvGroup",s=(ye.l(t+" options:",e),new Ei("createConvGroup")),{groupName:i,conversationIDList:n}=(s.setMessage(JSON.stringify(e)),e),r={fromAccount:this._getMyUserID(),itemList:[{groupName:i,contactItem:[]}]},a=[],l=[];return n.forEach((e=>this._hasLocalConv(e)?ct(e)||_t(e)?void(ct(e)?r.itemList[0].contactItem.push({type:1,toAccount:e.replace(o.CONV_C2C,"")}):_t(e)&&r.itemList[0].contactItem.push({type:2,groupID:e.replace(o.CONV_GROUP,"")})):(this._onConvIDInvalid(l,e),!0):(this._onConvNotFound(l,e),!0))),l.length===n.length?ri({successConversationIDList:a,failureConversationIDList:l}):this._convM.req({P:di.CREATE_CONV_GRP,data:r}).then((e=>{s.end(),ye.l(t+" ok");e=e.data["groupResultItem"];var{groupItem:e,resultItem:o}=e[0];if(xe(e)&&(this._convGroupMap.set(e.convGroupID,e.groupName),this._emitConvGroupListUpdate()),Ve(o)){let e,t,s=!1;o.forEach((o=>{e=this._concatConvID(o.contactItem),0===o.resultCode?(a.push(e),(t=this._getLocalConv(e))&&-1===t.conversationGroupList.indexOf(i)&&(t.conversationGroupList.push(i),s=!0)):l.push({conversationID:e,code:o.resultCode,message:o.resultInfo})})),!0===s&&(this._emitConvUpdate(),this._emitConvGroupListUpdate())}return ti({successConversationIDList:a,failureConversationIDList:l})})).catch((e=>(s.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}deleteConvGroup(e){if(!this._convM.canIUse(y.CONV_GROUP))return this._convM.noUse("deleteConvGroup");let t=this._n+".deleteConvGroup",s=(ye.l(t+" groupName:"+e),new Ei("deleteConvGroup"));return s.setMessage(e),this._convM.req({P:di.DEL_CONV_GRP,data:{fromAccount:this._getMyUserID(),groupName:[e]}}).then((i=>{if(s.end(),ye.l(t+" ok"),i=i.data.groupItem,Ve(i)){let e=!1;i.forEach((t=>{this._convGroupMap.has(t.convGroupID)&&(this._convGroupMap.delete(t.convGroupID),e=!0)})),!0===e&&this._emitConvGroupListUpdate()}this._eraseFromConversationGroupList([e])})).catch((e=>(s.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}renameConvGroup(e){if(!this._convM.canIUse(y.CONV_GROUP))return this._convM.noUse("renameConvGroup");let t=this._n+".renameConvGroup",s=(ye.l(t+" options:",e),new Ei("renameConvGroup")),{oldName:i,newName:o}=(s.setMessage(JSON.stringify(e)),e);return this._convM.req({P:di.RENAME_CONV_GRP,data:{fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:1,oldName:i,newName:o}}}).then((e=>{s.end(),ye.l(t+" ok"),e=e.data.updateGroupResult,e=e.convGroupID,this._convGroupMap.set(e,o),this._emitConvGroupListUpdate(),e=this._convM.getLocalConvList();let n,r,a=!1;e.forEach((e=>{n=e.conversationGroupList,-1!==(r=n.indexOf(i))&&(n.splice(r,1,o),a=!0)})),!0===a&&this._emitConvUpdate()})).catch((e=>(s.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}addConvsToGroup(e){if(!this._convM.canIUse(y.CONV_GROUP))return this._convM.noUse("addConvsToGroup");let t=this._n+".addConvsToGroup",s=(ye.l(t+" options:",e),new Ei("addConvsToGroup")),{conversationIDList:i,groupName:n}=(s.setMessage(JSON.stringify(e)),e),r={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:n,updateItem:[]}},a=[],l=[];return i.forEach((e=>this._hasLocalConv(e)?ct(e)||_t(e)?void(ct(e)?r.updateGroup.updateItem.push({operationType:1,contactItem:{type:1,toAccount:e.replace(o.CONV_C2C,"")}}):_t(e)&&r.updateGroup.updateItem.push({operationType:1,contactItem:{type:2,groupID:e.replace(o.CONV_GROUP,"")}})):(this._onConvIDInvalid(l,e),!0):(this._onConvNotFound(l,e),!0))),l.length===i.length?ri({successConversationIDList:a,failureConversationIDList:l}):this._convM.req({P:di.ADD_CONV_TO_GRP,data:r}).then((e=>{if(s.end(),ye.l(t+" ok"),e=e.data.updateGroupResult.contactResultItem,Ve(e)){let t,s,i=!1;e.forEach((e=>{t=this._concatConvID(e.contactItem),0===e.resultCode?(s=this._getLocalConv(t))&&-1===s.conversationGroupList.indexOf(n)&&(s.conversationGroupList.push(n),a.push(t),i=!0):l.push({conversationID:t,code:e.resultCode,message:e.resultInfo})})),!0===i&&(this._emitConvUpdate(),this._emitConvInGroupUpdate(n))}return ti({successConversationIDList:a,failureConversationIDList:l})})).catch((e=>(s.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}deleteConvsFromGroup(e){var t="deleteConvsFromGroup";if(!this._convM.canIUse(y.CONV_GROUP))return this._convM.noUse(t);let s=this._n+"."+t,i=(ye.l(s+" options:",e),new Ei(t)),{conversationIDList:n,groupName:r}=(i.setMessage(JSON.stringify(e)),e),a={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:r,updateItem:[]}},l=[],d=[];return n.forEach((e=>this._hasLocalConv(e)?ct(e)||_t(e)?void(ct(e)?a.updateGroup.updateItem.push({operationType:2,contactItem:{type:1,toAccount:e.replace(o.CONV_C2C,"")}}):_t(e)&&a.updateGroup.updateItem.push({operationType:2,contactItem:{type:2,groupID:e.replace(o.CONV_GROUP,"")}})):(this._onConvIDInvalid(d,e),!0):(this._onConvNotFound(d,e),!0))),d.length===n.length?ri({successConversationIDList:l,failureConversationIDList:d}):this._convM.req({P:di.DEL_CONV_FROM_GRP,data:a}).then((e=>{if(i.end(),ye.l(s+" ok"),e=e.data.updateGroupResult.contactResultItem,Ve(e)){let t,s,i=!1;e.forEach((e=>{if(t=this._concatConvID(e.contactItem),0===e.resultCode){if(s=this._getLocalConv(t)){let e=s.conversationGroupList.indexOf(r);-1!==e&&(s.conversationGroupList.splice(e,1),l.push(t),i=!0)}}else d.push({conversationID:t,code:e.resultCode,message:e.resultInfo})})),!0===i&&(this._emitConvUpdate(),this._emitConvInGroupUpdate(r))}return ti({successConversationIDList:l,failureConversationIDList:d})})).catch((e=>(i.setError(e).end(),ye.e(s+" failed. error:",e),ai(e))))}onConvMarkUpdated(e){if(!Ue(e)){let t,s,i=(ye.l(this._n+".onConvMarkUpdated markItemList:",e),!1);e.forEach((e=>{var{recentContactItem:e,optType:o,standardMark:n,customMark:r}=e;if(t=this._concatConvID(e),s=this._getLocalConv(t))if(1===o)i=this._diffStandardMark(s,n);else if(2===o)i=this._diffCustomMark(s,r);else if(3===o){let e=this._diffStandardMark(s,n),t=this._diffCustomMark(s,r);i=e||t}})),!0===i&&this._emitConvUpdate()}}_diffStandardMark(e,t){t=Dt(t);let s=!1;return!0!==function(e,t){if(e!==t){if(!e||!t)return!1;if(e.length!==t.length)return!1;for(let s=0,i=e.length;s<i;s++)if(e[s]!==t[s])return!1}return!0}(e.markList,t)&&(e.markList=t,s=!0),s}_diffCustomMark(e,t){let s=!1;return e.customData!==t&&void 0!==t&&(e.customData=t,s=!0),s}onConvGroupCreated(e){ye.l(this._n+".onConvGroupCreated resultList:",e);let t=!1,s=!1;Ve(e)&&(e.forEach((e=>{let{groupID:i,groupName:o}=e.msgGroupItem;if(this._convGroupMap.get(i)!==o&&(this._convGroupMap.set(i,o),s=!0),e=e.msgRecentContactItem,Ve(e)){let s,i;e.forEach((e=>{s=this._concatConvID(e),(i=this._getLocalConv(s))&&-1===i.conversationGroupList.indexOf(o)&&(i.conversationGroupList.push(o),t=!0)}))}})),!0===t&&this._emitConvUpdate(),!0===s)&&this._emitConvGroupListUpdate()}onConvGroupDeleted(e){ye.l(this._n+".onConvGroupDeleted groupItemList:",e);let t=[];if(Ve(e)){let s=!1;e.forEach((e=>{var{groupID:e,groupName:i}=e;this._convGroupMap.has(e)&&(this._convGroupMap.delete(e),s=!0,t.push(i))})),!0===s&&this._emitConvGroupListUpdate()}this._eraseFromConversationGroupList(t)}_eraseFromConversationGroupList(e){Ue(e)||(this._convM.getLocalConvList().forEach((t=>{t.conversationGroupList=t.conversationGroupList.filter((t=>!e.includes(t)))})),this._emitConvUpdate())}onConvGroupNameUpdated(e){ye.l(this._n+".onConvGroupNameUpdated options:",e);let{groupID:t,groupName:s,oldGroupName:i}=e;if(this._convGroupMap.get(t)!==s){this._convGroupMap.set(t,s),this._emitConvGroupListUpdate(),e=this._convM.getLocalConvList();let o,n,r=!1;e.forEach((e=>{o=e.conversationGroupList,-1!==(n=o.indexOf(i))&&(o.splice(n,1,s),r=!0)})),!0===r&&this._emitConvUpdate()}}onConvInGroupUpdated(e){ye.l(this._n+".onConvInGroupUpdated options:",e);let{oldGroupName:t,recentContactUpdateGroupItem:s}=e;if(Ve(s)){let e,i,o,n=!1;s.forEach((s=>{var{contactOptType:s,recentContactItem:r}=s;e=this._concatConvID(r),(i=this._getLocalConv(e))&&(o=i.conversationGroupList.indexOf(t),1===s?-1===o&&(i.conversationGroupList.push(t),n=!0):2===s&&-1!==o&&(i.conversationGroupList.splice(o,1),n=!0))})),!0===n&&(this._emitConvUpdate(),this._emitConvInGroupUpdate(t))}}onConvAddedToOrDeletedFromGroup(e){ye.l(this._n+".onConvAddedToOrDeletedFromGroup options:",e);let{msgRecentContactItem:t,msgRecentContactUpdateContactItem:s}=e,i=this._concatConvID(t),o=this._getLocalConv(i);if(o&&Ve(s)){let e,t=!1;s.forEach((s=>{var{groupOptType:s,recentContactGroupItem:i}=s,i=i["groupName"];e=o.conversationGroupList.indexOf(i),1===s?-1===e&&(o.conversationGroupList.push(i),t=!0):2===s&&-1!==e&&(o.conversationGroupList.splice(e,1),t=!0),!0===t&&this._emitConvInGroupUpdate(i)})),!0===t&&this._emitConvUpdate()}}onConvGroupListSynced(e){Ve(e)&&0!==e.length&&(ye.l(this._n+".onConvGroupListSynced groupItem:",e),this._fillConvGroupMap(e))}getConvGroupListByID(e){if(!Ue(e)){let t=[];return e.forEach((e=>{this._convGroupMap.has(e)&&t.push(this._convGroupMap.get(e))})),t}}_onConvNotFound(e,t){e.push({conversationID:t,code:ii.CONV_NOT_FOUND,message:this._convM.getErrMsg(ii.CONV_NOT_FOUND)})}_onConvIDInvalid(e,t){e.push({conversationID:t,code:ii.INVALID_CONV_ID,message:this._convM.getErrMsg(ii.INVALID_CONV_ID)})}_getFlagBit(e){var t=e.toString(2),s=t.length;for(let i=s-1;0<=i;i--)if("1"===t[i])return s-i-1}_concatConvID(e){var{type:e,to:t,groupID:s,userID:i}=e;let n;return 1===e?Be(i)?Be(t)||(n=""+o.CONV_C2C+t):n=""+o.CONV_C2C+i:2===e&&(n=""+o.CONV_GROUP+s),n}_getMyUserID(){return this._convM.getMyUserID()}_getLocalConv(e){return this._convM.getLocalConversation(e)}_hasLocalConv(e){return this._convM.hasLocalConversation(e)}_emitConvUpdate(){this._convM.emitConvUpdate(!0,!1)}_emitConvGroupListUpdate(){this._convM.emitOEvt(i.CONVERSATION_GROUP_LIST_UPDATED,[...this._convGroupMap.values()])}_emitConvInGroupUpdate(e){var t={groupName:e,conversationList:[]},s=this._convM.getLocalConvList();t.conversationList=s.filter((t=>t.conversationGroupList.includes(e))),this._convM.emitOEvt(i.CONVERSATION_IN_GROUP_UPDATED,t)}reset(){ye.l(this._n+".reset"),this._convGroupMap.clear(),this._startIndex=0,this._pagingStatus=wt}}class go extends li{constructor(e){super(e),this._n="ConvModule",Zi.mixin(this),this._msgListHandler=new Xi(this),this._msgRemindHandler=new ho(this),this._convGroupHandler=new po(this),this._sll=new ro(100),this._pagingStatus=wt,this._pagingTs=0,this._pagingStartIdx=0,this._pagingPinnedTs=0,this._pagingPinnedStartIdx=0,this._pagingConvIDMap=new Map,this._convIDFromUnreadDBMap=new Map,this._convMap=new Map,this._tmpGroupList=[],this._tmpGroupAtTipsList=[],this._peerReadTimeMap=new Map,this._completedMap=new Map,this._roamingMsgKeyAndTimeMap=new Map,this._remoteGroupReadSeqMap=new Map,this._convTotalUnreadCount=0,this._pagingGetCostList=[],this._convMapForDiff=new Map,this._partialUpdatedConvMap=new Map,this._everClearedMap=new Map,this._bPullOnInvite=!0,this._initListeners()}_initListeners(){var e=this.getIEmitInst();e.on(Ji.A2KEY_AND_TINYID_UPDATED,this._init,this),e.on(Ji.PROFILE_UPDATED,this._onProfileUpdated,this),e.on(Ji.CLOUD_CONFIG,this._onCloudConfig,this)}_init(){ye.l(this._n+"._init");var e=this.get(Ns).getItem("conversationMap"),t=this.isIntl(),s=this.isUsingChatCore();if(e){var i=e.length;for(let n=0;n<i;n++){var o=e[n];if(o){if(this._isNonExistentAccount(o.conversationID))continue;if(o.groupProfile&&at(o.groupProfile.type))continue}this._convMap.set(o.conversationID,new _o(e[n],t,s))}this.emitConvUpdate(!0,!1)}this.ready((()=>{0<this._tmpGroupList.length&&(this.updateConvGroupProfile(this._tmpGroupList),this._tmpGroupList.length=0)})),this.syncConvList()}_isNonExistentAccount(e){let t;return"@TLS#ERROR"===(t=e.startsWith(o.CONV_C2C)?e.replace(o.CONV_C2C,""):t)||"@TLS#NOT_FOUND"===t}onCheckTimer(e){this.isLoggedIn()&&this._msgListHandler.onCheckTimer(e)}onMessageSent(e){this._onSendOrRcvMsg({conversationOptionsList:e.conversationOptionsList,isInstantMessage:!0})}onNewMessage(e){this._onSendOrRcvMsg(e)}_onSendOrRcvMsg(e){var{conversationOptionsList:t,isInstantMessage:s=!0,isUnreadC2CMessage:i=!1,updateUnreadCount:o=!0,isSyncingEnded:n=!1}=e;this._isReady?0===t.length?n&&this.emitIEvt(Ji.C2C_UNREAD_HANDLE_COMPLETED):(!0===s&&this._checkNewConv(t),this._updateLocalConvList({conversationOptionsList:t,isInstantMessage:s,isUnreadC2CMessage:i,isFromGetConversations:!1,updateUnreadCount:o}),s||(this._convIDFromUnreadDBMap=new Map([...this._convIDFromUnreadDBMap,...t.map((e=>[e.conversationID,1]))]),this._diffAndDeleteConv(),n&&this.emitIEvt(Ji.C2C_UNREAD_HANDLE_COMPLETED)),0<t.filter((e=>!this._isConvNeedShow(e.conversationID))).length||this.emitConvUpdate()):this.ready((()=>{this._onSendOrRcvMsg(e)}))}updateConvGroupProfile(e){if(!Ve(e)||0!==e.length)if(0===this._convMap.size)this._tmpGroupList=e;else{let t=!1;e.forEach((e=>{var s=""+o.CONV_GROUP+e.groupID;if(this._convMap.has(s)){t=!0;let i=this._convMap.get(s);i.groupProfile=JSON.parse(JSON.stringify(e)),i.lastMessage.lastSequence<e.nextMessageSeq&&(i.lastMessage.lastSequence=e.nextMessageSeq-1),i.subType||(i.subType=e.type)}})),t&&this.emitConvUpdate(!0,!1)}}onMessageRevoked(e,t){if(0!==e.length){let s=null,i=!1,n=[];e.forEach((e=>{(s=this._convMap.get(e.conversationID))&&(t&&s.reduceUnreadCount()&&(i=s.type!==o.CONV_TOPIC),s.type===o.CONV_TOPIC?n.push(e):s.isLastMessageRevoked({sequence:e.sequence,time:e.time})&&(s.setLastMessageRevoked(!0),s.setLastMessageRevoker(e.revoker),i=!0))})),this.get(Ls).onMessageRevoked(n),i&&this.emitConvUpdate(!0,!1)}}updateRevokerInfo(e){var t=new Set;for(let o=0;o<e.length;o++){let s=e[o]["revoker"];t.add(s)}let s=[...t],i=this.get(Es);return new Promise((t=>{i.getUserProfile({userIDList:s}).then((s=>{if(s=s.data,!Ve(s)||0===s.length)return t(e);let i={};for(let{userID:e,nick:t,avatar:o}of s)i[e]={nick:t,avatar:o};e.forEach((e=>{var t=e["revoker"];i[t]&&(e.revokerInfo.nick=i[t].nick||"",e.revokerInfo.avatar=i[t].avatar||"")})),t(e)})).catch((()=>{t(e)}))}))}isLastMessageRevoked(e){let t=!1;var{conversationID:s,sequence:i,time:n}=e,r=this._convMap.get(s);return r&&(t=r.type===o.CONV_TOPIC?this.get(Ls).isLastMessageRevoked({topicID:s.replace(o.CONV_GROUP,""),sequence:i}):r.isLastMessageRevoked({sequence:i,time:n})),ye.l(this._n+".isLastMessageRevoked options:",e,"ret:"+t),t}onMessageDeleted(e){if(0!==e.length){let i=null;e.forEach((e=>{(i=this._msgListHandler.getLocalMsg(e.conversationID,e.ID))&&(i.isDeleted=!0),e!==i&&(e.isDeleted=!0)}));e=e[0].conversationID;var t=this._msgListHandler.getLocalMsgList(e);let n={};for(let e=t.length-1;0<=e;e--)if(!t[e].isDeleted){n=t[e];break}var s=this._convMap.get(e);if(s){let t=!1;s.lastMessage.lastSequence===n.sequence&&s.lastMessage.lastTime===n.time||(Ue(n)&&(n=void 0),s.updateLastMessage(n),s.type!==o.CONV_TOPIC&&(t=!0),ye.l(this._n+`.onMessageDeleted. update convID:${e} with lastMessage:`,s.lastMessage)),e.startsWith(o.CONV_C2C)&&this.updateUnreadCount(e),t&&this.emitConvUpdate(!0,!1)}}}onMessageModified(e){var t=this._n+".onMessageModified",{conversationType:s,from:n,to:r,time:a,sequence:l,elements:d,cloudCustomData:c,messageVersion:_}=e;let u=""+s+r;r===this.getMyUserID()&&s===o.CONV_C2C&&(u=""+s+n);var{isUpdated:s,message:h}=this._msgListHandler.onMsgModified(u,e),p=(!0===s&&this.emitOEvt(i.MESSAGE_MODIFIED,[h]),this._isTopicConv(u));if(null===h?ye.l(t+" message is null! options:",e):ye.l(t+` isUpdated:${s} isTopicMessage:${p} from:${n} to:${r} sequence:${h.sequence} time:`+h.time),p)this.get(Ls).onMessageModified(e);else{let e=this._convMap.get(u);if(e){let s=e.lastMessage;s&&s.lastTime===a&&s.lastSequence===l&&s.version!==_&&(ye.l(t+` convID:${u} lastMessage updated`),s.type=d[0].type,s.payload=d[0].content,s.messageForShow=St(s.type,s.payload,this.isIntl()),s.cloudCustomData=c,s.version=_,this.emitConvUpdate(!0,!1))}}return h}onNewGroupAtTips(e){e=e.dataList;let t=null;e.forEach((e=>{e.groupAtTips?t=e.groupAtTips:e.elements?t={...e.elements,sync:!0}:e.groupAtType&&(t={...e,sync:!0}),t.__random=e.random,t.__sequence=e.clientSequence,this._tmpGroupAtTipsList.push(t)})),ye.l(this._n+".onNewGroupAtTips isReady:"+this._isReady,this._tmpGroupAtTipsList),this._isReady&&this._handleGroupAtTipsList()}_handleGroupAtTipsList(){if(0!==this._tmpGroupAtTipsList.length){let e=!1;this._tmpGroupAtTipsList.forEach((t=>{let{groupID:s,from:i,topicID:n,sync:r=!1}=t;if(i!==this.getMyUserID())if(Be(n)){let i=this._convMap.get(""+o.CONV_GROUP+s);i&&(i.updateGroupAtInfoList(t),e=!0)}else{let e=this._convMap.get(""+o.CONV_GROUP+n);e&&(e.updateGroupAtInfoList(t),this.get(Ls).onAtInfoUpdated({topicID:n,groupAtInfoList:e.groupAtInfoList})),Ue(e)&&r&&(this.updateTopicConversation([{conversationID:""+o.CONV_GROUP+n,type:o.CONV_TOPIC}]),this._convMap.get(""+o.CONV_GROUP+n).updateGroupAtInfoList(t))}})),e&&this.emitConvUpdate(!0,!1),this._tmpGroupAtTipsList.length=0}}_checkNewConv(e){let t=[],s=[];e.forEach((e=>{this._convMap.has(e.conversationID)||(e.type===o.CONV_C2C?t.push(e.conversationID.replace(o.CONV_C2C,"")):e.type===o.CONV_GROUP&&s.push(e.conversationID.replace(o.CONV_GROUP,"")))})),0<t.length&&(this._onNewC2CConv(t),t=null),0<s.length&&(this._onNewGroupConv(s),s=null)}_onNewC2CConv(e){var t=this.get(Ss);return Promise.all([t.getRemotePeerReadTime(e),this._msgRemindHandler.getC2CMsgRemindType(e),this._convGroupHandler.searchConvGroupAndMark(e,1)])}_onNewGroupConv(e){var t=this.get(Ds);return t?Promise.all([t.getMsgRemindType(e),this._convGroupHandler.searchConvGroupAndMark(e,2)]):Promise.resolve()}_setStorageConvList(e=!1){var t=this.getLocalConvList().filter((e=>e.type===o.CONV_C2C||e.type===o.CONV_GROUP&&e.lastMessage.type!==o.MSG_GRP_TIP)).slice(0,20).map((e=>({conversationID:e.conversationID,type:e.type,subType:e.subType,lastMessage:e.lastMessage,groupProfile:e.groupProfile,userProfile:e.userProfile})));this.get(Ns).setItem("conversationMap",t,e)}emitConvUpdate(e=!0,t=!0){var s=this.getLocalConvList();if(t){let e=this.get(Ds);e&&e.updateGroupLastMessage(s)}e&&(this.get(Os).isPartialUpdatedConvs()?(this._diffConvMap(this._convMapForDiff,this._convMap),0<this._partialUpdatedConvMap.size&&(this.emitOEvt(i.CONVERSATION_LIST_UPDATED),this.onTotalUnreadCountUpdate(),this._convMapForDiff.clear(),this._convMapForDiff=Je(this._convMap,!0)),0===this._convMapForDiff.size&&(this._convMapForDiff=Je(this._convMap,!0))):(this.emitOEvt(i.CONVERSATION_LIST_UPDATED),this.onTotalUnreadCountUpdate()))}_diffConvMap(e,t){for(var[s,i]of t)e.has(s)&&JSON.stringify(i)===e.get(s)||this._partialUpdatedConvMap.set(s,i)}getPartialUpdatedConvs(){var e=[...Je(this._partialUpdatedConvMap,!1).values()];return this._partialUpdatedConvMap.clear(),e}getLocalConvList(){return[...this._convMap.values()].filter((e=>this._isConvNeedShow(e.conversationID)))}getLocalConversation(e){return this._convMap.get(e)}hasLocalConversation(e){return this._convMap.has(e)}getLocalOldestMessage(e){return this._msgListHandler.getLocalOldestMsg(e)}syncConvList(e=!0){let t=new Ei("syncConvList");return this._pagingStatus===wt&&this._convMap.clear(),this._pagingGetConvList(e).then((e=>{var s=function(e){if(Ve(e)&&0!==e.length){let t=0;return e.forEach((e=>{t+=e})),(t/e.length).toFixed(0)}}(this._pagingGetCostList),i=function(e){if(Ve(e)&&0!==e.length){let t=0;return e.forEach((e=>{t+=e})),t.toFixed(0)}}(this._pagingGetCostList);this._pagingGetCostList.length=0,this._pagingStatus=Ft,this._diffAndDeleteConv(),this.emitConvUpdate(!0,!1),this._setStorageConvList(),this._handleC2CPeerReadTime(),this.emitIEvt(Ji.CONV_SYNC_COMPLETED),i=`count:${this._convMap.size} sum:${i} avg:`+s;return ye.l(this._n+".syncConvList. "+i),t.setMessage(i).end(),e})).catch((e=>(this._pagingStatus=qt,t.setMessage(this._pagingTs).setError(e).end(),ai(e))))}_diffAndDeleteConv(){if(this._isSyncCompleted()){let e=[];this._convMap.forEach(((t,s)=>{!this._pagingConvIDMap.has(s)&&this._convIDFromUnreadDBMap.has(s)&&(this._convMap.delete(s),e.push(s))})),ye.l(this._n+"._diffAndDeleteConv list:"+e),e=null}}_pagingGetConvList(e=!0){let t=this._n+"._pagingGetConvList",s=(ye.l(t+` incrementalPullFlag:${e} ts:${this._pagingTs} startIdx:${this._pagingStartIdx} pinnedTs:${this._pagingPinnedTs} pinnedStartIdx:`+this._pagingPinnedStartIdx),Date.now());return this._pagingStatus=bt,this.req({P:di.PAGING_GET_CONV_LIST,data:{fromAccount:this.getMyUserID(),timeStamp:e?this._pagingTs:0,startIndex:e?this._pagingStartIdx:0,pinnedTimeStamp:e?this._pagingPinnedTs:0,pinnedStartIndex:e?this._pagingPinnedStartIdx:0,orderType:1}}).then((e=>{var{completeFlag:e,conversations:i=[],timeStamp:o,startIndex:n,pinnedTimeStamp:r,pinnedStartIndex:a,groupItem:l}=e.data;if(this._pagingGetCostList.push(At(s,!1)),ye.l(t+` ok. completeFlag:${e} count:${i.length} cost:`+At(s)),this._convGroupHandler.onConvGroupListSynced(l),0<i.length){let e=this._getConvOptions(i);this._pagingConvIDMap=new Map([...this._pagingConvIDMap,...e.map((e=>[e.conversationID,1]))]),this._updateLocalConvList({conversationOptionsList:e,isFromGetConversations:!0,updateUnreadCount:!0}),this.isLoggedIn()&&this.emitConvUpdate()}if(!this._isReady){if(!this.isLoggedIn())return ri();this.triggerReady()}return this._pagingTs=o,this._pagingStartIdx=n,this._pagingPinnedTs=r,this._pagingPinnedStartIdx=a,1!==e?this._pagingGetConvList():(this._handleGroupAtTipsList(),this._convGroupHandler.getRemoteConvGroupList(),ri())})).catch((e=>{throw!this.isLoggedIn()||this._isReady||(ye.w(t+" failed. error:",e),this.triggerReady()),e}))}_updateLocalConvList(e){var t=e["isFromGetConversations"],s=Date.now();e=this._getTmpConvListMapping(e)["newConvList"];this._convMap=new Map(this._sortConvList([...this._convMap])),t||this._updateUserOrGroupProfile(e),ye.l(this._n+"._updateLocalConvList cost:"+At(s))}_getTmpConvListMapping(e){let{conversationOptionsList:t,isFromGetConversations:s,isInstantMessage:i,isUnreadC2CMessage:n=!1,updateUnreadCount:r}=e,a=[],l=[],d=this.get(Ds),c=this.get(Rs),_=this.isIntl(),u=this.isUsingChatCore();for(let p=0,g=t.length;p<g;p++){let e=new _o(t[p],_,u),{conversationID:h,type:g}=e;if(!this._isNonExistentAccount(h)){if(this._convMap.has(h)){let a=this._convMap.get(h);if(s&&g!==o.CONV_TOPIC){this._convMap.set(h,e),g===o.CONV_C2C?e.unreadCount=a.unreadCount:g===o.CONV_GROUP&&(e.groupProfile=JSON.parse(JSON.stringify(a.groupProfile)));continue}let l=["unreadCount","allowType","adminForbidType","payload"],d=(!1===i&&l.push("lastMessage"),"boolean"==typeof i&&l.push("isPinned"),t[p].lastMessage),c=!Be(d);c||t[p].type===o.CONV_TOPIC||this._onLastMsgNotExist(t[p]),Be(i)&&c&&null===a.lastMessage.payload&&(a.lastMessage.payload=d.payload),Ue(a.lastMessage.revoker)||(a.lastMessage.revoker=null),je(a,e,l,[null,void 0,"",0,NaN]),!0===r&&a.updateUnreadCount({nextUnreadCount:e.unreadCount,isFromGetConversations:s,isUnreadC2CMessage:n}),i&&c&&(d.payload&&(a.lastMessage.payload=d.payload),a.type===o.CONV_GROUP)&&(a.lastMessage.nameCard=d.nameCard,a.lastMessage.nick=d.nick),c&&a.lastMessage.cloudCustomData!==d.cloudCustomData&&(a.lastMessage.cloudCustomData=d.cloudCustomData||"")}else{if(g===o.CONV_GROUP&&d){let t=e.groupProfile["groupID"],s=d.getLocalGroupProfile(t);s&&(e.groupProfile=s,!0===r)&&e.updateUnreadCount({nextUnreadCount:0})}else if(g===o.CONV_C2C){let t=h.replace(o.CONV_C2C,"");c&&c.isMyFriend(t)&&(e.remark=c.getFriendRemark(t))}a.push(e),this._convMap.set(h,e)}this._convMap.get(h).type===o.CONV_TOPIC&&l.push(this._convMap.get(h))}}let h=this.get(Ls);for(let p=0,g=l.length;p<g;p++){let{conversationID:e,groupAtInfoList:t}=l[p];Ue(t)||h.onAtInfoUpdated({topicID:e.replace(o.CONV_GROUP,""),groupAtInfoList:t})}return{newConvList:a}}_onLastMsgNotExist(e){new Ei("lastMsgNotExist").setMessage(JSON.stringify(e)).end()}_sortConvList(e){let t=[],s=[],i=[],o=[];return e.forEach((e=>{(!0===e[1].isPinned?Ue(e[1].lastMessage.lastTime)?s:t:Ue(e[1].lastMessage.lastTime)?o:i).push(e)})),t.sort(((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime)).concat(s).concat(i.sort(((e,t)=>t[1].lastMessage.lastTime-e[1].lastMessage.lastTime))).concat(o)}_sortConvListAndEmitEvent(){this._convMap=new Map(this._sortConvList([...this._convMap])),this.emitConvUpdate(!0,!1)}_updateUserOrGroupProfile(e){if(0!==e.length){let t=[],s=[],i=this.get(Es),n=this.get(Ds);e.forEach((e=>{if(e.type===o.CONV_C2C)t.push(e.toAccount);else if(e.type===o.CONV_GROUP){let t=e.toAccount;n.hasLocalGroup(t)?e.groupProfile=n.getLocalGroupProfile(t):s.push(t)}})),ye.l(`${this._n}._updateUserOrGroupProfile userIDList:${t} groupIDList:`+s),0<t.length&&i.getUserProfile({userIDList:t}).then((({data:e})=>{Ve(e)?e.forEach((e=>{this._doUpdateUserProfile(""+o.CONV_C2C+e.userID,e)})):this._doUpdateUserProfile(""+o.CONV_C2C+e.userID,e)})),0<s.length&&n.getGroupProfileAdvance({groupIDList:s,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then((({data:{successGroupList:e}})=>{let t=!1;e.forEach((e=>{var s=""+o.CONV_GROUP+e.groupID;if(this._convMap.has(s)){let i=this._convMap.get(s);je(i.groupProfile,e,[],[null,void 0,"",0,NaN]),!i.subType&&e.type&&(i.subType=e.type),t=!0}})),t&&this.emitConvUpdate()}))}}_doUpdateUserProfile(e,t){this.hasLocalConversation(e)&&(this.getLocalConversation(e).userProfile=t,this.emitConvUpdate())}_getConvOptions(e){let t=[],s=e.filter((({type:e,userID:t})=>1===e&&!this._isNonExistentAccount(t)||2===e)),i=this.getMyUserID(),n=s.map((e=>{var s;return Be(e.lastMsg)&&(e.lastMsg={elements:[]}),1===e.type?(s={userID:e.userID,nick:e.peerNick,avatar:e.peerAvatar},t.push(s),{conversationID:""+o.CONV_C2C+e.userID,type:o.CONV_C2C,lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.lastC2CMsgFromAccount,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:null,payload:e.lastMsg.elements[0]?this._amendLayersOverLimitProp(e.lastMsg.elements[0].content):null,cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:8===e.lastMessageFlag,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:e.lastC2CMsgFromAccount===i&&e.time<=e.c2cPeerReadTime,revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null},unreadCount:0,userProfile:new no(s),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:Dt(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId),remark:e.friendRemark||"",messageRemindType:this._transMsgRemindType(e.messageRemindType)}):{conversationID:""+o.CONV_GROUP+e.groupID,type:o.CONV_GROUP,lastMessage:{lastTime:e.time,lastSequence:e.sequence,fromAccount:e.msgGroupFromAccount,...this._patchTypeAndPayload(e),cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:2===e.lastMessageFlag,onlineOnlyFlag:!1,nick:e.senderNick||"",nameCard:e.senderNameCard||"",revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null},groupProfile:new lo({groupID:e.groupID,name:e.groupNick,avatar:e.groupImage,type:e.groupType,nextMessageSeq:e.nextMessageSeq}),unreadCount:this._computeGroupUnreadCount(e),peerReadTime:0,isPinned:1===e.isPinned,version:0,customData:e.customMark||"",markList:Dt(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId),messageRemindType:this._transMsgRemindType(e.messageRemindType)}}));return 0<t.length&&this.get(Es).onConvProfileUpdated(t),n}_transMsgRemindType(e){let t="";return 0===e?t=o.MSG_REMIND_ACPT_AND_NOTE:1===e?t=o.MSG_REMIND_DISCARD:2===e?t=o.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(t=o.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),t}_computeGroupUnreadCount(e){var{unreadCount:e=0,noUnreadCount:t=0}=e;e-=t;return 0<e?e:0}_patchTypeAndPayload(e){let{event:t,elements:s=[],groupTips:i={}}=e.lastMsg;if(Be(t)||Ue(i))return{type:s[0]?s[0].type:null,payload:s[0]?this._amendLayersOverLimitProp(s[0].content):null};{let e=new Hi(i),t=(e.setElement({type:o.MSG_GRP_TIP,content:{...i.elements,groupProfile:i.groupProfile}}),JSON.parse(JSON.stringify(e.payload)));return e=null,{type:o.MSG_GRP_TIP,payload:t}}}_amendLayersOverLimitProp(e){var t=e["layersOverLimit"];return 0===t?e.layersOverLimit=!1:1===t&&(e.layersOverLimit=!0),e}getLocalMessageList(e){return this._msgListHandler.getLocalMsgList(e)}deleteLocalMessage(e){e instanceof Hi&&this._msgListHandler.remove(e)}onConvDeleted(e){Ve(e)&&(e=e.map((e=>{var{type:e,userID:t,groupID:s}=e;return 1===e?""+o.CONV_C2C+t:2===e?""+o.CONV_GROUP+s:void 0})),ye.l(this._n+".onConvDeleted convIDList:"+e),this.deleteLocalConvList(e))}onConvPinnedStatus(e,t){if(Ve(e)){let s=!1;e.forEach((e=>{var{type:e,userID:i,groupID:n}=e;let r;1===e?r=this.getLocalConversation(""+o.CONV_C2C+i):2===e&&(r=this.getLocalConversation(""+o.CONV_GROUP+n)),r&&(ye.l(`${this._n}.onConvPinnedStatus convID:${r.conversationID} localPinned:${r.isPinned} remotePinned:`+t),t?r.isPinned||(r.isPinned=!0,s=!0):r.isPinned&&(r.isPinned=!1,s=!0))})),s&&this._sortConvListAndEmitEvent()}}getMessageList({conversationID:e,nextReqMessageID:t,count:s}){let i=this._n+".getMessageList",o=this.getLocalConversation(e),n="";if(o&&o.groupProfile&&(n=o.groupProfile.type),at(n))return ye.l(i+` not available in ${n}. convID:`+e),ri({messageList:[],nextReqMessageID:"",isCompleted:!0});(Be(s)||15<s)&&(s=15),t||this._isMeInCommunity(e)||this.clearMemMsg(e);let r=this._computeRemainingCount({conversationID:e,nextReqMessageID:t}),a=this._completedMap.has(e);return ye.l(i+` convID:${e} isEverCleared:${this._isEverCleared(e)} nextReqMessageID:${t} remainingCount:${r} count:${s} isCompleted:`+a),this._needGetHistory({conversationID:e,remainingCount:r,count:s})?this.getHistoryMessages({conversationID:e,nextReqMessageID:t,count:20}).then((t=>{var{nextReqID:t,storedMessageList:s,assembledMessageList:o,isPullingCompleted:n}=t,a=this._completedMap.has(e);let l=s,d=(0<r&&(l=this._msgListHandler.getLocalMsgList(e).slice(0,s.length+r)),{nextReqMessageID:void 0,messageList:void 0,isCompleted:void 0});return this._isEverCleared(e)?(d.nextReqMessageID=t,d.messageList=o,d.isCompleted=n):(d.nextReqMessageID=a?"":t,d.messageList=l,d.isCompleted=a),s=d.messageList.filter((e=>e.isRevoked))||[],o=d.messageList.map((e=>e.sequence)),ye.l(i+` ret.nextReqMessageID:${d.nextReqMessageID} ret.isCompleted:${d.isCompleted} sequenceList:`,o),Ve(s)&&0!==s.length?this.updateRevokerInfo(s).then((e=>(e.forEach((e=>{let t=e["revokerInfo"];d.messageList=d.messageList.map((s=>(s.ID===e.ID&&t&&(s.revokeReason=t.reason||"",s.revokerInfo={userID:t.revoker||s.revoker,nick:t.nick,avatar:t.avatar}),s)))})),ti(d)))):ti(d)})):(this.modifyMessageList(e),t=this._getMsgListFromMem({conversationID:e,nextReqMessageID:t,count:s}),ri(t))}_isEverCleared(e){return this._everClearedMap.has(e)}_getMsgListFromMem({conversationID:e,nextReqMessageID:t,count:s}){var i=this._n+"._getMsgListFromMem",o=this._msgListHandler.getLocalMsgList(e),n=o.length,r=ct(e);let a=0;var l={isCompleted:!1,nextReqMessageID:"",messageList:[]};t?(a=r?o.findIndex((e=>e.ID===t)):o.findIndex((e=>e.sequence+""===t)))>s?(l.messageList=o.slice(a-s,a),l.nextReqMessageID=r?o[a-s].ID:o[a-s].sequence+""):(l.messageList=o.slice(0,a),l.isCompleted=!0):s<n?(a=n-s,l.messageList=o.slice(a,n),l.nextReqMessageID=r?o[a].ID:o[a].sequence+""):(l.messageList=o.slice(0,n),l.isCompleted=!0),s=l.messageList.map((e=>e.sequence));return ye.l(i+` convID:${e} ret.nextReqMessageID:${l.nextReqMessageID} ret.isCompleted:${l.isCompleted} sequenceList:`+s),l}getMessageListHopping(e){let{conversationID:t,sequence:s,time:i,count:n,direction:r=0}=e;if((Be(n)||15<n)&&(n=15),t.startsWith(o.CONV_C2C)){let e=this.get(Ss),s=t.replace(o.CONV_C2C,"");return e.getRoamingMessagesHopping({peerAccount:s,time:i,count:n,direction:r})}if(t.startsWith(o.CONV_GROUP)){let e=this.get(Ds),i=t.replace(o.CONV_GROUP,"");return e.getRoamingMessagesHopping({groupID:i,sequence:s,count:n,direction:r})}}_computeRemainingCount({conversationID:e,nextReqMessageID:t}){var s=this._msgListHandler.getLocalMsgList(e),i=s.length;if(ye.l(this._n+`._computeRemainingCount convID:${e} nextReqMessageID:${t} length:`+i),!t)return i;let o=0;return ct(e)?o=s.findIndex((e=>e.ID===t)):_t(e)&&(o=-1!==t.indexOf("-")?s.findIndex((e=>e.ID===t)):s.findIndex((e=>e.sequence+""===t))),-1===o?0:o}_needGetHistory({conversationID:e,remainingCount:t,count:s}){var i=this.getLocalConversation(e);let o="";return i&&i.groupProfile&&(o=i.groupProfile.type),!(ut(e)||at(o)||!this._isEverCleared(e)&&(i=t<=s&&!this._completedMap.has(e),ye.l(this._n+`._needGetHistory convID:${e} ret:`+i),!i))}_isTopicConv(e){return e=e.replace(o.CONV_GROUP,""),dt(e)}getHistoryMessages(e){var{conversationID:t,count:e,nextReqMessageID:s}=e;if(t!==o.CONV_SYSTEM){let i=15,n=(20<e&&(i=20),null);if(ct(t)){let r=0,a="",l=!1;if(e=this._roamingMsgKeyAndTimeMap.has(t),s)if(l=!0,e)r=this._roamingMsgKeyAndTimeMap.get(t).lastMessageTime,a=this._roamingMsgKeyAndTimeMap.get(t).messageKey;else{let i=this._msgListHandler.findMessage(s);i&&(r=i.time,ye.l(this._n+`.getHistoryMessages convID:${t} isRelayInfoExisted:${e} lastMessageTime:`+r))}return(n=this.get(Ss)).getRoamingMessage({conversationID:t,peerAccount:t.replace(o.CONV_C2C,""),count:i,lastMessageTime:l?r:0,messageKey:l?a:""})}if(_t(t)){if(!(n=this.get(Ds)))return ai({code:ii.NO_MODULE});let e=t.replace(o.CONV_GROUP,""),r=null,a=(this._convMap.has(t)&&!dt(e)&&(r=this._convMap.get(t).lastMessage),0);return s?a=Number(s):r&&(a=r.lastSequence),n.getRoamingMessage({conversationID:t,groupID:e,count:i,sequence:a})}}return ri()}patchConvLastMessage(e,t=!1){var s=this.getLocalConversation(e);if(s){let{messageForShow:i,payload:o}=s.lastMessage;if(Ue(i)||Ue(o)||t){let i=this._msgListHandler.getLocalMsgList(e);if(0!==i.length){let o=i[i.length-1];ye.l(this._n+`.patchConvLastMessage bForceUpdate:${t} convID:${e} payload:`,o.payload),s.updateLastMessage(o)}}}}onRoamingMessage(e=[],t,s=!0,i){var n=t.startsWith(o.CONV_C2C)?o.CONV_C2C:o.CONV_GROUP;let r,a=null,l=[],d=[],c=0,_=e.length,u=n===o.CONV_GROUP,h=this.getFileDownloadProxy(),p=this.getDownloadFileAuthKey(),g=Ve(i),m=this.get(Gs).getFileDNList(),M=()=>{u?--c:++c},f=()=>u?c>=_:c<_;for(c=u?e.length-1:0,_=u?0:e.length;f();M())if(1!==e[c].isPlaceMessage)if((a=new Hi(e[c])).to=e[c].to,n!==o.CONV_GROUP||Be(e[c].topicID)||(a.to=e[c].topicID),a.isSystemMessage=!!e[c].isSystemMessage,a.conversationType=n,r=4===e[c].event?{type:o.MSG_GRP_TIP,content:{...e[c].elements,groupProfile:e[c].groupProfile}}:e[c].elements,u||a.setNickAndAvatar({nick:e[c].nick,avatar:e[c].avatar}),Ue(r)){let t=new Ei("emptyMessageBody");t.setMessage(`from:${a.from} to:${a.to} sequence:${a.sequence} event:`+e[c].event),t.setLevel("warning").end()}else a.setElement(r,h,p,m),a.reInitialize(this.getMyUserID()),l.push(a),g&&i.push(a);return M=f=null,s?(this._msgListHandler.unshift(l,d),l=null,d):l}findMessage(e){return this._msgListHandler.findMessage(e)}_isMeInCommunity(e){let t=!0;return this._isTopicConv(e)&&(e=Et(e.replace(o.CONV_GROUP,"")),this.get(Ds).hasLocalGroup(e)||(t=!1,ye.l(this._n+`._isMeInCommunity groupID:${e} ret:`+t))),t}deleteTopicRoamingInfo(e){lt({groupID:e})&&this._msgListHandler.getTopicConvIDList(e).forEach((e=>{this.clearMemMsg(e)}))}deleteGroupRoamingInfo(e){e=""+o.CONV_GROUP+e,0<this._msgListHandler.getLocalMsgList(e).length&&this.clearMemMsg(e)}setMessageRead({conversationID:e}){let t=this.getLocalConversation(e),s=this._n+".setMessageRead";if(ye.l(s+` convID:${e} unreadCount:`+(t?t.unreadCount:0)),!t)return ri();if(t.type!==o.CONV_GROUP&&t.type!==o.CONV_TOPIC||Ue(t.groupAtInfoList)||this.deleteGroupAtTips(e),0===t.unreadCount)return ri();let i=this._msgListHandler.getLocalLastMsg(e),n=t.lastMessage.lastTime;var r=this._msgListHandler.getLocalMaxTime(e);n<r&&(ye.l(`${s} update lastMessageTime from ${n} to `+r),n=r),r=this._msgListHandler.getLocalMaxSeq(e);let a=t.lastMessage.lastSequence;if(a<r&&(ye.l(`${s} update lastMessageSeq from ${a} to `+r),a=r),t.type===o.CONV_TOPIC&&Be(i)){let t=this.get(Ls),s=e.replace(o.CONV_GROUP,""),i=Et(s),n=t.getLocalTopic(i,s);n&&(a=n.nextMessageSeq-1)}let l=null;switch(t.type){case o.CONV_C2C:return(l=this.get(Ss))?l.setMessageRead({conversationID:e,lastMessageTime:n}):ai({code:ii.NO_MODULE});case o.CONV_GROUP:case o.CONV_TOPIC:return(l=this.get(Ds))?l.setMessageRead({conversationID:e,lastMessageSeq:a}):ai({code:ii.NO_MODULE});case o.CONV_SYSTEM:return t.unreadCount=0,this.emitConvUpdate(!0,!1),ri();default:return ri()}}setAllMessageRead(e={}){let t=this._n+".setAllMessageRead";e.scope||(e.scope=o.READ_ALL_MSG),ye.l(t+" options:",e);var s=this._createSetAllMessageReadPack(e);if(0===s.readAllC2CMessage&&0===s.groupMessageReadInfoList.length)return ri();let i=new Ei("setAllMessageRead");return this.req({P:di.SET_ALL_MSG_READ,data:s}).then((t=>(t=t.data,t=this._handleAllMsgRead(t),i.setMessage(`scope:${e.scope} failureGroups:`+JSON.stringify(t)).end(),ri()))).catch((e=>(i.setError(e).end(),ye.w(t+" failed. error:",e),ai({code:e&&e.code?e.code:ii.MSG_UNREAD_ALL_FAIL,message:e&&e.message?e.message:void 0}))))}setConvCustomData(e){return this._convGroupHandler.setConvCustomData(e)}markConv(e){return this._convGroupHandler.markConv(e)}getConvGroupList(){return this._convGroupHandler.getLocalConvGroupList()}createConvGroup(e){return this._convGroupHandler.createConvGroup(e)}deleteConvGroup(e){return this._convGroupHandler.deleteConvGroup(e)}renameConvGroup(e){return this._convGroupHandler.renameConvGroup(e)}addConvsToGroup(e){return this._convGroupHandler.addConvsToGroup(e)}deleteConvsFromGroup(e){return this._convGroupHandler.deleteConvsFromGroup(e)}onConvMarkUpdated(e){this._convGroupHandler.onConvMarkUpdated(e)}onConvGroupCreated(e){this._convGroupHandler.onConvGroupCreated(e)}onConvGroupDeleted(e){this._convGroupHandler.onConvGroupDeleted(e)}onConvGroupNameUpdated(e){this._convGroupHandler.onConvGroupNameUpdated(e)}onConvInGroupUpdated(e){this._convGroupHandler.onConvInGroupUpdated(e)}onConvAddedToOrDeletedFromGroup(e){this._convGroupHandler.onConvAddedToOrDeletedFromGroup(e)}_getConvLastMessageSeq(e){var t=this._msgListHandler.getLocalLastMsg(e.conversationID);let s=e.lastMessage.lastSequence;return t&&s<t.sequence?t.sequence:s}_getConvLastMessageTime(e){var t=this._msgListHandler.getLocalLastMsg(e.conversationID);let s=e.lastMessage.lastTime;return t&&s<t.time?t.time:s}_createSetAllMessageReadPack(e){var t,s={readAllC2CMessage:0,groupMessageReadInfoList:[]},i=e["scope"];for([,t]of this._convMap)if(0<t.unreadCount)if(t.type===o.CONV_C2C&&0===s.readAllC2CMessage){if(i===o.READ_ALL_MSG)s.readAllC2CMessage=1;else if(i===o.READ_ALL_C2C_MSG){s.readAllC2CMessage=1;break}}else if(t.type===o.CONV_GROUP&&(i===o.READ_ALL_GROUP_MSG||i===o.READ_ALL_MSG)){let e=this._getConvLastMessageSeq(t);s.groupMessageReadInfoList.push({groupID:t.groupProfile.groupID,messageSequence:e})}return s}onPushedAllMessageRead(e){this._handleAllMsgRead(e)}_handleAllMsgRead(e){var{groupMessageReadInfoList:e,readAllC2CMessage:t}=e;e=this._parseGroupReadInfo(e);return 1<=this._updateAllConvUnreadCount({readAllC2CMessage:t})&&this.emitConvUpdate(!0,!1),e}_parseGroupReadInfo(e){var t=[];if(e&&e.length)for(let r=0,a=e.length;r<a;r++){var{groupID:s,sequence:i,retCode:o,lastMessageSeq:n}=e[r];Be(o)?this._remoteGroupReadSeqMap.set(s,n):(this._remoteGroupReadSeqMap.set(s,i),0!==o&&t.push(s+`-${i}-`+o))}return t}_updateAllConvUnreadCount(e){let t=e["readAllC2CMessage"],s=0;for(var[i,n]of this._convMap)if(1<=n.unreadCount){if(1===t&&n.type===o.CONV_C2C){let e=this._getConvLastMessageTime(n);this.updateIsReadAfterReadReport({conversationID:i,lastMessageTime:e})}else if(n.type===o.CONV_GROUP){let e=i.replace(o.CONV_GROUP,"");if(this._remoteGroupReadSeqMap.has(e)){let t=this._remoteGroupReadSeqMap.get(e),s=this._getConvLastMessageSeq(n);this.updateIsReadAfterReadReport({conversationID:i,remoteReadSequence:t}),s>=t&&this._remoteGroupReadSeqMap.delete(e)}}this.updateUnreadCount(i,!1)&&(s+=1)}return s}isRemoteRead(e){var{conversationID:t,sequence:s}=e,i=t.replace(o.CONV_GROUP,"");let n=!1;if(this._remoteGroupReadSeqMap.has(i)){let e=this._remoteGroupReadSeqMap.get(i);s<=e&&(n=!0,ye.l(this._n+`.isRemoteRead convID:${t} msgSeq:${s} remoteReadSeq:`+e)),s>=e+10&&this._remoteGroupReadSeqMap.delete(i)}return n}updateIsReadAfterReadReport({conversationID:e,lastMessageSeq:t,lastMessageTime:s}){var i,o=this._msgListHandler.getLocalMsgList(e);if(0!==o.length)for(let n=o.length-1;0<=n;n--)if(i=o[n],!(s&&i.time>s||t&&i.sequence>t)){if("in"===i.flow&&i.isRead)break;i.setIsRead(!0)}}updateUnreadCount(e,t=!0){let s=!1,i=this.getLocalConversation(e),n=this._msgListHandler.getLocalMsgList(e);if(i){var r=i.unreadCount,a=n.filter((e=>!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted)).length;if(r!==a&&(i.unreadCount=a,s=!0,ye.l(this._n+`.updateUnreadCount from ${r} to ${a}, convID:`+e),!0===t)&&this.emitConvUpdate(!0,!1),s&&i.type===o.CONV_TOPIC){let t=i["unreadCount"],s=this.get(Ls),n=e.replace(o.CONV_GROUP,"");s.onUnreadCountUpdatedFromConv(n,t)}return s}}clearGroupAtInfoList(e,t=!0){var s=this.getLocalConversation(e);if(s&&0<s.groupAtInfoList.length){if(s.clearGroupAtInfoList(),ye.l(this._n+".clearGroupAtInfoList convID:"+e),s.type===o.CONV_TOPIC){let t=s["groupAtInfoList"],i=this.get(Ls),n=e.replace(o.CONV_GROUP,"");i.onAtInfoUpdated({topicID:n,groupAtInfoList:t})}!0===t&&this.emitConvUpdate(!0,!1)}}updateReadReceiptInfo(e){let{userID:t,groupID:s,readReceiptList:n,timestamp:r=0}=e;if(!Ue(n)){let e=[];if(Be(t)){if(!Be(s)){let t=""+o.CONV_GROUP+s;n.forEach((i=>{var{tinyID:i,clientTime:o,random:n,readCount:r,unreadCount:a}=i,o=(i=i+`-${o}-`+n,this._msgListHandler.getLocalMsg(t,i)||this._msgListHandler.getHoppingMsg(t,i)),n={groupID:s,messageID:i,readCount:0,unreadCount:0};o&&(be(r)&&(o.readReceiptInfo.readCount=r,n.readCount=r),be(a)&&(o.readReceiptInfo.unreadCount=a,n.unreadCount=a),e.push(n))}))}}else{let s=""+o.CONV_C2C+t;n.forEach((i=>{var{tinyID:i,clientTime:o,random:n}=i,o=(i=i+`-${o}-`+n,this._msgListHandler.getLocalMsg(s,i)||this._msgListHandler.getHoppingMsg(s,i));if(o&&!o.readReceiptInfo.isPeerRead){o.readReceiptInfo.isPeerRead=!0,o.readReceiptInfo.timestamp=r;let s={userID:t,messageID:i,isPeerRead:!0,timestamp:r};e.push(s)}}))}0<e.length&&this.emitOEvt(i.MESSAGE_READ_RECEIPT_RECEIVED,e)}}updateIsRead(e){var t=this.getLocalConversation(e),s=this.getLocalMessageList(e);if(t&&0!==s.length&&!ut(t.type)){var i=[];for(let t=0,o=s.length;t<o;t++)"in"!==s[t].flow?"out"!==s[t].flow||s[t].isRead||s[t].setIsRead(!0):i.push(s[t]);let e=0;if(t.type===o.CONV_C2C){let s=i.slice(-t.unreadCount).filter((e=>e.isRevoked)).length;e=i.length-t.unreadCount-s}else e=i.length-t.unreadCount;for(let t=0;t<e&&!i[t].isRead;t++)i[t].setIsRead(!0)}}deleteGroupAtTips(e){let t=this._n+".deleteGroupAtTips";ye.l(t);var s=this._convMap.get(e);if(!s)return Promise.resolve();let i=s.groupAtInfoList;if(0===i.length)return Promise.resolve();let n,r=(e.startsWith(o.CONV_GROUP)&&(n=e.replace(o.CONV_GROUP,"")),[...i]);if((lt({groupID:n})||dt(n))&&0===(r=i.filter((e=>!e.atTypeArray.includes(o.CONV_AT_ALL)))).length)return this.clearGroupAtInfoList(e,!1),Promise.resolve();let a=this.getMyUserID();return this.req({P:di.DEL_GROUP_AT_TIPS,data:{messageListToDelete:r.map((e=>({from:e.from,to:a,messageSeq:e.__sequence,messageRandom:e.__random,groupID:Be(e.topicID)?e.groupID:e.topicID})))}}).then((()=>(ye.l(t+" ok. count:"+i.length),this.clearGroupAtInfoList(e,!1),Promise.resolve()))).catch((e=>(ye.e(t+" failed. error:",e),ai(e))))}appendToMessageList(e){return this._msgListHandler.pushIn(e)}setMessageRandom(e){this._sll.set(e.random)}deleteMessageRandom(e){this._sll.delete(e.random)}pushIntoMessageList(e,t,s){return!(!this._msgListHandler.pushIn(t,s)||this._sll.has(t.random)&&!s||(e.push(t),0))}revoke(e,t,s){return this._msgListHandler.revoke(e,t,s)}getPeerReadTime(e){return this._peerReadTimeMap.get(e)}recordPeerReadTime(e,t){(!this._peerReadTimeMap.has(e)||this._peerReadTimeMap.get(e)<t)&&this._peerReadTimeMap.set(e,t)}updateMsgIsPeerReadProp(e,t){if(e.startsWith(o.CONV_C2C)&&0<t){let s=this._msgListHandler.updateMsgIsPeerReadProp(e,t);if(0<s.length&&this.emitOEvt(i.MESSAGE_READ_BY_PEER,s),this._convMap.has(e)){let s=this._convMap.get(e).lastMessage;Ue(s)||s.fromAccount===this.getMyUserID()&&s.lastTime<=t&&!s.isPeerRead&&(s.isPeerRead=!0,this.emitConvUpdate(!0,!1))}}}updateMsgIsModifiedProp(e){this._msgListHandler.updateMsgIsModifiedProp(e)}setCompleted(e){ye.l(this._n+".setCompleted convID:"+e),this._completedMap.set(e,!0)}updateRoamingMsgKeyAndTime(e,t,s){this._roamingMsgKeyAndTimeMap.set(e,{messageKey:t,lastMessageTime:s})}getConvList(e){let t=this._n+".getConvList",s=`pagingStatus:${this._pagingStatus}, local conversation count:${this._convMap.size}, options:`+JSON.stringify(e);if(ye.l(t+". "+s),this._pagingStatus===qt){let i=new Ei("getConvList");return i.setMessage(s),this.syncConvList().then((()=>{i.end();var t=this._getConvList(e);return ti({conversationList:t,isSyncCompleted:this._isSyncCompleted()})})).catch((e=>(i.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}let i=this._getConvList(e);return ye.l(t+". returned conversation count:"+i.length),ri({conversationList:i,isSyncCompleted:this._isSyncCompleted()})}_getConvList(e){if(Be(e))return this.getLocalConvList();if(Ve(e))return 0===e.length?[]:this.getLocalConvList().filter((t=>e.includes(t.conversationID)));if(xe(e)){let{type:t,markType:s,groupName:i,hasUnreadCount:o,hasGroupAtInfo:n}=e;return this.getLocalConvList().filter((e=>this._filterType(e,t)&&this._filterMarkType(e,s)&&this._filterGroupName(e,i)&&this._filterUnreadCount(e,o)&&this._filterGroupAtInfo(e,n)))}return[]}_filterType(e,t){return t!==o.CONV_C2C&&t!==o.CONV_GROUP||e.type===t}_filterGroupName(e,t){return!Fe(t)||(""===t?0===e.conversationGroupList.length:e.conversationGroupList.includes(t))}_filterMarkType(e,t){return!be(t)||(0===t?0===e.markList.length:e.markList.includes(t))}_filterUnreadCount(e,t){let s=!0;return!0===t?s=1<=e.unreadCount:!1===t&&(s=0===e.unreadCount),s}_filterGroupAtInfo(e,t){let s=!0;return!0===t?s=1<=e.groupAtInfoList.length:!1===t&&(s=0===e.groupAtInfoList.length),s}_handleC2CPeerReadTime(){for(var[e,t]of this._convMap)t.type===o.CONV_C2C&&this.recordPeerReadTime(e,t.peerReadTime)}_isPagingGetGroupListCompleted(){var e=this.get(Ds);return!e||e.isPagingGetCompleted()}_getLocalGroupCount(){var e=this.get(Ds);return e?e.getLocalGroupList().length:0}_hasLocalGroup(e){var t=this.get(Ds);return!!t&&t.hasLocalGroup(e.replace(o.CONV_GROUP,""))}getConversationProfile(e){let t,s=!1;if(this._convMap.has(e)?t=this._convMap.get(e):(t=new _o({conversationID:e,type:ct(e)?o.CONV_C2C:o.CONV_GROUP},this.isIntl(),this.isUsingChatCore()),s=!0),t._isInfoCompleted||t.type===o.CONV_SYSTEM)return ri({conversation:t});if(_t(e)){if(!this.get(Ds))return ai({code:ii.NO_MODULE});if(!this._hasLocalGroup(e))return ri({conversation:t})}let i=this._n+".getConversationProfile",n=new Ei("getConversationProfile");return ye.l(i+`. convID:${e} remark:${t.remark} lastMessage:`,t.lastMessage),this._getUserOrGroupProfile(t).then((r=>{n.setMessage(`convID:${e} unreadCount:`+r.data.conversation.unreadCount).end();var a=this.get(Rs);if(a&&t.type===o.CONV_C2C){let s=e.replace(o.CONV_C2C,"");if(a.isMyFriend(s)){let o=a.getFriendRemark(s);t.remark!==o&&(t.remark=o,ye.l(i+`. convID:${e} patch remark:`+t.remark))}}if(ye.l(i+` ok. isNewConv:${s} convID:`+e),s){if(t.type===o.CONV_C2C)return this._onNewC2CConv([e.replace(o.CONV_C2C,"")]).then((()=>ri({conversation:t})));if(t.type===o.CONV_GROUP)return this._onNewGroupConv([e.replace(o.CONV_GROUP,"")]).then((()=>ri({conversation:t})))}return r})).catch((t=>(n.setError(t).setMessage("convID:"+e).end(),ye.e(i+" failed. error:",t),ai(t))))}_getUserOrGroupProfile(e){return e.type===o.CONV_C2C?this.get(Es).getUserProfile({userIDList:[e.toAccount]}).then((t=>(t=t.data,0===t.length?ai({code:ii.USER_OR_GRP_NOT_FOUND}):(e.userProfile=t[0],e._isInfoCompleted=!0,this._insertConvAfterTopmost(e),ri({conversation:e}))))):this.get(Ds).getGroupProfile({groupID:e.toAccount}).then((t=>(e.groupProfile=t.data.group,e._isInfoCompleted=!0,this._insertConvAfterTopmost(e),ri({conversation:e}))))}_insertConvAfterTopmost(e){var t,s;e instanceof _o&&!this._convMap.has(e.conversationID)&&(s=(t=[...this._convMap]).findIndex((e=>!1===e[1].isPinned)),t.splice(s,0,[e.conversationID,e]),this._convMap=new Map(t),this._setStorageConvList(),this.emitConvUpdate(!0,!1))}_onProfileUpdated(e){e.data.forEach((e=>{var t=e["userID"];t===this.getMyUserID()?this._onMyProfileModified({latestNick:e.nick,latestAvatar:e.avatar}):(t=this._convMap.get(""+o.CONV_C2C+t))&&(t.userProfile=e)}))}_onCloudConfig(e){"0"===this.getCloudConfig("pull_on_invite")&&(this._bPullOnInvite=!1),ye.l(this._n+"._onCloudConfig bPullOnInvite:"+this._bPullOnInvite)}disableMsgPullOnInvite(){this._bPullOnInvite=!1}_isSyncCompleted(){return this._pagingStatus===Ft}_errorLog(e,t,s,i){var o=new Error("Params validate failed."),n=""+this.getErrMsg("API_REFER")+e;throw ye.w(`[${e}] | ${t} | ${this.getErrMsg(s,i)}, `+n),ye.e(`[${e}] Invalid ${t}: type check failed for ${t}.`),o}_isValidConvID(e){return ct(e)||_t(e)||ut(e)}deleteConversation(e){let t="deleteConversation";return Fe(e)||qe(e)||this._errorLog(t,"options","StringOrObjectRequiredLog"),Fe(e)?(this._isValidConvID(e)||this._errorLog(t,"options","InvalidConversationID",e),ye.l(`${this._n}.${t} convID:`+e),this.deleteConvList({conversationIDList:[e],flag:1})):(Ve(e.conversationIDList)||this._errorLog(t,"conversationIDList","ArrayRequiredLog"),0===e.conversationIDList.length&&this._errorLog(t,"conversationIDList","NonEmptyArrayLog"),e.conversationIDList.forEach((e=>{this._isValidConvID(e)||this._errorLog(t,"conversationIDList","InvalidConversationID",e)})),"clearHistoryMessage"in e&&"boolean"!=typeof e.clearHistoryMessage&&this._errorLog(t,"clearHistoryMessage","BooleanRequiredLog"),100<e.conversationIDList.length&&(e.conversationIDList=e.conversationIDList.slice(0,100)),this.deleteConvList(e))}deleteConvList(e){let{conversationIDList:t=[],clearHistoryMessage:s=!0,flag:i=0}=e,o=this._n+".deleteConvList",n=`convIDList:${t} clearHistoryMessage:`+s,r=(ye.l(o+" "+n),new Ei("deleteConvList"));return r.setMessage(n),Promise.all([this.rmLocalOnlyConvList(t),this.rmLocalAndRemoteConvList(t,s)]).then((e=>(r.end(),e=[...e[0],...e[1]],0===e.length?ai(new si({code:ii.CONV_NOT_FOUND})):(ye.l(o+" ok"),ri(1===i?{conversationID:e[0]}:{conversationIDList:e}))))).catch((e=>(r.setError(e).end(),ye.e(o+" failed. error:",e),ai(e))))}rmLocalOnlyConvList(e){return e.filter((e=>{var t;return!!this._convMap.has(e)&&((t=this.getLocalConversation(e).type)!==o.CONV_GROUP||this._hasLocalGroup(e)?t===o.CONV_SYSTEM&&(this.get(Ds).deleteGroupSystemNotice({messageList:this._msgListHandler.getLocalMsgList(e)}),this.deleteLocalConv(e),!0):(this.deleteLocalConv(e),!0))}))}rmLocalAndRemoteConvList(e,t){let s={fromAccount:this.getMyUserID(),conversationList:[],clearHistoryMessage:t?1:0};return e.forEach((e=>{var t;this._convMap.has(e)&&((t=this.getLocalConversation(e).type)===o.CONV_C2C?s.conversationList.push({toAccount:e.replace(t,""),type:1}):t===o.CONV_GROUP&&this._hasLocalGroup(e)&&s.conversationList.push({toGroupID:e.replace(t,""),type:2}))})),0===s.conversationList.length?[]:this.req({P:di.DEL_CONV,data:s}).then((e=>{let t=[];return 0<e.data.resultList.length&&e.data.resultList.map((e=>{0===e.code&&(e=1===e.type?""+o.CONV_C2C+e.to:""+o.CONV_GROUP+e.groupID,t.push(e))})),this.deleteLocalConvList(t),t}))}setConvDraft(e){var{conversationID:e,draftText:t}=e,s=this._n+".setConvDraft";return ye.l(s+` convID:${e} draftText:`+t),this._convMap.has(e)?((s=this._convMap.get(e)).setDraftText(t),this.emitConvUpdate(),ri({code:0,conversation:s})):ai({code:ii.CONV_NOT_FOUND})}clearHistoryMessage(e){let t={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._convMap.has(e))return ai({code:ii.CONV_NOT_FOUND});var s=this._convMap.get(e).type;if(s===o.CONV_C2C)t.type=1,t.toAccount=e.replace(o.CONV_C2C,"");else{if(s!==o.CONV_GROUP)return s===o.CONV_SYSTEM?(this.get(Ds).deleteGroupSystemNotice({messageList:this._msgListHandler.getLocalMsgList(e)}),ri({conversationID:e})):ai({code:ii.CONV_UN_RECORDED_TYPE});t.type=2,t.toGroupID=e.replace(o.CONV_GROUP,"")}let i=this._n+".clearHistoryMessage",n=new Ei("clearHistoryMessage");return n.setMessage("convID:"+e),ye.l(i+". convID:"+e),this.setMessageRead({conversationID:e}).then((()=>this.req({P:di.CLEAR_HISTORY_MSG,data:t}))).then((()=>{n.end(),ye.l(i+" ok"),this.clearMemMsg(e);var t=this.getLocalConversation(e);return t&&(t.updateLastMessage(),this._sortConvListAndEmitEvent()),ri({conversationID:e})})).catch((e=>(n.setError(e).end(),ye.e(i+" failed. error:",e),ai(e))))}pinConversation(e){let{conversationID:t,isPinned:s}=e,i=this.getLocalConversation(t);if(i&&i.isPinned===s)return ri({conversationID:t});if(ut(t))return i&&(i.isPinned=s),this._sortConvListAndEmitEvent(),ri({conversationID:t});let n=null;if(ct(t)?n={type:1,toAccount:t.replace(o.CONV_C2C,"")}:_t(t)&&(n={type:2,groupID:t.replace(o.CONV_GROUP,"")}),null===n)return ai({code:ii.INVALID_CONV_ID});let r=this._n+".pinConversation",a=`convID:${t} isPinned:`+s,l=new Ei("pinConversation");return l.setMessage(a),ye.l(r+". "+a),this.req({P:di.PIN_CONV,data:{fromAccount:this.getMyUserID(),operationType:!0===s?1:2,itemList:[n]}}).then((()=>(l.end(),ye.l(r+" ok"),i?i.isPinned!==s&&(i.isPinned=s):this._convMap.set(t,new _o({conversationID:t,type:ct(t)?o.CONV_C2C:o.CONV_GROUP,isPinned:s},this.isIntl(),this.isUsingChatCore())),this._sortConvListAndEmitEvent(),ti({conversationID:t})))).catch((e=>(l.setError(e).end(),ye.e(r+" failed. error:",e),ai(e))))}setMessageRemindType(e){return this._msgRemindHandler.set(e)}patchMsgRemindType(e){var{ID:t,isC2CConversation:s,messageRemindType:i}=e;let n=!1;return s=this.getLocalConversation(s?""+o.CONV_C2C+t:""+o.CONV_GROUP+t),s&&s.messageRemindType!==i&&(s.messageRemindType=i,n=!0),ye.l(this._n+".patchMsgRemindType options:",e,"ret:"+n),n}onC2CMsgRemindTypeFetched(e){if(Ve(e)&&0<e.length){let t=0;e.forEach((e=>{var{userID:e,muteFlag:s}=e,s=this._transMsgRemindType(s);!0===this.patchMsgRemindType({ID:e,isC2CConversation:!0,messageRemindType:s})&&(t+=1)})),ye.l(this._n+".onC2CMsgRemindTypeFetched updateCount:"+t),1<=t&&this.emitConvUpdate(!0,!1)}}onC2CMsgRemindTypeSynced(e){let t=this._n+".onC2CMsgRemindTypeSynced";e.dataList.forEach((e=>{if(!Ue(e.muteNotificationsSync)){var{to:e,muteFlag:s}=e.muteNotificationsSync,s=this._transMsgRemindType(s);let i=0;this.patchMsgRemindType({ID:e,isC2CConversation:!0,messageRemindType:s})&&(i+=1),ye.l(t+" updateCount:"+i),1<=i&&this.emitConvUpdate(!0,!1)}}))}onGroupMsgRemindTypeUpdated(e){this._msgRemindHandler.onGroupMsgRemindTypeUpdated(e)}deleteLocalConv(e,t=!0){var s=this._convMap.has(e);if(ye.l(this._n+`.deleteLocalConv convID:${e} has:`+s),s&&(this._convMap.delete(e),this._convMapForDiff.delete(e),this.clearMemMsg(e),this._setStorageConvList(!0),t)){let t=!this._isTopicConv(e);this.emitConvUpdate(t,!1)}}pullMsgOnInvite(e){var t=this.get(Ds);if(t){var s=this._n+".pullMsgOnInvite";if(ye.l(s+" flag:"+this._bPullOnInvite),this._bPullOnInvite){var i=this.getLocalLastMessage(e),n=this.getLocalSecondLastMessage(e);let r=1,a=1;i&&(r=i.sequence),n&&(a=n.sequence),i=t.getGroupRemoteLastSeq(e.replace(o.CONV_GROUP,"")),ye.l(s+` convID:${e} localLastSeq:${r} localSecondLastSeq:${a} remoteLastSeq:`+i),this.clearMemMsg(e),1<r-a?this._recursiveGetMsgList([],e,!1,r,a):1<i-r&&this._recursiveGetMsgList([],e,!0,i,r)}}}_recursiveGetMsgList(e,t,s,i,o,n){this.getMessageList({conversationID:t,nextReqMessageID:n}).then((n=>{var{messageList:n,isCompleted:r,nextReqMessageID:a}=n.data,l=n.filter((e=>s?e.sequence>o&&e.sequence<=i:e.sequence>o&&e.sequence<i));e.unshift(...l),!r&&0<n.length&&n[0].sequence>o&&e.length<60?this._recursiveGetMsgList(e,t,s,i,o,a):this._emitMsgReceived(t,e)}))}_emitMsgReceived(e,t){var s,o;0<t.length&&(t=t.filter(((e,t,s)=>t===s.findIndex((t=>t.sequence===e.sequence)))),s=this.hasLocalConversation(e),o=t.map((e=>e.sequence)),ye.l(`${this._n}._emitMsgReceived convID:${e} has:${s} count:${o.length} sequenceList:`,o),this.emitOEvt(i.MESSAGE_RECEIVED,t),s?this.patchConvLastMessage(e,!0):this.getConversationProfile(e).then((()=>{this.patchConvLastMessage(e,!0)})))}deleteLocalConvList(e){let t=!1;e.forEach((e=>{this._convMap.has(e)&&(this.deleteLocalConv(e,!1),t=!0)})),ye.l(this._n+`.deleteLocalConvList convID:${e} isConvIDExisted:`+t),t&&this.emitConvUpdate(!0,!1)}isMessageSentByCurrentInstance(e){return!(!this._msgListHandler.hasLocalMsg(e.conversationID,e.ID)&&!this._sll.has(e.random))}modifyMessageList(e){var t,s;e.startsWith(o.CONV_C2C)&&this._convMap.has(e)&&(s=this._convMap.get(e),t=Date.now(),this._msgListHandler.modifyMsgSentByPeer({conversationID:e,latestNick:s.userProfile.nick,latestAvatar:s.userProfile.avatar}),s=this.get(Es).getNickAndAvatarByUserID(this.getMyUserID()),this._msgListHandler.modifyMsgSentByMe({conversationID:e,latestNick:s.nick,latestAvatar:s.avatar}),ye.l(this._n+`.modifyMessageList convID:${e} cost:`+At(t)))}updateUserProfileSpecifiedKey(e){ye.l(this._n+".updateUserProfileSpecifiedKey options:",e);var{conversationID:t,nick:s,avatar:i}=e;if(this._convMap.has(t)){let e=this._convMap.get(t).userProfile;Fe(s)&&e.nick!==s&&(e.nick=s),Fe(i)&&e.avatar!==i&&(e.avatar=i),this.emitConvUpdate(!0,!1)}}_onMyProfileModified(e){var t=this.getLocalConvList(),s=Date.now();t.forEach((t=>{this.modifyMessageSentByMe({conversationID:t.conversationID,...e})})),ye.l(this._n+"._onMyProfileModified. modify all messages sent by me, cost:"+At(s))}modifyMessageSentByMe(e){this._msgListHandler.modifyMsgSentByMe(e)}getLatestMessageSentByMe(e){return this._msgListHandler.getLatestMsgSentByMe(e)}modifyMessageSentByPeer(e){this._msgListHandler.modifyMsgSentByPeer(e)}getLatestMessageSentByPeer(e){return this._msgListHandler.getLatestMsgSentByPeer(e)}pushIntoNoticeResult(e,t){return!(!this._msgListHandler.pushIn(t)||this._sll.has(t.random)||(e.push(t),0))}getLocalLastMessage(e){return this._msgListHandler.getLocalLastMsg(e)}getLocalSecondLastMessage(e){return this._msgListHandler.getLocalSecondLastMsg(e)}checkAndPatchRemark(){let e=this.get(Rs);if(0!==this._convMap.size&&e){var t=[...this._convMap.values()].filter((e=>e.type===o.CONV_C2C));if(0!==t.length){let s=0;t.forEach((t=>{var i=t.conversationID.replace(o.CONV_C2C,"");if(e.isMyFriend(i)){let o=e.getFriendRemark(i);t.remark!==o&&(t.remark=o,s+=1)}})),ye.l(`${this._n}.checkAndPatchRemark. c2cConvCount:${t.length} patchedCount:`+s),0<s&&this.emitConvUpdate(!0,!1)}}}updateTopicConversation(e){this._updateLocalConvList({conversationOptionsList:e,isFromGetConversations:!0,updateUnreadCount:!0})}sendReadReceipt(e){var t=e[0];let s=null;return t.conversationType===o.CONV_C2C?s=this._m.get(Ss):t.conversationType===o.CONV_GROUP&&(s=this._m.get(Ds)),s?s.sendReadReceipt(e):ai({code:ii.NO_MODULE})}getReadReceiptList(e){var t=e[0];let s=null;return t.conversationType===o.CONV_C2C?s=this._m.get(Ss):t.conversationType===o.CONV_GROUP&&(s=this._m.get(Ds)),s?s.getReadReceiptList(e):ai({code:ii.NO_MODULE})}getLastMessageTime(e){return e=this.getLocalConversation(e),e?e.lastMessage.lastTime:0}getTotalUnreadCount(){var e=this.getLocalConvList();let t=0;return e.forEach((e=>{e.type===o.CONV_SYSTEM||""!==e.messageRemindType&&e.messageRemindType!==o.MSG_REMIND_ACPT_AND_NOTE||(t+=e.unreadCount)})),t}onTotalUnreadCountUpdate(){var e=this.getTotalUnreadCount();this._convTotalUnreadCount!==e&&(ye.l(`${this._n}.onTotalUnreadCountUpdate from ${this._convTotalUnreadCount} to `+e),this._convTotalUnreadCount=e,this.emitOEvt(i.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED))}_isConvNeedShow(e){var t,s;e=this.getLocalConversation(e);return!(!Be(e)&&(t=e.type===o.CONV_TOPIC,s=e.type===o.CONV_GROUP&&e.groupProfile.type===o.GRP_ROOM,e=e.type===o.CONV_GROUP&&e.groupProfile.type===o.GRP_LIVE,t||s||e))}setAllRcvMsgOpt(e){return this._msgRemindHandler.setAllRcvMsgOpt(e)}getAllRcvMsgOpt(){return this._msgRemindHandler.getAllRcvMsgOpt()}onAllRcvMsgOptNotify(e){this._msgRemindHandler.onAllRcvMsgOptNotify(e)}clearUnreadCount(e){e=this.getLocalConversation(e),e&&0<e.unreadCount&&(e.unreadCount=0,this.emitConvUpdate(!0,!1))}storeHoppingMessageList(e){this._msgListHandler.storeHoppingMsgList(e)}clearMemMsg(e,t=!1){ye.l(this._n+`.clearMemMsg convID:${e} isOverLimit:`+t),this._msgListHandler.removeByConvID(e),this._completedMap.delete(e),this._roamingMsgKeyAndTimeMap.delete(e),this._everClearedMap.set(e,1)}reset(){ye.l(this._n+".reset"),this._setStorageConvList(!0),this._pagingStatus=wt,this._msgListHandler.reset(),this._msgRemindHandler.reset(),this._roamingMsgKeyAndTimeMap.clear(),this._sll.reset(),this._peerReadTimeMap.clear(),this._completedMap.clear(),this._convMap.clear(),this._pagingTs=0,this._pagingStartIdx=0,this._pagingPinnedTs=0,this._pagingPinnedStartIdx=0,this._remoteGroupReadSeqMap.clear(),this._convTotalUnreadCount=0,this._pagingGetCostList.length=0,this._pagingConvIDMap.clear(),this._convIDFromUnreadDBMap.clear(),this._pagingGetCostList.length=0,this._convMapForDiff.clear(),this._partialUpdatedConvMap.clear(),this._everClearedMap.clear(),this._bPullOnInvite=!0,this._convGroupHandler.reset(),this.resetReady()}}let mo=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","groupAtInfoList","nextMessageSeq","selfInfo"],Mo=function(e,t){return Ue(e)?{lastTime:0,lastSequence:0,fromAccount:"",payload:null,type:"",messageForShow:"",nick:"",avatar:"",version:0,cloudCustomData:"",isRevoked:!1,revoker:null}:{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",payload:e.payload||null,type:e.type||"",messageForShow:St(e.type,e.payload,t),nick:e.nick||"",avatar:e.avatar||"",version:e.version||0,cloudCustomData:e.cloudCustomData||"",isRevoked:e.isRevoked||!1,revoker:e.revoker||null}};class fo{constructor(e,t){this.topicID="",this.topicName="",this.avatar="",this.introduction="",this.notification="",this.unreadCount=0,this.muteAllMembers=!1,this.customData="",this.groupAtInfoList=[],this.nextMessageSeq=0,this.lastMessage=Mo(e.lastMessage,t),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:"",excludedUnreadSequenceList:void 0},this._initTopic(e)}_initTopic(e){for(var t in e)mo.indexOf(t)<0||("selfInfo"===t?this.updateSelfInfo(e[t]):this[t]="muteAllMembers"===t?1===e[t]:e[t])}updateUnreadCount(e=0){this.unreadCount=e}updateNextMessageSeq(e){this.nextMessageSeq=e}updateLastMessage(e){this.lastMessage=Mo(e)}updateGroupAtInfoList(e){this.groupAtInfoList=JSON.parse(JSON.stringify(e))}updateTopic(e){Be(e.selfInfo)||this.updateSelfInfo(e.selfInfo),Be(e.muteAllMembers)||(this.muteAllMembers=1===e.muteAllMembers),je(this,e,["groupID","lastMessageTime","selfInfo","muteAllMembers","lastMsg"])}updateSelfInfo(e){return 0===je(this.selfInfo,e,[],[""])}reduceUnreadCount(){return 1<=this.unreadCount&&(--this.unreadCount,!0)}isLastMessageRevoked({sequence:e}){return e===this.lastMessage.lastSequence}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}}class Io extends li{constructor(e){super(e),this._n="TopicModule",this._topicMap=new Map,this._getTopicTimeMap=new Map,this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600,this.getIEmitInst().on(Ji.CLOUD_CONFIG,this._onCloudConfig,this)}_onCloudConfig(){var e=this.getCloudConfig("topic_cache_time"),t=this.getCloudConfig("topic_last_active_time");Be(e)||(this.TOPIC_CACHE_TIME=Number(e)),Be(t)||(this.TOPIC_LAST_ACTIVE_TIME=Number(t))}onTopicCreated(e){var t=e["groupID"];this.resetGetTopicTime(t),this.emitOEvt(i.TOPIC_CREATED,e)}onTopicDeleted(e){let{groupID:t,topicIDList:s=[]}=e;s.forEach((e=>{this._deleteLocalTopic(t,e)})),this.emitOEvt(i.TOPIC_DELETED,e)}onTopicProfileUpdated(e){var{groupID:t,topicID:s}=e,s=this.getLocalTopic(t,s);s&&(s.updateTopic(e),this.emitOEvt(i.TOPIC_UPDATED,{groupID:t,topic:s}))}onTopicLatestMsg(e){var{topicLatestMessage:t,excludedUnreadSequenceList:s}=e||{};if(!Ue(t)){let{topicID:e}=t["groupProfile"];t.conversationType=o.CONV_GROUP,t.to=e;var i=new Hi(t);i.setElement(t.elements),this.updateUnreadCountAndLastMsg(e,i,s)}}onMessageRemindTypeUpdated(e){var{groupID:t,topicID:s,messageRemindType:o}=e,n=this.getLocalTopic(t,s);if(n){let e=n.updateSelfInfo({messageRemindType:o});e&&this.emitOEvt(i.TOPIC_UPDATED,{groupID:t,topic:n}),ye.l(this._n+`.onMessageRemindTypeUpdated topicID:${s} messageRemindType:${o} isUpdated:`+e)}}onAtInfoUpdated(e){var{topicID:e,groupAtInfoList:t}=e,s=Et(e);e=this.getLocalTopic(s,e);e&&!Be(t)&&(e.updateGroupAtInfoList(t),this.emitOEvt(i.TOPIC_UPDATED,{groupID:s,topic:e}))}onUnreadCountUpdatedFromConv(e,t=0){var s=Et(e);e=this.getLocalTopic(s,e);e&&e.unreadCount!==t&&(e.updateUnreadCount(t),0===t&&e.updateSelfInfo({readedSequence:e.lastMessage.lastSequence}),this.emitOEvt(i.TOPIC_UPDATED,{groupID:s,topic:e}))}onMessageSent(e){let{groupID:t,topicID:s,lastMessage:o}=e,n=this.getLocalTopic(t,s);if(n){let{sequence:e=0}=o,s=e+1;s>n.nextMessageSeq&&(n.updateNextMessageSeq(s),n.updateLastMessage(o),n.updateSelfInfo({readedSequence:e}),n.updateUnreadCount(0),this.emitOEvt(i.TOPIC_UPDATED,{groupID:t,topic:n}))}}onMessageModified(e){var t,{to:s,time:o,sequence:n,elements:r,cloudCustomData:a,messageVersion:l}=e,d=Et(s),c=this.getLocalTopic(d,s);c&&(t=c.lastMessage,ye.d(this._n+`.onMessageModified topicID:${s} lastMessage:`,JSON.stringify(t),"options:",JSON.stringify(e)),t)&&(null===t.payload||t.lastTime===o&&t.lastSequence===n&&t.version!==l)&&(t.type=r[0].type,t.payload=r[0].content,t.messageForShow=St(t.type,t.payload,this.isIntl()),t.cloudCustomData=a,t.version=l,t.lastSequence=n,t.lastTime=o,this.emitOEvt(i.TOPIC_UPDATED,{groupID:d,topic:c}))}onMessageRevoked(e){if(0!==e.length){let t=null,s=null,o=!1;e.forEach((e=>{let i=e.to;if(s=Et(i),t=this.getLocalTopic(s,i)){t.reduceUnreadCount()&&(o=!0),t.isLastMessageRevoked(e)&&(t.setLastMessageRevoked(!0),t.setLastMessageRevoker(e.revoker),o=!0);let s=t.selfInfo.excludedUnreadSequenceList||[];s.push(e.sequence),t.updateSelfInfo({excludedUnreadSequenceList:s})}})),o&&this.emitOEvt(i.TOPIC_UPDATED,{groupID:s,topic:t})}}isLastMessageRevoked(e){var{topicID:e,sequence:t}=e,s=Et(e);s=this.getLocalTopic(s,e);let i=!1;return s?s.isLastMessageRevoked({sequence:t}):i}updateUnreadCountAndLastMsg(e,t,s){var n=Et(e),r=this.getLocalTopic(n,e);if(r){let a=r.selfInfo.excludedUnreadSequenceList||[];if(Be(s)||(a=s),t._isExcludedFromUnreadCount&&a.push(t.sequence),r.updateSelfInfo({excludedUnreadSequenceList:a}),ye.l(`${this._n}.updateUnreadCountAndLastMsg seq:${t.sequence} lastSeq:`+r.lastMessage.lastSequence),t.sequence>r.lastMessage.lastSequence){r.updateLastMessage(t);let s=t.sequence+1;r.updateNextMessageSeq(s),t=this._computeUnreadCount(r),r.updateUnreadCount(t),e=this.get(As).getLocalConversation(""+o.CONV_GROUP+e),e&&e.updateUnreadCount({nextUnreadCount:t,isFromGetConversations:!0}),this.emitOEvt(i.TOPIC_UPDATED,{groupID:n,topic:r})}}}getJoinedCommunityList(){return this.get(Ds).syncCommunityWithTopic()}createTopicInCommunity(e){let t=this._n+".createTopicInCommunity",s=e["topicID"];if(!Be(s)&&!dt(s))return ai({code:ii.ILLEGAL_TOPIC_ID});if(e.topicName&&!1===this._filterProfanity("topicName",e))return ai({code:ii.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return ai({code:ii.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return ai({code:ii.PROFANITY_FOUND});let i=new Ei("createTopicInCommunity");return this.req({P:di.CREATE_TOPIC,data:{...e}}).then((s=>(s=s.data.topicID,i.setMessage("topicID:"+s).end(),ye.l(t+" ok. topicID:"+s),this._updateTopicMap([{...e,topicID:s}]),ti({topicID:s})))).catch((e=>(i.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}deleteTopicFromCommunity(e){let t=this._n+".deleteTopicFromCommunity",{groupID:s,topicIDList:i=[]}=e,o=new Ei("deleteTopicFromCommunity");return o.setMessage(`groupID:${s} topicIDList:`+i),this.req({P:di.DEL_TOPIC,data:{groupID:s,topicIDList:i}}).then((e=>{let{resultList:i=[]}=e.data,n=[],r=[];return i.forEach((e=>{var{topicID:e,errorCode:t,errorInfo:s}=e;0===t?n.push({topicID:e}):r.push({topicID:e,code:t,message:s})})),e=`success count:${n.length}, fail count:`+r.length,o.setMoreMessage(e).end(),ye.l(t+" ok. "+e),n.forEach((e=>{this._deleteLocalTopic(s,e.topicID)})),ti({successTopicList:n,failureTopicList:r})})).catch((e=>(o.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}updateTopicProfile(e){let t=this._n+".updateTopicProfile";if(ye.l(t+" options:",e),e.topicName&&!1===this._filterProfanity("topicName",e))return ai({code:ii.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return ai({code:ii.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return ai({code:ii.PROFANITY_FOUND});let s=new Ei("updateTopicProfile");return s.setMessage(`groupID:${e.groupID} topicID:`+e.topicID),Be(e.muteAllMembers)||(e.muteAllMembers=!0===e.muteAllMembers?"On":"Off"),this.req({P:di.UPDATE_TOPIC_PROFILE,data:{...e}}).then((()=>(s.end(),ye.l(t+" ok"),this._updateTopicMap([e]),ti({topic:this.getLocalTopic(e.groupID,e.topicID)})))).catch((e=>(s.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}getTopicList(e){let t=this._n+".getTopicList",{groupID:s,topicIDList:i=[]}=e,o=0===i.length,n=new Ei("getTopicList");if(n.setMessage("groupID:"+s),this._getTopicTimeMap.has(s)){let{isGetAll:e,time:r}=this._getTopicTimeMap.get(s);if((e||!e&&!o)&&Date.now()-r<1e3*this.TOPIC_CACHE_TIME){let e=this._getLocalTopicList(s,i);if(o||e.length===i.length)return n.setMoreMessage("from cache, topic count:"+e.length).end(),ye.l(t+` groupID:${s} from cache, topic count:`+e.length),ri({successTopicList:e,failureTopicList:[]})}}return this.req({P:di.GET_TOPIC_LIST,data:{groupID:s,topicIDList:i}}).then((e=>{let{topicInfoList:i=[]}=e.data,r=[],a=[],l=[];i.forEach((e=>{var{topic:e,selfInfo:t,errorCode:s,errorInfo:i}=e,o=e["topicID"];0===s?(r.push({...e,selfInfo:t}),a.push(o)):l.push({topicID:o,code:s,message:i})})),this._updateTopicMap(r),this._handleTopicAtInfo(r),e=`success count:${a.length}, fail count:`+l.length,n.setMoreMessage(e).end(),ye.l(t+` groupID:${s} from remote, `+e);let d=[];return Ue(a)||(this._getTopicTimeMap.set(s,{time:Date.now(),isGetAll:o}),d=this._getLocalTopicList(s,a)),ti({successTopicList:d,failureTopicList:l})})).catch((e=>(n.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}hasLocalTopic(e,t){return!!this._topicMap.has(e)&&this._topicMap.get(e).has(t)}getLocalTopic(e,t){let s=null;return this._topicMap.has(e)?this._topicMap.get(e).get(t):s}_getLocalTopicList(e,t=[]){e=this._topicMap.get(e);let s=[];return e&&(s=[...e.values()]),0===t.length?s:s.filter((e=>t.includes(e.topicID)))}_deleteLocalTopic(e,t){this._topicMap.has(e)&&this._topicMap.get(e).has(t)&&(this._topicMap.get(e).delete(t),ye.l(this._n+`._deleteLocalTopic groupID:${e} topicID:`+t))}_updateTopicMap(e){let t=[];e.forEach((e=>{var{groupID:s,topicID:i}=e;let n=null;this._topicMap.has(s)||this._topicMap.set(s,new Map),this._topicMap.get(s).has(i)?(n=this._topicMap.get(s).get(i)).updateTopic(e):(this._getTopicLastMessage(e),n=new fo(e,this.isIntl()),this._topicMap.get(s).set(i,n)),e=this._computeUnreadCount(n),n.updateUnreadCount(e),t.push({conversationID:""+o.CONV_GROUP+i,type:o.CONV_TOPIC,unreadCount:e})})),0<t.length&&this.get(As).updateTopicConversation(t)}resetGetTopicTime(e){Be(e)?[...this._getTopicTimeMap.keys()].forEach((e=>{this._getTopicTimeMap.set(e,0)})):this._getTopicTimeMap.set(e,0)}getTopicListOnReconnected(){let e=[...this._topicMap.keys()],t=[],s=this.get(As);e.forEach((e=>{let i=[],o=this._getLocalTopicList(e);s.deleteTopicRoamingInfo(e),o.forEach((e=>{var{lastMessage:{lastTime:t=0}}=e;Date.now()-1e3*t<1e3*this.TOPIC_LAST_ACTIVE_TIME&&i.push(e.topicID)})),0<i.length&&t.push({groupID:e,topicIDList:i})})),ye.l(this._n+".getTopicListOnReconnected. active community count:"+t.length),this._relayGetTopicList(t)}_relayGetTopicList(e){if(0!==e.length){let t=e.shift(),s=5<t.topicIDList.length?"topicIDList.length:"+t.topicIDList.length:"topicIDList:"+t.topicIDList,i=new Ei("relayGetTopicList");i.setMessage(s),ye.l(this._n+"._relayGetTopicList. "+s),this.getTopicList(t).then((()=>{i.end(),this._relayGetTopicList(e)})).catch((t=>{i.setError(t).end(),this._relayGetTopicList(e)}))}}_handleTopicAtInfo(e){0!==e.length&&e.forEach((e=>{let{groupID:t,topicID:s,groupAtInfoList:i}=e,o=[];Be(i)||(i.forEach((e=>{o.push({...e,groupID:t,topicID:s})})),this.get(As).onNewGroupAtTips({dataList:o}))}))}_getTopicLastMessage(e){var t;Be(e.lastMsg)||(t={time:e.lastMsg.time,sequence:e.lastMsg.sequence,from:e.lastMsg.from,payload:e.lastMsg.elements[0]?e.lastMsg.elements[0].content:null,type:e.lastMsg.elements[0]?e.lastMsg.elements[0].type:"",nick:e.lastMsg.nick,avatar:e.lastMsg.avatar,version:e.lastMsg.messageVersion,cloudCustomData:e.lastMsg.cloudCustomData,isRevoked:2===e.lastMsg.isPlaceMessage,revoker:Ue(e.lastMsg.revokerInfo)?null:e.lastMsg.revokerInfo.revoker},e.lastMessage=t)}deleteTopicListInCommunity(e){let t=this._getLocalTopicList(e),s=this.get(As);t.forEach((t=>{t=t.topicID,this._deleteLocalTopic(e,t),this._getTopicTimeMap.delete(e),s.deleteLocalConv(""+o.CONV_GROUP+t)}))}_computeUnreadCount(e){let{excludedUnreadSequenceList:t,readedSequence:s}=e.selfInfo,i=e.nextMessageSeq-e.selfInfo.readedSequence-1;if(Ve(t)){let o=0;t.forEach((t=>{t>s&&t<=e.nextMessageSeq-1&&(o+=1)})),1<=o&&(i-=o)}return i<0?0:i}_filterProfanity(e,t){var s,i=this.get($s);return!i||(({isAllowedToSend:i,modifiedText:s}=i.filterText(t[e],A)),!0===i&&(t[e]=s,!0))}getMessageExtensions(e,t){ye.l(this._n+".getMessageExtensions startSequence:"+t);var s=Et(e.to);return this.req({P:di.GET_GRP_MSG_EXT,data:{groupID:s,topicID:e.to,messageSequence:e.sequence,startSequence:t}})}modifyMsgExts(e,t,s=1){ye.l(this._n+".modifyMsgExts operateType:"+s);var i=Et(e.to);return this.req({P:di.MODIFY_GRP_MSG_EXT,data:{groupID:i,topicID:e.to,messageSequence:e.sequence,extensionList:t,operateType:s}})}reset(){ye.l(this._n+".reset"),this._topicMap.clear(),this._getTopicTimeMap.clear(),this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600}}class Co{constructor(e){this._userM=e,this._n="ProfileHandler",this.TAG="profile",this.accountProfileMap=new Map,this.expirationTime=864e5}setExpirationTime(e){this.expirationTime=e}getUserProfile(e){let t=this._n+".getUserProfile",s=e.userIDList,i=(e.fromAccount=this._userM.getMyAccount(),100<s.length&&(ye.w(t+" "+Lt(100)),s.length=100),[]),o=[];var n;for(let d=0,c=s.length;d<c;d++)n=s[d],this._userM.isMyFriend(n)&&this._contains(n)?o.push(this._getProfileFromMap(n)):i.push(n);if(0===i.length)return ri(o);e.toAccount=i;let r=e.bFromGetMyProfile||!1,a=[],l=(e.toAccount.forEach((e=>{a.push({toAccount:e,standardSequence:0,customSequence:0})})),e.userItem=a,new Ei("getUserProfile"));return l.setMessage(5<s.length?"userIDList.length:"+s.length:"userIDList:"+s),this._userM.req({P:di.GET_USER_PROFILE,data:e}).then((e=>(l.end(),ye.i(t+" ok"),e=this._handleResponse(e).concat(o),ti(r?e[0]:e)))).catch((e=>(l.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}getMyProfile(){var e,t=this._userM.getMyAccount(),s=this._n+".getMyProfile";return ye.l(s+" myAccount:"+t),this._fill(),this._contains(t)?(e=this._getProfileFromMap(t),ye.d(s+" from cache, myProfile:"+JSON.stringify(e)),ri(e)):this.getUserProfile({fromAccount:t,userIDList:[t],bFromGetMyProfile:!0})}_handleResponse(e){var t,s=e.data["userProfileItem"];if(!Ve(s))return[];let i=[],o=Date.now();for(let n=0,r=s.length;n<r;n++){let{to:e,profileItem:o}=s[n];"@TLS#NOT_FOUND"!==e&&""!==e&&(t=this._update(e,this._getLatestProfileFromResponse(e,o))["latestProfile"],i.push(t))}return ye.l(this._n+"._handleResponse cost:"+At(o)),i}_getLatestProfileFromResponse(e,t){var s={userID:e,profileCustomField:[]};if(!Ue(t))for(let i=0,o=t.length;i<o;i++)if(-1<t[i].tag.indexOf("Tag_Profile_Custom"))s.profileCustomField.push({key:t[i].tag,value:t[i].value});else switch(t[i].tag){case Se.NICK:s.nick=t[i].value;break;case Se.GENDER:s.gender=t[i].value;break;case Se.BIRTHDAY:s.birthday=t[i].value;break;case Se.LOCATION:s.location=t[i].value;break;case Se.SELFSIGNATURE:s.selfSignature=t[i].value;break;case Se.ALLOWTYPE:s.allowType=t[i].value;break;case Se.LANGUAGE:s.language=t[i].value;break;case Se.AVATAR:s.avatar=t[i].value;break;case Se.MESSAGESETTINGS:s.messageSettings=t[i].value;break;case Se.ADMINFORBIDTYPE:s.adminForbidType=t[i].value;break;case Se.LEVEL:s.level=t[i].value;break;case Se.ROLE:s.role=t[i].value;break;default:ye.w(this._n+"._getLatestProfileFromResponse unknown tag:",t[i].tag,t[i].value)}return s}updateMyProfile(e){let t=this._n+".updateMyProfile";if(e.nick&&!1===this._userM.filterProfanity("nick",e))return ai({code:ii.PROFANITY_FOUND});if(e.selfSignature&&!1===this._userM.filterProfanity("selfSignature",e))return ai({code:ii.PROFANITY_FOUND});let s=new Ei("updateMyProfile");s.setMessage(JSON.stringify(e));var o=(new no).validate(e);if(!o.valid)return s.setCode(ii.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("info:"+o.tips).end(),ye.e(t+" info:"+o.tips),ai({code:ii.UPDATE_PROFILE_INVALID_PARAM});let n=[];for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&("profileCustomField"===i?e.profileCustomField.forEach((e=>{n.push({tag:e.key,value:e.value})})):n.push({tag:Se[i.toUpperCase()],value:e[i]}));if(0===n.length){let e=new si({code:ii.UPDATE_PROFILE_NO_KEY});return s.setError(e).end(),ye.e(t+" failed. error:",e),ai(e)}let r=this._userM.getMyAccount();return this._userM.req({P:di.UPDATE_MY_PROFILE,data:{fromAccount:r,profileItem:n}}).then((o=>{s.end(),ye.i(t+" ok");var{isProfileUpdated:n,latestProfile:a}=this._update(r,e);return!0===n&&this._userM.emitOEvt(i.PROFILE_UPDATED,[a]),ri(a)})).catch((e=>(s.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}onProfileModified(e){var t=e.dataList;if(!Ue(t)){let n=t.length;ye.d(`${this._n}.onProfileModified count:${n} dataList:`,e.dataList);var s,o=[];for(let e=0;e<n;e++){s=t[e].userID;let{isProfileUpdated:i,latestProfile:n}=this._update(s,this._getLatestProfileFromResponse(s,t[e].profileList));!0===i&&o.push(n)}0<o.length&&(this._userM.emitIEvt(Ji.PROFILE_UPDATED,o),this._userM.emitOEvt(i.PROFILE_UPDATED,o))}}_fill(){if(0===this.accountProfileMap.size){var e=this._getCachedProfiles(),t=Date.now();for(let s=0,i=e.length;s<i;s++)t-e[s].lastUpdatedTime<this.expirationTime&&this.accountProfileMap.set(e[s].userID,e[s]);ye.l(this._n+"._fill from cache, size:"+this.accountProfileMap.size)}}_update(e,t){let s,i=!1;var o=Date.now();return this._contains(e)?(s=this._getProfileFromMap(e),t.profileCustomField&&!0===nt(s.profileCustomField,t.profileCustomField)&&(s.lastUpdatedTime=o,i=!0),0<je(s,t,["profileCustomField"])&&(s.lastUpdatedTime=o,i=!0)):(s=new no(t),!this._userM.isMyFriend(e)&&e!==this._userM.getMyAccount()||(s.lastUpdatedTime=o,i=!0,this.accountProfileMap.set(e,s))),this._flush(e===this._userM.getMyAccount()),!0===i&&ye.l(this._n+`._update account:${e} isUpdated:`+i),{isProfileUpdated:i,latestProfile:s}}_flush(e){var t=[...this.accountProfileMap.values()],s=this._userM.getStorageModule();ye.d(this._n+`._flush length:${t.length} flushAtOnce:`+e),s.setItem(this.TAG,t,e)}_contains(e){return this.accountProfileMap.has(e)}_getProfileFromMap(e){return this.accountProfileMap.get(e)}_getCachedProfiles(){var e=this._userM.getStorageModule().getItem(this.TAG);return Ue(e)?[]:e}onConvProfileUpdated(e){var t,s,i,o=[];for(let n=0,r=e.length;n<r;n++)s=(t=e[n]).userID,this._userM.isMyFriend(s)&&(this._contains(s)?(i=this._getProfileFromMap(s),0<je(i,t)&&o.push(s)):o.push(t.userID));0!==o.length&&(ye.l(this._n+".onConvProfileUpdated toAccountList:"+o),this.getUserProfile({userIDList:o}))}getNickAndAvatarByUserID(e){return this._contains(e)?{nick:(e=this._getProfileFromMap(e)).nick,avatar:e.avatar}:{nick:"",avatar:""}}getUserNickAndAvatar(e){var t=[...new Set(e)];ye.l(`${this._n}.getUserNickAndAvatar userIDList.length:${e.length} uniqueUserIDList.length:`+t.length);let s=[];if(0===e.length)return Promise.resolve(s);let i=this._createUserIDListGroup(t),o=[];return i.forEach((e=>{o.push(this.getUserProfile({userIDList:e}))})),Promise.all(o).then((e=>(e.forEach((e=>{e=e.data.map((({userID:e,nick:t,avatar:s})=>({userID:e,nick:t,avatar:s}))),s.push(...e)})),s)))}_createUserIDListGroup(e){var t=[];let s=0;for(;s<e.length;)t.push(e.slice(s,s+=100));return t}reset(){this._flush(!0),this.accountProfileMap.clear()}}class vo{constructor(e){Ue||(this.userID=e.userID||"",this.timeStamp=e.timeStamp||0)}}class To{constructor(e){this._userM=e,this._n="BlacklistHandler",this._blacklistMap=new Map,this._startIndex=0}getLocalBlacklist(){return[...this._blacklistMap.keys()]}getBlacklist(){let e=this._n+".getBlacklist",t={fromAccount:this._userM.getMyAccount(),maxLimited:100,startIndex:this._startIndex},s=new Ei("getBlacklist");return this._userM.req({P:di.GET_BL,data:t}).then((t=>{var{blackListItem:t,startIndex:o}=t.data,n=Ue(t)?0:t.length;s.setMessage("count:"+n).end(),ye.i(e+" ok"),this._startIndex=o,this._handleResponse(t,!0),this._userM.emitOEvt(i.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]),0!==this._startIndex&&this.getBlacklist()})).catch((t=>(s.setError(t).end(),ye.e(e+" failed. error:",t),ai(t))))}addBlacklist(e){let t=new Ei("addToBlacklist"),s=this._n+".addBlacklist",i=this._userM.getMyAccount();if(1!==e.userIDList.length||e.userIDList[0]!==i)return e.userIDList.includes(i)&&(e.userIDList=e.userIDList.filter((e=>e!==i))),e.fromAccount=this._userM.getMyAccount(),e.toAccount=e.userIDList,this._userM.req({P:di.ADD_TO_BL,data:e}).then((i=>(t.setMessage(5<e.userIDList.length?"userIDList.length:"+e.userIDList.length:"userIDList:"+e.userIDList).end(),ye.i(s+" ok"),this._handleResponse(i.resultItem,!0),ti([...this._blacklistMap.keys()])))).catch((e=>(t.setError(e).end(),ye.e(s+" failed. error:",e),ai(e))));{let e=ii.CANNOT_ADD_SELF_TO_BLACKLIST,i=this._userM.getErrMsg(e);t.setCode(e).setMessage(i).end();var o=new si({code:e});return ye.e(s+" failed. error:",o),ai(o)}}_handleResponse(e,t){if(!Ue(e)){let s,i,o;for(let n=0,r=e.length;n<r;n++)i=e[n].to,o=e[n].resultCode,!Be(o)&&0!==o||(t?((s=this._blacklistMap.has(i)?this._blacklistMap.get(i):new vo).userID=i,Ue(e[n].addBlackTimeStamp)||(s.timeStamp=e[n].addBlackTimeStamp),this._blacklistMap.set(i,s)):this._blacklistMap.has(i)&&(s=this._blacklistMap.get(i),this._blacklistMap.delete(i)))}ye.l(`${this._n}._handleResponse total:${this._blacklistMap.size} bAdd:`+t)}deleteBlacklist(e){let t=this._n+".deleteBlacklist",s=new Ei("removeFromBlacklist");return e.fromAccount=this._userM.getMyAccount(),e.toAccount=e.userIDList,this._userM.req({P:di.RM_FROM_BL,data:e}).then((i=>(s.setMessage(5<e.userIDList.length?"userIDList.length:"+e.userIDList.length:"userIDList:"+e.userIDList).end(),ye.i(t+" ok"),this._handleResponse(i.data.resultItem,!1),ti([...this._blacklistMap.keys()])))).catch((e=>(s.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}onAccountDeleted(e){for(let s=0,i=e.length;s<i;s++){let t=e[s];this._blacklistMap.has(t)&&this._blacklistMap.delete(t)}let t=e.length;0<t&&(ye.l(`${this._n}.onAccountDeleted count:${t} `+(t<30?"userIDList:"+e:"")),this._userM.emitOEvt(i.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]))}onAccountAdded(e){var t,s=[];for(let i=0,o=e.length;i<o;i++)t=e[i],this._blacklistMap.has(t)||(this._blacklistMap.set(t,new vo({userID:t})),s.push(t));0<s.length&&(ye.l(this._n+`.onAccountAdded count:${s.length} userIDList:`,s),this._userM.emitOEvt(i.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]))}reset(){this._blacklistMap.clear(),this._startIndex=0}}let yo=function(e){var t=String(e).replace(/[=]+$/,"");let s="";if(t.length%4==1)return"";for(let i,o,n=0,r=0;o=t.charAt(r++);~o&&(i=n%4?64*i+o:o,n++%4)&&(s+=String.fromCharCode(255&i>>(-2*n&6))))o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);try{return decodeURIComponent(escape(s))}catch(e){return""}};class Eo{constructor(e){this._userM=e,this._n="UserStatusHandler",this.MAX_QUERY_USER_COUNT=500,this.MAX_SUBSCRIBE_USER_COUNT=100,this.MAX_UNSUBSCRIBE_USER_COUNT=100,this._userM.getIEmitInst().on(Ji.CLOUD_CONFIG,this._onCloudConfig,this)}_onCloudConfig(){var e=this._userM.getCloudConfig("status_query_count"),t=this._userM.getCloudConfig("status_sub_count"),s=this._userM.getCloudConfig("status_unsub_count");ye.l(this._n+`._onCloudConfig statusQueryCount:${e} statusSubscribeCount:${t} statusUnsubscribeCount:`+s),Be(e)||(this.MAX_QUERY_USER_COUNT=parseInt(e,10)),Be(e)||(this.MAX_SUBSCRIBE_USER_COUNT=parseInt(t,10)),Be(e)||(this.MAX_UNSUBSCRIBE_USER_COUNT=parseInt(s,10))}onUserStatusUpdated(e){let t=e["dataList"],s=this._userM.getMyUserID(),o=this._userM.get(Os),n=t.map((e=>{var{to:e,statusType:t,customStatus:i}=e,i=yo(i);return e===s&&o.setCustomStatus(i),{userID:e,statusType:t,customStatus:i}}));ye.l(this._n+".onUserStatusUpdated list:"+JSON.stringify(n)),this._userM.emitOEvt(i.USER_STATUS_UPDATED,n)}setSelfStatus(e){let t=this._n+".setSelfStatus";if(!1===this._userM.filterProfanity("customStatus",e))return ai({code:ii.PROFANITY_FOUND});let s=new Ei("setSelfStatus"),i=e["customStatus"];return this._userM.req({P:di.SET_SELF_STATUS,data:{customStatus:i}}).then((e=>(s.setMessage("customStatus:"+i).end(),ye.l(t+" ok. customStatus:"+i),this._userM.get(Os).setCustomStatus(i),ti({userID:this._userM.getMyUserID(),statusType:1,customStatus:i})))).catch((e=>(s.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}getUserStatus(e){let t,s=this._n+".getUserStatus",{userIDList:i=[]}=e,o=this._userM.getMyUserID(),n=[...i];var r=n.indexOf(o);if(-1<r){n.splice(r,1);let e=this._userM.get(Os).getCustomStatus();t={userID:o,statusType:1,customStatus:e}}if(0===n.length)return ri({successUserList:[t],failureUserList:[]});if(!this._userM.canIUse(y.USER_STATUS))return this._userM.noUse("getUserStatus");n.length>this.MAX_QUERY_USER_COUNT&&(ye.w(s+" "+Lt(this.MAX_QUERY_USER_COUNT)),n=i.slice(0,this.MAX_QUERY_USER_COUNT));let a=new Ei("getUserStatus");return this._userM.req({P:di.GET_USER_STATUS,data:{userIDList:n}}).then((e=>{var{successUserList:e=[],failureUserList:o=[]}=e.data,o=(e=e.map((e=>{var{userID:e,statusType:t,customStatus:s}=e;return{userID:e,statusType:t,customStatus:yo(s)}})),o.map((e=>{var{userID:e,invalidUserID:t,errorCode:s,errorInfo:i}=e;return{userID:Ue(t)?e:t,code:s,message:i}}))),n=(Be(t)||e.unshift(t),`userID count:${i.length}, success count:${e.length}, fail count:`+o.length);return a.setMessage(n).end(),ye.l(s+` ok. ${n}.`),ti({successUserList:e,failureUserList:o})})).catch((e=>(a.setMessage("userID count:"+i.length).setError(e).end(),ye.e(s+" failed. error:",e),ai(e))))}subscribeUserStatus(e){var t="subscribeUserStatus";if(!this._userM.canIUse(y.USER_STATUS))return this._userM.noUse(t);let s=this._n+"."+t,{userIDList:i=[]}=e,o=[...i],n=(o.length>this.MAX_SUBSCRIBE_USER_COUNT&&(ye.w(s+" "+Lt(this.MAX_SUBSCRIBE_USER_COUNT)),o=i.slice(0,this.MAX_SUBSCRIBE_USER_COUNT)),new Ei(t)),r="userID count:"+i.length;return ye.l(s+" "+r),this._userM.req({P:di.SUB_USER_STATUS,data:{userIDList:o}}).then((e=>{var{failureUserList:e=[]}=e.data;e=e.map((e=>{var{userID:e,invalidUserID:t,errorCode:s,errorInfo:i}=e;return{userID:Ue(t)?e:t,code:s,message:i}}));return n.setMessage(r+" fail count:"+e.length).end(),ye.l(s+` ok. fail count:${e.length}.`),ti({failureUserList:e})})).catch((e=>(n.setMessage(r).setError(e).end(),ye.e(s+" failed. error:",e),ai(e))))}unsubscribeUserStatus(e){var t="unsubscribeUserStatus";if(!this._userM.canIUse(y.USER_STATUS))return this._userM.noUse(t);let s=this._n+"."+t,{userIDList:i=[]}=e||{},o=[...i],n=(i.length>this.MAX_UNSUBSCRIBE_USER_COUNT&&(ye.w(s+" "+Lt(this.MAX_UNSUBSCRIBE_USER_COUNT)),o=i.slice(0,this.MAX_UNSUBSCRIBE_USER_COUNT)),new Ei(t)),r="userID count:"+i.length;return ye.l(s+" "+r),e={userIDList:o},0===o.length&&(e.userIDList=void 0,e.unsubscribeAll=1),this._userM.req({P:di.UNSUB_USER_STATUS,data:e}).then((e=>{var{failureUserList:e=[]}=e.data;e=e.map((e=>{var{userID:e,invalidUserID:t,errorCode:s,errorInfo:i}=e;return{userID:Ue(t)?e:t,code:s,message:i}}));return n.setMessage(r+" fail count:"+e.length).end(),ye.l(s+` ok. fail count:${e.length}.`),ti({failureUserList:e})})).catch((e=>(n.setMessage(r).setError(e).end(),ye.e(s+" failed. error:",e),ai(e))))}reset(){this.MAX_QUERY_USER_COUNT=500,this.MAX_SUBSCRIBE_USER_COUNT=100,this.MAX_UNSUBSCRIBE_USER_COUNT=100}}class So extends li{constructor(e){super(e),this._n="UserModule",this._profileHandler=new Co(this),this._blacklistHandler=new To(this),this._userStatusHandler=new Eo(this),this.getIEmitInst().on(Ji.A2KEY_AND_TINYID_UPDATED,this.onContextUpdated,this)}onContextUpdated(e){this._profileHandler.getMyProfile(),this._blacklistHandler.getBlacklist()}mockOnNickAvatarModified(e,t){ye.l(this._n+`._mockOnNickAvatarModified nick:${e} avatar:`+t),this.onProfileModified({dataList:[{pushType:1,userID:this.getMyUserID(),profileList:[{tag:Se.NICK,value:e},{tag:Se.AVATAR,value:t}]}]})}onProfileModified(e){this._profileHandler.onProfileModified(e)}onRelationChainModified(e){if(e=e.dataList,!Ue(e)){let t=[],s=(e.forEach((e=>{e.blackListDelAccount&&t.push(...e.blackListDelAccount)})),0<t.length&&this._blacklistHandler.onAccountDeleted(t),[]);e.forEach((e=>{e.blackListAddAccount&&s.push(...e.blackListAddAccount)})),0<s.length&&this._blacklistHandler.onAccountAdded(s)}}onConvProfileUpdated(e){this._profileHandler.onConvProfileUpdated(e)}getMyAccount(){return this.getMyUserID()}getMyNick(){return this._profileHandler.getNickAndAvatarByUserID(this.getMyUserID()).nick}getMyProfile(){return this._profileHandler.getMyProfile()}getStorageModule(){return this.get(Ns)}filterProfanity(e,t){var s,i=this.get($s);return!i||(({isAllowedToSend:i,modifiedText:s}=i.filterText(t[e],L)),!0===i&&(t[e]=s,!0))}isMyFriend(e){var t=this.get(Rs);return!!t&&t.isMyFriend(e)}getUserProfile(e){return this._profileHandler.getUserProfile(e)}updateMyProfile(e){return this._profileHandler.updateMyProfile(e)}getNickAndAvatarByUserID(e){return this._profileHandler.getNickAndAvatarByUserID(e)}getUserNickAndAvatar(e){return this._profileHandler.getUserNickAndAvatar(e)}getLocalBlacklist(){var e=this._blacklistHandler.getLocalBlacklist();return ri(e)}addBlacklist(e){return this._blacklistHandler.addBlacklist(e)}deleteBlacklist(e){return this._blacklistHandler.deleteBlacklist(e)}onUserStatusUpdated(e){this._userStatusHandler.onUserStatusUpdated(e)}setSelfStatus(e){return this._userStatusHandler.setSelfStatus(e)}getUserStatus(e){return this._userStatusHandler.getUserStatus(e)}subscribeUserStatus(e){return this._userStatusHandler.subscribeUserStatus(e)}unsubscribeUserStatus(e){return this._userStatusHandler.unsubscribeUserStatus(e)}reset(){ye.l(this._n+".reset"),this._profileHandler.reset(),this._blacklistHandler.reset(),this._userStatusHandler.reset()}}class Do{constructor(e,t){this._m=e,this._isLoggedIn=!1,this._SDKAppID=t.SDKAppID,this._userID=t.userID||"",this._userSig=t.userSig||"",this._version="3.5.3",this._a2Key="",this._tinyID="",this._customStatus="",this._contentType="json",this._unlimitedAVChatRoom=t.unlimitedAVChatRoom,this._scene=t.scene||"",this._oversea=t.oversea,this._instanceID=t.instanceID,this._statusInstanceID=0,this._isDevMode=t.devMode,this._isTestEnv=t.testEnv,this._proxyServer=t.proxyServer,this._fileUploadProxy=t.fileUploadProxy,this._fileDownloadProxy=t.fileDownloadProxy,this._applicationID=0,this._isPartialUpdatedConvs=t.partialUpdatedConversations,this._isIndependentDomainDisabled=t.disableIndependentDomain,this._isUsingChatCore=!1,this._uiPlatform=0,this._authKey="",this._customLoginInfo=""}isLoggedIn(){return this._isLoggedIn}isOversea(){return this._oversea}isPrivateNetWork(){return this._proxyServer}isDevMode(){return this._isDevMode}isTestEnv(){return this._isTestEnv}isPartialUpdatedConvs(){return this._isPartialUpdatedConvs}isIndependentDomainDisabled(){return this._isIndependentDomainDisabled}isSingaporeSite(){return 2e7<=this._SDKAppID&&this._SDKAppID<3e7||172e7<=this._SDKAppID&&this._SDKAppID<173e7}isKoreaSite(){return 3e7<=this._SDKAppID&&this._SDKAppID<4e7||173e7<=this._SDKAppID&&this._SDKAppID<174e7}isGermanySite(){return 4e7<=this._SDKAppID&&this._SDKAppID<5e7||174e7<=this._SDKAppID&&this._SDKAppID<175e7}isIndiaSite(){return 5e7<=this._SDKAppID&&this._SDKAppID<6e7||175e7<=this._SDKAppID&&this._SDKAppID<176e7}isJapanSite(){return 6e7<=this._SDKAppID&&this._SDKAppID<7e7||176e7<=this._SDKAppID&&this._SDKAppID<177e7}isUSASite(){return 7e7<=this._SDKAppID&&this._SDKAppID<8e7||177e7<=this._SDKAppID&&this._SDKAppID<178e7}isIndonesiaSite(){return 8e7<=this._SDKAppID&&this._SDKAppID<9e7||178e7<=this._SDKAppID&&this._SDKAppID<179e7}isIntl(){return 0===(e=this._SDKAppID)||2e7<=e&&e<9e7||172e7<=e&&e<179e7;var e}isUnlimitedAVChatRoom(){return this._unlimitedAVChatRoom}isUsingChatCore(){return this._isUsingChatCore}setUsingChatCore(e){this._isUsingChatCore=e}getUIPlatform(){return this._uiPlatform}setUIPlatform(e){this._uiPlatform=e}setUserID(e){this._userID=e}getUserID(){return this._userID}setUserSig(e){this._userSig=e}getUserSig(){return this._userSig}getSDKAppID(){return this._SDKAppID}setTinyID(e){this._tinyID=e,this._isLoggedIn=!0}getTinyID(){return this._tinyID}setCustomStatus(e){this._customStatus=e}getCustomStatus(){return this._customStatus}getScene(){return ce?window.tencent_cloud_im_csig_flutter_for_web_25F_cy:this._isTUIKit()?"tuikit":this._scene}getInstanceID(){return this._instanceID}getStatusInstanceID(){return this._statusInstanceID}setStatusInstanceID(e){this._statusInstanceID=e}getVersion(){return this._version}getA2Key(){return this._a2Key}setA2Key(e){this._a2Key=e}getContentType(){return this._contentType}getProxyServer(){return this._proxyServer}getFileUploadProxy(){return this._fileUploadProxy}getFileDownloadProxy(){return this._fileDownloadProxy}setApplicationID(e){this._applicationID=e}getApplicationID(){return this._applicationID}setDowloadFileAuthKey(e){this._authKey=e}getDownloadFileAuthKey(){return this._authKey}setCustomLoginInfo(e){this._customLoginInfo=e}getCustomLoginInfo(){return this._customLoginInfo}_isTUIKit(){let e=!1,t=!1,s=!1,i=!1,o=[];x&&(o=Object.keys(H));for(let r=0,a=(o=K?q?Object.keys(uni):Object.keys(window):o).length;r<a;r++)if(o[r].toLowerCase().includes("uikit")){e=!0;break}if(o=null,x&&!He(H.createGamePortal)&&He(getApp)&&!Be(getApp())){let e=getApp().globalData;xe(e)&&!0===e.isTUIKit&&(t=!0)}!0===this._m.get(Ns).getStorageSync(`TIM_${this._SDKAppID}_isTUIKit`)&&(s=!0);let n=null;if(O&&!U&&"undefined"==typeof uni&&__wxConfig&&(n=__wxConfig.pages),P&&"undefined"==typeof uni&&__qqConfig&&(n=__qqConfig.pages),Ve(n)&&0<n.length){for(let e=0,t=n.length;e<t;e++)if(n[e].toLowerCase().includes("tui")){i=!0;break}n=null}return e||t||s||i}reset(){this._isLoggedIn=!1,this._userSig="",this._a2Key="",this._tinyID="",this._customStatus="",this._statusInstanceID=0}}let Ro={"k-vue2-pc":1,"k-vue2-h5":2,"k-vue2-h5-uni":3,"k-vue2-app-uni":4,"k-vue2-mp-uni":5,"k-vue2-pc-uni":6,"k-vue3-pc":7,"k-vue3-h5":8,"k-vue3-h5-uni":9,"k-vue3-app-uni":10,"k-vue3-mp-uni":11,"k-vue3-pc-uni":12,"k-rn":13};class Lo extends li{constructor(e){super(e),this._n="SignModule",this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0,Zi.mixin(this)}onCheckTimer(e){this.isLoggedIn()&&e%this._helloInterval==0&&this._hello()}getPushModule(){let e;var t=this.get(Zs),s=this.get(Hs);return t.canIUseTIMPush()?e=t:s.canIUseOfflinePush()&&(e=s),e}login(e){if(this.isLoggedIn()){let e=this.getMyUserID();return(s=this.getErrMsg("RepeatLogin",e))&&ye.w(s),ri({actionStatus:"OK",errorCode:0,errorInfo:s,repeatLogin:!0})}if(Date.now()-this._lastLoginTs<=15e3)return this.warn("LoggingIn",e.userID),ai({code:ii.REPEAT_LOGIN});ye.l(this._n+".login userID:"+e.userID);var t,s=this._checkLoginInfo(e);return 0!==s.code?ai(s):(({userID:s,userSig:e}=e),(t=this.get(Os)).setUserID(s),t.setUserSig(e),this.get(bs).updateProtocolConfig(),this._login())}_login(){let e=this.get(Os),t=e.getScene(),s=0,i=t,o=(t&&t.startsWith("k-")&&(i=Ro[t],t="tuikit"),new Ei("login"));o.setMessage(""+i).setMoreMessage("identifier:"+this.getMyUserID());var n="tuikit"===t;let r=0;if(q?r=n?3===i||4===i||5===i||6===i?31:9===i||10===i||11===i||12===i?32:4:3:x?r=N?36:"tuikit"===t?12:11:K?r=ce?"flutter_web_uikit"===t?21:20:this._isReactUIKit()?de?25:24:n?1===i||2===i?29:7===i||8===i?30:de?17:14:de?16:13:13===i&&(r=38),o.setUIPlatform(r),e.setUIPlatform(r),n=this.getPushModule(),n){this._isWebUniapp=n.getUniAppPlatform();let t=this._getStatusInstanceID();e.setStatusInstanceID(t),this.get(bs).updateProtocolConfig(),s=n.getDeviceBrand()}let a=this._n+"._login";return this._lastLoginTs=Date.now(),this.req({P:di.LOGIN,data:{deviceBrand:s,isWebUniapp:this._isWebUniapp,customInfo:e.getCustomLoginInfo()}}).then((s=>{this._lastLoginTs=0;var i=Date.now();let n=null;var{a2Key:r,tinyID:l,helloInterval:d,instanceID:c,timeStamp:_,customStatus:u="",purchaseBits:h,authKey:p=""}=s.data,g=1e3*_,m=i-o.getStartTs();m=g+parseInt(m/2)-i,i=o.getStartTs()+m,o.start(i),i=g,g=m;if(me=g,(g=new Date).setTime(i),ye.i(`baseTime from server:${g} offset:`+me),!l)throw n=new si({code:ii.NO_TINYID}),o.setError(n).end(),n;if(!r)throw n=new si({code:ii.NO_A2KEY}),o.setError(n).end(),n;i=this.get(Fs).getSocketID(),g=yo(u),u=`socketID:${i} scene:${t} helloInterval:${d} instanceID:${c} timeStamp:${_} offset:${m} customStatus:${g} isWebUniapp:`+this._isWebUniapp,ye.l(a+" ok. "+u);let M="",f="";if(O&&He(H.getAccountInfoSync)){let e=H.getAccountInfoSync().miniProgram;e&&(M=e.appId,f=e.envVersion)}return o.setMoreMessage(u+` href:${K?window.location.href:""} mpAppId:${M} envVersion:${f} authKey:`+p).end(),e.setA2Key(r),e.setTinyID(l),e.setStatusInstanceID(c),e.setCustomStatus(g),e.setDowloadFileAuthKey(p),h&&this.get(Ks).onPushedConfig({errorCode:0,expiredTime:0,purchaseBits:h}),this.get(bs).updateProtocolConfig(),this.emitIEvt(Ji.A2KEY_AND_TINYID_UPDATED),this._helloInterval=d,this.triggerReady(),i=this.getPushModule(),i&&(uni.setStorageSync("timUniAppInstanceID",c),i.init()),this._fetchCloudControlConfig(),this.get($s).init(),s})).catch((e=>(o.setError(e).end(!0),this._m.setNotReadyReason(ii.LOGIN_FAILED),ye.e(a+" failed. error:",e),this._lastLoginTs=0,this._m.onLoginFailed(),ai(e))))}logout(e=0){let t=this._n+".logout",s=this.isLoggedIn();return ye.i(t+` type:${e} isLoggedIn:${s} isWebUniapp:`+this._isWebUniapp),s?(new Ei("logout").setMessage("identifier:"+this.getMyUserID()).end(!0),0===e&&this._m.setNotReadyReason(ii.LOGGED_OUT),this.req({P:di.LOGOUT,data:{type:e,isWebUniapp:this._isWebUniapp}}).then((()=>(this.resetReady(),ri({})))).catch((e=>(ye.e(t+" error:",e),this.resetReady(),ri({}))))):ai({code:ii.USER_NOT_LOGGED_IN})}getLoginUser(){return this.isLoggedIn()?this.getMyUserID():""}_fetchCloudControlConfig(){this.get(qs).fetchConfig()}_getStatusInstanceID(){return uni.getStorageSync("timUniAppInstanceID")||0}_hello(){this._lastWsHelloTs=Date.now(),this.req({P:di.HELLO,data:{isWebUniapp:this._isWebUniapp}}).catch((e=>{ye.w(this._n+"._hello error:",e)}))}getLastWsHelloTs(){return this._lastWsHelloTs}_checkLoginInfo(e){let t=0;return Ue(this.get(Os).getSDKAppID())?t=ii.NO_SDKAPPID:Ue(e.userID)?t=ii.NO_IDENTIFIER:Ue(e.userSig)&&(t=ii.NO_USERSIG),{code:t}}_isReactUIKit(){return K&&void 0!==window.tencent_cloud_im_csig_react_uikit_23F_xa}onMultipleAccountKickedOut(e){new Ei("kickedOut").setMessage(`type:${o.KICKED_OUT_MULT_ACCOUNT} newInstanceInfo:`+JSON.stringify(e)).end(!0),ye.w(`${this._n}.onMultipleAccountKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,e),this.logout(1).then((()=>{this.emitOEvt(i.KICKED_OUT,{type:o.KICKED_OUT_MULT_ACCOUNT}),this._m.setNotReadyReason(ii.KICKED_OUT_MULT_ACCOUNT),this._m.reset()}))}onMultipleDeviceKickedOut(e){new Ei("kickedOut").setMessage(`type:${o.KICKED_OUT_MULT_DEVICE} newInstanceInfo:`+JSON.stringify(e)).end(!0),ye.w(`${this._n}.onMultipleDeviceKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,e),this.logout(1).then((()=>{this.emitOEvt(i.KICKED_OUT,{type:o.KICKED_OUT_MULT_DEVICE}),this._m.setNotReadyReason(ii.KICKED_OUT_MULT_DEVICE),this._m.reset()}))}onUserSigExpired(){new Ei("kickedOut").setMessage(o.KICKED_OUT_USERSIG_EXPIRED).end(!0),ye.w(this._n+".onUserSigExpired userID:"+this.getMyUserID()),0!==this.get(Os).getStatusInstanceID()&&(this.emitOEvt(i.KICKED_OUT,{type:o.KICKED_OUT_USERSIG_EXPIRED}),this._m.setNotReadyReason(ii.KICKED_OUT_USERSIG_EXPIRED),this._m.reset())}onRestApiKickedOut(e){new Ei("kickedOut").setMessage(`type:${o.KICKED_OUT_REST_API} newInstanceInfo:`+JSON.stringify(e)).end(!0),ye.w(`${this._n}.onRestApiKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,e),0!==this.get(Os).getStatusInstanceID()&&(this.emitOEvt(i.KICKED_OUT,{type:o.KICKED_OUT_REST_API}),this._m.setNotReadyReason(ii.KICKED_OUT_REST_API),this._m.reset(),this.get(Fs).onRestApiKickedOut())}reset(){ye.l(this._n+".reset"),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0}}function Ao(){return null}class Oo{constructor(e){this._m=e,this._n="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()}_errorTolerantHandle(){x||"undefined"!=typeof window&&this._canIUseCookies()||(this.getItem=Ao,this.setItem=Ao,this.removeItem=Ao,this.clear=Ao)}onCheckTimer(e){e%20==0&&0!==this._storageQueue.size&&this._doFlush()}_doFlush(){try{for(var[e,t]of this._storageQueue)this._setStorageSync(this._getKey(e),t);this._storageQueue.clear()}catch(e){ye.w(this._n+"._doFlush error:",e)}}_getPrefix(){var e=this._m.get(Os);return`TIM_${e.getSDKAppID()}_${e.getUserID()}_`}_getKey(e){return""+this._getPrefix()+e}getItem(e,t=!0){try{var s=t?this._getKey(e):e;return this.getStorageSync(s)}catch(e){return ye.w(this._n+".getItem error:",e),{}}}setItem(e,t,s=!1,i=!0){if(s){let s=i?this._getKey(e):e;this._setStorageSync(s,t)}else this._storageQueue.set(e,t)}clear(){try{x?H.clearStorageSync():this._canIUseCookies()&&localStorage.clear()}catch(i){ye.w(this._n+".clear error:",i)}}removeItem(e,t=!0){try{var s=t?this._getKey(e):e;this._removeStorageSync(s)}catch(e){ye.w(this._n+".removeItem error:",e)}}getSize(e,t="b"){try{let s={size:0,limitSize:5242880,unit:t};if(Object.defineProperty(s,"leftSize",{enumerable:!0,get:()=>s.limitSize-s.size}),x&&(s.limitSize=1024*H.getStorageInfoSync().limitSize),e)s.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if(x){let e=H.getStorageInfoSync()["keys"];e.forEach((e=>{s.size+=JSON.stringify(this.getStorageSync(e)).length+this._getKey(e).length}))}else if(this._canIUseCookies())for(let e in localStorage)localStorage.hasOwnProperty(e)&&(s.size+=localStorage.getItem(e).length+e.length);return this._convertUnit(s)}catch(e){ye.w(this._n+" error:",e)}}_convertUnit(e){var t,s={},i=e["unit"];for(t in s.unit=i,e)"number"==typeof e[t]&&("kb"===i.toLowerCase()?s[t]=Math.round(e[t]/1024):"mb"===i.toLowerCase()?s[t]=Math.round(e[t]/1024/1024):s[t]=e[t]);return s}_setStorageSync(e,t){x?k?my.setStorageSync({key:e,data:t}):H.setStorageSync(e,t):this._canIUseCookies()&&localStorage.setItem(e,JSON.stringify(t))}getStorageSync(e){return x?k?my.getStorageSync({key:e}).data:H.getStorageSync(e):this._canIUseCookies()?JSON.parse(localStorage.getItem(e)):{}}_removeStorageSync(e){x?k?my.removeStorageSync({key:e}):H.removeStorageSync(e):this._canIUseCookies()&&localStorage.removeItem(e)}_canIUseCookies(){return"undefined"!=typeof window&&navigator&&navigator.cookieEnabled&&localStorage}reset(){ye.l(this._n+".reset"),this._doFlush()}}class No{constructor(e){this._n="SSOLogBody",this._report=[]}pushIn(e){ye.d(this._n+".pushIn",this._report.length,e),this._report.push(e)}backfill(e){Ve(e)&&0!==e.length&&(ye.d(this._n+".backfill",this._report.length,e.length),this._report.unshift(...e))}getLogsNumInMemory(){return this._report.length}isEmpty(){return 0===this._report.length}_reset(){this._report.length=0,this._report=[]}getLogsInMemory(){var e=this._report.slice();return this._reset(),e}}let Po=function(e){var t=e.get(Os);return{SDKType:10,SDKAppID:t.getSDKAppID(),SDKVersion:t.getVersion(),tinyID:Number(t.getTinyID()),userID:t.getUserID(),platform:e.getPlatform(),instanceID:t.getInstanceID(),traceID:Me()}};class Uo extends li{constructor(e){super(e),this._n="EventStatModule",this.TAG="im-ssolog-event",this._reportBody=new No,this.MIN_THRESHOLD=20,this.MAX_THRESHOLD=100,this.WAITING_TIME=6e4,this.REPORT_LEVEL=[4,5,6],this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._lastReportTime=Date.now(),e=this.getIEmitInst(),e.on(Ji.A2KEY_AND_TINYID_UPDATED,this._onLoginSuccess,this),e.on(Ji.CLOUD_CONFIG,this._onCloudConfig,this)}reportAtOnce(){this._report()}_onLoginSuccess(){var e=this.get(Ns),t=e.getItem(this.TAG,!1);!Ue(t)&&He(t.forEach)&&(ye.l(this._n+"._onLoginSuccess. logs count:"+t.length),t.forEach((e=>{this._reportBody.pushIn(e)})),e.removeItem(this.TAG,!1))}_onCloudConfig(){var e=this.getCloudConfig("evt_rpt_threshold"),t=this.getCloudConfig("evt_rpt_waiting"),s=this.getCloudConfig("evt_rpt_level"),i=this.getCloudConfig("evt_rpt_sdkappid_bl"),o=this.getCloudConfig("evt_rpt_tinyid_wl");Be(e)||(this.MIN_THRESHOLD=Number(e)),Be(t)||(this.WAITING_TIME=Number(t)),Be(s)||(this.REPORT_LEVEL=s.split(",").map((e=>Number(e)))),Be(i)||(this.REPORT_SDKAPPID_BLACKLIST=i.split(",").map((e=>Number(e)))),Be(o)||(this.REPORT_TINYID_WHITELIST=o.split(","))}pushIn(e){e instanceof Ei&&(e.updateTimeStamp(),this._reportBody.pushIn(e),this._reportBody.getLogsNumInMemory()>=this.MIN_THRESHOLD)&&this._report()}onCheckTimer(){Date.now()<this._lastReportTime+this.WAITING_TIME||this._reportBody.isEmpty()||this._report()}_filterLogs(e){var t=this.get(Os),s=t.getSDKAppID();t=t.getTinyID();return Tt(this.REPORT_SDKAPPID_BLACKLIST,s)&&!yt(this.REPORT_TINYID_WHITELIST,t)?[]:e.filter((e=>this.REPORT_LEVEL.includes(e.level)))}_report(){if(!this._reportBody.isEmpty()){let t=this._reportBody.getLogsInMemory(),s=this._filterLogs(t);var e;0===s.length?this._lastReportTime=Date.now():(e={header:Po(this),event:s},this.req({P:di.SSO_STAT,data:{...e}}).then((()=>{this._lastReportTime=Date.now()})).catch((e=>{ye.w(this._n+"._report failed. error:",e),this._lastReportTime=Date.now(),this._reportBody.backfill(t),this._reportBody.getLogsNumInMemory()>this.MAX_THRESHOLD&&this._flushAtOnce()})))}}_flushAtOnce(){var e=this.get(Ns),t=e.getItem(this.TAG,!1),s=this._reportBody.getLogsInMemory(),i=this._n+"._flushAtOnce";if(Ue(t))ye.l(i+" count:"+s.length),e.setItem(this.TAG,s,!0,!1);else{let o=s.concat(t);o.length>this.MAX_THRESHOLD&&(o=o.slice(0,this.MAX_THRESHOLD)),ye.l(i+" count:"+o.length),e.setItem(this.TAG,o,!0,!1)}}reset(){ye.l(this._n+".reset"),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}let Go="none",ko="online";class wo{constructor(e){this._m=e,this._networkType=ko,this._n="NetMonitorModule",this._mpNetworkStatusCallback=null,this._webOnlineCallback=null,this._webOfflineCallback=null,this._removeListener=null,this._m.getIEmitInst().on(Ji.A2KEY_AND_TINYID_UPDATED,this._startRN,this)}_startRN(){var e;B&&(e=this._m.get(ks).getPlugin("chat-network-monitor"))&&(this._removeListener=e.addEventListener((e=>{var{isConnected:e=!1,type:t}=e;this._networkType!==t&&this._onNetworkStatusChange({isConnected:e,networkType:t})})))}start(){let e=this._n+".start";x?(H.getNetworkType({success:t=>{this._networkType=t.networkType||t.subtype||"",t.networkType===Go?ye.w(e+" no network, please check!"):ye.i(e+" networkType:"+t.networkType)}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),H.onNetworkStatusChange(this._mpNetworkStatusCallback)):K&&(this._networkType=ko,this._webOnlineCallback=this._onWebOnline.bind(this),this._webOfflineCallback=this._onWebOffline.bind(this),window.addEventListener("online",this._webOnlineCallback),window.addEventListener("offline",this._webOfflineCallback))}_onWebOnline(){this._onNetworkStatusChange({isConnected:!0,networkType:ko})}_onWebOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:Go})}_onNetworkStatusChange(e){var{isConnected:e,networkType:t}=e,s=this._n+"._onNetworkStatusChange";let i=!1;var o=`previous:${this._networkType} current:`+t;e?(ye.i(s+" "+o),this._networkType!==t&&(i=!0,this._networkType=t,this._m.get(Fs).reConnect(!0))):this._networkType!==t&&(i=!0,this._networkType=t,ye.w(s+" no network, please check!"),this._m.get(Fs).offline()),i&&new Ei("networkChange").setMessage(`isConnected:${e} `+o).end()}isOnline(){return this._networkType!==Go}getNetworkType(){return this._networkType}reset(){ye.l(this._n+".reset"),x?null!==this._mpNetworkStatusCallback&&(H.offNetworkStatusChange&&H.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null):K?(null!==this._webOnlineCallback&&(window.removeEventListener("online",this._webOnlineCallback),this._webOnlineCallback=null),null!==this._onWebOffline&&(window.removeEventListener("offline",this._webOfflineCallback),this._webOfflineCallback=null)):B&&this._removeListener&&(this._removeListener(),this._removeListener=null)}}function bo(e,t){return e(t={exports:{}},t.exports),t.exports}var Fo=bo((function(e){var t=Object.prototype.hasOwnProperty,s="~";function i(){}function o(e,t,s){this.fn=e,this.context=t,this.once=s||!1}function n(e,t,i,n,r){if("function"!=typeof i)throw new TypeError("The listener must be a function");return i=new o(i,n||e,r),n=s?s+t:t,e._events[n]?e._events[n].fn?e._events[n]=[e._events[n],i]:e._events[n].push(i):(e._events[n]=i,e._eventsCount++),e}function r(e,t){0==--e._eventsCount?e._events=new i:delete e._events[t]}function a(){this._events=new i,this._eventsCount=0}Object.create&&(i.prototype=Object.create(null),(new i).__proto__||(s=!1)),a.prototype.eventNames=function(){var e,i,o=[];if(0===this._eventsCount)return o;for(i in e=this._events)t.call(e,i)&&o.push(s?i.slice(1):i);return Object.getOwnPropertySymbols?o.concat(Object.getOwnPropertySymbols(e)):o},a.prototype.listeners=function(e){e=s?s+e:e;var t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var i=0,o=t.length,n=new Array(o);i<o;i++)n[i]=t[i].fn;return n},a.prototype.listenerCount=function(e){return e=s?s+e:e,e=this._events[e],e?e.fn?1:e.length:0},a.prototype.emit=function(e,t,i,o,n,r){var a=s?s+e:e;if(!this._events[a])return!1;var l,d=this._events[a],c=arguments.length;if(d.fn){switch(d.once&&this.removeListener(e,d.fn,void 0,!0),c){case 1:return d.fn.call(d.context),!0;case 2:return d.fn.call(d.context,t),!0;case 3:return d.fn.call(d.context,t,i),!0;case 4:return d.fn.call(d.context,t,i,o),!0;case 5:return d.fn.call(d.context,t,i,o,n),!0;case 6:return d.fn.call(d.context,t,i,o,n,r),!0}for(h=1,l=new Array(c-1);h<c;h++)l[h-1]=arguments[h];d.fn.apply(d.context,l)}else for(var _,u=d.length,h=0;h<u;h++)switch(d[h].once&&this.removeListener(e,d[h].fn,void 0,!0),c){case 1:d[h].fn.call(d[h].context);break;case 2:d[h].fn.call(d[h].context,t);break;case 3:d[h].fn.call(d[h].context,t,i);break;case 4:d[h].fn.call(d[h].context,t,i,o);break;default:if(!l)for(_=1,l=new Array(c-1);_<c;_++)l[_-1]=arguments[_];d[h].fn.apply(d[h].context,l)}return!0},a.prototype.on=function(e,t,s){return n(this,e,t,s,!1)},a.prototype.once=function(e,t,s){return n(this,e,t,s,!0)},a.prototype.removeListener=function(e,t,i,o){if(e=s?s+e:e,this._events[e])if(t){var n=this._events[e];if(n.fn)n.fn!==t||o&&!n.once||i&&n.context!==i||r(this,e);else{for(var a=0,l=[],d=n.length;a<d;a++)(n[a].fn!==t||o&&!n[a].once||i&&n[a].context!==i)&&l.push(n[a]);l.length?this._events[e]=1===l.length?l[0]:l:r(this,e)}}else r(this,e);return this},a.prototype.removeAllListeners=function(e){return e?(e=s?s+e:e,this._events[e]&&r(this,e)):(this._events=new i,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=s,e.exports=a.EventEmitter=a}));let qo=["rich.my-imcloud.com","imrich.qcloud.com"],xo=9999,Vo=1e4;class Bo extends li{constructor(e){super(e),this._n="UploadModule",this.TIMUploadPlugin=null,this.timUploadPlugin=null,this.COSSDK=null,this._cosUploadMethod=null,this.expiredTimeLimit=600,this.appid=0,this.bucketName="",this.ciUrl="",this.directory="",this.downloadUrl="",this.uploadUrl="",this.region="ap-shanghai",this.cos=null,this.cosOptions={secretId:"",secretKey:"",sessionToken:"",expiredTime:0},this.uploadFileType="",this.duration=900,this.tryCount=0,this.UPLOAD_SIZE_LIMIT={A:20971520,F:104857600,I:20971520,V:104857600},this.isSimpleCos=!1,this._fileDownloadProxy="",this._authKey="",this._fileDNList=qo,e=this.getIEmitInst(),e.on(Ji.A2KEY_AND_TINYID_UPDATED,this._init,this),e.on(Ji.CLOUD_CONFIG,this._onCloudConfig,this)}_init(){this._fileDownloadProxy=this.getFileDownloadProxy(),this._authKey=this.getDownloadFileAuthKey();var e,t=this.get(ks);this.TIMUploadPlugin=t.getPlugin("tim-upload-plugin"),this.TIMUploadPlugin?this._initUploaderMethod():(e=x?"cos-wx-sdk":"cos-js-sdk",this.COSSDK=t.getPlugin(e),this.COSSDK?(this._getAuthorizationKey(),this.warn("CosReplacement",e)):this.warn("PluginUndetected"))}_onCloudConfig(){let e=this._n+"._onCloudConfig",t=this.getCloudConfig("upload_size_limit"),s=this.getCloudConfig("simple_cos"),i=this.getCloudConfig("file_dn_list");if(ye.l(e+` uploadSizeLimit:${t} simpleCos:`+s),!Be(t))try{let e=JSON.parse(t);this.UPLOAD_SIZE_LIMIT={A:e.a?1048576*parseInt(e.a):this.UPLOAD_SIZE_LIMIT.A,F:e.f?1048576*parseInt(e.f):this.UPLOAD_SIZE_LIMIT.F,I:e.i?1048576*parseInt(e.i):this.UPLOAD_SIZE_LIMIT.I,V:e.v?1048576*parseInt(e.v):this.UPLOAD_SIZE_LIMIT.V}}catch(e){}if(Be(s)||(this.isSimpleCos="1"===s),!Be(i))try{JSON.parse(i).forEach((e=>{this._fileDNList.includes(e)||this._fileDNList.push(e)}))}catch(e){}}_getAuthorizationKey(){let e=this._n+"._getAuthorizationKey",t=new Ei("_getAuthorizationKey"),s=Math.ceil(Date.now()/1e3);this.req({P:di.COS_SIGN,data:{duration:this.expiredTimeLimit}}).then((i=>{i=i["data"];var o=(ye.l(e+" ok. data:",i),i.expiredTime-s);t.setMessage(`requestId:${i.requestId} requestTime:${s} expiredTime:${i.expiredTime} diff:${o}s`).end(),!x&&i.region&&(this.region=i.region),this.appid=i.appid,this.bucketName=i.bucketName,this.ciUrl=i.ciUrl,this.directory=i.directory,this.downloadUrl=i.downloadUrl,this.uploadUrl=i.uploadUrl,this.cosOptions={secretId:i.secretId,secretKey:i.secretKey,sessionToken:i.sessionToken,expiredTime:i.expiredTime},ye.l(e+` ok. region:${this.region} bucketName:`+this.bucketName),this._initUploaderMethod()})).catch((s=>{t.setError(s).end(),ye.w(e+" failed. error:",s)}))}_getCosPreSigUrl(e){let t=this._n+"._getCosPreSigUrl",s=Math.ceil(Date.now()/1e3),i=new Ei("_getCosPreSigUrl"),o={uploadMethod:e.uploadMethod,platform:this.getPlatform(),SDKAppID:this.getSDKAppID(),userID:e.userID,conversationType:e.conversationType,uploadConfig:[{fileID:1,fileType:e.fileType,fileName:e.fileName}]},n=di.SIMPLE_COS_PRE_SIG;return this.isSimpleCos||(o={fileType:e.fileType,fileName:e.fileName,uploadMethod:e.uploadMethod,duration:e.duration},n=di.COS_PRE_SIG),this.req({P:n,data:o}).then((e=>{this.tryCount=0;var o=e.data||{};ye.l(`${t} ok. isSimpleCos:${this.isSimpleCos} data:`,o);let n="";if(this.isSimpleCos){let{uploadUrl:e,fileKey:t}=o.preSig[0];n=`uploadIP:${o.uploadIP} uploadUrl:${e} fileKey:${t} cost:`+At(s)}else n=`requestId:${o.requestId} expiredTime:${o.expiredTime} diff:${o.expiredTime-s}s`;return i.setMessage(n).end(),o})).catch((s=>(-1===s.code&&(s.code=ii.COS_GET_SIG_FAIL),i.setError(s).end(),ye.w(t+" failed. error:",s),this.tryCount<1?(this.tryCount++,this._getCosPreSigUrl(e)):(this.tryCount=0,ai({code:ii.COS_GET_SIG_FAIL})))))}_initUploaderMethod(){this.TIMUploadPlugin?(this.timUploadPlugin=new this.TIMUploadPlugin,this._cosUploadMethod=(e,t)=>{this.timUploadPlugin.uploadFile(e,t)}):this.appid&&(this.cos=x?new this.COSSDK({ForcePathStyle:!0,getAuthorization:this._getAuthorization.bind(this)}):new this.COSSDK({getAuthorization:this._getAuthorization.bind(this)}),this._cosUploadMethod=x?(e,t)=>{this.cos.postObject(e,t)}:(e,t)=>{this.cos.uploadFiles(e,t)})}onCheckTimer(e){!this.COSSDK||this.TIMUploadPlugin||this.isLoggedIn()&&e%60==0&&Math.ceil(Date.now()/1e3)>=this.cosOptions.expiredTime-120&&this._getAuthorizationKey()}getFileDNList(){return this._fileDNList}_getAuthorization(e,t){t({TmpSecretId:this.cosOptions.secretId,TmpSecretKey:this.cosOptions.secretKey,XCosSecurityToken:this.cosOptions.sessionToken,ExpiredTime:this.cosOptions.expiredTime})}upload(e){if(!0===e._relayFlag)return Promise.resolve();var t=this.get(Bs);switch(e.type){case o.MSG_IMAGE:return t.addTotalCount(mi),this._uploadImage(e);case o.MSG_FILE:return t.addTotalCount(mi),this._uploadFile(e);case o.MSG_AUDIO:return t.addTotalCount(mi),this._uploadAudio(e);case o.MSG_VIDEO:return t.addTotalCount(mi),this._uploadVideo(e);default:return Promise.resolve()}}_uploadImage(e){let t=this.get(Ts),s=e.getElements()[0],i=t.getMessageOption(e.clientSequence);return this.doUploadImage({file:i.payload.file,to:i.to,message:e,onProgress:e=>{if(s.updatePercent(e),He(i.onProgress))try{i.onProgress(e)}catch(e){return ai({code:ii.MSG_ONPROGRESS_ERR})}}}).then((t=>{var{location:t,fileType:i,fileSize:o,width:n,height:r,smallImageUrl:a,smallImageWidth:l,smallImageHeight:d,largeImageUrl:c,largeImageWidth:_,largeImageHeight:u,imageInfoArray:h}=t;t=this.isPrivateNetWork()?t:ot(t);s.updateImageFormat(i);let p,g,m={size:o,url:t,width:n,height:r};if(h&&0<h.length)for(let e=0;e<h.length;e++){let t=h[e];1===t.type?p=t:2===t.type?g=t:m={...m,...t}}else g=a&&c?(p={url:a,width:l,height:d},{url:c,width:_,height:u}):(p=ft({originUrl:t,originWidth:n,originHeight:r,min:198}),ft({originUrl:t,originWidth:n,originHeight:r,min:720}));return s.updateImageInfoArray([{...m},{...g},{...p}]),e}))}_uploadFile(e){let t=this.get(Ts),s=e.getElements()[0],i=t.getMessageOption(e.clientSequence);return this.doUploadFile({file:i.payload.file,to:i.to,message:e,onProgress:e=>{if(s.updatePercent(e),He(i.onProgress))try{i.onProgress(e)}catch(e){return ai({code:ii.MSG_ONPROGRESS_ERR})}}}).then((({location:t})=>{let i=t;return this.isPrivateNetWork()||(i=Di(i=ot(t),this._fileDownloadProxy,this._authKey,this._fileDNList)),s.updateFileUrl(i),e}))}_uploadAudio(e){let t=this.get(Ts),s=e.getElements()[0],i=t.getMessageOption(e.clientSequence);return this.doUploadAudio({file:i.payload.file,to:i.to,message:e,onProgress:e=>{if(s.updatePercent(e),He(i.onProgress))try{i.onProgress(e)}catch(e){return ai({code:ii.MSG_ONPROGRESS_ERR})}}}).then((({location:t})=>(t=this.isPrivateNetWork()?t:ot(t),s.updateAudioUrl(t),e)))}_uploadVideo(e){let t=this.get(Ts),s=e.getElements()[0],i=t.getMessageOption(e.clientSequence);return this.doUploadVideo({file:i.payload.file,to:i.to,message:e,onProgress:e=>{if(s.updatePercent(e),He(i.onProgress))try{i.onProgress(e)}catch(e){return ai({code:ii.MSG_ONPROGRESS_ERR})}}}).then((t=>{var{location:t,snapshotInfo:i}=t;t=this.isPrivateNetWork()?t:ot(t);return s.updateVideoUrl(t),Ue(i)||s.updateSnapshotInfo(i),e}))}_checkSizeError(e){let t="";return"A"===e?t="audio":"I"===e?t="image":"V"===e?t="video":"F"===e&&(t="file"),ai({code:ii[`MSG_${e}_SIZE_LIMIT`],message:this.getErrMsg("UploadSizeLimit",t,this.UPLOAD_SIZE_LIMIT[e]/1048576+"MB")})}doUploadImage(e){if(!e.file||this._isEmptyFileList(e.file.files))return ai({code:ii.MSG_I_SELECT_F_FIRST});var t=this._checkImageType(e.file);if(!0!==t)return t;if(t=this._checkImageSize(e.file),!0!==t)return t;let s=null;return this._setUploadFileType(to),this.uploadByCOS(e).then((t=>{if(s=t,this.isPrivateNetWork())return pt(i);if(Ve(s.imageInfoArray)){let e=s.imageInfoArray.find((e=>3===e.type));if(e)return e}if(B)return{width:e.file.width,height:e.file.height};let i=ot(t.location);return pt(i=this.COSSDK?i:Di(i,this._fileDownloadProxy,this._authKey,this._fileDNList))})).then((e=>(s.width=e.width,s.height=e.height,Promise.resolve(s))))}_checkImageType(e){var t="";t=x?e.url.slice(e.url.lastIndexOf(".")+1):B?e.type.split("/")[1]:e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1);return 0<=Qi.indexOf(t.toLowerCase())||ai({code:ii.MSG_I_TYPES_LIMIT})}_checkImageSize(e){return 0===(e=(x||B?e:e.files[0]).size)?ai({code:ii.MSG_F_IS_EMPTY}):e<this.UPLOAD_SIZE_LIMIT.I||this._checkSizeError("I")}doUploadFile(e){let t=null;return!e.file||this._isEmptyFileList(e.file.files)?(t={code:ii.MSG_F_SELECT_F_FIRST},ai(t)):e.file.files[0].size>this.UPLOAD_SIZE_LIMIT.F?this._checkSizeError("F"):0===e.file.files[0].size?(t={code:ii.MSG_F_IS_EMPTY},ai(t)):(this._setUploadFileType(oo),this.uploadByCOS(e))}doUploadVideo(e){return e.file.videoFile.size>this.UPLOAD_SIZE_LIMIT.V?this._checkSizeError("V"):0===e.file.videoFile.size?ai({code:ii.MSG_F_IS_EMPTY}):-1===eo.indexOf(e.file.videoFile.type)?ai({code:ii.MSG_V_TYPES_LIMIT}):(this._setUploadFileType(so),x||B?this.handleVideoUpload({...e,file:e.file.videoFile}):K?this.handleVideoUpload(e):void 0)}handleVideoUpload(e){return new Promise(((t,s)=>{this.uploadByCOS(e).then((e=>{t(e)})).catch((()=>{this.uploadByCOS(e).then((e=>{t(e)})).catch((()=>{s(new si({code:ii.MSG_V_UPLOAD_FAIL}))}))}))}))}doUploadAudio(e){return e.file?e.file.size>this.UPLOAD_SIZE_LIMIT.A?this._checkSizeError("A"):0===e.file.size?ai({code:ii.MSG_F_IS_EMPTY}):(this._setUploadFileType(io),this.uploadByCOS(e)):ai({code:ii.MSG_A_UPLOAD_FAIL})}uploadByCOS(e){if(!He(this._cosUploadMethod))return this.warn("PluginUndetected"),ai({code:ii.COS_UNDETECTED});if(this.timUploadPlugin)return this._uploadWithPreSigUrl(e);let t=new Ei("upload"),s=this._n+".uploadByCOS",i=Date.now(),o=this._getFile(e);return new Promise(((n,r)=>{let a=x?this._createCosOptionsWXMiniApp(e):this._createCosOptionsWeb(e),l=this;this._cosUploadMethod(a,((e,a)=>{var d=Object.create(null);if(a){if(e||Ve(a.files)&&a.files[0].error){let e=new si({code:ii.MSG_F_UPLOAD_FAIL});return t.setError(e).end(),ye.l(s+" failed. error:",a.files[0].error),403===a.files[0].error.statusCode&&this._getAuthorizationKey(),void r(e)}d.fileName=o.name,d.fileSize=o.size,d.fileType=o.type.slice(o.type.indexOf("/")+1).toLowerCase(),d.location=(x?a:a.files[0].data).Location;let c=Date.now()-i,_=`size:${l._formatFileSize(o.size)} time:${c}ms speed:`+l._formatSpeed(1e3*o.size/c);ye.l(s+` success. name:${o.name} `+_),n(d),a=this.get(Bs),a.addCost(mi,c),a.addFileSize(mi,o.size),t.setMessage(_).end()}else{let i=new si({code:ii.MSG_F_UPLOAD_FAIL});t.setError(i).end(),ye.w(s+" failed. error:",e),403===e.statusCode&&this._getAuthorizationKey(),r(i)}}))}))}_uploadWithPreSigUrl(e){let t=this._n+"._uploadWithPreSigUrl",s=this._getFile(e);return this._createCosOptionsPreSigUrl(e).then((e=>new Promise(((i,o)=>{let n=new Ei("upload"),{requestSnapshotUrl:r,...a}=e,l=Date.now();this._cosUploadMethod(a,((d,c)=>{if(d||403===c.statusCode){n.setError(new si(d)).end();let s={HttpStatusCode:xo,CostTime:At(l,!1),error:d,url:e.url};c.data&&c.data.uploadIP&&(s.uploadIP=c.data.uploadIP),this._uploadSSOLog(s),ye.l(t+" failed, error:",d),o(new si({code:ii.MSG_F_UPLOAD_FAIL}))}else{let o=Object.create(null),u=c.data.location||"";this.isPrivateNetWork()||0!==u.indexOf("https://")&&0!==u.indexOf("http://")||(u=u.split("//")[1]),o.fileName=s.name,o.fileSize=s.size,o.fileType=s.type.slice(s.type.indexOf("/")+1).toLowerCase(),o.location=u;d=At(l,!1);var _=`size:${this._formatFileSize(s.size)} time:${d}ms speed:${this._formatSpeed(1e3*s.size/d)} res:`+JSON.stringify(c.data);_=(ye.l(t+` ok. name:${s.name} `+_),n.setMessage(_).end(),{HttpStatusCode:c.statusCode,FileSize:s.size,CostTime:d,url:e.url}),_=(c.data&&c.data.uploadIP&&(_.uploadIP=c.data.uploadIP),this._uploadSSOLog(_),this.get(Bs)),d=(_.addCost(mi,d),_.addFileSize(mi,s.size),[]);if(a.thumbUrl&&a.largeUrl&&d.push(this._getSmallImageInfoByUrl(a.thumbUrl,o),this._getLargeImageInfoByUrl(a.largeUrl,o)),this.uploadFileType===to&&this.isSimpleCos&&!this.isPrivateNetWork()&&(d.push(this._getImageInfoArray(a.downloadUrl,o)),c.data.uploadIP)&&d.push(this._getDownloadIP(a.downloadUrl.split("//")[1].split("/")[0],o)),r&&d.push(this._getSnapshotInfoByUrl(r,o)),0<d.length)return Promise.all(d).then((()=>{i(o)}));i(o)}}))}))))}_getDownloadIP(e,t){let s=this._n+"._getDownloadIP",i=Date.now();return this.req({P:di.GET_IP,data:{domainName:e}}).then((e=>{var o;e.data&&e.data.ip&&(ye.l(s+` ok. downloadIP:${e.data.ip} cost:`+At(i)),(o=t.location.split("/"))[0]=e.data.ip,t.location=o.join("/"))})).catch((e=>{}))}_getImageInfoArray(e,t){let s=this._n+"._getImageInfoArray",i=Date.now();return this.req({P:di.GET_IMAGE_INFO,data:{imageUrl:e}}).then((e=>(e=e.data||{},ye.l(s+` ok. data: ${JSON.stringify(e)} cost:`+At(i)),t.imageInfoArray=e.imageInfoArray,e))).catch((s=>{t.imageInfoArray=void 0,this._uploadSSOLog({HttpStatusCode:Vo,CostTime:At(i,!1),url:e})}))}_uploadSSOLog(e){if(this.isSimpleCos){var t=new Ei;t.setEventType(18),e.error&&t.setError(new si(e.error));let s=`HttpStatusCode:${e.HttpStatusCode}|CosRequestId:${e.CosRequestId||""}|FileAlreadyExist:${e.FileAlreadyExist||0}|FileSize:${e.FileSize||0}|CostTime:`+e.CostTime;e.uploadIP&&(s+="|FinalIP:"+e.uploadIP),t.setMessage("OK").setMoreMessage(e.url).setExtension(s).end()}}_getRawOrUploadProxyUrl(e){var t=this.get(Os).getFileUploadProxy();let s=e;return t?e.replace(/^https:\/\/[^/]+/,t):s}_getFile(e){return Ve(e.file.files)||We(e.file.files)?e.file.files[0]:e.file}_formatFileSize(e){return e<1024?e+"B":e<1048576?Math.floor(e/1024)+"KB":Math.floor(e/1048576)+"MB"}_formatSpeed(e){return e<=1048576?vt(e/1024,1)+"KB/s":vt(e/1048576,1)+"MB/s"}_createCosOptionsWeb(e){var t=this._getFile(e),s=t.name;s=s.slice(s.lastIndexOf(".")),s=this._genFileName(""+Ze(999999)+s);return{files:[{Bucket:this.bucketName+"-"+this.appid,Region:this.region,Key:this.directory+"/"+s,Body:t}],SliceSize:1048576,onProgress:t=>{if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(t){ye.w("onProgress callback error:",t)}},onFileFinish:(e,t,s)=>{}}}_createCosOptionsWXMiniApp(e){var t=this._getFile(e),s=this._genFileName(t.name);t=t.url;return{Bucket:this.bucketName+"-"+this.appid,Region:this.region,Key:this.directory+"/"+s,FilePath:t,onProgress:t=>{if(ye.l(JSON.stringify(t)),"function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(t){ye.w("onProgress callback error:",t)}}}}_createCosOptionsPreSigUrl(e){let t="",s="",i=0;var n=this._getFile(e);if(x||B){if(e.message.type===o.MSG_FILE){let e=n.name,s=e.slice(e.lastIndexOf("."));t=this._genFileName(""+Ze(999999)+s)}else t=this._genFileName(n.name);s=n.url,i=1}else{let e=n.name,o=e.slice(e.lastIndexOf("."));t=this._genFileName(""+Ze(999999)+o),s=n,i=0}return this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:t,uploadMethod:i,duration:this.duration,userID:e.message.from,conversationType:ct(e.message.conversationID)?1:2}).then((i=>{var{uploadUrl:o,downloadUrl:n,requestSnapshotUrl:r,thumbUrl:a,largeUrl:l,fileKey:d}=this.isSimpleCos?i.preSig[0]:i,{uploadIP:i=""}=i;return{url:this._getRawOrUploadProxyUrl(o),fileType:this.uploadFileType,fileName:t,resources:s,downloadUrl:n,requestSnapshotUrl:r,thumbUrl:a,largeUrl:l,fileKey:d,uploadIP:!this.isPrivateNetWork()&&i,onProgress:t=>{if("function"==typeof e.onProgress)try{e.onProgress(t.percent)}catch(t){ye.w("onProgress callback error:",t),ye.e(t)}}}}))}_genFileName(e){return gt()+"-"+e}_setUploadFileType(e){this.uploadFileType=e}_getSnapshotInfoByUrl(e,t){let s="_getSnapshotInfoByUrl",i=new Ei(s);return this.req({P:di.VIDEO_COVER,data:{platform:this.getPlatform(),coverName:this._genFileName(Ze(99999)),requestSnapshotUrl:e}}).then((e=>{if(e=(e.data||{}).snapshotUrl,ye.l(`${this._n}.${s} ok. snapshotUrl:`+e),i.setMessage("snapshotUrl:"+e).end(),Ue(e))return{};let o=Di(e,this._fileDownloadProxy,this._authKey,this._fileDNList);return pt(o).then((e=>{t.snapshotInfo={snapshotUrl:o,snapshotWidth:e.width,snapshotHeight:e.height}}))})).catch((e=>(ye.w(`${this._n}.${s} failed. error:`,e),i.setCode(e.errorCode).setMessage(e.errorInfo).end(),{})))}_getSmallImageInfoByUrl(e,t){return pt(Di(e,this._fileDownloadProxy,this._authKey,this._fileDNList)).then((s=>{t.smallImageUrl=e,t.smallImageWidth=s.width,t.smallImageHeight=s.height}))}_getLargeImageInfoByUrl(e,t){return pt(Di(e,this._fileDownloadProxy,this._authKey,this._fileDNList)).then((s=>{t.largeImageUrl=e,t.largeImageWidth=s.width,t.largeImageHeight=s.height}))}_isEmptyFileList(e){return!(!We(e)||0!==e.length)}reset(){ye.l(this._n+".reset")}}class Ko{constructor(e){this._n="MergerMessageHandler",this._msgM=e}uploadMergerMessage(e,t){let s=this._n+".uploadMergerMessage",i=(ye.d(s+" message:",e,"messageBytes:"+t),JSON.parse(JSON.stringify(e.payload)))["messageList"],o=i.length,n=this._msgM.get(Gs).getFileDNList(),r=new Ei("uploadMergerMessage");return i.forEach((e=>{Ri(e.messageBody[0].type,e.messageBody,n)})),this._msgM.req({P:di.UPLOAD_MERGER_MSG,data:{messageList:i}}).then((e=>{ye.d(s+" ok. response:",e.data);var{pbDownloadKey:e,downloadKey:i}=e.data;e={pbDownloadKey:e,downloadKey:i,messageNumber:o};return r.setMessage(o+`-${t}-`+i).end(),e})).catch((e=>{throw ye.w(s+" failed. error:",e),r.setError(e).end(),e}))}downloadMergerMessage(e){let t=this._n+".downloadMergerMessage",s=(ye.d(t+" message:",e),e.payload)["downloadKey"],i=this._msgM.getFileDownloadProxy(),o=this._msgM.getDownloadFileAuthKey(),n=new Ei("downloadMergerMessage");return n.setMessage("downloadKey:"+s),this._msgM.req({P:di.DOWNLOAD_MERGER_MSG,data:{downloadKey:s}}).then((s=>{ye.d(t+" ok. response:",s.data);let r=this._msgM.get(Gs).getFileDNList();if(He(e.clearElement)){let{downloadKey:t,pbDownloadKey:n,messageList:a,...l}=e.payload;e.clearElement(),e.setElement({type:e.type,content:{messageList:s.data.messageList,...l}},i,o,r)}else{let t=[];s.data.messageList.forEach((e=>{Ue(e)||(e=new Vi(e,i,o,r),t.push(e))})),e.payload.messageList=t,e.payload.downloadKey="",e.payload.pbDownloadKey=""}return n.end(),e})).catch((e=>{throw ye.w(`${t} failed. key:${s} error:`,e),n.setError(e).end(),e}))}createMergerMessagePack(e,t,s){return e.conversationType===o.CONV_C2C?this._createC2CMergerMessagePack(e,t,s):this._createGroupMergerMessagePack(e,t,s)}_createC2CMergerMessagePack(e,t,s){let i=null;t&&(t.offlinePushInfo&&(i=t.offlinePushInfo),!0===t.onlineUserOnly)&&(i?i.disablePush=!0:i={disablePush:!0});var o=[];if(xe(t)&&xe(t.messageControlInfo)){let{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:i}=t.messageControlInfo;!0===e&&o.push("NoUnread"),!0===s&&o.push("NoLastMsg"),!0===i&&o.push("NoMsgCheck")}let n="";Fe(e.cloudCustomData)&&0<e.cloudCustomData.length&&(n=e.cloudCustomData);var{pbDownloadKey:s,downloadKey:r,messageNumber:a}=s,{title:l,abstractList:d,compatibleText:c}=e.payload,_=this._msgM.get(Ss);_=_&&_.isOnlineMessage(e,t)?0:void 0;return{P:di.SEND_C2C_MSG,data:{fromAccount:this._msgM.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:s,downloadKey:r,title:l,abstractList:d,compatibleText:c,messageNumber:a}}],cloudCustomData:n,clientTime:e.clientTime,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:_,offlinePushInfo:zi(i),messageControlInfo:0!==_?o:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}_createGroupMergerMessagePack(e,t,s){let i=null;t&&t.offlinePushInfo&&(i=t.offlinePushInfo);var o=[];if(xe(t)&&xe(t.messageControlInfo)){let{excludedFromUnreadCount:e,excludedFromLastMessage:s,excludedFromContentModeration:i}=t.messageControlInfo;!0===e&&o.push("NoUnread"),!0===s&&o.push("NoLastMsg"),!0===i&&o.push("NoMsgCheck")}let n="";Fe(e.cloudCustomData)&&0<e.cloudCustomData.length&&(n=e.cloudCustomData);var{pbDownloadKey:s,downloadKey:r,messageNumber:a}=s,{title:l,abstractList:d,compatibleText:c}=e.payload,_=this._msgM.get(Ds);t=_&&_.isOnlineMessage(e,t)?1:0;return{P:di.SEND_GRP_MSG,data:{fromAccount:this._msgM.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:s,downloadKey:r,title:l,abstractList:d,compatibleText:c,messageNumber:a}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:n,onlineOnlyFlag:t,offlinePushInfo:zi(i),clientTime:e.clientTime,needReadReceipt:!0!==e.needReadReceipt||_.isMessageFromOrToAVChatroom(e.to)?0:1,messageControlInfo:0==t?o:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}}let Ho={ERR_SVR_COMM_SENSITIVE_TEXT:80001,ERR_SVR_COMM_BODY_SIZE_LIMIT:80002,OPEN_SERVICE_OVERLOAD_ERROR:60022,ERR_SVR_MSG_PKG_PARSE_FAILED:20001,ERR_SVR_MSG_INTERNAL_AUTH_FAILED:20002,ERR_SVR_MSG_INVALID_ID:20003,ERR_SVR_MSG_PUSH_DENY:20006,ERR_SVR_MSG_IN_PEER_BLACKLIST:20007,ERR_SVR_MSG_BOTH_NOT_FRIEND:20009,ERR_SVR_MSG_NOT_PEER_FRIEND:20010,ERR_SVR_MSG_NOT_SELF_FRIEND:20011,ERR_SVR_MSG_SHUTUP_DENY:20012,ERR_SVR_GROUP_INVALID_PARAMETERS:10004,ERR_SVR_GROUP_PERMISSION_DENY:10007,ERR_SVR_GROUP_NOT_FOUND:10010,ERR_SVR_GROUP_INVALID_GROUPID:10015,ERR_SVR_GROUP_REJECT_FROM_THIRDPARTY:10016,ERR_SVR_GROUP_SHUTUP_DENY:10017,MSG_SEND_FAIL:2100,OVER_FREQUENCY_LIMIT:2996},$o=[ii.MSG_ONPROGRESS_ERR,ii.MSG_I_SELECT_F_FIRST,ii.MSG_I_TYPES_LIMIT,ii.MSG_F_IS_EMPTY,ii.MSG_I_SIZE_LIMIT,ii.MSG_F_SELECT_F_FIRST,ii.MSG_F_SIZE_LIMIT,ii.MSG_V_SIZE_LIMIT,ii.MSG_V_TYPES_LIMIT,ii.MSG_A_UPLOAD_FAIL,ii.MSG_A_SIZE_LIMIT,ii.COS_UNDETECTED];function Wo(e){let t=!1;return Object.values(Ho).includes(e)&&(t=!0),120001<=e&&e<=13e4||10100<=e&&e<=10200||t}class Yo extends li{constructor(e){super(e),this._n="MessageModule",this._messageOptionsMap=new Map,this._mergerMessageHandler=new Ko(this)}createTextMessage(e){var t=this.getMyUserID(),s=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new Hi(e));e=Fe(e.payload)?e.payload:e.payload.text,e=new Si({text:e}),t=this._getNickAndAvatarByUserID(t);return s.setElement(e),s.setNickAndAvatar(t),s.setNameCard(this._getNameCardByGroupID(s)),s}createImageMessage(e){let t=this.getMyUserID(),s=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new Hi(e));if(x){let t=e.payload["file"];if(we(t))return void this.warn("FileUnsupportedInMP","createImageMessage");let s=t.tempFiles[0].path||t.tempFiles[0].tempFilePath,i={url:s,name:s.slice(s.lastIndexOf("/")+1),size:t.tempFiles&&t.tempFiles[0].size||1,type:s.slice(s.lastIndexOf(".")+1).toLowerCase()};e.payload.file=i}else if(B){let t=e.payload["file"],s={url:t.uri,name:t.fileName,size:t.fileSize||1,type:t.type,width:t.width,height:t.height};e.payload.file=s}else if(K)if(we(e.payload.file)){let t=e.payload.file;e.payload.file={files:[t]}}else if(xe(e.payload.file)&&"undefined"!=typeof uni){let t=e.payload.file.tempFiles[0];e.payload.file={files:[t]}}let i=new Oi({imageFormat:Ee.UNKNOWN,uuid:this._generateUUID(e.payload.file),file:e.payload.file},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),qo),o=this._getNickAndAvatarByUserID(t);return s.setElement(i),s.setNickAndAvatar(o),s.setNameCard(this._getNameCardByGroupID(s)),this._messageOptionsMap.set(s.clientSequence,e),s}createAudioMessage(e){var t=e.payload["file"];if(x){let s={url:t.tempFilePath,name:t.tempFilePath.slice(t.tempFilePath.lastIndexOf("/")+1),size:t.fileSize,second:parseInt(t.duration)/1e3,type:t.tempFilePath.slice(t.tempFilePath.lastIndexOf(".")+1).toLowerCase()};e.payload.file=s}if(B){let s={url:t.uri,name:t.uri.slice(t.uri.lastIndexOf("/")+1),size:t.fileSize||1,second:Math.floor(t.duration/1e3),type:t.uri.slice(t.uri.lastIndexOf(".")+1).toLowerCase()};e.payload.file=s,Ue(t.uri)&&this.warn("VoiceFileInRN")}let s=this.getMyUserID();e.currentUser=s,e.senderTinyID=this.getMyTinyID();var i=new Hi(e),o=(t=new Pi({second:Math.floor(t.duration/1e3),size:t.fileSize||t.size||1,url:t.tempFilePath||t.uri,uuid:this._generateUUID(e.payload.file)},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),qo),this._getNickAndAvatarByUserID(s));return i.setElement(t),i.setNickAndAvatar(o),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}createVideoMessage(e){let t=this.getMyUserID();e.currentUser=t,e.senderTinyID=this.getMyTinyID(),e.payload.file.thumbUrl="",e.payload.file.thumbSize=0;var s={};if(x){if(k)return void this.warn("VideoUnsupportedInAlipay");if(we(e.payload.file))return void this.warn("FileUnsupportedInMP","createVideoMessage");let t=e.payload["file"];Ve(t.tempFiles)&&(t=t.tempFiles[0]),s.url=t.tempFilePath,s.name=t.tempFilePath.slice(t.tempFilePath.lastIndexOf("/")+1),s.size=t.size||1,s.second=t.duration||0,s.type=t.tempFilePath.slice(t.tempFilePath.lastIndexOf(".")+1).toLowerCase()}else if(B){let t=e.payload["file"];s.url=t.uri,s.name=t.fileName,s.size=t.fileSize||1,s.second=t.duration||0,s.type=t.type.split("/")[1]}else if(K){if(we(e.payload.file)){let t=e.payload.file;e.payload.file.files=[t]}else if(xe(e.payload.file)&&"undefined"!=typeof uni){let t=e.payload.file.tempFile;e.payload.file.files=[t]}let t=e.payload["file"];s.url=window.URL.createObjectURL(t.files[0]),s.name=t.files[0].name,s.size=t.files[0].size||1,s.second=t.files[0].duration||0,s.type=t.files[0].type.split("/")[1]}e.payload.file.videoFile=s;var i=new Hi(e),o=(s=new qi({videoFormat:s.type,videoSecond:vt(s.second,0),videoSize:s.size,remoteVideoUrl:"",videoUrl:s.url,videoUUID:this._generateUUID(e.payload.file.videoFile),thumbUUID:this._generateUUID(e.payload.file.videoFile),thumbWidth:e.payload.file.width||200,thumbHeight:e.payload.file.height||200,thumbUrl:e.payload.file.thumbUrl,thumbSize:e.payload.file.thumbSize,thumbFormat:e.payload.file.thumbUrl.slice(e.payload.file.thumbUrl.lastIndexOf(".")+1).toLowerCase()},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),qo),this._getNickAndAvatarByUserID(t));return i.setElement(s),i.setNickAndAvatar(o),i.setNameCard(this._getNameCardByGroupID(i)),this._messageOptionsMap.set(i.clientSequence,e),i}createCustomMessage(e){var t=this.getMyUserID(),s=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new Hi(e));e=new Fi({data:e.payload.data,description:e.payload.description,extension:e.payload.extension}),t=this._getNickAndAvatarByUserID(t);return s.setElement(e),s.setNickAndAvatar(t),s.setNameCard(this._getNameCardByGroupID(s)),s}createFaceMessage(e){var t=this.getMyUserID(),s=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new Hi(e));e=new Ni(e.payload),t=this._getNickAndAvatarByUserID(t);return s.setElement(e),s.setNickAndAvatar(t),s.setNameCard(this._getNameCardByGroupID(s)),s}createMergerMessage(e){var t=this.getMyUserID(),s=(t=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),this._getNickAndAvatarByUserID(t)),new Hi(e));e=new Bi(e.payload);return s.setElement(e),s.setNickAndAvatar(t),s.setNameCard(this._getNameCardByGroupID(s)),s.setRelayFlag(!0),s}createForwardMessage(e){var t,s,{to:i,conversationType:n,priority:r,payload:a,needReadReceipt:l,receiverList:d}=e;return Ve(a._elements)?(t=this.getMyUserID(),s=this._getNickAndAvatarByUserID(t),a.type===o.MSG_GRP_TIP?ai({code:ii.MSG_FORWARD_TYPE_INVALID}):(n={to:i,conversationType:n,conversationID:""+n+i,priority:r,isPlaceMessage:0,status:Ut,currentUser:t,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||a.cloudCustomData||"",needReadReceipt:l,receiverList:d,isSupportExtension:e.isSupportExtension||!1},(i=new Hi(n)).setElement(a._elements[0]),i.setNickAndAvatar(s),i.setNameCard(this._getNameCardByGroupID(a)),i.setRelayFlag(!0),i)):ai({code:ii.MSG_FORWARD_INVALID_ELEMENTS})}downloadMergerMessage(e){return this._mergerMessageHandler.downloadMergerMessage(e)}createFileMessage(e){if(x){if(!O&&!P&&!b)return;let e,t=H.getSystemInfoSync().SDKVersion;if(O&&Mt(t,e="2.5.0")<0)return void this.warn("WXChooseMessageFile");if(P&&Mt(t,e="1.18.0")<0)return void this.warn("QQChooseMessageFile")}if(K||b){if(we(e.payload.file)){let t=e.payload.file;e.payload.file={files:[t]}}else if(xe(e.payload.file)&&"undefined"!=typeof uni){let{tempFiles:t,files:s}=e.payload.file,i=null;Ve(t)?i=t[0]:Ve(s)&&(i=s[0]),e.payload.file={files:[i]}}}else if(O||P){let t=e.payload.file["tempFiles"],s={...t[0],url:t[0].path};e.payload.file={files:[s]}}else if(B){let t=e.payload["file"],s={...t,url:t.uri};e.payload.file={files:[s]}}let t=this.getMyUserID(),s=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new Hi(e)),i=new bi({uuid:this._generateUUID(e.payload.file),file:e.payload.file}),o=this._getNickAndAvatarByUserID(t);return s.setElement(i),s.setNickAndAvatar(o),s.setNameCard(this._getNameCardByGroupID(s)),this._messageOptionsMap.set(s.clientSequence,e),s}createLocationMessage(e){var t=this.getMyUserID(),s=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new Hi(e));e=new xi(e.payload),t=this._getNickAndAvatarByUserID(t);return s.setElement(e),s.setNickAndAvatar(t),s.setNameCard(this._getNameCardByGroupID(s)),s}_onNoModule(){return ai({code:ii.NO_MODULE})}sendMessageInstance(e,t){if(!1===this.get($s).filterMessage(e,t))return e.hasRiskContent=!0,this._onSendMessageFailed(e,new si({code:ii.PROFANITY_FOUND}));let s=null;if(e.conversationType===o.CONV_C2C)s=this.get(Ss);else{if(e.conversationType!==o.CONV_GROUP)return ai({code:ii.MSG_INVALID_CONV_TYPE});s=this.get(Ds)}if(!s)return this._onNoModule();let i,n=this._n+".sendMessageInstance",r=this.get(As),a=s.isOnlineMessage(e,t);return this.get(Gs).upload(e).then((()=>(this._getSendMessageSpecifiedKey(e)===gi&&this.get(Bs).addSuccessCount(mi),this._guardForGroup(e).then((()=>{if(!e.isSendable())return ai({code:ii.MSG_F_URL_IS_EMPTY});this._addSendMessageTotalCount(e),i=Date.now();var n=function(e){let t="utf-8";K&&document&&(t=document.charset.toLowerCase());let s,i,o=0;if(i=e.length,"utf-8"===t||"utf8"===t)for(let n=0;n<i;n++)(s=e.codePointAt(n))<=127?o+=1:s<=2047?o+=2:s<=65535?o+=3:(o+=4,n++);else if("utf-16"===t||"utf16"===t)for(let n=0;n<i;n++)(s=e.codePointAt(n))<=65535?o+=2:(o+=4,n++);else o=e.replace(/[^\x00-\xff]/g,"aa").length;return o}(JSON.stringify(e));return e.type===o.MSG_MERGER&&11264<n?this._mergerMessageHandler.uploadMergerMessage(e,n).then((s=>(s=this._mergerMessageHandler.createMergerMessagePack(e,t,s),this.req(s)))):(r.setMessageRandom(e),s.sendMessage(e,t))})).then((s=>{var{time:s,sequence:l,readReceiptCode:d,messageDropReason:c}=s.data;if(be(d)&&0!==d&&(new Ei("sendMessageWithReceipt").setMessage(`from:${e.from} to:${e.to} sequence:${l} readReceiptCode:`+d).end(),ye.w(n+` readReceiptCode:${d} message:`+this.getErrMsg(d))),c){let t=new Ei("messageDropReason"),s=`from:${e.from} to:${e.to} sequence:${l} messageDropReason:`+c;t.setMessage(s).end(),ye.w(n+" "+s)}if(this._addSendMessageSuccessCount(e,i),this._messageOptionsMap.delete(e.clientSequence),!0===e.isResend){let t=r.findMessage(e.ID);t&&(ye.l(n+" resend ok. ID:"+t.ID),r.deleteLocalMessage(t))}e.status=Gt,e.time=s;let _=!1;if(e.conversationType===o.CONV_GROUP)e.sequence=l;else if(e.conversationType===o.CONV_C2C){let t=r.getLatestMessageSentByMe(e.conversationID);if(t){let{nick:s,avatar:i}=t;s===e.nick&&i===e.avatar||(_=!0)}}if(_&&r.modifyMessageSentByMe({conversationID:e.conversationID,latestNick:e.nick,latestAvatar:e.avatar}),!0===a)e._onlineOnlyFlag=!0;else{r.appendToMessageList(e);let s=e,i=(xe(t)&&xe(t.messageControlInfo)&&(!0===t.messageControlInfo.excludedFromLastMessage&&(e._isExcludedFromLastMessage=!0,s=""),!0===t.messageControlInfo.excludedFromUnreadCount)&&(e._isExcludedFromUnreadCount=!0),e.conversationType);dt(e.to)&&(i=o.CONV_TOPIC,this.get(Ls).onMessageSent({groupID:Et(e.to),topicID:e.to,lastMessage:s})),r.onMessageSent({conversationOptionsList:[{conversationID:e.conversationID,unreadCount:0,type:i,subType:e.conversationSubType,lastMessage:s}]})}return e._relayFlag||"TIMImageElem"!==e.type||It(e.payload.imageInfoArray),ti({message:e})}))))).catch((t=>this._onSendMessageFailed(e,t,a)))}_guardForGroup(e){if(e.conversationType!==o.CONV_GROUP)return Promise.resolve();var t=this.get(Ds);if(!t)return this._onNoModule();if(lt({groupID:e.to})){let s=t.getLocalGroupProfile(e.to);if(s&&s.isSupportTopic)return ai({code:ii.MSG_SEND_GRP_WITH_TOPIC_FAIL})}return t.guardForAVChatRoom(e)}_onSendMessageFailed(e,t,s=!1){var i=this._n+"._onSendMessageFailed",o=(e.status=kt,80001!==t.code&&80004!==t.code||(e.hasRiskContent=!0),this.get(As)),n=(o.deleteMessageRandom(e),10100<=t.code&&t.code<=10200||120001<=t.code&&t.code<=13e4);s||n||!0===o.appendToMessageList(e)&&ye.l(i+" message stored, ID:"+e.ID),this._addSendMessageFailCountOnUser(e,t),s=new Ei("sendMessage");let r=`head.seq:${t.data.headSeq} type:${e.type} from:${e.from} to:`+e.to;if(K){if("connection"in navigator){let e=navigator.connection;r+=` downlink:${e.downlink} effectiveType:${e.effectiveType} rtt:`+e.rtt}if("memory"in window.performance){let e=window.performance.memory;r+=` usedJSHeapSize:${e.usedJSHeapSize} totalJSHeapSize:${e.totalJSHeapSize} jsHeapSizeLimit:`+e.jsHeapSizeLimit}}return s.setMessage(r).setError(t).end(),ye.e(i+` ${r} error:`,t),ai(new si({code:t&&t.code?t.code:ii.MSG_SEND_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}}))}_getSendMessageSpecifiedKey(e){if([o.MSG_IMAGE,o.MSG_AUDIO,o.MSG_VIDEO,o.MSG_FILE].includes(e.type))return gi;if(e.conversationType===o.CONV_C2C)return ui;if(e.conversationType===o.CONV_GROUP){let t=this.get(Ds);if(t){e=t.getLocalGroupProfile(e.to);if(e)return e=e.type,at(e)?pi:hi}}}_addSendMessageTotalCount(e){e=this._getSendMessageSpecifiedKey(e),e&&this.get(Bs).addTotalCount(e)}_addSendMessageSuccessCount(e,t){var s=this._getSendMessageSpecifiedKey(e);if(s){let e=this.get(Bs);e.addSuccessCount(s),e.addCost(s,At(t,!1))}}_addSendMessageFailCountOnUser(e,t){var{code:t=-1}=t,s=this.get(Bs);e=this._getSendMessageSpecifiedKey(e);e===gi&&function(e){let t=!1;return!!$o.includes(e)||t}(t)?s.addFailedCountOfUserSide(mi):Wo(t)&&e&&s.addFailedCountOfUserSide(e)}resendMessage(e,t){return e.isResend=!0,e.status=Ut,this.sendMessageInstance(e,t)}revokeMessage(e){let t=null;if(e.conversationType===o.CONV_C2C?t=this.get(Ss):e.conversationType===o.CONV_GROUP&&(t=this.get(Ds)),!t)return this._onNoModule();let s=new Ei("revokeMessage"),i=(s.setMessage(`type:${e.type} from:${e.from} to:`+e.to),this._n+".revokeMessage");return t.revokeMessage(e).then((t=>{var o=t.data.recallRetList;if(Ue(o)||0===o[0].retCode)return ye.i(i+" ok. ID:"+e.ID),e.isRevoked=!0,s.end(),this.get(As).onMessageRevoked([e]),ti({message:e});{let t=new si({code:o[0].retCode,data:{message:e}});return s.setCode(t.code).setMoreMessage(t.message).end(),ai(t)}})).catch((t=>{s.setError(t).end();var o=new si({code:t&&t.code?t.code:ii.MSG_REVOKE_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}});return ye.w(i+" failed. error:",t),ai(o)}))}deleteMessage(e){let t=null,s=e[0],i=s.conversationID,n="",r=[],a=[];if(s.conversationType===o.CONV_C2C)t=this.get(Ss),n=i.replace(o.CONV_C2C,""),e.forEach((e=>{e&&e.status===Gt&&e.conversationID===i&&(e._onlineOnlyFlag||r.push(`${e.sequence}_${e.random}_`+e.time),a.push(e))}));else if(s.conversationType===o.CONV_GROUP)t=this.get(Ds),n=i.replace(o.CONV_GROUP,""),e.forEach((e=>{e&&e.status===Gt&&e.conversationID===i&&(e._onlineOnlyFlag||r.push(""+e.sequence),a.push(e))}));else if(s.conversationType===o.CONV_SYSTEM)return ai({code:ii.CANNOT_DELETE_GRP_SYSTEM_NOTICE});if(!t)return this._onNoModule();if(0===r.length)return this._onMessageDeleted(a);30<r.length&&(r=r.slice(0,30),a=a.slice(0,30));let l=new Ei("deleteMessage"),d=(l.setMessage(`to:${n} count:`+r.length),this._n+".deleteMessage");return t.deleteMessage({to:n,keyList:r}).then((e=>(l.end(),ye.i(d+" ok"),this._onMessageDeleted(a)))).catch((e=>(l.setError(e).end(),ye.w(d+" failed. error:",e),e=new si({code:e&&e.code?e.code:ii.MSG_DELETE_FAIL,message:e&&e.message?e.message:void 0}),ai(e))))}_onMessageDeleted(e){return this.get(As).onMessageDeleted(e),ri({messageList:e})}translateText(e){let t=this._n+".translateText",{sourceTextList:s,sourceLanguage:i,targetLanguage:o}=e,n=new Ei("translateText");return n.setMessage(`sourceLanguage:${i} targetLanguage:`+o),this.req({P:di.TRANSLATE_TEXT,data:{sourceTextList:s,source:i||"auto",target:o,from:this.getMyTinyID(),SDKAppID:this.getSDKAppID()}}).then((e=>{var{error:e,requestID:s,translatedTextList:i}=e.data,o=e["code"];if(0===o)return n.end(),ye.i(t+" ok. requestID:"+s),ti({translatedTextList:i});throw{...e,requestID:s}})).catch((e=>(n.setCode(e.code).setMoreMessage(e.requestID).end(),ye.w(t+" failed. error:",e),ai({code:ii.TRANSLATE_TEXT_FAIL}))))}convertVoiceToText(e){var{message:e,language:t}=e;let s=e.payload.url;if(e.from===this.getMyUserID()&&"out"===e.flow&&(s=e.payload.remoteAudioUrl),e=/\.(wav|pcm|ogg-opus|speex|silk|mp3|m4a|aac|amr)/,!e.test(s))return ai({code:ii.UNSUPPORTED_VOICE_FORMAT});e=e.exec(s)[1]||"mp3";let i="16k_zh-PY",o=(t?"zh (cmn-Hans-CN)"===t?i="16k_zh":"en-US"===t?i="16k_en":"yue-Hant-HK"===t?i="16k_yue":"ja-JP"===t&&(i="16k_ja"):i="16k_zh-PY",`serviceType:${i} url:`+s),n=this._n+".convertVoiceToText",r=(ye.i(n+" "+o),new Ei("convertVoiceToText"));return r.setMessage(o),this.req({P:di.VOICE_TO_TEXT,data:{url:s,language:i,SDKAppID:this.getSDKAppID(),format:e}}).then((e=>{var{error:e,requestID:t,result:s}=e.data,i=e["code"];if(0===i)return r.end(),ye.i(n+" ok. requestID:"+t),ti({result:s});throw{...e,requestID:t}})).catch((e=>(r.setCode(e.code).setMoreMessage(e.requestID||"").end(),ye.w(n+" failed. error:",e),ai({code:ii.VOICE_TO_TEXT_FAIL}))))}modifyRemoteMessage(e){if(!1===this.get($s).filterMessage(e))return e.hasRiskContent=!0,ai({code:ii.PROFANITY_FOUND,data:{message:e}});let t=null;var{conversationType:s,to:i}=e;if(s===o.CONV_C2C)t=this.get(Ss);else if(s===o.CONV_GROUP){if(!(t=this.get(Ds)))return this._onNoModule();if(t.isMessageFromOrToAVChatroom(i))return ai({code:ii.MSG_MODIFY_DISABLED_IN_AV,data:{message:e}})}let n=new Ei("modifyMessage"),r=(n.setMessage("to:"+i),this._n+".modifyRemoteMessage");return t.modifyRemoteMessage(e).then((t=>(n.end(),ye.i(r+" ok"),t=this._onModifyRemoteMessageResp(e,t.data),ti({message:t})))).catch((t=>{var s;return n.setCode(t.code).setMoreMessage(t.message).end(),ye.w(r+" failed. error:",t),20027===t.code?(s=this._onModifyRemoteMessageResp(e,t.data),ai({code:ii.MSG_MODIFY_CONFLICT,data:{message:s}})):ai({code:t.code,message:t.message,data:{message:e}})}))}_onModifyRemoteMessageResp(e,t){ye.d(this._n+"._onModifyRemoteMessageResp options:",t);var{conversationType:e,from:s,to:i,random:o,sequence:n,time:r}=e,{elements:t,messageVersion:a,cloudCustomData:l=""}=t;return this.get(As).onMessageModified({conversationType:e,from:s,to:i,time:r,random:o,sequence:n,elements:t,cloudCustomData:l,messageVersion:a})}_generateUUID(e){var t=this.get(Os);let s=`${t.getSDKAppID()}-${t.getUserID()}-`+function(){let e="";for(let t=32;0<t;--t)e+=Qe[Math.floor(Math.random()*et)];return e}();return t=e.name||e.value||e.url||e.tempFilePath,e=t&&t.slice(t.lastIndexOf(".")+1),e?s+"."+e:s}getMessageOption(e){return this._messageOptionsMap.get(e)}_getNickAndAvatarByUserID(e){return this.get(Es).getNickAndAvatarByUserID(e)}_getNameCardByGroupID(e){if(e.conversationType===o.CONV_GROUP){let t=this.get(Ds);if(t)return t.getMyNameCardByGroupID(e.to)}return""}reset(){ye.l(this._n+".reset"),this._messageOptionsMap.clear()}}class zo extends li{constructor(e){super(e),this._n="MsgExtModule",this.msgExtMap=new Map,this.globalSeqMap=new Map,this.getMsgExtsMap=new Map}onMsgExtNotify(e){let{messageInfo:t,operateType:s,operateResultList:o,tinyID:n,globalSequence:r}=e.dataList,{clientTime:a,random:l}=t,d=n+`-${a}-`+l,c=[],_=[],u=(ye.l(`${this._n}.onMsgExtNotify messageID:${d} operateType:${s} globalSequence:`+r),this._updateGlobalSeq(d,r),!1),h=!1;o.forEach((e=>{let{extensions:t=[],clearSequence:i}=e;1===s?(u=!0,t.forEach((e=>{c.push({key:e.key,value:e.value})})),this._updateLocalExt(d,t)):2===s?(h=!0,t.forEach((e=>{_.push(e.key)})),this._updateLocalExt(d,t)):3===s&&(h=!0,this._hasLocalExt(d)&&this._getLocalExt(d).forEach(((e,t)=>{e.seq<=i&&!Ue(e.value)&&_.push(t)})),this._clearLocalExt(d,i))})),u&&this.emitOEvt(i.MESSAGE_EXTENSIONS_UPDATED,{messageID:d,extensions:c}),h&&this.emitOEvt(i.MESSAGE_EXTENSIONS_DELETED,{messageID:d,keyList:_})}setMessageExtensions(e,t){var s="setMessageExtensions";if(!this.canIUse(y.MSG_EXT))return this.noUse(s);let i=this._n+"."+s,{ID:o,conversationID:n,sequence:r,time:a}=e,l=[...t],d=(20<t.length&&(l=t.slice(0,20),ye.w(i+". the length of extensions cannot exceed 20.")),`convID:${n} messageID:${o} sequence:${r} time:${a} count:`+l.length),c=new Ei(s);return c.setMessage(d),ye.l(i+" "+d),this._modifyMsgExts(e,l).then((e=>{var{resultList:e,successCount:t,failureCount:s}=e,t=`successCount:${t} failCount:`+s;return c.setMoreMessage(t).end(),ye.l(i+" ok. "+t),ti({extensions:e})})).catch((e=>(c.setError(e).end(),ye.e(i+" failed. error:",e),ai(e))))}getMessageExtensions(e){var t="getMessageExtensions";if(!this.canIUse(y.MSG_EXT))return this.noUse(t);let s=this._n+"."+t,{ID:i,conversationID:o,sequence:n,time:r}=e,a=`convID:${o} messageID:${i} sequence:${n} time:`+r,l=new Ei(t),d=(l.setMessage(a),void ye.l(s+" "+a));return this.getMsgExtsMap.has(i)&&(d=this._getGlobalSeq(i)),this._getMsgExts(e,d).then((e=>(l.end(),ye.l(s+" ok. extCount:"+e.length),Be(d)&&0<e.length&&this.getMsgExtsMap.set(i,1),ti({extensions:e})))).catch((e=>(l.setError(e).end(),ye.e(s+" failed. error:",e),ai(e))))}deleteMessageExtensions(e,t){var s="deleteMessageExtensions";if(!this.canIUse(y.MSG_EXT))return this.noUse(s);let i=this._n+"."+s,o=[],n=3,{ID:r,conversationID:a,sequence:l,time:d}=(Ue(t)||(n=2,t.forEach((e=>{o.push({key:e,value:"",seq:0})}))),e),c=`convID:${a} messageID:${r} sequence:${l} time:${d} operateType:`+n,_=new Ei(s);return _.setMessage(c),ye.l(i+" "+c),this._modifyMsgExts(e,o,n).then((e=>{var{resultList:e,successCount:t,failureCount:s}=e;let o="";return 2===n&&(o=`success count:${t} fail count:`+s),_.setMoreMessage(""+o).end(),ye.l(i+" ok. "+o),ti({extensions:e})})).catch((e=>(_.setError(e).end(),ye.e(i+" failed. error:",e),ai(e))))}_modifyMsgExts(e,t,s=1){var i=dt(e.to)?o.CONV_TOPIC:e.conversationType;let n,r=(3!==s&&(n=this._getReqExts(e,t)),null);switch(i){case o.CONV_C2C:r=this.get(Ss);break;case o.CONV_GROUP:r=this.get(Ds);break;case o.CONV_TOPIC:r=this.get(Ls);break;default:return ai({code:ii.NO_MODULE})}return r.modifyMsgExts(e,n,s).then((t=>{var{extensions:t,seq:s}=t.data;let i=[],o=0,n=0,r=[];return(t=Ue(t)?[]:t).forEach((e=>{var{errorCode:e,extension:t}=e,{key:t,value:s,seq:a}=t;i.push({code:e,key:t,value:s}),0===e?o++:n++,r.push({key:t,value:s,seq:a})})),this._updateGlobalSeq(e.ID,s),0<r.length&&(this._updateLocalExt(e.ID,r),r=null),{resultList:i,successCount:o,failureCount:n}})).catch((e=>ai(e)))}_getReqExts(e,t){let s=[];if(this._hasLocalExt(e.ID)){let i=this._getLocalExt(e.ID);t.forEach((e=>{var{key:e,value:t}=e;let o=0;i.has(e)&&(o=i.get(e).seq),s.push({key:e,value:t,seq:o})}))}else t.forEach((e=>{var{key:e,value:t}=e;s.push({key:e,value:t,seq:0})}));return s}_getMsgExts(e,t){let s=this._n+"._getMsgExts",{ID:i,to:n}=e,r=null;switch(dt(n)?o.CONV_TOPIC:e.conversationType){case o.CONV_C2C:r=this.get(Ss);break;case o.CONV_GROUP:r=this.get(Ds);break;case o.CONV_TOPIC:r=this.get(Ls);break;default:return ai({code:ii.NO_MODULE})}return r.getMessageExtensions(e,t).then((t=>{var{extensions:o,completeFlag:t,globalSequence:n,clearSequence:r}=t.data,o=Ue(o)?[]:o;if(ye.l(s+` ok. completeFlag:${t} globalSequence:${n} clearSequence:${r} count:`+o.length),this._updateLocalExt(i,o),this._clearLocalExt(i,r),this._updateGlobalSeq(i,n),1===t)return this._getLocalExtList(i);{let t=o.slice(-1)[0].seq+1;return this._getMsgExts(e,t)}})).catch((e=>ai(e)))}_hasLocalExt(e){return this.msgExtMap.has(e)}_getLocalExt(e){return this.msgExtMap.get(e)}_updateLocalExt(e,t){this._hasLocalExt(e)||this.msgExtMap.set(e,new Map);let s=this._getLocalExt(e);t.forEach((e=>{var{key:e,value:t="",seq:i}=e;s.set(e,{value:t,seq:i})}))}_clearLocalExt(e,t){if(!(t<=0)&&this._hasLocalExt(e)){let s=this._getLocalExt(e);s.forEach(((e,i)=>{e.seq<=t&&s.delete(i)}))}}_getLocalExtList(e){let t=[];return this._hasLocalExt(e)&&this._getLocalExt(e).forEach(((e,s)=>{e=e.value,Ue(e)||t.push({key:s,value:e})})),t}_getGlobalSeq(e){return this.globalSeqMap.get(e)}_updateGlobalSeq(e,t){this.globalSeqMap.set(e,t)}reset(){ye.l(this._n+".reset"),this.msgExtMap.clear(),this.globalSeqMap.clear(),this.getMsgExtsMap.clear()}}class jo extends li{constructor(e){super(e),this._n="MsgReactionModule",this._reactedByMyselfMap=new Map,this._reactionInfoMap=new Map}onReactionNotifyList(e){var{dataList:e=[]}=e||{};e.forEach((e=>{let{C2CMessageInfo:t={},groupMessageInfo:s={},reactionList:o=[]}=e,{tinyID:n,clientTime:r,random:a}={...t,...s},l=n+`-${r}-`+a,d=[];o.forEach((e=>{Be(e.userIDList)&&(e.userIDList=[],e.count=0),d.push(...e.userIDList)})),ye.l(this._n+`.onReactionNotifyList messageID:${l} reactionList:`+o.length),this._handleReactionSummary([{messageID:l,reactionList:o}],d).then((e=>{this.emitOEvt(i.MESSAGE_REACTIONS_UPDATED,{...e[0]})}))}))}onReactionNotify(e){var{C2CMessageInfo:e={},groupMessageInfo:t={},reactionID:s,operateType:o}=e.dataList||{},{tinyID:e,clientTime:t,random:n}={...e,...t},t=e+`-${t}-`+n,n=(ye.l(this._n+`.onReactionNotify messageID:${t} reactionID:${s} operateType:`+o),1===o?this._addReactedByMyselfMap(t,s):this._removeReactedByMyselfMap(t,s),t+"-"+s);if(this._reactionInfoMap.has(n)){let e=this._reactionInfoMap.get(n);e.reactedByMyself=1===o,this.emitOEvt(i.MESSAGE_REACTIONS_UPDATED,{messageID:t,reactionList:[e]})}}addMessageReaction(e,t){var s="addMessageReaction";if(!this.canIUse(y.MSG_REACTION))return this.noUse(s);let i=this._n+"."+s,{ID:o,conversationID:n}=e,r=`convID:${n} messageID:${o} reactionID:`+t,a=new Ei(s);return a.setMessage(r),ye.l(i+" "+r),s=this._createReactionOperationPack(e,t,1),this._addReactedByMyselfMap(e.ID,t),this.req(s).then((()=>(a.end(),ye.l(i+" ok."),ti()))).catch((s=>(this._removeReactedByMyselfMap(e.ID,t),a.setError(s).end(),ye.e(i+" failed. error:",s),ai(s))))}removeMessageReaction(e,t){var s="removeMessageReaction";if(!this.canIUse(y.MSG_REACTION))return this.noUse(s);let i=this._n+"."+s,{ID:o,conversationID:n}=e,r=`convID:${n} messageID:${o} reactionID:`+t,a=new Ei(s);return a.setMessage(r),ye.l(i+" "+r),s=this._createReactionOperationPack(e,t,2),this._removeReactedByMyselfMap(e.ID,t),this.req(s).then((()=>(a.end(),ye.l(i+" ok."),ti()))).catch((e=>(a.setError(e).end(),ye.e(i+" failed. error:",e),ai(e))))}getMessageReactions(e){var t="getMessageReactions";if(!this.canIUse(y.MSG_REACTION))return this.noUse(t);let s=this._n+"."+t,{messageList:i,maxUserCountPerReaction:o}=e,n=i[0]["conversationID"],r=`convID:${n} maxUserCountPerReaction:${o} msgCount:`+i.length,a=new Ei(t),l=(a.setMessage(r),ye.l(s+" "+r),new Map),d=this._createReactionSummaryPack({...e,messageIDMap:l});return this.req(d).then((e=>{let{resultList:t=[]}=e.data,s=[],i=[];return t.forEach((e=>{var{messageKey:e,messageSequence:t,reactionList:o=[]}=e,t=Be(e)?l.get(t):l.get(e);s.push({messageID:t,reactionList:o}),o.forEach((e=>{i.push(...e.userIDList)}))})),this._handleReactionSummary(s,i)})).then((e=>(a.end(),ye.l(s+" ok."),l.clear(),ti({resultList:e})))).catch((e=>(a.setError(e).end(),ye.e(s+" failed. error:",e),ai(e))))}getAllUserListOfMessageReaction(e){var t="getAllUserListOfMessageReaction";if(!this.canIUse(y.MSG_REACTION))return this.noUse(t);let s=this._n+"."+t,{message:i,reactionID:o,nextSeq:n,count:r}=e,{ID:a,conversationID:l}=i,d=`convID:${l} messageID:${a} reactionID:${o} nextSeq:${n} count:`+r,c=new Ei(t),_=(c.setMessage(d),ye.l(s+" "+d),{userList:[],nextSeq:0,isCompleted:!1}),u=this._createReactionUserListPack(e);return this.req(u).then((e=>{var{userIDList:e=[],nextSeq:t=0}=e.data;return _.nextSeq=t,_.isCompleted=0===t,this.get(Es).getUserNickAndAvatar(e)})).then((e=>(_.userList=e,c.end(),ye.l(s+" ok."),ti(_)))).catch((e=>(c.setError(e).end(),ye.e(s+" failed. error:",e),ai(e))))}_createReactionOperationPack(e,t,s){let i;if(t={reactionID:t,userIDList:[this.getMyUserID()]},e.conversationType===o.CONV_C2C){let o=this.get(Ss);i=1===s?di.ADD_C2C_MSG_REACTION:di.RM_C2C_MSG_REACTION,t.from=e.from,t.to=e.to,t.messageKey=o.getMessageKey(e)}if(e.conversationType===o.CONV_GROUP){let o,n=e.to;dt(e.to)&&(o=e.to,n=Et(o)),i=1===s?di.ADD_GRP_MSG_REACTION:di.RM_GRP_MSG_REACTION,t.groupID=n,t.topicID=o,t.messageSequence=e.sequence}return{P:i,data:t}}_createReactionSummaryPack(e){let t,s,{messageList:i,maxUserCountPerReaction:n=10,messageIDMap:r}=e,a=i[0];if(a.conversationType===o.CONV_C2C){let e=this.get(Ss),o=i.map((t=>{var s=e.getMessageKey(t);return r.set(s,t.ID),s}));t=di.GET_C2C_MSG_REACTIONS,s={from:a.from,to:a.to,messageKeyList:o,count:n}}if(a.conversationType===o.CONV_GROUP){let o,l=a.to;dt(a.to)&&(o=a.to,l=Et(o)),e=i.map((e=>(r.set(e.sequence,e.ID),e.sequence))),t=di.GET_GRP_MSG_REACTIONS,s={groupID:l,topicID:o,messageSequenceList:e,count:n}}return{P:t,data:s}}_createReactionUserListPack(e){var{message:t,reactionID:e,nextSeq:s=0,count:i=100}=e;let n;if(s={reactionID:e,nextSeq:s,count:100<i?100:i},t.conversationType===o.CONV_C2C){let e=this.get(Ss);n=di.GET_C2C_MSG_REACTION_USER_LIST,s.from=t.from,s.to=t.to,s.messageKey=e.getMessageKey(t)}if(t.conversationType===o.CONV_GROUP){let e,i=t.to;dt(t.to)&&(e=t.to,i=Et(e)),n=di.GET_GRP_MSG_REACTION_USER_LIST,s.groupID=i,s.topicID=e,s.messageSequence=t.sequence}return{P:n,data:s}}_handleReactionSummary(e,t){return this.get(Es).getUserNickAndAvatar(t).then((t=>{let s=[];return e.forEach((e=>{let i=[];e.reactionList.forEach((s=>{let{reactionID:o,count:n,userIDList:r,reactedByMyself:a}=s,l=[];if(r.forEach((e=>{t.forEach((t=>{e===t.userID&&l.push(t)}))})),s={reactionID:o,totalUserCount:n,partialUserList:l,reactedByMyself:this._computeReactedByMyself({reactedByMyself:a,messageID:e.messageID,reactionID:o})},i.push(s),Be(a)&&!this._reactedByMyselfMap.has(e.messageID)){let t=e.messageID+"-"+o;this._reactionInfoMap.set(t,s)}})),s.push({messageID:e.messageID,reactionList:i})})),s}))}_addReactedByMyselfMap(e,t){this._reactedByMyselfMap.has(e)||this._reactedByMyselfMap.set(e,[]),e=this._reactedByMyselfMap.get(e),-1===e.indexOf(t)&&e.push(t)}_removeReactedByMyselfMap(e,t){this._reactedByMyselfMap.has(e)&&-1<(t=(e=this._reactedByMyselfMap.get(e)).indexOf(t))&&e.splice(t,1)}_computeReactedByMyself({reactedByMyself:e,messageID:t,reactionID:s}){return Be(e)?!!this._reactedByMyselfMap.has(t)&&this._reactedByMyselfMap.get(t).includes(s):1===e}reset(){ye.l(this._n+".reset"),this._reactedByMyselfMap.clear(),this._reactionInfoMap.clear()}}class Jo extends li{constructor(e){super(e),this._n="ComboMsgModule"}sendMessage(e){let t=this._createMsg(e);if(null===t)return ai({code:ii.MSG_SEND_FAIL});this._addSendMessageTotalCount(t);let s=Date.now();return this.get(As).setMessageRandom(t),this._sendComboMessage(t,e).then((e=>{var{time:e,sequence:i,readReceiptCode:n}=e.data,n=(be(n)&&0!==n&&(new Ei("sendMessageWithReceipt").setMessage(`from:${t.from} to:${t.to} sequence:${i} readReceiptCode:`+n).end(),ye.w(this._n+`.sendMessage readReceiptCode:${n} message:`+this.getErrMsg(n))),this._addSendMessageSuccessCount(t,s),this.get(As));t.status=Gt,t.time=e,t.conversationType===o.CONV_GROUP&&(t.sequence=i),n.appendToMessageList(t);let r=t;return!0===t._isExcludedFromLastMessage&&(r=""),n.onMessageSent({conversationOptionsList:[{conversationID:t.conversationID,unreadCount:0,type:t.conversationType,subType:t.conversationSubType,lastMessage:r}]}),ti({message:t})})).catch((e=>this._onSendMessageFailed(t,e)))}_sendComboMessage(e,t){var s=this._m.get(bs);let i="";return e.conversationType===o.CONV_C2C&&(i=T.NAME.OPEN_IM+"."+di.SEND_C2C_MSG),e.conversationType===o.CONV_GROUP&&(i=T.NAME.GRP+"."+di.SEND_GRP_MSG),s.sendComboMessage({servcmd:i,data:t})}_createMsg(e){var t=this._n+"._createMsg";let s=null;try{var i=this.getMyUserID(),n={};if(n.senderTinyID=this.getMyTinyID(),n.currentUser=i,n.from=e.From_Account||i,e.GroupId?(n.conversationID=""+o.CONV_GROUP+e.GroupId,n.conversationType=o.CONV_GROUP,n.to=e.GroupId):e.To_Account&&(n.conversationID=""+o.CONV_C2C+e.To_Account,n.conversationType=o.CONV_C2C,n.to=e.To_Account),n.time=e.MsgTimeStamp||0,n.random=e.Random||e.MsgRandom||0,n.priority=e.MsgPriority,Fe(e.CloudCustomData)&&0<e.CloudCustomData.length&&(n.cloudCustomData=e.CloudCustomData),Ve(e.SendMsgControl)&&(n.messageControlInfo={},e.SendMsgControl.includes("NoUnread")&&(n.messageControlInfo.excludedFromUnreadCount=1),e.SendMsgControl.includes("NoLastMsg"))&&(n.messageControlInfo.excludedFromLastMessage=1),n.conversationType===o.CONV_GROUP&&Ve(e.To_Account)&&0<e.To_Account.length){let s=e.To_Account;50<e.To_Account.length&&(s=e.To_Account.slice(0,50),ye.w(t+" To_Account must be less than or equal to 50.")),n.receiverList=[...s],e.To_Account=[...s]}1!==e.IsNeedReadReceipt&&1!==e.NeedReadReceipt||(n.needReadReceipt=!0),1===e.SupportMessageExtension&&(n.isSupportExtension=!0),(s=new Hi(n)).status=Ut,e.MsgClientTime=s.clientTime,s.conversationType===o.CONV_C2C&&(e.MsgSeq=s.sequence);var r,a=e.MsgBody.length;for(let t=0;t<a;t++)"TIMTextElem"===(r=e.MsgBody[t]).MsgType?s.setTextElement(r.MsgContent.Text):"TIMCustomElem"===r.MsgType?s.setCustomElement({data:r.MsgContent.Data||"",description:r.MsgContent.Desc||"",extension:r.MsgContent.Ext||""}):"TIMFaceElem"===r.MsgType&&s.setFaceElement({index:r.MsgContent.Index,data:r.MsgContent.Data});var l=s.getElements();s.payload=l[0].content,s.type=l[0].type}catch(i){s=null,ye.e(t+" failed. error:",i)}return s}_onSendMessageFailed(e,t){e.status=kt,this.get(As).deleteMessageRandom(e),this._addSendMessageFailCountOnUser(e,t);var s=new Ei("sendMessage"),i=`head.seq:${t.data.headSeq} type:${e.type} from:${e.from} to:`+e.to;return s.setMessage(i).setError(t).end(),ye.e(this._n+`._onSendMessageFailed ${i} error:`,t),ai(new si({code:t&&t.code?t.code:ii.MSG_SEND_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}}))}_getSendMessageSpecifiedKey(e){if(e.conversationType===o.CONV_C2C)return ui;if(e.conversationType===o.CONV_GROUP){let t=this.get(Ds).getLocalGroupProfile(e.to);if(t)return e=t.type,at(e)?pi:hi}}_addSendMessageTotalCount(e){e=this._getSendMessageSpecifiedKey(e),e&&this.get(Bs).addTotalCount(e)}_addSendMessageSuccessCount(e,t){var s=this._getSendMessageSpecifiedKey(e);if(s){let e=this.get(Bs);e.addSuccessCount(s),e.addCost(s,At(t,!1))}}_addSendMessageFailCountOnUser(e,t){var{code:t=-1}=t,s=this.get(Bs);e=this._getSendMessageSpecifiedKey(e);Wo(t)&&e&&s.addFailedCountOfUserSide(e)}}class Xo extends li{constructor(e){super(e),this._n="PluginModule",this.plugins={}}registerPlugin(e){let t="0";Object.keys(e).forEach((s=>{this.plugins[s]=e[s],"tim-upload-plugin"===s&&"function"==typeof e[s].getVersion&&(t=e[s].getVersion())})),new Ei("registerPlugin").setMessage(""+Object.keys(e)).setMoreMessage("version:"+t).end()}getPlugin(e){return this.plugins[e]}reset(){}}class Zo extends li{constructor(e){super(e),this._n="SyncUnreadMsgModule",this._cookie="",this._onlineSyncFlag=!1,this.getIEmitInst().on(Ji.A2KEY_AND_TINYID_UPDATED,this._init,this)}_init(){this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}_startSync(e){let{cookie:t,syncFlag:s,isOnlineSync:i}=e,o=this._n+"._startSync",n=(ye.l(o+" options:",e),new Ei("syncUnread"));n.setMessage(JSON.stringify(e)),this.req({P:di.SYNC_UNREAD_MSG,data:{cookie:t,syncFlag:s,isOnlineSync:i}}).then((e=>{var{cookie:t,syncFlag:s}=e.data,i=`$cookie:${t} syncFlag:`+s;ye.l(o+" ok. "+i),this._cookie=t,n.setMoreMessage(i).end(),Ue(t)||(0===s||1===s?(this._dispatch({...e.data,isSyncingEnded:!1}),this._startSync({cookie:t,syncFlag:s,isOnlineSync:0})):2===s&&this._dispatch({...e.data,isSyncingEnded:!0}))})).catch((e=>{n.setError(e).end(),ye.e(o+" failed. error:",e)}))}_dispatch(e){e.eventArray&&this.get(bs).onMessage({head:{},body:{eventArray:e.eventArray,isInstantMessage:this._onlineSyncFlag,isSyncingEnded:e.isSyncingEnded}}),this.get(Ss).onNewMessage({dataList:e.messageList,isInstantMessage:!!e.isSyncingEnded&&this._onlineSyncFlag,C2CRemainingUnreadList:e.C2CRemainingUnreadList,C2CPairUnreadList:e.C2CPairUnreadList,isSyncingEnded:e.isSyncingEnded})}syncOnNeed(){ye.l(this._n+".syncOnNeed cookie:"+this._cookie),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}syncOnReconnected(){ye.l(this._n+".syncOnReconnected cookie:"+this._cookie),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}reset(){ye.l(this._n+".reset"),this._onlineSyncFlag=!1,this._cookie=""}}let Qo={req:{toAccount:"To_Account",fromAccount:"From_Account",to:"To_Account",from:"From_Account",groupID:"GroupId",groupAtUserID:"GroupAt_Account",extension:"Ext",data:"Data",description:"Desc",elements:"MsgBody",sizeType:"Type",downloadFlag:"Download_Flag",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",videoUrl:"",imageUrl:"URL",fileUrl:"Url",uuid:"UUID",priority:"MsgPriority",receiverUserID:"To_Account",receiverGroupID:"GroupId",messageSender:"SenderId",messageReceiver:"ReceiverId",nick:"From_AccountNick",avatar:"From_AccountHeadurl",messageNumber:"MsgNum",pbDownloadKey:"PbMsgKey",downloadKey:"JsonMsgKey",applicationType:"PendencyType",userIDList:"To_Account",groupNameList:"GroupName",userID:"To_Account",groupAttributeList:"GroupAttr",mainSequence:"AttrMainSeq",avChatRoomKey:"BytesKey",attributeControl:"AttrControl",sequence:"seq",messageControlInfo:"SendMsgControl",updateSequence:"UpdateSeq",clientTime:"MsgClientTime",sequenceList:"MsgSeqList",topicID:"TopicId",customData:"CustomString",isSupportTopic:"SupportTopic",isWebUniapp:"is_web_uniapp",isSupportExtension:"SupportMessageExtension",messageSequence:"MsgSeq",messageKey:"MsgKey",startSequence:"startSeq",simplifiedMessage:"DownsizeFlag",isRelayMessage:"IsRelayMsg",reactionID:"Reaction",messageSequenceList:"MsgSeqList",messageKeyList:"MsgKeyList",cmConfigID:"CustomModerationConfigID"},res:{MsgPriority:"priority",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",Download_Flag:"downloadFlag",GroupId:"groupID",Member_Account:"userID",MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",MsgSeq:"sequence",MsgRandom:"random",MsgTime:"time",MsgTimeStamp:"time",MsgContent:"content",MsgBody:"elements",From_AccountNick:"nick",From_AccountHeadurl:"avatar",GroupWithdrawInfoArray:"revokedInfos",GroupReadInfoArray:"groupMessageReadNotice",LastReadMsgSeq:"lastMessageSeq",WithdrawC2cMsgNotify:"c2cMessageRevokedNotify",C2cWithdrawInfoArray:"revokedInfos",C2cReadedReceipt:"c2cMessageReadReceipt",ReadC2cMsgNotify:"c2cMessageReadNotice",LastReadTime:"peerReadTime",MsgRand:"random",MsgType:"type",MsgShow:"messageShow",NextMsgSeq:"nextMessageSeq",FaceUrl:"avatar",ProfileDataMod:"profileModify",Profile_Account:"userID",ValueBytes:"value",ValueNum:"value",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgFrom_AccountExtraInfo:"messageFromAccountExtraInformation",Operator_Account:"operatorID",OpType:"operationType",ReportType:"operationType",UserId:"userID",User_Account:"userID",List_Account:"userIDList",MsgOperatorMemberExtraInfo:"operatorInfo",MsgMemberExtraInfo:"memberInfoList",ImageUrl:"avatar",NickName:"nick",MsgGroupNewInfo:"newGroupProfile",MsgAppDefinedData:"groupCustomField",Owner_Account:"ownerID",GroupFaceUrl:"avatar",GroupIntroduction:"introduction",GroupNotification:"notification",GroupApplyJoinOption:"joinOption",MsgKey:"messageKey",GroupInfo:"groupProfile",ShutupTime:"muteTime",Desc:"description",Ext:"extension",GroupAt_Account:"groupAtUserID",MsgNum:"messageNumber",PbMsgKey:"pbDownloadKey",JsonMsgKey:"downloadKey",MsgModifiedFlag:"isModified",PendencyItem:"applicationItem",PendencyType:"applicationType",AddTime:"time",AddSource:"source",AddWording:"wording",ProfileImImage:"avatar",PendencyAdd:"friendApplicationAdded",FrienPencydDel_Account:"friendApplicationDeletedUserIDList",Peer_Account:"userID",GroupAttr:"groupAttributeList",GroupAttrAry:"groupAttributeList",AttrMainSeq:"mainSequence",seq:"sequence",GroupAttrOption:"groupAttributeOption",BytesChangedKeys:"changedKeyList",GroupAttrInfo:"groupAttributeList",GroupAttrSeq:"mainSequence",PushChangedAttrValFlag:"isWithChangedAttributeInfo",SubKeySeq:"sequence",Val:"value",MsgGroupFromCardName:"senderNameCard",MsgGroupFromNickName:"senderNick",C2cNick:"peerNick",C2cImage:"peerAvatar",SendMsgControl:"messageControlInfo",NoLastMsg:"excludedFromLastMessage",NoUnread:"excludedFromUnreadCount",UpdateSeq:"updateSequence",MuteNotifications:"muteFlag",MsgClientTime:"clientTime",TinyId:"tinyID",GroupMsgReceiptList:"readReceiptList",ReadNum:"readCount",UnreadNum:"unreadCount",TopicId:"topicID",MillionGroupFlag:"communityType",SupportTopic:"isSupportTopic",MsgTopicNewInfo:"newTopicInfo",ShutupAll:"muteAllMembers",CustomString:"customData",TopicFaceUrl:"avatar",TopicIntroduction:"introduction",TopicNotification:"notification",TopicIdArray:"topicIDList",MsgVersion:"messageVersion",C2cMsgModNotifys:"c2cMessageModified",GroupMsgModNotifys:"groupMessageModified",ApplyJoinOption:"joinOption",MsgFlag:"messageRemindType",AtInfoList:"groupAtInfoList",AtFlagList:"groupAtType",AtMsgSeq:"sequence",BanDuration:"duration",BanDescription:"reason",NotVisible:"invisible",BytesTag:"tag",BytesValue:"value",RptBytesValue:"value",LatestSeq:"globalSequence",ClearSeq:"clearSequence",SupportMessageExtension:"isSupportExtension",ExtensionList:"extensions",GroupCounter:"counterList",Revoker_Account:"revoker",MsgExtensionNotify:"messageExtensionNotify",ExtensionC2cMsgInfo:"messageInfo",ExtensionGroupMsgInfo:"messageInfo",MsgOptType:"operateType",SetKVInfo:"operateResultList",DeleteKVInfo:"operateResultList",ClearKVInfo:"operateResultList",MsgKeyValue:"extensions",ClearMsgSeq:"clearSequence",MsgLastSeq:"globalSequence",InviteJoinOption:"inviteOption",MemberList_Account:"inviteeList",MsgMemberExtraInfoList:"inviteeInfoList",E:"event",GInf:"groupProfile",MCT:"clientTime",MR:"random",MP:"priority",MTS:"time",GId:"groupID",MS:"sequence",CCD:"cloudCustomData",F_Account:"from",F_Hd:"avatar",F_NN:"nick",GN:"groupName",GT:"groupType",IsSys:"isSystemMessage",OpInf:"operatorInfo",Img:"avatar",NN:"nick",OnlineInf:"onlineMemberInfo",ET:"expireTime",Num:"onlineMemberNum",Opt:"operationType",O_Account:"operatorID",RT:"operationType",UDF:"userDefinedField",L_Account:"userIDList",IsPlaceMsg:"isPlaceMessage",MsgCheckResult:"checkResult",Results:"resultList",Reaction:"reactionID",Reaction_Account:"userIDList",MsgReactionNotifyList:"messageReactionNotifyList",MsgReactionNotify:"messageReactionNotify",MsgReactionSummary:"reactionList",C2CMsgInfo:"C2CMessageInfo",GroupMsgInfo:"groupMessageInfo",int32_err_code:"errorCode",str_err_msg:"errorMsg",MsgDropReason:"messageDropReason",ReactedByMe:"reactedByMyself",Level:"messageRemindType",PeerReadTime:"timestamp",NoUnreadSeqList:"excludedUnreadSequenceList",NewMsg:"topicLatestMessage"},ignoreKeyWord:["C2C","ID","USP"]};function en(e,t){if("string"==typeof e||Array.isArray(e))return t=Object.assign({pascalCase:!1},t),0===(e=Array.isArray(e)?e.map((e=>e.trim())).filter((e=>e.length)).join("-"):e.trim()).length?"":1===e.length?t.pascalCase?e.toUpperCase():e.toLowerCase():(e=e=(e=e!==e.toLowerCase()?tn(e):e).replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,((e,t)=>t.toUpperCase())).replace(/\d+(\w|$)/g,(e=>e.toUpperCase())),t.pascalCase?e.charAt(0).toUpperCase()+e.slice(1):e);throw new TypeError("Expected the input to be `string | string[]`")}let tn=e=>{let t=!1,s=!1,i=!1;for(let n=0;n<e.length;n++){var o=e[n];t&&/[a-zA-Z]/.test(o)&&o.toUpperCase()===o?(e=e.slice(0,n)+"-"+e.slice(n),t=!1,i=s,s=!0,n++):s&&i&&/[a-zA-Z]/.test(o)&&o.toLowerCase()===o?(e=e.slice(0,n-1)+"-"+e.slice(n-1),i=s,s=!1,t=!0):(t=o.toLowerCase()===o&&o.toUpperCase()!==o,i=s,s=o.toUpperCase()===o&&o.toLowerCase()!==o)}return e};function sn(e,t){let s=0;return function e(t,i){var o;return 100<++s?(s--,t):Ve(t)?(o=t.map((t=>qe(t)?e(t,i):t)),s--,o):qe(t)?(o=ht(o=function(e){let t=Object.create(null);return Object.keys(e).forEach((s=>{var o=(e=>{if(!ze(e))return!1;if(e!==en(e))for(let s=0;s<Qo.ignoreKeyWord.length&&!e.includes(Qo.ignoreKeyWord[s]);s++);var t;return Be(i[e])?(t=e)[0].toUpperCase()+en(t).slice(1):i[e]})((e[s],s));o&&(t[o]=e[s])})),t}(t),((t,s)=>Ve(t)||qe(t)?e(t,i):t)),s--,o):void 0}(e,t)}function on(e,t){return Ve(e)?e.map((e=>qe(e)?on(e,t):e)):qe(e)?ht(function(e){let s={};return Object.keys(e).forEach((i=>{var o;s[(e[i],o=i,Be(t[o])?en(o):t[o])]=e[i]})),s}(e),(e=>Ve(e)||qe(e)?on(e,t):e)):void 0}let nn=String.fromCharCode,rn=function(e){let t=0|e.charCodeAt(0);if(55296<=t)if(t<56320)if(e=0|e.charCodeAt(1),56320<=e&&e<=57343){if(65535<(t=(t<<10)+e-56613888|0))return nn(240|t>>>18,128|t>>>12&63,128|t>>>6&63,128|63&t)}else t=65533;else t<=57343&&(t=65533);return t<=2047?nn(192|t>>>6,128|63&t):nn(224|t>>>12,128|t>>>6&63,128|63&t)},an=function(e){var t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,rn),s=0|t.length,i=new Uint8Array(s);let o=0;for(;o<s;o=o+1|0)i[o]=0|t.charCodeAt(o);return i};class ln{constructor(e){var t=(this._handler=e).getURL();if(this._socket=null,this._workerSocket=null,this._id=Ze(),this._handler.getIsWorkerEnabled()){let e=URL.createObjectURL(new Blob([';let _socket = null;onmessage = function(event) { if (event.data.cmd === "start") { const url = event.data.url; _socket = new WebSocket(url); _socket.binaryType = "arraybuffer"; _socket.onopen = function() { postMessage({ callback: "onOpen", extensions: _socket.extensions }); }; _socket.onclose = function(e) { postMessage({ callback: "onOpen", e: { code: e.code, reason: e.reason } }); }; _socket.onmessage = function(e) { postMessage({ callback: "onMessage", data: e.data }); }; _socket.onerror = function(e) { postMessage({ callback: "onError", e: { isTrusted: "true" } }); }; } else if (event.data.cmd === "sendMessage") { if (_socket !== null) { _socket.send(event.data.data); } } else if (event.data.cmd === "stop") { if (_socket !== null) { _socket.close(event.data.code); _socket = null; } }};'],{type:"application/javascript; charset=utf-8"})),s=(this._workerSocket=new Worker(e),this);this._workerSocket.onmessage=function(e){var{callback:t,e:i,extensions:o}=e.data;"onOpen"===t?s._onOpen(o):"onClose"===t?s._onClose(i):"onError"===t?s._onError(i):"onMessage"===t&&s._onMessage(e.data)},this._workerSocket.postMessage({cmd:"start",id:this._id,url:t})}else x?k?(H.connectSocket({url:t,header:{"content-type":"application/json"}}),H.onSocketClose(this._onClose.bind(this)),H.onSocketOpen(this._onOpen.bind(this)),H.onSocketMessage(this._onMessage.bind(this)),H.onSocketError(this._onError.bind(this))):(this._socket=H.connectSocket({url:t,header:{"content-type":"application/json"},complete:()=>{}}),this._socket.onClose(this._onClose.bind(this)),this._socket.onOpen(this._onOpen.bind(this)),this._socket.onMessage(this._onMessage.bind(this)),this._socket.onError(this._onError.bind(this))):(this._socket=new WebSocket(t),this._socket.binaryType="arraybuffer",this._socket.onopen=this._onOpen.bind(this,this._socket.extensions),this._socket.onmessage=this._onMessage.bind(this),this._socket.onclose=this._onClose.bind(this),this._socket.onerror=this._onError.bind(this));this._canIUseBinaryFrame=e.canIUseBinaryFrame()}getID(){return this._id}_onOpen(e){this._handler.onOpen({id:this._id,res:JSON.stringify(e)})}_onClose(e){this._handler.onClose({id:this._id,e:e})}_onMessage(e){e=this._canIUseBinaryFrame?this._isAppCompressedData(e.data)?this._handler.inflate(e.data):function(e){var t=new Uint8Array(e);let s="",i=0;for(var o=t.length;i<o;){let e=t[i],n=0,r=0;if(e<=127?(n=0,r=255&e):e<=223?(n=1,r=31&e):e<=239?(n=2,r=15&e):e<=244&&(n=3,r=7&e),0<o-i-n){let s=0;for(;s<n;)e=t[i+s+1],r=r<<6|63&e,s+=1}else r=65533,n=o-i;s+=String.fromCodePoint(r),i+=n+1}return s}(e.data):e.data,this._handler.onMessage({data:e})}_isAppCompressedData(e){return e=new Uint8Array(e),67===e[0]&&79===e[1]&&77===e[2]&&80===e[3]}_onError(e){this._handler.onError({id:this._id,e:e})}setIsWorkerEnabled(e){this._isWorkerEnabled=!0}close(e){this._workerSocket&&(this._workerSocket.postMessage({cmd:"stop",code:e}),this._workerSocket.terminate(),this._workerSocket=null),k?(H.offSocketClose(),H.offSocketMessage(),H.offSocketOpen(),H.offSocketError(),H.closeSocket()):this._socket&&(x?(this._socket.onClose((()=>{})),this._socket.onOpen((()=>{})),this._socket.onMessage((()=>{})),this._socket.onError((()=>{}))):(this._socket.onopen=null,this._socket.onmessage=null,this._socket.onclose=null,this._socket.onerror=null),G?this._socket.close({code:e}):this._socket.close(e),this._socket=null)}send(e){this._workerSocket?this._workerSocket.postMessage({cmd:"sendMessage",data:this._canIUseBinaryFrame?an(e.data).buffer:e.data}):k?H.sendSocketMessage({data:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}}):this._socket&&(x?this._socket.send({data:this._canIUseBinaryFrame?an(e.data).buffer:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}}):this._socket.send(this._canIUseBinaryFrame?an(e.data):e.data))}}let dn=4e3,cn=4001,_n="connected",un="connecting",hn="disconnected";class pn{constructor(e){this._chM=e,this._n="SocketHandler",this._promiseMap=new Map,this._readyState=hn,this._simpleRequestMap=new Map,this.MAX_SIZE=100,this._startSequence=Ze(),this._startTs=0,this._reConnectFlag=!1,this._nextPingTs=0,this._reConnectCount=0,this.MAX_RECONNECT_COUNT=3,this._socketID=-1,this._random=0,this._socket=null,this._url="",this._onOpenTs=0,this._canIUseBinaryFrame=!0,this._isWorkerEnabled=!0,this._currentSite=h,this._setWebsocketHost(),this._initConnection()}_setWebsocketHost(){var e=this._chM.get(Os);this._currentSite=h,this._chM.isOversea()&&(this._currentSite=p),e.isSingaporeSite()?this._currentSite=g:e.isKoreaSite()?this._currentSite=m:e.isGermanySite()?this._currentSite=M:e.isIndiaSite()?this._currentSite=f:e.isJapanSite()?this._currentSite=I:e.isUSASite()?this._currentSite=C:e.isIndonesiaSite()&&(this._currentSite=v),T.HOST.setCurrent(this._currentSite)}_initConnection(){var e=this._chM.get(Os).getSDKAppID()+"",t=this._chM.get(Os).isIndependentDomainDisabled();Be(T.HOST.CURRENT.BACKUP)?this._url=T.HOST.CURRENT.DEFAULT:""===this._url?this._url=t?T.HOST.CURRENT.DEFAULT:T.HOST.CURRENT.DEFAULT0.replace("*",e):-1<this._url.indexOf(e)?this._url=T.HOST.CURRENT.DEFAULT:this._url===T.HOST.CURRENT.DEFAULT?this._url=T.HOST.CURRENT.IPV6:this._url===T.HOST.CURRENT.IPV6?this._url=K?this._genRandomDomain():T.HOST.CURRENT.BACKUP:this._isWebBackupUrl(this._url)||this._url===T.HOST.CURRENT.BACKUP?this._url=this._canIUseAnyCast()?T.HOST.CURRENT.ANYCAST:T.HOST.CURRENT.DEFAULT:this._url===T.HOST.CURRENT.ANYCAST&&(T.HOST.CURRENT.ANYCAST="",this._url=T.HOST.CURRENT.DEFAULT),t=this._chM.get(Os),e=t.getProxyServer();Ue(e)||(this._url=e),t.isTestEnv()&&(this._url=d.TEST[this._currentSite].DEFAULT),this._connect(),this._nextPingTs=0}_genRandomDomain(){var e=Math.floor(10001*Math.random())+1e4;return T.HOST.CURRENT.BACKUP_WEB.replace("*",e)}_isWebBackupUrl(e){return e.includes("my-cpaas.com")}_canIUseAnyCast(){return K&&T.HOST.CURRENT.ANYCAST}onCheckTimer(e){e%1==0&&(this._checkPromiseMap(),this._checkNativeAppWS())}_checkPromiseMap(){0!==this._promiseMap.size&&this._promiseMap.forEach(((e,t)=>{var{reject:e,timestamp:s,headSeq:i}=e;let o=15e3;-1!==t.indexOf(di.LOGIN)?o=9e4:-1!==t.indexOf(di.PING)&&(o=3e3),Date.now()-s>=o&&(ye.l(this._n+"._checkPromiseMap request timeout, delete requestID:"+t),this._promiseMap.delete(t),e(new si({code:ii.NETWORK_TIMEOUT,data:{headSeq:i}})),this._chM.onRequestTimeout())}))}_checkNativeAppWS(){b&&!this.isConnected()&&this._reConnect()}onOpen(e){var t,s;this._readyState!==hn&&(this._onOpenTs=Date.now(),({id:e,res:t}=e),this._socketID=e,s=At(this._startTs,!1),e=`socketID:${e} res:`+t,ye.l(this._n+`._onOpen cost:${s} ms. `+e),new Ei("wsOnOpen").setMessage(s).setCostTime(s).setMoreMessage(e).end(),this._readyState=_n,this._reConnectCount=0,this._resend(),!0===this._reConnectFlag&&(this._chM.onReconnected(),this._reConnectFlag=!1),this._chM.onOpen())}onClose(e){var t=new Ei("wsOnClose"),{id:e,e:s}=e,i=`sourceSocketID:${e} currentSocketID:${this._socketID} code:${s.code} reason:`+s.reason;let o=0;0!==this._onOpenTs&&(o=Date.now()-this._onOpenTs),t.setMessage(o).setCostTime(o).setMoreMessage(i).setCode(s.code).end(!0),ye.l(this._n+`._onClose ${i} onlineTime:`+o),e===this._socketID&&(this._readyState=hn,o<1e3?this._chM.onReconnectFailed():this._chM.onClose())}onError(e){var{id:e,e:t}=e,s=`sourceSocketID:${e} currentSocketID:`+this._socketID;new Ei("wsOnError").setMessage(t.errMsg||JSON.stringify(t,["message","code"])).setMoreMessage(s).setLevel("error").end(!0),ye.w(this._n+"._onError",t,s),e===this._socketID&&(this._readyState=hn,this._chM.onError())}onMessage(e){let t;try{t=JSON.parse(e.data)}catch(i){new Ei("jsonParseError").setMessage(e.data).end()}if(t&&t.head){var s=this._getRequestIDFromHead(t.head);let e=t.body;if(!this._chM.get(Ws).isTRTCCommand(s)){let s=Ct(t.head);e=on(t.body,this._getResKeyMap(s))}if(ye.d(`${this._n}.onMessage ret:${JSON.stringify(e)} requestID:${s} has:`+this._promiseMap.has(s)),this._setNextPingTs(),this._promiseMap.has(s)){let{resolve:t,reject:i,timestamp:o,headSeq:n}=this._promiseMap.get(s);this._promiseMap.delete(s),this._calcRTT(o),e.errorCode&&0!==e.errorCode?(this._chM.onErrorCodeNotZero(e),i(new si({code:e.errorCode,message:e.errorInfo||"",data:s.includes(di.MODIFY_C2C_MSG)||s.includes(di.MODIFY_GRP_MSG)?{elements:e.elements,messageVersion:e.messageVersion,cloudCustomData:e.cloudCustomData,headSeq:n}:{headSeq:n}}))):t(ti(e))}else this._chM.onMessage({head:t.head,body:e})}}_calcRTT(e){e=Date.now()-e,this._chM.get(Bs).addRTT(e)}_connect(){this._readyState!==un&&this._readyState!==_n&&(this._startTs=Date.now(),this._onOpenTs=0,this._readyState=un,this._socket=new ln(this),this._socketID=this._socket.getID(),ye.l(`${this._n}._connect isWorkerEnabled:${this.getIsWorkerEnabled()} socketID:${this._socketID} url:`+this.getURL()),new Ei("wsConnect").setMessage(`socketID:${this._socketID} url:`+this.getURL()).end())}getURL(){this._chM.isDevMode()&&(this._canIUseBinaryFrame=!1);var e=mt();(k||O&&"windows"===e||b)&&(this._canIUseBinaryFrame=!1);let t=-1;"ios"===e?t=Z||-1:"android"===e&&(t=ee||-1);var s=this._chM.get(Os),i=this._chM.getPlatform();let o=`sdkappid=${s.getSDKAppID()}&instanceid=${s.getInstanceID()}&random=${this._getRandom()}&platform=${i}&host=${e}&version=${t}&sdkversion=3.5.3`;return N&&(o+="&isminigame=1"),this._chM.canIUseInflate()&&(o+="&compress=gzip"),this._canIUseBinaryFrame?this._url+"/binfo?"+o:this._url+"/info?"+o}_closeConnection(e){ye.l(this._n+"._closeConnection socketID:"+this._socketID),this._socket&&(this._socket.close(e),this._socketID=-1,this._socket=null,this._readyState=hn)}_resend(){if(ye.l(this._n+"._resend reConnectFlag:"+this._reConnectFlag,`promiseMap.size:${this._promiseMap.size} simpleRequestMap.size:`+this._simpleRequestMap.size),0<this._promiseMap.size&&this._promiseMap.forEach(((e,t)=>{var{uplinkData:e,resolve:s,reject:i}=e;-1!==t.indexOf(di.AV_POLLING)?this._promiseMap.delete(t):(this._promiseMap.set(t,{resolve:s,reject:i,timestamp:Date.now(),uplinkData:e}),this._execute(t,e))})),0<this._simpleRequestMap.size){for(var[e,t]of this._simpleRequestMap)this._execute(e,t);this._simpleRequestMap.clear()}}send(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3),e.head.cs=this._calcCheckSum(e.head.servcmd,e.body);let{keyMap:t,...s}=e,i=this._getRequestIDFromHead(e.head),o=JSON.stringify(s);return new Promise(((t,n)=>{this._promiseMap.set(i,{resolve:t,reject:n,timestamp:Date.now(),uplinkData:o,headSeq:e.head.seq}),ye.d(`${this._n}.send uplinkData:${JSON.stringify(s)} requestID:${i} readyState:`+this._readyState),this._readyState!==_n?this._reConnect():(this._execute(i,o),this._chM.get(Bs).addRequestCount())}))}simplySend(e){e.head.seq=this._getSequence(),e.head.reqtime=Math.floor(Date.now()/1e3);let{keyMap:t,...s}=e,i=this._getRequestIDFromHead(e.head),o=JSON.stringify(s);this._readyState!==_n?(this._simpleRequestMap.size<this.MAX_SIZE?this._simpleRequestMap.set(i,o):ye.l(this._n+".simplySend. simpleRequestMap is full, drop request!"),this._reConnect()):this._execute(i,o)}_execute(e,t){this._socket.send({data:t,fail:x?this._onSendFail.bind(this):void 0,requestID:e})}_onSendFail(e){ye.l(this._n+"._onSendFail requestID:"+e),this._chM.onSendFail()}_getSequence(){var e;if(this._startSequence<2415919103)return e=this._startSequence,this._startSequence+=1,2415919103===this._startSequence&&(this._startSequence=Ze()),e}_getRequestIDFromHead(e){var{servcmd:e,seq:t}=e;return e+t}_getResKeyMap(e){return e=this._chM.getKeyMap(e),{...Qo.res,...e.res}}_reConnect(){this._readyState!==_n&&this._readyState!==un&&this.forcedReconnect()}forcedReconnect(){var e=this._n+".forcedReconnect";ye.l(e+` count:${this._reConnectCount} readyState:`+this._readyState),this._reConnectFlag=!0,this._resetRandom(),this._reConnectCount<this.MAX_RECONNECT_COUNT?(this._reConnectCount+=1,this._closeConnection(cn),this._initConnection()):(this._reConnectCount=0,this._chM.get(Us).isOnline()?(ye.w(e+" disconnected from wsserver but network is ok, continue..."),this._closeConnection(cn),this._initConnection()):this._chM.onReconnectFailed())}getReconnectFlag(){return this._reConnectFlag}_setNextPingTs(){this._nextPingTs=b?Date.now()+5e3:Date.now()+1e4}getNextPingTs(){return this._nextPingTs}isConnected(){return this._readyState===_n}canIUseBinaryFrame(){return this._canIUseBinaryFrame}getSocketID(){return this._socketID}inflate(e){if(this._chM.canIUseInflate())return this._chM.get(Qs).inflate(e)}setIsWorkerEnabled(e){ye.l(this._n+".setIsWorkerEnabled flag:"+e),this._isWorkerEnabled=e}getIsWorkerEnabled(){return this._isWorkerEnabled&&le}_getRandom(){return 0===this._random&&(this._random=Math.random()),this._random}_resetRandom(){this._random=0}_calcCheckSum(e,t){if(-1!==e.indexOf(di.PING)||-1!==e.indexOf(di.LOGIN)||-1!==e.indexOf(di.LOGOUT)||-1!==e.indexOf(di.AV_POLLING)||-1!==e.indexOf(di.AV_NOAUTH_POLLING))return 0;var s=an(JSON.stringify(t));let i=4294967295;for(let o=0,n=s.length;o<n;o++){i^=s[o];for(let e=0;e<8;e++)1==(1&i)?i=i>>>1^3988292384:i>>>=1}return(4294967295^i)>>>0}close(){ye.l(this._n+".close"),this._closeConnection(dn),this._promiseMap.clear(),this._startSequence=Ze(),this._readyState=hn,this._simpleRequestMap.clear(),this._reConnectFlag=!1,this._reConnectCount=0,this._onOpenTs=0,this._url="",this._random=0,this._canIUseBinaryFrame=!0,this._isWorkerEnabled=!0}}let gn=function(e,t,s){return new Promise(((i,o)=>{var n="application/x-www-form-urlencoded;charset=UTF-8";if(x)H.request({url:t,data:s,method:e,timeout:3e3,header:{"content-type":n},success:e=>{e&&e.data&&e.data.NetCheckInfo&&ye.l("getconninfo ok in miniapp. ret:",e.data),i()},fail:()=>{o(new si({code:ii.NETWORK_ERROR}))}});else{let r=new XMLHttpRequest,a=setTimeout((()=>{r.abort(),o(new si({code:ii.NETWORK_TIMEOUT}))}),3e3);r.onreadystatechange=function(){4===r.readyState&&(a&&clearTimeout(a),200===r.status||304===r.status?(r.responseText&&-1<r.responseText.indexOf("NetCheckInfo")&&ye.l("getconninfo ok in web. ret:",JSON.parse(r.responseText)),i()):o(new si({code:ii.NETWORK_ERROR})))},r.open(e,t,!0),r.setRequestHeader("Content-type",n),s?r.send(s):r.send()}}))};class mn extends li{constructor(e){super(e),this._n="ChannelModule",this._socketHandler=new pn(this),this._probing=!1,this._isAppShowing=!0,this._previousState=o.NET_STATE_CONNECTED,this._timerForNotLoggedIn=-1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3),this._fatalErrorFlag=!1,this._disconnectedTS=0,this._lastDiagnoseTS=0}onCheckTimer(e){this._socketHandler&&(this.isLoggedIn()?(0<this._timerForNotLoggedIn&&(clearInterval(this._timerForNotLoggedIn),this._timerForNotLoggedIn=-1),this._socketHandler.onCheckTimer(e)):this._socketHandler.onCheckTimer(1),this._checkNextPing())}onErrorCodeNotZero(e){this.get(bs).onErrorCodeNotZero(e)}onMessage(e){this.get(bs).onMessage(e)}send(e){return this._socketHandler?this._previousState!==o.NET_STATE_CONNECTED&&e.head.servcmd.includes(di.SSO_STAT)?(this.reConnect(),this.isPrivateNetWork()?Promise.resolve():this._sendLogViaHTTP(e)):this._socketHandler.send(e):Promise.reject()}_sendLogViaHTTP(e){var t=`${T.HOST.CURRENT.STAT}/v4/imopenstat/tim_web_report_v2?sdkappid=${e.head.sdkappid}&reqtime=`+Date.now();e=JSON.stringify(e.body);return gn("POST",t,e)}simplySend(e){return this._socketHandler?this._socketHandler.simplySend(e):Promise.reject()}onOpen(){this._ping()}onClose(){this._socketHandler&&this._socketHandler.getReconnectFlag()&&this._emitNetStateChangeEvent(o.NET_STATE_DISCONNECTED),this.reConnect()}onError(){x&&!b&&this.warn("DomainNameInMP"),this._emitNetStateChangeEvent(o.NET_STATE_DISCONNECTED)}getKeyMap(e){return this.get(bs).getKeyMap(e)}onRequestTimeout(){3e4<=Date.now()-this._lastDiagnoseTS&&this.diagnose()}onSendFail(){this._emitNetStateChangeEvent(o.NET_STATE_DISCONNECTED)}onReconnected(){ye.l(this._n+".onReconnected cost:"+At(this._disconnectedTS,!0,!0)),this._m.restartTimer(),this.get(bs).onReconnected(At(this._disconnectedTS,!1,!1)),this._disconnectedTS=0,this._emitNetStateChangeEvent(o.NET_STATE_CONNECTED)}onReconnectFailed(){ye.l(this._n+".onReconnectFailed"),this._emitNetStateChangeEvent(o.NET_STATE_DISCONNECTED)}setIsWorkerEnabled(e){this._socketHandler&&this._socketHandler.setIsWorkerEnabled(!1)}offline(){this._emitNetStateChangeEvent(o.NET_STATE_DISCONNECTED)}reConnect(e=!1){let t=!1;this._socketHandler&&(t=this._socketHandler.getReconnectFlag());var s=`forcedFlag:${e} fatalErrorFlag:${this._fatalErrorFlag} previousState:${this._previousState} reconnectFlag:`+t;ye.l(this._n+".reConnect "+s),this._fatalErrorFlag||!this._socketHandler||!0!==e&&this._previousState===o.NET_STATE_CONNECTING&&t||(this._socketHandler.forcedReconnect(),this._emitNetStateChangeEvent(o.NET_STATE_CONNECTING))}_emitNetStateChangeEvent(e){this._previousState!==e&&(ye.l(`${this._n}._emitNetStateChangeEvent from ${this._previousState} to `+e),e===o.NET_STATE_DISCONNECTED&&0===this._disconnectedTS&&(this._disconnectedTS=Date.now(),this.diagnose()),this._previousState=e,this.emitOEvt(i.NET_STATE_CHANGE,{state:e}))}_ping(){var e;!0!==this._probing&&(this._probing=!0,e=this.get(bs).getProtocolData({P:di.PING}),this.send(e).then((()=>{this._probing=!1})).catch((e=>{this._probing=!1;var t=this.get(Us).isOnline();ye.w(this._n+`._ping failed. bOnline:${t} error:`,e),e&&60002===e.code?(new Ei("error").setMessage(`code:${e.code} message:`+e.message).end(),this._fatalErrorFlag=!0,this._emitNetStateChangeEvent(o.NET_STATE_DISCONNECTED)):t?this.reConnect():this._emitNetStateChangeEvent(o.NET_STATE_DISCONNECTED)})))}_checkNextPing(){this._socketHandler&&this._socketHandler.isConnected()&&Date.now()>=this._socketHandler.getNextPingTs()&&this._ping()}dealloc(){this._socketHandler&&(this._socketHandler.close(),this._socketHandler=null),-1<this._timerForNotLoggedIn&&clearInterval(this._timerForNotLoggedIn)}onRestApiKickedOut(){this._socketHandler&&(this._socketHandler.close(),this.reConnect(!0))}canIUseInflate(){return this._m.canIUseInflate()}getSocketID(){if(this._socketHandler)return this._socketHandler.getSocketID()}diagnose(){this.isPrivateNetWork()||(this._lastDiagnoseTS=Date.now(),this._diagnoseBySSO(),this._diagnoseByCDN())}_diagnoseBySSO(){var e=this._socketHandler.getURL(),t=e.split("/")[2];t.startsWith("ws")&&(t=`https://${t}/v3/netcheck/getconninfo?${e.slice(e.indexOf("info?")+5)}&reqtime=`+Date.now(),gn("GET",t).catch((e=>{ye.w(this._n+"._diagnoseBySSO failed. error:",e)})))}_diagnoseByCDN(){var e=this._socketHandler.getURL();e=`https://boce-cdn.my-imcloud.com/v3/netcheck/getconninfo?${e.slice(e.indexOf("info?")+5)}&reqtime=`+Date.now();gn("GET",e).catch((e=>{ye.w(this._n+"._diagnoseByCDN failed. error:",e)}))}reset(){ye.l(this._n+".reset"),this._previousState=o.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3),this._disconnectedTS=0,this._lastDiagnoseTS=0}}class Mn{constructor(e){this._n="PHandler",this._sessionM=e,this._map=new Map,this._fillMap()}_fillMap(){this._map.clear();var e=this._sessionM.genCommonHead(),t=this._sessionM.genCosSpecifiedHead(),s=this._sessionM.genSSOReportHead();this._map.set(di.LOGIN,{head:{...e,servcmd:T.NAME.IM_OPEN_STATUS+"."+di.LOGIN},body:{state:"Online",isWebUniapp:0,deviceBrand:0,customInfo:""},keyMap:{req:{deviceBrand:"InstType"},res:{InstId:"instanceID",HelloInterval:"helloInterval",RichMsgAuthKey:"authKey"}}}),this._map.set(di.LOGOUT,{head:{...e,servcmd:T.NAME.IM_OPEN_STATUS+"."+di.LOGOUT},body:{type:0,isWebUniapp:0},keyMap:{req:{type:"wslogout_type"}}}),this._map.set(di.HELLO,{head:{...e,servcmd:T.NAME.IM_OPEN_STATUS+"."+di.HELLO},body:{isWebUniapp:0},keyMap:{res:{NewInstInfo:"newInstanceInfo"}}}),this._map.set(di.KICK_OTHER,{head:{...e,servcmd:T.NAME.STAT_SERVICE+"."+di.KICK_OTHER},body:{}}),this._map.set(di.COS_SIGN,{head:{...t,servcmd:T.NAME.IM_COS_SIGN+"."+di.COS_SIGN},body:{cmd:"open_im_cos_svc",subCmd:"get_cos_token",duration:300,version:2},keyMap:{req:{userSig:"usersig",subCmd:"sub_cmd",cmd:"cmd",duration:"duration",version:"version"},res:{expired_time:"expiredTime",bucket_name:"bucketName",session_token:"sessionToken",tmp_secret_id:"secretId",tmp_secret_key:"secretKey"}}}),this._map.set(di.COS_PRE_SIG,{head:{...t,servcmd:T.NAME.CUSTOM_UPLOAD+"."+di.COS_PRE_SIG},body:{fileType:void 0,fileName:void 0,uploadMethod:0,duration:900},keyMap:{req:{userSig:"usersig",fileType:"file_type",fileName:"file_name",uploadMethod:"upload_method"},res:{expired_time:"expiredTime",request_id:"requestId",head_url:"headUrl",upload_url:"uploadUrl",download_url:"downloadUrl",ci_url:"ciUrl",snapshot_url:"requestSnapshotUrl"}}}),this._map.set(di.SIMPLE_COS_PRE_SIG,{head:{...t,servcmd:T.NAME.CUSTOM_UPLOAD+"."+di.SIMPLE_COS_PRE_SIG},body:{uploadMethod:0,platform:2,SDKAppID:0,userID:"",conversationType:1,uploadConfig:[{fileID:1,fileType:1,fileName:""}]},keyMap:{req:{platform:"uint32_platform",SDKAppID:"uint32_sdkappid",userID:"str_user_id",uploadMethod:"uint32_upload_method",conversationType:"uint32_scene",uploadConfig:"rpt_upload_object",fileID:"uint32_file_id",fileType:"uint32_file_type",fileName:"str_file_name"},res:{str_final_ip:"uploadIP",rpt_pre_sig:"preSig",uint32_file_id:"fileID",uint32_exist_flag:"existFlag",str_download_url:"downloadUrl",str_upload_url:"uploadUrl",str_snapshot_url:"requestSnapshotUrl",str_file_key:"fileKey"}}}),this._map.set(di.GET_IMAGE_INFO,{head:{...t,servcmd:T.NAME.CUSTOM_UPLOAD+"."+di.GET_IMAGE_INFO},body:{imageUrl:""},keyMap:{req:{imageUrl:"str_image_url"},res:{rpt_msg_image_info:"imageInfoArray",uint32_image_type:"type",str_url:"url",uint32_width:"width",uint32_height:"height",str_image_format:"imageFormat"}}}),this._map.set(di.GET_IP,{head:{...t,servcmd:T.NAME.CUSTOM_UPLOAD+"."+di.GET_IP},body:{domainName:""},keyMap:{req:{domainName:"str_domain"},res:{str_final_ip:"ip"}}}),this._map.set(di.VIDEO_COVER,{head:{...t,servcmd:T.NAME.CUSTOM_UPLOAD+"."+di.VIDEO_COVER},body:{version:1,platform:void 0,coverName:void 0,requestSnapshotUrl:void 0},keyMap:{req:{version:"version",platform:"platform",coverName:"cover_name",requestSnapshotUrl:"snapshot_url"},res:{error_code:"errorCode",error_msg:"errorInfo",download_url:"snapshotUrl"}}}),this._map.set(di.FETCH_COMMERCIAL_CONFIG,{head:{...e,servcmd:T.NAME.IM_CONFIG_MANAGER+"."+di.FETCH_COMMERCIAL_CONFIG},body:{SDKAppID:0},keyMap:{req:{SDKAppID:"uint32_sdkappid"},res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}),this._map.set(di.PUSHED_COMMERCIAL_CONFIG,{head:{...e,servcmd:T.NAME.IM_CONFIG_MANAGER+"."+di.PUSHED_COMMERCIAL_CONFIG},body:{},keyMap:{res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_purchase_bits:"purchaseBits",uint32_expired_time:"expiredTime"}}}),this._map.set(di.FETCH_CLOUD_CTRL_CONFIG,{head:{...e,servcmd:T.NAME.IM_CONFIG_MANAGER+"."+di.FETCH_CLOUD_CTRL_CONFIG},body:{SDKAppID:0,version:0},keyMap:{req:{SDKAppID:"uint32_sdkappid",version:"uint64_version"},res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}),this._map.set(di.PUSHED_CLOUD_CTRL_CONFIG,{head:{...e,servcmd:T.NAME.IM_CONFIG_MANAGER+"."+di.PUSHED_CLOUD_CTRL_CONFIG},body:{},keyMap:{res:{int32_error_code:"errorCode",str_error_message:"errorMessage",str_json_config:"cloudControlConfig",uint32_expired_time:"expiredTime",uint32_sdkappid:"SDKAppID",uint64_version:"version"}}}),this._map.set(di.OVERLOAD_NOTIFY,{head:{...e,servcmd:T.NAME.OVERLOAD_PUSH+"."+di.OVERLOAD_NOTIFY},body:{},keyMap:{res:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}),this._map.set(di.SYNC_UNREAD_MSG,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.SYNC_UNREAD_MSG},body:{cookie:"",syncFlag:0,needAbstract:1,isOnlineSync:0,needSignaling:1,needCachedMsg:1},keyMap:{req:{fromAccount:"From_Account",toAccount:"To_Account",from:"From_Account",to:"To_Account",time:"MsgTimeStamp",sequence:"MsgSeq",random:"MsgRandom",elements:"MsgBody"},res:{MsgList:"messageList",SyncFlag:"syncFlag",To_Account:"to",From_Account:"from",ClientSeq:"clientSequence",MsgSeq:"sequence",NoticeSeq:"noticeSequence",NotifySeq:"notifySequence",MsgRandom:"random",MsgTimeStamp:"time",MsgContent:"content",ToGroupId:"to",MsgKey:"messageKey",GroupTips:"groupTips",MsgBody:"elements",MsgType:"type",C2CRemainingUnreadCount:"C2CRemainingUnreadList",C2CPairUnreadCount:"C2CPairUnreadList"}}}),this._map.set(di.GET_PROFANITY_LIST,{head:{...e,servcmd:T.NAME.IM_MSG_AUDIT_MGR+"."+di.GET_PROFANITY_LIST},body:{version:0,deviceID:"",startIndex:void 0},keyMap:{req:{version:"uint64_version",deviceID:"str_device_id",startIndex:"uint64_start_index"},res:{msg_cmd_error_code:"errorInfo",str_err_msg:"errorMessage",uint32_code:"errorCode",msg_scene_ctl_config:"filterConfig",uint64_c2c_custom_msg_flag:"c2c_custom_message",uint64_c2c_text_msg_flag:"c2c_text_message",uint64_group_custom_msg_flag:"group_custom_message",uint64_group_text_msg_flag:"group_text_message",uint64_group_info_flag:"group_profile",uint64_group_member_info_flag:"group_member_profile",uint64_relation_chain_flag:"sns",uint64_user_info_flag:"user_profile",rpt_msg_dirty_word:"lexicon",str_dirty_word:"profanity",str_replaced_content:"replacement",uint64_filter_type:"filterType",uint64_id:"id",uint64_word_type:"profanityType",uint64_complete_flag:"completeFlag",uint64_next_start_index:"nextStartIndex",uint64_version:"version",uint64_expired_time:"expiredTime"}}}),this._map.set(di.SEND_C2C_MSG,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.SEND_C2C_MSG},body:{fromAccount:"",toAccount:"",msgSeq:0,msgRandom:0,msgBody:[],cloudCustomData:void 0,nick:"",avatar:"",msgLifeTime:void 0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{sound:"",badgeMode:0,isVoipPush:void 0,image:""},androidInfo:{sound:"",XiaoMiChannelID:"",OPPOChannelID:"",GoogleChannelID:"",VIVOClassification:1,VIVOCategory:"",HuaWeiCategory:"",OPPOCategory:"",HuaWeiImage:"",HonorImage:"",GoogleImage:"",HonorImportance:""}},messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,isSupportExtension:0,isRelayMessage:0,cmConfigID:void 0,forbidCallbackControl:void 0},keyMap:{req:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",count:"MaxCnt",lastMessageTime:"LastMsgTime",messageKey:"MsgKey",peerAccount:"Peer_Account",data:"Data",description:"Desc",extension:"Ext",type:"MsgType",content:"MsgContent",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",nick:"From_AccountNick",avatar:"From_AccountHeadurl",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"IsNeedReadReceipt",GoogleChannelID:"GoogleChannelID",XiaoMiChannelID:"XiaoMiChannelID",OPPOChannelID:"OPPOChannelID",OPPOCategory:"OPPOCategory",VIVOClassification:"VIVOClassification",VIVOCategory:"VIVOCategory",HonorImportance:"HonorImportance"}}}),this._map.set(di.SEND_GRP_MSG,{head:{...e,servcmd:T.NAME.GRP+"."+di.SEND_GRP_MSG},body:{fromAccount:"",groupID:"",random:0,clientSequence:0,priority:"",msgBody:[],cloudCustomData:void 0,onlineOnlyFlag:0,offlinePushInfo:{pushFlag:0,title:"",desc:"",ext:"",apnsInfo:{sound:"",badgeMode:0,isVoipPush:void 0,image:""},androidInfo:{sound:"",XiaoMiChannelID:"",OPPOChannelID:"",GoogleChannelID:"",VIVOClassification:1,VIVOCategory:"",HuaWeiCategory:"",OPPOCategory:"",HuaWeiImage:"",HonorImage:"",GoogleImage:"",HonorImportance:""}},groupAtInfo:[],messageControlInfo:void 0,clientTime:void 0,needReadReceipt:0,topicID:void 0,receiverList:void 0,isSupportExtension:0,isRelayMessage:0,cmConfigID:void 0,forbidCallbackControl:void 0},keyMap:{req:{to:"GroupId",extension:"Ext",data:"Data",description:"Desc",random:"Random",sequence:"ReqMsgSeq",count:"ReqMsgNumber",type:"MsgType",priority:"MsgPriority",content:"MsgContent",elements:"MsgBody",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",clientSequence:"ClientSeq",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody",needReadReceipt:"NeedReadReceipt",receiverList:"To_Account",GoogleChannelID:"GoogleChannelID",XiaoMiChannelID:"XiaoMiChannelID",OPPOChannelID:"OPPOChannelID",OPPOCategory:"OPPOCategory",VIVOClassification:"VIVOClassification",VIVOCategory:"VIVOCategory",HonorImportance:"HonorImportance"},res:{MsgTime:"time",MsgSeq:"sequence"}}}),this._map.set(di.REVOKE_C2C_MSG,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.REVOKE_C2C_MSG},body:{msgInfo:{fromAccount:"",toAccount:"",msgTimeStamp:0,msgSeq:0,msgRandom:0}},keyMap:{req:{msgInfo:"MsgInfo",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom"}}}),this._map.set(di.REVOKE_GRP_MSG,{head:{...e,servcmd:T.NAME.GRP+"."+di.REVOKE_GRP_MSG},body:{groupID:"",msgSeqList:void 0,topicID:""},keyMap:{req:{msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}),this._map.set(di.GET_C2C_ROAMING_MSG,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.GET_C2C_ROAMING_MSG},body:{peerAccount:"",count:15,lastMessageTime:0,messageKey:"",withRecalledMessage:1,direction:0},keyMap:{req:{messageKey:"MsgKey",peerAccount:"Peer_Account",count:"MaxCnt",lastMessageTime:"LastMsgTime",withRecalledMessage:"WithRecalledMsg",direction:"GetDirection"},res:{LastMsgTime:"lastMessageTime",IsNeedReadReceipt:"needReadReceipt",IsPeerRead:"readReceiptSentByPeer"}}}),this._map.set(di.MODIFY_C2C_MSG,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.MODIFY_C2C_MSG},body:{from:"",to:"",sequence:0,random:0,time:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{req:{sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}),this._map.set(di.GET_GRP_ROAMING_MSG,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_GRP_ROAMING_MSG},body:{withRecalledMsg:1,groupID:"",count:15,sequence:"",topicID:void 0},keyMap:{req:{sequence:"ReqMsgSeq",count:"ReqMsgNumber",withRecalledMessage:"WithRecalledMsg"},res:{Random:"random",MsgTime:"time",MsgSeq:"sequence",ReqMsgSeq:"sequence",RspMsgList:"messageList",IsSystemMsg:"isSystemMessage",ToGroupId:"to",EnumFrom_AccountType:"fromAccountType",EnumTo_AccountType:"toAccountType",GroupCode:"groupCode",MsgPriority:"priority",MsgBody:"elements",MsgType:"type",MsgContent:"content",IsFinished:"complete",Download_Flag:"downloadFlag",ClientSeq:"clientSequence",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID",ToTopicId:"topicID",InvisibleMsgSeq:"invisibleSequenceList",NextReqMsgSeq:"nextSequence"}}}),this._map.set(di.SET_C2C_MSG_READ,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.SET_C2C_MSG_READ},body:{C2CMsgReaded:void 0},keyMap:{req:{lastMessageTime:"LastedMsgTime"}}}),this._map.set(di.SET_C2C_PEER_MUTE_NOTIFICATIONS,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.SET_C2C_PEER_MUTE_NOTIFICATIONS},body:{userIDList:void 0,muteFlag:0},keyMap:{req:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}),this._map.set(di.GET_C2C_PEER_MUTE_NOTIFICATIONS,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.GET_C2C_PEER_MUTE_NOTIFICATIONS},body:{toAccount:void 0,userIDList:void 0},keyMap:{req:{userIDList:"Peer_Account"},res:{MuteNotificationsList:"muteFlagList"}}}),this._map.set(di.SET_GRP_MSG_READ,{head:{...e,servcmd:T.NAME.GRP+"."+di.SET_GRP_MSG_READ},body:{groupID:void 0,messageReadSeq:void 0,topicID:void 0},keyMap:{req:{messageReadSeq:"MsgReadedSeq"}}}),this._map.set(di.SET_ALL_MSG_READ,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.SET_ALL_MSG_READ},body:{readAllC2CMessage:0,groupMessageReadInfoList:[]},keyMap:{req:{readAllC2CMessage:"C2CReadAllMsg",groupMessageReadInfoList:"GroupReadInfo",messageSequence:"MsgSeq"},res:{C2CReadAllMsg:"readAllC2CMessage",GroupReadInfoArray:"groupMessageReadInfoList"}}}),this._map.set(di.DEL_C2C_MSG,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.DEL_C2C_MSG},body:{fromAccount:"",to:"",keyList:void 0},keyMap:{req:{keyList:"MsgKeyList"}}}),this._map.set(di.DEL_GRP_MSG,{head:{...e,servcmd:T.NAME.GRP+"."+di.DEL_GRP_MSG},body:{groupID:"",deleter:"",keyList:void 0,topicID:void 0},keyMap:{req:{deleter:"Deleter_Account",keyList:"Seqs"}}}),this._map.set(di.TRANSLATE_TEXT,{head:{...e,servcmd:T.NAME.IM_OPEN_TRANSLATE+"."+di.TRANSLATE_TEXT},body:{sourceTextList:void 0,SDKAppID:0,from:0,source:"",target:""},keyMap:{req:{sourceTextList:"SourceText",SDKAppID:"SdkAppId",from:"FromAccount"},res:{TargetText:"translatedTextList",RequestId:"requestID",CmdErrorCode:"error",ErrorCode:"code",ErrorInfo:"message"}}}),this._map.set(di.VOICE_TO_TEXT,{head:{...e,servcmd:T.NAME.IM_OPEN_SPEECH+"."+di.VOICE_TO_TEXT},body:{url:"",SDKAppID:0,format:"",sourceType:0,language:""},keyMap:{req:{url:"BytesUrl",SDKAppID:"Uint32Sdkappid",format:"BytesVoiceFormat",sourceType:"Uint64SourceType",language:"BytesEngServiceType"},res:{BytesRequestid:"requestID",BytesResult:"result",CmdErrorCode:"error",ErrorCode:"code",ErrorInfo:"message"}}}),this._map.set(di.MODIFY_GRP_MSG,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.MODIFY_GRP_MSG},body:{groupID:"",topicID:void 0,sequence:0,version:0,elements:void 0,cloudCustomData:void 0},keyMap:{req:{sequence:"MsgSeq",version:"MsgVersion",type:"MsgType",content:"MsgContent"}}}),this._map.set(di.GET_READ_RECEIPT,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_READ_RECEIPT},body:{groupID:"",sequenceList:void 0},keyMap:{req:{sequence:"MsgSeq"}}}),this._map.set(di.SEND_C2C_READ_RECEIPT,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.SEND_C2C_READ_RECEIPT},body:{peerAccount:"",messageInfoList:void 0},keyMap:{req:{peerAccount:"Peer_Account",messageInfoList:"C2CMsgInfo",fromAccount:"From_Account",toAccount:"To_Account",sequence:"MsgSeq",random:"MsgRandom",time:"MsgTime",clientTime:"MsgClientTime"}}}),this._map.set(di.SEND_READ_RECEIPT,{head:{...e,servcmd:T.NAME.GRP+"."+di.SEND_READ_RECEIPT},body:{groupID:"",sequenceList:void 0},keyMap:{req:{sequenceList:"MsgSeqList",sequence:"MsgSeq"}}}),this._map.set(di.GET_READ_RECEIPT_DETAIL,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_READ_RECEIPT_DETAIL},body:{groupID:"",sequence:void 0,flag:0,cursor:0,count:0},keyMap:{req:{sequence:"MsgSeq",count:"Num"},res:{ReadList:"readUserIDList",Read_Account:"userID",UnreadList:"unreadUserIDList",Unread_Account:"userID",IsFinish:"isCompleted"}}}),this._map.set(di.GET_GRP_RECEIPTS_BY_USERS,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_GRP_RECEIPTS_BY_USERS},body:{groupID:"",dataList:void 0},keyMap:{req:{dataList:"MemberReadMsgList",sequence:"MsgSeq",userIDList:"MemberList_Account"},res:{MsgReadList:"dataList",Read_Account:"userID",Read_Time:"readTime"}}}),this._map.set(di.MODIFY_C2C_MSG_EXT,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.MODIFY_C2C_MSG_EXT},body:{from:void 0,to:void 0,messageKey:void 0,operateType:void 0,extensionList:void 0}}),this._map.set(di.GET_C2C_MSG_EXT,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.GET_C2C_MSG_EXT},body:{from:void 0,to:void 0,messageKey:void 0,startSequence:void 0}}),this._map.set(di.MODIFY_GRP_MSG_EXT,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.MODIFY_GRP_MSG_EXT},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,operateType:void 0,extensionList:void 0}}),this._map.set(di.GET_GRP_MSG_EXT,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.GET_GRP_MSG_EXT},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,startSequence:void 0}}),this._map.set(di.ADD_C2C_MSG_REACTION,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.ADD_C2C_MSG_REACTION},body:{from:void 0,to:void 0,reactionID:void 0,messageKey:void 0,userIDList:void 0},keyMap:{req:{userIDList:"Add_Account"}}}),this._map.set(di.RM_C2C_MSG_REACTION,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.RM_C2C_MSG_REACTION},body:{from:void 0,to:void 0,reactionID:void 0,messageKey:void 0,userIDList:void 0},keyMap:{req:{userIDList:"Del_Account"}}}),this._map.set(di.GET_C2C_MSG_REACTIONS,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.GET_C2C_MSG_REACTIONS},body:{from:void 0,to:void 0,messageKeyList:void 0,count:void 0}}),this._map.set(di.GET_C2C_MSG_REACTION_USER_LIST,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.GET_C2C_MSG_REACTION_USER_LIST},body:{from:void 0,to:void 0,reactionID:void 0,messageKey:void 0,count:void 0}}),this._map.set(di.ADD_GRP_MSG_REACTION,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.ADD_GRP_MSG_REACTION},body:{groupID:void 0,topicID:void 0,reactionID:void 0,messageSequence:void 0,userIDList:void 0},keyMap:{req:{userIDList:"Add_Account"}}}),this._map.set(di.RM_GRP_MSG_REACTION,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.RM_GRP_MSG_REACTION},body:{groupID:void 0,topicID:void 0,reactionID:void 0,messageSequence:void 0,userIDList:void 0},keyMap:{req:{userIDList:"Del_Account"}}}),this._map.set(di.GET_GRP_MSG_REACTIONS,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.GET_GRP_MSG_REACTIONS},body:{groupID:void 0,topicID:void 0,messageSequenceList:void 0,count:void 0},keyMap:{res:{MsgSeq:"messageSequence"}}}),this._map.set(di.GET_GRP_MSG_REACTION_USER_LIST,{head:{...e,servcmd:T.NAME.OPEN_IM_MSG_EXT+"."+di.GET_GRP_MSG_REACTION_USER_LIST},body:{groupID:void 0,topicID:void 0,reactionID:void 0,messageSequence:void 0,nextSeq:void 0,count:void 0}}),this._map.set(di.GET_C2C_PEER_READ_TIME,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.GET_C2C_PEER_READ_TIME},body:{userIDList:void 0},keyMap:{req:{userIDList:"To_Account"},res:{ReadTime:"peerReadTimeList"}}}),this._map.set(di.PAGING_GET_CONV_LIST,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.PAGING_GET_CONV_LIST},body:{fromAccount:void 0,timeStamp:void 0,startIndex:void 0,pinnedTimeStamp:void 0,pinnedStartIndex:void 0,orderType:void 0,messageAssistFlag:15,assistFlag:31},keyMap:{req:{messageAssistFlag:"MsgAssistFlags",assistFlag:"AssistFlags",pinnedTimeStamp:"TopTimeStamp",pinnedStartIndex:"TopStartIndex"},res:{SessionItem:"conversations",ToAccount:"groupID",To_Account:"userID",UnreadMsgCount:"unreadCount",MsgGroupReadedSeq:"messageReadSeq",C2cPeerReadTime:"c2cPeerReadTime",LastMsgFlags:"lastMessageFlag",TopFlags:"isPinned",TopTimeStamp:"pinnedTimeStamp",TopStartIndex:"pinnedStartIndex",GroupId:"convGroupID",C2cRemark:"friendRemark",MsgRecvOption:"messageRemindType",GroupIgnoredUnreadSeqCount:"noUnreadCount",GroupNextMsgSeq:"nextMessageSeq"}}}),this._map.set(di.DEL_CONV,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.DEL_CONV},body:{fromAccount:"",conversationList:void 0,clearHistoryMessage:void 0},keyMap:{req:{toGroupID:"ToGroupid",clearHistoryMessage:"ClearRamble",conversationList:"ContactItem"},res:{ResultItem:"resultList",ToGroupid:"groupID",ResultCode:"code",ResultInfo:"info"}}}),this._map.set(di.CLEAR_HISTORY_MSG,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.CLEAR_HISTORY_MSG},body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0},keyMap:{req:{toGroupID:"ToGroupid"}}}),this._map.set(di.PIN_CONV,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.PIN_CONV},body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{req:{itemList:"RecentContactItem"}}}),this._map.set(di.DEL_GROUP_AT_TIPS,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.DEL_GROUP_AT_TIPS},body:{messageListToDelete:void 0},keyMap:{req:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}),this._map.set(di.SET_CONV_CUSTOM_DATA,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.MARK_CONV},body:{fromAccount:"",itemList:void 0},keyMap:{req:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},res:{ToGroupId:"groupID",OptType:"operationType"}}}),this._map.set(di.MARK_CONV,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.MARK_CONV},body:{fromAccount:"",itemList:void 0},keyMap:{req:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},res:{ToGroupId:"groupID",OptType:"operationType"}}}),this._map.set(di.CREATE_CONV_GRP,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.CREATE_CONV_GRP},body:{fromAccount:"",itemList:void 0},keyMap:{req:{itemList:"GroupContactItem",groupID:"ToGroupId"},res:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType"}}}),this._map.set(di.DEL_CONV_GRP,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.DEL_CONV_GRP},body:{fromAccount:"",groupName:void 0},keyMap:{res:{GroupId:"convGroupID"}}}),this._map.set(di.RENAME_CONV_GRP,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.RENAME_CONV_GRP},body:{fromAccount:"",updateType:void 0,updateGroup:void 0},keyMap:{req:{oldName:"OldGroupName",newName:"NewGroupName",groupID:"ToGroupId",operationType:"ContactOptType",groupName:"OldGroupName",updateItem:"ContactUpdateItem"},res:{ContactOptType:"operationType",ToGroupId:"groupID",GroupId:"convGroupID"}}}),this._map.set(di.ADD_CONV_TO_GRP,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.RENAME_CONV_GRP},body:{fromAccount:"",updateType:void 0,updateGroup:{groupName:void 0,updateGroupType:void 0,updateItem:void 0}}}),this._map.set(di.DEL_CONV_FROM_GRP,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.RENAME_CONV_GRP},body:{fromAccount:"",updateType:void 0,updateGroup:void 0}}),this._map.set(di.GET_CONV_GRP_LIST,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.GET_CONV_GRP_LIST},body:{fromAccount:"",startIndex:void 0},keyMap:{res:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType",CustomMark:"customData",ContactGroupId:"convGroupIDList"}}}),this._map.set(di.SEARCH_CONV_GRP_MARK,{head:{...e,servcmd:T.NAME.RECENT_CONTACT+"."+di.SEARCH_CONV_GRP_MARK},body:{fromAccount:"",contactItem:void 0},keyMap:{req:{groupID:"ToGroupId"},res:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType",CustomMark:"customData",ContactGroupId:"convGroupIDList",ContactResultItem:"contactItem"}}}),this._map.set(di.GET_USER_PROFILE,{head:{...e,servcmd:T.NAME.PROFILE+"."+di.GET_USER_PROFILE},body:{fromAccount:"",userItem:[]},keyMap:{req:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}),this._map.set(di.UPDATE_MY_PROFILE,{head:{...e,servcmd:T.NAME.PROFILE+"."+di.UPDATE_MY_PROFILE},body:{fromAccount:"",profileItem:[{tag:Se.NICK,value:""},{tag:Se.GENDER,value:""},{tag:Se.ALLOWTYPE,value:""},{tag:Se.AVATAR,value:""}]},keyMap:{req:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}),this._map.set(di.GET_BL,{head:{...e,servcmd:T.NAME.FD+"."+di.GET_BL},body:{fromAccount:"",startIndex:0,maxLimited:30}}),this._map.set(di.ADD_TO_BL,{head:{...e,servcmd:T.NAME.FD+"."+di.ADD_TO_BL},body:{fromAccount:"",toAccount:[]}}),this._map.set(di.RM_FROM_BL,{head:{...e,servcmd:T.NAME.FD+"."+di.RM_FROM_BL},body:{fromAccount:"",toAccount:[]}}),this._map.set(di.SET_SELF_STATUS,{head:{...e,servcmd:T.NAME.IM_OPEN_STATUS+"."+di.SET_SELF_STATUS},body:{customStatus:""}}),this._map.set(di.GET_USER_STATUS,{head:{...e,servcmd:T.NAME.IM_OPEN_STATUS+"."+di.GET_USER_STATUS},body:{userIDList:void 0},keyMap:{res:{UserStatusList:"successUserList",ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID",Status:"statusType"}}}),this._map.set(di.SUB_USER_STATUS,{head:{...e,servcmd:T.NAME.IM_OPEN_STATUS+"."+di.SUB_USER_STATUS},body:{userIDList:void 0},keyMap:{res:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}),this._map.set(di.UNSUB_USER_STATUS,{head:{...e,servcmd:T.NAME.IM_OPEN_STATUS+"."+di.UNSUB_USER_STATUS},body:{userIDList:void 0,unsubscribeAll:void 0},keyMap:{res:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}),this._map.set(di.GET_FD_LIST,{head:{...e,servcmd:T.NAME.FD+"."+di.GET_FD_LIST},body:{fromAccount:"",startIndex:0,standardSequence:0,customSequence:0},keyMap:{res:{FriendNum:"friendCount",UserDataItem:"resultList",ValueItem:"tagValueList"}}}),this._map.set(di.ADD_FD,{head:{...e,servcmd:T.NAME.FD+"."+di.ADD_FD},body:{fromAccount:"",addFriendItem:[],type:""},keyMap:{req:{source:"AddSource",wording:"AddWording",type:"AddType"},res:{ResultItem:"resultList"}}}),this._map.set(di.UPDATE_FD,{head:{...e,servcmd:T.NAME.FD+"."+di.UPDATE_FD},body:{fromAccount:"",updateItem:void 0},keyMap:{req:{snsItem:"SnsItem"},res:{ResultItem:"resultList"}}}),this._map.set(di.DEL_FD,{head:{...e,servcmd:T.NAME.FD+"."+di.DEL_FD},body:{fromAccount:"",userIDList:[],type:""},keyMap:{req:{type:"DeleteType"},res:{ResultItem:"resultList"}}}),this._map.set(di.GET_FD_PROFILE,{head:{...e,servcmd:T.NAME.FD+"."+di.GET_FD_PROFILE},body:{fromAccount:"",userIDList:void 0},keyMap:{res:{InfoItem:"resultList",SnsProfileItem:"tagValueList"}}}),this._map.set(di.CHECK_FD,{head:{...e,servcmd:T.NAME.FD+"."+di.CHECK_FD},body:{fromAccount:"",userIDList:[],type:""},keyMap:{req:{type:"CheckType"},res:{InfoItem:"resultList"}}}),this._map.set(di.GET_FD_APPLICATION_LIST,{head:{...e,servcmd:T.NAME.FD+"."+di.GET_FD_APPLICATION_LIST},body:{fromAccount:"",applicationType:"",startTime:0,maxLimited:0,lastSequence:0},keyMap:{res:{PendencyItem:"resultList",AddSource:"source",AddTime:"time",AddWording:"wording",Image:"avatar",UnreadPendencyCount:"unreadCount",To_Account:"userID",PendencyType:"type"}}}),this._map.set(di.RESPOND_FD_APPLICATION,{head:{...e,servcmd:T.NAME.FD+"."+di.RESPOND_FD_APPLICATION},body:{fromAccount:"",responseFriendItem:[]},keyMap:{req:{tag:"TagName",action:"ResponseAction"},res:{ResultItem:"resultList"}}}),this._map.set(di.DEL_FD_APPLICATION,{head:{...e,servcmd:T.NAME.FD+"."+di.DEL_FD_APPLICATION},body:{fromAccount:"",type:"",userIDList:void 0},keyMap:{req:{type:"PendencyType",userIDList:"To_Account"},res:{ResultItem:"resultList"}}}),this._map.set(di.REPORT_FD_APPLICATION,{head:{...e,servcmd:T.NAME.FD+"."+di.REPORT_FD_APPLICATION},body:{fromAccount:"",latestTimeStamp:""},keyMap:{req:{latestTimeStamp:"LatestPendencyTimeStamp"}}}),this._map.set(di.CREATE_FD_GRP,{head:{...e,servcmd:T.NAME.FD+"."+di.CREATE_FD_GRP},body:{fromAccount:"",groupName:void 0,userIDList:void 0},keyMap:{req:{groupName:"GroupName",userIDList:"To_Account"},res:{ResultItem:"resultList"}}}),this._map.set(di.DEL_FD_GRP,{head:{...e,servcmd:T.NAME.FD+"."+di.DEL_FD_GRP},body:{fromAccount:"",nameList:void 0},keyMap:{req:{nameList:"GroupName"}}}),this._map.set(di.GET_FD_GRP_LIST,{head:{...e,servcmd:T.NAME.FD+"."+di.GET_FD_GRP_LIST},body:{fromAccount:"",lastSequence:0,needFriend:"Need_Friend_Type_Yes"},keyMap:{res:{ResultItem:"resultList",GroupName:"name",FriendNumber:"friendCount",To_Account:"userIDList"}}}),this._map.set(di.UPDATE_FD_GRP,{head:{...e,servcmd:T.NAME.FD+"."+di.UPDATE_FD_GRP},body:{fromAccount:"",oldName:"",newName:void 0,updateGroupItem:void 0},keyMap:{req:{oldName:"GroupOldName",newName:"GroupNewName"},res:{UpdateType:"type",ResultItem:"resultList"}}}),this._map.set(di.GET_GRP_LIST,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_GRP_LIST},body:{memberAccount:"",limit:void 0,offset:void 0,groupType:void 0,responseFilter:{groupBaseInfoFilter:void 0,selfInfoFilter:void 0},isSupportTopic:0,needAppDefineData:1},keyMap:{req:{memberAccount:"Member_Account"},res:{GroupIdList:"groups",MsgSeq:"readedSequence",LastRecallTime:"_lastRevokedTime",AppDefinedData:"groupCustomField"}}}),this._map.set(di.GET_GRP_PROFILE,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_GRP_PROFILE},body:{groupIDList:void 0,responseFilter:{groupBaseInfoFilter:void 0,groupCustomFieldFilter:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0}},keyMap:{req:{groupIDList:"GroupIdList",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData",groupCustomFieldFilter:"AppDefinedDataFilter_Group",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},res:{GroupIdList:"groups",AppDefinedData:"groupCustomField",AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_Group:"groupCustomFieldFilter",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",InfoSeq:"infoSequence",MemberList:"members",GroupInfo:"groups",ShutUpUntil:"muteUntil",ShutUpAllMember:"muteAllMembers"}}}),this._map.set(di.CREATE_GRP,{head:{...e,servcmd:T.NAME.GRP+"."+di.CREATE_GRP},body:{type:void 0,name:void 0,groupID:void 0,ownerID:void 0,introduction:void 0,notification:void 0,maxMemberNum:void 0,joinOption:void 0,memberList:void 0,groupCustomField:void 0,memberCustomField:void 0,webPushFlag:1,avatar:"",isSupportTopic:void 0,inviteOption:void 0},keyMap:{req:{ownerID:"Owner_Account",userID:"Member_Account",avatar:"FaceUrl",maxMemberNum:"MaxMemberCount",joinOption:"ApplyJoinOption",groupCustomField:"AppDefinedData",memberCustomField:"AppMemberDefinedData",inviteOption:"InviteJoinOption"},res:{HugeGroupFlag:"avChatRoomFlag",OverJoinedGroupLimit_Account:"overLimitUserIDList"}}}),this._map.set(di.DISMISS_GRP,{head:{...e,servcmd:T.NAME.GRP+"."+di.DISMISS_GRP},body:{groupID:void 0}}),this._map.set(di.UPDATE_GRP_PROFILE,{head:{...e,servcmd:T.NAME.GRP+"."+di.UPDATE_GRP_PROFILE},body:{groupID:void 0,name:void 0,introduction:void 0,notification:void 0,avatar:void 0,joinOption:void 0,groupCustomField:void 0,muteAllMembers:void 0,inviteOption:void 0},keyMap:{req:{groupCustomField:"AppDefinedData",muteAllMembers:"ShutUpAllMember",joinOption:"ApplyJoinOption",avatar:"FaceUrl",inviteOption:"InviteJoinOption"},res:{AppDefinedData:"groupCustomField",ShutUpAllMember:"muteAllMembers"}}}),this._map.set(di.APPLY_JOIN_GRP,{head:{...e,servcmd:T.NAME.GRP+"."+di.APPLY_JOIN_GRP},body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1,historyMessageFlag:void 0},keyMap:{req:{applyMessage:"ApplyMsg",historyMessageFlag:"HugeGroupHistoryMsgFlag"},res:{HugeGroupFlag:"avChatRoomFlag",AVChatRoomKey:"avChatRoomKey",RspMsgList:"messageList",ToGroupId:"to"}}}),this._map.set(di.APPLY_JOIN_GRP_NOAUTH,function(){let{a2:t,tinyid:s,...i}=e;return{head:{...i,servcmd:T.NAME.BIG_GRP_NO_AUTH+"."+di.APPLY_JOIN_GRP},body:{groupID:void 0,applyMessage:void 0,userDefinedField:void 0,webPushFlag:1},keyMap:{req:{applyMessage:"ApplyMsg"},res:{HugeGroupFlag:"avChatRoomFlag"}}}}()),this._map.set(di.QUIT_GRP,{head:{...e,servcmd:T.NAME.GRP+"."+di.QUIT_GRP},body:{groupID:void 0}}),this._map.set(di.SEARCH_GRP,{head:{...e,servcmd:T.NAME.GRP+"."+di.SEARCH_GRP},body:{groupIDList:void 0,responseFilter:{groupBasePublicInfoFilter:["Type","Name","Introduction","Notification","FaceUrl","CreateTime","Owner_Account","LastInfoTime","LastMsgTime","NextMsgSeq","MemberNum","MaxMemberNum","ApplyJoinOption","InviteJoinOption"]}}}),this._map.set(di.CHANGE_GRP_OWNER,{head:{...e,servcmd:T.NAME.GRP+"."+di.CHANGE_GRP_OWNER},body:{groupID:void 0,newOwnerID:void 0},keyMap:{req:{newOwnerID:"NewOwner_Account"}}}),this._map.set(di.HANDLE_GRP_APPLICATION,{head:{...e,servcmd:T.NAME.GRP+"."+di.HANDLE_GRP_APPLICATION},body:{groupID:void 0,applicant:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{req:{applicant:"Applicant_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}),this._map.set(di.HANDLE_INVITE_JOIN_GRP,{head:{...e,servcmd:T.NAME.GRP+"."+di.HANDLE_INVITE_JOIN_GRP},body:{groupID:void 0,applicant:void 0,invitee:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,userDefinedField:void 0},keyMap:{req:{applicant:"Applicant_Account",invitee:"Invited_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg"}}}),this._map.set(di.HANDLE_GRP_INVITATION,{head:{...e,servcmd:T.NAME.GRP+"."+di.HANDLE_GRP_INVITATION},body:{groupID:void 0,inviter:void 0,handleAction:void 0,handleMessage:void 0,authentication:void 0,messageKey:void 0,userDefinedField:void 0},keyMap:{req:{inviter:"Inviter_Account",handleAction:"HandleMsg",handleMessage:"ApprovalMsg",messageKey:"MsgKey"}}}),this._map.set(di.GET_GRP_PENDENCY,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_GRP_PENDENCY},body:{startTime:void 0,limit:void 0,handleAccount:void 0},keyMap:{req:{handleAccount:"Handle_Account"},res:{To_Account:"userID",ApplyInviteMsg:"note"}}}),this._map.set(di.DEL_GRP_SYSTEM_NOTICE,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.DEL_GRP_SYSTEM_NOTICE},body:{messageListToDelete:void 0},keyMap:{req:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}),this._map.set(di.AV_POLLING,{head:{...e,servcmd:T.NAME.BIG_GRP_POLLING+"."+di.AV_POLLING},body:{USP:1,startSeq:1,startBroadcastSeq:void 0,holdTime:90,key:void 0,simplifiedMessage:void 0},keyMap:{req:{USP:"USP"},res:{ToGroupId:"groupID",RspBroadcastMsgList:"broadcastMessageList",IsSystemMsg:"isSystemMessage"}}}),this._map.set(di.AV_NOAUTH_POLLING,function(){let{a2:t,tinyid:s,...i}=e;return{head:{...i,servcmd:T.NAME.BIG_GRP_POLLING_NO_AUTH+"."+di.AV_POLLING},body:{USP:1,startSeq:1,holdTime:90,key:void 0,simplifiedMessage:void 0},keyMap:{req:{USP:"USP"},res:{ToGroupId:"groupID",RspBroadcastMsgList:"broadcastMessageList",IsSystemMsg:"isSystemMessage"}}}}()),this._map.set(di.GET_ONLINE_MBR_NUM,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_ONLINE_MBR_NUM},body:{groupID:void 0},keyMap:{res:{OnlineMemberNum:"memberCount"}}}),this._map.set(di.SET_GRP_ATTR,{head:{...e,servcmd:T.NAME.GRP+"."+di.SET_GRP_ATTR},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{req:{key:"key",value:"value"}}}),this._map.set(di.MODIFY_GRP_ATTR,{head:{...e,servcmd:T.NAME.GRP+"."+di.MODIFY_GRP_ATTR},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{req:{key:"key",value:"value"}}}),this._map.set(di.DEL_GRP_ATTR,{head:{...e,servcmd:T.NAME.GRP+"."+di.DEL_GRP_ATTR},body:{groupID:void 0,groupAttributeList:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]},keyMap:{req:{key:"key"}}}),this._map.set(di.CLEAR_GRP_ATTR,{head:{...e,servcmd:T.NAME.GRP+"."+di.CLEAR_GRP_ATTR},body:{groupID:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]}}),this._map.set(di.GET_GRP_ATTR,{head:{...e,servcmd:T.NAME.GRP_ATTR+"."+di.GET_GRP_ATTR},body:{groupID:void 0,avChatRoomKey:void 0,groupType:1},keyMap:{req:{avChatRoomKey:"Key",groupType:"GroupType"}}}),this._map.set(di.GET_GRP_NOTIFY,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_GRP_NOTIFY},body:{notifyReqList:[]},keyMap:{req:{notifyReqList:"NotifyReqList"},res:{NextMsgTime:"nextRevokedTime",NotifyMsgList:"notifyList",NotifyRspList:"notifyRspList"}}}),this._map.set(di.UPDATE_GRP_COUNTER,{head:{...e,servcmd:T.NAME.GRP+"."+di.UPDATE_GRP_COUNTER},body:{groupID:void 0,counterList:void 0,avChatRoomKey:void 0,mode:void 0},keyMap:{req:{counterList:"GroupCounter"}}}),this._map.set(di.GET_GRP_COUNTER,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_GRP_COUNTER},body:{groupID:void 0,keyList:[],avChatRoomKey:void 0},keyMap:{req:{keyList:"GroupCounterKeys"}}}),this._map.set(di.CREATE_TOPIC,{head:{...e,servcmd:T.NAME.GRP_COMMUNITY+"."+di.CREATE_TOPIC},body:{groupID:void 0,topicName:void 0,avatar:void 0,customData:void 0,topicID:void 0,notification:void 0,introduction:void 0},keyMap:{req:{avatar:"FaceUrl"}}}),this._map.set(di.DEL_TOPIC,{head:{...e,servcmd:T.NAME.GRP_COMMUNITY+"."+di.DEL_TOPIC},body:{groupID:void 0,topicIDList:void 0},keyMap:{req:{topicIDList:"TopicIdList"},res:{DestroyResultItem:"resultList"}}}),this._map.set(di.UPDATE_TOPIC_PROFILE,{head:{...e,servcmd:T.NAME.GRP_COMMUNITY+"."+di.UPDATE_TOPIC_PROFILE},body:{groupID:void 0,topicID:void 0,avatar:void 0,customData:void 0,notification:void 0,introduction:void 0,muteAllMembers:void 0,topicName:void 0},keyMap:{req:{avatar:"FaceUrl",muteAllMembers:"ShutUpAllMember"}}}),this._map.set(di.GET_TOPIC_LIST,{head:{...e,servcmd:T.NAME.GRP_COMMUNITY+"."+di.GET_TOPIC_LIST},body:{groupID:void 0,topicIDList:void 0,MemberInfoFilter:["NoUnreadSeqList"]},keyMap:{req:{topicIDList:"TopicIdList"},res:{TopicAndSelfInfo:"topicInfoList",TopicInfo:"topic",GroupID:"groupID",ShutUpTime:"muteTime",ShutUpAllFlag:"muteAllMembers",LastMsgTime:"lastMessageTime",MsgSeq:"readedSequence",LastMsgSeq:"sequence"}}}),this._map.set(di.GET_GRP_MBR_LIST,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_GRP_MBR_LIST},body:{groupID:void 0,limit:0,offset:void 0,next:void 0,memberRoleFilter:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMap:{req:{memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},res:{AppMemberDefinedData:"memberCustomField",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",MemberList:"members",ShutUpUntil:"muteUntil"}}}),this._map.set(di.GET_AV_MBR_LIST,{head:{...e,servcmd:T.NAME.GRP_AV+"."+di.GET_AV_MBR_LIST},body:{groupID:void 0,offset:void 0,filter:void 0},keyMap:{req:{offset:"Timestamp",filter:"Mark"},res:{NextTimestamp:"offset"}}}),this._map.set(di.GET_GRP_MBR_PROFILE,{head:{...e,servcmd:T.NAME.GRP+"."+di.GET_GRP_MBR_PROFILE},body:{groupID:void 0,userIDList:void 0,memberInfoFilter:void 0,memberCustomFieldFilter:void 0},keyMap:{req:{userIDList:"Member_List_Account",memberCustomFieldFilter:"AppDefinedDataFilter_GroupMember"},res:{MemberList:"members",ShutUpUntil:"muteUntil",AppDefinedDataFilter_GroupMember:"memberCustomFieldFilter",AppMemberDefinedData:"memberCustomField"}}}),this._map.set(di.ADD_GRP_MBR,{head:{...e,servcmd:T.NAME.GRP+"."+di.ADD_GRP_MBR},body:{groupID:void 0,silence:void 0,userIDList:void 0},keyMap:{req:{userID:"Member_Account",userIDList:"MemberList"},res:{MemberList:"members"}}}),this._map.set(di.DEL_GRP_MBR,{head:{...e,servcmd:T.NAME.GRP+"."+di.DEL_GRP_MBR},body:{groupID:void 0,userIDList:void 0,reason:void 0},keyMap:{req:{userIDList:"MemberToDel_Account"}}}),this._map.set(di.BAN_AV_MBR,{head:{...e,servcmd:T.NAME.GRP+"."+di.BAN_AV_MBR},body:{groupID:void 0,userIDList:void 0,duration:void 0,reason:""},keyMap:{req:{userIDList:"Members_Account",duration:"Duration",reason:"Description"}}}),this._map.set(di.MODIFY_GRP_MBR_INFO,{head:{...e,servcmd:T.NAME.GRP+"."+di.MODIFY_GRP_MBR_INFO},body:{groupID:void 0,topicID:void 0,userID:void 0,messageRemindType:void 0,nameCard:void 0,role:void 0,memberCustomField:void 0,muteTime:void 0},keyMap:{req:{userID:"Member_Account",memberCustomField:"AppMemberDefinedData",muteTime:"ShutUpTime",messageRemindType:"MsgFlag"}}}),this._map.set(di.MARK_AV_MBR_INFO,{head:{...e,servcmd:T.NAME.GRP_AV+"."+di.MARK_AV_MBR_INFO},body:{groupID:void 0,operationType:1,memberList:[]},keyMap:{req:{operationType:"CommandType",memberList:"MemberList",markType:"Marks",userID:"Member_Account"},res:{CommandType:"operationType",Marks:"markType",Member_Account:"userID"}}}),this._map.set(di.CS,{head:{...e,servcmd:T.NAME.MSG_SEARCH+"."+di.CS},body:{keywordList:void 0,keywordListMatchType:"or",account:void 0,groupID:void 0,count:100,cursor:void 0,messageTypeList:void 0,senderUserIDList:void 0,startTime:void 0,endTime:void 0},keyMap:{req:{keywordListMatchType:"MatchType",account:"PeerAccount",groupID:"GroupID",messageTypeList:"MsgTypeList",senderUserIDList:"SendUserIDList",keywords:"Keywords",keywordMatchType:"KeywordMatchType",count:"Count",miniBirthday:"UserBirthStart",maxBirthday:"UserBirthEnd",gender:"UserGenderType",groupTypeList:"GroupType",groupIDList:"GroupIdList"},res:{GroupID:"groupID",UserID:"userID",ErrorCode:"code",ErrorInfo:"message",TotalCount:"totalCount",Count:"messageCount",LastMsgTime:"lastMessageTime",ConversationMsgs:"searchResult",IsNeedReadReceipt:"needReadReceipt",IsPeerRead:"readReceiptSentByPeer",MsgSeq:"sequence",ReqMsgSeq:"sequence",IsSystemMsg:"isSystemMessage",ToGroupId:"to",EnumFrom_AccountType:"fromAccountType",EnumTo_AccountType:"toAccountType",GroupCode:"groupCode",MsgContent:"content",ClientSeq:"clientSequence",ToTopicId:"topicID",InvisibleMsgSeq:"invisibleSequenceList",Users:"userList",ProfileItems:"profileItems",StrValue:"value",IntValue:"value",Groups:"groupList",GroupFaceUrl:"avatar",GroupIntroduction:"introduction",GroupOwnerUserID:"ownerID",GroupOwnerUserName:"ownerNick",GroupOwnerTinyID:"ownerTinyID",GroupMemberNum:"memberNum",GroupName:"name",GroupType:"type",GroupMembers:"groupMemberList",GroupMemberUserID:"userID",GroupMemberTinyID:"userTinyID",GroupMemberUserName:"nick",GroupMemberNameCard:"nameCard"}}}),this._map.set(di.USER_CS,{head:{...e,servcmd:T.NAME.USER_SEARCH+"."+di.CS},body:{keywords:void 0,keywordMatchType:0,miniBirthday:void 0,maxBirthday:void 0,gender:void 0,count:20,cursor:void 0}}),this._map.set(di.GRP_CS,{head:{...e,servcmd:T.NAME.GRP_SEARCH+"."+di.CS},body:{keywords:void 0,keywordMatchType:0,groupType:void 0,count:20,cursor:void 0}}),this._map.set(di.MBR_CS,{head:{...e,servcmd:T.NAME.GRP_MEMBER_SEARCH+"."+di.CS},body:{keywords:void 0,keywordMatchType:0,groupType:void 0,groupIDList:void 0,count:20,cursor:void 0}}),this._map.set(di.SSO_STAT,{head:{...s,servcmd:T.NAME.IM_OPEN_STAT+"."+di.SSO_STAT},body:{header:{},event:[],quality:[]},keyMap:{req:{SDKType:"sdk_type",SDKVersion:"sdk_version",deviceType:"device_type",platform:"platform",instanceID:"instance_id",traceID:"trace_id",SDKAppID:"sdk_app_id",userID:"user_id",tinyID:"tiny_id",extension:"extension",timestamp:"timestamp",networkType:"network_type",eventType:"event_type",code:"error_code",message:"error_message",moreMessage:"more_message",duplicate:"duplicate",costTime:"cost_time",level:"level",qualityType:"quality_type",reportIndex:"report_index",wholePeriod:"whole_period",totalCount:"total_count",rttCount:"success_count_business",successRateOfRequest:"percent_business",countLessThan1Second:"success_count_business",percentOfCountLessThan1Second:"percent_business",countLessThan3Second:"success_count_platform",percentOfCountLessThan3Second:"percent_platform",successCountOfBusiness:"success_count_business",successRateOfBusiness:"percent_business",successCountOfPlatform:"success_count_platform",successRateOfPlatform:"percent_platform",successCountOfMessageReceived:"success_count_business",successRateOfMessageReceived:"percent_business",avgRTT:"average_value",avgDelay:"average_value",avgValue:"average_value",uiPlatform:"ui_platform"}}}),this._map.set(di.PING,{head:{...e,servcmd:T.NAME.HEARTBEAT+"."+di.PING},body:{}}),this._map.set(di.MSG_PUSH,{head:{...e,servcmd:T.NAME.IM_OPEN_PUSH+"."+di.MSG_PUSH},body:{},keyMap:{res:{C2cMsgArray:"C2CMessageArray",GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",C2cNotifyMsgArray:"C2CNotifyMessageArray",C2cMsgInfo:"C2CReadReceiptArray",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyAdd_Account:"userID",ProfileImNick:"nick",PendencyType:"applicationType",C2CReadAllMsg:"readAllC2CMessage",IsNeedReadReceipt:"needReadReceipt",Status:"statusType"}}}),this._map.set(di.MULTI_MSG_PUSH,{head:{...e,servcmd:T.NAME.IM_OPEN_PUSH+"."+di.MULTI_MSG_PUSH},body:{},keyMap:{res:{GroupMsgArray:"groupMessageArray",GroupTips:"groupTips",ClientSeq:"clientSequence",MsgPriority:"priority",NoticeSeq:"noticeSequence",MsgContent:"content",MsgType:"type",MsgBody:"elements",ToGroupId:"to",Desc:"description",Ext:"extension",IsSyncMsg:"isSyncMessage",Flag:"needSync",NeedAck:"needAck",PendencyType:"applicationType"}}}),this._map.set(di.MSG_PUSH_ACK,{head:{...e,servcmd:T.NAME.OPEN_IM+"."+di.MSG_PUSH_ACK},body:{sessionData:void 0},keyMap:{req:{sessionData:"SessionData"}}}),this._map.set(di.STATUS_FORCE_OFFLINE,{head:{...e,servcmd:T.NAME.IM_OPEN_STATUS+"."+di.STATUS_FORCE_OFFLINE},body:{},keyMap:{res:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}),this._map.set(di.DOWNLOAD_MERGER_MSG,{head:{...e,servcmd:T.NAME.IM_LONG_MSG+"."+di.DOWNLOAD_MERGER_MSG},body:{downloadKey:""},keyMap:{res:{Data:"data",Desc:"description",Ext:"extension",Download_Flag:"downloadFlag",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}}}),this._map.set(di.UPLOAD_MERGER_MSG,{head:{...e,servcmd:T.NAME.IM_LONG_MSG+"."+di.UPLOAD_MERGER_MSG},body:{messageList:[]},keyMap:{req:{fromAccount:"From_Account",toAccount:"To_Account",msgTimeStamp:"MsgTimeStamp",msgSeq:"MsgSeq",msgRandom:"MsgRandom",msgBody:"MsgBody",type:"MsgType",content:"MsgContent",data:"Data",description:"Desc",extension:"Ext",sizeType:"Type",uuid:"UUID",url:"",imageUrl:"URL",fileUrl:"Url",remoteAudioUrl:"Url",remoteVideoUrl:"VideoUrl",thumbUUID:"ThumbUUID",videoUUID:"VideoUUID",videoUrl:"",downloadFlag:"Download_Flag",from:"From_Account",time:"MsgTimeStamp",messageRandom:"MsgRandom",messageSequence:"MsgSeq",elements:"MsgBody",clientSequence:"ClientSeq",payload:"MsgContent",messageList:"MsgList",messageNumber:"MsgNum",abstractList:"AbstractList",messageBody:"MsgBody"}}}),this._map.set(di.FOLLOW,{head:{...e,servcmd:T.NAME.FOLLOW+"."+di.FOLLOW},body:{fromAccount:"",userIDList:[]},keyMap:{req:{userIDList:"FollowItem"},res:{ResultItem:"resultList",To_Account:"userID"}}}),this._map.set(di.UNFOLLOW,{head:{...e,servcmd:T.NAME.FOLLOW+"."+di.UNFOLLOW},body:{fromAccount:"",userIDList:[]},keyMap:{req:{userIDList:"To_Account"},res:{ResultItem:"resultList",To_Account:"userID"}}}),this._map.set(di.GET_FOLLOW_INFO,{head:{...e,servcmd:T.NAME.FOLLOW+"."+di.GET_FOLLOW_INFO},body:{fromAccount:"",userIDList:[]},keyMap:{req:{userIDList:"To_Account"},res:{FollowInfo:"followInfoList",To_Account:"userID",FollowerCount:"followersCount",FollowingCount:"followingCount",MutualFollowingCount:"mutualFollowersCount"}}}),this._map.set(di.GET_FOLLOW,{head:{...e,servcmd:T.NAME.FOLLOW+"."+di.GET_FOLLOW},body:{fromAccount:"",type:1,nextCursor:"",count:500},keyMap:{req:{type:"FollowType",nextCursor:"StartCursor",count:"WantNum"},res:{FollowItem:"resultList",To_Account:"userID",ProfileItem:"profileList"}}}),this._map.set(di.CHECK_FOLLOW_TYPE,{head:{...e,servcmd:T.NAME.FOLLOW+"."+di.CHECK_FOLLOW_TYPE},body:{fromAccount:"",userIDList:[]},keyMap:{req:{userIDList:"To_Account"},res:{ResultItem:"resultList",To_Account:"userID"}}}),this._map.set(di.SET_TOKEN,{head:{...e,servcmd:T.NAME.IM_OPEN_STATUS+"."+di.SET_TOKEN},body:{tokenID:"",pushMsg:0,sdkAppID:0,businessID:"",deviceBrand:"",deviceToken:"",isTpns:0,isWebUniapp:0,notificationStatus:0,deviceModel:"",systemVersion:"",pushVersion:""},keyMap:{req:{tokenID:"TokenID",pushMsg:"PushMsg",sdkAppID:"EnterVersion",businessID:"BusiID",deviceBrand:"InstType",deviceToken:"VarToken",isTpns:"IsTpns",notificationStatus:"NotificationStatus",deviceModel:"DeviceModel",systemVersion:"SystemVersion",pushVersion:"PushPluginVersion"}}}),this._map.set(di.STAT_FOREGROUND,{head:{...e,servcmd:T.NAME.IM_OPEN_STATUS+"."+di.STAT_FOREGROUND},body:{isWebUniapp:0}}),this._map.set(di.STAT_BACKGROUND,{head:{...e,servcmd:T.NAME.IM_OPEN_STATUS+"."+di.STAT_BACKGROUND},body:{C2CUnread:0,GroupUnread:0,isWebUniapp:0},keyMap:{req:{c2cUnreadCount:"C2cUnread",groupUnreadCount:"GrpUnread"}}}),this._map.set(di.PUSH_REPORT,{head:{...e,servcmd:T.NAME.OFFLINE_PUSH_REPORT+"."+di.PUSH_REPORT},body:{eventList:[]},keyMap:{req:{eventList:"UinappPushEvents",type:"EventType",time:"EventTime",pushId:"ClickExt"}}}),this._map.set(di.SET_ALL_RECEIVE_MSG_OPT,{head:{...e,servcmd:T.NAME.IM_MSG_LOGIC+"."+di.SET_ALL_RECEIVE_MSG_OPT},body:{startTime:0,endTime:0,isRepeated:0,messageRemindType:0},keyMap:{req:{messageRemindType:"Level"}}}),this._map.set(di.GET_ALL_RECEIVE_MSG_OPT,{head:{...e,servcmd:T.NAME.IM_MSG_LOGIC+"."+di.GET_ALL_RECEIVE_MSG_OPT},body:{toAccount:void 0}})}has(e){return this._map.has(e)}get(e){return this._map.get(e)}update(){this._fillMap()}getKeyMap(e){return this.has(e)?this.get(e).keyMap||{}:(ye.w(this._n+".getKeyMap unknown P:"+e),{})}getProtocolData(e){let{P:t,data:s}=e,i=this.get(t),o=null;if(s){let e=this._simpleDeepCopy(i),t=this._updateService(s,e),n=t.body,r=Object.create(null);for(let i in n)if(Object.prototype.hasOwnProperty.call(n,i)){if(r[i]=n[i],void 0===s[i])continue;r[i]=s[i]}t.body=r,o=this._getUplinkData(t)}else o=this._getUplinkData(i);return o}_getUplinkData(e){e=this._dataCleaner(e);var t=Ct(e.head);t=sn(e.body,this._getReqKeyMap(t));return e.body=t,e}_updateService(e,t){var s=Ct(t.head);if(this._isFromGroupRequest(t)){let{type:i,groupID:o,groupIDList:n=[]}=e;Be(o)&&(o=n[0]||""),lt({type:i,groupID:o})&&(t.head.servcmd=T.NAME.GRP_COMMUNITY+"."+s)}return t}_isFromGroupRequest(e){return e.head.servcmd.includes(T.NAME.GRP)||e.head.servcmd.includes(T.NAME.GRP_ATTR)}_getReqKeyMap(e){return e=this.getKeyMap(e),{...Qo.req,...e.req}}_dataCleaner(e){var t,s=Array.isArray(e)?[]:Object.create(null);for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&ze(t)&&null!==e[t]&&void 0!==e[t]&&("object"!=typeof e[t]?s[t]=e[t]:s[t]=this._dataCleaner.bind(this)(e[t]));return s}_simpleDeepCopy(e){var t,s=Object.keys(e),i={};for(let o=0,n=s.length;o<n;o++)t=s[o],Ve(e[t])?i[t]=Array.from(e[t]):qe(e[t])?i[t]=this._simpleDeepCopy(e[t]):i[t]=e[t];return i}}let fn=[di.MSG_PUSH_ACK];class In{constructor(e){this._sessionM=e,this._n="MsgDispatcher",this._eventHandlerMap=new Map,this._eventHandlerMap.set("C2CMessageArray",this._onC2CMsgArray.bind(this)),this._eventHandlerMap.set("groupMessageArray",this._onGroupMsgArray.bind(this)),this._eventHandlerMap.set("groupTips",this._onGroupTips.bind(this)),this._eventHandlerMap.set("C2CNotifyMessageArray",this._onC2CNotifyMsgArray.bind(this)),this._eventHandlerMap.set("C2CReadReceiptArray",this._onC2CReadReceiptArray.bind(this)),this._eventHandlerMap.set("profileModify",this._onProfileModified.bind(this)),this._eventHandlerMap.set("friendListMod",this._onRelationChainModified.bind(this)),this._eventHandlerMap.set("recentContactMod",this._onRecentContact.bind(this)),this._eventHandlerMap.set("readAllC2CMessage",this._onAllMsgRead.bind(this)),this._eventHandlerMap.set("c2cMessageModified",this._onC2CMsgModified.bind(this)),this._eventHandlerMap.set("groupMessageModified",this._onGroupMsgModified.bind(this)),this._eventHandlerMap.set("userStatusList",this._onUserStatusList.bind(this)),this._eventHandlerMap.set("messageExtensionNotify",this._onMsgExtNotify.bind(this)),this._eventHandlerMap.set("messageReactionNotifyList",this._onMsgReactionNotifyList.bind(this)),this._eventHandlerMap.set("messageReactionNotify",this._onMsgReactionNotify.bind(this)),this._eventHandlerMap.set("followChangeList",this._onFollowNotify.bind(this)),this._keys=[...this._eventHandlerMap.keys()]}_onC2CMsgArray(e){var t=this._sessionM.get(Ss);e.dataList.forEach((e=>{var t;1===e.isSyncMessage&&(t=e.from,e.from=e.to,e.to=t)})),1===e.needSync&&this._sessionM.get(ws).syncOnNeed(),t.onNewMessage({dataList:e.dataList,isInstantMessage:!0})}_onC2CMsgModified(e){this._sessionM.get(Ss).onMsgModified(e)}_onGroupMsgArray(e){var t=this._sessionM.get(Ds);t&&t.onNewMessage({event:e.event,dataList:e.dataList,isInstantMessage:!0})}_onGroupMsgModified(e){var t=this._sessionM.get(Ds);t&&t.onMsgModified(e)}_onGroupTips(e){var t=this._sessionM.get(Ds);if(t){var{event:s,dataList:i,isInstantMessage:o=!0,isSyncingEnded:n}=e;switch(s){case 4:case 6:t.onNewGroupTips({event:s,dataList:i});break;case 5:for(let e=0;e<i.length;e++)if(Ve(i[e].elements.revokedInfos))t.onMsgRevoked({dataList:i});else if(Ve(i[e].elements.groupMessageReadNotice))t.onMsgReadNotice({dataList:i});else{if(!Ve(i[e].elements.readReceiptList)){t.onNewGroupSystemNotice({dataList:i,isInstantMessage:o,isSyncingEnded:n});break}t.onReadReceiptList({dataList:i})}break;case 12:this._sessionM.get(As).onNewGroupAtTips({dataList:i});break;default:ye.l(this._n+`._onGroupTips unknown event:${s} dataList:`,i)}}}_onC2CNotifyMsgArray(e){let t=e["dataList"];if(Ve(t)){let e=this._sessionM.get(Ss);t.forEach((s=>{if(xe(s))if(s.hasOwnProperty("kickoutMsgNotify")){let{kickoutMsgNotify:{kickType:e,newInstanceInfo:t={}}}=s;1===e?this._sessionM.onMultipleAccountKickedOut(t):2===e?this._sessionM.onMultipleDeviceKickedOut(t):3===e&&this._sessionM.onRestApiKickedOut(t)}else s.hasOwnProperty("c2cMessageRevokedNotify")?e&&e.onMsgRevoked({dataList:t},!0):s.hasOwnProperty("c2cMessageReadReceipt")?e&&e.onMsgReadReceipt({dataList:t}):s.hasOwnProperty("c2cMessageReadNotice")?e&&e.onMsgReadNotice({dataList:t}):s.hasOwnProperty("muteNotificationsSync")&&this._sessionM.get(As).onC2CMsgRemindTypeSynced({dataList:t})}))}}_onC2CReadReceiptArray(e){this._sessionM.get(Ss).onReadReceiptList(e)}_onProfileModified(e){this._sessionM.get(Es).onProfileModified({dataList:e.dataList});var t=this._sessionM.get(Rs);t&&t.onFriendProfileModified({dataList:e.dataList})}_onRelationChainModified(e){this._sessionM.get(Es).onRelationChainModified({dataList:e.dataList});var t=this._sessionM.get(Rs);t&&t.onRelationChainModified({dataList:e.dataList})}_onRecentContact(e){if(e=e.dataList,Ve(e)){let t=this._sessionM.get(As);t&&e.forEach((e=>{let s=e["pushType"];if(1===s){let s=e["recentContactDeleteItem"];t.onConvDeleted(s.recentContactList)}else if(2===s){let s=e["recentContactTopItem"];t.onConvPinnedStatus(s.recentContactList,!0)}else if(3===s){let s=e["recentContactTopItem"];t.onConvPinnedStatus(s.recentContactList,!1)}else if(4===s){let s=e["recentContactMarkContact"];t.onConvMarkUpdated(s.recentContactMarkContactItem)}else if(5===s){let s=e["recentContactCreateContactGroup"];t.onConvGroupCreated(s.msgContactGroupContactItem)}else if(6===s){let s=e["recentContactDelContactGroup"];t.onConvGroupDeleted(s.msgGroupItem)}else if(7===s){let s=e["recentContactUpdateContactGroup"],{updateType:i,msgUpdateGroup:o,msgUpdateContact:n}=s;if(1===i){let e=o["updateGroupType"];1===e?t.onConvGroupNameUpdated(o):2===e&&t.onConvInGroupUpdated(o)}else 2===i&&t.onConvAddedToOrDeletedFromGroup(n)}}))}}_onAllMsgRead(e){e=e["dataList"];var t=this._sessionM.get(As);t&&t.onPushedAllMessageRead(e)}_onUserStatusList(e){this._sessionM.get(Es).onUserStatusUpdated(e)}_onMsgExtNotify(e){this._sessionM.get(ys).onMsgExtNotify(e)}_onMsgReactionNotifyList(e){this._sessionM.get(Js).onReactionNotifyList(e)}_onMsgReactionNotify(e){this._sessionM.get(Js).onReactionNotify(e)}_onFollowNotify(e){this._sessionM.get(Xs).onFollowNotify(e)}_onTopicLatestMsg(e){this._sessionM.get(Ls).onTopicLatestMsg(e)}onMessage(e){var t=e["body"];if(this._filterMsgFromIMOpenPush(e)){var s,i,o,{eventArray:n,isInstantMessage:r,isSyncingEnded:a,needSync:l}=t;if(Ve(n))for(let e=0,t=n.length;e<t;e++)if(100===(o=(s=n[e]).event))this._onRoomCustomData(s.content);else if(24===o)this._onAllRcvMsgOptNotify(s);else if(26===o)this._onTopicLatestMsg(s);else{let e=Object.keys(s).find((e=>-1!==this._keys.indexOf(e)));e?(i=14===o?{readAllC2CMessage:s[e],groupMessageReadInfoList:s.groupMessageReadNotice||[]}:16===o?{userID:s.userID,timestamp:s.timestamp,readReceiptList:s[e]}:s[e],this._eventHandlerMap.get(e)({event:o,dataList:i,isInstantMessage:r,isSyncingEnded:a,needSync:l})):ye.l(this._n+".onMessage unknown eventItem:",s)}}}_onRoomCustomData(e){this._sessionM.get(Ws).onRoomCustomDataReceived(e),ye.l(this._n+"._onRoomCustomData data:"+e)}_onAllRcvMsgOptNotify(e){this._sessionM.get(As).onAllRcvMsgOptNotify(e)}_filterMsgFromIMOpenPush(e){let{head:t,body:s}=e,i=t["servcmd"],o=!1;if(!(o=Be(i)?o:i.includes(T.NAME.IM_CONFIG_MANAGER)||i.includes(T.NAME.OVERLOAD_PUSH)||i.includes(T.NAME.STAT_SERVICE)))return!0;if(i.includes(di.PUSHED_CLOUD_CTRL_CONFIG))this._sessionM.get(qs).onPushedConfig(s);else if(i.includes(di.PUSHED_COMMERCIAL_CONFIG))this._sessionM.get(Ks).onPushedConfig(s);else if(i.includes(di.OVERLOAD_NOTIFY))this._sessionM.onPushedServerOverload(s);else if(i.includes(di.KICK_OTHER)){let e=Date.now(),t=(this._sessionM.reLoginOnKickOther(),new Ei("kickOther")),s=this._sessionM.get(vs).getLastWsHelloTs(),i=e-s;t.setMessage(`last wshello time:${s} diff:${i}ms`).end()}return!1}}let Cn=[{cmd:di.GET_GRP_PROFILE,interval:1,count:8},{cmd:di.UPDATE_GRP_PROFILE,interval:1,count:8},{cmd:di.GET_AV_MBR_LIST,interval:3,count:1},{cmd:di.GET_GRP_PENDENCY,interval:1,count:15},{cmd:di.GET_TOPIC_LIST,interval:1,count:10},{cmd:di.SET_GRP_ATTR,interval:5,count:10},{cmd:di.MODIFY_GRP_ATTR,interval:5,count:10},{cmd:di.DEL_GRP_ATTR,interval:5,count:10},{cmd:di.CLEAR_GRP_ATTR,interval:5,count:10},{cmd:di.GET_GRP_ATTR,interval:5,count:20},{cmd:di.UPDATE_GRP_COUNTER,interval:5,count:20},{cmd:di.GET_GRP_COUNTER,interval:5,count:20},{cmd:di.SET_ALL_MSG_READ,interval:1,count:1},{cmd:di.GET_USER_STATUS,interval:5,count:20},{cmd:di.SUB_USER_STATUS,interval:5,count:20},{cmd:di.UNSUB_USER_STATUS,interval:5,count:20},{cmd:di.CS,interval:5,count:20},{cmd:di.GRP_CS,interval:5,count:20},{cmd:di.MBR_CS,interval:5,count:20},{cmd:di.USER_CS,interval:5,count:20},{cmd:di.CHECK_FOLLOW_TYPE,interval:5,count:20},{cmd:di.GET_GRP_ROAMING_MSG,interval:1,count:20},{cmd:di.GET_C2C_ROAMING_MSG,interval:1,count:20}],vn=new Map,Tn=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let tt=0,kr=Tn.length;tt<kr;tt++)vn.set(tt,Tn[tt]);function yn(e){let t,s,i=e,o="";for(let n=0,r=(i=e.length%8!=0?"0".repeat(8-e.length%8)+e:i).length;n<r;n+=8)t=parseInt(i.slice(n,n+4),2),s=parseInt(i.slice(n+4,n+8),2),o+=vn.get(t)+vn.get(s);return o}class En extends li{constructor(e){super(e),this._n="SessionModule",this._platform=this.getPlatform(),this._pHandler=new Mn(this),this._msgDispatcher=new In(this),this._cmdFreqLimitMap=new Map,this._cmdReqInfoMap=new Map,this._serverOverloadInfoMap=new Map,this._incrementalPullContactFlag=!0,this._init(),this.getIEmitInst().on(Ji.CLOUD_CONFIG,this._onCloudConfig,this)}_init(){this._updateCmdFreqLimitMap(Cn)}_onCloudConfig(){var e=this.getCloudConfig("cmd_frequency_limit");Be(e)||(e=JSON.parse(e),this._updateCmdFreqLimitMap(e))}_updateCmdFreqLimitMap(e){e.forEach((e=>{this._cmdFreqLimitMap.set(e.cmd,{interval:e.interval,count:e.count})}))}updateProtocolConfig(){this._pHandler.update()}req(e){ye.d(this._n+".req options:",e);var t=e["P"];if(!this._pHandler.has(t))return ye.w(this._n+".req unknown P:"+t),ai({code:ii.NO_PROTOCOL});e=this.getProtocolData(e);var s=e.head["servcmd"];let i;return this._isFreqOverLimit(s)?(i=ii.OVER_FREQUENCY_LIMIT,ai({code:i,message:this.getErrMsg(i,this._getCmd(s))})):this._isServerOverload(s)?(i=ii.OPEN_SERVICE_OVERLOAD_ERROR,ai({code:i,message:this.getErrMsg(i,this._getCmd(s))})):(s=this.get(Fs),fn.includes(t)?s.simplySend(e):s.send(e))}getKeyMap(e){return this._pHandler.getKeyMap(e)}genCommonHead(){var e=this.get(Os);return{ver:"v4",platform:this._platform,websdkappid:u,websdkversion:_,a2:e.getA2Key()||void 0,tinyid:e.getTinyID()||void 0,status_instid:e.getStatusInstanceID(),sdkappid:e.getSDKAppID(),contenttype:e.getContentType(),reqtime:0,identifier:e.getA2Key()?void 0:e.getUserID(),usersig:e.getA2Key()?void 0:e.getUserSig(),sdkability:75689843,sdkability_ext:yn(""),cappid:e.getApplicationID(),cs:0}}genCosSpecifiedHead(){var e=this.get(Os);return{ver:"v4",platform:this._platform,websdkappid:u,websdkversion:_,sdkappid:e.getSDKAppID(),contenttype:e.getContentType(),reqtime:0,identifier:e.getUserID(),usersig:e.getUserSig(),status_instid:e.getStatusInstanceID(),sdkability:75689843,sdkability_ext:yn(""),cappid:e.getApplicationID(),cs:0}}genSSOReportHead(){var e=this.get(Os);return{ver:"v4",platform:this._platform,websdkappid:u,websdkversion:_,sdkappid:e.getSDKAppID(),contenttype:"",reqtime:0,identifier:"",usersig:"",status_instid:e.getStatusInstanceID(),sdkability:75689843,sdkability_ext:yn(""),cappid:e.getApplicationID(),cs:0}}getProtocolData(e){return this._pHandler.getProtocolData(e)}trans(e){var{servcmd:e,data:t}=e;e={head:{...this.genCommonHead(),servcmd:e},body:t};return this.get(Fs).send(e)}sendComboMessage(e){var{servcmd:e,data:t}=e;e={head:{...this.genCommonHead(),servcmd:e},body:t};return this.get(Fs).send(e)}onErrorCodeNotZero(e){let t=e["errorCode"];if(t===ii.HELLO_ANSWER_KICKED_OUT){let{kickType:t,newInstanceInfo:s={}}=e;1===t?this.onMultipleAccountKickedOut(s):2===t?this.onMultipleDeviceKickedOut(s):3===t&&this.onRestApiKickedOut(s)}t!==ii.MSG_A2KEY_EXPIRED&&t!==ii.ACCOUNT_A2KEY_EXPIRED||(this._onUserSigExpired(),this.get(Fs).reConnect())}onMessage(e){var t=e["body"],{needAck:t=0,sessionData:s}=t;1===t&&this._sendACK(s),this._msgDispatcher.onMessage(e)}onReconnected(e){this._incrementalPullContactFlag=e<=300,this._reLoginOnReconnected()}reLoginOnKickOther(){ye.l(this._n+".reLoginOnKickOther"),this._reLogin()}_reLoginOnReconnected(){ye.l(this._n+"._reLoginOnReconnected"),this._reLogin()}_reLogin(){let e=this._n+"._reLogin";if(this.isLoggedIn()){let s=0;var t=this.get(vs).getPushModule();t&&(s=t.getUniAppPlatform());let i=new Ei("reLogin");this.req({P:di.LOGIN,data:{isWebUniapp:s,customInfo:this.get(Os).getCustomLoginInfo()}}).then((t=>{var{instanceID:t,customStatus:s}=t.data,n=this.get(Os),r=yo(s),a=(n.setStatusInstanceID(t),this.get(Fs));t=`socketID:${a.getSocketID()} instanceID:${t} customStatus:`+r,i.setMessage(t).end(!0),ye.l(e+" ok. "+t),n.getCustomStatus()!==r&&this.get(Es).onUserStatusUpdated({dataList:[{to:this.getMyUserID(),statusType:o.USER_STATUS_ONLINE,customStatus:s}]}),a.diagnose(),this.get(As).syncConvList(this._incrementalPullContactFlag).then((()=>{ye.l(e+", sync conv list ok."),this.get(Vs).start()})),t=this.get(Ds),t&&t.updateLocalMainSequenceOnReconnected(),n=this.get(Ls),n.resetGetTopicTime(),n.getTopicListOnReconnected(),r=this.get(Xs);r&&r.clearCacheOnReconnected()}))}}onMultipleAccountKickedOut(e){this.get(vs).onMultipleAccountKickedOut(e)}onMultipleDeviceKickedOut(e){this.get(vs).onMultipleDeviceKickedOut(e)}_onUserSigExpired(){this.get(vs).onUserSigExpired()}onRestApiKickedOut(e){this.get(vs).onRestApiKickedOut(e)}_sendACK(e){this.req({P:di.MSG_PUSH_ACK,data:{sessionData:e}})}_isFreqOverLimit(e){if(e=e.split(".")[1],!this._cmdFreqLimitMap.has(e))return!1;if(!this._cmdReqInfoMap.has(e))return this._cmdReqInfoMap.set(e,{startTime:Date.now(),requestCount:1}),!1;var{count:t,interval:s}=this._cmdFreqLimitMap.get(e),{startTime:i,requestCount:o}=this._cmdReqInfoMap.get(e);if(Date.now()-i>1e3*s)return this._cmdReqInfoMap.set(e,{startTime:Date.now(),requestCount:1}),!1;this._cmdReqInfoMap.set(e,{startTime:i,requestCount:o+=1});let n=t<o;return n}_isServerOverload(e){if(!this._serverOverloadInfoMap.has(e))return!1;var{overloadTime:t,waitingTime:s}=this._serverOverloadInfoMap.get(e);return Date.now()-t<=1e3*s||(this._serverOverloadInfoMap.delete(e),!1)}_getCmd(e){let t="";if(e.includes(".")){var s,i=e.split(".")[1];for(s in di)if(di[s]===i){t=s;break}}return t}onPushedServerOverload(e){var{overloadCommand:e,waitingTime:t}=e;this._serverOverloadInfoMap.set(e,{overloadTime:Date.now(),waitingTime:t}),ye.w(this._n+`.onPushedServerOverload waitingTime:${t}s cmd:`+this._getCmd(e))}reset(){ye.l(this._n+".reset"),this._updateCmdFreqLimitMap(Cn),this._cmdReqInfoMap.clear(),this._serverOverloadInfoMap.clear(),this._incrementalPullContactFlag=!0}}class Sn extends li{constructor(e){super(e),this._n="CloudControlModule",this._cloudConfig=new Map,this._expiredTime=0,this._version=0,this._isFetching=!1}getCloudConfig(e){return Be(e)?this._cloudConfig:this._cloudConfig.has(e)?this._cloudConfig.get(e):void 0}getServerConfig(e){var t={code:0,data:""};return!Be(e)&&this._cloudConfig.has(e)&&(t.data=this._cloudConfig.get(e)),Promise.resolve(t)}_canFetch(){return this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime}fetchConfig(){let e=this._n+".fetchConfig",t=this._canFetch();if(ye.l(e+" canFetch:"+t),t){let t=new Ei("fetchCloudCtrlConfig"),s=this.get(Os).getSDKAppID();this._isFetching=!0,this.req({P:di.FETCH_CLOUD_CTRL_CONFIG,data:{SDKAppID:s,version:this._version}}).then((s=>{this._isFetching=!1;var{version:i,cloudControlConfig:o}=s.data;t.setMessage(`version:${this._version} newVersion:${i} config:`+o).end(),ye.l(e+" ok"),this._parse(s.data)})).catch((s=>{this._isFetching=!1,t.setError(s).end(),ye.l(e+" failed. error:",s),this._setExpiredTime(12e4)}))}}onPushedConfig(e){ye.l(this._n+".onPushedConfig config:",e),new Ei("pushedCloudCtrlConfig").setMessage(`newVersion:${e.version} config:`+e.cloudControlConfig).end(),this._parse(e)}onCheckTimer(e){this._canFetch()&&this.fetchConfig()}_parse(e){var t=this._n+"._parse",{errorCode:s,errorMessage:i,cloudControlConfig:o,version:n,expiredTime:r}=e;if(0===s){if(this._version!==n){let s=null;try{s=JSON.parse(o)}catch(e){this.isPrivateNetWork()||ye.e(t+" failed. config:",o)}s&&(this._cloudConfig.clear(),Object.keys(s).forEach((e=>{this._cloudConfig.set(e,s[e])})),this._version=n,this.emitIEvt(Ji.CLOUD_CONFIG))}this._setExpiredTime(1e3*r)}else Be(s)?(ye.l(t+" failed. Invalid message format:",e),this._setExpiredTime(36e5)):(ye.e(t+` errorCode:${s} errorMessage:`+i),this._setExpiredTime(12e4))}_setExpiredTime(e){this._expiredTime=Date.now()+e}reset(){ye.l(this._n+".reset"),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}class Dn extends li{constructor(e){super(e),this._n="RecoverMsgModule",this.PULL_LIMIT_COUNT=15}start(){this._recoverGroupChat(),this._recoverC2CChat()}_recoverGroupChat(){let e,t,s,i,n,r=this._getLocalConvList().filter((e=>e.type===o.CONV_GROUP&&e.groupProfile.type!==o.GRP_AVCHATROOM)),a=this.get(As),l=[];r.forEach((r=>{var{conversationID:r,lastMessage:d}=r;t=r.replace(o.CONV_GROUP,""),e=a.getLocalLastMessage(r),d&&0!==d.lastSequence&&e&&(i=d.lastSequence,s=e.sequence,n=i-s,0<s)&&1<=n&&n<300?this._recoverGroupMsg({groupID:t,localLastMessageSequence:s,remoteLastMessageSequence:i}):l.push(t)})),this._getGroupNotice(l)}_recoverC2CChat(){let e,t,s,i,n=this._getLocalConvList().filter((e=>e.type===o.CONV_C2C)),r=this.get(As),a=[Promise.resolve()];n.forEach((o=>{var{conversationID:o,lastMessage:n}=o;e=r.getLocalLastMessage(o),n&&0!==n.lastTime&&e&&(s=n.lastTime,t=e.time,i=s-t,0<t)&&1<=i&&i<=600&&a.push(this._recoverC2CMsg({conversationID:o,localLastMessageTime:t,remoteLastMessageTime:s}))})),Promise.all(a).then((()=>{ye.l(this._n+"._recoverC2CChat all done"),this.get(ws).syncOnReconnected()}))}_getLocalConvList(){return this.get(As).getLocalConvList()}_recoverGroupMsg(e){let t=this._n+"._recoverGroupMsg",{groupID:s,localLastMessageSequence:i,remoteLastMessageSequence:n}=(ye.l(t+" options:",e),e),r=JSON.stringify(e),a=new Ei("_recoverGroupMsg");a.setMessage(r),this._getGroupRoamingMsg({groupID:s,sequence:i}).then((e=>{var{complete:l,messageList:d}=e.data;if(!Be(d)){let e=d[0].sequence,_=d.map((e=>e.sequence)),u=r+` complete:${l} sequenceList:`+_;ye.l(t+" "+u),e!==i&&e<n&&2!==l&&this._recoverGroupMsg({groupID:s,localLastMessageSequence:e,remoteLastMessageSequence:n}),a.setMessage(u).end();var c=this.get(Ds);1<d.length&&d.sort(((e,t)=>e.sequence-t.sequence));let h=!1;for(let t=0,s=d.length;t<s;t++)if(d[t].from===o.CONV_SYSTEM){h=!0;break}if(h)for(let t=0,s=d.length;t<s;t++){let e=d[t];e.from!==o.CONV_SYSTEM?c.onNewMessage({dataList:[e],isInstantMessage:!1,updateUnreadCount:!1}):c.onNewGroupTips({event:e.event,dataList:[e]})}else c.onNewMessage({dataList:d,isInstantMessage:!1,updateUnreadCount:!1})}})).catch((e=>{a.setError(e).end(),ye.w(t+" failed. error:",e)}))}_getGroupNotice(e){var t=e.length;if(ye.l(this._n+"._getGroupNotice length:"+t),0!==t){var s=this.get(Ds);if(t<=10)s.getNotice(e);else{let i=Math.floor(t/10);5<=i&&(i=5);for(let t=0;t<=i;t++)s.getNotice(e.slice(10*t,10*(t+1)))}}}_getGroupRoamingMsg(e){var{groupID:e,sequence:t}=e;return this.req({P:di.GET_GRP_ROAMING_MSG,data:{groupID:e,count:this.PULL_LIMIT_COUNT,sequence:t+this.PULL_LIMIT_COUNT-1}})}_recoverC2CMsg(e){let t=this._n+"._recoverC2CMsg",{conversationID:s,localLastMessageTime:i,remoteLastMessageTime:o}=(ye.l(t+" options:",e),e),n=JSON.stringify(e),r=new Ei("_recoverC2CMsg");return r.setMessage(n),this._getC2CRoamingMsg({conversationID:s,time:i}).then((e=>{var{complete:i,messageList:a}=e.data;if(!Be(a)){let e=a.length;this.get(Ss).onNewMessage({dataList:a,isInstantMessage:!0});var l=a[e-1].time,a=(a=a.map((e=>e.random)),n+` complete:${i} randomList:`+a);if(ye.l(t+" "+a),r.setMessage(a).end(),l<o&&1!==i)return this._recoverC2CMsg({conversationID:s,localLastMessageTime:l,remoteLastMessageTime:o})}})).catch((e=>{r.setError(e).end(),ye.w(t+" failed. error:",e)}))}_getC2CRoamingMsg(e){var{conversationID:e,time:t}=e;return this.req({P:di.GET_C2C_ROAMING_MSG,data:{peerAccount:e.replace(o.CONV_C2C,""),count:this.PULL_LIMIT_COUNT+1,lastMessageTime:t,direction:1}})}reset(){ye.l(this._n+".reset")}}class Rn{constructor(){this._n="AvgE2EDelay",this._e2eDelayArray=[]}addMessageDelay(e){e=Ie()-e,0<=e&&this._e2eDelayArray.push(e)}_calcAvg(e,t){if(0===t)return 0;let s=0;return e.forEach((e=>{s+=e})),vt(s/t,1)}_calcCountWithLimit(e){let{e2eDelayArray:t,min:s,max:i}=e;return t.filter((e=>s<=e&&e<i)).length}_calcPercent(e,t){let s=vt(e/t*100,2);return 100<s?100:s}_checkE2EDelayException(e,t){var s=e.filter((e=>t<e));if(0<s.length){let t=s.length,i=Math.min(...s),o=Math.max(...s),n=this._calcAvg(s,t),r=vt(t/e.length*100,2);50<r&&new Ei("messageE2EDelayException").setMessage(`count:${t} min:${i} max:${o} avg:${n} percent:`+r).setLevel("warning").end()}}getStatResult(){var e,t,s,i,o,n,r=this._e2eDelayArray.length;return 0===r?null:(e=[...this._e2eDelayArray],t=this._calcCountWithLimit({e2eDelayArray:e,min:0,max:1}),s=this._calcCountWithLimit({e2eDelayArray:e,min:1,max:3}),i=this._calcPercent(t,r),o=this._calcPercent(s,r),n=this._calcAvg(e,r),this._checkE2EDelayException(e,3),e.length=0,this.reset(),{totalCount:r,countLessThan1Second:t,percentOfCountLessThan1Second:i,countLessThan3Second:s,percentOfCountLessThan3Second:o,avgDelay:n})}reset(){this._e2eDelayArray.length=0}}class Ln{constructor(){this._n="AvgRTT",this._requestCount=0,this._rttArray=[]}addRequestCount(){this._requestCount+=1}addRTT(e){this._rttArray.push(e)}_calcTotalCount(){return this._requestCount}_calcRTTCount(e){return e.length}_calcSuccessRateOfRequest(e,t){if(0===t)return 0;let s=vt(e/t*100,2);return 100<s?100:s}_calcAvg(e,t){if(0===t)return 0;let s=0;return e.forEach((e=>{s+=e})),parseInt(s/t)}_calcMax(){return Math.max(...this._rttArray)}_calcMin(){return Math.min(...this._rttArray)}getStatResult(){var e,t,s=this._calcTotalCount(),i=[...this._rttArray];return 0===s?null:(e=this._calcRTTCount(i),t=this._calcSuccessRateOfRequest(e,s),i=this._calcAvg(i,e),ye.l(`${this._n}.getStatResult max:${this._calcMax()} min:${this._calcMin()} avg:`+i),this.reset(),{totalCount:s,rttCount:e,successRateOfRequest:t,avgRTT:i})}reset(){this._requestCount=0,this._rttArray.length=0}}class An{constructor(){this._map=new Map}initMap(e){e.forEach((e=>{this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}))}addTotalCount(e){return!(Be(e)||!this._map.has(e)||(this._map.get(e).totalCount+=1,0))}addSuccessCount(e){return!(Be(e)||!this._map.has(e)||(this._map.get(e).successCount+=1,0))}addFailedCountOfUserSide(e){return!(Be(e)||!this._map.has(e)||(this._map.get(e).failedCountOfUserSide+=1,0))}addCost(e,t){return!(Be(e)||!this._map.has(e)||(this._map.get(e).costArray.push(t),0))}addFileSize(e,t){return!(Be(e)||!this._map.has(e)||(this._map.get(e).fileSizeArray.push(t),0))}_calcSuccessRateOfBusiness(e){if(Be(e)||!this._map.has(e))return-1;e=this._map.get(e);let t=vt(e.successCount/e.totalCount*100,2);return 100<t?100:t}_calcSuccessRateOfPlatform(e){if(Be(e)||!this._map.has(e))return-1;var t=this._map.get(e);let s=this._calcSuccessCountOfPlatform(e)/t.totalCount*100;return 100<(s=vt(s,2))?100:s}_calcTotalCount(e){return Be(e)||!this._map.has(e)?-1:this._map.get(e).totalCount}_calcSuccessCountOfBusiness(e){return Be(e)||!this._map.has(e)?-1:this._map.get(e).successCount}_calcSuccessCountOfPlatform(e){return Be(e)||!this._map.has(e)?-1:(e=this._map.get(e)).successCount+e.failedCountOfUserSide}_calcAvg(e){return Be(e)||!this._map.has(e)?-1:e===mi?this._calcAvgSpeed(e):this._calcAvgCost(e)}_calcAvgCost(e){var t=this._map.get(e).costArray.length;if(0===t)return 0;let s=0;return this._map.get(e).costArray.forEach((e=>{s+=e})),parseInt(s/t)}_calcAvgSpeed(e){let t=0,s=0;return this._map.get(e).costArray.forEach((e=>{t+=e})),this._map.get(e).fileSizeArray.forEach((e=>{s+=e})),parseInt(1e3*s/t)}getStatResult(e){var t,s,i,o,n,r=this._calcTotalCount(e);return 0===r?null:(t=this._calcSuccessCountOfBusiness(e),s=this._calcSuccessRateOfBusiness(e),i=this._calcSuccessCountOfPlatform(e),o=this._calcSuccessRateOfPlatform(e),n=this._calcAvg(e),this.reset(e),{totalCount:r,successCountOfBusiness:t,successRateOfBusiness:s,successCountOfPlatform:i,successRateOfPlatform:o,avgValue:n})}reset(e){Be(e)?this._map.clear():this._map.set(e,{totalCount:0,successCount:0,failedCountOfUserSide:0,costArray:[],fileSizeArray:[]})}}class On{constructor(){this._lastMap=new Map,this._currentMap=new Map}initMap(e){e.forEach((e=>{this._lastMap.set(e,new Map),this._currentMap.set(e,new Map)}))}addMessageSequence(e){let{key:t,message:s}=e;if(Be(t)||!this._lastMap.has(t)||!this._currentMap.has(t))return!1;var{conversationID:i,sequence:n}=s,i=i.replace(o.CONV_GROUP,"");if(0===this._lastMap.get(t).size)this._addCurrentMap(e);else if(this._lastMap.get(t).has(i)){let s=this._lastMap.get(t).get(i),o=s.length-1;n>s[0]&&n<s[o]?(s.push(n),s.sort(),this._lastMap.get(t).set(i,s)):this._addCurrentMap(e)}else this._addCurrentMap(e);return!0}_addCurrentMap(e){var{key:e,message:t}=e,{conversationID:t,sequence:s}=t,t=t.replace(o.CONV_GROUP,"");this._currentMap.get(e).has(t)||this._currentMap.get(e).set(t,[]),this._currentMap.get(e).get(t).push(s)}_copyData(e){if(!Be(e)){this._lastMap.set(e,new Map);let i=this._lastMap.get(e);for(var[t,s]of this._currentMap.get(e))i.set(t,s);i=null,this._currentMap.set(e,new Map)}}getStatResult(e){if(Be(this._currentMap.get(e))||Be(this._lastMap.get(e)))return null;if(0===this._lastMap.get(e).size)return this._copyData(e),null;let t=0,s=0;if(this._lastMap.get(e).forEach(((e,i)=>{e=[...e.values()];var o=e.length;t+=e[o-1]-e[0]+1,s+=o})),0===t)return null;let i=vt(s/t*100,2);return 100<i&&(i=100),this._copyData(e),{totalCount:t,successCountOfMessageReceived:s,successRateOfMessageReceived:i}}reset(){this._currentMap.clear(),this._lastMap.clear()}}class Nn extends li{constructor(e){super(e),this._n="QualityStatModule",this.TAG="im-ssolog-quality-stat",this.reportIndex=0,this.wholePeriod=!1,this._qualityItems=[ci,_i,ui,hi,pi,gi,mi,Mi,fi,Ii],this._messageSentItems=[ui,hi,pi,gi,mi],this._messageReceivedItems=[Mi,fi,Ii],this.REPORT_INTERVAL=120,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._statInfoArr=[],this._avgRTT=new Ln,this._avgE2EDelay=new Rn,this._rateMessageSent=new An,this._rateMessageReceived=new On,e=this.getIEmitInst(),e.on(Ji.A2KEY_AND_TINYID_UPDATED,this._onLoginSuccess,this),e.on(Ji.CLOUD_CONFIG,this._onCloudConfig,this)}_onLoginSuccess(){this._rateMessageSent.initMap(this._messageSentItems),this._rateMessageReceived.initMap(this._messageReceivedItems);var e=this.get(Ns),t=e.getItem(this.TAG,!1);!Ue(t)&&He(t.forEach)&&(ye.l(this._n+"._onLoginSuccess. logs count:"+t.length),t.forEach((e=>{this._statInfoArr.push(e)})),e.removeItem(this.TAG,!1))}_onCloudConfig(){var e=this.getCloudConfig("q_rpt_interval"),t=this.getCloudConfig("q_rpt_sdkappid_bl"),s=this.getCloudConfig("q_rpt_tinyid_wl");Be(e)||(this.REPORT_INTERVAL=Number(e)),Be(t)||(this.REPORT_SDKAPPID_BLACKLIST=t.split(",").map((e=>Number(e)))),Be(s)||(this.REPORT_TINYID_WHITELIST=s.split(","))}onCheckTimer(e){this.isLoggedIn()&&e%this.REPORT_INTERVAL==0&&(this.wholePeriod=!0,this._report())}addRequestCount(){this._avgRTT.addRequestCount()}addRTT(e){this._avgRTT.addRTT(e)}addMessageDelay(e){this._avgE2EDelay.addMessageDelay(e)}addTotalCount(e){this._rateMessageSent.addTotalCount(e)||ye.w(this._n+".addTotalCount invalid key:",e)}addSuccessCount(e){this._rateMessageSent.addSuccessCount(e)||ye.w(this._n+".addSuccessCount invalid key:",e)}addFailedCountOfUserSide(e){this._rateMessageSent.addFailedCountOfUserSide(e)||ye.w(this._n+".addFailedCountOfUserSide invalid key:",e)}addCost(e,t){this._rateMessageSent.addCost(e,t)||ye.w(this._n+".addCost invalid key or cost:",e,t)}addFileSize(e,t){this._rateMessageSent.addFileSize(e,t)||ye.w(this._n+".addFileSize invalid key or size:",e,t)}addMessageSequence(e){this._rateMessageReceived.addMessageSequence(e)||ye.w(this._n+".addMessageSequence invalid key:",e.key)}_getQualityItem(e){let t={},s=Ti[this.get(Us).getNetworkType()];Be(s)&&(s=8);var i={qualityType:Ci[e],timestamp:Me(),networkType:s,extension:""};switch(e){case ci:t=this._avgRTT.getStatResult();break;case _i:t=this._avgE2EDelay.getStatResult();break;case ui:case hi:case pi:case gi:case mi:t=this._rateMessageSent.getStatResult(e);break;case Mi:case fi:case Ii:t=this._rateMessageReceived.getStatResult(e)}return null===t?null:{...i,...t}}_report(e){let t=[],s=null;Be(e)?this._qualityItems.forEach((e=>{null!==(s=this._getQualityItem(e))&&(s.reportIndex=this.reportIndex,s.wholePeriod=this.wholePeriod,t.push(s))})):null!==(s=this._getQualityItem(e))&&(s.reportIndex=this.reportIndex,s.wholePeriod=this.wholePeriod,t.push(s)),ye.d(this._n+"._report",t),0<this._statInfoArr.length&&(t=t.concat(this._statInfoArr),this._statInfoArr=[]);e=this.get(Os);var i=e.getSDKAppID();e=e.getTinyID();0<(t=Tt(this.REPORT_SDKAPPID_BLACKLIST,i)&&!yt(this.REPORT_TINYID_WHITELIST,e)?[]:t).length&&this._doReport(t)}_doReport(e){var t={header:Po(this),quality:e};this.req({P:di.SSO_STAT,data:{...t}}).then((()=>{this.reportIndex++,this.wholePeriod=!1})).catch((t=>{ye.w(this._n+"._doReport failed. error:",t),this._statInfoArr=this._statInfoArr.concat(e),this._flushAtOnce()}))}_flushAtOnce(){var e=this.get(Ns),t=e.getItem(this.TAG,!1),s=this._statInfoArr,i=this._n+"._flushAtOnce";if(Ue(t))ye.l(i+" count:"+s.length),e.setItem(this.TAG,s,!0,!1);else{let o=s.concat(t);10<o.length&&(o=o.slice(0,10)),ye.l(i+" count:"+o.length),e.setItem(this.TAG,o,!0,!1)}this._statInfoArr=[]}reset(){ye.l(this._n+".reset"),this._report(),this.reportIndex=0,this.wholePeriod=!1,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._avgRTT.reset(),this._avgE2EDelay.reset(),this._rateMessageSent.reset(),this._rateMessageReceived.reset()}}class Pn extends li{constructor(e){super(e),this._n="WorkerTimerModule",this._isWorkerEnabled=!0,this._workerTimer=null,this._timerID=-1,this._init(),this.getIEmitInst().on(Ji.CLOUD_CONFIG,this._onCloudConfig,this)}isWorkerEnabled(){return this._isWorkerEnabled&&le}startWorkerTimer(){ye.l(this._n+".startWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("start")}stopWorkerTimer(){ye.l(this._n+".stopWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("stop")}_init(){if(le){var e=URL.createObjectURL(new Blob(['let interval = -1;onmessage = function(event) { if (event.data === "start") { if (interval > 0) { clearInterval(interval); } interval = setInterval(() => { postMessage(""); }, 1000); postMessage(interval); } else if (event.data === "stop") { clearInterval(interval); interval = -1; }};'],{type:"application/javascript; charset=utf-8"}));this._workerTimer=new Worker(e);let t=this;this._workerTimer.onmessage=function(e){e.data?(t._timerID=e.data,ye.l(t._n+"._init seed:"+t._timerID)):t._m.onCheckTimer()}}}_onCloudConfig(){var e=this.getCloudConfig("enable_worker");ye.l(this._n+"._onCloudConfig enableWorker:"+e),Be(e)||"1"===e?!this._isWorkerEnabled&&le&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._m.onWorkerTimerEnabled()):this._isWorkerEnabled&&le&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._m.onWorkerTimerDisabled())}terminate(){ye.l(this._n+".terminate"),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null,this._timerID=-1)}getTimerID(){return this._timerID}reset(){ye.l(this._n+".reset")}}class Un{constructor(e){this._commercialConfigM=e,this._n="PurchasedFeatureHandler",this._isCSPluginReported=!1,this._featureMap=new Map}isValidPurchaseBits(e){return e&&"string"==typeof e&&1<=e.length&&e.length<=64&&/[01]{1,64}/.test(e)}parsePurchaseBits(e){if(this.isValidPurchaseBits(e)){var t;this._featureMap.clear();for(let s=e.length-1,i=0;0<=s;s--,i++)t=(i<32?new r(0,Math.pow(2,i)):new r(Math.pow(2,i-32),0)).toString(),"1"===e[s]?this._featureMap.set(t,!0):this._featureMap.set(t,!1)}else ye.w(this._n+".parsePurchaseBits invalid purchasebits:"+e)}hasPurchasedFeature(e){return!!this._featureMap.get(e)}isFeatureEnabled(e){var t=parseInt(e).toString(2);let s,i=!0;for(let o=t.length-1,n=0;0<=o;o--,n++)if("1"===t.charAt(o)&&(s=(n<32?new r(0,Math.pow(2,n)):new r(Math.pow(2,n-32),0)).toString(),!this._featureMap.get(s))){i=!1;break}return ye.l(`${this._n}.isFeatureEnabled decimalNumber:${e} key:${s} ret:`+i),ri({enabled:i})}isFeatureEnabledForStat(e){var t=parseInt(e).toString(2);let s;for(let i=t.length-1,o=0;0<=i;i--,o++)if("1"===t.charAt(i)){if(s=(o<32?new r(0,Math.pow(2,o)):new r(Math.pow(2,o-32),0)).toString(),!this._featureMap.get(s))break;{let e="",t=0;if(s===y.PLUGIN_TRANSLATE?(e="plugin_translate",t=16):s===y.PLUGIN_VOICE_TO_TEXT?(e="plugin_voice_to_text",t=17):s===y.PLUGIN_CS?(e="plugin_cs",t=14):s===y.PLUGIN_PUSH?(e="plugin_push",t=13):s===y.PLUGIN_BOT?(e="plugin_bot",t=15):s===y.MSG_REACTION&&(e="plugin_emoji_reaction",t=18),""!==e){let s=this._commercialConfigM.get(Os).getUIPlatform();new Ei(e).setCode(t).setUIPlatform(s).end(),ye.l(`${this._n}.isFeatureEnabledForStat ${e} code:${t} uiPlatform:`+s)}}}}isCSPluginEnabled(){var e;this._isCSPluginReported||(e=this._commercialConfigM.get(Os).getUIPlatform(),new Ei("plugin_search").setCode(6).setUIPlatform(e).end(),this._isCSPluginReported=!0)}clear(){this._featureMap.clear(),this._isCSPluginReported=!1}}class Gn{constructor(e){this._m=e,this._n="CommercialConfigModule",this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler=new Un(this)}_canFetch(){return this.get(Os).isLoggedIn()?!this._isFetching&&Date.now()>=this._expiredTime:(this._expiredTime=Date.now()+2e3,!1)}onCheckTimer(e){this._canFetch()&&this.fetchConfig()}fetchConfig(){let e=this._canFetch(),t=this._n+".fetchConfig";if(ye.l(t+" canFetch:"+e),e){let e=new Ei("fetchCommercialConfig"),s=this.get(Os).getSDKAppID(),i=this.get(bs);this._isFetching=!0,i.req({P:di.FETCH_COMMERCIAL_CONFIG,data:{SDKAppID:s}}).then((s=>{e.setMessage("purchaseBits:"+s.data.purchaseBits).end(),ye.l(t+" ok."),this._parseConfig(s.data),this._isFetching=!1})).catch((t=>{e.setError(t).end(),this._isFetching=!1}))}}onPushedConfig(e){var t=this._n+".onPushedConfig data:"+JSON.stringify(e);ye.l(t),new Ei("pushedCommercialConfig").setMessage("purchaseBits:"+e.purchaseBits).end(),this._parseConfig(e)}_parseConfig(e){var t=this._n+"._parseConfig",{errorCode:s,errorMessage:i,purchaseBits:o,expiredTime:n}=e;0===s?(this._purchasedFeatureHandler.parsePurchaseBits(o),this._expiredTime=Date.now()+1e3*n):Be(s)?(ye.l(t+" failed. Invalid message format:",e),this._setExpiredTimeOnResponseError(36e5)):(ye.e(t+` errorCode:${s} errorMessage:`+i),this._setExpiredTimeOnResponseError(12e4))}_setExpiredTimeOnResponseError(e){this._expiredTime=Date.now()+e}canIUse(e){return this._purchasedFeatureHandler.hasPurchasedFeature(e)}isFeatureEnabled(e){return this._purchasedFeatureHandler.isFeatureEnabled(e)}isFeatureEnabledForStat(e){this._purchasedFeatureHandler.isFeatureEnabledForStat(e)}isCSPluginEnabled(){this._purchasedFeatureHandler.isCSPluginEnabled()}get(e){return this._m.get(e)}reset(){ye.l(this._n+".reset"),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}class kn extends li{constructor(e){super(e),this._m=e,this._n="OfflinePushModule",this._offlinePushPlugin=void 0,this._androidPushConfig={huaweiPushBussinessId:"",xiaomiPushBussinessId:"",xiaomiPushAppId:"",xiaomiPushAppKey:"",meizuPushBussinessId:"",meizuPushAppId:"",meizuPushAppKey:"",vivoPushBussinessId:"",fcmPushBussinessId:"",oppoPushBussinessId:"",oppoPushAppKey:"",oppoPushAppSecret:"",honorPushBussinessId:""},this._deviceToken="",this._businessID=0,this._iosBusinessID=0,this._c2cUnreadCount=0,this._groupUnreadCount=0,this._isWebUniapp=0}registerPlugin(e){var t,s,i,o,n,r,a,l,d,c,_,u,h;b?(this._offlinePushPlugin=e["tim-offline-push-plugin"],({huaweiBusinessID:t,xiaomiBusinessID:s,xiaomiAppID:i,xiaomiAppKey:o,meizuBusinessID:n,meizuAppID:r,meizuAppKey:a,vivoBusinessID:l,oppoBusinessID:d,oppoAppKey:c,oppoAppSecret:_,honorBusinessID:u,iosBusinessID:h}=e.offlinePushConfig||{}),this._androidPushConfig.huaweiPushBussinessId=t,this._androidPushConfig.xiaomiPushBussinessId=s,this._androidPushConfig.xiaomiPushAppId=i,this._androidPushConfig.xiaomiPushAppKey=o,this._androidPushConfig.meizuPushBussinessId=n,this._androidPushConfig.meizuPushAppId=r,this._androidPushConfig.meizuPushAppKey=a,this._androidPushConfig.vivoPushBussinessId=l,this._androidPushConfig.oppoPushBussinessId=d,this._androidPushConfig.oppoPushAppKey=c,this._androidPushConfig.oppoPushAppSecret=_,this._androidPushConfig.honorPushBussinessId=u,new Ei("registerPlugin").setMessage("tim-offline-push-plugin").setMoreMessage("isExist:"+!Be(this._offlinePushPlugin)).end(!0),ye.l(this._n+".registerPlugin ok. offlinePushConfig:"+JSON.stringify(e.offlinePushConfig)),this._iosBusinessID=h,this._setAppShowListener()):this.warn("OfflinePushInUniapp")}init(){this._isWebUniapp=this.getUniAppPlatform(),this._getDeviceToken()}_getDeviceToken(){let e=this._n+"._getDeviceToken";if(He(this._offlinePushPlugin.getDeviceToken)){let t=`androidPushConfig:${JSON.stringify(this._androidPushConfig)}, iosBusinessID:`+this._iosBusinessID;ye.l(e+" start. "+t),new Ei("_getDeviceToken").setMessage(t).end(!0),this._offlinePushPlugin.getDeviceToken(this._androidPushConfig,(s=>{let i=new Ei("getDeviceTokenRes"),{code:o,msg:n}=s;if(0===o){let{deviceToken:o,deviceBrand:n,deviceType:r,bussinessId:a}=s.data;this._deviceToken=o,this._businessID=a||this._iosBusinessID,t=`deviceToken:${o}, deviceBrand:${n||r}, businessID:`+this._businessID,ye.l(e+" ok. "+t),i.setMessage(t).end(!0),this._setToken()}else i.setMessage(`code:${o}, msg:`+n).end(!0),ye.e(e+" failed. error:",s)}))}else ye.e(e+" getDeviceToken is not a function")}canIUseOfflinePush(){return b&&!Be(this._offlinePushPlugin)}_setAppShowListener(){let e=this._n+"._setAppShowListener";Be(this._offlinePushPlugin)?ye.e(e+" offlinePushPlugin is undefined"):He(this._offlinePushPlugin.setAppShowListener)?(new Ei("_setAppShowListener").end(!0),ye.l(e+" start"),this._offlinePushPlugin.setAppShowListener((t=>{t=(t||{}).appShow,new Ei("setAppShowListenerRes").setMessage("appShow:"+t).end(!0),ye.l(e+" ok. appShow:"+t),this._m.isReady()&&(0===t?(this._getConvUnreadCount(),this._onBackground()):1===t&&this._onForeground())}))):ye.e(e+" setAppShowListener is not a function")}getDeviceBrand(){var e;if(!Be(this._offlinePushPlugin)&&He(this._offlinePushPlugin.getDeviceType))return e=(this._offlinePushPlugin.getDeviceType()||{})["deviceType"],ye.l(this._n+".getDeviceBrand ok. deviceType:"+e),e}_setToken(){let e,t=this._n+"._setToken",s=this.get(Os),i=1,o="",n="";Ue(this._deviceToken)&&(i=0);var r=this.getUniAppPlatform(),a=this.getDeviceBrand();r===c.IOS||r===c.IPAD||r===c.MAC?n=this._deviceToken:r===c.ANDROID&&(o=this._deviceToken);let l=new Ei("offlinePushSetToken");return e=`deviceToken:${n||o}, businessID:${this._businessID}, deviceBrand:${a}, isWebUniapp:${this._isWebUniapp}, pushMsg:${i}, platform:`+r,l.setMessage(e),ye.l(t+" "+e),this.req({P:di.SET_TOKEN,data:{tokenID:o,pushMsg:i,sdkAppID:s.getSDKAppID(),businessID:parseInt(this._businessID),deviceBrand:a,deviceToken:n,isWebUniapp:this._isWebUniapp}}).then((e=>(l.end(),ye.l(t+" ok"),e))).catch((e=>(l.setError(e).end(),ye.e(t+" failed. error:",e),ai(e))))}_getConvUnreadCount(){this._c2cUnreadCount=0,this._groupUnreadCount=0,this.get(As).getLocalConvList().forEach((e=>{e.type===o.CONV_C2C&&(this._c2cUnreadCount+=e.unreadCount),e.type===o.CONV_GROUP&&(this._groupUnreadCount+=e.unreadCount)}))}_onBackground(){let e=this._n+"._onBackground",t=new Ei("_onBackground");this.req({P:di.STAT_BACKGROUND,data:{c2cUnreadCount:this._c2cUnreadCount,groupUnreadCount:this._groupUnreadCount,isWebUniapp:this._isWebUniapp}}).then((s=>(t.setMessage(`c2cUnreadCount: ${this._c2cUnreadCount}, groupUnreadCount: `+this._groupUnreadCount).end(),ye.l(e+" ok"),s))).catch((s=>{t.setError(s).end(),ye.e(e+" failed. error:",s)}))}_onForeground(){let e=this._n+"._onForeground",t=new Ei("_onForeground");this.req({P:di.STAT_FOREGROUND,data:{isWebUniapp:this._isWebUniapp}}).then((s=>(t.end(),ye.l(e+" ok"),s))).catch((s=>{t.setError(s).end(),ye.e(e+" failed. error:",s)}))}getUniAppPlatform(){var e=uni.getSystemInfoSync().platform,t=this.getDeviceBrand();return"ios"===e?c.IOS:"android"===e?c.ANDROID:1002===t?c.IPAD:1001===t?c.MAC:void 0}reset(){this._deviceToken="",this._businessID=0,this._c2cUnreadCount=0,this._groupUnreadCount=0,this._isWebUniapp=0,ye.l(this._n+".reset")}}class wn extends li{constructor(e){super(e),this._m=e,this._n="TIMPushModule",this._pluginName="TIMPush",this._pushPlugin=void 0,this._androidPushConfig={},this._deviceToken="",this._businessID=0,this._iOSBusinessID=0,this._c2cUnreadCount=0,this._groupUnreadCount=0,this._isWebUniapp=0,this._deviceInfo={notificationStatus:0,deviceModel:"",systemVersion:"",pushVersion:"1.0.1",packageName:""}}registerPlugin(e){var t,s,i;b?(t=this._n+".registerPlugin",({androidConfig:s,iOSConfig:i}=(this._pushPlugin=e["tim-push"],this._getDeviceInfo(),e.pushConfig||{})),qe(s)&&(this._androidPushConfig=s[this._deviceInfo.packageName]),s=(i||{}).iOSBusinessID,this._iOSBusinessID=s,i=!Be(this._pushPlugin),new Ei("registerPlugin").setMessage(this._pluginName).setMoreMessage("isExisted:"+i).end(!0),ye.l(t+" ok. pushConfig:"+JSON.stringify(e.pushConfig)),i?(this._setAppShowListener(),this._setPushEventReportListener()):ye.e(t+` ${this._pluginName} is undefined`)):this.warn("TIMPushInUniapp")}init(){this._isWebUniapp=this.getUniAppPlatform(),this._reportEventCacheList(),this._getDeviceToken(),this.get(Ks).isFeatureEnabledForStat(Math.pow(2,41))}_reportEventCacheList(){let e=this._n+"._reportEventCacheList";He(this._pushPlugin.getPushEventCacheList)?(new Ei("_reportEventCacheList").end(!0),this._pushPlugin.getPushEventCacheList((t=>{var{code:s,data:{eventList:i}}=t,o=new Ei("getPushEventCacheListRes");if(o.setCode(s),0!==s)o.setMessage("res:"+JSON.stringify(t)).end(!0),ye.e(e+" failed. error:"+JSON.stringify(t));else{s=i.length<10?"eventList:"+JSON.stringify(i):"eventList.length:"+i.length,ye.l(e+" ok. "+s),o.setMessage(s).end(!0);for(var n={...t.data,eventList:[]};0<i.length;)n.eventList=i.splice(0,40),this._pushReport(n)}}))):ye.e(this._pluginName+".getPushEventCacheList is not a function")}_getDeviceToken(){let e=this._n+"._getDeviceToken";if(He(this._pushPlugin.getDeviceToken)){let t=`androidPushConfig:${JSON.stringify(this._androidPushConfig)} iOSBusinessID:`+this._iOSBusinessID;ye.l(e+" start. "+t),new Ei("_getDeviceToken").setMessage(t).end(!0),this._pushPlugin.getDeviceToken(this._androidPushConfig,(s=>{let{code:i,msg:o}=s,n=new Ei("getDeviceTokenRes");if(n.setCode(i),0===i){let{deviceToken:i,deviceBrand:o,deviceType:r,bussinessId:a}=s.data;this._deviceToken=i,this._businessID=a||this._iOSBusinessID,t=`deviceToken:${i} deviceBrand:${o||r} businessID:`+this._businessID,ye.l(e+" ok. "+t),n.setMessage(t).end(!0),this._setToken()}else n.setMessage(o).end(!0),ye.e(e+" failed. error:"+JSON.stringify(s))}))}else ye.e(this._pluginName+".getDeviceToken is not a function")}_getDeviceInfo(){var e=this._n+"._getDeviceInfo";if(He(this._pushPlugin.getDeviceInfo)){let t=this._pushPlugin.getDeviceInfo(),{code:s,data:i}=t,o=new Ei("_getDeviceInfo");if(o.setCode(s),0===s){this._deviceInfo={...this._deviceInfo,...i},this._deviceInfo.pushVersion||(this._deviceInfo.pushVersion="1.0.1");let t="deviceInfo:"+JSON.stringify(this._deviceInfo);ye.l(e+" ok. "+t),o.setMessage(t).end(!0)}else o.setMessage("deviceInfoRes:"+JSON.stringify(t)).end(!0),ye.e(e+" failed. error:"+JSON.stringify(t))}else ye.e(this._pluginName+".getDeviceInfo is not a function")}canIUseTIMPush(){return b&&!Be(this._pushPlugin)}_setAppShowListener(){let e=this._n+"._setAppShowListener";He(this._pushPlugin.setAppShowListener)?(new Ei("_setAppShowListener").end(!0),ye.l(e+" start"),this._pushPlugin.setAppShowListener((t=>{t=(t||{}).appShow,new Ei("setAppShowListenerRes").setMessage("appShow:"+t).end(!0),ye.l(e+" ok. appShow:"+t),this._m.isReady()&&(0===t?(this._getConvUnreadCount(),this._onBackground()):1===t&&this._onForeground())}))):ye.e(this._pluginName+".setAppShowListener is not a function")}_setPushEventReportListener(){let e=this._n+"._setPushEventReportListener";He(this._pushPlugin.setPushEventReportListener)?(new Ei("_setPushEventReportListener").end(!0),this._pushPlugin.setPushEventReportListener((t=>{var{code:s,data:i}=t,o=i["eventList"],n=new Ei("setPushEventReportListenerRes");if(n.setCode(s),0===s){let t="eventList:"+JSON.stringify(o);ye.l(e+" ok. "+t),n.setMessage(t).end(!0),this._m.isReady()&&Ve(o)&&0<o.length&&this._pushReport(i)}else n.setMessage("res:"+JSON.stringify(t)).end(!0),ye.e(e+" failed. error:"+JSON.stringify(t))}))):ye.e(this._pluginName+".setPushEventReportListener is not a function")}getDeviceBrand(){var e;if(!Be(this._pushPlugin)&&He(this._pushPlugin.getDeviceType))return e=(this._pushPlugin.getDeviceType()||{})["deviceType"],ye.l(this._n+".getDeviceBrand ok. deviceType:"+e),e}_setToken(){let e,t=this._n+"._setToken",s=this.get(Os),i=1,o="",n="";Ue(this._deviceToken)&&(i=0);var r=this.getUniAppPlatform(),a=this.getDeviceBrand();r===c.IOS||r===c.IPAD||r===c.MAC?n=this._deviceToken:r===c.ANDROID&&(o=this._deviceToken);let l={tokenID:o,pushMsg:i,sdkAppID:s.getSDKAppID(),businessID:parseInt(this._businessID),deviceBrand:a,deviceToken:n,isWebUniapp:this._isWebUniapp,...this._deviceInfo},d=new Ei("_setToken");e="data:"+JSON.stringify(l),d.setMessage(e),ye.l(t+" "+e),this.req({P:di.SET_TOKEN,data:l}).then((()=>{d.end(),ye.w(t+" ok")})).catch((e=>{d.setError(e).end(),ye.e(t+" failed. error:",e),ai(e)}))}_getConvUnreadCount(){this._c2cUnreadCount=0,this._groupUnreadCount=0,this.get(As).getLocalConvList().forEach((e=>{e.type===o.CONV_C2C&&(this._c2cUnreadCount+=e.unreadCount),e.type===o.CONV_GROUP&&(this._groupUnreadCount+=e.unreadCount)}))}_onBackground(){let e=this._n+"._onBackground",t=new Ei("_onBackground");this.req({P:di.STAT_BACKGROUND,data:{c2cUnreadCount:this._c2cUnreadCount,groupUnreadCount:this._groupUnreadCount,isWebUniapp:this._isWebUniapp}}).then((()=>{t.setMessage(`c2cUnreadCount:${this._c2cUnreadCount} groupUnreadCount:`+this._groupUnreadCount).end(),ye.l(e+" ok")})).catch((s=>{t.setError(s).end(),ye.e(e+" failed. error:",s)}))}_onForeground(){let e=this._n+"._onForeground",t=new Ei("_onForeground");this.req({P:di.STAT_FOREGROUND,data:{isWebUniapp:this._isWebUniapp}}).then((()=>{t.end(),ye.l(e+" ok")})).catch((s=>{t.setError(s).end(),ye.e(e+" failed. error:",s)}))}_pushReport(e){let t=this._n+"._pushReport",s=new Ei("_pushReport");this.req({P:di.PUSH_REPORT,data:{eventList:e.eventList}}).then((()=>{s.end(),this._notifyReportSuccess(e)})).catch((e=>{s.setError(e).end(),ye.e(t+" failed. error:",e)}))}_notifyReportSuccess(e){!Be(this._pushPlugin)&&He(this._pushPlugin.notifyReportSuccess)&&(this._pushPlugin.notifyReportSuccess(e),ye.l(this._n+"._notifyReportSuccess ok"))}getUniAppPlatform(){var e=uni.getSystemInfoSync().platform,t=this.getDeviceBrand();return"ios"===e?c.IOS:"android"===e?c.ANDROID:1002===t?c.IPAD:1001===t?c.MAC:void 0}reset(){this._deviceToken="",this._businessID=0,this._c2cUnreadCount=0,this._groupUnreadCount=0,this._isWebUniapp=0,ye.l(this._n+".reset")}}class bn extends li{constructor(e){super(e),this._n="ProfanityFilterModule",this._plugin=null,this._filterConfigMap=new Map,this._startIndex=0,this._version=0,this._canIUseLexicon=!1,this._isFetching=!1,this._expiredTime=0}init(){var e=this.get(ks).getPlugin("tim-profanity-filter-plugin");e&&(this._plugin=new e({logger:ye,isArray:Ve,isMap:Ge,isDevMode:this.isDevMode()}),this._getLexicon())}onCheckTimer(){this._plugin&&this._canIUseLexicon&&this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime&&this._getLexicon()}filterMessage(e,t){let s=!0;if(this._plugin&&this._canIUseLexicon&&(!t||!t.messageControlInfo||!0!==t.messageControlInfo.excludedFromContentModeration)){let{type:t,conversationType:i}=e;if(t===o.MSG_TEXT||t===o.MSG_CUSTOM){let n,r=this._n+".filterMessage";if(ye.l(""+r),t===o.MSG_TEXT){if(i===o.CONV_C2C?n=E:i===o.CONV_GROUP&&(n=D),!this._isConfigOn(n))return s;let{type:t,modifiedText:r}=this._plugin.filter(e.payload.text);1===t?s=!1:2===t&&(e.payload.text=r)}else if(t===o.MSG_CUSTOM){if(i===o.CONV_C2C?n=S:i===o.CONV_GROUP&&(n=R),!this._isConfigOn(n))return s;let t=this._plugin.filter(e.payload.data),r=this._plugin.filter(e.payload.description),a=this._plugin.filter(e.payload.extension);1===t.type||1===r.type||1===a.type?s=!1:(2===t.type&&(e.payload.data=t.modifiedText),2===r.type&&(e.payload.description=r.modifiedText),2===a.type&&(e.payload.extension=a.modifiedText))}ye.l(r+" done. isAllowedToSend:"+s)}}return s}filterText(e,t){var s=this._n+".filterText",i={isAllowedToSend:!0,modifiedText:e};return this._plugin&&this._canIUseLexicon&&this._isConfigOn(t)&&(ye.l(s),({type:t,modifiedText:e}=this._plugin.filter(e)),1===t?i.isAllowedToSend=!1:2===t&&(i.modifiedText=e),ye.l(s+" done. ret:",i)),i}_getLexicon(){let e=new Ei("profanityFilter"),t=this._n+"._getLexicon";this._isFetching=!0,this.req({P:di.GET_PROFANITY_LIST,data:{startIndex:this._startIndex,version:this._version}}).then((s=>{var{errorInfo:s,filterConfig:i,lexicon:o,strToken:n,completeFlag:r,nextStartIndex:a,version:l,expiredTime:d}=s.data,{errorCode:c,errorMessage:_}=s;return 0!==c?(this._isFetching=!1,ye.w(t+" failed. error:",s),void e.setCode(c).setMessage(_).end()):(this._onFilterConfig(i),this._getToken(n),1===r?(ye.l(t+` done. version:${l} expiredTime:`+d),this._version=l,this._canIUseLexicon=!0,this._isFetching=!1,this._expiredTime=Date.now()+1e3*d,void this._plugin.onLexiconCompleted(o)):(this._startIndex=a,this._plugin.onLexiconSliced(o),void this._getLexicon()))})).catch((s=>{e.setError(s).end(),this._isFetching=!1,ye.l(t+" failed. error:",s)}))}_onFilterConfig(e){Ue(e)||(this._filterConfigMap.clear(),Object.keys(e).forEach((t=>{this._filterConfigMap.set(t,e[t])})),ye.l(`${this._n}._onFilterConfig. keys:${Array.from(this._filterConfigMap.keys())} values:`+Array.from(this._filterConfigMap.values())))}_isConfigOn(e){return 1===this._filterConfigMap.get(e)}_getToken(e){if(Fe(e)){var t=e.length;let s="";if(t%2==0)for(let i=0;i<=t-1;i+=2)s=(s+=e[i+1])+e[i];else{for(let i=0;i<t-1;i+=2)s=(s+=e[i+1])+e[i];s+=e[t-1]}this._plugin.onToken(s)}}reset(){ye.l(this._n+".reset"),this._plugin&&(this._plugin.reset(),this._plugin=null),this._filterConfigMap.clear(),this._startIndex=0,this._version=0,this._canIUseLexicon=!1,this._isFetching=!1,this._expiredTime=0}}class Fn{constructor(e){this._m=e,this._n="TransCmdModule",this._TRTCCommandList=["tui_room_svr.*","callkit_records_svr.*","room_engine_srv.*","room_engine_http_srv.*","room_engine_mic.*","live_engine_srv.*","live_engine_http_srv.*","live_engine_pk.*","trtc_ai_service.*","call_engine_srv.*"],this._TRTCCommandMap=new Map,this._setTRTCCommandMap(),this._m.getIEmitInst().on(Ji.CLOUD_CONFIG,this._onCloudConfig,this)}_onCloudConfig(){var e=this._m.get(qs).getCloudConfig("rtc_cmd");Be(e)||((e=JSON.parse(e)).forEach((e=>{this._TRTCCommandList.includes(e)||this._TRTCCommandList.push(e)})),this._setTRTCCommandMap())}_setTRTCCommandMap(){var e;for(let t=0,s=this._TRTCCommandList.length;t<s;t++)e=this._TRTCCommandList[t].split(".")[0],this._TRTCCommandMap.set(e,1)}onRoomCustomDataReceived(e){this._m.getOEmitInst().emit(i.ROOM_CUSTOM_DATA_RECEIVED,e)}sendTRTCCustomData(e){var{serviceCommand:e,data:t}=e;let s=T.NAME.TUIROOM_SVR+".*";return Be(e)||(s=e),this._isValidServiceCommand(s)?this._trans({servcmd:s,data:t}):ai({code:ii.INVALID_TRTC_CMD})}_trans(e){ye.d(this._n+"._trans. options:"+JSON.stringify(e));var{servcmd:e,data:t}=e;return this._m.get(bs).trans({servcmd:e,data:Fe(t)?JSON.parse(t):t})}_isValidServiceCommand(e){return e.endsWith(".*")?this._TRTCCommandList.includes(e):(e=e.split(".")[0],this._TRTCCommandMap.has(e))}isTRTCCommand(e){return e=e.split(".")[0],this._TRTCCommandMap.has(e)}reset(){ye.l(this._n+".reset")}}class qn{constructor(e){this._m=e,this._n="ErrMsgModule",this.TIM_ERROR_ASSISTANCE="tim_error_assistance",this.STORAGE_EXPIRES_TIME=6048e5,this._map=new Map,this._init()}_init(){var e=this._getStorageModule().getItem(this.TIM_ERROR_ASSISTANCE,!1);if(e){let t;try{t=JSON.parse(e)}catch(i){this._getStorageModule().removeItem(this.TIM_ERROR_ASSISTANCE,!1),ye.w(this._n+"._init error:",i)}t&&(this._needToUpdate(t)?this._fetch():this._fillMap(t.message))}else this._fetch()}_needToUpdate(e){var{localSavedTime:e,localSavedVersion:t}=e,t=(e=e&&(new Date).getTime()-e>=this.STORAGE_EXPIRES_TIME,!t||"3.5.3"!==t);return ye.l(this._n+`._needToUpdate isTimeout:${e} isDifferentVersion:`+t),e||t}_fetch(){if(!this._m.get(Os).isPrivateNetWork()){let e="https://web.sdk.qcloud.com/im/download/error-message/v3/0.0.7/tim-error-message.txt",t="application/x-www-form-urlencoded;charset=UTF-8",s=this._n+"._fetch ok in",i=this;if(x)H.request({url:e,method:"GET",timeout:3e3,header:{"content-type":t},dataType:"text",success:e=>{i._fillAndSave(e.data),ye.l(s+" mini program")},fail:()=>{}});else{let o=new XMLHttpRequest,n=setTimeout((()=>{o.abort()}),3e3);o.onreadystatechange=function(){4===o.readyState&&(n&&clearTimeout(n),200!==o.status&&304!==o.status||(ye.l(s+" browser"),i._fillAndSave(o.responseText)))},o.open("GET",e,!0),o.setRequestHeader("Content-type",t),o.send()}}}_fillAndSave(e){this._fillMap(e),this._getStorageModule().setItem(this.TIM_ERROR_ASSISTANCE,JSON.stringify({message:e,localSavedTime:(new Date).getTime(),localSavedVersion:"3.5.3"}),!0,!1)}_getStorageModule(){return this._m.get(Ns)}_fillMap(e){this._map.clear();var t,s,i=e.split(";\n"),o=i.length,n=new RegExp(/'/g);for(let r=0;r<o;r++)if(s=i[r].indexOf(":"),t=i[r].slice(0,s),s=i[r].slice(s+1,i[r].length),!t.startsWith("//")){if(Be(s))continue;this._map.set(t,s.replace(n,""))}}get(e){var{isIntl:e,key:t,replacement1:s,replacement2:i}=e;let o=e?t+"_en":t+"_cn",n=(!this._map.has(o)&&this._map.has(t)&&(o=t),"");return this._map.has(o)&&(n=this._map.get(o),Be(s)||(n=n.replace("$replacement1",s)),Be(i)||(n=n.replace("$replacement2",i))),n}reset(){ye.l(this._n+".reset")}}var xn=bo((function(e,t){var s="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;t.assign=function(e){for(var t,s,i=Array.prototype.slice.call(arguments,1);i.length;){var o=i.shift();if(o){if("object"!=typeof o)throw new TypeError(o+"must be non-object");for(var n in o)t=o,s=n,Object.prototype.hasOwnProperty.call(t,s)&&(e[n]=o[n])}}return e},t.shrinkBuf=function(e,t){return e.length===t?e:e.subarray?e.subarray(0,t):(e.length=t,e)};var i={arraySet:function(e,t,s,i,o){if(t.subarray&&e.subarray)e.set(t.subarray(s,s+i),o);else for(var n=0;n<i;n++)e[o+n]=t[s+n]},flattenChunks:function(e){for(var t,s,i,o=0,n=0,r=e.length;n<r;n++)o+=e[n].length;for(i=new Uint8Array(o),n=t=0,r=e.length;n<r;n++)s=e[n],i.set(s,t),t+=s.length;return i}},o={arraySet:function(e,t,s,i,o){for(var n=0;n<i;n++)e[o+n]=t[s+n]},flattenChunks:function(e){return[].concat.apply([],e)}};t.setTyped=function(e){e?(t.Buf8=Uint8Array,t.Buf16=Uint16Array,t.Buf32=Int32Array,t.assign(t,i)):(t.Buf8=Array,t.Buf16=Array,t.Buf32=Array,t.assign(t,o))},t.setTyped(s)})),Vn=(xn.assign,xn.shrinkBuf,xn.setTyped,xn.Buf8,xn.Buf16,xn.Buf32,function(e,t,s,i){for(var o=65535&e,n=e>>>16&65535,r=0;0!==s;){for(s-=r=2e3<s?2e3:s;n=n+(o=o+t[i++]|0)|0,--r;);o%=65521,n%=65521}return o|n<<16}),Bn=function(){for(var e=[],t=0;t<256;t++){for(var s=t,i=0;i<8;i++)s=1&s?3988292384^s>>>1:s>>>1;e[t]=s}return e}(),Kn=function(e,t,s,i){var o=Bn,n=i+s;e^=-1;for(var r=i;r<n;r++)e=e>>>8^o[255&(e^t[r])];return-1^e},Hn=function(e,t){var s,i,o,n,r,a,l=e.state,d=e.next_in,c=e.input,_=d+(e.avail_in-5),u=e.next_out,h=e.output,p=u-(t-e.avail_out),g=u+(e.avail_out-257),m=l.dmax,M=l.wsize,f=l.whave,I=l.wnext,C=l.window,v=l.hold,T=l.bits,y=l.lencode,E=l.distcode,S=(1<<l.lenbits)-1,D=(1<<l.distbits)-1;e:do{for(T<15&&(v+=c[d++]<<T,T+=8,v+=c[d++]<<T,T+=8),s=y[v&S];;){if(v>>>=i=s>>>24,T-=i,0==(i=s>>>16&255))h[u++]=65535&s;else{if(!(16&i)){if(0==(64&i)){s=y[(65535&s)+(v&(1<<i)-1)];continue}if(32&i){l.mode=12;break e}e.msg="invalid literal/length code",l.mode=30;break e}for(o=65535&s,(i&=15)&&(T<i&&(v+=c[d++]<<T,T+=8),o+=v&(1<<i)-1,v>>>=i,T-=i),T<15&&(v+=c[d++]<<T,T+=8,v+=c[d++]<<T,T+=8),s=E[v&D];;){if(v>>>=i=s>>>24,T-=i,!(16&(i=s>>>16&255))){if(0==(64&i)){s=E[(65535&s)+(v&(1<<i)-1)];continue}e.msg="invalid distance code",l.mode=30;break e}if(n=65535&s,T<(i&=15)&&(v+=c[d++]<<T,(T+=8)<i)&&(v+=c[d++]<<T,T+=8),(n+=v&(1<<i)-1)>m){e.msg="invalid distance too far back",l.mode=30;break e}if(v>>>=i,T-=i,n>(i=u-p)){if((i=n-i)>f&&l.sane){e.msg="invalid distance too far back",l.mode=30;break e}if(a=C,(r=0)===I){if(r+=M-i,i<o){for(o-=i;h[u++]=C[r++],--i;);r=u-n,a=h}}else if(I<i){if(r+=M+I-i,(i-=I)<o){for(o-=i;h[u++]=C[r++],--i;);if(r=0,I<o){for(o-=i=I;h[u++]=C[r++],--i;);r=u-n,a=h}}}else if(r+=I-i,i<o){for(o-=i;h[u++]=C[r++],--i;);r=u-n,a=h}for(;2<o;)h[u++]=a[r++],h[u++]=a[r++],h[u++]=a[r++],o-=3;o&&(h[u++]=a[r++],1<o)&&(h[u++]=a[r++])}else{for(r=u-n;h[u++]=h[r++],h[u++]=h[r++],h[u++]=h[r++],2<(o-=3););o&&(h[u++]=h[r++],1<o)&&(h[u++]=h[r++])}break}}break}}while(d<_&&u<g);d-=o=T>>3,v&=(1<<(T-=o<<3))-1,e.next_in=d,e.next_out=u,e.avail_in=d<_?_-d+5:5-(d-_),e.avail_out=u<g?g-u+257:257-(u-g),l.hold=v,l.bits=T},$n=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],Wn=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],Yn=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],zn=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64],jn=function(e,t,s,i,o,n,r,a){var l,d,c,_,u,h,p,g,m,M=a.bits,f=0,I=0,C=0,v=0,T=0,y=0,E=0,S=0,D=0,R=0,L=null,A=0,O=new xn.Buf16(16),N=new xn.Buf16(16),P=null,U=0;for(f=0;f<=15;f++)O[f]=0;for(I=0;I<i;I++)O[t[s+I]]++;for(T=M,v=15;1<=v&&0===O[v];v--);if(v<T&&(T=v),0===v)o[n++]=20971520,o[n++]=20971520,a.bits=1;else{for(C=1;C<v&&0===O[C];C++);for(T<C&&(T=C),f=S=1;f<=15;f++)if((S=(S<<1)-O[f])<0)return-1;if(0<S&&(0===e||1!==v))return-1;for(N[1]=0,f=1;f<15;f++)N[f+1]=N[f]+O[f];for(I=0;I<i;I++)0!==t[s+I]&&(r[N[t[s+I]]++]=I);if(h=0===e?(L=P=r,19):1===e?(L=$n,A-=257,P=Wn,U-=257,256):(L=Yn,P=zn,-1),f=C,u=n,E=I=R=0,c=-1,_=(D=1<<(y=T))-1,1===e&&852<D||2===e&&592<D)return 1;for(;;){for(m=r[I]<h?(g=0,r[I]):r[I]>h?(g=P[U+r[I]],L[A+r[I]]):(g=96,0),l=1<<(p=f-E),C=d=1<<y;o[u+(R>>E)+(d-=l)]=p<<24|g<<16|m,0!==d;);for(l=1<<f-1;R&l;)l>>=1;if(R=0!==l?(R&l-1)+l:0,I++,0==--O[f]){if(f===v)break;f=t[s+r[I]]}if(T<f&&(R&_)!==c){for(u+=C,S=1<<(y=f-(E=0===E?T:E));y+E<v&&!((S-=O[y+E])<=0);)y++,S<<=1;if(D+=1<<y,1===e&&852<D||2===e&&592<D)return 1;o[c=R&_]=T<<24|y<<16|u-n}}0!==R&&(o[u+R]=f-E<<24|64<<16),a.bits=T}return 0};function Jn(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Xn(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new xn.Buf16(320),this.work=new xn.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Zn(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=1,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new xn.Buf32(852),t.distcode=t.distdyn=new xn.Buf32(592),t.sane=1,t.back=-1,0):-2}function Qn(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,Zn(e)):-2}function er(e,t){var s,i;return!e||!e.state||(i=e.state,t<0?(s=0,t=-t):(s=1+(t>>4),t<48&&(t&=15)),t&&(t<8||15<t))?-2:(null!==i.window&&i.wbits!==t&&(i.window=null),i.wrap=s,i.wbits=t,Qn(e))}function tr(e,t){var s;return e?(s=new Xn,(e.state=s).window=null,0!==(s=er(e,t))&&(e.state=null),s):-2}var sr,ir,or=!0;function nr(e){if(or){var t;for(sr=new xn.Buf32(512),ir=new xn.Buf32(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(jn(1,e.lens,0,288,sr,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;jn(2,e.lens,0,32,ir,0,e.work,{bits:5}),or=!1}e.lencode=sr,e.lenbits=9,e.distcode=ir,e.distbits=5}function rr(e,t,s,i){var o;e=e.state;return null===e.window&&(e.wsize=1<<e.wbits,e.wnext=0,e.whave=0,e.window=new xn.Buf8(e.wsize)),i>=e.wsize?(xn.arraySet(e.window,t,s-e.wsize,e.wsize,0),e.wnext=0,e.whave=e.wsize):((o=e.wsize-e.wnext)>i&&(o=i),xn.arraySet(e.window,t,s-i,o,e.wnext),(i-=o)?(xn.arraySet(e.window,t,s-i,i,0),e.wnext=i,e.whave=e.wsize):(e.wnext+=o,e.wnext===e.wsize&&(e.wnext=0),e.whave<e.wsize&&(e.whave+=o))),0}var ar={inflateReset:Qn,inflateReset2:er,inflateResetKeep:Zn,inflateInit:function(e){return tr(e,15)},inflateInit2:tr,inflate:function(e,t){var s,i,o,n,r,a,l,d,c,_,u,h,p,g,m,M,f,I,C,v,T,y,E,S,D=0,R=new xn.Buf8(4),L=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!e||!e.state||!e.output||!e.input&&0!==e.avail_in)return-2;12===(s=e.state).mode&&(s.mode=13),r=e.next_out,o=e.output,l=e.avail_out,n=e.next_in,i=e.input,a=e.avail_in,d=s.hold,c=s.bits,_=a,u=l,y=0;e:for(;;)switch(s.mode){case 1:if(0===s.wrap)s.mode=13;else{for(;c<16;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}if(2&s.wrap&&35615===d)R[s.check=0]=255&d,R[1]=d>>>8&255,s.check=Kn(s.check,R,2,0),c=d=0,s.mode=2;else if(s.flags=0,s.head&&(s.head.done=!1),!(1&s.wrap)||(((255&d)<<8)+(d>>8))%31)e.msg="incorrect header check",s.mode=30;else if(8!=(15&d))e.msg="unknown compression method",s.mode=30;else{if(c-=4,T=8+(15&(d>>>=4)),0===s.wbits)s.wbits=T;else if(T>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<T,e.adler=s.check=1,s.mode=512&d?10:12,c=d=0}}break;case 2:for(;c<16;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}if(s.flags=d,8!=(255&s.flags)){e.msg="unknown compression method",s.mode=30;break}if(57344&s.flags){e.msg="unknown header flags set",s.mode=30;break}s.head&&(s.head.text=d>>8&1),512&s.flags&&(R[0]=255&d,R[1]=d>>>8&255,s.check=Kn(s.check,R,2,0)),c=d=0,s.mode=3;case 3:for(;c<32;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}s.head&&(s.head.time=d),512&s.flags&&(R[0]=255&d,R[1]=d>>>8&255,R[2]=d>>>16&255,R[3]=d>>>24&255,s.check=Kn(s.check,R,4,0)),c=d=0,s.mode=4;case 4:for(;c<16;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}s.head&&(s.head.xflags=255&d,s.head.os=d>>8),512&s.flags&&(R[0]=255&d,R[1]=d>>>8&255,s.check=Kn(s.check,R,2,0)),c=d=0,s.mode=5;case 5:if(1024&s.flags){for(;c<16;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}s.length=d,s.head&&(s.head.extra_len=d),512&s.flags&&(R[0]=255&d,R[1]=d>>>8&255,s.check=Kn(s.check,R,2,0)),c=d=0}else s.head&&(s.head.extra=null);s.mode=6;case 6:if(1024&s.flags&&((h=(h=s.length)>a?a:h)&&(s.head&&(T=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),xn.arraySet(s.head.extra,i,n,h,T)),512&s.flags&&(s.check=Kn(s.check,i,h,n)),a-=h,n+=h,s.length-=h),s.length))break e;s.length=0,s.mode=7;case 7:if(2048&s.flags){if(0===a)break e;for(h=0;T=i[n+h++],s.head&&T&&s.length<65536&&(s.head.name+=String.fromCharCode(T)),T&&h<a;);if(512&s.flags&&(s.check=Kn(s.check,i,h,n)),a-=h,n+=h,T)break e}else s.head&&(s.head.name=null);s.length=0,s.mode=8;case 8:if(4096&s.flags){if(0===a)break e;for(h=0;T=i[n+h++],s.head&&T&&s.length<65536&&(s.head.comment+=String.fromCharCode(T)),T&&h<a;);if(512&s.flags&&(s.check=Kn(s.check,i,h,n)),a-=h,n+=h,T)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;c<16;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}if(d!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}c=d=0}s.head&&(s.head.hcrc=s.flags>>9&1,s.head.done=!0),e.adler=s.check=0,s.mode=12;break;case 10:for(;c<32;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}e.adler=s.check=Jn(d),c=d=0,s.mode=11;case 11:if(0===s.havedict)return e.next_out=r,e.avail_out=l,e.next_in=n,e.avail_in=a,s.hold=d,s.bits=c,2;e.adler=s.check=1,s.mode=12;case 12:if(5===t||6===t)break e;case 13:if(s.last)d>>>=7&c,c-=7&c,s.mode=27;else{for(;c<3;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}switch(s.last=1&d,--c,3&(d>>>=1)){case 0:s.mode=14;break;case 1:if(nr(s),s.mode=20,6!==t)break;d>>>=2,c-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}d>>>=2,c-=2}break;case 14:for(d>>>=7&c,c-=7&c;c<32;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}if((65535&d)!=(d>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&d,c=d=0,s.mode=15,6===t)break e;case 15:s.mode=16;case 16:if(h=s.length){if(0===(h=l<(h=a<h?a:h)?l:h))break e;xn.arraySet(o,i,n,h,r),a-=h,n+=h,l-=h,r+=h,s.length-=h}else s.mode=12;break;case 17:for(;c<14;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}if(s.nlen=257+(31&d),d>>>=5,c-=5,s.ndist=1+(31&d),d>>>=5,c-=5,s.ncode=4+(15&d),d>>>=4,c-=4,286<s.nlen||30<s.ndist){e.msg="too many length or distance symbols",s.mode=30;break}s.have=0,s.mode=18;case 18:for(;s.have<s.ncode;){for(;c<3;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}s.lens[L[s.have++]]=7&d,d>>>=3,c-=3}for(;s.have<19;)s.lens[L[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,E={bits:s.lenbits},y=jn(0,s.lens,0,19,s.lencode,0,s.work,E),s.lenbits=E.bits,y){e.msg="invalid code lengths set",s.mode=30;break}s.have=0,s.mode=19;case 19:for(;s.have<s.nlen+s.ndist;){for(;M=(D=s.lencode[d&(1<<s.lenbits)-1])>>>16&255,f=65535&D,!((m=D>>>24)<=c);){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}if(f<16)d>>>=m,c-=m,s.lens[s.have++]=f;else{if(16===f){for(S=m+2;c<S;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}if(d>>>=m,c-=m,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}T=s.lens[s.have-1],h=3+(3&d),d>>>=2,c-=2}else if(17===f){for(S=m+3;c<S;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}T=0,h=3+(7&(d>>>=m)),d>>>=3,c=c-m-3}else{for(S=m+7;c<S;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}T=0,h=11+(127&(d>>>=m)),d>>>=7,c=c-m-7}if(s.have+h>s.nlen+s.ndist){e.msg="invalid bit length repeat",s.mode=30;break}for(;h--;)s.lens[s.have++]=T}}if(30===s.mode)break;if(0===s.lens[256]){e.msg="invalid code -- missing end-of-block",s.mode=30;break}if(s.lenbits=9,E={bits:s.lenbits},y=jn(1,s.lens,0,s.nlen,s.lencode,0,s.work,E),s.lenbits=E.bits,y){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,E={bits:s.distbits},y=jn(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,E),s.distbits=E.bits,y){e.msg="invalid distances set",s.mode=30;break}if(s.mode=20,6===t)break e;case 20:s.mode=21;case 21:if(6<=a&&258<=l){e.next_out=r,e.avail_out=l,e.next_in=n,e.avail_in=a,s.hold=d,s.bits=c,Hn(e,u),r=e.next_out,o=e.output,l=e.avail_out,n=e.next_in,i=e.input,a=e.avail_in,d=s.hold,c=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;M=(D=s.lencode[d&(1<<s.lenbits)-1])>>>16&255,f=65535&D,!((m=D>>>24)<=c);){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}if(M&&0==(240&M)){for(I=m,C=M,v=f;M=(D=s.lencode[v+((d&(1<<I+C)-1)>>I)])>>>16&255,f=65535&D,!(I+(m=D>>>24)<=c);){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}d>>>=I,c-=I,s.back+=I}if(d>>>=m,c-=m,s.back+=m,s.length=f,0===M){s.mode=26;break}if(32&M){s.back=-1,s.mode=12;break}if(64&M){e.msg="invalid literal/length code",s.mode=30;break}s.extra=15&M,s.mode=22;case 22:if(s.extra){for(S=s.extra;c<S;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}s.length+=d&(1<<s.extra)-1,d>>>=s.extra,c-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;M=(D=s.distcode[d&(1<<s.distbits)-1])>>>16&255,f=65535&D,!((m=D>>>24)<=c);){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}if(0==(240&M)){for(I=m,C=M,v=f;M=(D=s.distcode[v+((d&(1<<I+C)-1)>>I)])>>>16&255,f=65535&D,!(I+(m=D>>>24)<=c);){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}d>>>=I,c-=I,s.back+=I}if(d>>>=m,c-=m,s.back+=m,64&M){e.msg="invalid distance code",s.mode=30;break}s.offset=f,s.extra=15&M,s.mode=24;case 24:if(s.extra){for(S=s.extra;c<S;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}s.offset+=d&(1<<s.extra)-1,d>>>=s.extra,c-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){e.msg="invalid distance too far back",s.mode=30;break}s.mode=25;case 25:if(0===l)break e;if(s.offset>(h=u-l)){if((h=s.offset-h)>s.whave&&s.sane){e.msg="invalid distance too far back",s.mode=30;break}p=h>s.wnext?(h-=s.wnext,s.wsize-h):s.wnext-h,h>s.length&&(h=s.length),g=s.window}else g=o,p=r-s.offset,h=s.length;for(l-=h=l<h?l:h,s.length-=h;o[r++]=g[p++],--h;);0===s.length&&(s.mode=21);break;case 26:if(0===l)break e;o[r++]=s.length,l--,s.mode=21;break;case 27:if(s.wrap){for(;c<32;){if(0===a)break e;a--,d|=i[n++]<<c,c+=8}if(u-=l,e.total_out+=u,s.total+=u,u&&(e.adler=s.check=(s.flags?Kn:Vn)(s.check,o,u,r-u)),u=l,(s.flags?d:Jn(d))!==s.check){e.msg="incorrect data check",s.mode=30;break}c=d=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;c<32;){if(0===a)break e;a--,d+=i[n++]<<c,c+=8}if(d!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=30;break}c=d=0}s.mode=29;case 29:y=1;break e;case 30:y=-3;break e;case 31:return-4;default:return-2}return e.next_out=r,e.avail_out=l,e.next_in=n,e.avail_in=a,s.hold=d,s.bits=c,(s.wsize||u!==e.avail_out&&s.mode<30&&(s.mode<27||4!==t))&&rr(e,e.output,e.next_out,u-e.avail_out),_-=e.avail_in,u-=e.avail_out,e.total_in+=_,e.total_out+=u,s.total+=u,s.wrap&&u&&(e.adler=s.check=(s.flags?Kn:Vn)(s.check,o,u,e.next_out-u)),e.data_type=s.bits+(s.last?64:0)+(12===s.mode?128:0)+(20===s.mode||15===s.mode?256:0),(0==_&&0===u||4===t)&&0===y?-5:y},inflateEnd:function(e){var t;return e&&e.state?((t=e.state).window&&(t.window=null),e.state=null,0):-2},inflateGetHeader:function(e,t){return e&&e.state&&0!=(2&(e=e.state).wrap)?((e.head=t).done=!1,0):-2},inflateSetDictionary:function(e,t){var s,i=t.length;return!e||!e.state||0!==(s=e.state).wrap&&11!==s.mode?-2:11===s.mode&&Vn(1,t,i,0)!==s.check?-3:rr(e,t,i,i)?(s.mode=31,-4):(s.havedict=1,0)},inflateInfo:"pako inflate (from Nodeca project)"},lr=!0,dr=!0;try{String.fromCharCode.apply(null,[0])}catch(i){lr=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(i){dr=!1}for(var cr=new xn.Buf8(256),_r=0;_r<256;_r++)cr[_r]=252<=_r?6:248<=_r?5:240<=_r?4:224<=_r?3:192<=_r?2:1;function ur(e,t){if(t<65534&&(e.subarray&&dr||!e.subarray&&lr))return String.fromCharCode.apply(null,xn.shrinkBuf(e,t));for(var s="",i=0;i<t;i++)s+=String.fromCharCode(e[i]);return s}cr[254]=cr[254]=1;var hr=function(e){for(var t,s,i,o,n=e.length,r=0,a=0;a<n;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<n&&56320==(64512&(i=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(i-56320),a++),r+=s<128?1:s<2048?2:s<65536?3:4;for(t=new xn.Buf8(r),a=o=0;o<r;a++)55296==(64512&(s=e.charCodeAt(a)))&&a+1<n&&56320==(64512&(i=e.charCodeAt(a+1)))&&(s=65536+(s-55296<<10)+(i-56320),a++),s<128?t[o++]=s:(s<2048?t[o++]=192|s>>>6:(s<65536?t[o++]=224|s>>>12:(t[o++]=240|s>>>18,t[o++]=128|s>>>12&63),t[o++]=128|s>>>6&63),t[o++]=128|63&s);return t},pr=function(e){for(var t=new xn.Buf8(e.length),s=0,i=t.length;s<i;s++)t[s]=e.charCodeAt(s);return t},gr=function(e,t){for(var s,i,o=t||e.length,n=new Array(2*o),r=0,a=0;a<o;)if((s=e[a++])<128)n[r++]=s;else if(4<(i=cr[s]))n[r++]=65533,a+=i-1;else{for(s&=2===i?31:3===i?15:7;1<i&&a<o;)s=s<<6|63&e[a++],i--;1<i?n[r++]=65533:s<65536?n[r++]=s:(s-=65536,n[r++]=55296|s>>10&1023,n[r++]=56320|1023&s)}return ur(n,r)},mr=function(e,t){for(var s=(t=(t=t||e.length)>e.length?e.length:t)-1;0<=s&&128==(192&e[s]);)s--;return!(s<0||0===s)&&s+cr[e[s]]>t?s:t},Mr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},fr={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},Ir=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0},Cr=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1},vr=Object.prototype.toString;function Tr(e){if(!(this instanceof Tr))return new Tr(e);this.options=xn.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&0<=t.windowBits&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits)&&(t.windowBits=-15),!(0<=t.windowBits&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),15<t.windowBits&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ir,this.strm.avail_out=0,e=ar.inflateInit2(this.strm,t.windowBits);if(e!==Mr.Z_OK)throw new Error(fr[e]);if(this.header=new Cr,ar.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=hr(t.dictionary):"[object ArrayBuffer]"===vr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(e=ar.inflateSetDictionary(this.strm,t.dictionary))!==Mr.Z_OK)throw new Error(fr[e])}function yr(e,t){if(t=new Tr(t),t.push(e,!0),t.err)throw t.msg||fr[t.err];return t.result}Tr.prototype.push=function(e,t){var s,i,o,n,r,a=this.strm,l=this.options.chunkSize,d=this.options.dictionary,c=!1;if(this.ended)return!1;i=t===~~t?t:!0===t?Mr.Z_FINISH:Mr.Z_NO_FLUSH,"string"==typeof e?a.input=pr(e):"[object ArrayBuffer]"===vr.call(e)?a.input=new Uint8Array(e):a.input=e,a.next_in=0,a.avail_in=a.input.length;do{if(0===a.avail_out&&(a.output=new xn.Buf8(l),a.next_out=0,a.avail_out=l),(s=(s=ar.inflate(a,Mr.Z_NO_FLUSH))===Mr.Z_NEED_DICT&&d?ar.inflateSetDictionary(this.strm,d):s)===Mr.Z_BUF_ERROR&&!0===c&&(s=Mr.Z_OK,c=!1),s!==Mr.Z_STREAM_END&&s!==Mr.Z_OK)return this.onEnd(s),!(this.ended=!0)}while(!a.next_out||0!==a.avail_out&&s!==Mr.Z_STREAM_END&&(0!==a.avail_in||i!==Mr.Z_FINISH&&i!==Mr.Z_SYNC_FLUSH)||("string"===this.options.to?(o=mr(a.output,a.next_out),n=a.next_out-o,r=gr(a.output,o),a.next_out=n,a.avail_out=l-n,n&&xn.arraySet(a.output,a.output,o,n,0),this.onData(r)):this.onData(xn.shrinkBuf(a.output,a.next_out))),0===a.avail_in&&0===a.avail_out&&(c=!0),(0<a.avail_in||0===a.avail_out)&&s!==Mr.Z_STREAM_END);return(i=s===Mr.Z_STREAM_END?Mr.Z_FINISH:i)===Mr.Z_FINISH?(s=ar.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===Mr.Z_OK):i!==Mr.Z_SYNC_FLUSH||(this.onEnd(Mr.Z_OK),!(a.avail_out=0))},Tr.prototype.onData=function(e){this.chunks.push(e)},Tr.prototype.onEnd=function(e){e===Mr.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=xn.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Er={Inflate:Tr,inflate:yr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,yr(e,t)},ungzip:yr},Sr={},Dr=((0,xn.assign)(Sr,Er,Mr),Sr);class Rr{constructor(e){this._m=e,this._n="InflateModule",this._bLogForInflateOK=!1,this._bLogForInflateError=!1}inflate(e){e=new Uint8Array(e).slice(4);var t=Date.now();let s;try{s=Dr.inflate(e,{to:"string"}),this._bLogForInflateOK||(this._bLogForInflateOK=!0,new Ei("inflateOK").end())}catch(e){return this._bLogForInflateError?void 0:(this._bLogForInflateError=!0,void new Ei("inflateError").setMessage(e).end())}e=e.length+4;var i=s.length;return ye.d(`inflate ok. zipped:${e} unzipped:${i} compression ratio:${Math.round(100*(i-e)/i)}% cost:`+(Date.now()-t)),s}reset(){ye.l(this._n+".reset"),this._bLogForInflateOK=!1,this._bLogForInflateError=!1}}class Lr{constructor(e){var t=new Ei("sdkConstruct");if(this._n="ModuleManager",this._isReady=!1,this._reason=ii.USER_NOT_LOGGED_IN,this._startLoginTs=0,this._map=new Map,this._optionalModuleMap=new Map,this._codeMsgForTUIMap=new Map,this._iEmitter=null,this._oEmitter=null,this._checkCount=0,this._checkTimer=-1,this._map.set(Os,new Do(this,e)),this._map.set(Qs,new Rr(this)),this._map.set(Us,new wo(this)),this._map.set(Ks,new Gn(this)),this._map.set(qs,new Sn(this)),this._map.set(xs,new Pn(this)),this._map.set(Bs,new Nn(this)),this._map.set(Fs,new mn(this)),this._map.set(bs,new En(this)),this._map.set(vs,new Lo(this)),this._map.set(Ts,new Yo(this)),this._map.set(ys,new zo(this)),this._map.set(Js,new jo(this)),this._map.set(Ys,new Jo(this)),this._map.set(Es,new So(this)),this._map.set(Ss,new ji(this)),this._map.set(As,new go(this)),this._map.set(Ls,new Io(this)),this._map.set(Ns,new Oo(this)),this._map.set(zs,new qn(this)),this._map.set(Ps,new Uo(this)),this._map.set(Gs,new Bo(this)),this._map.set(ks,new Xo(this)),this._map.set(ws,new Zo(this)),this._map.set(Vs,new Dn(this)),this._map.set(Hs,new kn(this)),this._map.set(Zs,new wn(this)),this._map.set($s,new bn(this)),this._map.set(Ws,new Fn(this)),this._eventThrottleMap=new Map,this._eventThrottling=e.eventThrottling,this._map.get(Os).isPartialUpdatedConvs()&&(this._eventThrottling=!1),xe(e.modules)){let t;Object.keys(e.modules).forEach((s=>{t=e.modules[s],"group-module"===s?this._map.set(Ds,new t(this)):"relationship-module"===s?this._map.set(Rs,new t(this)):"signaling-module"===s?this._map.set(js,new t(this)):"follow-module"===s?this._map.set(Xs,new t(this)):"cloud-search-module"===s&&this._map.set(ei,new t(this)),this._optionalModuleMap.set(s,1)})),this._map.get(Os).setUsingChatCore(!0)}else this._map.has(Ds)||this._map.get(Os).setUsingChatCore(!0);var{instanceID:s,SDKAppID:i}=e,s=`instanceID:${s} SDKAppID:${i} isIntl:${this._map.get(Os).isIntl()} isUsingChatCore:${this._map.get(Os).isUsingChatCore()} host:${mt()} isIOSWebView:${_e} platform:${Y} canIUseInflate:${this.canIUseInflate()} workerAvailable:${le} eventThrottling:${this._eventThrottling} UserAgent:`+$;Ei.bindEventStatModule(this._map.get(Ps)),Ei.bindNetMonitorModule(this._map.get(Us)),t.setMessage(s+" "+function(){let e="";if(x)try{var{model:t,version:s,system:i,platform:o,SDKVersion:n}=H.getSystemInfoSync();e=`model:${t} version:${s} system:${i} platform:${o} SDKVersion:`+n}catch(t){e=""}return e}()).end(),ye.i("SDK "+s),si.prototype._getErrMsg=this.getErrMsg.bind(this),this._readyList=void 0,this._ssoLogForReady=null,this._initReadyList()}_startTimer(){var e=this._map.get(xs),t=e.isWorkerEnabled();ye.l(this._n+`.startTimer isWorkerEnabled:${t} seed:`+this._checkTimer),t?e.startWorkerTimer():this._startMainThreadTimer()}_startMainThreadTimer(){this._checkTimer<0&&(this._checkTimer=setInterval(this.onCheckTimer.bind(this),1e3)),ye.l(this._n+"._startMainThreadTimer seed:"+this._checkTimer)}stopTimer(){var e=this._map.get(xs),t=e.isWorkerEnabled();ye.l(this._n+`.stopTimer isWorkerEnabled:${t} seed:`+this._checkTimer),t?e.stopWorkerTimer():this._stopMainThreadTimer()}_stopMainThreadTimer(){ye.l(this._n+"._stopMainThreadTimer"),0<this._checkTimer&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}_stopMainThreadSocket(){ye.l(this._n+"._stopMainThreadSocket");var e=this._map.get(Fs);e.setIsWorkerEnabled(!0),e.reConnect()}_startMainThreadSocket(){ye.l(this._n+"._startMainThreadSocket");var e=this._map.get(Fs);e.setIsWorkerEnabled(!1),e.reConnect()}onWorkerTimerEnabled(){ye.l(this._n+".onWorkerTimerEnabled, disable main thread timer and socket"),this._stopMainThreadTimer(),this._stopMainThreadSocket()}onWorkerTimerDisabled(){ye.l(this._n+".onWorkerTimerDisabled, enable main thread timer and socket"),this._startMainThreadTimer(),this._startMainThreadSocket()}onCheckTimer(){for(var[,e]of(this._checkCount+=1,this._map))e.onCheckTimer&&e.onCheckTimer(this._checkCount)}_initReadyList(){this._readyList=[this._map.get(vs)],this._readyList.forEach((e=>{e.ready((()=>this._onModuleReady()))}))}_onModuleReady(){let e=!0;if(this._readyList.forEach((t=>{t.isReady()||(e=!1)})),e&&!this._isReady){this._isReady=!0,this._oEmitter.emit(i.SDK_READY);let e=Date.now()-this._startLoginTs;ye.w(`SDK is ready. cost ${e} ms`),this._startLoginTs=Date.now();var t=this._ssoLogForReady.getStartTs()+me;this._ssoLogForReady.setMessage(e).start(t).end()}}login(){0===this._startLoginTs&&(fe(),this._startLoginTs=Date.now(),this._startTimer(),this._map.get(Us).start(),this._ssoLogForReady=new Ei("sdkReady"),this._reason=ii.LOGGING_IN)}onLoginFailed(){this._startLoginTs=0}getOEmitInst(){return null===this._oEmitter&&(this._oEmitter=new Fo,ni(this._oEmitter),this._oEmitter._emit=this._oEmitter.emit,this._oEmitter.emit=function(e,t){if(this._canIUseSignaling()&&(e===i.MESSAGE_RECEIVED&&this.get(js).onNewMessageList(t),e===i.MESSAGE_MODIFIED)&&this.get(js).onMessageModified(t),e===i.CONVERSATION_LIST_UPDATED||e===i.FRIEND_LIST_UPDATED||e===i.GROUP_LIST_UPDATED||e===i.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED)if(!1!==this._eventThrottling)if(this._eventThrottleMap.has(e)){let t=Date.now(),s=this._eventThrottleMap.get(e);t-s.last<=1e3?(-1<s.timeoutID&&clearTimeout(s.timeoutID),s.timeoutID=setTimeout((()=>{s.last=Date.now(),this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:this._getEventData(e)}])}),1e3)):(s.last=t,this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:this._getEventData(e)}]))}else this._eventThrottleMap.set(e,{last:Date.now(),timeoutID:-1}),this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:this._getEventData(e)}]);else this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:this._getEventData(e)}]);else this._oEmitter._emit.apply(this._oEmitter,[e,{name:e,data:t}])}.bind(this)),this._oEmitter}_canIUseSignaling(){var e=this.get(js);return!!e&&e.canIUseSignaling()}_getEventData(e){return e===i.CONVERSATION_LIST_UPDATED?this._map.get(Os).isPartialUpdatedConvs()?this._map.get(As).getPartialUpdatedConvs():this._map.get(As).getLocalConvList():e===i.FRIEND_LIST_UPDATED?this._map.get(Rs).getLocalFriendList(!1):e===i.GROUP_LIST_UPDATED?this._map.get(Ds).getLocalGroupList():e===i.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED?this._map.get(As).getTotalUnreadCount():e===i.CONVERSATION_ID_LIST_UPDATED?this._map.get(As).getUpdatedConvIDList():void 0}getIEmitInst(){return null===this._iEmitter&&(this._iEmitter=new Fo,this._iEmitter._emit=this._iEmitter.emit,this._iEmitter.emit=function(e,t){e=xe(t)&&t.data?[e,{name:e,data:t.data}]:[e,{name:e,data:t}],this._iEmitter._emit.apply(this._iEmitter,e)}.bind(this)),this._iEmitter}hasModule(e){return this._map.has(e)}get(e){return this._map.get(e)}canIUseModule(e){return!this._map.get(Os).isUsingChatCore()||this._optionalModuleMap.has(e)}canIUseInflate(){return!!this._map.get(Qs)}isReady(){return this._isReady}isIntl(){return this.get(Os).isIntl()}getNotReadyReason(){return this._reason}setNotReadyReason(e){this._reason=e}getErrMsg(e,t,s){return this._map.get(zs).get({key:e,replacement1:t,replacement2:s,isIntl:this.isIntl()})}warn(e,t,s){e=this.getErrMsg(e,t,s),e&&ye.w(e)}onError(e){var t=`code:${e.code} message:`+e.message;ye.w("Oops! "+t),new Ei("error").setMessage(t).setLevel("error").end(),this.getOEmitInst().emit(i.ERROR,e)}restartTimer(){ye.l(this._n+".restartTimer"),this.stopTimer(),this._startTimer();var e=this.get(Ds);e&&e.restartPolling()}getTimerID(){var e=this._map.get(xs);return e.isWorkerEnabled()?e.getTimerID():this._checkTimer}getPollingTimerID(e){return this._map.get(Ds).getPollingTimerID(e)}statTUIKeyFeatures(e){var{code:e,msg:t=""}=e,s=e+t;this._codeMsgForTUIMap.has(s)||(this._codeMsgForTUIMap.set(s,1),s=this.get(Os).getUIPlatform(),new Ei("tui_key_features").setCode(e).setMessage(t).setUIPlatform(s).end())}reset(){ye.l(this._n+".reset"),fe();for(let[,e]of this._map)e.reset&&e.reset();this._startLoginTs=0,this._initReadyList(),this._isReady=!1,this.stopTimer(),this._oEmitter.emit(i.SDK_NOT_READY);for(let[,e]of this._eventThrottleMap)-1<e.timeoutID&&clearTimeout(e.timeoutID);this._eventThrottleMap.clear(),this._codeMsgForTUIMap.clear()}}class Ar{constructor(e){this._funcMap=new Map,this._m=e,this._n="SafetyCallback",this._reportCount=0}defense(e,t,s){if("string"!=typeof e)return null;if(0===e.length)return null;if("function"!=typeof t)return null;if(this._funcMap.has(e)&&this._funcMap.get(e).has(t))return this._funcMap.get(e).get(t);this._funcMap.has(e)||this._funcMap.set(e,new Map);let i=null;return this._funcMap.get(e).has(t)?i=this._funcMap.get(e).get(t):(i=this._pack(e,t,s),this._funcMap.get(e).set(t,i)),i}defenseOnce(e,t,s){return"function"!=typeof t?null:this._pack(e,t,s)}find(e,t){return"string"!=typeof e||0===e.length||"function"!=typeof t?null:this._funcMap.has(e)&&this._funcMap.get(e).has(t)?this._funcMap.get(e).get(t):(this._m.warn("ListenerFnNotFound",e),null)}delete(e,t){return"function"==typeof t&&!!this._funcMap.has(e)&&!!this._funcMap.get(e).has(t)&&(this._funcMap.get(e).delete(t),0===this._funcMap.get(e).size&&this._funcMap.delete(e),!0)}_pack(e,t,s){let o=this;return function(){try{t.apply(s,Array.from(arguments))}catch(t){let n=Object.values(i).indexOf(e),r="CallbackError";if(-1!==n){let e=Object.keys(i)[n];o._m.warn(r,e,t)}o._reportCount<5&&(new Ei(r).setMessage("eventName:"+e).setMoreMessage(t.message).end(),o._reportCount+=1)}}}destroy(){this._funcMap.clear()}reset(){ye.l(this._n+".reset"),this._reportCount=0}}class Or{constructor(e){e={SDKAppID:e.SDKAppID,unlimitedAVChatRoom:e.unlimitedAVChatRoom||!1,scene:e.scene||"",oversea:e.oversea||!1,instanceID:gt(),devMode:e.devMode||!1,testEnv:e.testEnv||!1,proxyServer:e.proxyServer||void 0,fileUploadProxy:e.fileUploadProxy||void 0,fileDownloadProxy:e.fileDownloadProxy||e.fileUploadProxy||void 0,eventThrottling:!1!==e.eventThrottling,partialUpdatedConversations:!0===e.partialUpdatedConversations,disableIndependentDomain:!0===e.disableIndependentDomain,modules:e.modules||void 0},this._m=new Lr(e),this._safetyCallbackFactory=new Ar(this._m)}onError(e){this._m.onError(e)}login(e){return this._m.login(),this._get(vs).login(e)}logout(){return this._get(vs).logout().then((e=>(this._safetyCallbackFactory.reset(),this._m.reset(),e)))}getLoginUser(){return this._get(vs).getLoginUser()}getServerTime(){return Me()}isReady(){return this._m.isReady()}isIntl(){return this._m.isIntl()}getNotReadyReason(){return this._m.getNotReadyReason()}getErrMsg(e,t,s){return this._m.getErrMsg(e,t,s)}_get(e){return this._m.get(e)}destroy(){let e=this._get(Os),t=e.getSDKAppID();return ye.w(`destroy ${t} `+e.getInstanceID()),this.logout().finally((()=>{this._safetyCallbackFactory.destroy(),this._m.stopTimer(),this._get(xs).terminate(),this._get(Fs).dealloc(),this._m.getOEmitInst().emit(i.SDK_DESTROY,{SDKAppID:t})}))}on(e,t,s){ye.d("on","eventName:"+e),this._m.getOEmitInst().on(e,this._safetyCallbackFactory.defense(e,t,s),s)}once(e,t,s){ye.d("once","eventName:"+e),this._m.getOEmitInst().once(e,this._safetyCallbackFactory.defenseOnce(e,t,s),s||this)}off(e,t,s,i){ye.d("off","eventName:"+e);var o=this._safetyCallbackFactory.find(e,t);null!==o&&(this._m.getOEmitInst().off(e,o,s,i),this._safetyCallbackFactory.delete(e,t))}registerPlugin(e){(Be(e["tim-push"])?Be(e["tim-offline-push-plugin"])?this._get(ks):this._get(Hs):this._get(Zs)).registerPlugin(e)}setLogLevel(e){if(e<=0){let e=this.getErrMsg("TIM_ASCII_ART");e&&console.log(e);var t=this.getErrMsg("API_REFER");if(t){let e="IM SDK API ->";Rt()?console.log(`%c ${e} %c`,"background:#ff9d00; padding:1px; border-radius:3px; color: #fff","background:transparent",t):console.log(e,t)}t=this.getErrMsg("DOCS_GUIDE"),t&&console.log(t),t=this.getErrMsg("IOS_WEBVIEW_WARNING"),_e&&t&&console.warn(t)}ye.setLevel(e)}createTextMessage(e){return this._get(Ts).createTextMessage(e)}createTextAtMessage(e){return this._get(Ts).createTextMessage(e)}createImageMessage(e){return this._get(Ts).createImageMessage(e)}createAudioMessage(e){return this._get(Ts).createAudioMessage(e)}createVideoMessage(e){return this._get(Ts).createVideoMessage(e)}createCustomMessage(e){return this._get(Ts).createCustomMessage(e)}createFaceMessage(e){return this._get(Ts).createFaceMessage(e)}createFileMessage(e){return this._get(Ts).createFileMessage(e)}createLocationMessage(e){return this._get(Ts).createLocationMessage(e)}createMergerMessage(e){return this._get(Ts).createMergerMessage(e)}downloadMergerMessage(e){return e.type!==o.MSG_MERGER?ai({code:ii.MSG_MERGER_TYPE_INVALID}):Ue(e.payload.downloadKey)?ai({code:ii.MSG_MERGER_KEY_INVALID}):this._get(Ts).downloadMergerMessage(e).catch((e=>ai({code:ii.MSG_MERGER_DOWNLOAD_FAIL})))}createForwardMessage(e){return this._get(Ts).createForwardMessage(e)}sendMessage(e,t){return e instanceof Hi?this._get(Ts).sendMessageInstance(e,t):ai({code:ii.MSG_INSTANCE_REQUIRED})}callExperimentalAPI(e,t){return"sendComboMessage"===e?this._get(Ys).sendMessage(t):"handleGroupInvitation"===e?this._get(Ds).handleGroupInvitation(t):"isCommercialAbilityEnabled"===e?this._get(Ks).isFeatureEnabled(t):"isFeatureEnabledForStat"===e?this._get(Ks).isFeatureEnabledForStat(t):"isIntl"===e?this.isIntl():"sendTRTCCustomData"===e||"sendRoomCustomData"===e?this._get(Ws).sendTRTCCustomData(t):"getTimerID"===e?this._m.getTimerID():"getPollingTimerID"===e?this._m.getPollingTimerID(t):"setApplicationID"!==e?"getServerConfig"===e?this._get(qs).getServerConfig(t):"canIUseModule"===e?this._m.canIUseModule(t):"startMessageLongPolling"===e?this._get(Ds).startMessageLongPolling(t):"stopMessageLongPolling"===e?this._get(Ds).stopMessageLongPolling(t):"disableMessagePullOnInvite"===e?this._get(As).disableMsgPullOnInvite(t):"clearLocalMessage"===e?this._get(As).clearMemMsg(t,!1):"setCustomLoginInfo"===e?this._get(Os).setCustomLoginInfo(t):"statTUIKeyFeatures"===e?this._m.statTUIKeyFeatures(t):"getGroupReceiptsByUsers"===e?this._get(Ds).getGroupReceiptsByUsers(t):ai({code:ii.INVALID_OPERATION}):(this._get(Os).setApplicationID(t),void this._get(bs).updateProtocolConfig())}revokeMessage(e){return this._get(Ts).revokeMessage(e)}resendMessage(e,t){return e instanceof Hi?this._get(Ts).resendMessage(e,t):ai({code:ii.MSG_INSTANCE_REQUIRED})}deleteMessage(e){return this._get(Ts).deleteMessage(e)}translateText(e){return this._get(Ts).translateText(e)}convertVoiceToText(e){return this._get(Ts).convertVoiceToText(e)}setMessageExtensions(e,t){return this._get(ys).setMessageExtensions(e,t)}getMessageExtensions(e){return this._get(ys).getMessageExtensions(e)}deleteMessageExtensions(e,t){return this._get(ys).deleteMessageExtensions(e,t)}addMessageReaction(e,t){return this._get(Js).addMessageReaction(e,t)}removeMessageReaction(e,t){return this._get(Js).removeMessageReaction(e,t)}getMessageReactions(e){return this._get(Js).getMessageReactions(e)}getAllUserListOfMessageReaction(e){return this._get(Js).getAllUserListOfMessageReaction(e)}modifyMessage(e){return this._get(Ts).modifyRemoteMessage(e)}getMessageList(e){return this._get(As).getMessageList(e)}getMessageListHopping(e){return this._get(As).getMessageListHopping(e)}sendMessageReadReceipt(e){return this._get(As).sendReadReceipt(e)}getMessageReadReceiptList(e){return this._get(As).getReadReceiptList(e)}getGroupMessageReadMemberList(e){var t=this._get(Ds);return t?t.getReadReceiptDetail(e):ai({code:ii.NO_MODULE})}findMessage(e){return this._get(As).findMessage(e)}setMessageRead(e){return this._get(As).setMessageRead(e)}getConversationList(e){return this._get(As).getConvList(e)}getConversationProfile(e){return this._get(As).getConversationProfile(e)}deleteConversation(e){return this._get(As).deleteConversation(e)}setConversationDraft(e){return this._get(As).setConvDraft(e)}clearHistoryMessage(e){return this._get(As).clearHistoryMessage(e)}pinConversation(e){return this._get(As).pinConversation(e)}setAllMessageRead(e){return this._get(As).setAllMessageRead(e)}setMessageRemindType(e){return this._get(As).setMessageRemindType(e)}setAllReceiveMessageOpt(e){return this._get(As).setAllRcvMsgOpt(e)}getAllReceiveMessageOpt(){return this._get(As).getAllRcvMsgOpt()}getTotalUnreadMessageCount(){return this._get(As).getTotalUnreadCount()}setConversationCustomData(e){return this._get(As).setConvCustomData(e)}markConversation(e){return this._get(As).markConv(e)}getConversationGroupList(){return this._get(As).getConvGroupList()}createConversationGroup(e){return this._get(As).createConvGroup(e)}deleteConversationGroup(e){return this._get(As).deleteConvGroup(e)}renameConversationGroup(e){return this._get(As).renameConvGroup(e)}addConversationsToGroup(e){return this._get(As).addConvsToGroup(e)}deleteConversationsFromGroup(e){return this._get(As).deleteConvsFromGroup(e)}searchCloudMessages(e){var t=this._get(ei);return t?t.searchCloudMessages(e):ai({code:ii.NO_MODULE})}searchCloudUsers(e){var t=this._get(ei);return t?t.searchCloudUsers(e):ai({code:ii.NO_MODULE})}searchCloudGroups(e){var t=this._get(ei);return t?t.searchCloudGroups(e):ai({code:ii.NO_MODULE})}searchCloudGroupMembers(e){var t=this._get(ei);return t?t.searchCloudGroupMembers(e):ai({code:ii.NO_MODULE})}getMyProfile(){return this._get(Es).getMyProfile()}getUserProfile(e){return this._get(Es).getUserProfile(e)}updateMyProfile(e){return this._get(Es).updateMyProfile(e)}getBlacklist(){return this._get(Es).getLocalBlacklist()}addToBlacklist(e){return this._get(Es).addBlacklist(e)}removeFromBlacklist(e){return this._get(Es).deleteBlacklist(e)}setSelfStatus(e){return this._get(Es).setSelfStatus(e)}getUserStatus(e){return this._get(Es).getUserStatus(e)}subscribeUserStatus(e){return this._get(Es).subscribeUserStatus(e)}unsubscribeUserStatus(e){return this._get(Es).unsubscribeUserStatus(e)}getFriendList(){var e=this._get(Rs);return e?e.getLocalFriendList():ai({code:ii.NO_MODULE})}addFriend(e){var t=this._get(Rs);return t?t.addFriend(e):ai({code:ii.NO_MODULE})}deleteFriend(e){var t=this._get(Rs);return t?t.deleteFriend(e):ai({code:ii.NO_MODULE})}checkFriend(e){var t=this._get(Rs);return t?t.checkFriend(e):ai({code:ii.NO_MODULE})}getFriendProfile(e){var t=this._get(Rs);return t?t.getFriendProfile(e):ai({code:ii.NO_MODULE})}updateFriend(e){var t=this._get(Rs);return t?t.updateFriend(e):ai({code:ii.NO_MODULE})}getFriendApplicationList(){var e=this._get(Rs);return e?e.getLocalFriendApplicationList():ai({code:ii.NO_MODULE})}acceptFriendApplication(e){var t=this._get(Rs);return t?t.acceptFriendApplication(e):ai({code:ii.NO_MODULE})}refuseFriendApplication(e){var t=this._get(Rs);return t?t.refuseFriendApplication(e):ai({code:ii.NO_MODULE})}deleteFriendApplication(e){var t=this._get(Rs);return t?t.deleteFriendApplication(e):ai({code:ii.NO_MODULE})}setFriendApplicationRead(){var e=this._get(Rs);return e?e.setFriendApplicationRead():ai({code:ii.NO_MODULE})}getFriendGroupList(){var e=this._get(Rs);return e?e.getLocalFriendGroupList():ai({code:ii.NO_MODULE})}createFriendGroup(e){var t=this._get(Rs);return t?t.createFriendGroup(e):ai({code:ii.NO_MODULE})}deleteFriendGroup(e){var t=this._get(Rs);return t?t.deleteFriendGroup(e):ai({code:ii.NO_MODULE})}addToFriendGroup(e){var t=this._get(Rs);return t?t.addToFriendGroup(e):ai({code:ii.NO_MODULE})}removeFromFriendGroup(e){var t=this._get(Rs);return t?t.removeFromFriendGroup(e):ai({code:ii.NO_MODULE})}renameFriendGroup(e){var t=this._get(Rs);return t?t.renameFriendGroup(e):ai({code:ii.NO_MODULE})}followUser(e){var t=this._get(Xs);return t?t.followUser(e):ai({code:ii.NO_MODULE})}unfollowUser(e){var t=this._get(Xs);return t?t.unfollowUser(e):ai({code:ii.NO_MODULE})}getMyFollowersList(e){var t=this._get(Xs);return t?t.getMyFollowersList(e):ai({code:ii.NO_MODULE})}getMyFollowingList(e){var t=this._get(Xs);return t?t.getMyFollowingList(e):ai({code:ii.NO_MODULE})}getMutualFollowersList(e){var t=this._get(Xs);return t?t.getMutualFollowersList(e):ai({code:ii.NO_MODULE})}getUserFollowInfo(e){var t=this._get(Xs);return t?t.getUserFollowInfo(e):ai({code:ii.NO_MODULE})}checkFollowType(e){var t=this._get(Xs);return t?t.checkFollowType(e):ai({code:ii.NO_MODULE})}getGroupList(){var e=this._get(Ds);return e?e.getGroupList():ai({code:ii.NO_MODULE})}getGroupProfile(e){var t=this._get(Ds);return t?t.getGroupProfile(e):ai({code:ii.NO_MODULE})}createGroup(e){var t=this._get(Ds);return t?t.createGroup(e):ai({code:ii.NO_MODULE})}dismissGroup(e){var t=this._get(Ds);return t?t.dismissGroup(e):ai({code:ii.NO_MODULE})}updateGroupProfile(e){var t=this._get(Ds);return t?t.updateGroupProfile(e):ai({code:ii.NO_MODULE})}joinGroup(e){var t=this._get(Ds);return t?t.joinGroup(e):ai({code:ii.NO_MODULE})}quitGroup(e){var t=this._get(Ds);return t?t.quitGroup(e):ai({code:ii.NO_MODULE})}searchGroupByID(e){var t=this._get(Ds);return t?t.searchGroupByID(e):ai({code:ii.NO_MODULE})}getGroupOnlineMemberCount(e){var t=this._get(Ds);return t?t.getGroupOnlineMemberCount(e):ai({code:ii.NO_MODULE})}changeGroupOwner(e){var t=this._get(Ds);return t?t.changeGroupOwner(e):ai({code:ii.NO_MODULE})}getGroupApplicationList(){var e=this._get(Ds);return e?e.getGroupApplicationList():ai({code:ii.NO_MODULE})}handleGroupApplication(e){var t=this._get(Ds);return t?t.handleGroupApplication(e):ai({code:ii.NO_MODULE})}initGroupAttributes(e){var t=this._get(Ds);return t?t.initGroupAttributes(e):ai({code:ii.NO_MODULE})}setGroupAttributes(e){var t=this._get(Ds);return t?t.setGroupAttributes(e):ai({code:ii.NO_MODULE})}deleteGroupAttributes(e){var t=this._get(Ds);return t?t.deleteGroupAttributes(e):ai({code:ii.NO_MODULE})}getGroupAttributes(e){var t=this._get(Ds);return t?t.getGroupAttributes(e):ai({code:ii.NO_MODULE})}setGroupCounters(e){var t=this._get(Ds);return t?t.setGroupCounters(e):ai({code:ii.NO_MODULE})}increaseGroupCounter(e){var t=this._get(Ds);return t?t.increaseGroupCounter(e):ai({code:ii.NO_MODULE})}decreaseGroupCounter(e){var t=this._get(Ds);return t?t.decreaseGroupCounter(e):ai({code:ii.NO_MODULE})}getGroupCounters(e){var t=this._get(Ds);return t?t.getGroupCounters(e):ai({code:ii.NO_MODULE})}getGroupMemberList(e){var t=this._get(Ds);return t?t.getGroupMemberList(e):ai({code:ii.NO_MODULE})}getGroupMemberProfile(e){var t=this._get(Ds);return t?t.getGroupMemberProfile(e):ai({code:ii.NO_MODULE})}addGroupMember(e){var t=this._get(Ds);return t?t.addGroupMember(e):ai({code:ii.NO_MODULE})}deleteGroupMember(e){var t=this._get(Ds);return t?t.deleteGroupMember(e):ai({code:ii.NO_MODULE})}setGroupMemberMuteTime(e){var t=this._get(Ds);return t?t.setGroupMemberMuteTime(e):ai({code:ii.NO_MODULE})}setGroupMemberRole(e){var t=this._get(Ds);return t?t.setGroupMemberRole(e):ai({code:ii.NO_MODULE})}setGroupMemberNameCard(e){var t=this._get(Ds);return t?t.setGroupMemberNameCard(e):ai({code:ii.NO_MODULE})}setGroupMemberCustomField(e){var t=this._get(Ds);return t?t.setGroupMemberCustomField(e):ai({code:ii.NO_MODULE})}markGroupMemberList(e){var t=this._get(Ds);return t?t.markGroupMemberList(e):ai({code:ii.NO_MODULE})}getJoinedCommunityList(){return this._get(Ls).getJoinedCommunityList()}createTopicInCommunity(e){return this._get(Ls).createTopicInCommunity(e)}deleteTopicFromCommunity(e){return this._get(Ls).deleteTopicFromCommunity(e)}updateTopicProfile(e){return this._get(Ls).updateTopicProfile(e)}getTopicList(e){return this._get(Ls).getTopicList(e)}addSignalingListener(e,t,s){var i=this._get(js);i&&i.addSignalingListener(e,this._safetyCallbackFactory.defense(e,t,s),s)}removeSignalingListener(e,t,s){var i,o=this._safetyCallbackFactory.find(e,t);null!==o&&(i=this._get(js))&&(i.removeSignalingListener(e,o,s),this._safetyCallbackFactory.delete(e,t))}invite(e){var t=this._get(js);return t?t.invite(e):ai({code:ii.NO_MODULE})}inviteSync(e,t,s){var i=this._get(js);return i?i.inviteSync(e,t,s):""}inviteInGroup(e){var t=this._get(js);return t?t.invite(e):ai({code:ii.NO_MODULE})}inviteInGroupSync(e,t,s){var i=this._get(js);return i?i.inviteSync(e,t,s):""}cancel(e){var t=this._get(js);return t?t.cancel(e):ai({code:ii.NO_MODULE})}accept(e){var t=this._get(js);return t?t.accept(e):ai({code:ii.NO_MODULE})}reject(e){var t=this._get(js);return t?t.reject(e):ai({code:ii.NO_MODULE})}getSignalingInfo(e){var t=this._get(js);return t?t.getSignalingInfo(e):null}modifyInvitation(e){var t=this._get(js);return t?t.modifyInvitation(e):ai({code:ii.NO_MODULE})}}let Nr={login:1,logout:1,getLoginUser:1,destroy:1,on:1,off:1,ready:1,setLogLevel:1,joinGroup:1,quitGroup:1,registerPlugin:1,getGroupOnlineMemberCount:1,isReady:1,addSignalingListener:1,removeSignalingListener:1,callExperimentalAPI:1};function Pr(e,t){var s;return!(!e.isReady()&&1!==Nr[t])||(s={code:s=e.getNotReadyReason(),message:e.getErrMsg(s)+` | ${t} | `+e.getErrMsg(ii.SDK_IS_NOT_READY)},e.onError(s),s)}let Ur={},Gr={create:function(e){var t="TencentCloudChat.create";let s=0;var o=e["SDKAppID"];if(be(o))s=o;else if(s=parseInt(o),isNaN(o))return ye.e(t+" failed. Failed to parse the SDKAppID, please check the arguments"),null;return s&&Ur[s]?Ur[s]:(ye.l(t),o=new Or({...e,SDKAppID:s}),o.on(i.SDK_DESTROY,(e=>{Ur[e.data.SDKAppID]=null,delete Ur[e.data.SDKAppID]})),e=function(e){let t=Object.create(null);return Object.keys(Cs).forEach((s=>{if(e[s]){let i=new n;t[s]=function(){var t=Array.from(arguments);return i.use((function(t,i){var o=Pr(e,s);return!0===o?i():ai(o)})).use((function(e,t){if(!0===Nt(e,Is[s],s))return t()})).use((function(t,i){return e[s].apply(e,t)})),i.run(t)}}})),t}(o),Ur[s]=e,Is.hookGetAPITips(o.getErrMsg.bind(o)),ye.l(t+" ok"),e)}};Gr.TYPES=o,Gr.EVENT=i,Gr.TSignaling={NEW_INVITATION_RECEIVED:"newInvitationReceived",INVITEE_ACCEPTED:"ts_invitee_accepted",INVITEE_REJECTED:"ts_invitee_rejected",INVITATION_CANCELLED:"ts_invitation_cancelled",INVITATION_TIMEOUT:"ts_invitation_timeout",INVITATION_MODIFIED:"ts_invitation_modified",ACTION_TYPE_UNKNOWN:0,ACTION_TYPE_INVITE:1,ACTION_TYPE_CANCEL_INVITE:2,ACTION_TYPE_ACCEPT_INVITE:3,ACTION_TYPE_REJECT_INVITE:4,ACTION_TYPE_INVITE_TIMEOUT:5},Gr.VERSION="3.5.3",ye.l("TencentCloudChat.VERSION:"+Gr.VERSION)}}]);
|
|
2
|
-
//# sourceMappingURL=index.umd.min.260.js.map
|