mrr.sj.front/node_modules/@tencentcloud/chat/index.es.js

1 line
464 KiB
JavaScript

let e={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",SERVER_CONFIG_UPDATED:"onServerConfigUpdated",PINNED_GROUP_MESSAGE_UPDATED:"onPinnedGroupMessageUpdated"},t={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 s{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 i{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 n={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",BACKUP_CN:"wss://wss.im.tencent.cn",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",BACKUP_CN:"wss://wss.im.tencent.cn",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",ANYCAST:"wss://162.14.13.254"},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"}}},o={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},r="1.7.3",a=537048168,c="CHINA",l="OVERSEA",u="SINGAPORE",d="KOREA",_="GERMANY",h="IND",p="JPN",g="USA",m="INDONESIA",f={HOST:{CURRENT:{DEFAULT:"wss://wss.im.qcloud.com",STAT:"https://events.im.qcloud.com"},setCurrent(e=c){this.CURRENT=n.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"}},M={SEARCH_GRP_SNS:new i(0,Math.pow(2,1)).toString(),AV_HISTORY_MSG:new i(0,Math.pow(2,2)).toString(),GRP_COMMUNITY:new i(0,Math.pow(2,3)).toString(),MSG_TO_SPECIFIED_GRP_MBR:new i(0,Math.pow(2,4)).toString(),AV_MBR_LIST:new i(0,Math.pow(2,6)).toString(),USER_STATUS:new i(0,Math.pow(2,7)).toString(),CONV_MARK:new i(0,Math.pow(2,9)).toString(),CONV_GROUP:new i(0,Math.pow(2,10)).toString(),AV_BAN_MBR:new i(0,Math.pow(2,11)).toString(),MSG_EXT:new i(0,Math.pow(2,13)).toString(),GRP_COUNTER:new i(0,Math.pow(2,15)).toString(),PLUGIN_TRANSLATE:new i(Math.pow(2,6)).toString(),PLUGIN_VOICE_TO_TEXT:new i(Math.pow(2,7)).toString(),PLUGIN_CS:new i(Math.pow(2,8)).toString(),PLUGIN_PUSH:new i(Math.pow(2,9)).toString(),PLUGIN_BOT:new i(Math.pow(2,10)).toString(),MSG_REACTION:new i(Math.pow(2,16)).toString(),FOLLOW:new i(Math.pow(2,20)).toString()},I="c2c_text_message",C="c2c_custom_message",T="group_text_message",y="group_custom_message",v="user_profile",S="group_profile",E="web.sdk.qcloud.com",D="web.sdk.cloud.tencent.cn",R="web.sdk.tencent.cn",L=(f.HOST.setCurrent(c),"undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform)&&void 0===wx.getSystemInfoSync().uniPlatform),A="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||L,O=A&&"function"==typeof wx.createGamePortal,N="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),P="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),U="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),G="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),k="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,w="undefined"!=typeof uni&&"undefined"==typeof window&&"function"==typeof uni.requireNativePlugin,b=A&&"object"==typeof wx.miniapp,F="undefined"!=typeof uni,$=A||N||P||U||G||w||k,q="undefined"==typeof window&&!$&&"undefined"!=typeof global&&void 0!==global.NativeScriptGlobals,x="undefined"!=typeof global&&(void 0!==global.nativeModuleProxy||void 0!==global.ReactNative),V="undefined"!=typeof uni?!$:"undefined"!=typeof window&&!$&&!x,B=N?qq:P?tt:U?swan:G?my:A?wx:w?uni:k?jd:{},K=V&&window&&window.navigator&&window.navigator.userAgent||"",H=/(micromessenger|webbrowser)/i.test(K),W=function(){let e="WEB";return H?e="WEB":N?e="QQ_MP":P?e="TT_MP":U?e="BAIDU_MP":G?e="ALI_MP":A?e=b?"DONUT_NATIVE_APP":"WX_MP":w?e="UNI_NATIVE_APP":q?e="NS_NATIVE_APP":x&&(e="RN_NATIVE_APP"),o[e]}(),Y=/iPad/i.test(K),z=/iPhone/i.test(K)&&!Y,j=/iPod/i.test(K),J=z||Y||j,X=function(){var e=K.match(/OS (\d+)_/i);return e&&e[1]?e[1]:null}(),Z=/Android/i.test(K),Q=function(){var e,t,s=K.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}(),ee=/Edge/i.test(K),te=!ee&&/Chrome/i.test(K),se=/MSIE/.test(K)||-1<K.indexOf("Trident")&&-1<K.indexOf("rv:11.0"),ie=function(){var e=/MSIE\s(\d+)\.\d/.exec(K);let t=e&&parseFloat(e[1]);return t=!t&&/Trident\/7.0/i.test(K)&&/rv:11.0/.test(K)?11:t}(),ne=/Safari/i.test(K)&&!te&&!Z&&!ee,oe=/Windows/i.test(K),re=/MAC OS X/i.test(K),ae=V&&"undefined"!=typeof Worker&&!se,ce=Z||J,le=V&&void 0!==window.tencent_cloud_im_csig_flutter_for_web_25F_cy,ue=function(){var e;return"undefined"!=typeof window&&void 0!==window.navigator&&(e=window.navigator.standalone,!(!J||e||ne))}(),de,_e,he=(de="undefined"!=typeof console?console:"undefined"!=typeof global&&global.console?global.console:"undefined"!=typeof window&&window.console?window.console:{},function(){}),pe=["assert","clear","count","debug","dir","dirxml","error","group","groupCollapsed","groupEnd","info","log","profile","profileEnd","table","time","timeEnd","timeStamp","trace","warn"],ge=pe.length;for(;ge--;)_e=pe[ge],console[_e]||(de[_e]=he);var me=de;let fe=0,Me=function(){return(new Date).getTime()+fe},Ie=function(){fe=0},Ce=function(){return Math.floor(Me()/1e3)},Te=0;function ye(){return Lt()?"%c Chat %c":"Chat"}function ve(){(e=new Date).setTime(Me());var e;return e.toLocaleTimeString("en-US",{hour12:!1})+"."+function(e){let t;switch(e.toString().length){case 1:t="00"+e;break;case 2:t="0"+e;break;default:t=e}return t}(e.getMilliseconds())}let Se={arguments2String(s){let i="";if(1===s.length)i=s[0];else for(let e=0,t=s.length;e<t;e++){if(Ke(s[e]))try{i+=We(s[e])?JSON.stringify(s[e],["message","code"]):JSON.stringify(s[e])}catch(e){i+=e?e.message:"";break}else i+=s[e];i+=" "}return i},_exec(e,t){Lt()?me[e](ye(),"background:#0abf5b; padding:1px; border-radius:3px; color: #fff","background:transparent",ve(),t):me[e](`${ye()} ${ve()} `+t)},d:function(){var e;Te<=-1&&(e=this.arguments2String(arguments),this._exec("debug",e))},l:function(){var e;Te<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},log:function(){var e;Te<=0&&(e=this.arguments2String(arguments),this._exec("log",e))},i:function(){var e;Te<=1&&(e=this.arguments2String(arguments),this._exec("info",e))},w:function(){var e;Te<=2&&(e=this.arguments2String(arguments),this._exec("warn",e))},e:function(){var e;Te<=3&&(e=this.arguments2String(arguments),this._exec("error",e))},setLevel:function(e){e<4&&this._exec("log","set level from "+Te+" to "+e),Te=e},getLevel:function(){return Te}},Ee={JPG:1,JPEG:1,GIF:2,PNG:3,BMP:4,UNKNOWN:255},De={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"},Re="Gender_Type_",Le={UNKNOWN:Re+"Unknown",FEMALE:Re+"Female",MALE:Re+"Male"},Ae={NONE:"AdminForbid_Type_None",SEND_OUT:"AdminForbid_Type_SendOut"},Oe={NEED_CONFIRM:"AllowType_Type_NeedConfirm",ALLOW_ANY:"AllowType_Type_AllowAny",DENY_ANY:"AllowType_Type_DenyAny"},Ne="@TGS#_",Pe="@TOPIC#_",Ue=Object.prototype.hasOwnProperty;function Ge(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(Ue.call(e,t))return!1;return!0}return!!(ke(e)||we(e)||be(e))&&0===e.size}let ke=function(e){return"map"===ze(e)},we=function(e){return"set"===ze(e)},be=function(e){return"file"===ze(e)},Fe=function(e){return null!==e&&("number"==typeof e&&!isNaN(+e)||"object"==typeof e&&e.constructor===Number)},$e=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;e=Object.getPrototypeOf(e);if(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"===ze(e)},Be=function(e){return void 0===e},Ke=function(e){return Ve(e)||qe(e)},He=function(e){return"function"==typeof e},We=function(e){return e instanceof Error},Ye=function(e){return"filelist"===ze(e)},ze=function(e){return Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase()},je=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(s,i,o,n){if(!Ke(s)||!Ke(i))return 0;let r=0;var a,l=Object.keys(i);for(let e=0,t=l.length;e<t;e++)if(a=l[e],!(Be(i[a])||o&&o.includes(a)))if(Ke(s[a])&&Ke(i[a]))r+=Je(s[a],i[a],o,n);else{if(n&&n.includes(i[a]))continue;s[a]!==i[a]&&(s[a]=i[a],r+=1)}return r}),Xe=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},Ze=function(e){if(0===e.length)return 0;let t=0,s=0,i;for(var o="undefined"!=typeof document&&void 0!==document.characterSet?document.characterSet:"UTF-8";void 0!==e[t];)i=e[t++].charCodeAt[t]<=255?1:!1===o?3:2,s+=i;return s},Qe=function(e){e=e||99999999;return Math.round(Math.random()*e)},et="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",st=et.length,it=function(e,t){for(var s in e)if(e[s]===t)return!0;return!1},nt={},ot=function(e){return-1===e.indexOf("http://")||-1===e.indexOf("https://")?"https://"+e:e.replace(/https|http/,"https")};function rt(i,e){if(!Ve(i)||!Ve(e))return!1;let o=!1;return e.forEach(({key:t,value:e})=>{var s=i.find(e=>e.key===t);s?s.value!==e&&(s.value=e,o=!0):(i.push({key:t,value:e}),o=!0)}),o}function at(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 ct=e=>e===t.GRP_AVCHATROOM,lt=({type:e,groupID:s})=>e===t.GRP_COMMUNITY||(""+s).startsWith(Ne)&&!(""+s).includes(Pe),ut=e=>(""+e).startsWith(Ne)&&(""+e).includes(Pe),dt=e=>$e(e)&&e.slice(0,3)===t.CONV_C2C,_t=e=>$e(e)&&e.slice(0,5)===t.CONV_GROUP,ht=e=>$e(e)&&e===t.CONV_SYSTEM;function pt(t,s){let i={};return Object.keys(t).forEach(e=>{i[e]=s(t[e],e)}),i}function gt(i){return x?Promise.resolve({width:0,height:0}):$?new Promise((t,e)=>{B.getImageInfo({src:i,success(e){t({width:e.width,height:e.height})},fail(){t({width:0,height:0})}})}):se&&9===ie?Promise.resolve({width:0,height:0}):new Promise((e,t)=>{let s=new Image;s.onload=function(){e({width:this.width,height:this.height}),s=null},s.onerror=function(){e({width:0,height:0}),s=null},s.src=i})}function mt(){function e(){return(65536*(1+Math.random())|0).toString(16).substring(1)}return""+(e()+e())+e()+e()+e()+e()+e()+e()}function ft(){let e="unknown";if(re&&(e="mac"),oe&&(e="windows"),J&&(e="ios"),Z&&(e="android"),$)try{var t=B.getSystemInfoSync().platform;void 0!==t&&(e=t)}catch(e){}return e}function Mt(i,o){i=i.split("."),o=o.split(".");let e=Math.max(i.length,o.length);for(;i.length<e;)i.push("0");for(;o.length<e;)o.push("0");for(let s=0;s<e;s++){let e=parseInt(i[s]),t=parseInt(o[s]);if(e>t)return 1;if(e<t)return-1}return 0}function It(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 Ct(t){var e=t[2];t[2]=t[1],t[1]=e;for(let e=0;e<t.length;e++)t[e].setType(e)}function Tt(e){e=e.servcmd;return e.slice(e.indexOf(".")+1)}function yt(e,t){return Math.round(Number(e)*Math.pow(10,t))/Math.pow(10,t)}function vt(e,t){return e.includes(t)}function St(e,t){return e.includes(t)}function Et(e){return e.split(Pe)[0]}let Dt=function(e,s,i){if(Be(s))return"";switch(e){case t.MSG_TEXT:return s.text;case t.MSG_IMAGE:return i?"[Image]":"[图片]";case t.MSG_LOCATION:return i?"[Location]":"[位置]";case t.MSG_AUDIO:return i?"[Voice]":"[语音]";case t.MSG_VIDEO:return i?"[Video]":"[视频]";case t.MSG_FILE:return i?"[File]":"[文件]";case t.MSG_CUSTOM:return i?"[Custom Messages]":"[自定义消息]";case t.MSG_GRP_TIP:return i?"[Group Notification]":"[群提示消息]";case t.MSG_GRP_SYS_NOTICE:return i?"[Group System Message]":"[群系统通知]";case t.MSG_FACE:return i?"[Animated Sticker]":"[动画表情]";case t.MSG_MERGER:return i?"[Chat Record]":"[聊天记录]";default:return""}};function Rt(t){var s=[];if($e(t)){var i=t.length;if(0!==i)for(let e=i-1;0<=e;e--)"1"===t[e]&&s.push(Math.pow(2,i-e-1))}return s}function Lt(){return!se&&!$}function At(e){return"the length of userIDList cannot exceed "+e}function Ot(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 Nt(e){let t=e&&1<e?!0:!1;return t}function Pt(s,i,o){if(void 0===i)return!0;let n=!0;if(xe(i))Object.keys(i).forEach(e=>{var t=1===s.length?s[0][e]:void 0;n=!!Ut(t,i[e],o,e)&&n});else if(Ve(i))for(let e=0;e<i.length;e++)n=!!Ut(s[e],i[e],o,i[e].name)&&n;if(n)return n;throw new Error("Params validate failed.")}function Ut(e,t,s,i){if(void 0===t)return!0;let o=!0;var n,r;return t.required&&Ge(e)&&(Se.e(`[${s}] Missing required params: "${i}".`),o=!1),Ge(e)||(n=ze(e))===(r=t.type.toLowerCase())||"asyncfunction"===n&&"function"===r||(Se.e(`[${s}] Invalid params: type check failed for "${i}". Expected ${t.type}.`),o=!1),t.validator&&!t.validator(e,s,i)&&(Se.e(`[${s}] Invalid params: custom validator check failed for "${i}".`),o=!1),o}let Gt="unSend",kt="success",wt="fail",bt="notStart",Ft="pending",$t="resolved",qt="rejected",xt=function(e){return!(!e||!(dt(e)||_t(e)||ht(e))&&((e=Is("InvalidConversationID",e))&&Se.w(e),1))},Vt=function(e){""!==e.desc&&""!==Is("API_REFER")&&Se.w(`[${e.api}] | ${e.paramName} | ${e.desc}, `+Is("API_REFER")+e.api)},Bt=function(){return Is("StringRequiredLog")},Kt=function(e){return Is("NonEmptyStringRequiredLog",e)},Ht=function(){return Is("NumberRequiredLog")},Wt=function(){return Is("UndefinedNotAllowedLog")},Yt=function(){return Is("FileRequiredLog")},zt=function(){return Is("FunctionRequiredLog")},jt=function(){return Is("ArrayRequiredLog")},Jt=function(){return Is("NonEmptyArrayLog")},Xt=function(){return Is("CallbackMissingLog")},Zt=function(){return Is("PositiveIntegerRequiredLog")},Qt=function(e,t){return Is("StringNotLongerThanLog",e,t)},es=function(e,t){return Is("NumberGreaterThanLog",e,t)},ts=function(e,t){return Is("NumberGreaterOrEqualLog",e,t)},ss=function(e){return Is("KeyValueStringRequiredLog",e)},is=function(){return Is("PlainObjectRequiredLog")},ns=function(){return Is("NonEmptyContentRequiredLog")},os=function(){return Is("FileNotSelectedLog")},rs=function(){return Is("MessageInstanceRequiredLog")},as=function(){return Is("NonAnonymousFunctionLog")},cs=function(){return Is("MessageExtensionNotAvailableLog")},ls=function(){return Is("MessageReactionRequiredLog")},us=function(e,t){return Is("ContainsUnsupportedTypeLog",e,t)},ds={type:"String",required:!0},_s={type:"Array",required:!0},hs={type:"Object",required:!0},ps={type:"Boolean",required:!0},gs={type:"number",required:!0},ms=function(e,t,s,{allowUndefined:i,allowEmpty:o,maxLength:n}){return Be(e)?!!i||(Vt({api:t,paramName:s,desc:Wt()}),!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,Is("MaximumArrayLengthLog",i,o))}),1)):(Vt({api:t,paramName:s,desc:jt()}),!1)},fs=function(e,t,s,{allowUndefined:i,min:o,max:n}){return Be(e)?!!i||(Vt({api:t,paramName:s,desc:Wt()}),!1):Fe(e)?Fe(o)&&e<o?(Vt({api:t,paramName:s,desc:0===o?ts(s,o):es(s,o-1)}),!1):!(Fe(n)&&n<e&&(Vt({api:t,paramName:s,desc:(i=s,o=n,Is("MaximumNumberLog",i,o))}),1)):(Vt({api:t,paramName:s,desc:Ht()}),!1)},Ms={keywordListForMsg:{type:"Array",required:!1,validator:(e,t,s)=>ms(e,t,s,{allowUndefined:!0,allowEmpty:!0,maxLength:5})},keywordListExceptMsg:{type:"Array",required:!0,validator:(e,t,s)=>ms(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)=>fs(e,t,s,{allowUndefined:!0,min:1,max:100})},groupTypeList:{type:"Array",required:!1,validator:(e,s,i)=>{if(!e)return!0;if(!ms(e,s,i,{allowUndefined:!0,allowEmpty:!0}))return!1;let o=[t.GRP_PUBLIC,t.GRP_COMMUNITY,t.GRP_WORK,t.GRP_MEETING];return!(0<e.filter(e=>-1===o.indexOf(e)).length&&(Vt({api:s,paramName:i,desc:us(i,"group")}),1))}}},Is=null,Cs={hookGetAPITips:function(e){Is=e},login:{userID:ds,userSig:ds},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:zt()}),!1):(""===e.name&&Vt({api:t,paramName:s,desc:as()}),!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:zt()}),!1):(""===e.name&&Vt({api:t,paramName:s,desc:as()}),!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:zt()}),!1):(""===e.name&&Vt({api:t,paramName:s,desc:as()}),!0)}],sendMessage:[{name:"message",...hs}],setMessageExtensions:[{name:"message",...hs,validator:(e,t,s)=>e.status===kt&&!0===e.isSupportExtension||(Vt({api:t,paramName:s,desc:cs()}),!1)},{name:"extensions",..._s}],getMessageExtensions:[{name:"message",...hs,validator:(e,t,s)=>e.status===kt&&!0===e.isSupportExtension||(Vt({api:t,paramName:s,desc:cs()}),!1)}],deleteMessageExtensions:[{name:"message",...hs,validator:(e,t,s)=>e.status===kt&&!0===e.isSupportExtension||(Vt({api:t,paramName:s,desc:cs()}),!1)}],addMessageReaction:[{name:"message",...hs,validator:(e,t,s)=>e.status===kt||(Vt({api:t,paramName:s,desc:ls()}),!1)},{name:"reactionID",...ds}],removeMessageReaction:[{name:"message",...hs,validator:(e,t,s)=>e.status===kt||(Vt({api:t,paramName:s,desc:ls()}),!1)},{name:"reactionID",...ds}],getMessageReactions:{messageList:{..._s}},getAllUserListOfMessageReaction:{message:{...hs,validator:(e,t,s)=>e.status===kt||(Vt({api:t,paramName:s,desc:ls()}),!1)},reactionID:{...ds},nextSeq:{type:"Number"},count:{type:"Number"}},getMessageList:{conversationID:{...ds,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:Zt()}),1))}},getMessageListHopping:{conversationID:{...ds,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:Is("0Or1RequiredLog")}),1))},count:{type:"Number",validator:(e,t,s)=>!(!Be(e)&&!/^[1-9][0-9]*$/.test(e)&&(Vt({api:t,paramName:s,desc:Zt}),1))}},setMessageRead:{conversationID:{...ds,validator:e=>xt(e)}},setAllMessageRead:{scope:{type:"String",required:!1,validator:(e,s,i)=>!e||-1!==[t.READ_ALL_C2C_MSG,t.READ_ALL_GROUP_MSG,t.READ_ALL_MSG].indexOf(e)||(Vt({api:s,paramName:i,desc:Is("ValidScopeRequired")}),!1)}},getConversationProfile:[{name:"conversationID",...ds,validator:e=>xt(e)}],clearHistoryMessage:[{name:"conversationID",...ds,validator:e=>xt(e)}],pinConversation:{conversationID:{...ds,validator:e=>xt(e)},isPinned:{...ps}},setConversationDraft:{conversationID:{...ds,validator:e=>xt(e)},draftText:{type:"String",validator:(e,t,s)=>!!$e(e)||(Vt({api:t,paramName:s,desc:Bt()}),!1)}},setConversationCustomData:{conversationIDList:{..._s},customData:{type:"String",validator:(e,t,s)=>$e(e)?!(256<e.length&&(Vt({api:t,paramName:s,desc:Qt(s,256)}),1)):(Vt({api:t,paramName:s,desc:Bt()}),!1)}},markConversation:{conversationIDList:{..._s},markType:{type:"number",validator:(e,t,s)=>{return Fe(e)?e<=0?(Vt({api:t,paramName:s,desc:es(s,0)}),!1):!(e>=Math.pow(2,64)&&(Vt({api:t,paramName:s,desc:(e=s,Is("NumberLessThanLog",e,"Math.pow(2,64)"))}),1)):(Vt({api:t,paramName:s,desc:Ht()}),!1)}},enableMark:{...ps}},createConversationGroup:{conversationIDList:{..._s},groupName:{...ds,validator:(e,t,s)=>!(!e||32<e.length&&(Vt({api:t,paramName:s,desc:Qt(s,32)}),1))}},deleteConversationGroup:[{name:"groupName",...ds}],renameConversationGroup:{oldName:{...ds},newName:{...ds,validator:(e,t,s)=>!(!e||32<e.length&&(Vt({api:t,paramName:s,desc:Qt(s,32)}),1))}},addConversationsToGroup:{conversationIDList:{..._s},groupName:{...ds}},deleteConversationsFromGroup:{conversationIDList:{..._s},groupName:{...ds}},getGroupList:{groupProfileFilter:{type:"Array"}},getGroupProfile:{groupID:ds,groupCustomFieldFilter:{type:"Array"},memberCustomFieldFilter:{type:"Array"}},getGroupProfileAdvance:{groupIDList:_s},createGroup:{name:ds},joinGroup:{groupID:ds,type:{type:"String"},applyMessage:{type:"String"}},quitGroup:[{name:"groupID",...ds}],pinGroupMessage:{groupID:ds,message:hs,isPinned:ps},getPinnedGroupMessageList:[{name:"groupID",...ds}],handleApplication:{message:hs,handleAction:ds,handleMessage:{type:"String"}},changeGroupOwner:{groupID:ds,newOwnerID:ds},updateGroupProfile:{groupID:ds,muteAllMembers:{type:"Boolean"}},dismissGroup:[{name:"groupID",...ds}],searchGroupByID:[{name:"groupID",...ds}],getGroupOnlineMemberCount:[{name:"groupID",...ds}],initGroupAttributes:{groupID:ds,groupAttributes:{...hs,validator:(t,s,i)=>{let o=!0;return Object.keys(t).forEach(e=>{if(!$e(t[e]))return Vt({api:s,paramName:i,desc:ss("value")}),o=!1}),o}}},setGroupAttributes:{groupID:ds,groupAttributes:{...hs,validator:(t,s,i)=>{let o=!0;return Object.keys(t).forEach(e=>{if(!$e(t[e]))return Vt({api:s,paramName:i,desc:ss("value")}),o=!1}),o}}},deleteGroupAttributes:{groupID:ds,keyList:{type:"Array",validator:(e,s,i)=>{if(Be(e)||!Ve(e))return Vt({api:s,paramName:i,desc:jt()}),!1;if(Ge(e))return!0;{let t=!0;return e.forEach(e=>{if(!$e(e))return Vt({api:s,paramName:i,desc:Is("StringArrayRequiredLog")}),t=!1}),t}}}},getGroupAttributes:{groupID:ds,keyList:{type:"Array",validator:(e,s,i)=>{if(Be(e)||!Ve(e))return Vt({api:s,paramName:i,desc:jt()}),!1;if(Ge(e))return!0;{let t=!0;return e.forEach(e=>{if(!$e(e))return Vt({api:s,paramName:i,desc:ss("key")}),t=!1}),t}}}},setGroupCounters:{groupID:ds,counters:hs},increaseGroupCounter:{groupID:ds,key:ds,value:gs},decreaseGroupCounter:{groupID:ds,key:ds,value:gs},getGroupCounters:{groupID:ds},getGroupMemberList:{groupID:ds,count:{type:"Number"}},getGroupMemberProfile:{groupID:ds,userIDList:_s,memberCustomFieldFilter:{type:"Array"}},addGroupMember:{groupID:ds,userIDList:_s},setGroupMemberRole:{groupID:ds,userID:ds,role:ds},setGroupMemberMuteTime:{groupID:ds,userID:ds,muteTime:{type:"Number",validator:e=>0<=e}},setGroupMemberNameCard:{groupID:ds,userID:{type:"String"},nameCard:{type:"String",validator:(e,t,s)=>$e(e)?(e.length,!0):(Vt({api:t,paramName:s,desc:Bt()}),!1)}},setGroupMemberCustomField:{groupID:ds,userID:{type:"String"},memberCustomField:_s},deleteGroupMember:{groupID:ds},markGroupMemberList:{groupID:ds,markType:{type:"number",validator:(e,t,s)=>Fe(e)?!(e<1e3&&(Vt({api:t,paramName:s,desc:ts(s,1e3)}),1)):(Vt({api:t,paramName:s,desc:Ht()}),!1)},userIDList:{..._s},enableMark:{...ps}},createTextMessage:{to:ds,conversationType:ds,payload:{...hs,validator:(e,t,s)=>xe(e)?$e(e.text)?0!==e.text.length||(Vt({api:t,paramName:"payload.text",desc:ns()}),!1):(Vt({api:t,paramName:"payload.text",desc:Bt()}),!1):(Vt({api:t,paramName:s,desc:is()}),!1)}},createTextAtMessage:{to:ds,conversationType:ds,payload:{...hs,validator:(e,t,s)=>xe(e)?$e(e.text)?0===e.text.length?(Vt({api:t,paramName:"payload.text",desc:ns()}),!1):!(e.atUserList&&!Ve(e.atUserList)&&(Vt({api:t,paramName:"payload.atUserList",desc:jt()}),1)):(Vt({api:t,paramName:"payload.text",desc:Bt()}),!1):(Vt({api:t,paramName:s,desc:is()}),!1)}},createCustomMessage:{to:ds,conversationType:ds,payload:{...hs,validator:(e,t,s)=>xe(e)?e.data&&!$e(e.data)?(Vt({api:t,paramName:"payload.data",desc:Bt()}),!1):e.description&&!$e(e.description)?(Vt({api:t,paramName:"payload.description",desc:Bt()}),!1):!(e.extension&&!$e(e.extension)&&(Vt({api:t,paramName:"payload.extension",desc:Bt()}),1)):(Vt({api:t,paramName:"payload",desc:is()}),!1)}},createImageMessage:{to:ds,conversationType:ds,payload:{...hs,validator:(e,t,s)=>{if(!xe(e))return Vt({api:t,paramName:s,desc:is()}),!1;if(Be(e.file))return Vt({api:t,paramName:"payload.file",desc:Wt()}),!1;if(V){if(!(e.file instanceof HTMLInputElement||be(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:Yt()}),!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:Xt()}),!0)}}},createAudioMessage:{to:ds,conversationType:ds,payload:{...hs,validator:(e,t,s)=>!!xe(e)||(Vt({api:t,paramName:s,desc:is()}),!1)},onProgress:{type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:Xt()}),!0)}},createVideoMessage:{to:ds,conversationType:ds,payload:{...hs,validator:(e,t,s)=>{if(!xe(e))return Vt({api:t,paramName:s,desc:is()}),!1;if(Be(e.file))return Vt({api:t,paramName:"payload.file",desc:Wt()}),!1;if(V){if(!(e.file instanceof HTMLInputElement||be(e.file)))return xe(e.file)&&"undefined"!=typeof uni?!!be(e.file.tempFile)||(Vt({api:t,paramName:"payload.file",desc:os()}),!1):(Vt({api:t,paramName:"payload.file",desc:Yt()}),!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:Xt()}),!0)}},createFaceMessage:{to:ds,conversationType:ds,payload:{...hs,validator:(e,t,s)=>xe(e)?Fe(e.index)?!!$e(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:is()}),!1)}},createFileMessage:{to:ds,conversationType:ds,payload:{...hs,validator:(e,t,s)=>{if(!xe(e))return Vt({api:t,paramName:s,desc:is()}),!1;if(Be(e.file))return Vt({api:t,paramName:"payload.file",desc:Wt()}),!1;if(V){if(!(e.file instanceof HTMLInputElement||be(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:Yt()}),!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:Xt()}),!0)}},createLocationMessage:{to:ds,conversationType:ds,payload:{...hs,validator:(e,t,s)=>xe(e)?$e(e.description)?Fe(e.longitude)?!!Fe(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:is()}),!1)}},createMergerMessage:{to:ds,conversationType:ds,payload:{...hs,validator:(e,t,s)=>{if(Ge(e.messageList))return Vt({api:t,paramName:"payload.messageList",desc:Jt()}),!1;if(Ge(e.compatibleText))return Vt({api:t,paramName:"payload.compatibleText",desc:Kt("compatibleText")}),!1;let i=!1;return e.messageList.forEach(e=>{e.status===wt&&(i=!0)}),!i||(Vt({api:t,paramName:"payload.messageList",desc:Is("MergeFailedMessageLog")}),!1)}}},revokeMessage:[{name:"message",...hs,validator:(e,s,i)=>Ge(e)?(Vt({api:s,paramName:i,desc:rs()}),!1):e.conversationType===t.CONV_SYSTEM?(Vt({api:s,paramName:i,desc:Is("MessageCanBeRevokedDesc")}),!1):!0!==e.isRevoked||(Vt({api:s,paramName:i,desc:Is("MessageRevokedLog")}),!1)}],deleteMessage:[{name:"messageList",..._s,validator:(e,t,s)=>!Ge(e)||(Vt({api:t,paramName:s,desc:Jt()}),!1)}],translateText:{sourceTextList:_s,sourceLanguage:ds,targetLanguage:ds},convertVoiceToText:{message:{...hs,validator:(e,s,i)=>Ge(e)?(Vt({api:s,paramName:i,desc:rs()}),!1):e.type===t.MSG_AUDIO&&e.status===kt||(Vt({api:s,paramName:i,desc:Is("AudioMessageRequiredLog")}),!1)}},modifyMessage:[{name:"message",...hs,validator:(e,s,i)=>Ge(e)?(Vt({api:s,paramName:i,desc:rs()}),!1):e.conversationType===t.CONV_SYSTEM?(Vt({api:s,paramName:i,desc:Is("MessageCanBeModifiedLog")}),!1):!0!==e._onlineOnlyFlag||(Vt({api:s,paramName:i,desc:Is("OnlineMessageNotSupportLog")}),!1)}],searchCloudMessages:{keywordList:Ms.keywordListForMsg,keywordListMatchType:Ms.keywordListMatchType,cursor:Ms.cursor,senderUserIDList:{type:"Array",required:!1,validator:(e,t,s)=>ms(e,t,s,{allowUndefined:!0,allowEmpty:!0,maxLength:5})},messageTypeList:{type:"Array",required:!1,validator:(e,s,i)=>{if(!e)return!0;if(!ms(e,s,i,{allowUndefined:!0,allowEmpty:!0}))return!1;let o=[t.MSG_TEXT,t.MSG_IMAGE,t.MSG_AUDIO,t.MSG_FILE,t.MSG_VIDEO,t.MSG_LOCATION,t.MSG_CUSTOM,t.MSG_MERGER];return!(0<e.filter(e=>-1===o.indexOf(e)).length&&(Vt({api:s,paramName:i,desc:us(i,"message")}),1))}},conversationID:{type:"String",required:!1,validator:e=>!e||xt(e)},timePosition:{type:"number",required:!1,validator:(e,t,s)=>fs(e,t,s,{allowUndefined:!0,min:0})},timePeriod:{type:"number",required:!1,validator:(e,t,s)=>fs(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)=>fs(e,t,s,{allowUndefined:!0,min:0})},maxBirthday:{type:"Number",required:!1,validator:(e,t,s)=>fs(e,t,s,{allowUndefined:!0,min:0})},gender:{type:"String",required:!1,validator:(e,s,i)=>!e||e===t.GENDER_FEMALE||e===t.GENDER_MALE||Vt({api:s,paramName:i,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)=>ms(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:jt()}),!1)}},updateMyProfile:{profileCustomField:{type:"Array",validator:(e,t,s)=>!!Be(e)||!!Ve(e)||(Vt({api:t,paramName:s,desc:jt()}),!1)}},setSelfStatus:{customStatus:{type:"String",validator:(e,t,s)=>!!$e(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:jt()}),!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:jt()}),!1)}},unsubscribeUserStatus:{userIDList:{type:"Array",validator:(e,t,s)=>!e||!!Ve(e)||(Vt({api:t,paramName:s,desc:jt()}),!1)}},addFriend:{to:ds,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:Qt("keyword",8)}),1):(Vt({api:t,paramName:s,desc:Is("SourcePrefixLog")}),1)))},remark:{type:"String",required:!1,validator:(e,t,s)=>!($e(e)&&96<e.length&&(Vt({api:t,paramName:s,desc:Qt(s,96)}),1))}},deleteFriend:{userIDList:_s},checkFriend:{userIDList:_s},getFriendProfile:{userIDList:_s},updateFriend:{userID:ds,remark:{type:"String",required:!1,validator:(e,t,s)=>!($e(e)&&96<e.length&&(Vt({api:t,paramName:s,desc:Qt(s,96)}),1))},friendCustomField:{type:"Array",required:!1,validator:(e,s,i)=>{if(e){if(!Ve(e))return Vt({api:s,paramName:i,desc:jt()}),!1;let t=!0;return e.forEach(e=>$e(e.key)&&-1!==e.key.indexOf("Tag_SNS_Custom")?$e(e.value)?8<e.key.replace("Tag_SNS_Custom_","").length?(Vt({api:s,paramName:i,desc:Qt("keyword",8)}),t=!1):void 0:(Vt({api:s,paramName:i,desc:ss("value")}),t=!1):(Vt({api:s,paramName:i,desc:Is("FriendCustomFieldPrefixLog")}),t=!1)),t}return!0}}},acceptFriendApplication:{userID:ds},refuseFriendApplication:{userID:ds},deleteFriendApplication:{userID:ds},createFriendGroup:{name:ds},deleteFriendGroup:{name:ds},addToFriendGroup:{name:ds,userIDList:_s},removeFromFriendGroup:{name:ds,userIDList:_s},renameFriendGroup:{oldName:ds,newName:ds},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:jt()}),!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:jt()}),!1)}],createTopicInCommunity:{groupID:ds,topicName:ds},deleteTopicFromCommunity:{groupID:ds,topicIDList:{type:"Array",validator:(e,t,s)=>!e||!!Ve(e)||(Vt({api:t,paramName:s,desc:jt()}),!1)}},updateTopicProfile:{groupID:ds,topicID:ds},getTopicList:{groupID:ds,topicIDList:{type:"Array",validator:(e,t,s)=>!e||!!Ve(e)||(Vt({api:t,paramName:s,desc:jt()}),!1)}},followUser:[{name:"userIDList",..._s}],unfollowUser:[{name:"userIDList",..._s}],getMyFollowingList:[{name:"startIndex",...ds,required:!1}],getMyFollowersList:[{name:"startIndex",...ds,required:!1}],getMutualFollowersList:[{name:"startIndex",...ds,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:zt()}),!1):(""===e.name&&Vt({api:t,paramName:s,desc:as()}),!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:zt()}),!1):(""===e.name&&Vt({api:t,paramName:s,desc:as()}),!0)}],invite:{userID:ds},inviteSync:[{...hs,validator:(e,t,s)=>xe(e)?!!$e(e.userID)||(Vt({api:t,paramName:"options.userID",desc:Bt()}),!1):(Vt({api:t,paramName:"options",desc:is()}),!1)},{name:"successCb",type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:zt()}),!0)},{name:"errorCb",type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:zt()}),!0)}],inviteInGroup:{groupID:ds,inviteeList:_s},inviteInGroupSync:[{...hs,validator:(e,t,s)=>xe(e)?$e(e.groupID)?!!Ve(e.inviteeList)||(Vt({api:t,paramName:"options.inviteeList",desc:jt()}),!1):(Vt({api:t,paramName:"options.groupID",desc:Bt()}),!1):(Vt({api:t,paramName:"options",desc:is()}),!1)},{name:"successCb",type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:zt()}),!0)},{name:"errorCb",type:"Function",required:!1,validator:(e,t,s)=>(Be(e)&&Vt({api:t,paramName:s,desc:zt()}),!0)}],accept:{inviteID:ds},reject:{inviteID:ds},getSignalingInfo:[{name:"message",...hs,validator:(e,t,s)=>!Ge(e)||(Vt({api:t,paramName:s,desc:rs()}),!1)}],modifyInvitation:{inviteID:ds,data:ds}},Ts={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,pinGroupMessage:1,getPinnedGroupMessageList: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},ys=1,vs=2,Ss=3,Es=4,Ds=6,Rs=7,Ls=8,As=10,Os=11,Ns=12,Ps=13,Us=14,Gs=15,ks=17,ws=18,bs=19,Fs=20,$s=21,qs=23,xs=24,Vs=25,Bs=26,Ks=27,Hs=28,Ws=29,Ys=30,zs=31,js=32,Js=33,Xs=34,Zs=35,Qs=36,ei=37,ti=38,si=function(e){return{code:0,data:e||{}}};class ii 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 ni={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,ri=function(e){oi=e},ai=function(e){return Promise.resolve(si(e))},ci=function(t,s=!1){if(t instanceof ii)return s&&null!==oi&&oi.emit(e.ERROR,t),Promise.reject(t);if(t instanceof Error){let t=new ii({code:ni.UNCAUGHT_ERROR});return s&&null!==oi&&oi.emit(e.ERROR,t),Promise.reject(t)}return Be(t)||Be(t.code)?Promise.reject(new ii({code:ni.UNCAUGHT_ERROR})):(t=new ii(t),s&&null!==oi&&oi.emit(e.ERROR,t),Promise.reject(t))};class li{constructor(e){this._m=e,this._n=""}isLoggedIn(){return this._m.get(Ns).isLoggedIn()}isOversea(){return this._m.get(Ns).isOversea()}isPrivateNetWork(){var e=this._m.get(Ns);return e.isPrivateNetWork()&&!e.getFileDownloadProxy()}getFileDownloadProxy(){return this._m.get(Ns).getFileDownloadProxy()}getDownloadFileAuthKey(){return this._m.get(Ns).getDownloadFileAuthKey()}getMyUserID(){return this._m.get(Ns).getUserID()}getMyTinyID(){return this._m.get(Ns).getTinyID()}getSDKAppID(){return this._m.get(Ns).getSDKAppID()}isIntl(){return this._m.get(Ns).isIntl()}isUsingChatCore(){return this._m.get(Ns).isUsingChatCore()}isDevMode(){return this._m.get(Ns).isDevMode()}get(e){return this._m.get(e)}getPlatform(){return W}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(Fs).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&&Se.w(e)}noUse(e){var t=ni.NO_USE;return ci({code:t,message:this.getErrMsg(t,e)})}}let ui={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",PIN_GRP_MSG:"pin_message",UNPIN_GRP_MSG:"unpin_message",GET_PINNED_GRP_MSG_LIST:"get_pinned_messages",GET_LIVE_HISTORY_MSG:"get_huge_group_msg",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"},di="networkRTT",_i="messageE2EDelay",hi="sendMessageC2C",pi="sendMessageGroup",gi="sendMessageGroupAV",mi="sendMessageRichMedia",fi="cosUpload",Mi="messageReceivedGroup",Ii="messageReceivedGroupAVPush",Ci="messageReceivedGroupAVPull",Ti={[di]:2,[_i]:3,[hi]:4,[pi]:5,[gi]:6,[mi]:7,[Mi]:8,[Ii]:9,[Ci]:10,[fi]:11},yi={info:4,warning:5,error:6},vi={wifi:1,"2g":2,"3g":3,"4g":4,"5g":5,unknown:6,none:7,online:8},Si={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=Si[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(t){if(t instanceof Error){if(!this._sentFlag){let e=!0;if(e=this._netMonitorModule?this._netMonitorModule.isOnline():e)t.code&&this.setCode(t.code),t.message&&this.setMoreMessage(t.message);else{let e=ni.NO_NETWORK;this.setCode(e)}this.setLevel("error")}}else Se.w(this._n+".setError value not instanceof Error, please check!");return this}setCode(e){return Be(e)||this._sentFlag||("ECONNABORTED"===e&&(this.code=103),Fe(e)?this.code=e:Se.w(this._n+".setCode value not a number, please check!",e,typeof e)),this}setMessage(e){return Be(e)||this._sentFlag||(Fe(e)&&(this.message=e.toString()),$e(e)&&(this.message=e)),this}setCostTime(e){return this.costTime=e,this}setLevel(e){return Be(e)||this._sentFlag||(this.level=yi[e]),this}setMoreMessage(e){return Ge(this.moreMessage)?this.moreMessage=""+e:this.moreMessage+=" "+e,this}setNetworkType(e){return Be(e)?Se.w(this._n+".setNetworkType value is undefined, please check!"):(e=vi[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 Di{constructor(e){this.type=t.MSG_TEXT,this.content={text:e.text||""}}setText(e){this.content.text=e}sendable(){return 0!==this.content.text.length}}function Ri(t,s,e,i=[]){if(!t)return t;let o=t,n=!1;if(!Ge(s)){let e=/^(https?:\/\/[^/]+)/;e.test(t)&&(o=t.replace(e,s),n=!0)}t=function(e,t){let s=!1;if(e){var e=e.match(/:\/\/([0-9]?\.)?(.[^/:]+)/),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}(o,i)||n;return o=e&&-1===o.indexOf("authKey=")&&t?-1<o.indexOf("?")?o+"&authKey="+e:o+"?authKey="+e:o}function Li(e,s,i=[]){var o=s[0].content||s[0].payload;if(e===t.MSG_IMAGE)o.imageInfoArray.forEach(e=>{e.imageUrl=Ai(e.imageUrl)});else if(e===t.MSG_VIDEO)o.remoteSnapshotUrl=Ai(o.remoteSnapshotUrl),o.remoteThumbUrl=Ai(o.remoteThumbUrl),o.remoteVideoUrl=Ai(o.remoteVideoUrl);else if(e===t.MSG_AUDIO)o.remoteAudioUrl=Ai(o.remoteAudioUrl);else if(e===t.MSG_FILE)o.remoteFileUrl=Ai(o.remoteFileUrl);else if(e===t.MSG_MERGER){let{downloadKey:e="",messageList:t=[]}=s[0].content||s[0].payload;Ge(e)&&t.forEach(e=>{Li(e.messageBody[0].type,e.messageBody,i)})}return s}function Ai(e){if(!e)return e;if(-1===e.indexOf("authKey="))return e;var e=e.split("?"),t=e[1].split("&");let s=0;for(let e=0;e<t.length;e++)if(-1<t[e].indexOf("authKey=")){s=e;break}return t.splice(s,1),0<t.length?e[0]+"?"+t.join("&"):e[0]}class Oi{constructor(e,s,i,o){this._imageMemoryURL="",this._fileDownloadProxy=s,this._authKey=i,this._fileDNList=o,$||x?this.createImageDataASURL(e.file):this.createImageDataASURLInWeb(e.file),this._initImageInfoModel(),this.type=t.MSG_IMAGE,this._percent=0,this.content={imageFormat:e.imageFormat||Ee.UNKNOWN,uuid:e.uuid,imageInfoArray:[]},this.initImageInfoArray(e.imageInfoArray),this._autoFixUrl()}_initImageInfoModel(){let t=this;this._ImageInfoModel=function(e){this.instanceID=Qe(9999999),this.sizeType=e.type||0,this.type=0,this.size=e.size||0,this.width=e.width||0,this.height=e.height||0,this.imageUrl=e.imageUrl||e.url||"",this.url=Ri(e.url||t._imageMemoryURL,t._fileDownloadProxy,t._authKey,t._fileDNList)},this._ImageInfoModel.prototype={setSizeType(e){this.sizeType=e},setType(e){this.type=e},setImageUrl(e){e&&(this.imageUrl=Ri(e,void 0,t._authKey,t._fileDNList))},getImageUrl(){return this.imageUrl}}}initImageInfoArray(e){let t=0,s=null,i;for(;t<=2;)i=Be(e)||Be(e[t])?{type:0,size:0,width:0,height:0,url:""}:e[t],(s=new this._ImageInfoModel(i)).setSizeType(t+1),s.setType(t),this.addImageInfo(s),t++;this.updateAccessSideImageInfoArray()}updateImageInfoArray(t){var s,i=this.content.imageInfoArray.length;for(let e=0;e<i;e++)s=this.content.imageInfoArray[e],t[e].size&&(s.size=t[e].size),t[e].url&&s.setImageUrl(t[e].url),t[e].width&&(s.width=t[e].width),t[e].height&&(s.height=t[e].height)}_autoFixUrl(){var t=this.content.imageInfoArray.length;let s="",i="";var o=["http","https"],n=null;for(let e=0;e<t;e++)this.content.imageInfoArray[e].url&&""!==(n=this.content.imageInfoArray[e]).imageUrl&&(i=n.imageUrl.slice(0,n.imageUrl.indexOf("://")+1),s=n.imageUrl.slice(n.imageUrl.indexOf("://")+1),o.indexOf(i)<0&&(i="https:"),this.content.imageInfoArray[e].setImageUrl([i,s].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&&(Ct(e),Object.assign(e[2],It({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=t.MSG_FACE,this.content=e||null}sendable(){return null!==this.content}}class Pi{constructor(e,s,i,o){this.type=t.MSG_AUDIO,this._percent=0,this._fileDownloadProxy=s,this._authKey=i,this._fileDNList=o,this.content={downloadFlag:2,second:e.second,size:e.size,url:Ri(e.url,this._fileDownloadProxy,this._authKey,this._fileDNList),remoteAudioUrl:Ri(e.url||"",void 0,this._authKey,this._fileDNList),uuid:e.uuid}}updatePercent(e){this._percent=e,1<this._percent&&(this._percent=1)}updateAudioUrl(e){this.content.remoteAudioUrl=Ri(e,void 0,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=t.MSG_GRP_TIP,this.content={},this._initContent(e)}_initContent(t){Object.keys(t).forEach(e=>{switch(e){case"remarkInfo":break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(t[e]);break;case"operatorInfo":this.content.operatorInfo={},this._initOperatorInfo(t[e]);break;case"memberInfoList":case"msgMemberInfo":this._updateMemberList(t[e]);break;case"memberExtraInfo":case"onlineMemberInfo":break;case"memberNum":this.content[e]=t[e],this.content.memberCount=t[e];break;case"newGroupProfile":this.content.newGroupProfile={},this._initNewGroupProfile(t[e]);break;default:this.content[e]=t[e]}}),this.content.userIDList||(this.content.userIDList=[this.content.operatorID])}_initGroupProfile(t){var s=Object.keys(t);for(let e=0;e<s.length;e++){var i=s[e];Ui[i]&&(this.content.groupProfile[i]=t[i])}}_initOperatorInfo(t){var s=Object.keys(t);for(let e=0;e<s.length;e++){var i=s[e];this.content.operatorInfo[i]=t[i]}}_updateMemberList(e){Ge(this.content.memberList)?this.content.memberList=e:this.content.memberList.forEach(t=>{e.forEach(e=>{t.userID===e.userID&&Object.assign(t,e)})})}_initNewGroupProfile(t){var s=Object.keys(t);for(let e=0;e<s.length;e++){var i=s[e];this.content.newGroupProfile[i]="muteAllMembers"!==i?t[i]:1===t[i]}}}let ki={from:!0,groupID:!0,groupName:!0,to:!0,groupType:!0};class wi{constructor(e){this.type=t.MSG_GRP_SYS_NOTICE,this.content={},this._initContent(e)}_initContent(t){Object.keys(t).forEach(e=>{switch(e){case"memberInfoList":break;case"remarkInfo":this.content.handleMessage=t[e];break;case"groupProfile":this.content.groupProfile={},this._initGroupProfile(t[e]);break;default:this.content[e]=t[e]}})}_initGroupProfile(t){var s=Object.keys(t);for(let e=0;e<s.length;e++){var i=s[e];ki[i]&&("groupName"===i?this.content.groupProfile.name=t[i]:this.content.groupProfile[i]=t[i])}}}class bi{constructor(e,s,i,o){this.type=t.MSG_FILE,this._percent=0;var n=this._getFileInfo(e);this.content={downloadFlag:2,fileUrl:Ri(e.url||e.fileUrl,s,i,o)||"",remoteFileUrl:Ri(e.url||e.fileUrl,void 0,i,o)||"",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(w){if(t.path&&-1!==t.path.indexOf(".")){let e=t.path.slice(t.path.lastIndexOf(".")+1).toLowerCase();t.type=e,t.name||(t.name=Qe(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,t){this.content.fileUrl=e,this.content.remoteFileUrl=t}sendable(){return""!==this.content.fileUrl&&""!==this.content.fileName&&0!==this.content.fileSize}}class Fi{constructor(e){this.type=t.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 $i{constructor(e,s,i,o){this.type=t.MSG_VIDEO,this._percent=0,this._fileDownloadProxy=s,this._authKey=i,this._fileDNList=o,this.content={remoteVideoUrl:Ri(e.remoteVideoUrl||e.videoUrl||"",void 0,this._authKey,this._fileDNList),videoFormat:e.videoFormat,videoSecond:parseInt(e.videoSecond,10),videoSize:e.videoSize,videoUrl:Ri(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:Ri(e.thumbUrl,this._fileDownloadProxy,this._authKey,this._fileDNList),snapshotUrl:Ri(e.thumbUrl,this._fileDownloadProxy,this._authKey,this._fileDNList),remoteSnapshotUrl:Ri(e.thumbUrl,void 0,this._authKey,this._fileDNList),remoteThumbUrl:Ri(e.thumbUrl,void 0,this._authKey,this._fileDNList)}}updatePercent(e){this._percent=e,1<this._percent&&(this._percent=1)}updateVideoUrl(e){e&&(this.content.remoteVideoUrl=Ri(e,void 0,this._authKey,this._fileDNList))}updateSnapshotInfo(e){var{snapshotUrl:e,snapshotWidth:t,snapshotHeight:s,remoteSnapshotUrl:i}=e;Ge(e)||(this.content.thumbUrl=this.content.snapshotUrl=e),Ge(t)||(this.content.thumbWidth=this.content.snapshotWidth=Number(t)),Ge(s)||(this.content.thumbHeight=this.content.snapshotHeight=Number(s)),Ge(i)||(this.content.remoteSnapshotUrl=i,this.content.remoteThumbUrl=i)}sendable(){return""!==this.content.remoteVideoUrl}}class qi{constructor(e){this.type=t.MSG_LOCATION;var{description:e,longitude:s,latitude:i}=e;this.content={description:e,longitude:s,latitude:i}}sendable(){return!0}}class xi{constructor(e,s,i,o){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(t.CONV_C2C)?this.receiverUserID=e.to:e.conversationType.startsWith(t.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,s,i,o),n===t.MSG_MERGER?this.messageBody.push({type:n,payload:new Vi(r,s,i,o).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,s){e===t.MSG_IMAGE?s.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===t.MSG_VIDEO?!s.remoteVideoUrl&&s.videoUrl&&(s.remoteVideoUrl=s.videoUrl):e===t.MSG_AUDIO?!s.remoteAudioUrl&&s.url&&(s.remoteAudioUrl=s.url):e===t.MSG_FILE&&!s.fileUrl&&s.url&&(s.remoteFileUrl=s.url,s.fileUrl=s.url,s.url=void 0)}_updateRichMediaDownloadUrl(e,s,i,o,n){(i||o)&&(e===t.MSG_IMAGE?s.imageInfoArray.forEach(e=>{e.imageUrl=Ri(e.imageUrl,void 0,o,n),e.url=Ri(e.url,i,o,n)}):e===t.MSG_VIDEO?(s.remoteVideoUrl=Ri(s.remoteVideoUrl,void 0,o,n),s.videoUrl=Ri(s.videoUrl,i,o,n),s.remoteThumbUrl=Ri(s.thumbUrl,void 0,o,n),s.remoteSnapshotUrl=Ri(s.thumbUrl,void 0,o,n),s.thumbUrl=Ri(s.thumbUrl,i,o,n),s.snapshotUrl=Ri(s.thumbUrl,i,o,n),s.snapshotHeight=s.thumbHeight,s.snapshotWidth=s.thumbWidth):e===t.MSG_AUDIO?(s.remoteAudioUrl=Ri(s.remoteAudioUrl,void 0,o,n),s.url=Ri(s.url,i,o,n)):e===t.MSG_FILE&&(s.remoteFileUrl=Ri(s.fileUrl,void 0,o,n),s.fileUrl=Ri(s.fileUrl,i,o,n)))}}var Vi=class{constructor(r,a,l,d){if(this.type=t.MSG_MERGER,this.content={downloadKey:"",pbDownloadKey:"",messageList:[],title:"",abstractList:[],compatibleText:"",version:0,layersOverLimit:!1},r.downloadKey){let{downloadKey:e,pbDownloadKey:t,title:s,abstractList:i,compatibleText:o,version:n}=r;this.content.downloadKey=e,this.content.pbDownloadKey=t,this.content.title=s,this.content.abstractList=i,this.content.compatibleText=o,this.content.version=n||0}else if(Ge(r.messageList))1===r.layersOverLimit&&(this.content.layersOverLimit=!0);else{let{messageList:e,title:t,abstractList:s,compatibleText:i,version:o}=r,n=[];e.forEach(e=>{Ge(e)||(e=new xi(e,a,l,d),n.push(e))}),this.content.messageList=n,this.content.title=t,this.content.abstractList=s,this.content.compatibleText=i,this.content.version=o||0}}sendable(){return!Ge(this.content.messageList)||!Ge(this.content.downloadKey)}};let Bi={1:t.MSG_PRIORITY_HIGH,2:t.MSG_PRIORITY_NORMAL,3:t.MSG_PRIORITY_LOW,4:t.MSG_PRIORITY_LOWEST};class Ki{constructor(e){this.ID="",this.conversationID=e.conversationID||null,this.conversationType=e.conversationType||t.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:Qe(),this.priority=this._computePriority(e.priority),this.nick=e.nick||"",this.avatar=e.avatar||"",this.isPeerRead=!1,this.nameCard="",this.hasRiskContent=Nt(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||kt,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||Ce()||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.pinnerInfo=e.pinnerInfo||null,this.level=e.level||0,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&&($e(e.nick)&&(this.nick=e.nick),$e(e.avatar)&&(this.avatar=e.avatar),Fe(e.level)&&(this.level=e.level),e=e.messageFromAccountExtraInformation,xe(e))&&$e(e.nameCard)&&(this.nameCard=e.nameCard)}handleGroupAtInfo(e){e.payload&&e.payload.atUserList&&e.payload.atUserList.forEach(e=>{e!==t.MSG_AT_ALL?(this._groupAtInfoList.push({groupAtAllFlag:0,groupAtUserID:e}),this.atUserList.push(e)):(this._groupAtInfoList.push({groupAtAllFlag:1}),this.atUserList.push(t.MSG_AT_ALL))}),Ve(e.groupAtInfo)&&e.groupAtInfo.forEach(e=>{0===e.groupAtAllFlag?this.atUserList.push(e.groupAtUserID):1===e.groupAtAllFlag&&this.atUserList.push(t.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?kt:Gt,!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===t.CONV_GROUP&&(this.to=e.groupID)}_initSequence(e){0===this.clientSequence&&e&&(this.clientSequence=function(i){if(!i)return!1;if(void 0===nt[i]){var o=new Date;let e=("3"+o.getHours()).slice(-2),t=("0"+o.getMinutes()).slice(-2),s=("0"+o.getSeconds()).slice(-2);nt[i]=parseInt([e,t,s,"0001"].join("")),e=null,t=null,s=null,Se.l("autoIncrementIndex start index:"+nt[i])}return nt[i]++}(e)),0===this.sequence&&this.conversationType===t.CONV_C2C&&(this.sequence=this.clientSequence)}generateMessageID(){this.from===t.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 s=this["to"],i=this.conversationType;i!==t.CONV_SYSTEM?(e=i===t.CONV_C2C?e===this.from?s:this.from:this.to,this.conversationID=e?""+i+e:null):this.conversationID=t.CONV_SYSTEM}isElement(e){return e instanceof Di||e instanceof Oi||e instanceof Ni||e instanceof Pi||e instanceof bi||e instanceof $i||e instanceof Gi||e instanceof wi||e instanceof Fi||e instanceof qi||e instanceof Vi}setElement(s,i,o,n){if(this.isElement(s))this._elements=[s];else{var r=e=>{if(e.type&&e.content)switch(e.type){case t.MSG_TEXT:this.setTextElement(e.content);break;case t.MSG_IMAGE:this.setImageElement(e.content,i,o,n);break;case t.MSG_AUDIO:this.setAudioElement(e.content,i,o,n);break;case t.MSG_FILE:this.setFileElement(e.content,i,o,n);break;case t.MSG_VIDEO:this.setVideoElement(e.content,i,o,n);break;case t.MSG_CUSTOM:this.setCustomElement(e.content);break;case t.MSG_LOCATION:this.setLocationElement(e.content);break;case t.MSG_GRP_TIP:this.setGroupTipElement(e.content);break;case t.MSG_GRP_SYS_NOTICE:this.setGroupSystemNoticeElement(e.content);break;case t.MSG_FACE:this.setFaceElement(e.content);break;case t.MSG_MERGER:this.setMergerElement(e.content,i,o,n)}};if(Ve(s))for(let e=0;e<s.length;e++)r(s[e]);else r(s)}this._initProxy()}clearElement(){this._elements.length=0}setTextElement(e){e="string"==typeof e?e:e.text,e=new Di({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 $i(e,t,s,i);this._elements.push(e)}setLocationElement(e){e=new qi(e);this._elements.push(e)}setCustomElement(e){e=new Fi(e);this._elements.push(e)}setGroupTipElement(e){let s={};var i=e.operationType;if(Ge(e.memberInfoList)?e.operatorInfo&&(s=e.operatorInfo):i!==t.GRP_TIP_MBR_JOIN&&i!==t.GRP_TIP_MBR_KICKED_OUT&&i!==t.GRP_TIP_MBR_SET_ADMIN&&i!==t.GRP_TIP_MBR_CANCELED_ADMIN||(s=e.memberInfoList[0]),!Ge(e.memberExtraInfo)){let t=e.memberExtraInfo["reason"];e.msgMemberInfo.forEach(e=>{e.reason=t})}var{nick:i,avatar:o}=s,i=($e(i)&&(this.nick=i),$e(o)&&(this.avatar=o),new Gi(e));this._elements.push(i)}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 Vi(e,t,s,i);this._elements.push(e)}setIsRead(e){this.isRead=e}setRelayFlag(e){this._relayFlag=e}_computePriority(s){if(!Be(s)){if($e(s)&&-1!==Object.values(Bi).indexOf(s))return s;if(Fe(s)){let e=""+s;if(-1!==Object.keys(Bi).indexOf(e))return Bi[e]}}return t.MSG_PRIORITY_NORMAL}setNickAndAvatar(e){var{nick:e,avatar:t}=e;$e(e)&&(this.nick=e),$e(t)&&(this.avatar=t)}setNameCard(e){$e(e)&&(this.nameCard=e)}initC2CReadReceiptInfo(e){var{readReceiptSentByPeer:e,timestamp:s=0}=e;this.conversationType===t.CONV_C2C&&!0===this.needReadReceipt&&(this.readReceiptInfo.isPeerRead=1===e,this.readReceiptInfo.timestamp=s)}}let Hi={HonorImportance:{range:["LOW","NORMAL"],defaultValue:void 0},MeizuNotifyType:{range:[0,1],defaultValue:void 0}},Wi={enableIOSBackgroundNotification:{range:[!0,!1],defaultValue:!1},interruptionLevel:{range:["passive","active","time-sensitive","critical"],defaultValue:"active"}};function Yi(e,t){for(var s in t){var i,o;Object.prototype.hasOwnProperty.call(t,s)&&({range:i,defaultValue:o}=t[s],e[s]=i.includes(e[s])?e[s]:o)}return e}function zi(e){var t=e.lastIndexOf(".");return-1===t?e:e.slice(0,t)}function ji(e){let{androidInfo:t={},androidOPPOChannelID:s=""}=e,i=t.OPPOChannelID||s,{sound:o="",FCMChannelID:n="",...r}=Yi(t,Hi);return{...r,Sound:zi(o),OPPOChannelID:i,GoogleChannelID:n}}function Ji(e){let{apnsInfo:t={},ignoreIOSBadge:s=!1,disableVoipPush:i}=e,{ignoreIOSBadge:o,disableVoipPush:n,enableIOSBackgroundNotification:r,...a}=Yi(t,Wi),l=!0===o||!0===s?1:0,d=void 0;return Be(i)||(d=!1===i?1:0),Be(n)||(d=!1===n?1:0),{...a,badgeMode:l,isVoipPush:d,contentAvailable:r?1:0}}function Xi(e){if(xe(e))return{pushFlag:!0===e.disablePush?1:0,title:e.title||"",desc:e.description||"",ext:e.extension||"",apnsInfo:Ji(e),androidInfo:ji(e)}}class Zi extends li{constructor(e){super(e),this._n="C2CModule",this._msgFromUnreadDBMap=new Map,this._noticeFromUnreadDBList=[],this._hoppingMsgKeyMap=new Map}onNewMessage(t){var{dataList:t,isInstantMessage:s,C2CRemainingUnreadList:i,C2CPairUnreadList:o,isSyncingEnded:n,isOnlineSync:r}=t,{conversationOptionsList:t,messageList:i,isUnreadC2CMessage:o}=(s||Se.l(this._n+".onNewMessage C2CPairUnreadList:",o,"C2CRemainingUnreadList:",i),this._assembly({dataList:t,C2CRemainingUnreadList:i,C2CPairUnreadList:o,isInstantMessage:s,isOnlineSync:r})),r=Ge(r=i)?[]:r.filter(e=>!0===e.isModified),t=(0<r.length&&this.emitOEvt(e.MESSAGE_MODIFIED,r),this.get(Os).onNewMessage({conversationOptionsList:t,isInstantMessage:s,isUnreadC2CMessage:o,isSyncingEnded:n}),Ge(r=i)?[]:r.filter(e=>!1===e.isModified));s&&0<t.length&&this.emitOEvt(e.MESSAGE_RECEIVED,t),i.length=0}_assembly({dataList:r,C2CRemainingUnreadList:i,C2CPairUnreadList:o,isInstantMessage:a,isOnlineSync:n}){var l=null,d=[],u=[],c={},_=this.get(Bs);let h=!1;var p=this.get(Os),g=this.get(Es),e=this.get(ks),m=this.getFileDownloadProxy(),f=this.getDownloadFileAuthKey(),M=e.getFileDNList();for(let n=0,e=r.length;n<e;n++)if(this._isC2CNotice(r[n]))this._noticeFromUnreadDBList.push(r[n].eventArray[0].c2CNotifyMsgArray[0]);else{let s=r[n],o=(s.currentUser=this.getMyUserID(),s.conversationType=t.CONV_C2C,s.isSystemMessage=!!s.isSystemMessage,(Be(s.nick)||Be(s.avatar))&&(h=!0),(l=new Ki(s)).setElement(s.elements,m,f,M),l.setNickAndAvatar({nick:s.nick,avatar:s.avatar}),l)["conversationID"];if(a){if(this._msgFromUnreadDBMap.get(l.ID))continue;let i=!1;if(l.from!==this.getMyUserID()){let s=p.getLatestMessageSentByPeer(o);if(s){let{nick:e,avatar:t}=s;h?l.setNickAndAvatar({nick:e,avatar:t}):e===l.nick&&t===l.avatar||(i=!0)}}else{let s=p.getLatestMessageSentByMe(o);if(s){let{nick:e,avatar:t}=s;e===l.nick&&t===l.avatar||(p.modifyMessageSentByMe({conversationID:o,latestNick:l.nick,latestAvatar:l.avatar}),g.mockOnNickAvatarModified(l.nick,l.avatar))}}let e=1===r[n].isModified;if(p.isMessageSentByCurrentInstance(l)?l.isModified=e:e=!1,0===s.msgLifeTime)l._onlineOnlyFlag=!0,p.isMessageSentByCurrentInstance(l)||u.push(l);else{if(!p.pushIntoMessageList(u,l,e))continue;i&&(p.modifyMessageSentByPeer({conversationID:o,latestNick:l.nick,latestAvatar:l.avatar}),p.updateUserProfileSpecifiedKey({conversationID:o,nick:l.nick,avatar:l.avatar}))}a&&0<l.clientTime&&_.addMessageDelay(l.clientTime)}else this._msgFromUnreadDBMap.set(l.ID,l);if(0!==s.msgLifeTime){if(!1===l._onlineOnlyFlag){let e=p.getLastMessageTime(o);if(!(Fe(e)&&l.time<e)&&a)if(Be(c[o])){let e=0;"in"!==l.flow||l._isExcludedFromUnreadCount||(e=1),c[o]=d.push({conversationID:o,unreadCount:e,type:l.conversationType,subType:l.conversationSubType,lastMessage:l._isExcludedFromLastMessage?"":l})-1}else{let e=c[o];d[e].type=l.conversationType,d[e].subType=l.conversationSubType,d[e].lastMessage=l._isExcludedFromLastMessage?"":l,"in"!==l.flow||l._isExcludedFromUnreadCount||d[e].unreadCount++}}}else l._onlineOnlyFlag=!0}this._handleNoticeFromUnreadDB();let I=!1;if(Ve(o)&&0<o.length)for(let s=0,e=o.length;s<e;s++)if(o[s].from!==t.CONV_SYSTEM){I=!0;let e=d.find(({conversationID:e})=>e===""+t.CONV_C2C+o[s].from);n&&!e||(e?e.unreadCount=o[s].unreadCount:d.push({conversationID:""+t.CONV_C2C+o[s].from,unreadCount:o[s].unreadCount,type:t.CONV_C2C}))}if(Ve(i))for(let s=0,e=i.length;s<e;s++)d.find(({conversationID:e})=>e===""+t.CONV_C2C+i[s].from)||d.push({conversationID:""+t.CONV_C2C+i[s].from,type:t.CONV_C2C,lastMsgTime:i[s].lastMsgTime});return{conversationOptionsList:d,messageList:u,isUnreadC2CMessage:I}}getMessageListFromUnreadDB(){return[...this._msgFromUnreadDBMap.values()]}_isC2CNotice(e){e=e.eventArray;return!(!Ve(e)||10!==e[0].event)}_handleNoticeFromUnreadDB(){var e=this._noticeFromUnreadDBList.length;if(0!==e){Se.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(s,i){let r=this.get(Os),a=[],l;s.dataList.forEach(e=>{e.c2cMessageRevokedNotify&&(e=e.c2cMessageRevokedNotify["revokedInfos"],Be(e)||e.forEach(e=>{var s=this.getMyUserID()===e.from?""+t.CONV_C2C+e.to:""+t.CONV_C2C+e.from,i=(l=r.revoke(s,e.sequence,e.random),e.revokerInfo&&e.revokerInfo.revoker),o=e.revokerInfo&&e.revokerInfo.reason||"";let n;l?n=l:(n={conversationID:s,sequence:e.sequence},e.tinyID&&e.clientTime&&e.random&&(n.ID=`${e.tinyID}-${e.clientTime}-`+e.random),e.time&&(n.time=e.time)),n&&(n.revoker=i,n.revokeReason=o,n.revokerInfo={userID:i,nick:"",avatar:""},a.push(n))}))}),0!==a.length&&(Se.l(`${this._n}.onMsgRevoked count:${a.length} updateUnreadCount:`+i),r.onMessageRevoked(a,i),r.updateRevokerInfo(a).then(t=>{this.emitOEvt(e.MESSAGE_REVOKED,t)}))}onMsgReadReceipt(e){e.dataList.forEach(e=>{if(!Ge(e.c2cMessageReadReceipt)){let o=e.c2cMessageReadReceipt["to"];e.c2cMessageReadReceipt.uinPairReadArray.forEach(e=>{var e=e["peerReadTime"],s=(Se.l(`${this._n}.onMsgReadReceipt to:${o} peerReadTime:`+e),""+t.CONV_C2C+o),i=this.get(Os);i.recordPeerReadTime(s,e),i.updateMsgIsPeerReadProp(s,e)})}})}onMsgReadNotice(e){e.dataList.forEach(e=>{if(!Ge(e.c2cMessageReadNotice)){let i=this.get(Os);e.c2cMessageReadNotice.uinPairReadArray.forEach(e=>{var{from:e,peerReadTime:s}=e,e=(Se.l(this._n+`.onMsgReadNotice from:${e} lastReadTime:`+s),""+t.CONV_C2C+e);i.updateIsReadAfterReadReport({conversationID:e,lastMessageTime:s}),i.updateUnreadCount(e)})}})}onMsgModified(e){Se.l(this._n+".onMsgModified options:",e);let s=this.get(Os);e.dataList.forEach(e=>{s.onMessageModified({...e,conversationType:t.CONV_C2C})})}onReadReceiptList(e){Se.l(this._n+".onReadReceiptList options:",e),this.get(Os).updateReadReceiptInfo(e.dataList)}sendMessage(e,t){e=this._createC2CMessagePack(e,t);return this.req(e)}_createC2CMessagePack(e,i){let t=null,s=(i&&(i.offlinePushInfo&&(t=i.offlinePushInfo),!0===i.onlineUserOnly)&&(t?t.disablePush=!0:t={disablePush:!0}),"");$e(e.cloudCustomData)&&0<e.cloudCustomData.length&&(s=e.cloudCustomData);var o=[];if(xe(i)&&xe(i.messageControlInfo)){let{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:s}=i.messageControlInfo;!0===e&&o.push("NoUnread"),!0===t&&o.push("NoLastMsg"),!0===s&&o.push("NoMsgCheck")}var n=this.isOnlineMessage(e,i)?0:void 0,r=JSON.parse(JSON.stringify(e.getElements())),a=this.get(ks).getFileDNList();return{P:ui.SEND_C2C_MSG,data:{fromAccount:this.getMyUserID(),toAccount:e.to,msgBody:Li(e.type,r,a),cloudCustomData:s,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:n,nick:e.nick,avatar:e.avatar,offlinePushInfo:Xi(t),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:at(i)}}}isOnlineMessage(e,t){return!(!t||!0!==t.onlineUserOnly)}revokeMessage(e){return this.req({P:ui.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 Se.l(this._n+`.deleteMessage toAccount:${e} count:`+t.length),this.req({P:ui.DEL_C2C_MSG,data:{fromAccount:this.getMyUserID(),to:e,keyList:t}})}modifyRemoteMessage(e){var s,{from:e,to:i,version:o=0,sequence:n,random:r,time:a,payload:l,type:d,cloudCustomData:u,_elements:c}=e;let _=void 0;return(s=d)!==t.MSG_TEXT&&s!==t.MSG_CUSTOM&&s!==t.MSG_LOCATION&&s!==t.MSG_FACE||(1<c.length&&c.splice(0,1,{type:d,content:l}),_=c),this.req({P:ui.MODIFY_C2C_MSG,data:{from:e,to:i,version:o,sequence:n,random:r,time:a,elements:_,cloudCustomData:u}})}setMessageRead({conversationID:t,lastMessageTime:s}){let i=this._n+".setMessageRead",e=`convID:${t} lastMessageTime:`+s,o=(Se.l(i+" "+e),Fe(s)||this.warn("DoNotModifyLastTime"),new Ei("setMessageRead"));return o.setMessage(e),this.req({P:ui.SET_C2C_MSG_READ,data:{C2CMsgReaded:{cookie:"",C2CMsgReadedItem:[{toAccount:t.replace("C2C",""),lastMessageTime:s,receipt:1}]}}}).then(()=>{o.end(),Se.l(i+" ok");var e=this.get(Os);return e.updateIsReadAfterReadReport({conversationID:t,lastMessageTime:s}),e.updateUnreadCount(t),si()}).catch(e=>(o.setError(e).end(),Se.l(i+" failed. error:",e),ci(e)))}getRoamingMessage(e){let u=this._n+".getRoamingMessage",{peerAccount:s,conversationID:c,count:i,lastMessageTime:o,messageKey:n}=e,_=`peerAccount:${s} count:${i||15} lastMessageTime:${o||0} messageKey:`+n,h=(Se.l(u+" "+_),new Ei("getRoamingMessage"));return this.req({P:ui.GET_C2C_ROAMING_MSG,data:{peerAccount:s,count:i||15,lastMessageTime:o||0,messageKey:n}}).then(e=>{var{complete:e,messageList:s,messageKey:i,lastMessageTime:o}=e.data;Be(s)?Se.l(u+` ok. complete:${e} but messageList is undefined!`):Se.l(u+` ok. complete:${e} count:`+s.length),h.setMessage(_+` complete:${e} length:`+s.length).end();let n=this.get(Os),r=1===e,a=(r&&n.setCompleted(c),[]),l=n.onRoamingMessage(s,c,!0,a),d=(n.modifyMessageList(c),n.updateIsRead(c),n.updateRoamingMsgKeyAndTime(c,i,o),"");if(0<l.length)d=l[0].ID;else{let e=n.getLocalOldestMessage(c);e&&(d=e.ID)}e=n.getPeerReadTime(c);if(Se.l(u+` update isPeerRead property. convID:${c} peerReadTime:`+e),e)return n.updateMsgIsPeerReadProp(c,e),Se.l(u+` nextReqID:${d} storedMsgCount:`+l.length),{nextReqID:d,storedMessageList:l,assembledMessageList:a,isPullingCompleted:r};{let e=c.replace(t.CONV_C2C,"");return this.getRemotePeerReadTime([e]).then(()=>(n.updateMsgIsPeerReadProp(c,n.getPeerReadTime(c)),Se.l(u+` nextReqID:${d} storedMsgCount:`+l.length),{nextReqID:d,storedMessageList:l,assembledMessageList:a,isPullingCompleted:r}))}}).catch(e=>(h.setMessage(_).setError(e).end(),Se.w(u+" failed. error:",e),ci(e)))}getRoamingMessagesHopping(e){let u=this._n+".getRoamingMessagesHopping",{peerAccount:s,time:i=0,count:o,direction:c}=e,_=""+t.CONV_C2C+s,h=`peerAccount:${s} count:${o} time:${i} direction:`+c,p=(Se.l(u+" "+h),new Ei("getRoamingMessagesHopping"));return this.req({P:ui.GET_C2C_ROAMING_MSG,data:{peerAccount:s,lastMessageTime:i,messageKey:this._gethHoppingMsgKey({conversationID:_,time:i,direction:c}),count:o,direction:c}}).then(e=>{var{complete:e,messageList:s=[],lastMessageTime:i,messageKey:o}=e.data,n=`complete:${e} count:`+s.length,n=(Se.l(u+" ok. "+n),p.setMessage(h+" "+n).end(),_+"-"+c);this._hoppingMsgKeyMap.set(n,{lastMessageTime:i,messageKey:o}),1===e&&this._hoppingMsgKeyMap.delete(n);let r=this.get(Os),a=r.onRoamingMessage(s,_,!1),l=(this._modifyMessageList(_,a),this._computeResult({complete:e,lastMessageTime:i,resultList:a})),d=(r.storeHoppingMessageList(l.messageList),r.getPeerReadTime(_));if(Se.l(u+` update isPeerRead property. convID:${_} peerReadTime:`+d),d)return r.updateMsgIsPeerReadProp(_,d),this._updateIsPeerReadByHopping(l,d),si(l);{let e=_.replace(t.CONV_C2C,"");return this.getRemotePeerReadTime([e]).then(()=>(r.updateMsgIsPeerReadProp(_,r.getPeerReadTime(_)),this._updateIsPeerReadByHopping(l,d),si(l)))}}).catch(e=>(p.setMessage(h).setError(e).end(),Se.w(u+" failed. error:",e),ci(e)))}_gethHoppingMsgKey(e){var{conversationID:e,time:t,direction:s}=e,{lastMessageTime:e,messageKey:s=""}=this._hoppingMsgKeyMap.get(e+"-"+s)||{};return t===e?s:""}_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}_updateIsPeerReadByHopping(e,s){var{messageList:i=[]}=e;for(let t=0;t<i.length;t++){let e=i[t];e.time<=s&&!e.isPeerRead&&"out"===e.flow&&(e.isPeerRead=!0)}}_modifyMessageList(e,s){e=this.get(Os).getLocalConversation(e);if(e){var i=e.userProfile.nick,o=e.userProfile.avatar,e=this.get(Es).getNickAndAvatarByUserID(this.getMyUserID()),n=e.nick,r=e.avatar;for(let t=s.length-1;0<=t;t--){let e=s[t];"in"===e.flow&&(e.nick!==i&&e.setNickAndAvatar({nick:i}),e.avatar!==o)&&e.setNickAndAvatar({avatar:o}),"out"===e.flow&&(e.nick!==n&&e.setNickAndAvatar({nick:n}),e.avatar!==r)&&e.setNickAndAvatar({avatar:r})}}}getRemotePeerReadTime(n){let r=this._n+".getRemotePeerReadTime";if(Ge(n))return Promise.resolve();let a=new Ei("getRemotePeerReadTime");return Se.l(r+" userIDList:"+n),this.req({P:ui.GET_C2C_PEER_READ_TIME,data:{userIDList:n}}).then(e=>{var s=e.data["peerReadTimeList"];Se.l(r+" ok. peerReadTimeList:"+s);let i="";var o=this.get(Os);for(let e=0;e<n.length;e++)i+=`${n[e]}-${s[e]} `,0<s[e]&&o.recordPeerReadTime(""+t.CONV_C2C+n[e],s[e]);a.setMessage(i).end()}).catch(e=>{a.setError(e).end(),Se.w(r+" failed. error:",e)})}sendReadReceipt(e){let s=e[0].conversationID.replace(t.CONV_C2C,""),i=new Ei("sendReadReceipt"),o=(i.setMessage("peerAccount:"+s),this.getMyUserID()),n=e.filter(e=>e.from!==o&&!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 ci({code:ni.READ_RECEIPT_MSG_LIST_EMPTY});let r=this._n+".sendReadReceipt";return Se.l(r+`. peerAccount:${s} length:`+n.length),this.req({P:ui.SEND_C2C_READ_RECEIPT,data:{peerAccount:s,messageInfoList:n}}).then(e=>(i.end(),Se.l(r+" ok"),si())).catch(e=>(i.setError(e).end(),Se.w(r+" failed. error:",e),ci(e)))}getReadReceiptList(e){var s=e[0].conversationID.replace(t.CONV_C2C,"");return Se.l(this._n+`.getReadReceiptList peerAccount:${s} msgCount:`+e.length),ai({messageList:e})}getMessageExtensions(e,t){return Se.l(this._n+".getMessageExtensions startSequence:"+t),this.req({P:ui.GET_C2C_MSG_EXT,data:{from:e.from,to:e.to,messageKey:this.getMessageKey(e),startSequence:t}})}modifyMsgExts(e,t,s=1){return Se.l(this._n+".modifyMsgExts operateType:"+s),this.req({P:ui.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(){Se.l(this._n+".reset"),this._msgFromUnreadDBMap.clear(),this._noticeFromUnreadDBList.length=0,this._hoppingMsgKeyMap.clear()}}let Qi={A2KEY_AND_TINYID_UPDATED:"_inner1",CLOUD_CONFIG:"_inner2",PROFILE_UPDATED:"_inner3",CONV_SYNC_COMPLETED:"_inner4",C2C_UNREAD_HANDLE_COMPLETED:"_inner5"};class en{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(Qi.CLOUD_CONFIG,this._onCloudConfig,this)}_onCloudConfig(){var e=this._convM.getCloudConfig("topic_msg_limit");Be(e)||(this.TOPIC_MSG_LIMIT=Number(e)),Se.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(Pe)&&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 i=!1}return this._map.get(s).set(o,e),this._setLatestMsgSentByPeer(s,e),this._setLatestMsgSentByMe(s,e),i}unshift(e,s){let o;if(Ve(e)?0<e.length&&(o=e[0].conversationID,this._unshiftMultipleMsgs(e,s)):(o=e.conversationID,this._unshiftSingleMsg(e,s)),o){let s=Array.from(this._map.get(o).values()),i=s.length;if(0!==i){for(let e=i-1;0<=e;e--)if("out"===s[e].flow){this._setLatestMsgSentByMe(o,s[e]);break}if(o.startsWith(t.CONV_C2C))for(let e=i-1;0<=e;e--)if("in"===s[e].flow){this._setLatestMsgSentByPeer(o,s[e]);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(s,i){let e=s.length,o=[],t=s[0].conversationID,n=this._map.get(t),r=this._map.has(t)?Array.from(n):[];for(let t=0;t<e;t++){let e=this._getUniqueIDOfMsg(s[t]);n&&n.has(e)||(o.push([e,s[t]]),i.push(s[t]))}this._map.set(t,new Map(o.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);Se.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=(t=this._findMsg(e,this._map))||this._findMsg(e,this._hoppingMsgMap)}_findMsg(i,e){let o=null;for(var[,n]of e){let t=[...n.values()],s=t.length;for(let e=0;e<s;e++)if(t[e].ID===i){o=t[e];break}}return o}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)),Se.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 e=0;e<o;e++)i[e].ID===t&&(s=!0);return s}getLocalMsg(e,t){let s=null;var i=this.getLocalMsgList(e),o=i.length;for(let e=0;e<o;e++)if(i[e].ID===t){s=i[e];break}return s}getLocalLastMsg(e){var t=this.getLocalMsgList(e);let s=void 0;for(let e=t.length-1;0<=e;e--)if(t[e].status===kt){s=t[e];break}return s}getLocalSecondLastMsg(e){e=this.getLocalMsgList(e);return e[e.length-2]}getLocalOldestMsg(e){return this.getLocalMsgList(e)[0]}_setLatestMsgSentByPeer(e,s){e.startsWith(t.CONV_C2C)&&"in"===s.flow&&this._latestMsgSentByPeerMap.set(e,s)}_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:o,latestAvatar:n}=e,r=this._map.get(e);if(!Ge(r)){var a=Array.from(r.values()),r=a.length;if(0!==r){let t=null,s=0,i=!1;for(let e=r-1;0<=e;e--)"in"===a[e].flow&&((t=a[e]).nick!==o&&(t.setNickAndAvatar({nick:o}),i=!0),t.avatar!==n&&(t.setNickAndAvatar({avatar:n}),i=!0),i)&&(s+=1);Se.l(this._n+`.modifyMsgSentByPeer convID:${e} count:`+s)}}}modifyMsgSentByMe(e){var{conversationID:e,latestNick:o,latestAvatar:n}=e,r=this._map.get(e);if(!Ge(r)){var a=Array.from(r.values()),r=a.length;if(0!==r){let t=null,s=0,i=!1;for(let e=r-1;0<=e;e--)"out"===a[e].flow&&((t=a[e]).nick!==o&&(t.setNickAndAvatar({nick:o}),i=!0),t.avatar!==n&&(t.setNickAndAvatar({avatar:n}),i=!0),i)&&(s+=1);Se.l(this._n+`.modifyMsgSentByMe convID:${e} count:`+s)}}}getTopicConvIDList(s){return[...this._map.keys()].filter(e=>e.startsWith(""+t.CONV_GROUP+s))}onMsgModified(s,r){if(this._map.has(s)||this._hoppingMsgMap.has(s)){let o=this._n+".onMsgModified",e=this._getUniqueIDOfMsg(r),n=this._getTargetMsg(s,e),t=!!n;if(Se.l(o+` convID:${s} uniqueID:${e} has:`+t),t){let{messageVersion:e,elements:t,cloudCustomData:s,checkResult:i}=r;return Se.l(o+` localVersion:${n.version} remoteVersion:`+e),n.version<e?(n.version=e,n._elements=JSON.parse(JSON.stringify(t)),n.payload=n._elements[0].content,n.type=n._elements[0].type,n.cloudCustomData=s,n.isModified=!0,n.hasRiskContent=Nt(i),{isUpdated:!0,message:n}):{isUpdated:!1,message:n}}}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=void 0;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(i){if(0!==i.length){let e=i[0]["conversationID"],s=i.length;this._hoppingMsgMap.has(e)||this._hoppingMsgMap.set(e,new Map);var o=this._hoppingMsgMap.get(e);for(let t=0;t<s;t++){let e=i[t];o.has(e.ID)||o.set(e.ID,e)}}}getHoppingMsg(e,t){if(this._hoppingMsgMap.has(e))return this._hoppingMsgMap.get(e).get(t)}findMsgBySeq(e,t){var s=[];return this._map.has(e)&&s.push(...this._map.get(e).values()),this._hoppingMsgMap.has(e)&&s.push(...this._hoppingMsgMap.get(e).values()),s.find(e=>e.sequence===t)}reset(){this._map.clear(),this._latestMsgSentByPeerMap.clear(),this._latestMsgSentByMeMap.clear(),this._hoppingMsgMap.clear()}}function tn(e){this.mixin(e)}tn.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 sn=["jpg","jpeg","gif","png","bmp","image","webp"],nn=["mp4","quicktime","mov","video"],on=1,rn=2,an=3,cn=255;class ln{constructor(e){Ge(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||t.ALLOW_TYPE_ALLOW_ANY,this.language=e.language||0,this.avatar=e.avatar||"",this.messageSettings=e.messageSettings||0,this.adminForbidType=e.adminForbidType||t.FORBID_TYPE_NONE,this.level=e.level||0,this.role=e.role||0,this.lastUpdatedTime=e.lastUpdatedTime||0,this.profileCustomField=[],Ge(e.profileCustomField))||e.profileCustomField.forEach(e=>{this.profileCustomField.push({key:e.key,value:e.value})})}validate(s){let e=!0,t="";if(Ge(s))return{valid:!1,tips:"empty options"};if(s.profileCustomField){let t=s.profileCustomField.length;var i=null;for(let e=0;e<t;e++){if(i=s.profileCustomField[e],!$e(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(!$e(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 s)if(Object.prototype.hasOwnProperty.call(s,o)){if("profileCustomField"===o)continue;if(Ge(s[o])&&!$e(s[o])&&!Fe(s[o])){t="key:"+o+", invalid value:"+s[o],e=!1;continue}switch(o){case"nick":$e(s[o])||(t="nick must be a string",e=!1),500<Ze(s[o])&&(t=`nick name limited: must less than or equal to 500 bytes, current size: ${Ze(s[o])} bytes`,e=!1);break;case"gender":it(Le,s.gender)||(t="key:gender, invalid value:"+s.gender,e=!1);break;case"birthday":Fe(s.birthday)||(t="birthday must be a number",e=!1);break;case"location":$e(s.location)||(t="location must be a string",e=!1);break;case"selfSignature":$e(s.selfSignature)||(t="selfSignature must be a string",e=!1);break;case"allowType":it(Oe,s.allowType)||(t="key:allowType, invalid value:"+s.allowType,e=!1);break;case"language":Fe(s.language)||(t="language must be a number",e=!1);break;case"avatar":$e(s.avatar)||(t="avatar must be a string",e=!1);break;case"messageSettings":0!==s.messageSettings&&1!==s.messageSettings&&(t="messageSettings must be 0 or 1",e=!1);break;case"adminForbidType":it(Ae,s.adminForbidType)||(t="key:adminForbidType, invalid value:"+s.adminForbidType,e=!1);break;case"level":Fe(s.level)||(t="level must be a number",e=!1);break;case"role":Fe(s.role)||(t="role must be a number",e=!1);break;default:t="unknown key:"+o+" "+s[o],e=!1}}return{valid:e,tips:t}}}class un{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 dn=["groupID","name","avatar","type","introduction","notification","ownerID","selfInfo","createTime","infoSequence","lastInfoTime","lastMessage","nextMessageSeq","memberNum","maxMemberNum","memberList","joinOption","groupCustomField","muteAllMembers","isSupportTopic","inviteOption","_lastRevokedTime"];class _n{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)dn.indexOf(t)<0||("selfInfo"!==t?("memberNum"===t&&(this.memberCount=e[t]),"maxMemberNum"===t&&(this.maxMemberCount=e[t]),"isSupportTopic"!==t?"muteAllMembers"===t&&$e(e[t])?this.muteAllMembers="On"===e[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&&rt(this.groupCustomField,e.groupCustomField),Be(e.memberNum)||(this.memberCount=e.memberNum),Be(e.maxMemberNum)||(this.maxMemberCount=e.maxMemberNum),Be(e.isSupportTopic)||(this.isSupportTopic=Fe(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 hn=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 Ki?{lastTime:e.time||0,lastSequence:e.sequence||0,fromAccount:e.from||"",messageForShow:Dt(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:Dt(e.type,e.payload,t)}};class pn{constructor(e,t,s=!1){this.conversationID=e.conversationID||"",this.unreadCount=e.unreadCount||0,this.type=e.type||"",this.lastMessage=hn(e.lastMessage,t,s),e.lastMsgTime&&(this.lastMessage.lastTime=e.lastMsgTime),this._isInfoCompleted=!1,this.peerReadTime=e.peerReadTime||0,this.groupAtInfoList=[],this.remark=e.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(t.CONV_C2C)?this.conversationID.replace(t.CONV_C2C,""):this.conversationID.startsWith(t.CONV_GROUP)?this.conversationID.replace(t.CONV_GROUP,""):""}_initProfile(s){Object.keys(s).forEach(e=>{switch(e){case"userProfile":this.userProfile=s.userProfile;break;case"groupProfile":this.groupProfile=s.groupProfile}}),Be(this.userProfile)&&this.type===t.CONV_C2C?this.userProfile=new ln({userID:s.conversationID.replace("C2C","")}):Be(this.groupProfile)&&this.type===t.CONV_GROUP&&(this.groupProfile=new _n({groupID:s.conversationID.replace("GROUP","")}))}updateUnreadCount(e){var{nextUnreadCount:e,isFromGetConversations:s,isUnreadC2CMessage:i}=e;Be(e)||(ct(this.subType)?this.unreadCount=0:s&&this.type===t.CONV_GROUP||s&&this.type===t.CONV_TOPIC||i&&this.type===t.CONV_C2C?this.unreadCount=e:this.unreadCount=this.unreadCount+e)}updateLastMessage(e){this.lastMessage=hn(e)}updateGroupAtInfoList(s){if(!this._isNeedMergeGroupAtInfo(s)){let[...e]=s.groupAtType;-1!==e.indexOf(t.CONV_AT_ME)&&-1!==e.indexOf(t.CONV_AT_ALL)&&(e=[t.CONV_AT_ALL_AT_ME]);s={from:s.from,groupID:s.groupID,topicID:s.topicID,messageSequence:s.sequence,atTypeArray:e,__random:s.__random,__sequence:s.__sequence};this.groupAtInfoList.push(s)}}_isNeedMergeGroupAtInfo(s){let{groupID:e,sequence:i}=s;if(!lt({groupID:e}))return!1;let o=!1;return this.groupAtInfoList.forEach(e=>{e.messageSequence===i&&(-1<e.atTypeArray.indexOf(t.CONV_AT_ME)&&-1<s.groupAtType.indexOf(t.CONV_AT_ALL)&&(e.atTypeArray=[t.CONV_AT_ALL_AT_ME]),-1<e.atTypeArray.indexOf(t.CONV_AT_ALL)&&-1<s.groupAtType.indexOf(t.CONV_AT_ME)&&(e.atTypeArray=[t.CONV_AT_ALL_AT_ME],e.__random=s.__random,e.__sequence=s.__sequence),o=!0)}),o}clearGroupAtInfoList(){this.groupAtInfoList.length=0}reduceUnreadCount(){return 1<=this.unreadCount&&(--this.unreadCount,!0)}isLastMessageRevoked({sequence:e,time:s}){return this.type===t.CONV_C2C&&e===this.lastMessage.lastSequence&&s===this.lastMessage.lastTime||this.type===t.CONV_GROUP&&e===this.lastMessage.lastSequence}setLastMessageRevoked(e){this.lastMessage.isRevoked=e}setLastMessageRevoker(e){this.lastMessage.revoker=e}setDraftText(e){this.draftText=e}}let gn={[t.MSG_REMIND_ACPT_AND_NOTE]:0,[t.MSG_REMIND_DISCARD]:1,[t.MSG_REMIND_ACPT_NOT_NOTE]:2};class mn{constructor(e){this._convM=e,this._n="MsgRemindHandler"}onAllRcvMsgOptNotify(t){t=this._handleResult(t);this._convM.emitOEvt(e.ALL_RECEIVE_MESSAGE_OPT_UPDATED,t)}getC2CMsgRemindType(t){let s=this._n+".getC2CMsgRemindType";return this._convM.req({P:ui.GET_C2C_PEER_MUTE_NOTIFICATIONS,data:{toAccount:this._convM.getMyUserID(),userIDList:t}}).then(e=>{Se.l(s+" ok. userIDList:"+t);e=e.data.muteFlagList;this._convM.onC2CMsgRemindTypeFetched(e)}).catch(e=>{Se.e(s+" failed. error:",e)})}set(e){return e.groupID?this._setGroupMsgRemindType(e):Ve(e.userIDList)?this._setC2CMsgRemindType(e):void 0}_setGroupMsgRemindType(t){let s=this._n+"._setGroupMsgRemindType",{groupID:e,messageRemindType:i}=t,o=`groupID:${e} messageRemindType:`+i,n=new Ei("_setGroupMsgRemindType");n.setMessage(o);var r=this._get(Rs);return r?r.modifyGroupMemberInfo({groupID:e,messageRemindType:i,userID:this._convM.getMyUserID()}).then(()=>{n.end(),Se.l(s+" ok. "+o);var e=this.onGroupMsgRemindTypeUpdated(t);return this._convM.onTotalUnreadCountUpdate(),si(e)}).catch(e=>(n.setError(e).end(),Se.e(s+" failed. error:",e),ci(e))):ci({code:ni.NO_MODULE})}onGroupMsgRemindTypeUpdated(t){var{groupID:o,messageRemindType:n}=t;Se.l(this._n+`.onGroupMsgRemindTypeUpdated groupID:${o} messageRemindType:`+n);let s=this._get(Rs).getLocalGroupProfile(o);if(s&&(s.selfInfo.messageRemindType=n),ut(o)){let t=o,s=Et(t),i=this._get(As).getLocalTopic(s,t);return i&&i.updateSelfInfo({messageRemindType:n})&&this._convM.emitOEvt(e.TOPIC_UPDATED,{groupID:s,topic:i}),{topic:i}}return this._convM.patchMsgRemindType({ID:o,isC2CConversation:!1,messageRemindType:n})&&this._emitConvUpdate(),{group:s}}_setC2CMsgRemindType(e){let n=this._n+"._setC2CMsgRemindType",{userIDList:t,messageRemindType:r}=e,a=t.slice(0,30),s=gn[r]||0,l=`userIDList:${a} messageRemindType:`+r,d=new Ei("_setC2CMsgRemindType");return d.setMessage(l),this._convM.req({P:ui.SET_C2C_PEER_MUTE_NOTIFICATIONS,data:{userIDList:a,muteFlag:s}}).then(e=>{d.end();let t=e.data["errorList"],s=[],i=[];Ve(t)&&t.forEach(e=>{s.push(e.userID),i.push({userID:e.userID,code:e.errorCode})});e=a.filter(e=>-1===s.indexOf(e));Se.l(n+` ok. ${l} successUserIDList:${e} failureUserIDList:`+JSON.stringify(i));let o=0;return e.forEach(e=>{this._convM.patchMsgRemindType({ID:e,isC2CConversation:!0,messageRemindType:r})&&(o+=1)}),1<=o&&this._emitConvUpdate(),a.length=s.length=0,this._convM.onTotalUnreadCountUpdate(),ai({successUserIDList:e.map(e=>({userID:e})),failureUserIDList:i})}).catch(e=>(d.setError(e).end(),Se.e(n+" failed. error:",e),ci(e)))}_get(e){return this._convM.get(e)}_emitConvUpdate(){this._convM.emitConvUpdate(!0,!1)}setAllRcvMsgOpt(e){let s=this._n+".setAllRcvMsgOpt",{messageRemindType:i=t.MSG_REMIND_ACPT_NOT_NOTE,isRepeated:o=!0}=e,{startTime:n=0,endTime:r=0}=this._calcStartAndEndTime(e),a=JSON.stringify(e),l=new Ei("setAllRcvMsgOpt");return l.setMessage(a),Se.l(s+" options:"+a),this._convM.req({P:ui.SET_ALL_RECEIVE_MSG_OPT,data:{messageRemindType:gn[i],startTime:n,endTime:r,isRepeated:o?1:0}}).then(e=>(l.end(),Se.l(s+" ok."),si(e))).catch(e=>(l.setError(e).end(),Se.e(s+" failed. error:",e),ci(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 t=this._n+".getAllRcvMsgOpt",s=new Ei("getAllRcvMsgOpt");return this._convM.req({P:ui.GET_ALL_RECEIVE_MSG_OPT,data:{toAccount:this._convM.getMyUserID()}}).then(e=>{e=e.data,s.setMessage(JSON.stringify(e)).end(),Se.l(t+" ok. data:"+JSON.stringify(e)),e=this._handleResult(e);return si(e)}).catch(e=>(s.setError(e).end(),Se.e(t+" failed. error:",e),ci(e)))}_handleResult(e){var{messageRemindType:e,startTime:s,endTime:i,isRepeated:o}=e;let n=t.MSG_REMIND_ACPT_AND_NOTE;return 1===e&&(n=t.MSG_REMIND_DISCARD),{messageRemindType:n=2===e?t.MSG_REMIND_ACPT_NOT_NOTE:n,startTime:s,endTime:i,isRepeated:1===o}}reset(){Se.l(this._n+".reset")}}class fn{constructor(e){this._convM=e,this._n="ConvGroupHandler",this._convGroupMap=new Map,this._startIndex=0,this._pagingStatus=bt}setConvCustomData(e){let s=this._n+".setConvCustomData",{conversationIDList:i,customData:o}=e,n=(Se.l(s+" options:",e),new Ei("setConvCustomData")),r=(n.setMessage(JSON.stringify(e)),{fromAccount:this._getMyUserID(),itemList:[]}),a=[],l=[];return i.forEach(e=>{var s;return this._hasLocalConv(e)?dt(e)||_t(e)?(s={operationType:2,contactItem:void 0,customMark:o},dt(e)?s.contactItem={type:1,toAccount:e.replace(t.CONV_C2C,"")}:_t(e)&&(s.contactItem={type:2,groupID:e.replace(t.CONV_GROUP,"")}),void r.itemList.push(s)):(this._onConvIDInvalid(l,e),!0):(this._onConvNotFound(l,e),!0)}),l.length===i.length?ai({successConversationIDList:a,failureConversationIDList:l}):this._convM.req({P:ui.SET_CONV_CUSTOM_DATA,data:r}).then(e=>{n.end(),Se.l(s+" ok");e=e.data.resultItem;if(Ve(e)){let t,s,i=!1;e.forEach(e=>{t=this._concatConvID(e.contactItem),0===e.resultCode?(a.push(t),(s=this._getLocalConv(t))&&s.customData!==o&&(s.customData=o,i=!0)):l.push({conversationID:t,code:e.resultCode,message:e.resultInfo})}),!0===i&&this._emitConvUpdate()}return si({successConversationIDList:a,failureConversationIDList:l})}).catch(e=>(n.setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}markConv(e){if(!this._convM.canIUse(M.CONV_MARK))return this._convM.noUse("markConv");let s=this._n+".markConv",{conversationIDList:i,markType:o,enableMark:n}=e,r=(Se.l(s+" options:",e),new Ei("markConv")),a=(r.setMessage(JSON.stringify(e)),void 0),l=void 0;e=this._getFlagBit(o);!0===n?l=[e]:a=[e];let d={fromAccount:this._getMyUserID(),itemList:[]},u=[],c=[];return i.forEach(e=>{var s;return this._hasLocalConv(e)?dt(e)||_t(e)?(s={operationType:1,contactItem:void 0,clearMark:a,setMark:l},dt(e)?s.contactItem={type:1,toAccount:e.replace(t.CONV_C2C,"")}:_t(e)&&(s.contactItem={type:2,groupID:e.replace(t.CONV_GROUP,"")}),void d.itemList.push(s)):(this._onConvIDInvalid(c,e),!0):(this._onConvNotFound(c,e),!0)}),c.length===i.length?ai({successConversationIDList:u,failureConversationIDList:c}):this._convM.req({P:ui.MARK_CONV,data:d}).then(e=>{r.end(),Se.l(s+" ok");e=e.data.resultItem;if(Ve(e)){let t,s,i=!1;e.forEach(e=>{if(t=this._concatConvID(e.contactItem),0===e.resultCode){if(u.push(t),s=this._getLocalConv(t)){let e=s.markList.indexOf(o);!0===n?-1===e&&(s.markList.push(o),i=!0):-1!==e&&(s.markList.splice(e,1),i=!0)}}else c.push({conversationID:t,code:e.resultCode,message:e.resultInfo})}),!0===i&&this._emitConvUpdate()}return si({successConversationIDList:u,failureConversationIDList:c})}).catch(e=>(r.setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}getLocalConvGroupList(){return Se.l(this._n+".getLocalConvGroupList pagingStatus:"+this._pagingStatus),this._pagingStatus===qt?this.getRemoteConvGroupList().then(()=>si([...this._convGroupMap.values()])):ai([...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})}),Se.l(s+` type:${t} list:`,e),this._convM.req({P:ui.SEARCH_CONV_GRP_MARK,data:{fromAccount:this._getMyUserID(),contactItem:i}}).then(e=>{var{contactItem:e,groupItem:t}=e.data;Se.l(s+" ok. contactItem:",e,"groupItem:",t),this._fillConvGroupMap(t),this._handleContactItem(e),this._emitConvUpdate()}).catch(e=>{Se.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 n,r;e.forEach(e=>{let t=[],{standardMark:s,customData:i,convGroupIDList:o}=e;Ve(o)&&o.forEach(e=>{this._convGroupMap.has(e)&&t.push(this._convGroupMap.get(e))}),r=this._concatConvID(e),(n=this._getLocalConv(r))&&(n.markList=Rt(s),n.customData=i||"",n.conversationGroupList=[...t])})}}getRemoteConvGroupList(){let o=this._n+".getRemoteConvGroupList";return this._pagingStatus=Ft,this._convM.req({P:ui.GET_CONV_GRP_LIST,data:{fromAccount:this._getMyUserID(),startIndex:this._startIndex}}).then(e=>{var{completeFlag:e,contactItem:t,nextStartIndex:s=0,groupItem:i}=e.data;if(this._startIndex=s,Se.l(o+` completeFlag:${e} nextStartIndex:${s}, groupItem:`,i,"contactItem:",t),this._fillConvGroupMap(i),this._handleContactItem(t),0===e)return this.getRemoteConvGroupList();1===e&&(this._pagingStatus=$t,this._emitConvUpdate(),this._emitConvGroupListUpdate())}).catch(e=>{this._pagingStatus=qt,Se.w(o+" failed. error:",e)})}createConvGroup(e){if(!this._convM.canIUse(M.CONV_GROUP))return this._convM.noUse("createConvGroup");let s=this._n+".createConvGroup",i=(Se.l(s+" options:",e),new Ei("createConvGroup")),{groupName:n,conversationIDList:o}=(i.setMessage(JSON.stringify(e)),e),r={fromAccount:this._getMyUserID(),itemList:[{groupName:n,contactItem:[]}]},a=[],l=[];return o.forEach(e=>this._hasLocalConv(e)?dt(e)||_t(e)?void(dt(e)?r.itemList[0].contactItem.push({type:1,toAccount:e.replace(t.CONV_C2C,"")}):_t(e)&&r.itemList[0].contactItem.push({type:2,groupID:e.replace(t.CONV_GROUP,"")})):(this._onConvIDInvalid(l,e),!0):(this._onConvNotFound(l,e),!0)),l.length===o.length?ai({successConversationIDList:a,failureConversationIDList:l}):this._convM.req({P:ui.CREATE_CONV_GRP,data:r}).then(e=>{i.end(),Se.l(s+" ok");var e=e.data["groupResultItem"],{groupItem:e,resultItem:o}=e[0];if(xe(e)&&(this._convGroupMap.set(e.convGroupID,e.groupName),this._emitConvGroupListUpdate()),Ve(o)){let t,s,i=!1;o.forEach(e=>{t=this._concatConvID(e.contactItem),0===e.resultCode?(a.push(t),(s=this._getLocalConv(t))&&-1===s.conversationGroupList.indexOf(n)&&(s.conversationGroupList.push(n),i=!0)):l.push({conversationID:t,code:e.resultCode,message:e.resultInfo})}),!0===i&&(this._emitConvUpdate(),this._emitConvGroupListUpdate())}return si({successConversationIDList:a,failureConversationIDList:l})}).catch(e=>(i.setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}deleteConvGroup(t){if(!this._convM.canIUse(M.CONV_GROUP))return this._convM.noUse("deleteConvGroup");let s=this._n+".deleteConvGroup",i=(Se.l(s+" groupName:"+t),new Ei("deleteConvGroup"));return i.setMessage(t),this._convM.req({P:ui.DEL_CONV_GRP,data:{fromAccount:this._getMyUserID(),groupName:[t]}}).then(e=>{i.end(),Se.l(s+" ok");e=e.data.groupItem;if(Ve(e)){let t=!1;e.forEach(e=>{this._convGroupMap.has(e.convGroupID)&&(this._convGroupMap.delete(e.convGroupID),t=!0)}),!0===t&&this._emitConvGroupListUpdate()}this._eraseFromConversationGroupList([t])}).catch(e=>(i.setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}renameConvGroup(e){if(!this._convM.canIUse(M.CONV_GROUP))return this._convM.noUse("renameConvGroup");let o=this._n+".renameConvGroup",n=(Se.l(o+" options:",e),new Ei("renameConvGroup")),{oldName:r,newName:a}=(n.setMessage(JSON.stringify(e)),e);return this._convM.req({P:ui.RENAME_CONV_GRP,data:{fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:1,oldName:r,newName:a}}}).then(e=>{n.end(),Se.l(o+" ok");e=e.data.updateGroupResult,e=e.convGroupID,this._convGroupMap.set(e,a),this._emitConvGroupListUpdate(),e=this._convM.getLocalConvList();let t,s,i=!1;e.forEach(e=>{t=e.conversationGroupList,-1!==(s=t.indexOf(r))&&(t.splice(s,1,a),i=!0)}),!0===i&&this._emitConvUpdate()}).catch(e=>(n.setError(e).end(),Se.e(o+" failed. error:",e),ci(e)))}addConvsToGroup(e){if(!this._convM.canIUse(M.CONV_GROUP))return this._convM.noUse("addConvsToGroup");let s=this._n+".addConvsToGroup",i=(Se.l(s+" options:",e),new Ei("addConvsToGroup")),{conversationIDList:o,groupName:n}=(i.setMessage(JSON.stringify(e)),e),r={fromAccount:this._getMyUserID(),updateType:1,updateGroup:{updateGroupType:2,groupName:n,updateItem:[]}},a=[],l=[];return o.forEach(e=>this._hasLocalConv(e)?dt(e)||_t(e)?void(dt(e)?r.updateGroup.updateItem.push({operationType:1,contactItem:{type:1,toAccount:e.replace(t.CONV_C2C,"")}}):_t(e)&&r.updateGroup.updateItem.push({operationType:1,contactItem:{type:2,groupID:e.replace(t.CONV_GROUP,"")}})):(this._onConvIDInvalid(l,e),!0):(this._onConvNotFound(l,e),!0)),l.length===o.length?ai({successConversationIDList:a,failureConversationIDList:l}):this._convM.req({P:ui.ADD_CONV_TO_GRP,data:r}).then(e=>{i.end(),Se.l(s+" ok");e=e.data.updateGroupResult.contactResultItem;if(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 si({successConversationIDList:a,failureConversationIDList:l})}).catch(e=>(i.setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}deleteConvsFromGroup(e){var s="deleteConvsFromGroup";if(!this._convM.canIUse(M.CONV_GROUP))return this._convM.noUse(s);let i=this._n+"."+s,o=(Se.l(i+" options:",e),new Ei(s)),{conversationIDList:n,groupName:r}=(o.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)?dt(e)||_t(e)?void(dt(e)?a.updateGroup.updateItem.push({operationType:2,contactItem:{type:1,toAccount:e.replace(t.CONV_C2C,"")}}):_t(e)&&a.updateGroup.updateItem.push({operationType:2,contactItem:{type:2,groupID:e.replace(t.CONV_GROUP,"")}})):(this._onConvIDInvalid(d,e),!0):(this._onConvNotFound(d,e),!0)),d.length===n.length?ai({successConversationIDList:l,failureConversationIDList:d}):this._convM.req({P:ui.DEL_CONV_FROM_GRP,data:a}).then(e=>{o.end(),Se.l(i+" ok");e=e.data.updateGroupResult.contactResultItem;if(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 si({successConversationIDList:l,failureConversationIDList:d})}).catch(e=>(o.setError(e).end(),Se.e(i+" failed. error:",e),ci(e)))}onConvMarkUpdated(e){if(!Ge(e)){let o,n,r=(Se.l(this._n+".onConvMarkUpdated markItemList:",e),!1);e.forEach(e=>{var{recentContactItem:e,optType:t,standardMark:s,customMark:i}=e;if(o=this._concatConvID(e),n=this._getLocalConv(o))if(1===t)r=this._diffStandardMark(n,s);else if(2===t)r=this._diffCustomMark(n,i);else if(3===t){let e=this._diffStandardMark(n,s),t=this._diffCustomMark(n,i);r=e||t}}),!0===r&&this._emitConvUpdate()}}_diffStandardMark(e,t){t=Rt(t);let s=!1;return!0!==function(s,i){if(s!==i){if(!s||!i)return!1;if(s.length!==i.length)return!1;for(let e=0,t=s.length;e<t;e++)if(s[e]!==i[e])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){Se.l(this._n+".onConvGroupCreated resultList:",e);let o=!1,s=!1;Ve(e)&&(e.forEach(e=>{let{groupID:t,groupName:i}=e.msgGroupItem;this._convGroupMap.get(t)!==i&&(this._convGroupMap.set(t,i),s=!0);e=e.msgRecentContactItem;if(Ve(e)){let t,s;e.forEach(e=>{t=this._concatConvID(e),(s=this._getLocalConv(t))&&-1===s.conversationGroupList.indexOf(i)&&(s.conversationGroupList.push(i),o=!0)})}}),!0===o&&this._emitConvUpdate(),!0===s)&&this._emitConvGroupListUpdate()}onConvGroupDeleted(e){Se.l(this._n+".onConvGroupDeleted groupItemList:",e);let i=[];if(Ve(e)){let s=!1;e.forEach(e=>{var{groupID:e,groupName:t}=e;this._convGroupMap.has(e)&&(this._convGroupMap.delete(e),s=!0,i.push(t))}),!0===s&&this._emitConvGroupListUpdate()}this._eraseFromConversationGroupList(i)}_eraseFromConversationGroupList(t){Ge(t)||(this._convM.getLocalConvList().forEach(e=>{e.conversationGroupList=e.conversationGroupList.filter(e=>!t.includes(e))}),this._emitConvUpdate())}onConvGroupNameUpdated(e){Se.l(this._n+".onConvGroupNameUpdated options:",e);let{groupID:o,groupName:n,oldGroupName:r}=e;if(this._convGroupMap.get(o)!==n){this._convGroupMap.set(o,n),this._emitConvGroupListUpdate();e=this._convM.getLocalConvList();let t,s,i=!1;e.forEach(e=>{t=e.conversationGroupList,-1!==(s=t.indexOf(r))&&(t.splice(s,1,n),i=!0)}),!0===i&&this._emitConvUpdate()}}onConvInGroupUpdated(e){Se.l(this._n+".onConvInGroupUpdated options:",e);let{oldGroupName:r,recentContactUpdateGroupItem:t}=e;if(Ve(t)){let s,i,o,n=!1;t.forEach(e=>{var{contactOptType:e,recentContactItem:t}=e;s=this._concatConvID(t),(i=this._getLocalConv(s))&&(o=i.conversationGroupList.indexOf(r),1===e?-1===o&&(i.conversationGroupList.push(r),n=!0):2===e&&-1!==o&&(i.conversationGroupList.splice(o,1),n=!0))}),!0===n&&(this._emitConvUpdate(),this._emitConvInGroupUpdate(r))}}onConvAddedToOrDeletedFromGroup(e){Se.l(this._n+".onConvAddedToOrDeletedFromGroup options:",e);let{msgRecentContactItem:t,msgRecentContactUpdateContactItem:o}=e,s=this._concatConvID(t),n=this._getLocalConv(s);if(n&&Ve(o)){let s,i=!1;o.forEach(e=>{var{groupOptType:e,recentContactGroupItem:t}=e,t=t["groupName"];s=n.conversationGroupList.indexOf(t),1===e?-1===s&&(n.conversationGroupList.push(t),i=!0):2===e&&-1!==s&&(n.conversationGroupList.splice(s,1),i=!0),!0===i&&this._emitConvInGroupUpdate(t)}),!0===i&&this._emitConvUpdate()}}onConvGroupListSynced(e){Ve(e)&&0!==e.length&&(Se.l(this._n+".onConvGroupListSynced groupItem:",e),this._fillConvGroupMap(e))}getConvGroupListByID(e){if(!Ge(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:ni.CONV_NOT_FOUND,message:this._convM.getErrMsg(ni.CONV_NOT_FOUND)})}_onConvIDInvalid(e,t){e.push({conversationID:t,code:ni.INVALID_CONV_ID,message:this._convM.getErrMsg(ni.INVALID_CONV_ID)})}_getFlagBit(e){var t=e.toString(2),s=t.length;for(let e=s-1;0<=e;e--)if("1"===t[e])return s-e-1}_concatConvID(e){var{type:e,to:s,groupID:i,userID:o}=e;let n;return 1===e?Be(o)?Be(s)||(n=""+t.CONV_C2C+s):n=""+t.CONV_C2C+o:2===e&&(n=""+t.CONV_GROUP+i),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(e.CONVERSATION_GROUP_LIST_UPDATED,[...this._convGroupMap.values()])}_emitConvInGroupUpdate(t){var s={groupName:t,conversationList:[]},i=this._convM.getLocalConvList();s.conversationList=i.filter(e=>e.conversationGroupList.includes(t)),this._convM.emitOEvt(e.CONVERSATION_IN_GROUP_UPDATED,s)}reset(){Se.l(this._n+".reset"),this._convGroupMap.clear(),this._startIndex=0,this._pagingStatus=bt}}class Mn extends li{constructor(e){super(e),this._n="ConvModule",tn.mixin(this),this._msgListHandler=new en(this),this._msgRemindHandler=new mn(this),this._convGroupHandler=new fn(this),this._sll=new un(100),this._pagingStatus=bt,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(Qi.A2KEY_AND_TINYID_UPDATED,this._init,this),e.on(Qi.PROFILE_UPDATED,this._onProfileUpdated,this),e.on(Qi.CLOUD_CONFIG,this._onCloudConfig,this)}_init(){Se.l(this._n+"._init");var t=this.get(Ps).getItem("conversationMap"),s=this.isIntl(),i=this.isUsingChatCore();if(t){var o=t.length;for(let e=0;e<o;e++){var n=t[e];if(n){if(this._isNonExistentAccount(n.conversationID))continue;if(n.groupProfile&&ct(n.groupProfile.type))continue}this._convMap.set(n.conversationID,new pn(t[e],s,i))}this.emitConvUpdate(!0,!1)}this.ready(()=>{0<this._tmpGroupList.length&&(this.updateConvGroupProfile(this._tmpGroupList),this._tmpGroupList.length=0)}),this.syncConvList()}_isNonExistentAccount(e){let s;return"@TLS#ERROR"===(s=e.startsWith(t.CONV_C2C)?e.replace(t.CONV_C2C,""):s)||"@TLS#NOT_FOUND"===s}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(Qi.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(Qi.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 o=!1;e.forEach(s=>{var i=""+t.CONV_GROUP+s.groupID;if(this._convMap.has(i)){o=!0;let e=this._convMap.get(i);e.groupProfile=JSON.parse(JSON.stringify(s)),e.lastMessage.lastSequence<s.nextMessageSeq&&(e.lastMessage.lastSequence=s.nextMessageSeq-1),e.subType||(e.subType=s.type)}}),o&&this.emitConvUpdate(!0,!1)}}onMessageRevoked(e,n){if(0!==e.length){let s=null,i=!1,o=[];e.forEach(e=>{(s=this._convMap.get(e.conversationID))&&(n&&s.reduceUnreadCount()&&(i=s.type!==t.CONV_TOPIC),s.type===t.CONV_TOPIC?o.push(e):s.isLastMessageRevoked({sequence:e.sequence,time:e.time})&&(s.setLastMessageRevoked(!0),s.setLastMessageRevoker(e.revoker),i=!0))}),this.get(As).onMessageRevoked(o),i&&(this.emitConvUpdate(!0,!1),this._updateGroupLastMessage(e[0]))}}_updateGroupLastMessage(e){var s=e["conversationID"];if(s.startsWith(t.CONV_GROUP)){let e=this._convMap.get(s),t=this.get(Rs);t&&t.updateGroupLastMessage([e])}}updateRevokerInfo(s){var i=new Set;for(let t=0;t<s.length;t++){let e=s[t]["revoker"];i.add(e)}let t=[...i],o=this.get(Es);return new Promise(e=>{o.getUserProfile({userIDList:t}).then(i=>{i=i.data;if(!Ve(i)||0===i.length)return e(s);let o={};for(let{userID:e,nick:t,avatar:s}of i)o[e]={nick:t,avatar:s};s.forEach(e=>{var t=e["revoker"];o[t]&&(e.revokerInfo.nick=o[t].nick||"",e.revokerInfo.avatar=o[t].avatar||"")}),e(s)}).catch(()=>{e(s)})})}isLastMessageRevoked(e){let s=!1;var{conversationID:i,sequence:o,time:n}=e,r=this._convMap.get(i);return r&&(s=r.type===t.CONV_TOPIC?this.get(As).isLastMessageRevoked({topicID:i.replace(t.CONV_GROUP,""),sequence:o}):r.isLastMessageRevoked({sequence:o,time:n})),Se.l(this._n+".isLastMessageRevoked options:",e,"ret:"+s),s}onMessageDeleted(o){if(0!==o.length){let s=null;o.forEach(e=>{(s=this._msgListHandler.getLocalMsg(e.conversationID,e.ID))&&(s.isDeleted=!0),e!==s&&(e.isDeleted=!0)});var o=o[0].conversationID,n=this._msgListHandler.getLocalMsgList(o);let i={};for(let e=n.length-1;0<=e;e--)if(!n[e].isDeleted){i=n[e];break}var r=this._convMap.get(o);if(r){let e=!1;r.lastMessage.lastSequence===i.sequence&&r.lastMessage.lastTime===i.time||(Ge(i)&&(i=void 0),r.updateLastMessage(i),r.type!==t.CONV_TOPIC&&(e=!0),Se.l(this._n+`.onMessageDeleted. update convID:${o} with lastMessage:`,r.lastMessage)),o.startsWith(t.CONV_C2C)&&this.updateUnreadCount(o),e&&this.emitConvUpdate(!0,!1)}}}onMessageModified(s){var i=this._n+".onMessageModified",{conversationType:o,from:n,to:r,time:a,sequence:l,elements:d,cloudCustomData:u,messageVersion:c}=s;let _=""+o+r;r===this.getMyUserID()&&o===t.CONV_C2C&&(_=""+o+n);var{isUpdated:o,message:h}=this._msgListHandler.onMsgModified(_,s),p=(!0===o&&this.emitOEvt(e.MESSAGE_MODIFIED,[h]),this._isTopicConv(_));if(null===h?Se.l(i+" message is null! options:",s):Se.l(i+` isUpdated:${o} isTopicMessage:${p} from:${n} to:${r} sequence:${h.sequence} time:`+h.time),p)this.get(As).onMessageModified(s);else{let t=this._convMap.get(_);if(t){let e=t.lastMessage;e&&e.lastTime===a&&e.lastSequence===l&&e.version!==c&&(Se.l(i+` convID:${_} lastMessage updated`),e.type=d[0].type,e.payload=d[0].content,e.messageForShow=Dt(e.type,e.payload,this.isIntl()),e.cloudCustomData=u,e.version=c,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)}),Se.l(this._n+".onNewGroupAtTips isReady:"+this._isReady,this._tmpGroupAtTipsList),this._isReady&&this._handleGroupAtTipsList()}_handleGroupAtTipsList(){if(0!==this._tmpGroupAtTipsList.length){let r=!1;this._tmpGroupAtTipsList.forEach(s=>{let{groupID:i,from:e,topicID:o,sync:n=!1}=s;if(e!==this.getMyUserID())if(Be(o)){let e=this._convMap.get(""+t.CONV_GROUP+i);e&&(e.updateGroupAtInfoList(s),r=!0)}else{let e=this._convMap.get(""+t.CONV_GROUP+o);e&&(e.updateGroupAtInfoList(s),this.get(As).onAtInfoUpdated({topicID:o,groupAtInfoList:e.groupAtInfoList})),Ge(e)&&n&&(this.updateTopicConversation([{conversationID:""+t.CONV_GROUP+o,type:t.CONV_TOPIC}]),this._convMap.get(""+t.CONV_GROUP+o).updateGroupAtInfoList(s))}}),r&&this.emitConvUpdate(!0,!1),this._tmpGroupAtTipsList.length=0}}_checkNewConv(e){let s=[],i=[];e.forEach(e=>{this._convMap.has(e.conversationID)||(e.type===t.CONV_C2C?s.push(e.conversationID.replace(t.CONV_C2C,"")):e.type===t.CONV_GROUP&&i.push(e.conversationID.replace(t.CONV_GROUP,"")))}),0<s.length&&(this._onNewC2CConv(s),s=null),0<i.length&&(this._onNewGroupConv(i),i=null)}_onNewC2CConv(e){var t=this.get(Ds);return Promise.all([t.getRemotePeerReadTime(e),this._msgRemindHandler.getC2CMsgRemindType(e),this._convGroupHandler.searchConvGroupAndMark(e,1)])}_onNewGroupConv(e){var t=this.get(Rs);return t?Promise.all([t.getMsgRemindType(e),this._convGroupHandler.searchConvGroupAndMark(e,2)]):Promise.resolve()}_setStorageConvList(e=!1){var s=this.getLocalConvList().filter(e=>e.type===t.CONV_C2C||e.type===t.CONV_GROUP&&e.lastMessage.type!==t.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(Ps).setItem("conversationMap",s,e)}emitConvUpdate(t=!0,s=!0){var i=this.getLocalConvList();if(s){let e=this.get(Rs);e&&e.updateGroupLastMessage(i)}t&&(this.get(Ns).isPartialUpdatedConvs()?(this._diffConvMap(this._convMapForDiff,this._convMap),0<this._partialUpdatedConvMap.size&&(this.emitOEvt(e.CONVERSATION_LIST_UPDATED),this.onTotalUnreadCountUpdate(),this._convMapForDiff.clear(),this._convMapForDiff=Xe(this._convMap,!0)),0===this._convMapForDiff.size&&(this._convMapForDiff=Xe(this._convMap,!0))):(this.emitOEvt(e.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=[...Xe(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 i=new Ei("syncConvList");return this._pagingStatus===bt&&this._convMap.clear(),this._pagingGetConvList(e).then(e=>{var t=function(e){if(Ve(e)&&0!==e.length){let t=0;return e.forEach(e=>{t+=e}),(t/e.length).toFixed(0)}}(this._pagingGetCostList),s=function(e){if(Ve(e)&&0!==e.length){let t=0;return e.forEach(e=>{t+=e}),t.toFixed(0)}}(this._pagingGetCostList),s=(this._pagingGetCostList.length=0,this._pagingStatus=$t,this._diffAndDeleteConv(),this.emitConvUpdate(!0,!1),this._setStorageConvList(),this._handleC2CPeerReadTime(),this.emitIEvt(Qi.CONV_SYNC_COMPLETED),`count:${this._convMap.size} sum:${s} avg:`+t);return Se.l(this._n+".syncConvList. "+s),i.setMessage(s).end(),e}).catch(e=>(this._pagingStatus=qt,i.setMessage(this._pagingTs).setError(e).end(),ci(e)))}_diffAndDeleteConv(){if(this.isSyncCompleted()){let s=[];this._convMap.forEach((e,t)=>{!this._pagingConvIDMap.has(t)&&this._convIDFromUnreadDBMap.has(t)&&(this._convMap.delete(t),s.push(t))}),Se.l(this._n+"._diffAndDeleteConv list:"+s),s=null}}_pagingGetConvList(e=!0){let a=this._n+"._pagingGetConvList",l=(Se.l(a+` incrementalPullFlag:${e} ts:${this._pagingTs} startIdx:${this._pagingStartIdx} pinnedTs:${this._pagingPinnedTs} pinnedStartIdx:`+this._pagingPinnedStartIdx),Date.now());return this._pagingStatus=Ft,this.req({P:ui.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:t=[],timeStamp:s,startIndex:i,pinnedTimeStamp:o,pinnedStartIndex:n,groupItem:r}=e.data;if(this._pagingGetCostList.push(Ot(l,!1)),Se.l(a+` ok. completeFlag:${e} count:${t.length} cost:`+Ot(l)),this._convGroupHandler.onConvGroupListSynced(r),0<t.length){let e=this._getConvOptions(t);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 ai();this.triggerReady()}return this._pagingTs=s,this._pagingStartIdx=i,this._pagingPinnedTs=o,this._pagingPinnedStartIdx=n,1!==e?this._pagingGetConvList():(this._handleGroupAtTipsList(),this._convGroupHandler.getRemoteConvGroupList(),ai())}).catch(e=>{throw!this.isLoggedIn()||this._isReady||(Se.w(a+" 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),Se.l(this._n+"._updateLocalConvList cost:"+Ot(s))}_getTmpConvListMapping(e){let{conversationOptionsList:d,isFromGetConversations:u,isInstantMessage:c,isUnreadC2CMessage:_=!1,updateUnreadCount:h}=e,s=[],o=[],i=this.get(Rs),p=this.get(Ls),g=this.isIntl(),m=this.isUsingChatCore();for(let l=0,e=d.length;l<e;l++){let n=new pn(d[l],g,m),{conversationID:r,type:a}=n;if(!this._isNonExistentAccount(r)){if(this._convMap.has(r)){let e=this._convMap.get(r);if(u&&a!==t.CONV_TOPIC){this._convMap.set(r,n),a===t.CONV_C2C?n.unreadCount=e.unreadCount:a===t.CONV_GROUP&&(n.groupProfile=JSON.parse(JSON.stringify(e.groupProfile)));continue}let s=["unreadCount","allowType","adminForbidType","payload","groupProfile"],i=(!1===c&&s.push("lastMessage"),"boolean"==typeof c&&s.push("isPinned"),d[l].lastMessage),o=!Be(i);o||d[l].type===t.CONV_TOPIC||this._onLastMsgNotExist(d[l]),Be(c)&&o&&null===e.lastMessage.payload&&(e.lastMessage.payload=i.payload),Ge(e.lastMessage.revoker)||(e.lastMessage.revoker=null),Je(e,n,s,[null,void 0,"",0,NaN]),!0===h&&e.updateUnreadCount({nextUnreadCount:n.unreadCount,isFromGetConversations:u,isUnreadC2CMessage:_}),c&&o&&(i.payload&&(e.lastMessage.payload=i.payload),e.type===t.CONV_GROUP)&&(e.lastMessage.nameCard=i.nameCard,e.lastMessage.nick=i.nick),o&&e.lastMessage.cloudCustomData!==i.cloudCustomData&&(e.lastMessage.cloudCustomData=i.cloudCustomData||"")}else{if(a===t.CONV_GROUP&&i){let e=n.groupProfile["groupID"],t=i.getLocalGroupProfile(e);t&&(n.groupProfile=t,!0===h)&&n.updateUnreadCount({nextUnreadCount:0})}else if(a===t.CONV_C2C){let e=r.replace(t.CONV_C2C,"");p&&p.isMyFriend(e)&&(n.remark=p.getFriendRemark(e))}s.push(n),this._convMap.set(r,n)}this._convMap.get(r).type===t.CONV_TOPIC&&o.push(this._convMap.get(r))}}let n=this.get(As);for(let i=0,e=o.length;i<e;i++){let{conversationID:e,groupAtInfoList:s}=o[i];Ge(s)||n.onAtInfoUpdated({topicID:e.replace(t.CONV_GROUP,""),groupAtInfoList:s})}return{newConvList:s}}_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?Ge(e[1].lastMessage.lastTime)?s:t:Ge(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(n){if(0!==n.length){let e=[],i=[],s=this.get(Es),o=this.get(Rs);n.forEach(s=>{if(s.type===t.CONV_C2C)e.push(s.toAccount);else if(s.type===t.CONV_GROUP){let e=s.toAccount;i.push(e)}}),Se.l(`${this._n}._updateUserOrGroupProfile userIDList:${e} groupIDList:`+i),0<e.length&&s.getUserProfile({userIDList:e}).then(({data:e})=>{Ve(e)?e.forEach(e=>{this._doUpdateUserProfile(""+t.CONV_C2C+e.userID,e)}):this._doUpdateUserProfile(""+t.CONV_C2C+e.userID,e)}),0<i.length&&o.getGroupProfileAdvance({groupIDList:i,responseFilter:{groupBaseInfoFilter:["Type","Name","FaceUrl"]}}).then(({data:{successGroupList:e}})=>{let o=!1;e.forEach(s=>{var i=""+t.CONV_GROUP+s.groupID;if(this._convMap.has(i)){let e=this._convMap.get(i);Je(e.groupProfile,s,[],[null,void 0,"",0,NaN]),!e.subType&&s.type&&(e.subType=s.type),o=!0}}),o&&this.emitConvUpdate()})}}_doUpdateUserProfile(e,t){this.hasLocalConversation(e)&&(this.getLocalConversation(e).userProfile=t,this.emitConvUpdate())}_getConvOptions(e){let i=[],s=e.filter(({type:e,userID:t})=>1===e&&!this._isNonExistentAccount(t)||2===e),o=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},i.push(s),{conversationID:""+t.CONV_C2C+e.userID,type:t.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,e.lastMsg.elements[0].type):null,cloudCustomData:e.lastMsg.cloudCustomData||"",isRevoked:8===e.lastMessageFlag,onlineOnlyFlag:!1,nick:"",nameCard:"",version:0,isPeerRead:e.lastC2CMsgFromAccount===o&&e.time<=e.c2cPeerReadTime,revoker:e.lastMsg.revokerInfo?e.lastMsg.revokerInfo.revoker:null},unreadCount:0,userProfile:new ln(s),peerReadTime:e.c2cPeerReadTime,isPinned:1===e.isPinned,customData:e.customMark||"",markList:Rt(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId),remark:e.friendRemark||"",messageRemindType:this._transMsgRemindType(e.messageRemindType)}):{conversationID:""+t.CONV_GROUP+e.groupID,type:t.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 _n({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:Rt(e.standardMark),conversationGroupList:this._convGroupHandler.getConvGroupListByID(e.contactGroupId),messageRemindType:this._transMsgRemindType(e.messageRemindType)}});return 0<i.length&&this.get(Es).onConvProfileUpdated(i),n}_transMsgRemindType(e){let s="";return 0===e?s=t.MSG_REMIND_ACPT_AND_NOTE:1===e?s=t.MSG_REMIND_DISCARD:2===e?s=t.MSG_REMIND_ACPT_NOT_NOTE:3===e&&(s=t.NOT_RECEIVE_OFFLINE_PUSH_EXCEPT_AT),s}_computeGroupUnreadCount(e){var{unreadCount:e=0,noUnreadCount:t=0}=e,e=e-t;return 0<e?e:0}_patchTypeAndPayload(e){let{event:s,elements:i=[],groupTips:o={}}=e.lastMsg;if(Be(s)||Ge(o))return{type:i[0]?i[0].type:null,payload:i[0]?this._amendLayersOverLimitProp(i[0].content,i[0].type):null};{let e=new Ki(o),s=(e.setElement({type:t.MSG_GRP_TIP,content:{...o.elements,groupProfile:o.groupProfile}}),JSON.parse(JSON.stringify(e.payload)));return e=null,{type:t.MSG_GRP_TIP,payload:s}}}_amendLayersOverLimitProp(e,s){var i=this.getFileDownloadProxy(),o=this.getDownloadFileAuthKey(),n=this.get(ks).getFileDNList(),r=e["layersOverLimit"];let a=null;return s===t.MSG_IMAGE&&(a=new Oi(e,i,o,n)),s===t.MSG_VIDEO&&(a=new $i(e,i,o,n)),s===t.MSG_SOUND&&(a=new Pi(e,i,o,n)),s===t.MSG_FILE&&((a=new bi(e,i,o,n)).content.url=void 0),0===r?e.layersOverLimit=!1:1===r&&(e.layersOverLimit=!0),a&&Object.assign(e,a.content),e}getLocalMessageList(e){return this._msgListHandler.getLocalMsgList(e)}deleteLocalMessage(e){e instanceof Ki&&this._msgListHandler.remove(e)}onConvDeleted(e){Ve(e)&&(e=e.map(e=>{var{type:e,userID:s,groupID:i}=e;return 1===e?""+t.CONV_C2C+s:2===e?""+t.CONV_GROUP+i:void 0}),Se.l(this._n+".onConvDeleted convIDList:"+e),this.deleteLocalConvList(e))}onConvPinnedStatus(e,r){if(Ve(e)){let n=!1;e.forEach(e=>{var{type:e,userID:s,groupID:i}=e;let o;1===e?o=this.getLocalConversation(""+t.CONV_C2C+s):2===e&&(o=this.getLocalConversation(""+t.CONV_GROUP+i)),o&&(Se.l(`${this._n}.onConvPinnedStatus convID:${o.conversationID} localPinned:${o.isPinned} remotePinned:`+r),r?o.isPinned||(o.isPinned=!0,n=!0):o.isPinned&&(o.isPinned=!1,n=!0))}),n&&this._sortConvListAndEmitEvent()}}getMessageList({conversationID:a,nextReqMessageID:e,count:t}){let l=this._n+".getMessageList",s=this.getLocalConversation(a),i="";if(s&&s.groupProfile&&(i=s.groupProfile.type),ct(i))return Se.l(l+` not available in ${i}. convID:`+a),ai({messageList:[],nextReqMessageID:"",isCompleted:!0});(Be(t)||15<t)&&(t=15),e||this._isMeInCommunity(a)||this.clearMemMsg(a);let d=this._computeRemainingCount({conversationID:a,nextReqMessageID:e}),o=this._completedMap.has(a);if(Se.l(l+` convID:${a} isEverCleared:${this._isEverCleared(a)} nextReqMessageID:${e} remainingCount:${d} count:${t} isCompleted:`+o),this._needGetHistory({conversationID:a,remainingCount:d,count:t}))return this.getHistoryMessages({conversationID:a,nextReqMessageID:e,count:20}).then(e=>{var{nextReqID:e,storedMessageList:t,assembledMessageList:s,isPullingCompleted:i}=e,o=this._completedMap.has(a);let n=t,r=(0<d&&(n=this._msgListHandler.getLocalMsgList(a).slice(0,t.length+d)),{nextReqMessageID:void 0,messageList:void 0,isCompleted:void 0});this._isEverCleared(a)?(r.nextReqMessageID=e,r.messageList=s,r.isCompleted=i):(r.nextReqMessageID=o?"":e,r.messageList=n,r.isCompleted=o);t=r.messageList.filter(e=>e.isRevoked)||[],s=r.messageList.map(e=>e.sequence);return Se.l(l+` ret.nextReqMessageID:${r.nextReqMessageID} ret.isCompleted:${r.isCompleted} sequenceList:`,s),Ve(t)&&0!==t.length?this.updateRevokerInfo(t).then(e=>(e.forEach(t=>{let s=t["revokerInfo"];r.messageList=r.messageList.map(e=>(e.ID===t.ID&&s&&(e.revokeReason=s.reason||"",e.revokerInfo={userID:s.revoker||e.revoker,nick:s.nick,avatar:s.avatar}),e))}),si(r))):si(r)});this.modifyMessageList(a);e=this._getMsgListFromMem({conversationID:a,nextReqMessageID:e,count:t});return ai(e)}_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=dt(e);let a=0;var l={isCompleted:!1,nextReqMessageID:"",messageList:[]},s=(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),l.messageList.map(e=>e.sequence));return Se.l(i+` convID:${e} ret.nextReqMessageID:${l.nextReqMessageID} ret.isCompleted:${l.isCompleted} sequenceList:`+s),l}getMessageListHopping(e){let{conversationID:i,sequence:o,time:n,count:r,direction:a=0}=e;if((Be(r)||15<r)&&(r=15),i.startsWith(t.CONV_C2C)){let e=this.get(Ds),s=i.replace(t.CONV_C2C,"");return e.getRoamingMessagesHopping({peerAccount:s,time:n,count:r,direction:a})}if(i.startsWith(t.CONV_GROUP)){let e=this.get(Rs),s=i.replace(t.CONV_GROUP,"");return e.getRoamingMessagesHopping({groupID:s,sequence:o,count:r,direction:a})}}_computeRemainingCount({conversationID:e,nextReqMessageID:t}){var s=this._msgListHandler.getLocalMsgList(e),i=s.length;if(Se.l(this._n+`._computeRemainingCount convID:${e} nextReqMessageID:${t} length:`+i),!t)return i;let o=0;return dt(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)),o=-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),!(ht(e)||ct(o)||!this._isEverCleared(e)&&(i=t<=s&&!this._completedMap.has(e),Se.l(this._n+`._needGetHistory convID:${e} ret:`+i),!i))}_isTopicConv(e){e=e.replace(t.CONV_GROUP,"");return ut(e)}getHistoryMessages(r){var{conversationID:a,count:r,nextReqMessageID:l}=r;if(a!==t.CONV_SYSTEM){let o=15,n=(20<r&&(o=20),null);if(dt(a)){let s=0,e="",i=!1;r=this._roamingMsgKeyAndTimeMap.has(a);if(l)if(i=!0,r)s=this._roamingMsgKeyAndTimeMap.get(a).lastMessageTime,e=this._roamingMsgKeyAndTimeMap.get(a).messageKey;else{let e=this._msgListHandler.findMessage(l);e&&(s=e.time,Se.l(this._n+`.getHistoryMessages convID:${a} isRelayInfoExisted:${r} lastMessageTime:`+s))}return(n=this.get(Ds)).getRoamingMessage({conversationID:a,peerAccount:a.replace(t.CONV_C2C,""),count:o,lastMessageTime:i?s:0,messageKey:i?e:""})}if(_t(a)){if(!(n=this.get(Rs)))return ci({code:ni.NO_MODULE});let e=a.replace(t.CONV_GROUP,""),s=null,i=(this._convMap.has(a)&&!ut(e)&&(s=this._convMap.get(a).lastMessage),0);return l?i=Number(l):s&&(i=s.lastSequence),n.getRoamingMessage({conversationID:a,groupID:e,count:o,sequence:i})}}return ai()}patchConvLastMessage(s,i=!1){var o=this.getLocalConversation(s);if(o){let{messageForShow:e,payload:t}=o.lastMessage;if(Ge(e)||Ge(t)||i){let t=this._msgListHandler.getLocalMsgList(s);if(0!==t.length){let e=t[t.length-1];Se.l(this._n+`.patchConvLastMessage bForceUpdate:${i} convID:${s} payload:`,e.payload),o.updateLastMessage(e)}}}}onRoamingMessage(s=[],e,i=!0,o){var n=e.startsWith(t.CONV_C2C)?t.CONV_C2C:t.CONV_GROUP;let r=null,a=[],l=[],d=0,u=s.length,c,_=n===t.CONV_GROUP,h=this.getFileDownloadProxy(),p=this.getDownloadFileAuthKey(),g=Ve(o),m=this.get(ks).getFileDNList(),f=()=>{_?--d:++d},M=()=>_?d>=u:d<u;for(d=_?s.length-1:0,u=_?0:s.length;M();f())if(1!==s[d].isPlaceMessage)if((r=new Ki(s[d])).to=s[d].to,n!==t.CONV_GROUP||Be(s[d].topicID)||(r.to=s[d].topicID),r.isSystemMessage=!!s[d].isSystemMessage,r.conversationType=n,c=4===s[d].event?{type:t.MSG_GRP_TIP,content:{...s[d].elements,groupProfile:s[d].groupProfile}}:s[d].elements,_||r.setNickAndAvatar({nick:s[d].nick,avatar:s[d].avatar}),Ge(c)){let e=new Ei("emptyMessageBody");e.setMessage(`from:${r.from} to:${r.to} sequence:${r.sequence} event:`+s[d].event),e.setLevel("warning").end()}else r.setElement(c,h,p,m),r.reInitialize(this.getMyUserID()),a.push(r),g&&o.push(r);return f=M=null,i?(this._msgListHandler.unshift(a,l),a=null,l):a}findMessage(e){return this._msgListHandler.findMessage(e)}_isMeInCommunity(e){let s=!0;return this._isTopicConv(e)&&(e=Et(e.replace(t.CONV_GROUP,"")),this.get(Rs).hasLocalGroup(e)||(s=!1,Se.l(this._n+`._isMeInCommunity groupID:${e} ret:`+s))),s}deleteTopicRoamingInfo(e){lt({groupID:e})&&this._msgListHandler.getTopicConvIDList(e).forEach(e=>{this.clearMemMsg(e)})}deleteGroupRoamingInfo(e){e=""+t.CONV_GROUP+e;0<this._msgListHandler.getLocalMsgList(e).length&&this.clearMemMsg(e)}setMessageRead({conversationID:n}){let e=this.getLocalConversation(n),s=this._n+".setMessageRead";if(Se.l(s+` convID:${n} unreadCount:`+(e?e.unreadCount:0)),!e)return ai();if(e.type!==t.CONV_GROUP&&e.type!==t.CONV_TOPIC||Ge(e.groupAtInfoList)||this.deleteGroupAtTips(n),0===e.unreadCount)return ai();let i=this._msgListHandler.getLocalLastMsg(n),o=e.lastMessage.lastTime;var r=this._msgListHandler.getLocalMaxTime(n),r=(o<r&&(Se.l(`${s} update lastMessageTime from ${o} to `+r),o=r),this._msgListHandler.getLocalMaxSeq(n));let a=e.lastMessage.lastSequence;if(a<r&&(Se.l(`${s} update lastMessageSeq from ${a} to `+r),a=r),e.type===t.CONV_TOPIC&&Be(i)){let e=this.get(As),s=n.replace(t.CONV_GROUP,""),i=Et(s),o=e.getLocalTopic(i,s);o&&(a=o.nextMessageSeq-1)}let l=null;switch(e.type){case t.CONV_C2C:return(l=this.get(Ds))?l.setMessageRead({conversationID:n,lastMessageTime:o}):ci({code:ni.NO_MODULE});case t.CONV_GROUP:case t.CONV_TOPIC:return(l=this.get(Rs))?l.setMessageRead({conversationID:n,lastMessageSeq:a}):ci({code:ni.NO_MODULE});case t.CONV_SYSTEM:return e.unreadCount=0,this.emitConvUpdate(!0,!1),ai();default:return ai()}}setAllMessageRead(s={}){let i=this._n+".setAllMessageRead";s.scope||(s.scope=t.READ_ALL_MSG),Se.l(i+" options:",s);var e=this._createSetAllMessageReadPack(s);if(0===e.readAllC2CMessage&&0===e.groupMessageReadInfoList.length)return ai();let o=new Ei("setAllMessageRead");return this.req({P:ui.SET_ALL_MSG_READ,data:e}).then(e=>{e=e.data,e=this._handleAllMsgRead(e);return o.setMessage(`scope:${s.scope} failureGroups:`+JSON.stringify(e)).end(),ai()}).catch(e=>(o.setError(e).end(),Se.w(i+" failed. error:",e),ci({code:e&&e.code?e.code:ni.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 s=t&&s<t.sequence?t.sequence:s}_getConvLastMessageTime(e){var t=this._msgListHandler.getLocalLastMsg(e.conversationID);let s=e.lastMessage.lastTime;return s=t&&s<t.time?t.time:s}_createSetAllMessageReadPack(e){var s,i={readAllC2CMessage:0,groupMessageReadInfoList:[]},o=e["scope"];for([,s]of this._convMap)if(0<s.unreadCount)if(s.type===t.CONV_C2C&&0===i.readAllC2CMessage){if(o===t.READ_ALL_MSG)i.readAllC2CMessage=1;else if(o===t.READ_ALL_C2C_MSG){i.readAllC2CMessage=1;break}}else if(s.type===t.CONV_GROUP&&(o===t.READ_ALL_GROUP_MSG||o===t.READ_ALL_MSG)){let e=this._getConvLastMessageSeq(s);i.groupMessageReadInfoList.push({groupID:s.groupProfile.groupID,messageSequence:e})}return i}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(s){var i=[];if(s&&s.length)for(let e=0,t=s.length;e<t;e++){var{groupID:o,sequence:n,retCode:r,lastMessageSeq:a}=s[e];Be(r)?this._remoteGroupReadSeqMap.set(o,a):(this._remoteGroupReadSeqMap.set(o,n),0!==r&&i.push(o+`-${n}-`+r))}return i}_updateAllConvUnreadCount(e){let s=e["readAllC2CMessage"],i=0;for(var[o,n]of this._convMap)if(1<=n.unreadCount){if(1===s&&n.type===t.CONV_C2C){let e=this._getConvLastMessageTime(n);this.updateIsReadAfterReadReport({conversationID:o,lastMessageTime:e})}else if(n.type===t.CONV_GROUP){let s=o.replace(t.CONV_GROUP,"");if(this._remoteGroupReadSeqMap.has(s)){let e=this._remoteGroupReadSeqMap.get(s),t=this._getConvLastMessageSeq(n);this.updateIsReadAfterReadReport({conversationID:o,remoteReadSequence:e}),t>=e&&this._remoteGroupReadSeqMap.delete(s)}}this.updateUnreadCount(o,!1)&&(i+=1)}return i}isRemoteRead(e){var{conversationID:s,sequence:i}=e,o=s.replace(t.CONV_GROUP,"");let n=!1;if(this._remoteGroupReadSeqMap.has(o)){let e=this._remoteGroupReadSeqMap.get(o);i<=e&&(n=!0,Se.l(this._n+`.isRemoteRead convID:${s} msgSeq:${i} remoteReadSeq:`+e)),i>=e+10&&this._remoteGroupReadSeqMap.delete(o)}return n}updateIsReadAfterReadReport({conversationID:e,lastMessageSeq:t,lastMessageTime:s}){var i,o=this._msgListHandler.getLocalMsgList(e);if(0!==o.length)for(let e=o.length-1;0<=e;e--)if(i=o[e],!(s&&i.time>s||t&&i.sequence>t)){if("in"===i.flow&&i.isRead)break;i.setIsRead(!0)}}updateUnreadCount(o,e=!0){let s=!1,n=this.getLocalConversation(o),i=this._msgListHandler.getLocalMsgList(o);if(n){var r=n.unreadCount,a=i.filter(e=>!e.isRead&&!e._onlineOnlyFlag&&!e.isDeleted).length;if(r!==a&&(n.unreadCount=a,s=!0,Se.l(this._n+`.updateUnreadCount from ${r} to ${a}, convID:`+o),!0===e)&&this.emitConvUpdate(!0,!1),s&&n.type===t.CONV_TOPIC){let e=n["unreadCount"],s=this.get(As),i=o.replace(t.CONV_GROUP,"");s.onUnreadCountUpdatedFromConv(i,e)}return s}}clearGroupAtInfoList(o,e=!0){var n=this.getLocalConversation(o);if(n&&0<n.groupAtInfoList.length){if(n.clearGroupAtInfoList(),Se.l(this._n+".clearGroupAtInfoList convID:"+o),n.type===t.CONV_TOPIC){let e=n["groupAtInfoList"],s=this.get(As),i=o.replace(t.CONV_GROUP,"");s.onAtInfoUpdated({topicID:i,groupAtInfoList:e})}!0===e&&this.emitConvUpdate(!0,!1)}}updateReadReceiptInfo(s){let{userID:o,groupID:a,readReceiptList:l,timestamp:n=0}=s;if(!Ge(l)){let r=[];if(Be(o)){if(!Be(a)){let n=""+t.CONV_GROUP+a;l.forEach(e=>{var{tinyID:e,clientTime:t,random:s,readCount:i,unreadCount:o}=e,e=e+`-${t}-`+s,t=this._msgListHandler.getLocalMsg(n,e)||this._msgListHandler.getHoppingMsg(n,e),s={groupID:a,messageID:e,readCount:0,unreadCount:0};t&&(Fe(i)&&(t.readReceiptInfo.readCount=i,s.readCount=i),Fe(o)&&(t.readReceiptInfo.unreadCount=o,s.unreadCount=o),r.push(s))})}}else{let i=""+t.CONV_C2C+o;l.forEach(t=>{var{tinyID:t,clientTime:s,random:e}=t,t=t+`-${s}-`+e,s=this._msgListHandler.getLocalMsg(i,t)||this._msgListHandler.getHoppingMsg(i,t);if(s&&!s.readReceiptInfo.isPeerRead){s.readReceiptInfo.isPeerRead=!0,s.readReceiptInfo.timestamp=n;let e={userID:o,messageID:t,isPeerRead:!0,timestamp:n};r.push(e)}})}0<r.length&&this.emitOEvt(e.MESSAGE_READ_RECEIPT_RECEIVED,r)}}updateIsRead(e){var i=this.getLocalConversation(e),o=this.getLocalMessageList(e);if(i&&0!==o.length&&!ht(i.type)){var n=[];for(let e=0,t=o.length;e<t;e++)"in"!==o[e].flow?"out"!==o[e].flow||o[e].isRead||o[e].setIsRead(!0):n.push(o[e]);let s=0;if(i.type===t.CONV_C2C){let e=n.slice(-i.unreadCount).filter(e=>e.isRevoked).length;s=n.length-i.unreadCount-e}else s=n.length-i.unreadCount;for(let e=0;e<s&&!n[e].isRead;e++)n[e].setIsRead(!0)}}deleteGroupAtTips(e){let s=this._n+".deleteGroupAtTips";Se.l(s);var i=this._convMap.get(e);if(!i)return Promise.resolve();let o=i.groupAtInfoList;if(0===o.length)return Promise.resolve();let n=void 0,r=(e.startsWith(t.CONV_GROUP)&&(n=e.replace(t.CONV_GROUP,"")),[...o]);if((lt({groupID:n})||ut(n))&&0===(r=o.filter(e=>!e.atTypeArray.includes(t.CONV_AT_ALL))).length)return this.clearGroupAtInfoList(e,!1),Promise.resolve();let a=this.getMyUserID();return this.req({P:ui.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(()=>(Se.l(s+" ok. count:"+o.length),this.clearGroupAtInfoList(e,!1),Promise.resolve())).catch(e=>(Se.e(s+" failed. error:",e),ci(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(s,i){if(s.startsWith(t.CONV_C2C)&&0<i){let t=this._msgListHandler.updateMsgIsPeerReadProp(s,i);if(0<t.length&&this.emitOEvt(e.MESSAGE_READ_BY_PEER,t),this._convMap.has(s)){let e=this._convMap.get(s).lastMessage;Ge(e)||e.fromAccount===this.getMyUserID()&&e.lastTime<=i&&!e.isPeerRead&&(e.isPeerRead=!0,this.emitConvUpdate(!0,!1))}}}updateMsgIsModifiedProp(e){this._msgListHandler.updateMsgIsModifiedProp(e)}setCompleted(e){Se.l(this._n+".setCompleted convID:"+e),this._completedMap.set(e,!0)}updateRoamingMsgKeyAndTime(e,t,s){this._roamingMsgKeyAndTimeMap.set(e,{messageKey:t,lastMessageTime:s})}getConvList(s){let i=this._n+".getConvList",e=`pagingStatus:${this._pagingStatus}, local conversation count:${this._convMap.size}, options:`+JSON.stringify(s);if(Se.l(i+". "+e),this._pagingStatus===qt){let t=new Ei("getConvList");return t.setMessage(e),this.syncConvList().then(()=>{t.end();var e=this._getConvList(s);return si({conversationList:e,isSyncCompleted:this.isSyncCompleted()})}).catch(e=>(t.setError(e).end(),Se.e(i+" failed. error:",e),ci(e)))}let t=this._getConvList(s);return Se.l(i+". returned conversation count:"+t.length),ai({conversationList:t,isSyncCompleted:this.isSyncCompleted()})}_getConvList(r){if(Be(r))return this.getLocalConvList();if(Ve(r))return 0===r.length?[]:this.getLocalConvList().filter(e=>r.includes(e.conversationID));if(xe(r)){let{type:t,markType:s,groupName:i,hasUnreadCount:o,hasGroupAtInfo:n}=r;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,s){return s!==t.CONV_C2C&&s!==t.CONV_GROUP||e.type===s}_filterGroupName(e,t){return!$e(t)||(""===t?0===e.conversationGroupList.length:e.conversationGroupList.includes(t))}_filterMarkType(e,t){return!Fe(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,s]of this._convMap)s.type===t.CONV_C2C&&this.recordPeerReadTime(e,s.peerReadTime)}_isPagingGetGroupListCompleted(){var e=this.get(Rs);return!e||e.isPagingGetCompleted()}_getLocalGroupCount(){var e=this.get(Rs);return e?e.getLocalGroupList().length:0}_hasLocalGroup(e){var s=this.get(Rs);return!!s&&s.hasLocalGroup(e.replace(t.CONV_GROUP,""))}getConversationProfile(o){let n,s=!1;if(this._convMap.has(o)?n=this._convMap.get(o):(n=new pn({conversationID:o,type:dt(o)?t.CONV_C2C:t.CONV_GROUP},this.isIntl(),this.isUsingChatCore()),s=!0),n._isInfoCompleted||n.type===t.CONV_SYSTEM)return ai({conversation:n});if(_t(o)){if(!this.get(Rs))return ci({code:ni.NO_MODULE});if(!this._hasLocalGroup(o))return ai({conversation:n})}let r=this._n+".getConversationProfile",a=new Ei("getConversationProfile");return Se.l(r+`. convID:${o} remark:${n.remark} lastMessage:`,n.lastMessage),this._getUserOrGroupProfile(n).then(e=>{a.setMessage(`convID:${o} unreadCount:`+e.data.conversation.unreadCount).end();var i=this.get(Ls);if(i&&n.type===t.CONV_C2C){let s=o.replace(t.CONV_C2C,"");if(i.isMyFriend(s)){let e=i.getFriendRemark(s);n.remark!==e&&(n.remark=e,Se.l(r+`. convID:${o} patch remark:`+n.remark))}}if(Se.l(r+` ok. isNewConv:${s} convID:`+o),s){if(n.type===t.CONV_C2C)return this._onNewC2CConv([o.replace(t.CONV_C2C,"")]).then(()=>ai({conversation:n}));if(n.type===t.CONV_GROUP)return this._onNewGroupConv([o.replace(t.CONV_GROUP,"")]).then(()=>ai({conversation:n}))}return e}).catch(e=>(a.setError(e).setMessage("convID:"+o).end(),Se.e(r+" failed. error:",e),ci(e)))}_getUserOrGroupProfile(s){return s.type===t.CONV_C2C?this.get(Es).getUserProfile({userIDList:[s.toAccount]}).then(e=>{e=e.data;return 0===e.length?ci({code:ni.USER_OR_GRP_NOT_FOUND}):(s.userProfile=e[0],s._isInfoCompleted=!0,this._insertConvAfterTopmost(s),ai({conversation:s}))}):this.get(Rs).getGroupProfile({groupID:s.toAccount}).then(e=>(s.groupProfile=e.data.group,s._isInfoCompleted=!0,this._insertConvAfterTopmost(s),ai({conversation:s})))}_insertConvAfterTopmost(e){var t,s;e instanceof pn&&!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 s=e["userID"];s===this.getMyUserID()?this._onMyProfileModified({latestNick:e.nick,latestAvatar:e.avatar}):(s=this._convMap.get(""+t.CONV_C2C+s))&&(s.userProfile=e)})}_onCloudConfig(e){"0"===this.getCloudConfig("pull_on_invite")&&(this._bPullOnInvite=!1),Se.l(this._n+"._onCloudConfig bPullOnInvite:"+this._bPullOnInvite)}disableMsgPullOnInvite(){this._bPullOnInvite=!1}isSyncCompleted(){return this._pagingStatus===$t}_errorLog(e,t,s,i){var o=new Error("Params validate failed."),n=""+this.getErrMsg("API_REFER")+e;throw Se.w(`[${e}] | ${t} | ${this.getErrMsg(s,i)}, `+n),Se.e(`[${e}] Invalid ${t}: type check failed for ${t}.`),o}_isValidConvID(e){return dt(e)||_t(e)||ht(e)}deleteConversation(e){let t="deleteConversation";return $e(e)||qe(e)||this._errorLog(t,"options","StringOrObjectRequiredLog"),$e(e)?(this._isValidConvID(e)||this._errorLog(t,"options","InvalidConversationID",e),Se.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=(Se.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]];return 0===e.length?ci(new ii({code:ni.CONV_NOT_FOUND})):(Se.l(o+" ok"),ai(1===i?{conversationID:e[0]}:{conversationIDList:e}))}).catch(e=>(r.setError(e).end(),Se.e(o+" failed. error:",e),ci(e)))}rmLocalOnlyConvList(e){return e.filter(e=>{var s;return!!this._convMap.has(e)&&((s=this.getLocalConversation(e).type)!==t.CONV_GROUP||this._hasLocalGroup(e)?s===t.CONV_SYSTEM&&(this.get(Rs).deleteGroupSystemNotice({messageList:this._msgListHandler.getLocalMsgList(e)}),this.deleteLocalConv(e),!0):(this.deleteLocalConv(e),!0))})}rmLocalAndRemoteConvList(e,s){let i={fromAccount:this.getMyUserID(),conversationList:[],clearHistoryMessage:s?1:0};return e.forEach(e=>{var s;this._convMap.has(e)&&((s=this.getLocalConversation(e).type)===t.CONV_C2C?i.conversationList.push({toAccount:e.replace(s,""),type:1}):s===t.CONV_GROUP&&this._hasLocalGroup(e)&&i.conversationList.push({toGroupID:e.replace(s,""),type:2}))}),0===i.conversationList.length?[]:this.req({P:ui.DEL_CONV,data:i}).then(e=>{let s=[];return 0<e.data.resultList.length&&e.data.resultList.map(e=>{0===e.code&&(e=1===e.type?""+t.CONV_C2C+e.to:""+t.CONV_GROUP+e.groupID,s.push(e))}),this.deleteLocalConvList(s),s})}setConvDraft(e){var{conversationID:e,draftText:t}=e,s=this._n+".setConvDraft";return Se.l(s+` convID:${e} draftText:`+t),this._convMap.has(e)?((s=this._convMap.get(e)).setDraftText(t),this.emitConvUpdate(),ai({code:0,conversation:s})):ci({code:ni.CONV_NOT_FOUND})}clearHistoryMessage(s){let e={fromAccount:this.getMyUserID(),toAccount:void 0,type:void 0,toGroupID:void 0};if(!this._convMap.has(s))return ci({code:ni.CONV_NOT_FOUND});var i=this._convMap.get(s).type;if(i===t.CONV_C2C)e.type=1,e.toAccount=s.replace(t.CONV_C2C,"");else{if(i!==t.CONV_GROUP)return i===t.CONV_SYSTEM?(this.get(Rs).deleteGroupSystemNotice({messageList:this._msgListHandler.getLocalMsgList(s)}),ai({conversationID:s})):ci({code:ni.CONV_UN_RECORDED_TYPE});e.type=2,e.toGroupID=s.replace(t.CONV_GROUP,"")}let o=this._n+".clearHistoryMessage",n=new Ei("clearHistoryMessage");return n.setMessage("convID:"+s),Se.l(o+". convID:"+s),this.setMessageRead({conversationID:s}).then(()=>this.req({P:ui.CLEAR_HISTORY_MSG,data:e})).then(()=>{n.end(),Se.l(o+" ok"),this.clearMemMsg(s);var e=this.getLocalConversation(s);return e&&(e.updateLastMessage(),this._sortConvListAndEmitEvent()),ai({conversationID:s})}).catch(e=>(n.setError(e).end(),Se.e(o+" failed. error:",e),ci(e)))}pinConversation(e){let{conversationID:s,isPinned:i}=e,o=this.getLocalConversation(s);if(o&&o.isPinned===i)return ai({conversationID:s});if(ht(s))return o&&(o.isPinned=i),this._sortConvListAndEmitEvent(),ai({conversationID:s});let n=null;if(dt(s)?n={type:1,toAccount:s.replace(t.CONV_C2C,"")}:_t(s)&&(n={type:2,groupID:s.replace(t.CONV_GROUP,"")}),null===n)return ci({code:ni.INVALID_CONV_ID});let r=this._n+".pinConversation",a=`convID:${s} isPinned:`+i,l=new Ei("pinConversation");return l.setMessage(a),Se.l(r+". "+a),this.req({P:ui.PIN_CONV,data:{fromAccount:this.getMyUserID(),operationType:!0===i?1:2,itemList:[n]}}).then(()=>(l.end(),Se.l(r+" ok"),o?o.isPinned!==i&&(o.isPinned=i):this._convMap.set(s,new pn({conversationID:s,type:dt(s)?t.CONV_C2C:t.CONV_GROUP,isPinned:i},this.isIntl(),this.isUsingChatCore())),this._sortConvListAndEmitEvent(),si({conversationID:s}))).catch(e=>(l.setError(e).end(),Se.e(r+" failed. error:",e),ci(e)))}setMessageRemindType(e){return this._msgRemindHandler.set(e)}patchMsgRemindType(e){var{ID:s,isC2CConversation:i,messageRemindType:o}=e;let n=!1;i=this.getLocalConversation(i?""+t.CONV_C2C+s:""+t.CONV_GROUP+s);return i&&i.messageRemindType!==o&&(i.messageRemindType=o,n=!0),Se.l(this._n+".patchMsgRemindType options:",e,"ret:"+n),n}onC2CMsgRemindTypeFetched(e){if(Ve(e)&&0<e.length){let s=0;e.forEach(e=>{var{userID:e,muteFlag:t}=e,t=this._transMsgRemindType(t);!0===this.patchMsgRemindType({ID:e,isC2CConversation:!0,messageRemindType:t})&&(s+=1)}),Se.l(this._n+".onC2CMsgRemindTypeFetched updateCount:"+s),1<=s&&this.emitConvUpdate(!0,!1)}}onC2CMsgRemindTypeSynced(e){let i=this._n+".onC2CMsgRemindTypeSynced";e.dataList.forEach(t=>{if(!Ge(t.muteNotificationsSync)){var{to:t,muteFlag:s}=t.muteNotificationsSync,s=this._transMsgRemindType(s);let e=0;this.patchMsgRemindType({ID:t,isC2CConversation:!0,messageRemindType:s})&&(e+=1),Se.l(i+" updateCount:"+e),1<=e&&this.emitConvUpdate(!0,!1)}})}onGroupMsgRemindTypeUpdated(e){this._msgRemindHandler.onGroupMsgRemindTypeUpdated(e)}deleteLocalConv(t,e=!0){var s=this._convMap.has(t);if(Se.l(this._n+`.deleteLocalConv convID:${t} has:`+s),s&&(this._convMap.delete(t),this._convMapForDiff.delete(t),this.clearMemMsg(t),this._setStorageConvList(!0),e)){let e=!this._isTopicConv(t);this.emitConvUpdate(e,!1)}}pullMsgOnInvite(i){var o=this.get(Rs);if(o){var n=this._n+".pullMsgOnInvite";if(Se.l(n+" flag:"+this._bPullOnInvite),this._bPullOnInvite){var r=this.getLocalLastMessage(i),a=this.getLocalSecondLastMessage(i);let e=1,s=1;r&&(e=r.sequence),a&&(s=a.sequence);r=o.getGroupRemoteLastSeq(i.replace(t.CONV_GROUP,""));Se.l(n+` convID:${i} localLastSeq:${e} localSecondLastSeq:${s} remoteLastSeq:`+r),this.clearMemMsg(i),1<e-s?this._recursiveGetMsgList([],i,!1,e,s):1<r-e&&this._recursiveGetMsgList([],i,!0,r,e)}}}_recursiveGetMsgList(o,n,r,a,l,e){this.getMessageList({conversationID:n,nextReqMessageID:e}).then(e=>{var{messageList:e,isCompleted:t,nextReqMessageID:s}=e.data,i=e.filter(e=>r?e.sequence>l&&e.sequence<=a:e.sequence>l&&e.sequence<a);o.unshift(...i),!t&&0<e.length&&e[0].sequence>l&&o.length<60?this._recursiveGetMsgList(o,n,r,a,l,s):this._emitMsgReceived(n,o)})}_emitMsgReceived(t,s){var i,o;0<s.length&&(s=s.filter((t,e,s)=>e===s.findIndex(e=>e.sequence===t.sequence)),i=this.hasLocalConversation(t),o=s.map(e=>e.sequence),Se.l(`${this._n}._emitMsgReceived convID:${t} has:${i} count:${o.length} sequenceList:`,o),this.emitOEvt(e.MESSAGE_RECEIVED,s),i?this.patchConvLastMessage(t,!0):this.getConversationProfile(t).then(()=>{this.patchConvLastMessage(t,!0)}))}deleteLocalConvList(e){let t=!1;e.forEach(e=>{this._convMap.has(e)&&(this.deleteLocalConv(e,!1),t=!0)}),Se.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 s,i;e.startsWith(t.CONV_C2C)&&this._convMap.has(e)&&(i=this._convMap.get(e),s=Date.now(),this._msgListHandler.modifyMsgSentByPeer({conversationID:e,latestNick:i.userProfile.nick,latestAvatar:i.userProfile.avatar}),i=this.get(Es).getNickAndAvatarByUserID(this.getMyUserID()),this._msgListHandler.modifyMsgSentByMe({conversationID:e,latestNick:i.nick,latestAvatar:i.avatar}),Se.l(this._n+`.modifyMessageList convID:${e} cost:`+Ot(s)))}updateUserProfileSpecifiedKey(e){Se.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;$e(s)&&e.nick!==s&&(e.nick=s),$e(i)&&e.avatar!==i&&(e.avatar=i),this.emitConvUpdate(!0,!1)}}_onMyProfileModified(t){var e=this.getLocalConvList(),s=Date.now();e.forEach(e=>{this.modifyMessageSentByMe({conversationID:e.conversationID,...t})}),Se.l(this._n+"._onMyProfileModified. modify all messages sent by me, cost:"+Ot(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 n=this.get(Ls);if(0!==this._convMap.size&&n){var e=[...this._convMap.values()].filter(e=>e.type===t.CONV_C2C);if(0!==e.length){let o=0;e.forEach(s=>{var i=s.conversationID.replace(t.CONV_C2C,"");if(n.isMyFriend(i)){let e=n.getFriendRemark(i);s.remark!==e&&(s.remark=e,o+=1)}}),Se.l(`${this._n}.checkAndPatchRemark. c2cConvCount:${e.length} patchedCount:`+o),0<o&&this.emitConvUpdate(!0,!1)}}}updateTopicConversation(e){this._updateLocalConvList({conversationOptionsList:e,isFromGetConversations:!0,updateUnreadCount:!0})}sendReadReceipt(e){var s=e[0];let i=null;return s.conversationType===t.CONV_C2C?i=this._m.get(Ds):s.conversationType===t.CONV_GROUP&&(i=this._m.get(Rs)),i?i.sendReadReceipt(e):ci({code:ni.NO_MODULE})}getReadReceiptList(e){var s=e[0];let i=null;return s.conversationType===t.CONV_C2C?i=this._m.get(Ds):s.conversationType===t.CONV_GROUP&&(i=this._m.get(Rs)),i?i.getReadReceiptList(e):ci({code:ni.NO_MODULE})}getLastMessageTime(e){e=this.getLocalConversation(e);return e?e.lastMessage.lastTime:0}getTotalUnreadCount(){var e=this.getLocalConvList();let s=0;return e.forEach(e=>{e.type===t.CONV_SYSTEM||""!==e.messageRemindType&&e.messageRemindType!==t.MSG_REMIND_ACPT_AND_NOTE||(s+=e.unreadCount)}),s}onTotalUnreadCountUpdate(){var t=this.getTotalUnreadCount();this._convTotalUnreadCount!==t&&(Se.l(`${this._n}.onTotalUnreadCountUpdate from ${this._convTotalUnreadCount} to `+t),this._convTotalUnreadCount=t,this.emitOEvt(e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED))}_isConvNeedShow(e){var s,i,e=this.getLocalConversation(e);return!(!Be(e)&&(s=e.type===t.CONV_TOPIC,i=e.type===t.CONV_GROUP&&e.groupProfile.type===t.GRP_ROOM,e=e.type===t.CONV_GROUP&&e.groupProfile.type===t.GRP_LIVE,s||i||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){Se.l(this._n+`.clearMemMsg convID:${e} isOverLimit:`+t),this._msgListHandler.removeByConvID(e),this._completedMap.delete(e),this._roamingMsgKeyAndTimeMap.delete(e),t&&this._everClearedMap.set(e,1)}findMsgBySeq(e,t){return this._msgListHandler.findMsgBySeq(e,t)}reset(){Se.l(this._n+".reset"),this._setStorageConvList(!0),this._pagingStatus=bt,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 In=["topicID","topicName","avatar","introduction","notification","unreadCount","muteAllMembers","customData","groupAtInfoList","nextMessageSeq","selfInfo"],Cn=function(e,t){return Ge(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:Dt(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 Tn{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=Cn(e.lastMessage,t),this.selfInfo={muteTime:0,readedSequence:0,messageRemindType:"",excludedUnreadSequenceList:void 0},this._initTopic(e)}_initTopic(e){for(var t in e)In.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=Cn(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 yn 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(Qi.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(t){var s=t["groupID"];this.resetGetTopicTime(s),this.emitOEvt(e.TOPIC_CREATED,t)}onTopicDeleted(t){let{groupID:s,topicIDList:i=[]}=t;i.forEach(e=>{this._deleteLocalTopic(s,e)}),this.emitOEvt(e.TOPIC_DELETED,t)}onTopicProfileUpdated(t){var{groupID:s,topicID:i}=t,i=this.getLocalTopic(s,i);i&&(i.updateTopic(t),this.emitOEvt(e.TOPIC_UPDATED,{groupID:s,topic:i}))}onTopicLatestMsg(e){var{topicLatestMessage:s,excludedUnreadSequenceList:i}=e||{};if(!Ge(s)){let{topicID:e}=s["groupProfile"];s.conversationType=t.CONV_GROUP,s.to=e;var o=new Ki(s);o.setElement(s.elements),this.updateUnreadCountAndLastMsg(e,o,i)}}onMessageRemindTypeUpdated(t){var{groupID:s,topicID:i,messageRemindType:o}=t,n=this.getLocalTopic(s,i);if(n){let t=n.updateSelfInfo({messageRemindType:o});t&&this.emitOEvt(e.TOPIC_UPDATED,{groupID:s,topic:n}),Se.l(this._n+`.onMessageRemindTypeUpdated topicID:${i} messageRemindType:${o} isUpdated:`+t)}}onAtInfoUpdated(t){var{topicID:t,groupAtInfoList:s}=t,i=Et(t),t=this.getLocalTopic(i,t);t&&!Be(s)&&(t.updateGroupAtInfoList(s),this.emitOEvt(e.TOPIC_UPDATED,{groupID:i,topic:t}))}onUnreadCountUpdatedFromConv(t,s=0){var i=Et(t),t=this.getLocalTopic(i,t);t&&t.unreadCount!==s&&(t.updateUnreadCount(s),0===s&&t.updateSelfInfo({readedSequence:t.lastMessage.lastSequence}),this.emitOEvt(e.TOPIC_UPDATED,{groupID:i,topic:t}))}onMessageSent(t){let{groupID:i,topicID:s,lastMessage:o}=t,n=this.getLocalTopic(i,s);if(n){let{sequence:t=0}=o,s=t+1;s>n.nextMessageSeq&&(n.updateNextMessageSeq(s),n.updateLastMessage(o),n.updateSelfInfo({readedSequence:t}),n.updateUnreadCount(0),this.emitOEvt(e.TOPIC_UPDATED,{groupID:i,topic:n}))}}onMessageModified(t){var s,{to:i,time:o,sequence:n,elements:r,cloudCustomData:a,messageVersion:l}=t,d=Et(i),u=this.getLocalTopic(d,i);u&&(s=u.lastMessage,Se.d(this._n+`.onMessageModified topicID:${i} lastMessage:`,JSON.stringify(s),"options:",JSON.stringify(t)),s)&&(null===s.payload||s.lastTime===o&&s.lastSequence===n&&s.version!==l)&&(s.type=r[0].type,s.payload=r[0].content,s.messageForShow=Dt(s.type,s.payload,this.isIntl()),s.cloudCustomData=a,s.version=l,s.lastSequence=n,s.lastTime=o,this.emitOEvt(e.TOPIC_UPDATED,{groupID:d,topic:u}))}onMessageRevoked(t){if(0!==t.length){let s=null,i=null,o=!1;t.forEach(t=>{let e=t.to;if(i=Et(e),s=this.getLocalTopic(i,e)){s.reduceUnreadCount()&&(o=!0),s.isLastMessageRevoked(t)&&(s.setLastMessageRevoked(!0),s.setLastMessageRevoker(t.revoker),o=!0);let e=s.selfInfo.excludedUnreadSequenceList||[];e.push(t.sequence),s.updateSelfInfo({excludedUnreadSequenceList:e})}}),o&&this.emitOEvt(e.TOPIC_UPDATED,{groupID:i,topic:s})}}isLastMessageRevoked(e){var{topicID:e,sequence:t}=e,s=Et(e),s=this.getLocalTopic(s,e);let i=!1;return i=s?s.isLastMessageRevoked({sequence:t}):i}updateUnreadCountAndLastMsg(i,o,n){var r=Et(i),a=this.getLocalTopic(r,i);if(a){let s=a.selfInfo.excludedUnreadSequenceList||[];if(Be(n)||(s=n),o._isExcludedFromUnreadCount&&s.push(o.sequence),a.updateSelfInfo({excludedUnreadSequenceList:s}),Se.l(`${this._n}.updateUnreadCountAndLastMsg seq:${o.sequence} lastSeq:`+a.lastMessage.lastSequence),o.sequence>a.lastMessage.lastSequence){a.updateLastMessage(o);let s=o.sequence+1;a.updateNextMessageSeq(s);o=this._computeUnreadCount(a),i=(a.updateUnreadCount(o),this.get(Os).getLocalConversation(""+t.CONV_GROUP+i));i&&i.updateUnreadCount({nextUnreadCount:o,isFromGetConversations:!0}),this.emitOEvt(e.TOPIC_UPDATED,{groupID:r,topic:a})}}}getJoinedCommunityList(){return this.get(Rs).syncCommunityWithTopic()}createTopicInCommunity(t){let s=this._n+".createTopicInCommunity",e=t["topicID"];if(!Be(e)&&!ut(e))return ci({code:ni.ILLEGAL_TOPIC_ID});if(t.topicName&&!1===this._filterProfanity("topicName",t))return ci({code:ni.PROFANITY_FOUND});if(t.introduction&&!1===this._filterProfanity("introduction",t))return ci({code:ni.PROFANITY_FOUND});if(t.notification&&!1===this._filterProfanity("notification",t))return ci({code:ni.PROFANITY_FOUND});let i=new Ei("createTopicInCommunity");return this.req({P:ui.CREATE_TOPIC,data:{...t}}).then(e=>{e=e.data.topicID;return i.setMessage("topicID:"+e).end(),Se.l(s+" ok. topicID:"+e),this._updateTopicMap([{...t,topicID:e}]),si({topicID:e})}).catch(e=>(i.setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}deleteTopicFromCommunity(e){let s=this._n+".deleteTopicFromCommunity",{groupID:n,topicIDList:t=[]}=e,r=new Ei("deleteTopicFromCommunity");return r.setMessage(`groupID:${n} topicIDList:`+t),this.req({P:ui.DEL_TOPIC,data:{groupID:n,topicIDList:t}}).then(e=>{let{resultList:t=[]}=e.data,i=[],o=[];t.forEach(e=>{var{topicID:e,errorCode:t,errorInfo:s}=e;0===t?i.push({topicID:e}):o.push({topicID:e,code:t,message:s})});e=`success count:${i.length}, fail count:`+o.length;return r.setMoreMessage(e).end(),Se.l(s+" ok. "+e),i.forEach(e=>{this._deleteLocalTopic(n,e.topicID)}),si({successTopicList:i,failureTopicList:o})}).catch(e=>(r.setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}updateTopicProfile(e){let t=this._n+".updateTopicProfile";if(Se.l(t+" options:",e),e.topicName&&!1===this._filterProfanity("topicName",e))return ci({code:ni.PROFANITY_FOUND});if(e.introduction&&!1===this._filterProfanity("introduction",e))return ci({code:ni.PROFANITY_FOUND});if(e.notification&&!1===this._filterProfanity("notification",e))return ci({code:ni.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:ui.UPDATE_TOPIC_PROFILE,data:{...e}}).then(()=>(s.end(),Se.l(t+" ok"),this._updateTopicMap([e]),si({topic:this.getLocalTopic(e.groupID,e.topicID)}))).catch(e=>(s.setError(e).end(),Se.e(t+" failed. error:",e),ci(e)))}getTopicList(e){let i=this._n+".getTopicList",{groupID:o,topicIDList:s=[]}=e,l=0===s.length,d=new Ei("getTopicList");if(d.setMessage("groupID:"+o),this._getTopicTimeMap.has(o)){let{isGetAll:e,time:t}=this._getTopicTimeMap.get(o);if((e||!e&&!l)&&Date.now()-t<1e3*this.TOPIC_CACHE_TIME){let e=this._getLocalTopicList(o,s);if(l||e.length===s.length)return d.setMoreMessage("from cache, topic count:"+e.length).end(),Se.l(i+` groupID:${o} from cache, topic count:`+e.length),ai({successTopicList:e,failureTopicList:[]})}}return this.req({P:ui.GET_TOPIC_LIST,data:{groupID:o,topicIDList:s}}).then(e=>{let{topicInfoList:t=[]}=e.data,n=[],r=[],a=[];t.forEach(e=>{var{topic:e,selfInfo:t,errorCode:s,errorInfo:i}=e,o=e["topicID"];0===s?(n.push({...e,selfInfo:t}),r.push(o)):a.push({topicID:o,code:s,message:i})}),this._updateTopicMap(n),this._handleTopicAtInfo(n);e=`success count:${r.length}, fail count:`+a.length;d.setMoreMessage(e).end(),Se.l(i+` groupID:${o} from remote, `+e);let s=[];return Ge(r)||(this._getTopicTimeMap.set(o,{time:Date.now(),isGetAll:l}),s=this._getLocalTopicList(o,r)),si({successTopicList:s,failureTopicList:a})}).catch(e=>(d.setError(e).end(),Se.e(i+" failed. error:",e),ci(e)))}hasLocalTopic(e,t){return!!this._topicMap.has(e)&&this._topicMap.get(e).has(t)}getLocalTopic(e,t){let s=null;return s=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),Se.l(this._n+`._deleteLocalTopic groupID:${e} topicID:`+t))}_updateTopicMap(e){let n=[];e.forEach(e=>{var{groupID:s,topicID:i}=e;let o=null;this._topicMap.has(s)||this._topicMap.set(s,new Map),this._topicMap.get(s).has(i)?(o=this._topicMap.get(s).get(i)).updateTopic(e):(this._getTopicLastMessage(e),o=new Tn(e,this.isIntl()),this._topicMap.get(s).set(i,o));e=this._computeUnreadCount(o);o.updateUnreadCount(e),n.push({conversationID:""+t.CONV_GROUP+i,type:t.CONV_TOPIC,unreadCount:e})}),0<n.length&&this.get(Os).updateTopicConversation(n)}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()],i=[],o=this.get(Os);e.forEach(e=>{let s=[],t=this._getLocalTopicList(e);o.deleteTopicRoamingInfo(e),t.forEach(e=>{var{lastMessage:{lastTime:t=0}}=e;Date.now()-1e3*t<1e3*this.TOPIC_LAST_ACTIVE_TIME&&s.push(e.topicID)}),0<s.length&&i.push({groupID:e,topicIDList:s})}),Se.l(this._n+".getTopicListOnReconnected. active community count:"+i.length),this._relayGetTopicList(i)}_relayGetTopicList(i){if(0!==i.length){let e=i.shift(),t=5<e.topicIDList.length?"topicIDList.length:"+e.topicIDList.length:"topicIDList:"+e.topicIDList,s=new Ei("relayGetTopicList");s.setMessage(t),Se.l(this._n+"._relayGetTopicList. "+t),this.getTopicList(e).then(()=>{s.end(),this._relayGetTopicList(i)}).catch(e=>{s.setError(e).end(),this._relayGetTopicList(i)})}}_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(Os).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:Ge(e.lastMsg.revokerInfo)?null:e.lastMsg.revokerInfo.revoker},e.lastMessage=t)}deleteTopicListInCommunity(s){let e=this._getLocalTopicList(s),i=this.get(Os);e.forEach(e=>{e=e.topicID;this._deleteLocalTopic(s,e),this._getTopicTimeMap.delete(s),i.deleteLocalConv(""+t.CONV_GROUP+e)})}_computeUnreadCount(s){let{excludedUnreadSequenceList:e,readedSequence:i}=s.selfInfo,o=s.nextMessageSeq-s.selfInfo.readedSequence-1;if(Ve(e)){let t=0;e.forEach(e=>{e>i&&e<=s.nextMessageSeq-1&&(t+=1)}),1<=t&&(o-=t)}return o<0?0:o}_filterProfanity(e,t){var s,i=this.get(Ws);return!i||({isAllowedToSend:i,modifiedText:s}=i.filterText(t[e],S),!0===i&&(t[e]=s,!0))}getMessageExtensions(e,t){Se.l(this._n+".getMessageExtensions startSequence:"+t);var s=Et(e.to);return this.req({P:ui.GET_GRP_MSG_EXT,data:{groupID:s,topicID:e.to,messageSequence:e.sequence,startSequence:t}})}modifyMsgExts(e,t,s=1){Se.l(this._n+".modifyMsgExts operateType:"+s);var i=Et(e.to);return this.req({P:ui.MODIFY_GRP_MSG_EXT,data:{groupID:i,topicID:e.to,messageSequence:e.sequence,extensionList:t,operateType:s}})}reset(){Se.l(this._n+".reset"),this._topicMap.clear(),this._getTopicTimeMap.clear(),this.TOPIC_CACHE_TIME=300,this.TOPIC_LAST_ACTIVE_TIME=3600}}class vn{constructor(e){this._userM=e,this._n="ProfileHandler",this.TAG="profile",this.MAX_USER_COUNT=1e3,this.CHUNK_SIZE=100,this.accountProfileMap=new Map,this.expirationTime=864e5,this.strangerProfileMap=new Map,this.strangerProfileExpirationTime=600,this._userM.getIEmitInst().on(Qi.CLOUD_CONFIG,this._onCloudConfig,this)}_onCloudConfig(){var e=this._userM.getCloudConfig("stranger_profile_expiration_time");Se.l(this._n+"._onCloudConfig profileExpirationTime:"+e),Be(e)||(this.strangerProfileExpirationTime=parseInt(e,10))}getUserProfile(t){let n=this._n+".getUserProfile",{userIDList:s=[],bFromGetMyProfile:r=!1}=t,i=[],a=[];for(let e=0,t=s.length;e<t;e++){let t=s[e];if(this._contains(t)){let e=this._getProfileFromMap(t);a.push(e)}else if(this._isStrangerProfileExpired(t))i.push(t);else{let e=this.strangerProfileMap.get(t);a.push(e)}}if(0===i.length)return Se.l(n+" from cache, total:"+a.length),ai(a);i.length>this.MAX_USER_COUNT&&(Se.w(n+" "+At(this.MAX_USER_COUNT)),i.length=this.MAX_USER_COUNT);let o=[],l=this._userM.getMyAccount(),d=(this._chunkUserIDList(i,this.CHUNK_SIZE).forEach(e=>{o.push(this._getUserProfile({...t,userIDList:e,fromAccount:l}))}),i.length),u=new Ei("getUserProfile"),c=(u.setMessage(5<d?"count:"+d:"userIDList:"+i),Date.now());return Promise.allSettled(o).then((e=[])=>{let t=[],i=0,o={};e.forEach(s=>{if("fulfilled"===s.status&&Ve(s.value)&&(i+=s.value.length,t.push(...s.value)),"rejected"===s.status){let{code:e,message:t}=s.reason||{};o.code=e,o.message=t}});var e=d-i,s=`query:${d} success:${i} fail:${e} from cache:`+a.length;return 0!==a.length||d!==e||Ge(o)?(t.push(...a),u.setMoreMessage(s+" total:"+t.length).end(),Se.l(`${n} ${s} total:${t.length} cost:`+Ot(c)),si(r?t[0]:t)):(u.setMoreMessage(s+" error:"+JSON.stringify(o)).end(),Se.e(`${n} ${s} error:${JSON.stringify(o)} cost:`+Ot(c)),ci(o))})}_isStrangerProfileExpired(e){return!!this._userM.isMyFriend(e)||({lastUpdatedTime:e=0}=this.strangerProfileMap.get(e)||{},Date.now()-e>1e3*this.strangerProfileExpirationTime)}_getUserProfile(e){let t=this._n+"._getUserProfile",s=e["userIDList"],i=[];return s.forEach(e=>{i.push({toAccount:e,standardSequence:0,customSequence:0})}),e.userItem=i,this._userM.req({P:ui.GET_USER_PROFILE,data:e}).then(e=>this._handleResponse(e)).catch(e=>(Se.e(t+" failed. error:",e),ci(e)))}getMyProfile(){var e,t=this._userM.getMyAccount(),s=this._n+".getMyProfile";return Se.l(s+" myAccount:"+t),this._fill(),this._contains(t)?(e=this._getProfileFromMap(t),Se.d(s+" from cache, myProfile:"+JSON.stringify(e)),ai(e)):this.getUserProfile({fromAccount:t,userIDList:[t],bFromGetMyProfile:!0})}_handleResponse(e){var i,o=e.data["userProfileItem"];if(!Ve(o))return[];let n=[],t=Date.now();for(let s=0,e=o.length;s<e;s++){let{to:e,profileItem:t}=o[s];"@TLS#NOT_FOUND"!==e&&""!==e&&(i=this._update(e,this._getLatestProfileFromResponse(e,t))["latestProfile"],n.push(i))}return Se.l(this._n+"._handleResponse cost:"+Ot(t)),n}_getLatestProfileFromResponse(e,s){var i={userID:e,profileCustomField:[]};if(!Ge(s))for(let e=0,t=s.length;e<t;e++)if(-1<s[e].tag.indexOf("Tag_Profile_Custom"))i.profileCustomField.push({key:s[e].tag,value:s[e].value});else switch(s[e].tag){case De.NICK:i.nick=s[e].value;break;case De.GENDER:i.gender=s[e].value;break;case De.BIRTHDAY:i.birthday=s[e].value;break;case De.LOCATION:i.location=s[e].value;break;case De.SELFSIGNATURE:i.selfSignature=s[e].value;break;case De.ALLOWTYPE:i.allowType=s[e].value;break;case De.LANGUAGE:i.language=s[e].value;break;case De.AVATAR:i.avatar=s[e].value;break;case De.MESSAGESETTINGS:i.messageSettings=s[e].value;break;case De.ADMINFORBIDTYPE:i.adminForbidType=s[e].value;break;case De.LEVEL:i.level=s[e].value;break;case De.ROLE:i.role=s[e].value;break;default:Se.w(this._n+"._getLatestProfileFromResponse unknown tag:",s[e].tag,s[e].value)}return i}updateMyProfile(o){let n=this._n+".updateMyProfile";if(o.nick&&!1===this._userM.filterProfanity("nick",o))return ci({code:ni.PROFANITY_FOUND});if(o.selfSignature&&!1===this._userM.filterProfanity("selfSignature",o))return ci({code:ni.PROFANITY_FOUND});let r=new Ei("updateMyProfile");r.setMessage(JSON.stringify(o));var t=(new ln).validate(o);if(!t.valid)return r.setCode(ni.UPDATE_PROFILE_INVALID_PARAM).setMoreMessage("info:"+t.tips).end(),Se.e(n+" info:"+t.tips),ci({code:ni.UPDATE_PROFILE_INVALID_PARAM});let s=[];for(let e in o)Object.prototype.hasOwnProperty.call(o,e)&&("profileCustomField"===e?o.profileCustomField.forEach(e=>{s.push({tag:e.key,value:e.value})}):s.push({tag:De[e.toUpperCase()],value:o[e]}));if(0===s.length){let e=new ii({code:ni.UPDATE_PROFILE_NO_KEY});return r.setError(e).end(),Se.e(n+" failed. error:",e),ci(e)}let a=this._userM.getMyAccount();return this._userM.req({P:ui.UPDATE_MY_PROFILE,data:{fromAccount:a,profileItem:s}}).then(t=>{r.end(),Se.i(n+" ok");var{isProfileUpdated:s,latestProfile:i}=this._update(a,o);return!0===s&&this._userM.emitOEvt(e.PROFILE_UPDATED,[i]),ai(i)}).catch(e=>(r.setError(e).end(),Se.e(n+" failed. error:",e),ci(e)))}onProfileModified(s){var i=s.dataList;if(!Ge(i)){let t=i.length;Se.d(`${this._n}.onProfileModified count:${t} dataList:`,s.dataList);var o,n=[];for(let s=0;s<t;s++){o=i[s].userID;let{isProfileUpdated:e,latestProfile:t}=this._update(o,this._getLatestProfileFromResponse(o,i[s].profileList));!0===e&&n.push(t)}0<n.length&&(this._userM.emitIEvt(Qi.PROFILE_UPDATED,n),this._userM.emitOEvt(e.PROFILE_UPDATED,n))}}_fill(){if(0===this.accountProfileMap.size){var s=this._getCachedProfiles(),i=Date.now();for(let e=0,t=s.length;e<t;e++)i-s[e].lastUpdatedTime<this.expirationTime&&this.accountProfileMap.set(s[e].userID,new ln(s[e]));Se.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===rt(s.profileCustomField,t.profileCustomField)&&(s.lastUpdatedTime=o,i=!0),0<Je(s,t,["profileCustomField"])&&(s.lastUpdatedTime=o,i=!0)):((s=new ln(t)).lastUpdatedTime=o,(this._userM.isMyFriend(e)||e===this._userM.getMyAccount()?(i=!0,this.accountProfileMap):this.strangerProfileMap).set(e,s)),this._flush(e===this._userM.getMyAccount()),{isProfileUpdated:i,latestProfile:s}}_flush(e){var t=[...this.accountProfileMap.values()],s=this._userM.getStorageModule();Se.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 Ge(e)?[]:e}onConvProfileUpdated(s){var i,o,n,r=[];for(let e=0,t=s.length;e<t;e++)o=(i=s[e]).userID,this._userM.isMyFriend(o)&&(this._contains(o)?(n=this._getProfileFromMap(o),0<Je(n,i)&&r.push(o)):r.push(i.userID));0!==r.length&&(Se.l(this._n+".onConvProfileUpdated toAccountList:"+r),this.getUserProfile({userIDList:r}))}getNickAndAvatarByUserID(e){return this._contains(e)?{nick:(e=this._getProfileFromMap(e)).nick,avatar:e.avatar}:{nick:"",avatar:""}}getUserNickAndAvatar(e){var t=[...new Set(e)];Se.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._chunkUserIDList(t,this.CHUNK_SIZE),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))}_chunkUserIDList(s,i){return Array.from({length:Math.ceil(s.length/i)},(e,t)=>s.slice(t*i,(t+1)*i))}getMyLocalProfile(){var e=this._userM.getMyAccount();return this._contains(e)?this._getProfileFromMap(e):{}}reset(){this._flush(!0),this.accountProfileMap.clear(),this.strangerProfileMap.clear(),this.strangerProfileExpirationTime=600}}class Sn{constructor(e){Ge||(this.userID=e.userID||"",this.timeStamp=e.timeStamp||0)}}class En{constructor(e){this._userM=e,this._n="BlacklistHandler",this._blacklistMap=new Map,this._startIndex=0}getLocalBlacklist(){return[...this._blacklistMap.keys()]}getBlacklist(){let o=this._n+".getBlacklist",t={fromAccount:this._userM.getMyAccount(),maxLimited:1e3,startIndex:this._startIndex},n=new Ei("getBlacklist");return this._userM.req({P:ui.GET_BL,data:t}).then(t=>{var{blackListItem:t,startIndex:s}=t.data,i=Ge(t)?0:t.length;n.setMessage("count:"+i).end(),Se.i(o+" ok"),this._startIndex=s,this._handleResponse(t,!0),this._userM.emitOEvt(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]),0!==this._startIndex&&this.getBlacklist()}).catch(e=>(n.setError(e).end(),Se.e(o+" failed. error:",e),ci(e)))}addBlacklist(t){let s=new Ei("addToBlacklist"),i=this._n+".addBlacklist",o=this._userM.getMyAccount();if(1!==t.userIDList.length||t.userIDList[0]!==o)return t.userIDList.includes(o)&&(t.userIDList=t.userIDList.filter(e=>e!==o)),t.fromAccount=this._userM.getMyAccount(),t.toAccount=t.userIDList,this._userM.req({P:ui.ADD_TO_BL,data:t}).then(e=>(s.setMessage(5<t.userIDList.length?"userIDList.length:"+t.userIDList.length:"userIDList:"+t.userIDList).end(),Se.i(i+" ok"),this._handleResponse(e.resultItem,!0),si([...this._blacklistMap.keys()]))).catch(e=>(s.setError(e).end(),Se.e(i+" failed. error:",e),ci(e)));{let e=ni.CANNOT_ADD_SELF_TO_BLACKLIST,t=this._userM.getErrMsg(e);s.setCode(e).setMessage(t).end();var n=new ii({code:e});return Se.e(i+" failed. error:",n),ci(n)}}_handleResponse(n,r){if(!Ge(n)){let s,i,o;for(let e=0,t=n.length;e<t;e++)i=n[e].to,o=n[e].resultCode,!Be(o)&&0!==o||(r?((s=this._blacklistMap.has(i)?this._blacklistMap.get(i):new Sn).userID=i,Ge(n[e].addBlackTimeStamp)||(s.timeStamp=n[e].addBlackTimeStamp),this._blacklistMap.set(i,s)):this._blacklistMap.has(i)&&(s=this._blacklistMap.get(i),this._blacklistMap.delete(i)))}Se.l(`${this._n}._handleResponse total:${this._blacklistMap.size} bAdd:`+r)}deleteBlacklist(t){let s=this._n+".deleteBlacklist",i=new Ei("removeFromBlacklist");return t.fromAccount=this._userM.getMyAccount(),t.toAccount=t.userIDList,this._userM.req({P:ui.RM_FROM_BL,data:t}).then(e=>(i.setMessage(5<t.userIDList.length?"userIDList.length:"+t.userIDList.length:"userIDList:"+t.userIDList).end(),Se.i(s+" ok"),this._handleResponse(e.data.resultItem,!1),si([...this._blacklistMap.keys()]))).catch(e=>(i.setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}onAccountDeleted(s){for(let t=0,e=s.length;t<e;t++){let e=s[t];this._blacklistMap.has(e)&&this._blacklistMap.delete(e)}let t=s.length;0<t&&(Se.l(`${this._n}.onAccountDeleted count:${t} `+(t<30?"userIDList:"+s:"")),this._userM.emitOEvt(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]))}onAccountAdded(s){var i,o=[];for(let e=0,t=s.length;e<t;e++)i=s[e],this._blacklistMap.has(i)||(this._blacklistMap.set(i,new Sn({userID:i})),o.push(i));0<o.length&&(Se.l(this._n+`.onAccountAdded count:${o.length} userIDList:`,o),this._userM.emitOEvt(e.BLACKLIST_UPDATED,[...this._blacklistMap.keys()]))}reset(){this._blacklistMap.clear(),this._startIndex=0}}let Dn=function(e){var o=String(e).replace(/[=]+$/,"");let n="";if(o.length%4==1)return"";for(let e,t,s=0,i=0;t=o.charAt(i++);~t&&(e=s%4?64*e+t:t,s++%4)&&(n+=String.fromCharCode(255&e>>(-2*s&6))))t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(t);try{return decodeURIComponent(escape(n))}catch(e){return""}};class Rn{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(Qi.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");Se.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(t){let s=t["dataList"],i=this._userM.getMyUserID(),o=this._userM.get(Ns),n=s.map(e=>{var{to:e,statusType:t,customStatus:s}=e,s=Dn(s);return e===i&&o.setCustomStatus(s),{userID:e,statusType:t,customStatus:s}});Se.l(this._n+".onUserStatusUpdated list:"+JSON.stringify(n)),this._userM.emitOEvt(e.USER_STATUS_UPDATED,n)}setSelfStatus(e){let t=this._n+".setSelfStatus";if(!1===this._userM.filterProfanity("customStatus",e))return ci({code:ni.PROFANITY_FOUND});let s=new Ei("setSelfStatus"),i=e["customStatus"];return this._userM.req({P:ui.SET_SELF_STATUS,data:{customStatus:i}}).then(e=>(s.setMessage("customStatus:"+i).end(),Se.l(t+" ok. customStatus:"+i),this._userM.get(Ns).setCustomStatus(i),si({userID:this._userM.getMyUserID(),statusType:1,customStatus:i}))).catch(e=>(s.setError(e).end(),Se.e(t+" failed. error:",e),ci(e)))}getUserStatus(e){let i=this._n+".getUserStatus",{userIDList:o=[]}=e,t=this._userM.getMyUserID(),s=[...o],n=void 0;var r=s.indexOf(t);if(-1<r){s.splice(r,1);let e=this._userM.get(Ns).getCustomStatus();n={userID:t,statusType:1,customStatus:e}}if(0===s.length)return ai({successUserList:[n],failureUserList:[]});if(!this._userM.canIUse(M.USER_STATUS))return this._userM.noUse("getUserStatus");s.length>this.MAX_QUERY_USER_COUNT&&(Se.w(i+" "+At(this.MAX_QUERY_USER_COUNT)),s=o.slice(0,this.MAX_QUERY_USER_COUNT));let a=new Ei("getUserStatus");return this._userM.req({P:ui.GET_USER_STATUS,data:{userIDList:s}}).then(e=>{var{successUserList:e=[],failureUserList:t=[]}=e.data,e=e.map(e=>{var{userID:e,statusType:t,customStatus:s}=e;return{userID:e,statusType:t,customStatus:Dn(s)}}),t=t.map(e=>{var{userID:e,invalidUserID:t,errorCode:s,errorInfo:i}=e;return{userID:Ge(t)?e:t,code:s,message:i}}),s=(Be(n)||e.unshift(n),`userID count:${o.length}, success count:${e.length}, fail count:`+t.length);return a.setMessage(s).end(),Se.l(i+` ok. ${s}.`),si({successUserList:e,failureUserList:t})}).catch(e=>(a.setMessage("userID count:"+o.length).setError(e).end(),Se.e(i+" failed. error:",e),ci(e)))}subscribeUserStatus(e){var t="subscribeUserStatus";if(!this._userM.canIUse(M.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&&(Se.w(s+" "+At(this.MAX_SUBSCRIBE_USER_COUNT)),o=i.slice(0,this.MAX_SUBSCRIBE_USER_COUNT)),new Ei(t)),r="userID count:"+i.length;return Se.l(s+" "+r),this._userM.req({P:ui.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:Ge(t)?e:t,code:s,message:i}});return n.setMessage(r+" fail count:"+e.length).end(),Se.l(s+` ok. fail count:${e.length}.`),si({failureUserList:e})}).catch(e=>(n.setMessage(r).setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}unsubscribeUserStatus(e){var t="unsubscribeUserStatus";if(!this._userM.canIUse(M.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&&(Se.w(s+" "+At(this.MAX_UNSUBSCRIBE_USER_COUNT)),o=i.slice(0,this.MAX_UNSUBSCRIBE_USER_COUNT)),new Ei(t)),r="userID count:"+i.length;Se.l(s+" "+r);e={userIDList:o};return 0===o.length&&(e.userIDList=void 0,e.unsubscribeAll=1),this._userM.req({P:ui.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:Ge(t)?e:t,code:s,message:i}});return n.setMessage(r+" fail count:"+e.length).end(),Se.l(s+` ok. fail count:${e.length}.`),si({failureUserList:e})}).catch(e=>(n.setMessage(r).setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}reset(){this.MAX_QUERY_USER_COUNT=500,this.MAX_SUBSCRIBE_USER_COUNT=100,this.MAX_UNSUBSCRIBE_USER_COUNT=100}}class Ln extends li{constructor(e){super(e),this._n="UserModule",this._profileHandler=new vn(this),this._blacklistHandler=new En(this),this._userStatusHandler=new Rn(this),this.getIEmitInst().on(Qi.A2KEY_AND_TINYID_UPDATED,this.onContextUpdated,this)}onContextUpdated(e){this._profileHandler.getMyProfile(),this._blacklistHandler.getBlacklist()}mockOnNickAvatarModified(e,t){Se.l(this._n+`._mockOnNickAvatarModified nick:${e} avatar:`+t),this.onProfileModified({dataList:[{pushType:1,userID:this.getMyUserID(),profileList:[{tag:De.NICK,value:e},{tag:De.AVATAR,value:t}]}]})}onProfileModified(e){this._profileHandler.onProfileModified(e)}onRelationChainModified(e){e=e.dataList;if(!Ge(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}getMyLevel(){return this._profileHandler.getMyLocalProfile().level||0}getMyProfile(){return this._profileHandler.getMyProfile()}getStorageModule(){return this.get(Ps)}filterProfanity(e,t){var s,i=this.get(Ws);return!i||({isAllowedToSend:i,modifiedText:s}=i.filterText(t[e],v),!0===i&&(t[e]=s,!0))}isMyFriend(e){var t=this.get(Ls);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 ai(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(){Se.l(this._n+".reset"),this._profileHandler.reset(),this._blacklistHandler.reset(),this._userStatusHandler.reset()}}class An{constructor(e,t){this._m=e,this._isLoggedIn=!1,this._SDKAppID=t.SDKAppID,this._userID=t.userID||"",this._userSig=t.userSig||"",this._version="3.6.5",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 le?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 s=!1,t=!1,e=!1,i=!1,o=[];$&&(o=Object.keys(B));for(let e=0,t=(o=V?F?Object.keys(uni):Object.keys(window):o).length;e<t;e++)if(o[e].toLowerCase().includes("uikit")){s=!0;break}if(o=null,$&&!He(B.createGamePortal)&&He(getApp)&&!Be(getApp())){let e=getApp().globalData;xe(e)&&!0===e.isTUIKit&&(t=!0)}!0===this._m.get(Ps).getStorageSync(`TIM_${this._SDKAppID}_isTUIKit`)&&(e=!0);let n=null;if(A&&!P&&"undefined"==typeof uni&&__wxConfig&&(n=__wxConfig.pages),N&&"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 s||t||e||i}reset(){this._isLoggedIn=!1,this._userSig="",this._a2Key="",this._tinyID="",this._customStatus="",this._statusInstanceID=0}}let On={"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 Nn extends li{constructor(e){super(e),this._n="SignModule",this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0,tn.mixin(this)}onCheckTimer(e){this.isLoggedIn()&&e%this._helloInterval==0&&this._hello()}getPushModule(){let e=void 0;var t=this.get(Qs),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))&&Se.w(s),ai({actionStatus:"OK",errorCode:0,errorInfo:s,repeatLogin:!0})}if(Date.now()-this._lastLoginTs<=15e3)return this.warn("LoggingIn",e.userID),ci({code:ni.REPEAT_LOGIN});Se.l(this._n+".login userID:"+e.userID);var t,s=this._checkLoginInfo(e);return 0!==s.code?ci(s):({userID:s,userSig:e}=e,(t=this.get(Ns)).setUserID(s),t.setUserSig(e),this.get(Fs).updateProtocolConfig(),this._login())}_login(){let g=this.get(Ns),m=g.getScene(),t=0,e=m,f=(m&&m.startsWith("k-")&&(e=On[m],m="tuikit"),new Ei("login"));f.setMessage(""+e).setMoreMessage("identifier:"+this.getMyUserID());var s="tuikit"===m;let i=0;F?i=s?3===e||4===e||5===e||6===e?31:9===e||10===e||11===e||12===e?32:4:3:$?i=O?36:"tuikit"===m?12:11:V?i=le?"flutter_web_uikit"===m?21:20:this._isReactUIKit()?ce?25:24:s?1===e||2===e?29:7===e||8===e?30:ce?17:14:ce?16:13:13===e&&(i=38),f.setUIPlatform(i),g.setUIPlatform(i);s=this.getPushModule();if(s){this._isWebUniapp=s.getUniAppPlatform();let e=this._getStatusInstanceID();g.setStatusInstanceID(e),this.get(Fs).updateProtocolConfig(),t=s.getDeviceBrand()}let M=this._n+"._login";return this._lastLoginTs=Date.now(),this.req({P:ui.LOGIN,data:{deviceBrand:t,isWebUniapp:this._isWebUniapp,customInfo:g.getCustomLoginInfo()}}).then(e=>{this._lastLoginTs=0;var t=Date.now();let s=null;var{a2Key:i,tinyID:o,helloInterval:n,instanceID:r,timeStamp:a,customStatus:l="",purchaseBits:d,authKey:u=""}=e.data,c=1e3*a,_=t-f.getStartTs(),_=c+parseInt(_/2)-t,t=f.getStartTs()+_,t=(f.start(t),c),c=_;if(fe=c,(c=new Date).setTime(t),Se.i(`baseTime from server:${c} offset:`+fe),!o)throw s=new ii({code:ni.NO_TINYID}),f.setError(s).end(),s;if(!i)throw s=new ii({code:ni.NO_A2KEY}),f.setError(s).end(),s;t=this.get($s).getSocketID(),c=Dn(l),l=`socketID:${t} scene:${m} helloInterval:${n} instanceID:${r} timeStamp:${a} offset:${_} customStatus:${c} isWebUniapp:`+this._isWebUniapp;Se.l(M+" ok. "+l);let h="",p="";if(A&&He(B.getAccountInfoSync)){let e=B.getAccountInfoSync().miniProgram;e&&(h=e.appId,p=e.envVersion)}f.setMoreMessage(l+` href:${V?window.location.href:""} mpAppId:${h} envVersion:${p} authKey:`+u).end(),g.setA2Key(i),g.setTinyID(o),g.setStatusInstanceID(r),g.setCustomStatus(c),g.setDowloadFileAuthKey(u),d&&this.get(Ks).onPushedConfig({errorCode:0,expiredTime:0,purchaseBits:d}),this.get(Fs).updateProtocolConfig(),this.emitIEvt(Qi.A2KEY_AND_TINYID_UPDATED),this._helloInterval=n,this.triggerReady();t=this.getPushModule();return t&&(uni.setStorageSync("timUniAppInstanceID",r),t.init()),this._fetchCloudControlConfig(),this.get(Ws).init(),e}).catch(e=>(f.setError(e).end(!0),this._m.setNotReadyReason(ni.LOGIN_FAILED),Se.e(M+" failed. error:",e),this._lastLoginTs=0,this._m.onLoginFailed(),ci(e)))}logout(e=0){let t=this._n+".logout",s=this.isLoggedIn();return Se.i(t+` type:${e} isLoggedIn:${s} isWebUniapp:`+this._isWebUniapp),s?(new Ei("logout").setMessage("identifier:"+this.getMyUserID()).end(!0),0===e&&this._m.setNotReadyReason(ni.LOGGED_OUT),this.req({P:ui.LOGOUT,data:{type:e,isWebUniapp:this._isWebUniapp}}).then(()=>(this.resetReady(),ai({}))).catch(e=>(Se.e(t+" error:",e),this.resetReady(),ai({})))):ci({code:ni.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:ui.HELLO,data:{isWebUniapp:this._isWebUniapp}}).catch(e=>{Se.w(this._n+"._hello error:",e)})}getLastWsHelloTs(){return this._lastWsHelloTs}_checkLoginInfo(e){let t=0;return Ge(this.get(Ns).getSDKAppID())?t=ni.NO_SDKAPPID:Ge(e.userID)?t=ni.NO_IDENTIFIER:Ge(e.userSig)&&(t=ni.NO_USERSIG),{code:t}}_isReactUIKit(){return V&&void 0!==window.tencent_cloud_im_csig_react_uikit_23F_xa}onMultipleAccountKickedOut(s){new Ei("kickedOut").setMessage(`type:${t.KICKED_OUT_MULT_ACCOUNT} newInstanceInfo:`+JSON.stringify(s)).end(!0),Se.w(`${this._n}.onMultipleAccountKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,s),this.logout(1).then(()=>{this.emitOEvt(e.KICKED_OUT,{type:t.KICKED_OUT_MULT_ACCOUNT}),this._m.setNotReadyReason(ni.KICKED_OUT_MULT_ACCOUNT),this._m.reset()})}onMultipleDeviceKickedOut(s){new Ei("kickedOut").setMessage(`type:${t.KICKED_OUT_MULT_DEVICE} newInstanceInfo:`+JSON.stringify(s)).end(!0),Se.w(`${this._n}.onMultipleDeviceKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,s),this.logout(1).then(()=>{this.emitOEvt(e.KICKED_OUT,{type:t.KICKED_OUT_MULT_DEVICE}),this._m.setNotReadyReason(ni.KICKED_OUT_MULT_DEVICE),this._m.reset()})}onUserSigExpired(){new Ei("kickedOut").setMessage(t.KICKED_OUT_USERSIG_EXPIRED).end(!0),Se.w(this._n+".onUserSigExpired userID:"+this.getMyUserID()),0!==this.get(Ns).getStatusInstanceID()&&(this.emitOEvt(e.KICKED_OUT,{type:t.KICKED_OUT_USERSIG_EXPIRED}),this._m.setNotReadyReason(ni.KICKED_OUT_USERSIG_EXPIRED),this._m.reset())}onRestApiKickedOut(s){new Ei("kickedOut").setMessage(`type:${t.KICKED_OUT_REST_API} newInstanceInfo:`+JSON.stringify(s)).end(!0),Se.w(`${this._n}.onRestApiKickedOut userID:${this.getMyUserID()} newInstanceInfo:`,s),0!==this.get(Ns).getStatusInstanceID()&&(this.emitOEvt(e.KICKED_OUT,{type:t.KICKED_OUT_REST_API}),this._m.setNotReadyReason(ni.KICKED_OUT_REST_API),this._m.reset(),this.get($s).onRestApiKickedOut())}reset(){Se.l(this._n+".reset"),this.resetReady(),this._helloInterval=120,this._lastLoginTs=0,this._lastWsHelloTs=0,this._isWebUniapp=0}}function Pn(){return null}class Un{constructor(e){this._m=e,this._n="StorageModule",this._storageQueue=new Map,this._errorTolerantHandle()}_errorTolerantHandle(){$||"undefined"!=typeof window&&this._canIUseCookies()||(this.getItem=Pn,this.setItem=Pn,this.removeItem=Pn,this.clear=Pn)}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){Se.w(this._n+"._doFlush error:",e)}}_getPrefix(){var e=this._m.get(Ns);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 Se.w(this._n+".getItem error:",e),{}}}setItem(t,s,e=!1,i=!0){if(e){let e=i?this._getKey(t):t;this._setStorageSync(e,s)}else this._storageQueue.set(t,s)}clear(){try{$?B.clearStorageSync():this._canIUseCookies()&&localStorage.clear()}catch(e){Se.w(this._n+".clear error:",e)}}removeItem(e,t=!0){try{var s=t?this._getKey(e):e;this._removeStorageSync(s)}catch(e){Se.w(this._n+".removeItem error:",e)}}getSize(e,s="b"){try{let t={size:0,limitSize:5242880,unit:s};if(Object.defineProperty(t,"leftSize",{enumerable:!0,get:()=>t.limitSize-t.size}),$&&(t.limitSize=1024*B.getStorageInfoSync().limitSize),e)t.size=JSON.stringify(this.getItem(e)).length+this._getKey(e).length;else if($){let e=B.getStorageInfoSync()["keys"];e.forEach(e=>{t.size+=JSON.stringify(this.getStorageSync(e)).length+this._getKey(e).length})}else if(this._canIUseCookies())for(let e in localStorage)localStorage.hasOwnProperty(e)&&(t.size+=localStorage.getItem(e).length+e.length);return this._convertUnit(t)}catch(e){Se.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){$?G?my.setStorageSync({key:e,data:t}):B.setStorageSync(e,t):this._canIUseCookies()&&localStorage.setItem(e,JSON.stringify(t))}getStorageSync(e){return $?G?my.getStorageSync({key:e}).data:B.getStorageSync(e):this._canIUseCookies()?JSON.parse(localStorage.getItem(e)):{}}_removeStorageSync(e){$?G?my.removeStorageSync({key:e}):B.removeStorageSync(e):this._canIUseCookies()&&localStorage.removeItem(e)}_canIUseCookies(){return"undefined"!=typeof window&&navigator&&navigator.cookieEnabled&&localStorage}reset(){Se.l(this._n+".reset"),this._doFlush()}}class Gn{constructor(e){this._n="SSOLogBody",this._report=[]}pushIn(e){Se.d(this._n+".pushIn",this._report.length,e),this._report.push(e)}backfill(e){Ve(e)&&0!==e.length&&(Se.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 kn=function(e){var t=e.get(Ns);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 wn extends li{constructor(e){super(e),this._n="EventStatModule",this.TAG="im-ssolog-event",this._reportBody=new Gn,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(Qi.A2KEY_AND_TINYID_UPDATED,this._onLoginSuccess,this),e.on(Qi.CLOUD_CONFIG,this._onCloudConfig,this)}reportAtOnce(){this._report()}_onLoginSuccess(){var e=this.get(Ps),t=e.getItem(this.TAG,!1);!Ge(t)&&He(t.forEach)&&(Se.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(Ns),s=t.getSDKAppID(),t=t.getTinyID();return vt(this.REPORT_SDKAPPID_BLACKLIST,s)&&!St(this.REPORT_TINYID_WHITELIST,t)?[]:e.filter(e=>this.REPORT_LEVEL.includes(e.level))}_report(){if(!this._reportBody.isEmpty()){let t=this._reportBody.getLogsInMemory(),e=this._filterLogs(t);var s;0===e.length?this._lastReportTime=Date.now():(s={header:kn(this),event:e},this.req({P:ui.SSO_STAT,data:{...s}}).then(()=>{this._lastReportTime=Date.now()}).catch(e=>{Se.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 t=this.get(Ps),s=t.getItem(this.TAG,!1),i=this._reportBody.getLogsInMemory(),o=this._n+"._flushAtOnce";if(Ge(s))Se.l(o+" count:"+i.length),t.setItem(this.TAG,i,!0,!1);else{let e=i.concat(s);e.length>this.MAX_THRESHOLD&&(e=e.slice(0,this.MAX_THRESHOLD)),Se.l(o+" count:"+e.length),t.setItem(this.TAG,e,!0,!1)}}reset(){Se.l(this._n+".reset"),this._lastReportTime=0,this._report(),this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[]}}let bn="none",Fn="online";class $n{constructor(e){this._m=e,this._networkType=Fn,this._n="NetMonitorModule",this._mpNetworkStatusCallback=null,this._webOnlineCallback=null,this._webOfflineCallback=null,this._removeListener=null,this._m.getIEmitInst().on(Qi.A2KEY_AND_TINYID_UPDATED,this._startRN,this)}_startRN(){var e;x&&(e=this._m.get(ws).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 t=this._n+".start";$?(B.getNetworkType({success:e=>{this._networkType=e.networkType||e.subtype||"",e.networkType===bn?Se.w(t+" no network, please check!"):Se.i(t+" networkType:"+e.networkType)}}),this._mpNetworkStatusCallback=this._onNetworkStatusChange.bind(this),B.onNetworkStatusChange(this._mpNetworkStatusCallback)):V&&(this._networkType=Fn,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:Fn})}_onWebOffline(){this._onNetworkStatusChange({isConnected:!1,networkType:bn})}_onNetworkStatusChange(e){var{isConnected:e,networkType:t}=e,s=this._n+"._onNetworkStatusChange";let i=!1;var o=`previous:${this._networkType} current:`+t;e?(Se.i(s+" "+o),this._networkType!==t&&(i=!0,this._networkType=t,this._m.get($s).reConnect(!0))):this._networkType!==t&&(i=!0,this._networkType=t,Se.w(s+" no network, please check!"),this._m.get($s).offline()),i&&new Ei("networkChange").setMessage(`isConnected:${e} `+o).end()}isOnline(){return this._networkType!==bn}getNetworkType(){return this._networkType}reset(){Se.l(this._n+".reset"),$?null!==this._mpNetworkStatusCallback&&(B.offNetworkStatusChange&&B.offNetworkStatusChange(this._mpNetworkStatusCallback),this._mpNetworkStatusCallback=null):V?(null!==this._webOnlineCallback&&(window.removeEventListener("online",this._webOnlineCallback),this._webOnlineCallback=null),null!==this._onWebOffline&&(window.removeEventListener("offline",this._webOfflineCallback),this._webOfflineCallback=null)):x&&this._removeListener&&(this._removeListener(),this._removeListener=null)}}function qn(e,t){return e(t={exports:{}},t.exports),t.exports}var xn=qn(function(e){var i=Object.prototype.hasOwnProperty,h="~";function s(){}function n(e,t,s){this.fn=e,this.context=t,this.once=s||!1}function o(e,t,s,i,o){if("function"!=typeof s)throw new TypeError("The listener must be a function");s=new n(s,i||e,o),i=h?h+t:t;return e._events[i]?e._events[i].fn?e._events[i]=[e._events[i],s]:e._events[i].push(s):(e._events[i]=s,e._eventsCount++),e}function l(e,t){0==--e._eventsCount?e._events=new s:delete e._events[t]}function t(){this._events=new s,this._eventsCount=0}Object.create&&(s.prototype=Object.create(null),(new s).__proto__||(h=!1)),t.prototype.eventNames=function(){var e,t,s=[];if(0===this._eventsCount)return s;for(t in e=this._events)i.call(e,t)&&s.push(h?t.slice(1):t);return Object.getOwnPropertySymbols?s.concat(Object.getOwnPropertySymbols(e)):s},t.prototype.listeners=function(e){var e=h?h+e:e,t=this._events[e];if(!t)return[];if(t.fn)return[t.fn];for(var s=0,i=t.length,o=new Array(i);s<i;s++)o[s]=t[s].fn;return o},t.prototype.listenerCount=function(e){e=h?h+e:e,e=this._events[e];return e?e.fn?1:e.length:0},t.prototype.emit=function(e,t,s,i,o,n){var r=h?h+e:e;if(!this._events[r])return!1;var a,l=this._events[r],d=arguments.length;if(l.fn){switch(l.once&&this.removeListener(e,l.fn,void 0,!0),d){case 1:return l.fn.call(l.context),!0;case 2:return l.fn.call(l.context,t),!0;case 3:return l.fn.call(l.context,t,s),!0;case 4:return l.fn.call(l.context,t,s,i),!0;case 5:return l.fn.call(l.context,t,s,i,o),!0;case 6:return l.fn.call(l.context,t,s,i,o,n),!0}for(_=1,a=new Array(d-1);_<d;_++)a[_-1]=arguments[_];l.fn.apply(l.context,a)}else for(var u,c=l.length,_=0;_<c;_++)switch(l[_].once&&this.removeListener(e,l[_].fn,void 0,!0),d){case 1:l[_].fn.call(l[_].context);break;case 2:l[_].fn.call(l[_].context,t);break;case 3:l[_].fn.call(l[_].context,t,s);break;case 4:l[_].fn.call(l[_].context,t,s,i);break;default:if(!a)for(u=1,a=new Array(d-1);u<d;u++)a[u-1]=arguments[u];l[_].fn.apply(l[_].context,a)}return!0},t.prototype.on=function(e,t,s){return o(this,e,t,s,!1)},t.prototype.once=function(e,t,s){return o(this,e,t,s,!0)},t.prototype.removeListener=function(e,t,s,i){e=h?h+e:e;if(this._events[e])if(t){var o=this._events[e];if(o.fn)o.fn!==t||i&&!o.once||s&&o.context!==s||l(this,e);else{for(var n=0,r=[],a=o.length;n<a;n++)(o[n].fn!==t||i&&!o[n].once||s&&o[n].context!==s)&&r.push(o[n]);r.length?this._events[e]=1===r.length?r[0]:r:l(this,e)}}else l(this,e);return this},t.prototype.removeAllListeners=function(e){return e?(e=h?h+e:e,this._events[e]&&l(this,e)):(this._events=new s,this._eventsCount=0),this},t.prototype.off=t.prototype.removeListener,t.prototype.addListener=t.prototype.on,t.prefixed=h,e.exports=t.EventEmitter=t});let Vn=["rich.my-imcloud.com","imrich.qcloud.com"],Bn=9999,Kn=1e4;class Hn 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=!this.isPrivateNetWork(),this._fileDownloadProxy="",this._authKey="",this._fileDNList=Vn;e=this.getIEmitInst();e.on(Qi.A2KEY_AND_TINYID_UPDATED,this._init,this),e.on(Qi.CLOUD_CONFIG,this._onCloudConfig,this)}_init(){this._fileDownloadProxy=this.getFileDownloadProxy(),this._authKey=this.getDownloadFileAuthKey();var e,t=this.get(ws);this.TIMUploadPlugin=t.getPlugin("tim-upload-plugin"),this.TIMUploadPlugin?this._initUploaderMethod():(e=$?"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(Se.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 s=this._n+"._getAuthorizationKey",i=new Ei("_getAuthorizationKey"),o=Math.ceil(Date.now()/1e3);this.req({P:ui.COS_SIGN,data:{duration:this.expiredTimeLimit}}).then(e=>{var e=e["data"],t=(Se.l(s+" ok. data:",e),e.expiredTime-o);i.setMessage(`requestId:${e.requestId} requestTime:${o} expiredTime:${e.expiredTime} diff:${t}s`).end(),!$&&e.region&&(this.region=e.region),this.appid=e.appid,this.bucketName=e.bucketName,this.ciUrl=e.ciUrl,this.directory=e.directory,this.downloadUrl=e.downloadUrl,this.uploadUrl=e.uploadUrl,this.cosOptions={secretId:e.secretId,secretKey:e.secretKey,sessionToken:e.sessionToken,expiredTime:e.expiredTime},Se.l(s+` ok. region:${this.region} bucketName:`+this.bucketName),this._initUploaderMethod()}).catch(e=>{i.setError(e).end(),Se.w(s+" failed. error:",e)})}_getCosPreSigUrl(t){let o=this._n+"._getCosPreSigUrl",n=Math.ceil(Date.now()/1e3),r=new Ei("_getCosPreSigUrl"),e={uploadMethod:t.uploadMethod,platform:this.getPlatform(),SDKAppID:this.getSDKAppID(),userID:t.userID,conversationType:t.conversationType,uploadConfig:[{fileID:1,fileType:t.fileType,fileName:t.fileName}]},s=ui.SIMPLE_COS_PRE_SIG;return this.isSimpleCos||(e={fileType:t.fileType,fileName:t.fileName,uploadMethod:t.uploadMethod,duration:t.duration},s=ui.COS_PRE_SIG),this.req({P:s,data:e}).then(e=>{this.tryCount=0;var s=e.data||{};Se.l(`${o} ok. isSimpleCos:${this.isSimpleCos} data:`,s);let i="";if(this.isSimpleCos){let{uploadUrl:e,fileKey:t}=s.preSig[0];i=`uploadIP:${s.uploadIP} uploadUrl:${e} fileKey:${t} cost:`+Ot(n)}else i=`requestId:${s.requestId} expiredTime:${s.expiredTime} diff:${s.expiredTime-n}s`;return r.setMessage(i).end(),s}).catch(e=>(-1===e.code&&(e.code=ni.COS_GET_SIG_FAIL),r.setError(e).end(),Se.w(o+" failed. error:",e),this.tryCount<1?(this.tryCount++,this._getCosPreSigUrl(t)):(this.tryCount=0,ci({code:ni.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=$?new this.COSSDK({ForcePathStyle:!0,getAuthorization:this._getAuthorization.bind(this)}):new this.COSSDK({getAuthorization:this._getAuthorization.bind(this)}),this._cosUploadMethod=$?(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 s=this.get(Bs);switch(e.type){case t.MSG_IMAGE:return s.addTotalCount(fi),this._uploadImage(e);case t.MSG_FILE:return s.addTotalCount(fi),this._uploadFile(e);case t.MSG_AUDIO:return s.addTotalCount(fi),this._uploadAudio(e);case t.MSG_VIDEO:return s.addTotalCount(fi),this._uploadVideo(e);default:return Promise.resolve()}}_uploadImage(g){let e=this.get(vs),m=g.getElements()[0],t=e.getMessageOption(g.clientSequence);return this.doUploadImage({file:t.payload.file,customFileName:t.payload.customFileName,to:t.to,message:g,onProgress:e=>{if(m.updatePercent(e),He(t.onProgress))try{t.onProgress(e)}catch(e){return ci({code:ni.MSG_ONPROGRESS_ERR})}}}).then(e=>{var{location:e,fileType:t,fileSize:s,width:i,height:o,smallImageUrl:n,smallImageWidth:r,smallImageHeight:a,largeImageUrl:l,largeImageWidth:d,largeImageHeight:u,imageInfoArray:c}=e,e=this.isPrivateNetWork()?e:ot(e);m.updateImageFormat(t);let _,h,p={size:s,url:e,width:i,height:o};if(c&&0<c.length)for(let t=0;t<c.length;t++){let e=c[t];1===e.type?_=e:2===e.type?h=e:p={...p,...e}}else h=n&&l?(_={url:n,width:r,height:a},{url:l,width:d,height:u}):(_=It({originUrl:e,originWidth:i,originHeight:o,min:198}),It({originUrl:e,originWidth:i,originHeight:o,min:720}));return m.updateImageInfoArray([{...p},{...h},{..._}]),g})}_uploadFile(e){let t=this.get(vs),o=e.getElements()[0],s=t.getMessageOption(e.clientSequence);return this.doUploadFile({file:s.payload.file,customFileName:s.payload.customFileName,to:s.to,message:e,onProgress:e=>{if(o.updatePercent(e),He(s.onProgress))try{s.onProgress(e)}catch(e){return ci({code:ni.MSG_ONPROGRESS_ERR})}}}).then(({location:t})=>{let s=t,i=t;if(!this.isPrivateNetWork()){let e=ot(t);s=Ri(e,this._fileDownloadProxy,this._authKey,this._fileDNList),i=Ri(e,void 0,this._authKey,this._fileDNList)}return o.updateFileUrl(s,i),e})}_uploadAudio(t){let e=this.get(vs),s=t.getElements()[0],i=e.getMessageOption(t.clientSequence);return this.doUploadAudio({file:i.payload.file,customFileName:i.payload.customFileName,to:i.to,message:t,onProgress:e=>{if(s.updatePercent(e),He(i.onProgress))try{i.onProgress(e)}catch(e){return ci({code:ni.MSG_ONPROGRESS_ERR})}}}).then(({location:e})=>{e=this.isPrivateNetWork()?e:ot(e);return s.updateAudioUrl(e),t})}_uploadVideo(s){let e=this.get(vs),i=s.getElements()[0],t=e.getMessageOption(s.clientSequence);return this.doUploadVideo({file:t.payload.file,customFileName:t.payload.customFileName,to:t.to,message:s,onProgress:e=>{if(i.updatePercent(e),He(t.onProgress))try{t.onProgress(e)}catch(e){return ci({code:ni.MSG_ONPROGRESS_ERR})}}}).then(e=>{var{location:e,snapshotInfo:t}=e,e=this.isPrivateNetWork()?e:ot(e);return i.updateVideoUrl(e),Ge(t)||i.updateSnapshotInfo(t),s})}_checkSizeError(e){let t="";return"A"===e?t="audio":"I"===e?t="image":"V"===e?t="video":"F"===e&&(t="file"),ci({code:ni[`MSG_${e}_SIZE_LIMIT`],message:this.getErrMsg("UploadSizeLimit",t,this.UPLOAD_SIZE_LIMIT[e]/1048576+"MB")})}doUploadImage(s){if(!s.file||this._isEmptyFileList(s.file.files))return ci({code:ni.MSG_I_SELECT_F_FIRST});var e=this._checkImageType(s.file);if(!0!==e)return e;e=this._checkImageSize(s.file);if(!0!==e)return e;let i=null;return this._setUploadFileType(on),this.uploadByCOS(s).then(e=>{if(i=e,this.isPrivateNetWork())return gt(e.location);if(Ve(i.imageInfoArray)){let e=i.imageInfoArray.find(e=>3===e.type);if(e)return e}if(x)return{width:s.file.width,height:s.file.height};let t=ot(e.location);return gt(t=this.COSSDK?t:Ri(t,this._fileDownloadProxy,this._authKey,this._fileDNList))}).then(e=>(i.width=e.width,i.height=e.height,Promise.resolve(i)))}_checkImageType(e){var t="",t=$?e.url.slice(e.url.lastIndexOf(".")+1):x?e.type.split("/")[1]:e.files[0].name.slice(e.files[0].name.lastIndexOf(".")+1);return 0<=sn.indexOf(t.toLowerCase())||ci({code:ni.MSG_I_TYPES_LIMIT})}_checkImageSize(e){return 0===(e=($||x?e:e.files[0]).size)?ci({code:ni.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:ni.MSG_F_SELECT_F_FIRST},ci(t)):e.file.files[0].size>this.UPLOAD_SIZE_LIMIT.F?this._checkSizeError("F"):0===e.file.files[0].size?(t={code:ni.MSG_F_IS_EMPTY},ci(t)):(this._setUploadFileType(cn),this.uploadByCOS(e))}doUploadVideo(e){return e.file.videoFile.size>this.UPLOAD_SIZE_LIMIT.V?this._checkSizeError("V"):0===e.file.videoFile.size?ci({code:ni.MSG_F_IS_EMPTY}):-1===nn.indexOf(e.file.videoFile.type)?ci({code:ni.MSG_V_TYPES_LIMIT}):(this._setUploadFileType(rn),$||x?this.handleVideoUpload({...e,file:e.file.videoFile}):V?this.handleVideoUpload(e):void 0)}handleVideoUpload(s){return new Promise((t,e)=>{this.uploadByCOS(s).then(e=>{t(e)}).catch(()=>{this.uploadByCOS(s).then(e=>{t(e)}).catch(()=>{e(new ii({code:ni.MSG_V_UPLOAD_FAIL}))})})})}doUploadAudio(e){return e.file?e.file.size>this.UPLOAD_SIZE_LIMIT.A?this._checkSizeError("A"):0===e.file.size?ci({code:ni.MSG_F_IS_EMPTY}):(this._setUploadFileType(an),this.uploadByCOS(e)):ci({code:ni.MSG_A_UPLOAD_FAIL})}uploadByCOS(t){if(!He(this._cosUploadMethod))return this.warn("PluginUndetected"),ci({code:ni.COS_UNDETECTED});if(this.timUploadPlugin)return this._uploadWithPreSigUrl(t);let l=new Ei("upload"),d=this._n+".uploadByCOS",u=Date.now(),c=this._getFile(t);return new Promise((n,r)=>{let e=$?this._createCosOptionsWXMiniApp(t):this._createCosOptionsWeb(t),a=this;this._cosUploadMethod(e,(s,i)=>{var o=Object.create(null);if(i){if(s||Ve(i.files)&&i.files[0].error){let e=new ii({code:ni.MSG_F_UPLOAD_FAIL});return l.setError(e).end(),Se.l(d+" failed. error:",i.files[0].error),403===i.files[0].error.statusCode&&this._getAuthorizationKey(),void r(e)}o.fileName=c.name,o.fileSize=c.size,o.fileType=c.type.slice(c.type.indexOf("/")+1).toLowerCase(),o.location=($?i:i.files[0].data).Location;let e=Date.now()-u,t=`size:${a._formatFileSize(c.size)} time:${e}ms speed:`+a._formatSpeed(1e3*c.size/e);Se.l(d+` success. name:${c.name} `+t),n(o);i=this.get(Bs);i.addCost(fi,e),i.addFileSize(fi,c.size),void l.setMessage(t).end()}else{let e=new ii({code:ni.MSG_F_UPLOAD_FAIL});l.setError(e).end(),Se.w(d+" failed. error:",s),403===s.statusCode&&this._getAuthorizationKey(),r(e)}})})}_uploadWithPreSigUrl(e){let l=this._n+"._uploadWithPreSigUrl",d=this._getFile(e);return this._createCosOptionsPreSigUrl(e).then(a=>new Promise((e,o)=>{let n=new Ei("upload"),{existFlag:t,...s}=a,r=Date.now();1!==t?this._cosUploadMethod(s,(s,i)=>{if(s||403===i.statusCode){let e=`${Be(s)?"":JSON.stringify(s)} `+(Be(i)?"":JSON.stringify(i)),t=(n.setMessage(e).end(),{HttpStatusCode:Bn,CostTime:Ot(r,!1),error:s,url:a.url});i.data&&i.data.uploadIP&&(t.uploadIP=i.data.uploadIP),this._uploadSSOLog(t),Se.l(l+" failed, error:"+e),void o(new ii({code:ni.MSG_F_UPLOAD_FAIL}))}else this._handleUploadSuccessResult({ssoLog:n,startTs:r,file:d,uploadOptions:a,uploadResult:i},e)}):this._handleUploadSuccessResult({ssoLog:n,startTs:r,file:d,uploadOptions:a,uploadResult:{data:{location:s.downloadUrl,statusCode:200}}},e)}))}_handleUploadSuccessResult(e,t){let{ssoLog:s,startTs:i,file:o,uploadOptions:{existFlag:n,fileType:r,url:a,downloadUrl:l,requestSnapshotUrl:d,thumbUrl:u,largeUrl:c,imageInfoArray:_=[]},uploadResult:h}=e,p=Object.create(null),g=h.data.location||"";this.isPrivateNetWork()||0!==g.indexOf("https://")&&0!==g.indexOf("http://")||(g=g.split("//")[1]),p.fileName=o.name,p.fileSize=o.size,p.fileType=o.type.slice(o.type.indexOf("/")+1).toLowerCase(),p.location=g;var e=Ot(i,!1),m=this._formatFileSize(o.size),f=this._formatSpeed(1e3*o.size/(e||1)),m=`exist:${n} fileType:${r} bytes:${o.size} size:${m} time:${e}ms speed:${f} res:`+JSON.stringify(h),f=(Se.l(`${this._n}._uploadWithPreSigUrl ok. name:${o.name} `+m),s.setMessage(m).end(),{HttpStatusCode:h.statusCode,FileSize:o.size,CostTime:e,url:a}),m=(h.data&&h.data.uploadIP&&(f.uploadIP=h.data.uploadIP),this._uploadSSOLog(f),this.get(Bs));if(m.addCost(fi,e),m.addFileSize(fi,o.size),1===n){if(0<_.length)return p.imageInfoArray=_,void t(p);if(d)return this._getSnapshotInfoByUrl(d,p).then(()=>{t(p)})}f=[];if(u&&c&&f.push(this._getSmallImageInfoByUrl(u,p),this._getLargeImageInfoByUrl(c,p)),this.isSimpleCos&&r===on&&!this.isPrivateNetWork()&&(f.push(this._getImageInfoArray(l,p)),h.data.uploadIP)&&f.push(this._getDownloadIP(l.split("//")[1].split("/")[0],p)),d&&f.push(this._getSnapshotInfoByUrl(d,p)),0<f.length)return Promise.all(f).then(()=>{t(p)});t(p)}_getDownloadIP(e,s){let i=this._n+"._getDownloadIP",o=Date.now();return this.req({P:ui.GET_IP,data:{domainName:e}}).then(e=>{var t;e.data&&e.data.ip&&(Se.l(i+` ok. downloadIP:${e.data.ip} cost:`+Ot(o)),(t=s.location.split("/"))[0]=e.data.ip,s.location=t.join("/"))}).catch(e=>{})}_getImageInfoArray(t,s){let i=this._n+"._getImageInfoArray",o=Date.now();return this.req({P:ui.GET_IMAGE_INFO,data:{imageUrl:t}}).then(e=>{e=e.data||{};return Se.l(i+` ok. data: ${JSON.stringify(e)} cost:`+Ot(o)),s.imageInfoArray=e.imageInfoArray,e}).catch(e=>{s.imageInfoArray=void 0,this._uploadSSOLog({HttpStatusCode:Kn,CostTime:Ot(o,!1),url:t})})}_uploadSSOLog(t){if(this.isSimpleCos){var s=new Ei;s.setEventType(18),t.error&&s.setError(new ii(t.error));let e=`HttpStatusCode:${t.HttpStatusCode}|CosRequestId:${t.CosRequestId||""}|FileAlreadyExist:${t.FileAlreadyExist||0}|FileSize:${t.FileSize||0}|CostTime:`+t.CostTime;t.uploadIP&&(e+="|FinalIP:"+t.uploadIP),s.setMessage("OK").setMoreMessage(t.url).setExtension(e).end()}}_getRawOrUploadProxyUrl(e){var t=this.get(Ns).getFileUploadProxy();let s=e;return s=t?e.replace(/^https:\/\/[^/]+/,t):s}_getFile(e){return Ve(e.file.files)||Ye(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?yt(e/1024,1)+"KB/s":yt(e/1048576,1)+"MB/s"}_createCosOptionsWeb(t){var e=this._getFile(t),s=e.name,s=s.slice(s.lastIndexOf(".")),s=this._genFileName(""+Qe(999999)+s);return{files:[{Bucket:this.bucketName+"-"+this.appid,Region:this.region,Key:this.directory+"/"+s,Body:e}],SliceSize:1048576,onProgress:e=>{if("function"==typeof t.onProgress)try{t.onProgress(e.percent)}catch(e){Se.w("onProgress callback error:",e)}},onFileFinish:(e,t,s)=>{}}}_createCosOptionsWXMiniApp(t){var e=this._getFile(t),s=this._genFileName(e.name),e=e.url;return{Bucket:this.bucketName+"-"+this.appid,Region:this.region,Key:this.directory+"/"+s,FilePath:e,onProgress:e=>{if(Se.l(JSON.stringify(e)),"function"==typeof t.onProgress)try{t.onProgress(e.percent)}catch(e){Se.w("onProgress callback error:",e)}}}}_createCosOptionsPreSigUrl(d){let u=d.customFileName,c="",e=0;var s=this._getFile(d);if($||x){if(Be(u))if(d.message.type===t.MSG_FILE||d.message.type===t.MSG_VIDEO){let e=s.name,t=e.slice(e.lastIndexOf("."));u=this._genFileName(""+Qe(999999)+t)}else u=this._genFileName(s.name);c=s.url,e=1}else{if(Be(u)){let e=s.name,t=e.slice(e.lastIndexOf("."));u=this._genFileName(""+Qe(999999)+t)}c=s,e=0}return this._getCosPreSigUrl({fileType:this.uploadFileType,fileName:u,uploadMethod:e,duration:this.duration,userID:d.message.from,conversationType:dt(d.message.conversationID)?1:2}).then(e=>{var{uploadUrl:t,downloadUrl:s,requestSnapshotUrl:i,thumbUrl:o,largeUrl:n,fileKey:r,existFlag:a=0,imageInfoArray:l}=this.isSimpleCos?e.preSig[0]:e,{uploadIP:e=""}=e;return{url:this._getRawOrUploadProxyUrl(t),fileType:this.uploadFileType,fileName:u,resources:c,downloadUrl:s,requestSnapshotUrl:i,thumbUrl:o,largeUrl:n,fileKey:r,existFlag:a,imageInfoArray:l,uploadIP:!this.isPrivateNetWork()&&e,onProgress:e=>{if("function"==typeof d.onProgress)try{d.onProgress(e.percent)}catch(e){Se.w("onProgress callback error:",e),Se.e(e)}}}})}_genFileName(e){return mt()+"-"+e}_setUploadFileType(e){this.uploadFileType=e}_getSnapshotInfoByUrl(e,i){let o="_getSnapshotInfoByUrl",n=new Ei(o);return this.req({P:ui.VIDEO_COVER,data:{platform:this.getPlatform(),coverName:this._genFileName(Qe(99999)),requestSnapshotUrl:e}}).then(e=>{e=(e.data||{}).snapshotUrl;if(Se.l(`${this._n}.${o} ok. snapshotUrl:`+e),n.setMessage("snapshotUrl:"+e).end(),Ge(e))return{};let t=Ri(e,this._fileDownloadProxy,this._authKey,this._fileDNList),s=Ri(e,void 0,this._authKey,this._fileDNList);return gt(t).then(e=>{i.snapshotInfo={snapshotUrl:t,snapshotWidth:e.width,snapshotHeight:e.height,remoteSnapshotUrl:s}})}).catch(e=>(Se.w(`${this._n}.${o} failed. error:`,e),n.setCode(e.errorCode).setMessage(e.errorInfo).end(),{}))}_getSmallImageInfoByUrl(t,s){return gt(Ri(t,this._fileDownloadProxy,this._authKey,this._fileDNList)).then(e=>{s.smallImageUrl=t,s.smallImageWidth=e.width,s.smallImageHeight=e.height})}_getLargeImageInfoByUrl(t,s){return gt(Ri(t,this._fileDownloadProxy,this._authKey,this._fileDNList)).then(e=>{s.largeImageUrl=t,s.largeImageWidth=e.width,s.largeImageHeight=e.height})}_isEmptyFileList(e){return!(!Ye(e)||0!==e.length)}reset(){Se.l(this._n+".reset")}}class Wn{constructor(e){this._n="MergerMessageHandler",this._msgM=e}uploadMergerMessage(e,s){let i=this._n+".uploadMergerMessage",t=(Se.d(i+" message:",e,"messageBytes:"+s),JSON.parse(JSON.stringify(e.payload)))["messageList"],o=t.length,n=this._msgM.get(ks).getFileDNList(),r=new Ei("uploadMergerMessage");return t.forEach(e=>{Li(e.messageBody[0].type,e.messageBody,n)}),this._msgM.req({P:ui.UPLOAD_MERGER_MSG,data:{messageList:t}}).then(e=>{Se.d(i+" ok. response:",e.data);var{pbDownloadKey:e,downloadKey:t}=e.data,e={pbDownloadKey:e,downloadKey:t,messageNumber:o};return r.setMessage(o+`-${s}-`+t).end(),e}).catch(e=>{throw Se.w(i+" failed. error:",e),r.setError(e).end(),e})}downloadMergerMessage(r){let t=this._n+".downloadMergerMessage",s=(Se.d(t+" message:",r),r.payload)["downloadKey"],a=this._msgM.getFileDownloadProxy(),l=this._msgM.getDownloadFileAuthKey(),i=new Ei("downloadMergerMessage");return i.setMessage("downloadKey:"+s),this._msgM.req({P:ui.DOWNLOAD_MERGER_MSG,data:{downloadKey:s}}).then(o=>{Se.d(t+" ok. response:",o.data);let n=this._msgM.get(ks).getFileDNList();if(He(r.clearElement)){let{downloadKey:e,pbDownloadKey:t,messageList:s,...i}=r.payload;r.clearElement(),r.setElement({type:r.type,content:{messageList:o.data.messageList,...i}},a,l,n)}else{let t=[];o.data.messageList.forEach(e=>{Ge(e)||(e=new xi(e,a,l,n),t.push(e))}),r.payload.messageList=t,r.payload.downloadKey="",r.payload.pbDownloadKey=""}return i.end(),r}).catch(e=>{throw Se.w(`${t} failed. key:${s} error:`,e),i.setError(e).end(),e})}createMergerMessagePack(e,s,i){return e.conversationType===t.CONV_C2C?this._createC2CMergerMessagePack(e,s,i):this._createGroupMergerMessagePack(e,s,i)}_createC2CMergerMessagePack(e,i,t){let s=null;i&&(i.offlinePushInfo&&(s=i.offlinePushInfo),!0===i.onlineUserOnly)&&(s?s.disablePush=!0:s={disablePush:!0});var o=[];if(xe(i)&&xe(i.messageControlInfo)){let{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:s}=i.messageControlInfo;!0===e&&o.push("NoUnread"),!0===t&&o.push("NoLastMsg"),!0===s&&o.push("NoMsgCheck")}let n="";$e(e.cloudCustomData)&&0<e.cloudCustomData.length&&(n=e.cloudCustomData);var{pbDownloadKey:t,downloadKey:r,messageNumber:a}=t,{title:l,abstractList:d,compatibleText:u}=e.payload,c=this._msgM.get(Ds),c=c&&c.isOnlineMessage(e,i)?0:void 0;return{P:ui.SEND_C2C_MSG,data:{fromAccount:this._msgM.getMyUserID(),toAccount:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:t,downloadKey:r,title:l,abstractList:d,compatibleText:u,messageNumber:a}}],cloudCustomData:n,clientTime:e.clientTime,msgSeq:e.sequence,msgRandom:e.random,msgLifeTime:c,offlinePushInfo:Xi(s),messageControlInfo:0!==c?o:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}_createGroupMergerMessagePack(e,i,t){let s=null;i&&i.offlinePushInfo&&(s=i.offlinePushInfo);var o=[];if(xe(i)&&xe(i.messageControlInfo)){let{excludedFromUnreadCount:e,excludedFromLastMessage:t,excludedFromContentModeration:s}=i.messageControlInfo;!0===e&&o.push("NoUnread"),!0===t&&o.push("NoLastMsg"),!0===s&&o.push("NoMsgCheck")}let n="";$e(e.cloudCustomData)&&0<e.cloudCustomData.length&&(n=e.cloudCustomData);var{pbDownloadKey:t,downloadKey:r,messageNumber:a}=t,{title:l,abstractList:d,compatibleText:u}=e.payload,c=this._msgM.get(Rs),i=c&&c.isOnlineMessage(e,i)?1:0;return{P:ui.SEND_GRP_MSG,data:{fromAccount:this._msgM.getMyUserID(),groupID:e.to,msgBody:[{msgType:e.type,msgContent:{pbDownloadKey:t,downloadKey:r,title:l,abstractList:d,compatibleText:u,messageNumber:a}}],random:e.random,priority:e.priority,clientSequence:e.clientSequence,groupAtInfo:void 0,cloudCustomData:n,onlineOnlyFlag:i,offlinePushInfo:Xi(s),clientTime:e.clientTime,needReadReceipt:!0!==e.needReadReceipt||c.isMessageFromOrToAVChatroom(e.to)?0:1,messageControlInfo:0==i?o:void 0,isSupportExtension:!0===e.isSupportExtension?1:0,isRelayMessage:!0===e._relayFlag?1:0}}}}let Yn={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},zn=[ni.MSG_ONPROGRESS_ERR,ni.MSG_I_SELECT_F_FIRST,ni.MSG_I_TYPES_LIMIT,ni.MSG_F_IS_EMPTY,ni.MSG_I_SIZE_LIMIT,ni.MSG_F_SELECT_F_FIRST,ni.MSG_F_SIZE_LIMIT,ni.MSG_V_SIZE_LIMIT,ni.MSG_V_TYPES_LIMIT,ni.MSG_A_UPLOAD_FAIL,ni.MSG_A_SIZE_LIMIT,ni.COS_UNDETECTED];function jn(e){let t=!1;return Object.values(Yn).includes(e)&&(t=!0),t=120001<=e&&e<=13e4||10100<=e&&e<=10200?!0:t}class Jn extends li{constructor(e){super(e),this._n="MessageModule",this._messageOptionsMap=new Map,this._mergerMessageHandler=new Wn(this)}createTextMessage(e){var t=this.getMyUserID(),s=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new Ki(e)),e=$e(e.payload)?e.payload:e.payload.text,e=new Di({text:e}),t=this._getNickAndAvatarByUserID(t);return s.setElement(e),s.setNickAndAvatar(t),s.setNameCard(this._getNameCardByGroupID(s)),s}createImageMessage(i){let e=this.getMyUserID(),t=(i.currentUser=e,i.senderTinyID=this.getMyTinyID(),new Ki(i));if($){let e=i.payload["file"];if(be(e))return void this.warn("FileUnsupportedInMP","createImageMessage");let t=e.tempFiles[0].path||e.tempFiles[0].tempFilePath,s={url:t,name:t.slice(t.lastIndexOf("/")+1),size:e.tempFiles&&e.tempFiles[0].size||1,type:t.slice(t.lastIndexOf(".")+1).toLowerCase()};i.payload.file=s}else if(x){let e=i.payload["file"],t={url:e.uri,name:e.fileName,size:e.fileSize||1,type:e.type,width:e.width,height:e.height};i.payload.file=t}else if(V)if(be(i.payload.file)){let e=i.payload.file;i.payload.file={files:[e]}}else if(xe(i.payload.file)&&"undefined"!=typeof uni){let e=i.payload.file.tempFiles[0];i.payload.file={files:[e]}}let s=this.get(ks).getFileDNList(),o=new Oi({imageFormat:Ee.UNKNOWN,uuid:this._generateUUID(i.payload.file),file:i.payload.file},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),s),n=this._getNickAndAvatarByUserID(e);return t.setElement(o),t.setNickAndAvatar(n),t.setNameCard(this._getNameCardByGroupID(t)),this._messageOptionsMap.set(t.clientSequence,i),t}createAudioMessage(t){var s=t.payload["file"];if($){let e={url:s.tempFilePath,name:s.tempFilePath.slice(s.tempFilePath.lastIndexOf("/")+1),size:s.fileSize,second:parseInt(s.duration)/1e3,type:s.tempFilePath.slice(s.tempFilePath.lastIndexOf(".")+1).toLowerCase()};t.payload.file=e}if(x){let e={url:s.uri,name:s.uri.slice(s.uri.lastIndexOf("/")+1),size:s.fileSize||1,second:Math.floor(s.duration/1e3),type:s.uri.slice(s.uri.lastIndexOf(".")+1).toLowerCase()};t.payload.file=e,Ge(s.uri)&&this.warn("VoiceFileInRN")}let e=this.getMyUserID();t.currentUser=e,t.senderTinyID=this.getMyTinyID();var i=this.get(ks).getFileDNList(),o=new Ki(t),s=new Pi({second:Math.floor(s.duration/1e3),size:s.fileSize||s.size||1,url:s.tempFilePath||s.uri,uuid:this._generateUUID(t.payload.file)},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),i),i=this._getNickAndAvatarByUserID(e);return o.setElement(s),o.setNickAndAvatar(i),o.setNameCard(this._getNameCardByGroupID(o)),this._messageOptionsMap.set(o.clientSequence,t),o}createVideoMessage(t){let e=this.getMyUserID();t.currentUser=e,t.senderTinyID=this.getMyTinyID(),t.payload.file.thumbUrl="",t.payload.file.thumbSize=0;var s={};if($){if(be(t.payload.file))return void this.warn("FileUnsupportedInMP","createVideoMessage");let e=t.payload["file"];Ve(e.tempFiles)&&(e=e.tempFiles[0]),s.url=e.tempFilePath,s.name=e.tempFilePath.slice(e.tempFilePath.lastIndexOf("/")+1),s.size=e.size||1,s.second=e.duration||0,s.type=this._getVideoFileType(e)}else if(x){let e=t.payload["file"];s.url=e.uri,s.name=e.fileName,s.size=e.fileSize||1,s.second=e.duration||0,s.type=e.type.split("/")[1]}else if(V){if(be(t.payload.file)){let e=t.payload.file;t.payload.file.files=[e]}else if(xe(t.payload.file)&&"undefined"!=typeof uni){let e=t.payload.file.tempFile;t.payload.file.files=[e]}let e=t.payload["file"];s.url=window.URL.createObjectURL(e.files[0]),s.name=e.files[0].name,s.size=e.files[0].size||1,s.second=e.files[0].duration||0,s.type=e.files[0].type.split("/")[1]}t.payload.file.videoFile=s;var i=this.get(ks).getFileDNList(),o=new Ki(t),s=new $i({videoFormat:s.type,videoSecond:yt(s.second,0),videoSize:s.size,remoteVideoUrl:"",videoUrl:s.url,videoUUID:this._generateUUID(t.payload.file.videoFile),thumbUUID:this._generateUUID(t.payload.file.videoFile,"jpg"),thumbWidth:t.payload.file.width||200,thumbHeight:t.payload.file.height||200,thumbUrl:t.payload.file.thumbUrl,thumbSize:t.payload.file.thumbSize,thumbFormat:"jpg"},this.getFileDownloadProxy(),this.getDownloadFileAuthKey(),i),i=this._getNickAndAvatarByUserID(e);return o.setElement(s),o.setNickAndAvatar(i),o.setNameCard(this._getNameCardByGroupID(o)),this._messageOptionsMap.set(o.clientSequence,t),o}_getVideoFileType(e){var t=e.tempFilePath.slice(e.tempFilePath.lastIndexOf(".")+1).toLowerCase();return w&&e.fileType||t}createCustomMessage(e){var t=this.getMyUserID(),s=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new Ki(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 Ki(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(),t=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),this._getNickAndAvatarByUserID(t)),s=new Ki(e),e=new Vi(e.payload);return s.setElement(e),s.setNickAndAvatar(t),s.setNameCard(this._getNameCardByGroupID(s)),s.setRelayFlag(!0),s}createForwardMessage(e){var s,i,{to:o,conversationType:n,priority:r,payload:a,needReadReceipt:l,receiverList:d}=e;return Ve(a._elements)?(s=this.getMyUserID(),i=this._getNickAndAvatarByUserID(s),a.type===t.MSG_GRP_TIP?ci({code:ni.MSG_FORWARD_TYPE_INVALID}):(n={to:o,conversationType:n,conversationID:""+n+o,priority:r,isPlaceMessage:0,status:Gt,currentUser:s,senderTinyID:this.getMyTinyID(),cloudCustomData:e.cloudCustomData||a.cloudCustomData||"",needReadReceipt:l,receiverList:d,isSupportExtension:e.isSupportExtension||!1},(o=new Ki(n)).setElement(a._elements[0]),o.setNickAndAvatar(i),o.setNameCard(this._getNameCardByGroupID(a)),o.setRelayFlag(!0),o)):ci({code:ni.MSG_FORWARD_INVALID_ELEMENTS})}downloadMergerMessage(e){return this._mergerMessageHandler.downloadMergerMessage(e)}createFileMessage(i){if($){if(!A&&!N&&!w)return;let e,t=B.getSystemInfoSync().SDKVersion;if(A&&Mt(t,e="2.5.0")<0)return void this.warn("WXChooseMessageFile");if(N&&Mt(t,e="1.18.0")<0)return void this.warn("QQChooseMessageFile")}if(V||w){if(be(i.payload.file)){let e=i.payload.file;i.payload.file={files:[e]}}else if(xe(i.payload.file)&&"undefined"!=typeof uni){let{tempFiles:e,files:t}=i.payload.file,s=null;Ve(e)?s=e[0]:Ve(t)&&(s=t[0]),i.payload.file={files:[s]}}}else if(A||N){let e=i.payload.file["tempFiles"],t={...e[0],url:e[0].path};i.payload.file={files:[t]}}else if(x){let e=i.payload["file"],t={...e,url:e.uri};i.payload.file={files:[t]}}let e=this.getMyUserID(),t=(i.currentUser=e,i.senderTinyID=this.getMyTinyID(),new Ki(i)),s=new bi({uuid:this._generateUUID(i.payload.file),file:i.payload.file}),o=this._getNickAndAvatarByUserID(e);return t.setElement(s),t.setNickAndAvatar(o),t.setNameCard(this._getNameCardByGroupID(t)),this._messageOptionsMap.set(t.clientSequence,i),t}createLocationMessage(e){var t=this.getMyUserID(),s=(e.currentUser=t,e.senderTinyID=this.getMyTinyID(),new Ki(e)),e=new qi(e.payload),t=this._getNickAndAvatarByUserID(t);return s.setElement(e),s.setNickAndAvatar(t),s.setNameCard(this._getNameCardByGroupID(s)),s}_onNoModule(){return ci({code:ni.NO_MODULE})}sendMessageInstance(r,a){if(!1===this.get(Ws).filterMessage(r,a))return r.hasRiskContent=!0,this._onSendMessageFailed(r,new ii({code:ni.PROFANITY_FOUND}));let s=null;if(r.conversationType===t.CONV_C2C)s=this.get(Ds);else{if(r.conversationType!==t.CONV_GROUP)return ci({code:ni.MSG_INVALID_CONV_TYPE});s=this.get(Rs)}if(!s)return this._onNoModule();let l=this._n+".sendMessageInstance",d=this.get(Os),u=s.isOnlineMessage(r,a),c;return this.get(ks).upload(r).then(()=>(this._getSendMessageSpecifiedKey(r)===mi&&this.get(Bs).addSuccessCount(fi),this._guardForGroup(r).then(()=>{if(!r.isSendable())return ci({code:ni.MSG_F_URL_IS_EMPTY});this._addSendMessageTotalCount(r),c=Date.now();var e=function(t){let e="utf-8";V&&document&&(e=document.charset.toLowerCase());let s,i=0,o;if(o=t.length,"utf-8"===e||"utf8"===e)for(let e=0;e<o;e++)(s=t.codePointAt(e))<=127?i+=1:s<=2047?i+=2:s<=65535?i+=3:(i+=4,e++);else if("utf-16"===e||"utf16"===e)for(let e=0;e<o;e++)(s=t.codePointAt(e))<=65535?i+=2:(i+=4,e++);else i=t.replace(/[^\x00-\xff]/g,"aa").length;return i}(JSON.stringify(r));return r.type===t.MSG_MERGER&&11264<e?this._mergerMessageHandler.uploadMergerMessage(r,e).then(e=>{e=this._mergerMessageHandler.createMergerMessagePack(r,a,e);return this.req(e)}):(d.setMessageRandom(r),s.sendMessage(r,a))}).then(e=>{var{time:e,sequence:s,readReceiptCode:i,messageDropReason:o}=e.data;if(Fe(i)&&0!==i&&(new Ei("sendMessageWithReceipt").setMessage(`from:${r.from} to:${r.to} sequence:${s} readReceiptCode:`+i).end(),Se.w(l+` readReceiptCode:${i} message:`+this.getErrMsg(i))),o){let e=new Ei("messageDropReason"),t=`from:${r.from} to:${r.to} sequence:${s} messageDropReason:`+o;e.setMessage(t).end(),Se.w(l+" "+t)}if(this._addSendMessageSuccessCount(r,c),this._messageOptionsMap.delete(r.clientSequence),!0===r.isResend){let e=d.findMessage(r.ID);e&&(Se.l(l+" resend ok. ID:"+e.ID),d.deleteLocalMessage(e))}r.status=kt,r.time=e;let n=!1;if(r.conversationType===t.CONV_GROUP)r.sequence=s;else if(r.conversationType===t.CONV_C2C){let s=d.getLatestMessageSentByMe(r.conversationID);if(s){let{nick:e,avatar:t}=s;e===r.nick&&t===r.avatar||(n=!0)}}if(n&&d.modifyMessageSentByMe({conversationID:r.conversationID,latestNick:r.nick,latestAvatar:r.avatar}),!0===u)r._onlineOnlyFlag=!0;else{d.appendToMessageList(r);let e=r,s=(xe(a)&&xe(a.messageControlInfo)&&(!0===a.messageControlInfo.excludedFromLastMessage&&(r._isExcludedFromLastMessage=!0,e=""),!0===a.messageControlInfo.excludedFromUnreadCount)&&(r._isExcludedFromUnreadCount=!0),r.conversationType);ut(r.to)&&(s=t.CONV_TOPIC,this.get(As).onMessageSent({groupID:Et(r.to),topicID:r.to,lastMessage:e})),d.onMessageSent({conversationOptionsList:[{conversationID:r.conversationID,unreadCount:0,type:s,subType:r.conversationSubType,lastMessage:e}]})}return r._relayFlag||"TIMImageElem"!==r.type||Ct(r.payload.imageInfoArray),si({message:r})}))).catch(e=>this._onSendMessageFailed(r,e,u))}_guardForGroup(s){if(s.conversationType!==t.CONV_GROUP)return Promise.resolve();var i=this.get(Rs);if(!i)return this._onNoModule();if(lt({groupID:s.to})){let e=i.getLocalGroupProfile(s.to);if(e&&e.isSupportTopic)return ci({code:ni.MSG_SEND_GRP_WITH_TOPIC_FAIL})}return i.guardForAVChatRoom(s)}_onSendMessageFailed(e,t,s=!1){var i=this._n+"._onSendMessageFailed",o=(e.status=wt,80001!==t.code&&80004!==t.code||(e.hasRiskContent=!0),this.get(Os)),n=(o.deleteMessageRandom(e),10100<=t.code&&t.code<=10200||120001<=t.code&&t.code<=13e4),s=(s||n||!0===o.appendToMessageList(e)&&Se.l(i+" message stored, ID:"+e.ID),this._addSendMessageFailCountOnUser(e,t),new Ei("sendMessage"));let r=`head.seq:${t.data.headSeq} type:${e.type} from:${e.from} to:`+e.to;if(V){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(),Se.e(i+` ${r} error:`,t),ci(new ii({code:t&&t.code?t.code:ni.MSG_SEND_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}}))}_getSendMessageSpecifiedKey(s){if([t.MSG_IMAGE,t.MSG_AUDIO,t.MSG_VIDEO,t.MSG_FILE].includes(s.type))return mi;if(s.conversationType===t.CONV_C2C)return hi;if(s.conversationType===t.CONV_GROUP){let e=this.get(Rs);if(e){var s=e.getLocalGroupProfile(s.to);if(s)return s=s.type,ct(s)?gi:pi}}}_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,Ot(t,!1))}}_addSendMessageFailCountOnUser(e,t){var{code:t=-1}=t,s=this.get(Bs),e=this._getSendMessageSpecifiedKey(e);e===mi&&function(e){let t=!1;return t=zn.includes(e)?!0:t}(t)?s.addFailedCountOfUserSide(fi):jn(t)&&e&&s.addFailedCountOfUserSide(e)}resendMessage(e,t){return e.isResend=!0,e.status=Gt,this.sendMessageInstance(e,t)}revokeMessage(s){let e=null;if(s.conversationType===t.CONV_C2C?e=this.get(Ds):s.conversationType===t.CONV_GROUP&&(e=this.get(Rs)),!e)return this._onNoModule();let i=new Ei("revokeMessage"),o=(i.setMessage(`type:${s.type} from:${s.from} to:`+s.to),this._n+".revokeMessage");return e.revokeMessage(s).then(e=>{var t=e.data.recallRetList;if(Ge(t)||0===t[0].retCode)return Se.i(o+" ok. ID:"+s.ID),s.isRevoked=!0,i.end(),this.get(Os).onMessageRevoked([s]),si({message:s});{let e=new ii({code:t[0].retCode,data:{message:s}});return i.setCode(e.code).setMoreMessage(e.message).end(),ci(e)}}).catch(e=>{i.setError(e).end();var t=new ii({code:e&&e.code?e.code:ni.MSG_REVOKE_FAIL,message:e&&e.message?e.message:void 0,data:{message:s}});return Se.w(o+" failed. error:",e),ci(t)})}deleteMessage(e){let s=null,i=e[0],o=i.conversationID,n="",r=[],a=[];if(i.conversationType===t.CONV_C2C)s=this.get(Ds),n=o.replace(t.CONV_C2C,""),e.forEach(e=>{e&&e.status===kt&&e.conversationID===o&&(e._onlineOnlyFlag||r.push(`${e.sequence}_${e.random}_`+e.time),a.push(e))});else if(i.conversationType===t.CONV_GROUP)s=this.get(Rs),n=o.replace(t.CONV_GROUP,""),e.forEach(e=>{e&&e.status===kt&&e.conversationID===o&&(e._onlineOnlyFlag||r.push(""+e.sequence),a.push(e))});else if(i.conversationType===t.CONV_SYSTEM)return ci({code:ni.CANNOT_DELETE_GRP_SYSTEM_NOTICE});if(!s)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 s.deleteMessage({to:n,keyList:r}).then(e=>(l.end(),Se.i(d+" ok"),this._onMessageDeleted(a))).catch(e=>{l.setError(e).end(),Se.w(d+" failed. error:",e);e=new ii({code:e&&e.code?e.code:ni.MSG_DELETE_FAIL,message:e&&e.message?e.message:void 0});return ci(e)})}_onMessageDeleted(e){return this.get(Os).onMessageDeleted(e),ai({messageList:e})}translateText(e){let o=this._n+".translateText",{sourceTextList:t,sourceLanguage:s,targetLanguage:i}=e,n=new Ei("translateText");return n.setMessage(`sourceLanguage:${s} targetLanguage:`+i),this.req({P:ui.TRANSLATE_TEXT,data:{sourceTextList:t,source:s||"auto",target:i,from:this.getMyTinyID(),SDKAppID:this.getSDKAppID()}}).then(e=>{var{error:e,requestID:t,translatedTextList:s}=e.data,i=e["code"];if(0===i)return n.end(),Se.i(o+" ok. requestID:"+t),si({translatedTextList:s});throw{...e,requestID:t}}).catch(e=>(n.setCode(e.code).setMoreMessage(e.requestID).end(),Se.w(o+" failed. error:",e),ci({code:e.code||ni.TRANSLATE_TEXT_FAIL,message:e.message})))}convertVoiceToText(e){var{message:e,language:t}=e;let s=e.payload.url;e.from===this.getMyUserID()&&"out"===e.flow&&(s=e.payload.remoteAudioUrl);e=/\.(wav|pcm|ogg-opus|speex|silk|mp3|m4a|aac|amr)/;if(!e.test(s))return ci({code:ni.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=(Se.i(n+" "+o),new Ei("convertVoiceToText"));return r.setMessage(o),this.req({P:ui.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(),Se.i(n+" ok. requestID:"+t),si({result:s});throw{...e,requestID:t}}).catch(e=>(r.setCode(e.code).setMoreMessage(e.requestID||"").end(),Se.w(n+" failed. error:",e),ci({code:ni.VOICE_TO_TEXT_FAIL})))}modifyRemoteMessage(s){if(!1===this.get(Ws).filterMessage(s))return s.hasRiskContent=!0,ci({code:ni.PROFANITY_FOUND,data:{message:s}});let e=null;var{conversationType:i,to:o}=s;if(i===t.CONV_C2C)e=this.get(Ds);else if(i===t.CONV_GROUP){if(!(e=this.get(Rs)))return this._onNoModule();if(e.isMessageFromOrToAVChatroom(o))return ci({code:ni.MSG_MODIFY_DISABLED_IN_AV,data:{message:s}})}let n=new Ei("modifyMessage"),r=(n.setMessage("to:"+o),this._n+".modifyRemoteMessage");return e.modifyRemoteMessage(s).then(e=>{n.end(),Se.i(r+" ok");e=this._onModifyRemoteMessageResp(s,e.data);return si({message:e})}).catch(e=>{var t;return n.setCode(e.code).setMoreMessage(e.message).end(),Se.w(r+" failed. error:",e),20027===e.code?(t=this._onModifyRemoteMessageResp(s,e.data),ci({code:ni.MSG_MODIFY_CONFLICT,data:{message:t}})):ci({code:e.code,message:e.message,data:{message:s}})})}_onModifyRemoteMessageResp(e,t){Se.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(Os).onMessageModified({conversationType:e,from:s,to:i,time:r,random:o,sequence:n,elements:t,cloudCustomData:l,messageVersion:a})}_generateUUID(e,t){var s=this.get(Ns);let i=`${s.getSDKAppID()}-${s.getUserID()}-`+function(){let t="";for(let e=32;0<e;--e)t+=et[Math.floor(Math.random()*st)];return t}();if(t)return i+"."+t;let o=e;s=(o=Ve(e.files)?e.files[0]:o).name||o.value||o.url||o.tempFilePath,t=s&&s.slice(s.lastIndexOf(".")+1);return i=t?i+"."+t:i}getMessageOption(e){return this._messageOptionsMap.get(e)}_getNickAndAvatarByUserID(e){return this.get(Es).getNickAndAvatarByUserID(e)}_getNameCardByGroupID(s){if(s.conversationType===t.CONV_GROUP){let e=this.get(Rs);if(e)return e.getMyNameCardByGroupID(s.to)}return""}reset(){Se.l(this._n+".reset"),this._messageOptionsMap.clear()}}class Xn extends li{constructor(e){super(e),this._n="MsgExtModule",this.msgExtMap=new Map,this.globalSeqMap=new Map,this.getMsgExtsMap=new Map}onMsgExtNotify(t){let{messageInfo:s,operateType:i,operateResultList:o,tinyID:n,globalSequence:r}=t.dataList,{clientTime:a,random:l}=s,d=n+`-${a}-`+l,u=[],c=[],_=(Se.l(`${this._n}.onMsgExtNotify messageID:${d} operateType:${i} globalSequence:`+r),this._updateGlobalSeq(d,r),!1),h=!1;o.forEach(e=>{let{extensions:t=[],clearSequence:s}=e;1===i?(_=!0,t.forEach(e=>{u.push({key:e.key,value:e.value})}),this._updateLocalExt(d,t)):2===i?(h=!0,t.forEach(e=>{c.push(e.key)}),this._updateLocalExt(d,t)):3===i&&(h=!0,this._hasLocalExt(d)&&this._getLocalExt(d).forEach((e,t)=>{e.seq<=s&&!Ge(e.value)&&c.push(t)}),this._clearLocalExt(d,s))}),_&&this.emitOEvt(e.MESSAGE_EXTENSIONS_UPDATED,{messageID:d,extensions:u}),h&&this.emitOEvt(e.MESSAGE_EXTENSIONS_DELETED,{messageID:d,keyList:c})}setMessageExtensions(e,t){var s="setMessageExtensions";if(!this.canIUse(M.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),Se.w(i+". the length of extensions cannot exceed 20.")),`convID:${n} messageID:${o} sequence:${r} time:${a} count:`+l.length),u=new Ei(s);return u.setMessage(d),Se.l(i+" "+d),this._modifyMsgExts(e,l).then(e=>{var{resultList:e,successCount:t,failureCount:s}=e,t=`successCount:${t} failCount:`+s;return u.setMoreMessage(t).end(),Se.l(i+" ok. "+t),si({extensions:e})}).catch(e=>(u.setError(e).end(),Se.e(i+" failed. error:",e),ci(e)))}getMessageExtensions(e){var t="getMessageExtensions";if(!this.canIUse(M.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),Se.l(s+" "+a),void 0);return this.getMsgExtsMap.has(i)&&(d=this._getGlobalSeq(i)),this._getMsgExts(e,d).then(e=>(l.end(),Se.l(s+" ok. extCount:"+e.length),Be(d)&&0<e.length&&this.getMsgExtsMap.set(i,1),si({extensions:e}))).catch(e=>(l.setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}deleteMessageExtensions(e,t){var s="deleteMessageExtensions";if(!this.canIUse(M.MSG_EXT))return this.noUse(s);let o=this._n+"."+s,i=[],n=3,{ID:r,conversationID:a,sequence:l,time:d}=(Ge(t)||(n=2,t.forEach(e=>{i.push({key:e,value:"",seq:0})})),e),u=`convID:${a} messageID:${r} sequence:${l} time:${d} operateType:`+n,c=new Ei(s);return c.setMessage(u),Se.l(o+" "+u),this._modifyMsgExts(e,i,n).then(e=>{var{resultList:e,successCount:t,failureCount:s}=e;let i="";return 2===n&&(i=`success count:${t} fail count:`+s),c.setMoreMessage(""+i).end(),Se.l(o+" ok. "+i),si({extensions:e})}).catch(e=>(c.setError(e).end(),Se.e(o+" failed. error:",e),ci(e)))}_modifyMsgExts(s,e,i=1){var o=ut(s.to)?t.CONV_TOPIC:s.conversationType;let n=void 0,r=(3!==i&&(n=this._getReqExts(s,e)),null);switch(o){case t.CONV_C2C:r=this.get(Ds);break;case t.CONV_GROUP:r=this.get(Rs);break;case t.CONV_TOPIC:r=this.get(As);break;default:return ci({code:ni.NO_MODULE})}return r.modifyMsgExts(s,n,i).then(e=>{var{extensions:e,seq:t}=e.data;let o=[],n=0,r=0,a=[];return(e=Ge(e)?[]:e).forEach(e=>{var{errorCode:e,extension:t}=e,{key:t,value:s,seq:i}=t;o.push({code:e,key:t,value:s}),0===e?n++:r++,a.push({key:t,value:s,seq:i})}),this._updateGlobalSeq(s.ID,t),0<a.length&&(this._updateLocalExt(s.ID,a),a=null),{resultList:o,successCount:n,failureCount:r}}).catch(e=>ci(e))}_getReqExts(e,t){let o=[];if(this._hasLocalExt(e.ID)){let i=this._getLocalExt(e.ID);t.forEach(e=>{var{key:e,value:t}=e;let s=0;i.has(e)&&(s=i.get(e).seq),o.push({key:e,value:t,seq:s})})}else t.forEach(e=>{var{key:e,value:t}=e;o.push({key:e,value:t,seq:0})});return o}_getMsgExts(o,e){let n=this._n+"._getMsgExts",{ID:r,to:s}=o,i=null;switch(ut(s)?t.CONV_TOPIC:o.conversationType){case t.CONV_C2C:i=this.get(Ds);break;case t.CONV_GROUP:i=this.get(Rs);break;case t.CONV_TOPIC:i=this.get(As);break;default:return ci({code:ni.NO_MODULE})}return i.getMessageExtensions(o,e).then(e=>{var{extensions:t,completeFlag:e,globalSequence:s,clearSequence:i}=e.data,t=Ge(t)?[]:t;if(Se.l(n+` ok. completeFlag:${e} globalSequence:${s} clearSequence:${i} count:`+t.length),this._updateLocalExt(r,t),this._clearLocalExt(r,i),this._updateGlobalSeq(r,s),1===e)return this._getLocalExtList(r);{let e=t.slice(-1)[0].seq+1;return this._getMsgExts(o,e)}}).catch(e=>ci(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 i=this._getLocalExt(e);t.forEach(e=>{var{key:e,value:t="",seq:s}=e;i.set(e,{value:t,seq:s})})}_clearLocalExt(e,i){if(!(i<=0)&&this._hasLocalExt(e)){let s=this._getLocalExt(e);s.forEach((e,t)=>{e.seq<=i&&s.delete(t)})}}_getLocalExtList(e){let s=[];return this._hasLocalExt(e)&&this._getLocalExt(e).forEach((e,t)=>{e=e.value;Ge(e)||s.push({key:t,value:e})}),s}_getGlobalSeq(e){return this.globalSeqMap.get(e)}_updateGlobalSeq(e,t){this.globalSeqMap.set(e,t)}reset(){Se.l(this._n+".reset"),this.msgExtMap.clear(),this.globalSeqMap.clear(),this.getMsgExtsMap.clear()}}class Zn extends li{constructor(e){super(e),this._n="MsgReactionModule",this._reactedByMyselfMap=new Map,this._reactionInfoMap=new Map}onReactionNotifyList(t){var{dataList:t=[]}=t||{};t.forEach(t=>{let{C2CMessageInfo:s={},groupMessageInfo:i={},reactionList:o=[]}=t,{tinyID:n,clientTime:r,random:a}={...s,...i},l=n+`-${r}-`+a,d=[];o.forEach(e=>{Be(e.userIDList)&&(e.userIDList=[],e.count=0),d.push(...e.userIDList)}),Se.l(this._n+`.onReactionNotifyList messageID:${l} reactionList:`+o.length),this._handleReactionSummary([{messageID:l,reactionList:o}],d).then(t=>{this.emitOEvt(e.MESSAGE_REACTIONS_UPDATED,{...t[0]})})})}onReactionNotify(t){var{C2CMessageInfo:t={},groupMessageInfo:s={},reactionID:i,operateType:o}=t.dataList||{},{tinyID:t,clientTime:s,random:n}={...t,...s},s=t+`-${s}-`+n,n=(Se.l(this._n+`.onReactionNotify messageID:${s} reactionID:${i} operateType:`+o),1===o?this._addReactedByMyselfMap(s,i):this._removeReactedByMyselfMap(s,i),s+"-"+i);if(this._reactionInfoMap.has(n)){let t=this._reactionInfoMap.get(n);t.reactedByMyself=1===o,this.emitOEvt(e.MESSAGE_REACTIONS_UPDATED,{messageID:s,reactionList:[t]})}}addMessageReaction(t,s){var e="addMessageReaction";if(!this.canIUse(M.MSG_REACTION))return this.noUse(e);let i=this._n+"."+e,{ID:o,conversationID:n}=t,r=`convID:${n} messageID:${o} reactionID:`+s,a=new Ei(e);a.setMessage(r),Se.l(i+" "+r);e=this._createReactionOperationPack(t,s,1);return this._addReactedByMyselfMap(t.ID,s),this.req(e).then(()=>(a.end(),Se.l(i+" ok."),si())).catch(e=>(this._removeReactedByMyselfMap(t.ID,s),a.setError(e).end(),Se.e(i+" failed. error:",e),ci(e)))}removeMessageReaction(e,t){var s="removeMessageReaction";if(!this.canIUse(M.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);a.setMessage(r),Se.l(i+" "+r);s=this._createReactionOperationPack(e,t,2);return this._removeReactedByMyselfMap(e.ID,t),this.req(s).then(()=>(a.end(),Se.l(i+" ok."),si())).catch(e=>(a.setError(e).end(),Se.e(i+" failed. error:",e),ci(e)))}getMessageReactions(e){var t="getMessageReactions";if(!this.canIUse(M.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),Se.l(s+" "+r),new Map),d=this._createReactionSummaryPack({...e,messageIDMap:l});return this.req(d).then(e=>{let{resultList:t=[]}=e.data,i=[],o=[];return t.forEach(e=>{var{messageKey:e,messageSequence:t,reactionList:s=[]}=e,t=Be(e)?l.get(t):l.get(e);i.push({messageID:t,reactionList:s}),s.forEach(e=>{o.push(...e.userIDList)})}),this._handleReactionSummary(i,o)}).then(e=>(a.end(),Se.l(s+" ok."),l.clear(),si({resultList:e}))).catch(e=>(a.setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}getAllUserListOfMessageReaction(e){var t="getAllUserListOfMessageReaction";if(!this.canIUse(M.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,u=new Ei(t),c=(u.setMessage(d),Se.l(s+" "+d),{userList:[],nextSeq:0,isCompleted:!1}),_=this._createReactionUserListPack(e);return this.req(_).then(e=>{var{userIDList:e=[],nextSeq:t=0}=e.data;return c.nextSeq=t,c.isCompleted=0===t,this.get(Es).getUserNickAndAvatar(e)}).then(e=>(c.userList=e,u.end(),Se.l(s+" ok."),si(c))).catch(e=>(u.setError(e).end(),Se.e(s+" failed. error:",e),ci(e)))}_createReactionOperationPack(s,i,o){let n=void 0;i={reactionID:i,userIDList:[this.getMyUserID()]};if(s.conversationType===t.CONV_C2C){let e=this.get(Ds);n=1===o?ui.ADD_C2C_MSG_REACTION:ui.RM_C2C_MSG_REACTION,i.from=s.from,i.to=s.to,i.messageKey=e.getMessageKey(s)}if(s.conversationType===t.CONV_GROUP){let e=void 0,t=s.to;ut(s.to)&&(e=s.to,t=Et(e)),n=1===o?ui.ADD_GRP_MSG_REACTION:ui.RM_GRP_MSG_REACTION,i.groupID=t,i.topicID=e,i.messageSequence=s.sequence}return{P:n,data:i}}_createReactionSummaryPack(s){let{messageList:i,maxUserCountPerReaction:o=10,messageIDMap:n}=s,r=i[0],a=void 0,l=void 0;if(r.conversationType===t.CONV_C2C){let s=this.get(Ds),e=i.map(e=>{var t=s.getMessageKey(e);return n.set(t,e.ID),t});a=ui.GET_C2C_MSG_REACTIONS,l={from:r.from,to:r.to,messageKeyList:e,count:o}}if(r.conversationType===t.CONV_GROUP){let e=void 0,t=r.to;ut(r.to)&&(e=r.to,t=Et(e));s=i.map(e=>(n.set(e.sequence,e.ID),e.sequence));a=ui.GET_GRP_MSG_REACTIONS,l={groupID:t,topicID:e,messageSequenceList:s,count:o}}return{P:a,data:l}}_createReactionUserListPack(e){var{message:s,reactionID:e,nextSeq:i=0,count:o=100}=e;let n=void 0;i={reactionID:e,nextSeq:i,count:100<o?100:o};if(s.conversationType===t.CONV_C2C){let e=this.get(Ds);n=ui.GET_C2C_MSG_REACTION_USER_LIST,i.from=s.from,i.to=s.to,i.messageKey=e.getMessageKey(s)}if(s.conversationType===t.CONV_GROUP){let e=void 0,t=s.to;ut(s.to)&&(e=s.to,t=Et(e)),n=ui.GET_GRP_MSG_REACTION_USER_LIST,i.groupID=t,i.topicID=e,i.messageSequence=s.sequence}return{P:n,data:i}}_handleReactionSummary(t,e){return this.get(Es).getUserNickAndAvatar(e).then(l=>{let e=[];return t.forEach(r=>{let a=[];r.reactionList.forEach(t=>{let{reactionID:s,count:e,userIDList:i,reactedByMyself:o}=t,n=[];i.forEach(t=>{l.forEach(e=>{t===e.userID&&n.push(e)})});t={reactionID:s,totalUserCount:e,partialUserList:n,reactedByMyself:this._computeReactedByMyself({reactedByMyself:o,messageID:r.messageID,reactionID:s})};if(a.push(t),Be(o)&&!this._reactedByMyselfMap.has(r.messageID)){let e=r.messageID+"-"+s;this._reactionInfoMap.set(e,t)}}),e.push({messageID:r.messageID,reactionList:a})}),e})}_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(){Se.l(this._n+".reset"),this._reactedByMyselfMap.clear(),this._reactionInfoMap.clear()}}class Qn extends li{constructor(e){super(e),this._n="ComboMsgModule"}sendMessage(e){let n=this._createMsg(e);if(null===n)return ci({code:ni.MSG_SEND_FAIL});this._addSendMessageTotalCount(n);let r=Date.now();return this.get(Os).setMessageRandom(n),this._sendComboMessage(n,e).then(e=>{var{time:e,sequence:s,readReceiptCode:i}=e.data,i=(Fe(i)&&0!==i&&(new Ei("sendMessageWithReceipt").setMessage(`from:${n.from} to:${n.to} sequence:${s} readReceiptCode:`+i).end(),Se.w(this._n+`.sendMessage readReceiptCode:${i} message:`+this.getErrMsg(i))),this._addSendMessageSuccessCount(n,r),this.get(Os));n.status=kt,n.time=e,n.conversationType===t.CONV_GROUP&&(n.sequence=s),i.appendToMessageList(n);let o=n;return!0===n._isExcludedFromLastMessage&&(o=""),i.onMessageSent({conversationOptionsList:[{conversationID:n.conversationID,unreadCount:0,type:n.conversationType,subType:n.conversationSubType,lastMessage:o}]}),si({message:n})}).catch(e=>this._onSendMessageFailed(n,e))}_sendComboMessage(e,s){var i=this._m.get(Fs);let o="";return e.conversationType===t.CONV_C2C&&(o=f.NAME.OPEN_IM+"."+ui.SEND_C2C_MSG),e.conversationType===t.CONV_GROUP&&(o=f.NAME.GRP+"."+ui.SEND_GRP_MSG),i.sendComboMessage({servcmd:o,data:s})}_createMsg(s){var i=this._n+"._createMsg";let o=null;try{var e=this.getMyUserID(),n=this.get(Es),r={};if(r.senderTinyID=this.getMyTinyID(),r.currentUser=e,r.from=s.From_Account||e,r.level=n.getMyLevel(),s.GroupId?(r.conversationID=""+t.CONV_GROUP+s.GroupId,r.conversationType=t.CONV_GROUP,r.to=s.GroupId):s.To_Account&&(r.conversationID=""+t.CONV_C2C+s.To_Account,r.conversationType=t.CONV_C2C,r.to=s.To_Account),r.time=s.MsgTimeStamp||0,r.random=s.Random||s.MsgRandom||0,r.priority=s.MsgPriority,$e(s.CloudCustomData)&&0<s.CloudCustomData.length&&(r.cloudCustomData=s.CloudCustomData),Ve(s.SendMsgControl)&&(r.messageControlInfo={},s.SendMsgControl.includes("NoUnread")&&(r.messageControlInfo.excludedFromUnreadCount=1),s.SendMsgControl.includes("NoLastMsg"))&&(r.messageControlInfo.excludedFromLastMessage=1),r.conversationType===t.CONV_GROUP&&Ve(s.To_Account)&&0<s.To_Account.length){let e=s.To_Account;50<s.To_Account.length&&(e=s.To_Account.slice(0,50),Se.w(i+" To_Account must be less than or equal to 50.")),r.receiverList=[...e],s.To_Account=[...e]}1!==s.IsNeedReadReceipt&&1!==s.NeedReadReceipt||(r.needReadReceipt=!0),1===s.SupportMessageExtension&&(r.isSupportExtension=!0),(o=new Ki(r)).status=Gt,s.MsgClientTime=o.clientTime,o.conversationType===t.CONV_C2C&&(s.MsgSeq=o.sequence);var a,l=s.MsgBody.length;for(let e=0;e<l;e++)"TIMTextElem"===(a=s.MsgBody[e]).MsgType?o.setTextElement(a.MsgContent.Text):"TIMCustomElem"===a.MsgType?o.setCustomElement({data:a.MsgContent.Data||"",description:a.MsgContent.Desc||"",extension:a.MsgContent.Ext||""}):"TIMFaceElem"===a.MsgType&&o.setFaceElement({index:a.MsgContent.Index,data:a.MsgContent.Data});var d=o.getElements();o.payload=d[0].content,o.type=d[0].type}catch(e){o=null,Se.e(i+" failed. error:",e)}return o}_onSendMessageFailed(e,t){e.status=wt,this.get(Os).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(),Se.e(this._n+`._onSendMessageFailed ${i} error:`,t),ci(new ii({code:t&&t.code?t.code:ni.MSG_SEND_FAIL,message:t&&t.message?t.message:void 0,data:{message:e}}))}_getSendMessageSpecifiedKey(s){if(s.conversationType===t.CONV_C2C)return hi;if(s.conversationType===t.CONV_GROUP){let e=this.get(Rs).getLocalGroupProfile(s.to);if(e)return s=e.type,ct(s)?gi:pi}}_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,Ot(t,!1))}}_addSendMessageFailCountOnUser(e,t){var{code:t=-1}=t,s=this.get(Bs),e=this._getSendMessageSpecifiedKey(e);jn(t)&&e&&s.addFailedCountOfUserSide(e)}}class eo extends li{constructor(e){super(e),this._n="PluginModule",this.plugins={}}registerPlugin(t){let s="0";Object.keys(t).forEach(e=>{this.plugins[e]=t[e],"tim-upload-plugin"===e&&"function"==typeof t[e].getVersion&&(s=t[e].getVersion())}),new Ei("registerPlugin").setMessage(""+Object.keys(t)).setMoreMessage("version:"+s).end()}getPlugin(e){return this.plugins[e]}reset(){}}class to extends li{constructor(e){super(e),this._n="SyncUnreadMsgModule",this._cookie="",this._onlineSyncFlag=!1,this.getIEmitInst().on(Qi.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=(Se.l(o+" options:",e),new Ei("syncUnread"));n.setMessage(JSON.stringify(e)),this.req({P:ui.SYNC_UNREAD_MSG,data:{cookie:t,syncFlag:s,isOnlineSync:i}}).then(e=>{var{cookie:t,syncFlag:s}=e.data,i=`$cookie:${t} syncFlag:`+s;Se.l(o+" ok. "+i),this._cookie=t,n.setMoreMessage(i).end(),Ge(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(),Se.e(o+" failed. error:",e)})}_dispatch(e){e.eventArray&&this.get(Fs).onMessage({head:{},body:{eventArray:e.eventArray,isInstantMessage:this._onlineSyncFlag,isSyncingEnded:e.isSyncingEnded}}),this.get(Ds).onNewMessage({dataList:e.messageList,isInstantMessage:!!e.isSyncingEnded&&this._onlineSyncFlag,C2CRemainingUnreadList:e.C2CRemainingUnreadList,C2CPairUnreadList:e.C2CPairUnreadList,isSyncingEnded:e.isSyncingEnded,isOnlineSync:this._onlineSyncFlag})}syncOnNeed(){Se.l(this._n+".syncOnNeed cookie:"+this._cookie),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:1})}syncOnReconnected(){Se.l(this._n+".syncOnReconnected cookie:"+this._cookie),this._onlineSyncFlag=!0,this._startSync({cookie:this._cookie,syncFlag:0,isOnlineSync:0})}reset(){Se.l(this._n+".reset"),this._onlineSyncFlag=!1,this._cookie=""}}let so={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",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",remoteSnapshotUrl:"SnapshotUrl",remoteThumbUrl:"ThumbUrl",remoteFileUrl:"Url",snapshotUrl:"",thumbUrl:""},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",PinnedMsg:"pinnedMessage",SdkGroupMessageId:"unPinnedMessageInfo",From_AccountLevel:"level",F_Ll:"level"},ignoreKeyWord:["C2C","ID","USP"]};function io(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()?no(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 no=t=>{let s=!1,i=!1,o=!1;for(let e=0;e<t.length;e++){var n=t[e];s&&/[a-zA-Z]/.test(n)&&n.toUpperCase()===n?(t=t.slice(0,e)+"-"+t.slice(e),s=!1,o=i,i=!0,e++):i&&o&&/[a-zA-Z]/.test(n)&&n.toLowerCase()===n?(t=t.slice(0,e-1)+"-"+t.slice(e-1),o=i,i=!1,s=!0):(s=n.toLowerCase()===n&&n.toUpperCase()!==n,o=i,i=n.toUpperCase()===n&&n.toLowerCase()!==n)}return t};function oo(e,t){let i=0;return function s(e,o){var t;return 100<++i?(i--,e):Ve(e)?(t=e.map(e=>qe(e)?s(e,o):e),i--,t):qe(e)?(t=pt(t=function(s){let i=Object.create(null);return Object.keys(s).forEach(e=>{var t=(t=>{if(!je(t))return!1;if(t!==io(t))for(let e=0;e<so.ignoreKeyWord.length&&!t.includes(so.ignoreKeyWord[e]);e++);var e,s;return Be(o[t])?(s=t)[0].toUpperCase()+io(s).slice(1):o[t]})((s[e],e));t&&(i[t]=s[e])}),i}(e),(e,t)=>Ve(e)||qe(e)?s(e,o):e),i--,t):void 0}(e,t)}function ro(e,o){return Ve(e)?e.map(e=>qe(e)?ro(e,o):e):qe(e)?pt(function(s){let i={};return Object.keys(s).forEach(e=>{var t;i[s[e],t=e,Be(o[t])?io(t):o[t]]=s[e]}),i}(e),e=>Ve(e)||qe(e)?ro(e,o):e):void 0}let ao=String.fromCharCode,co=function(e){let t=0|e.charCodeAt(0);if(55296<=t)if(t<56320){e=0|e.charCodeAt(1);if(56320<=e&&e<=57343){if(65535<(t=(t<<10)+e-56613888|0))return ao(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?ao(192|t>>>6,128|63&t):ao(224|t>>>12,128|t>>>6&63,128|63&t)},lo=function(e){var t=void 0===e?"":(""+e).replace(/[\x80-\uD7ff\uDC00-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]?/g,co),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 uo{constructor(e){var t=(this._handler=e).getURL();if(this._socket=null,this._workerSocket=null,this._id=Qe(),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: "onClose", 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"})),o=(this._workerSocket=new Worker(e),this);this._workerSocket.onmessage=function(e){var{callback:t,e:s,extensions:i}=e.data;"onOpen"===t?o._onOpen(i):"onClose"===t?o._onClose(s):"onError"===t?o._onError(s):"onMessage"===t&&o._onMessage(e.data)},this._workerSocket.postMessage({cmd:"start",id:this._id,url:t})}else if($){let e={"content-type":"application/json"};G?(B.connectSocket({url:t,header:e}),B.onSocketClose(this._onClose.bind(this)),B.onSocketOpen(this._onOpen.bind(this)),B.onSocketMessage(this._onMessage.bind(this)),B.onSocketError(this._onError.bind(this))):P?this._socket=B.connectSocket({url:t,header:e,success:()=>{this._bindEventsInMini()},fail:e=>{this._onFail({code:e.errNo,reason:e.errMsg})}}):(this._socket=B.connectSocket({url:t,header:e,complete:()=>{}}),this._bindEventsInMini())}else 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}getClient(){return this._socket}_bindEventsInMini(){this._socket.onOpen(this._onOpen.bind(this)),this._socket.onMessage(this._onMessage.bind(this)),this._socket.onClose(this._onClose.bind(this)),this._socket.onError(this._onError.bind(this))}_onOpen(e){this._handler.onOpen({id:this._id,res:JSON.stringify(e)})}_onClose(e){this._handler.onClose({id:this._id,e:e})}_onFail(e){this._handler.onFail({id:this._id,e:e})}_onMessage(e){e=this._canIUseBinaryFrame?this._isAppCompressedData(e.data)?this._handler.inflate(e.data):function(e){var o=new Uint8Array(e);let n="",r=0;for(var a=o.length;r<a;){let t=o[r],s=0,i=0;if(t<=127?(s=0,i=255&t):t<=223?(s=1,i=31&t):t<=239?(s=2,i=15&t):t<=244&&(s=3,i=7&t),0<a-r-s){let e=0;for(;e<s;)t=o[r+e+1],i=i<<6|63&t,e+=1}else i=65533,s=a-r;n+=String.fromCodePoint(i),r+=s+1}return n}(e.data):e.data;this._handler.onMessage({data:e})}_isAppCompressedData(e){e=new Uint8Array(e);return 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),G?(B.offSocketClose(),B.offSocketMessage(),B.offSocketOpen(),B.offSocketError(),B.closeSocket()):this._socket&&($?(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),U?this._socket.close({code:e}):this._socket.close(e),this._socket=null)}send(e){this._workerSocket?this._workerSocket.postMessage({cmd:"sendMessage",data:this._canIUseBinaryFrame?lo(e.data).buffer:e.data}):G?B.sendSocketMessage({data:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}}):this._socket&&($?this._socket.send({data:this._canIUseBinaryFrame?lo(e.data).buffer:e.data,fail:()=>{e.fail&&e.requestID&&e.fail(e.requestID)}}):this._socket.send(this._canIUseBinaryFrame?lo(e.data):e.data))}}let _o=4e3,ho=4001,po="connected",go="connecting",mo="disconnected";class fo{constructor(e){this._chM=e,this._n="SocketHandler",this._promiseMap=new Map,this._readyState=mo,this._simpleRequestMap=new Map,this.MAX_SIZE=100,this._startSequence=Qe(),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=c,this._setWebsocketHost(),this._initConnection(),this._addAppVisibilityListener()}_addAppVisibilityListener(){P&&B.onAppShow(()=>{Se.l(this._n+"._addAppVisibilityListener onAppShow readyState:"+this._readyState),this._readyState===mo&&this._initConnection()})}_setWebsocketHost(){var e=this._chM.get(Ns);this._currentSite=c,this._chM.isOversea()&&(this._currentSite=l),e.isSingaporeSite()?this._currentSite=u:e.isKoreaSite()?this._currentSite=d:e.isGermanySite()?this._currentSite=_:e.isIndiaSite()?this._currentSite=h:e.isJapanSite()?this._currentSite=p:e.isUSASite()?this._currentSite=g:e.isIndonesiaSite()&&(this._currentSite=m),f.HOST.setCurrent(this._currentSite)}_initConnection(){var e=this._chM.get(Ns).getSDKAppID()+"",t=this._chM.get(Ns).isIndependentDomainDisabled(),t=(Be(f.HOST.CURRENT.BACKUP)?this._url=f.HOST.CURRENT.DEFAULT:""===this._url?this._url=t?f.HOST.CURRENT.DEFAULT:f.HOST.CURRENT.DEFAULT0.replace("*",e):-1<this._url.indexOf(e)?this._url=f.HOST.CURRENT.DEFAULT:this._url===f.HOST.CURRENT.DEFAULT?this._url=f.HOST.CURRENT.IPV6:this._url===f.HOST.CURRENT.IPV6?this._url=V?this._genRandomDomain():f.HOST.CURRENT.BACKUP:this._isWebBackupUrl(this._url)||this._url===f.HOST.CURRENT.BACKUP?this._canIUseBackupCN()?this._url=f.HOST.CURRENT.BACKUP_CN:this._canIUseAnyCast()?this._url=f.HOST.CURRENT.ANYCAST:this._url=f.HOST.CURRENT.DEFAULT:this._url===f.HOST.CURRENT.BACKUP_CN?this._url=this._canIUseAnyCast()?f.HOST.CURRENT.ANYCAST:f.HOST.CURRENT.DEFAULT:this._url===f.HOST.CURRENT.ANYCAST&&(f.HOST.CURRENT.ANYCAST="",this._url=f.HOST.CURRENT.DEFAULT),this._chM.get(Ns)),e=t.getProxyServer();Ge(e)||(this._url=e),t.isTestEnv()&&(this._url=n.TEST[this._currentSite].DEFAULT),this._connect(),this._nextPingTs=0}_genRandomDomain(){var e=Math.floor(10001*Math.random())+1e4;return f.HOST.CURRENT.BACKUP_WEB.replace("*",e)}_isWebBackupUrl(e){return e.includes("my-cpaas.com")}_canIUseAnyCast(){return V&&f.HOST.CURRENT.ANYCAST}_canIUseBackupCN(){return f.HOST.CURRENT.BACKUP_CN}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(ui.LOGIN)?o=9e4:-1!==t.indexOf(ui.PING)&&(o=3e3),Date.now()-s>=o&&(Se.l(this._n+"._checkPromiseMap request timeout, delete requestID:"+t),this._promiseMap.delete(t),e(new ii({code:ni.NETWORK_TIMEOUT,data:{headSeq:i}})),this._chM.onRequestTimeout())})}_checkNativeAppWS(){w&&!this.isConnected()&&this._reConnect()}onOpen(e){var t,s;this._readyState!==mo&&(this._onOpenTs=Date.now(),{id:e,res:t}=e,this._socketID=e,s=Ot(this._startTs,!1),e=`socketID:${e} res:`+t,Se.l(this._n+`._onOpen cost:${s} ms. `+e),new Ei("wsOnOpen").setMessage(s).setCostTime(s).setMoreMessage(e).end(),this._readyState=po,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),Se.l(this._n+`._onClose ${i} onlineTime:`+o),e!==this._socketID||G&&!0===this._reConnectFlag&&e===this._socketID&&0===o||(this._readyState=mo,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),Se.w(this._n+"._onError",t,s),e===this._socketID&&(this._readyState=mo,this._chM.onError())}onFail(e){this._readyState=mo;var{id:e,e:t}=e,e=`currentSocketID:${e} code:${t.code} reason:`+t.reason;new Ei("wsOnFail").setMessage(e).setCode(t.code).end(!0),Se.l(this._n+"._onFail "+e)}onMessage(t){let s;try{s=JSON.parse(t.data)}catch(e){new Ei("jsonParseError").setMessage(t.data).end()}if(s&&s.head){var n=this._getRequestIDFromHead(s.head);let o=s.body;if(!this._chM.get(Ys).isTRTCCommand(n)){let e=Tt(s.head);o=ro(s.body,this._getResKeyMap(e))}if(Se.d(`${this._n}.onMessage ret:${JSON.stringify(o)} requestID:${n} has:`+this._promiseMap.has(n)),this._setNextPingTs(),this._promiseMap.has(n)){let{resolve:e,reject:t,timestamp:s,headSeq:i}=this._promiseMap.get(n);this._promiseMap.delete(n),this._calcRTT(s),void(o.errorCode&&0!==o.errorCode?(this._chM.onErrorCodeNotZero(o),t(new ii({code:o.errorCode,message:o.errorInfo||"",data:n.includes(ui.MODIFY_C2C_MSG)||n.includes(ui.MODIFY_GRP_MSG)?{elements:o.elements,messageVersion:o.messageVersion,cloudCustomData:o.cloudCustomData,headSeq:i}:{headSeq:i}}))):e(si(o)))}else this._chM.onMessage({head:s.head,body:o})}}_calcRTT(e){e=Date.now()-e;this._chM.get(Bs).addRTT(e)}_connect(){if(this._readyState!==go&&this._readyState!==po){if(this._startTs=Date.now(),this._onOpenTs=0,this._readyState=go,this._socket=new uo(this),this._socketID=this._socket.getID(),P){var e=this._socket.getClient().readyState;if(Be(e))return void(this._readyState=mo)}new Ei("wsConnect").setMessage(`socketID:${this._socketID} url:`+this.getURL()).end(),Se.l(`${this._n}._connect isWorkerEnabled:${this.getIsWorkerEnabled()} socketID:${this._socketID} url:`+this.getURL())}}getURL(){this._chM.isDevMode()&&(this._canIUseBinaryFrame=!1);let e=ft();if((G||A&&"windows"===e)&&(this._canIUseBinaryFrame=!1),w){let{uniRuntimeVersion:i=""}=B.getSystemInfoSync(),e=function(){var[e=0,t=0,s=0]=i.split(".").map(Number);return 2<e||!(e<2)&&(2<t||!(t<2)&&6<=s)}();Se.l(`${this._n}.getURL uniRuntimeVersion:${i} isUniRuntimeVersionGte226:`+e),e||(this._canIUseBinaryFrame=!1)}let t=-1;"ios"===e?t=X||-1:"android"===e&&(t=Q||-1);var s=this._chM.get(Ns),i=this._chM.getPlatform();let o=`sdkappid=${s.getSDKAppID()}&instanceid=${s.getInstanceID()}&random=${this._getRandom()}&platform=${i}&host=${e}&version=${t}&sdkversion=3.6.5`;return O&&(o+="&isminigame=1"),this._chM.canIUseInflate()&&(o+="&compress=gzip"),this._canIUseBinaryFrame?this._url+"/binfo?"+o:this._url+"/info?"+o}_closeConnection(e){Se.l(this._n+"._closeConnection socketID:"+this._socketID),this._socket&&(this._socket.close(e),this._socketID=-1,this._socket=null,this._readyState=mo)}_resend(){if(Se.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(ui.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(s){s.head.seq=this._getSequence(),s.head.reqtime=Math.floor(Date.now()/1e3),s.head.cs=this._calcCheckSum(s.head.servcmd,s.body);let{keyMap:e,...i}=s,o=this._getRequestIDFromHead(s.head),n=JSON.stringify(i);return new Promise((e,t)=>{this._promiseMap.set(o,{resolve:e,reject:t,timestamp:Date.now(),uplinkData:n,headSeq:s.head.seq}),Se.d(`${this._n}.send uplinkData:${JSON.stringify(i)} requestID:${o} readyState:`+this._readyState),this._readyState!==po?this._reConnect():(this._execute(o,n),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!==po?(this._simpleRequestMap.size<this.MAX_SIZE?this._simpleRequestMap.set(i,o):Se.l(this._n+".simplySend. simpleRequestMap is full, drop request!"),this._reConnect()):this._execute(i,o)}_execute(e,t){this._socket.send({data:t,fail:$?this._onSendFail.bind(this):void 0,requestID:e})}_onSendFail(e){Se.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=Qe()),e}_getRequestIDFromHead(e){var{servcmd:e,seq:t}=e;return e+t}_getResKeyMap(e){e=this._chM.getKeyMap(e);return{...so.res,...e.res}}_reConnect(){this._readyState!==po&&this._readyState!==go&&this.forcedReconnect()}forcedReconnect(){var e=this._n+".forcedReconnect";Se.l(e+` count:${this._reConnectCount} readyState:`+this._readyState),this._reConnectFlag=!0,this._resetRandom(),this._reConnectCount<this.MAX_RECONNECT_COUNT?(this._reConnectCount+=1,this._closeConnection(ho),this._initConnection()):(this._reConnectCount=0,this._chM.get(Gs).isOnline()?(Se.w(e+" disconnected from wsserver but network is ok, continue..."),this._closeConnection(ho),this._initConnection()):this._chM.onReconnectFailed())}getReconnectFlag(){return this._reConnectFlag}_setNextPingTs(){this._nextPingTs=w?Date.now()+5e3:Date.now()+1e4}getNextPingTs(){return this._nextPingTs}isConnected(){return this._readyState===po}canIUseBinaryFrame(){return this._canIUseBinaryFrame}getSocketID(){return this._socketID}inflate(e){if(this._chM.canIUseInflate())return this._chM.get(ei).inflate(e)}setIsWorkerEnabled(e){Se.l(this._n+".setIsWorkerEnabled flag:"+e),this._isWorkerEnabled=e}getIsWorkerEnabled(){return this._isWorkerEnabled&&ae}_getRandom(){return 0===this._random&&(this._random=Math.random()),this._random}_resetRandom(){this._random=0}_calcCheckSum(e,t){if(-1!==e.indexOf(ui.PING)||-1!==e.indexOf(ui.LOGIN)||-1!==e.indexOf(ui.LOGOUT)||-1!==e.indexOf(ui.AV_POLLING)||-1!==e.indexOf(ui.AV_NOAUTH_POLLING))return 0;var s=lo(JSON.stringify(t));let i=4294967295;for(let e=0,t=s.length;e<t;e++){i^=s[e];for(let e=0;e<8;e++)1==(1&i)?i=i>>>1^3988292384:i>>>=1}return(4294967295^i)>>>0}close(){Se.l(this._n+".close"),this._closeConnection(_o),this._promiseMap.clear(),this._startSequence=Qe(),this._readyState=mo,this._simpleRequestMap.clear(),this._reConnectFlag=!1,this._reConnectCount=0,this._onOpenTs=0,this._url="",this._random=0,this._canIUseBinaryFrame=!0,this._isWorkerEnabled=!0}}let Mo=function(n,r,a){return new Promise((s,i)=>{var o="application/x-www-form-urlencoded;charset=UTF-8";if($)B.request({url:r,data:a,method:n,timeout:3e3,header:{"content-type":o},success:e=>{e&&e.data&&e.data.NetCheckInfo&&Se.l("getconninfo ok in miniapp. ret:",e.data),s()},fail:()=>{i(new ii({code:ni.NETWORK_ERROR}))}});else{let e=new XMLHttpRequest,t=setTimeout(()=>{e.abort(),i(new ii({code:ni.NETWORK_TIMEOUT}))},3e3);e.onreadystatechange=function(){4===e.readyState&&(t&&clearTimeout(t),200===e.status||304===e.status?(e.responseText&&-1<e.responseText.indexOf("NetCheckInfo")&&Se.l("getconninfo ok in web. ret:",JSON.parse(e.responseText)),s()):i(new ii({code:ni.NETWORK_ERROR})))},e.open(n,r,!0),e.setRequestHeader("Content-type",o),a?e.send(a):e.send()}})};class Io extends li{constructor(e){super(e),this._n="ChannelModule",this._socketHandler=new fo(this),this._probing=!1,this._isAppShowing=!0,this._previousState=t.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(Fs).onErrorCodeNotZero(e)}onMessage(e){this.get(Fs).onMessage(e)}send(e){return this._socketHandler?this._previousState!==t.NET_STATE_CONNECTED&&e.head.servcmd.includes(ui.SSO_STAT)?(this.reConnect(),this.isPrivateNetWork()?Promise.resolve():this._sendLogViaHTTP(e)):this._socketHandler.send(e):Promise.reject()}_sendLogViaHTTP(e){var t=`${f.HOST.CURRENT.STAT}/v4/imopenstat/tim_web_report_v2?sdkappid=${e.head.sdkappid}&reqtime=`+Date.now(),e=JSON.stringify(e.body);return Mo("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(t.NET_STATE_DISCONNECTED),this.reConnect()}onError(){$&&!w&&this.warn("DomainNameInMP"),this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}getKeyMap(e){return this.get(Fs).getKeyMap(e)}onRequestTimeout(){3e4<=Date.now()-this._lastDiagnoseTS&&this.diagnose()}onSendFail(){this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}onReconnected(){Se.l(this._n+".onReconnected cost:"+Ot(this._disconnectedTS,!0,!0)),this._m.restartTimer(),this.get(Fs).onReconnected(Ot(this._disconnectedTS,!1,!1)),this._disconnectedTS=0,this._emitNetStateChangeEvent(t.NET_STATE_CONNECTED)}onReconnectFailed(){Se.l(this._n+".onReconnectFailed"),this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}setIsWorkerEnabled(e){this._socketHandler&&this._socketHandler.setIsWorkerEnabled(!1)}offline(){this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)}reConnect(e=!1){let s=!1;this._socketHandler&&(s=this._socketHandler.getReconnectFlag());var i=`forcedFlag:${e} fatalErrorFlag:${this._fatalErrorFlag} previousState:${this._previousState} reconnectFlag:`+s;Se.l(this._n+".reConnect "+i),this._fatalErrorFlag||!this._socketHandler||!0!==e&&this._previousState===t.NET_STATE_CONNECTING&&s||(this._socketHandler.forcedReconnect(),this._emitNetStateChangeEvent(t.NET_STATE_CONNECTING))}_emitNetStateChangeEvent(s){this._previousState!==s&&(Se.l(`${this._n}._emitNetStateChangeEvent from ${this._previousState} to `+s),s===t.NET_STATE_DISCONNECTED&&0===this._disconnectedTS&&(this._disconnectedTS=Date.now(),this.diagnose()),this._previousState=s,this.emitOEvt(e.NET_STATE_CHANGE,{state:s}))}_ping(){var e;!0!==this._probing&&(this._probing=!0,e=this.get(Fs).getProtocolData({P:ui.PING}),this.send(e).then(()=>{this._probing=!1}).catch(e=>{this._probing=!1;var s=this.get(Gs).isOnline();Se.w(this._n+`._ping failed. bOnline:${s} error:`,e),e&&60002===e.code?(new Ei("error").setMessage(`code:${e.code} message:`+e.message).end(),this._fatalErrorFlag=!0,this._emitNetStateChangeEvent(t.NET_STATE_DISCONNECTED)):s?this.reConnect():this._emitNetStateChangeEvent(t.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(),Mo("GET",t).catch(e=>{Se.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();Mo("GET",e).catch(e=>{Se.w(this._n+"._diagnoseByCDN failed. error:",e)})}reset(){Se.l(this._n+".reset"),this._previousState=t.NET_STATE_CONNECTED,this._probing=!1,this._fatalErrorFlag=!1,this._timerForNotLoggedIn=setInterval(this.onCheckTimer.bind(this),1e3),this._disconnectedTS=0,this._lastDiagnoseTS=0}}class Co{constructor(e){this._n="PHandler",this._sessionM=e,this._map=new Map,this._fillMap()}_fillMap(){this._map.clear();var i=this._sessionM.genCommonHead(),e=this._sessionM.genCosSpecifiedHead(),t=this._sessionM.genSSOReportHead();this._map.set(ui.LOGIN,{head:{...i,servcmd:f.NAME.IM_OPEN_STATUS+"."+ui.LOGIN},body:{state:"Online",isWebUniapp:0,deviceBrand:0,customInfo:""},keyMap:{req:{deviceBrand:"InstType"},res:{InstId:"instanceID",HelloInterval:"helloInterval",RichMsgAuthKey:"authKey"}}}),this._map.set(ui.LOGOUT,{head:{...i,servcmd:f.NAME.IM_OPEN_STATUS+"."+ui.LOGOUT},body:{type:0,isWebUniapp:0},keyMap:{req:{type:"wslogout_type"}}}),this._map.set(ui.HELLO,{head:{...i,servcmd:f.NAME.IM_OPEN_STATUS+"."+ui.HELLO},body:{isWebUniapp:0},keyMap:{res:{NewInstInfo:"newInstanceInfo"}}}),this._map.set(ui.KICK_OTHER,{head:{...i,servcmd:f.NAME.STAT_SERVICE+"."+ui.KICK_OTHER},body:{}}),this._map.set(ui.COS_SIGN,{head:{...e,servcmd:f.NAME.IM_COS_SIGN+"."+ui.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(ui.COS_PRE_SIG,{head:{...e,servcmd:f.NAME.CUSTOM_UPLOAD+"."+ui.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(ui.SIMPLE_COS_PRE_SIG,{head:{...e,servcmd:f.NAME.CUSTOM_UPLOAD+"."+ui.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",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(ui.GET_IMAGE_INFO,{head:{...e,servcmd:f.NAME.CUSTOM_UPLOAD+"."+ui.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(ui.GET_IP,{head:{...e,servcmd:f.NAME.CUSTOM_UPLOAD+"."+ui.GET_IP},body:{domainName:""},keyMap:{req:{domainName:"str_domain"},res:{str_final_ip:"ip"}}}),this._map.set(ui.VIDEO_COVER,{head:{...e,servcmd:f.NAME.CUSTOM_UPLOAD+"."+ui.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(ui.FETCH_COMMERCIAL_CONFIG,{head:{...i,servcmd:f.NAME.IM_CONFIG_MANAGER+"."+ui.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(ui.PUSHED_COMMERCIAL_CONFIG,{head:{...i,servcmd:f.NAME.IM_CONFIG_MANAGER+"."+ui.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(ui.FETCH_CLOUD_CTRL_CONFIG,{head:{...i,servcmd:f.NAME.IM_CONFIG_MANAGER+"."+ui.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(ui.PUSHED_CLOUD_CTRL_CONFIG,{head:{...i,servcmd:f.NAME.IM_CONFIG_MANAGER+"."+ui.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(ui.OVERLOAD_NOTIFY,{head:{...i,servcmd:f.NAME.OVERLOAD_PUSH+"."+ui.OVERLOAD_NOTIFY},body:{},keyMap:{res:{OverLoadServCmd:"overloadCommand",DelaySecs:"waitingTime"}}}),this._map.set(ui.SYNC_UNREAD_MSG,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.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(ui.GET_PROFANITY_LIST,{head:{...i,servcmd:f.NAME.IM_MSG_AUDIT_MGR+"."+ui.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(ui.SEND_C2C_MSG,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.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:"",interruptionLevel:"active",contentAvailable:0},androidInfo:{sound:"",XiaoMiChannelID:"",OPPOChannelID:"",GoogleChannelID:"",VIVOClassification:1,VIVOCategory:"",HuaWeiCategory:"",OPPOCategory:"",HuaWeiImage:"",HonorImage:"",GoogleImage:"",HonorImportance:"",MeizuNotifyType:void 0}},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",MeizuNotifyType:"MeiZuNoticeMsgType"}}}),this._map.set(ui.SEND_GRP_MSG,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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:"",interruptionLevel:"active",contentAvailable:0},androidInfo:{sound:"",XiaoMiChannelID:"",OPPOChannelID:"",GoogleChannelID:"",VIVOClassification:1,VIVOCategory:"",HuaWeiCategory:"",OPPOCategory:"",HuaWeiImage:"",HonorImage:"",GoogleImage:"",HonorImportance:"",MeizuNotifyType:void 0}},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",MeizuNotifyType:"MeiZuNoticeMsgType"},res:{MsgTime:"time",MsgSeq:"sequence"}}}),this._map.set(ui.REVOKE_C2C_MSG,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.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(ui.REVOKE_GRP_MSG,{head:{...i,servcmd:f.NAME.GRP+"."+ui.REVOKE_GRP_MSG},body:{groupID:"",msgSeqList:void 0,topicID:""},keyMap:{req:{msgSeqList:"MsgSeqList",msgSeq:"MsgSeq"}}}),this._map.set(ui.GET_C2C_ROAMING_MSG,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.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(ui.MODIFY_C2C_MSG,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.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(ui.GET_GRP_ROAMING_MSG,{head:{...i,servcmd:f.NAME.GRP+"."+ui.GET_GRP_ROAMING_MSG},body:{withRecalledMsg:1,groupID:"",count:15,sequence:void 0,topicID:void 0,getType:void 0,reqMsgSeqList: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(ui.SET_C2C_MSG_READ,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.SET_C2C_MSG_READ},body:{C2CMsgReaded:void 0},keyMap:{req:{lastMessageTime:"LastedMsgTime"}}}),this._map.set(ui.SET_C2C_PEER_MUTE_NOTIFICATIONS,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.SET_C2C_PEER_MUTE_NOTIFICATIONS},body:{userIDList:void 0,muteFlag:0},keyMap:{req:{userIDList:"Peer_Account",muteFlag:"Mute_Notifications"}}}),this._map.set(ui.GET_C2C_PEER_MUTE_NOTIFICATIONS,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.GET_C2C_PEER_MUTE_NOTIFICATIONS},body:{toAccount:void 0,userIDList:void 0},keyMap:{req:{userIDList:"Peer_Account"},res:{MuteNotificationsList:"muteFlagList"}}}),this._map.set(ui.SET_GRP_MSG_READ,{head:{...i,servcmd:f.NAME.GRP+"."+ui.SET_GRP_MSG_READ},body:{groupID:void 0,messageReadSeq:void 0,topicID:void 0},keyMap:{req:{messageReadSeq:"MsgReadedSeq"}}}),this._map.set(ui.SET_ALL_MSG_READ,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.SET_ALL_MSG_READ},body:{readAllC2CMessage:0,groupMessageReadInfoList:[]},keyMap:{req:{readAllC2CMessage:"C2CReadAllMsg",groupMessageReadInfoList:"GroupReadInfo",messageSequence:"MsgSeq"},res:{C2CReadAllMsg:"readAllC2CMessage",GroupReadInfoArray:"groupMessageReadInfoList"}}}),this._map.set(ui.DEL_C2C_MSG,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.DEL_C2C_MSG},body:{fromAccount:"",to:"",keyList:void 0},keyMap:{req:{keyList:"MsgKeyList"}}}),this._map.set(ui.DEL_GRP_MSG,{head:{...i,servcmd:f.NAME.GRP+"."+ui.DEL_GRP_MSG},body:{groupID:"",deleter:"",keyList:void 0,topicID:void 0},keyMap:{req:{deleter:"Deleter_Account",keyList:"Seqs"}}}),this._map.set(ui.TRANSLATE_TEXT,{head:{...i,servcmd:f.NAME.IM_OPEN_TRANSLATE+"."+ui.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(ui.VOICE_TO_TEXT,{head:{...i,servcmd:f.NAME.IM_OPEN_SPEECH+"."+ui.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(ui.MODIFY_GRP_MSG,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.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(ui.GET_READ_RECEIPT,{head:{...i,servcmd:f.NAME.GRP+"."+ui.GET_READ_RECEIPT},body:{groupID:"",sequenceList:void 0},keyMap:{req:{sequence:"MsgSeq"}}}),this._map.set(ui.SEND_C2C_READ_RECEIPT,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.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(ui.SEND_READ_RECEIPT,{head:{...i,servcmd:f.NAME.GRP+"."+ui.SEND_READ_RECEIPT},body:{groupID:"",sequenceList:void 0},keyMap:{req:{sequenceList:"MsgSeqList",sequence:"MsgSeq"}}}),this._map.set(ui.GET_READ_RECEIPT_DETAIL,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.GET_GRP_RECEIPTS_BY_USERS,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.MODIFY_C2C_MSG_EXT,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.MODIFY_C2C_MSG_EXT},body:{from:void 0,to:void 0,messageKey:void 0,operateType:void 0,extensionList:void 0}}),this._map.set(ui.GET_C2C_MSG_EXT,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.GET_C2C_MSG_EXT},body:{from:void 0,to:void 0,messageKey:void 0,startSequence:void 0}}),this._map.set(ui.MODIFY_GRP_MSG_EXT,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.MODIFY_GRP_MSG_EXT},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,operateType:void 0,extensionList:void 0}}),this._map.set(ui.GET_GRP_MSG_EXT,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.GET_GRP_MSG_EXT},body:{groupID:void 0,topicID:void 0,messageSequence:void 0,startSequence:void 0}}),this._map.set(ui.ADD_C2C_MSG_REACTION,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.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(ui.RM_C2C_MSG_REACTION,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.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(ui.GET_C2C_MSG_REACTIONS,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.GET_C2C_MSG_REACTIONS},body:{from:void 0,to:void 0,messageKeyList:void 0,count:void 0}}),this._map.set(ui.GET_C2C_MSG_REACTION_USER_LIST,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.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(ui.ADD_GRP_MSG_REACTION,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.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(ui.RM_GRP_MSG_REACTION,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.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(ui.GET_GRP_MSG_REACTIONS,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.GET_GRP_MSG_REACTIONS},body:{groupID:void 0,topicID:void 0,messageSequenceList:void 0,count:void 0},keyMap:{res:{MsgSeq:"messageSequence"}}}),this._map.set(ui.GET_GRP_MSG_REACTION_USER_LIST,{head:{...i,servcmd:f.NAME.OPEN_IM_MSG_EXT+"."+ui.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(ui.GET_C2C_PEER_READ_TIME,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.GET_C2C_PEER_READ_TIME},body:{userIDList:void 0},keyMap:{req:{userIDList:"To_Account"},res:{ReadTime:"peerReadTimeList"}}}),this._map.set(ui.PAGING_GET_CONV_LIST,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.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(ui.DEL_CONV,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.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(ui.CLEAR_HISTORY_MSG,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.CLEAR_HISTORY_MSG},body:{fromAccount:"",toAccount:void 0,type:1,toGroupID:void 0},keyMap:{req:{toGroupID:"ToGroupid"}}}),this._map.set(ui.PIN_CONV,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.PIN_CONV},body:{fromAccount:"",operationType:1,itemList:void 0},keyMap:{req:{itemList:"RecentContactItem"}}}),this._map.set(ui.DEL_GROUP_AT_TIPS,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.DEL_GROUP_AT_TIPS},body:{messageListToDelete:void 0},keyMap:{req:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}),this._map.set(ui.SET_CONV_CUSTOM_DATA,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.MARK_CONV},body:{fromAccount:"",itemList:void 0},keyMap:{req:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},res:{ToGroupId:"groupID",OptType:"operationType"}}}),this._map.set(ui.MARK_CONV,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.MARK_CONV},body:{fromAccount:"",itemList:void 0},keyMap:{req:{itemList:"MarkItem",operationType:"OptType",groupID:"ToGroupId"},res:{ToGroupId:"groupID",OptType:"operationType"}}}),this._map.set(ui.CREATE_CONV_GRP,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.CREATE_CONV_GRP},body:{fromAccount:"",itemList:void 0},keyMap:{req:{itemList:"GroupContactItem",groupID:"ToGroupId"},res:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType"}}}),this._map.set(ui.DEL_CONV_GRP,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.DEL_CONV_GRP},body:{fromAccount:"",groupName:void 0},keyMap:{res:{GroupId:"convGroupID"}}}),this._map.set(ui.RENAME_CONV_GRP,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.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(ui.ADD_CONV_TO_GRP,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.RENAME_CONV_GRP},body:{fromAccount:"",updateType:void 0,updateGroup:{groupName:void 0,updateGroupType:void 0,updateItem:void 0}}}),this._map.set(ui.DEL_CONV_FROM_GRP,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.RENAME_CONV_GRP},body:{fromAccount:"",updateType:void 0,updateGroup:void 0}}),this._map.set(ui.GET_CONV_GRP_LIST,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.GET_CONV_GRP_LIST},body:{fromAccount:"",startIndex:void 0},keyMap:{res:{GroupId:"convGroupID",ToGroupId:"groupID",OptType:"operationType",CustomMark:"customData",ContactGroupId:"convGroupIDList"}}}),this._map.set(ui.SEARCH_CONV_GRP_MARK,{head:{...i,servcmd:f.NAME.RECENT_CONTACT+"."+ui.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(ui.GET_USER_PROFILE,{head:{...i,servcmd:f.NAME.PROFILE+"."+ui.GET_USER_PROFILE},body:{fromAccount:"",userItem:[]},keyMap:{req:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}),this._map.set(ui.UPDATE_MY_PROFILE,{head:{...i,servcmd:f.NAME.PROFILE+"."+ui.UPDATE_MY_PROFILE},body:{fromAccount:"",profileItem:[{tag:De.NICK,value:""},{tag:De.GENDER,value:""},{tag:De.ALLOWTYPE,value:""},{tag:De.AVATAR,value:""}]},keyMap:{req:{toAccount:"To_Account",standardSequence:"StandardSequence",customSequence:"CustomSequence"}}}),this._map.set(ui.GET_BL,{head:{...i,servcmd:f.NAME.FD+"."+ui.GET_BL},body:{fromAccount:"",startIndex:0,maxLimited:30}}),this._map.set(ui.ADD_TO_BL,{head:{...i,servcmd:f.NAME.FD+"."+ui.ADD_TO_BL},body:{fromAccount:"",toAccount:[]}}),this._map.set(ui.RM_FROM_BL,{head:{...i,servcmd:f.NAME.FD+"."+ui.RM_FROM_BL},body:{fromAccount:"",toAccount:[]}}),this._map.set(ui.SET_SELF_STATUS,{head:{...i,servcmd:f.NAME.IM_OPEN_STATUS+"."+ui.SET_SELF_STATUS},body:{customStatus:""}}),this._map.set(ui.GET_USER_STATUS,{head:{...i,servcmd:f.NAME.IM_OPEN_STATUS+"."+ui.GET_USER_STATUS},body:{userIDList:void 0},keyMap:{res:{UserStatusList:"successUserList",ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID",Status:"statusType"}}}),this._map.set(ui.SUB_USER_STATUS,{head:{...i,servcmd:f.NAME.IM_OPEN_STATUS+"."+ui.SUB_USER_STATUS},body:{userIDList:void 0},keyMap:{res:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}),this._map.set(ui.UNSUB_USER_STATUS,{head:{...i,servcmd:f.NAME.IM_OPEN_STATUS+"."+ui.UNSUB_USER_STATUS},body:{userIDList:void 0,unsubscribeAll:void 0},keyMap:{res:{ErrorList:"failureUserList",To_Account:"userID",Invalid_Account:"invalidUserID"}}}),this._map.set(ui.GET_FD_LIST,{head:{...i,servcmd:f.NAME.FD+"."+ui.GET_FD_LIST},body:{fromAccount:"",startIndex:0,standardSequence:0,customSequence:0},keyMap:{res:{FriendNum:"friendCount",UserDataItem:"resultList",ValueItem:"tagValueList"}}}),this._map.set(ui.ADD_FD,{head:{...i,servcmd:f.NAME.FD+"."+ui.ADD_FD},body:{fromAccount:"",addFriendItem:[],type:""},keyMap:{req:{source:"AddSource",wording:"AddWording",type:"AddType"},res:{ResultItem:"resultList"}}}),this._map.set(ui.UPDATE_FD,{head:{...i,servcmd:f.NAME.FD+"."+ui.UPDATE_FD},body:{fromAccount:"",updateItem:void 0},keyMap:{req:{snsItem:"SnsItem"},res:{ResultItem:"resultList"}}}),this._map.set(ui.DEL_FD,{head:{...i,servcmd:f.NAME.FD+"."+ui.DEL_FD},body:{fromAccount:"",userIDList:[],type:""},keyMap:{req:{type:"DeleteType"},res:{ResultItem:"resultList"}}}),this._map.set(ui.GET_FD_PROFILE,{head:{...i,servcmd:f.NAME.FD+"."+ui.GET_FD_PROFILE},body:{fromAccount:"",userIDList:void 0},keyMap:{res:{InfoItem:"resultList",SnsProfileItem:"tagValueList"}}}),this._map.set(ui.CHECK_FD,{head:{...i,servcmd:f.NAME.FD+"."+ui.CHECK_FD},body:{fromAccount:"",userIDList:[],type:""},keyMap:{req:{type:"CheckType"},res:{InfoItem:"resultList"}}}),this._map.set(ui.GET_FD_APPLICATION_LIST,{head:{...i,servcmd:f.NAME.FD+"."+ui.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(ui.RESPOND_FD_APPLICATION,{head:{...i,servcmd:f.NAME.FD+"."+ui.RESPOND_FD_APPLICATION},body:{fromAccount:"",responseFriendItem:[]},keyMap:{req:{tag:"TagName",action:"ResponseAction"},res:{ResultItem:"resultList"}}}),this._map.set(ui.DEL_FD_APPLICATION,{head:{...i,servcmd:f.NAME.FD+"."+ui.DEL_FD_APPLICATION},body:{fromAccount:"",type:"",userIDList:void 0},keyMap:{req:{type:"PendencyType",userIDList:"To_Account"},res:{ResultItem:"resultList"}}}),this._map.set(ui.REPORT_FD_APPLICATION,{head:{...i,servcmd:f.NAME.FD+"."+ui.REPORT_FD_APPLICATION},body:{fromAccount:"",latestTimeStamp:""},keyMap:{req:{latestTimeStamp:"LatestPendencyTimeStamp"}}}),this._map.set(ui.CREATE_FD_GRP,{head:{...i,servcmd:f.NAME.FD+"."+ui.CREATE_FD_GRP},body:{fromAccount:"",groupName:void 0,userIDList:void 0},keyMap:{req:{groupName:"GroupName",userIDList:"To_Account"},res:{ResultItem:"resultList"}}}),this._map.set(ui.DEL_FD_GRP,{head:{...i,servcmd:f.NAME.FD+"."+ui.DEL_FD_GRP},body:{fromAccount:"",nameList:void 0},keyMap:{req:{nameList:"GroupName"}}}),this._map.set(ui.GET_FD_GRP_LIST,{head:{...i,servcmd:f.NAME.FD+"."+ui.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(ui.UPDATE_FD_GRP,{head:{...i,servcmd:f.NAME.FD+"."+ui.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(ui.GET_GRP_LIST,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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",MuteAllMember:"muteAllMembers"}}}),this._map.set(ui.GET_GRP_PROFILE,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.CREATE_GRP,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.DISMISS_GRP,{head:{...i,servcmd:f.NAME.GRP+"."+ui.DISMISS_GRP},body:{groupID:void 0}}),this._map.set(ui.UPDATE_GRP_PROFILE,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.APPLY_JOIN_GRP,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.APPLY_JOIN_GRP_NOAUTH,function(){let{a2:e,tinyid:t,...s}=i;return{head:{...s,servcmd:f.NAME.BIG_GRP_NO_AUTH+"."+ui.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(ui.QUIT_GRP,{head:{...i,servcmd:f.NAME.GRP+"."+ui.QUIT_GRP},body:{groupID:void 0}}),this._map.set(ui.SEARCH_GRP,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.CHANGE_GRP_OWNER,{head:{...i,servcmd:f.NAME.GRP+"."+ui.CHANGE_GRP_OWNER},body:{groupID:void 0,newOwnerID:void 0},keyMap:{req:{newOwnerID:"NewOwner_Account"}}}),this._map.set(ui.HANDLE_GRP_APPLICATION,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.HANDLE_INVITE_JOIN_GRP,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.HANDLE_GRP_INVITATION,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.GET_GRP_PENDENCY,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.DEL_GRP_SYSTEM_NOTICE,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.DEL_GRP_SYSTEM_NOTICE},body:{messageListToDelete:void 0},keyMap:{req:{messageListToDelete:"DelMsgList",messageSeq:"MsgSeq",messageRandom:"MsgRandom"}}}),this._map.set(ui.AV_POLLING,{head:{...i,servcmd:f.NAME.BIG_GRP_POLLING+"."+ui.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(ui.AV_NOAUTH_POLLING,function(){let{a2:e,tinyid:t,...s}=i;return{head:{...s,servcmd:f.NAME.BIG_GRP_POLLING_NO_AUTH+"."+ui.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(ui.GET_ONLINE_MBR_NUM,{head:{...i,servcmd:f.NAME.GRP+"."+ui.GET_ONLINE_MBR_NUM},body:{groupID:void 0},keyMap:{res:{OnlineMemberNum:"memberCount"}}}),this._map.set(ui.SET_GRP_ATTR,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.MODIFY_GRP_ATTR,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.DEL_GRP_ATTR,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.CLEAR_GRP_ATTR,{head:{...i,servcmd:f.NAME.GRP+"."+ui.CLEAR_GRP_ATTR},body:{groupID:void 0,mainSequence:void 0,avChatRoomKey:void 0,attributeControl:["RaceConflict"]}}),this._map.set(ui.GET_GRP_ATTR,{head:{...i,servcmd:f.NAME.GRP_ATTR+"."+ui.GET_GRP_ATTR},body:{groupID:void 0,avChatRoomKey:void 0,groupType:1},keyMap:{req:{avChatRoomKey:"Key",groupType:"GroupType"}}}),this._map.set(ui.GET_GRP_NOTIFY,{head:{...i,servcmd:f.NAME.GRP+"."+ui.GET_GRP_NOTIFY},body:{notifyReqList:[]},keyMap:{req:{notifyReqList:"NotifyReqList"},res:{NextMsgTime:"nextRevokedTime",NotifyMsgList:"notifyList",NotifyRspList:"notifyRspList"}}}),this._map.set(ui.UPDATE_GRP_COUNTER,{head:{...i,servcmd:f.NAME.GRP+"."+ui.UPDATE_GRP_COUNTER},body:{groupID:void 0,counterList:void 0,avChatRoomKey:void 0,mode:void 0},keyMap:{req:{counterList:"GroupCounter"}}}),this._map.set(ui.GET_GRP_COUNTER,{head:{...i,servcmd:f.NAME.GRP+"."+ui.GET_GRP_COUNTER},body:{groupID:void 0,keyList:[],avChatRoomKey:void 0},keyMap:{req:{keyList:"GroupCounterKeys"}}}),this._map.set(ui.PIN_GRP_MSG,{head:{...i,servcmd:f.NAME.GRP+"."+ui.PIN_GRP_MSG},body:{groupID:void 0,topicID:void 0,sequence:void 0,operator:void 0},keyMap:{req:{sequence:"MsgSeq",operator:"Pinner_Account"}}}),this._map.set(ui.UNPIN_GRP_MSG,{head:{...i,servcmd:f.NAME.GRP+"."+ui.UNPIN_GRP_MSG},body:{groupID:void 0,topicID:void 0,sequence:void 0,operator:void 0},keyMap:{req:{sequence:"MsgSeq",operator:"UnPinner_Account"}}}),this._map.set(ui.GET_PINNED_GRP_MSG_LIST,{head:{...i,servcmd:f.NAME.GRP+"."+ui.GET_PINNED_GRP_MSG_LIST},body:{groupID:void 0,topicID:void 0},keyMap:{res:{PinnedMsgList:"pinnedMessageList",Pinner_Account:"userID"}}}),this._map.set(ui.GET_LIVE_HISTORY_MSG,{head:{...i,servcmd:f.NAME.GRP+"."+ui.GET_LIVE_HISTORY_MSG},body:{groupID:"",longPollingKey:void 0,startSeq:void 0},keyMap:{req:{startSeq:"PullPreSeq"},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"}}}),this._map.set(ui.CREATE_TOPIC,{head:{...i,servcmd:f.NAME.GRP_COMMUNITY+"."+ui.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(ui.DEL_TOPIC,{head:{...i,servcmd:f.NAME.GRP_COMMUNITY+"."+ui.DEL_TOPIC},body:{groupID:void 0,topicIDList:void 0},keyMap:{req:{topicIDList:"TopicIdList"},res:{DestroyResultItem:"resultList"}}}),this._map.set(ui.UPDATE_TOPIC_PROFILE,{head:{...i,servcmd:f.NAME.GRP_COMMUNITY+"."+ui.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(ui.GET_TOPIC_LIST,{head:{...i,servcmd:f.NAME.GRP_COMMUNITY+"."+ui.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(ui.GET_GRP_MBR_LIST,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.GET_AV_MBR_LIST,{head:{...i,servcmd:f.NAME.GRP_AV+"."+ui.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(ui.GET_GRP_MBR_PROFILE,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.ADD_GRP_MBR,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.DEL_GRP_MBR,{head:{...i,servcmd:f.NAME.GRP+"."+ui.DEL_GRP_MBR},body:{groupID:void 0,userIDList:void 0,reason:void 0},keyMap:{req:{userIDList:"MemberToDel_Account"}}}),this._map.set(ui.BAN_AV_MBR,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.MODIFY_GRP_MBR_INFO,{head:{...i,servcmd:f.NAME.GRP+"."+ui.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(ui.MARK_AV_MBR_INFO,{head:{...i,servcmd:f.NAME.GRP_AV+"."+ui.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(ui.CS,{head:{...i,servcmd:f.NAME.MSG_SEARCH+"."+ui.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",GroupAddOption:"joinOption",GroupInviteOption:"inviteOption",GroupName:"name",GroupType:"type",GroupMembers:"groupMemberList",GroupMemberUserID:"userID",GroupMemberTinyID:"userTinyID",GroupMemberUserName:"nick",GroupMemberNameCard:"nameCard",GroupMemberAvatar:"memberAvatar"}}}),this._map.set(ui.USER_CS,{head:{...i,servcmd:f.NAME.USER_SEARCH+"."+ui.CS},body:{keywords:void 0,keywordMatchType:0,miniBirthday:void 0,maxBirthday:void 0,gender:void 0,count:20,cursor:void 0}}),this._map.set(ui.GRP_CS,{head:{...i,servcmd:f.NAME.GRP_SEARCH+"."+ui.CS},body:{keywords:void 0,keywordMatchType:0,groupType:void 0,count:20,cursor:void 0}}),this._map.set(ui.MBR_CS,{head:{...i,servcmd:f.NAME.GRP_MEMBER_SEARCH+"."+ui.CS},body:{keywords:void 0,keywordMatchType:0,groupType:void 0,groupIDList:void 0,count:20,cursor:void 0}}),this._map.set(ui.SSO_STAT,{head:{...t,servcmd:f.NAME.IM_OPEN_STAT+"."+ui.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(ui.PING,{head:{...i,servcmd:f.NAME.HEARTBEAT+"."+ui.PING},body:{}}),this._map.set(ui.MSG_PUSH,{head:{...i,servcmd:f.NAME.IM_OPEN_PUSH+"."+ui.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(ui.MULTI_MSG_PUSH,{head:{...i,servcmd:f.NAME.IM_OPEN_PUSH+"."+ui.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(ui.MSG_PUSH_ACK,{head:{...i,servcmd:f.NAME.OPEN_IM+"."+ui.MSG_PUSH_ACK},body:{sessionData:void 0},keyMap:{req:{sessionData:"SessionData"}}}),this._map.set(ui.STATUS_FORCE_OFFLINE,{head:{...i,servcmd:f.NAME.IM_OPEN_STATUS+"."+ui.STATUS_FORCE_OFFLINE},body:{},keyMap:{res:{C2cNotifyMsgArray:"C2CNotifyMessageArray",NoticeSeq:"noticeSequence",KickoutMsgNotify:"kickoutMsgNotify",NewInstInfo:"newInstanceInfo"}}}),this._map.set(ui.DOWNLOAD_MERGER_MSG,{head:{...i,servcmd:f.NAME.IM_LONG_MSG+"."+ui.DOWNLOAD_MERGER_MSG},body:{downloadKey:""},keyMap:{res:{Data:"data",Desc:"description",Ext:"extension",Download_Flag:"downloadFlag",ThumbUUID:"thumbUUID",VideoUUID:"videoUUID"}}}),this._map.set(ui.UPLOAD_MERGER_MSG,{head:{...i,servcmd:f.NAME.IM_LONG_MSG+"."+ui.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:"",fileUrl:"",imageUrl:"URL",remoteFileUrl:"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(ui.FOLLOW,{head:{...i,servcmd:f.NAME.FOLLOW+"."+ui.FOLLOW},body:{fromAccount:"",userIDList:[]},keyMap:{req:{userIDList:"FollowItem"},res:{ResultItem:"resultList",To_Account:"userID"}}}),this._map.set(ui.UNFOLLOW,{head:{...i,servcmd:f.NAME.FOLLOW+"."+ui.UNFOLLOW},body:{fromAccount:"",userIDList:[]},keyMap:{req:{userIDList:"To_Account"},res:{ResultItem:"resultList",To_Account:"userID"}}}),this._map.set(ui.GET_FOLLOW_INFO,{head:{...i,servcmd:f.NAME.FOLLOW+"."+ui.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(ui.GET_FOLLOW,{head:{...i,servcmd:f.NAME.FOLLOW+"."+ui.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(ui.CHECK_FOLLOW_TYPE,{head:{...i,servcmd:f.NAME.FOLLOW+"."+ui.CHECK_FOLLOW_TYPE},body:{fromAccount:"",userIDList:[]},keyMap:{req:{userIDList:"To_Account"},res:{ResultItem:"resultList",To_Account:"userID"}}}),this._map.set(ui.SET_TOKEN,{head:{...i,servcmd:f.NAME.IM_OPEN_STATUS+"."+ui.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(ui.STAT_FOREGROUND,{head:{...i,servcmd:f.NAME.IM_OPEN_STATUS+"."+ui.STAT_FOREGROUND},body:{isWebUniapp:0}}),this._map.set(ui.STAT_BACKGROUND,{head:{...i,servcmd:f.NAME.IM_OPEN_STATUS+"."+ui.STAT_BACKGROUND},body:{C2CUnread:0,GroupUnread:0,isWebUniapp:0},keyMap:{req:{c2cUnreadCount:"C2cUnread",groupUnreadCount:"GrpUnread"}}}),this._map.set(ui.PUSH_REPORT,{head:{...i,servcmd:f.NAME.OFFLINE_PUSH_REPORT+"."+ui.PUSH_REPORT},body:{eventList:[]},keyMap:{req:{eventList:"UinappPushEvents",type:"EventType",time:"EventTime",pushId:"ClickExt"}}}),this._map.set(ui.SET_ALL_RECEIVE_MSG_OPT,{head:{...i,servcmd:f.NAME.IM_MSG_LOGIC+"."+ui.SET_ALL_RECEIVE_MSG_OPT},body:{startTime:0,endTime:0,isRepeated:0,messageRemindType:0},keyMap:{req:{messageRemindType:"Level"}}}),this._map.set(ui.GET_ALL_RECEIVE_MSG_OPT,{head:{...i,servcmd:f.NAME.IM_MSG_LOGIC+"."+ui.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||{}:(Se.w(this._n+".getKeyMap unknown P:"+e),{})}getProtocolData(e){let{P:t,data:o}=e,n=this.get(t),r=null;if(o){let e=this._simpleDeepCopy(n),t=this._updateService(o,e),s=t.body,i=Object.create(null);for(let e in s)if(Object.prototype.hasOwnProperty.call(s,e)){if(i[e]=s[e],void 0===o[e])continue;i[e]=o[e]}t.body=i,r=this._getUplinkData(t)}else r=this._getUplinkData(n);return r}_getUplinkData(e){var e=this._dataCleaner(e),t=Tt(e.head),t=oo(e.body,this._getReqKeyMap(t));return e.body=t,e}_updateService(i,o){var n=Tt(o.head);if(this._isFromGroupRequest(o)){let{type:e,groupID:t,groupIDList:s=[]}=i;Be(t)&&(t=s[0]||""),lt({type:e,groupID:t})&&(o.head.servcmd=f.NAME.GRP_COMMUNITY+"."+n)}return o}_isFromGroupRequest(e){return e.head.servcmd.includes(f.NAME.GRP)||e.head.servcmd.includes(f.NAME.GRP_ATTR)}_getReqKeyMap(e){e=this.getKeyMap(e);return{...so.req,...e.req}}_dataCleaner(e){var t,s=Array.isArray(e)?[]:Object.create(null);for(t in e)Object.prototype.hasOwnProperty.call(e,t)&&je(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(s){var i,o=Object.keys(s),n={};for(let e=0,t=o.length;e<t;e++)i=o[e],Ve(s[i])?n[i]=Array.from(s[i]):qe(s[i])?n[i]=this._simpleDeepCopy(s[i]):n[i]=s[i];return n}}let To=[ui.MSG_PUSH_ACK];class yo{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(Ds);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(bs).syncOnNeed(),t.onNewMessage({dataList:e.dataList,isInstantMessage:!0})}_onC2CMsgModified(e){this._sessionM.get(Ds).onMsgModified(e)}_onGroupMsgArray(e){var t=this._sessionM.get(Rs);t&&t.onNewMessage({event:e.event,dataList:e.dataList,isInstantMessage:!0})}_onGroupMsgModified(e){var t=this._sessionM.get(Rs);t&&t.onMsgModified(e)}_onGroupTips(e){var t=this._sessionM.get(Rs);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(Os).onNewGroupAtTips({dataList:i});break;default:Se.l(this._n+`._onGroupTips unknown event:${s} dataList:`,i)}}}_onC2CNotifyMsgArray(e){let t=e["dataList"];if(Ve(t)){let e=this._sessionM.get(Ds);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(Os).onC2CMsgRemindTypeSynced({dataList:t})})}}_onC2CReadReceiptArray(e){this._sessionM.get(Ds).onReadReceiptList(e)}_onProfileModified(e){this._sessionM.get(Es).onProfileModified({dataList:e.dataList});var t=this._sessionM.get(Ls);t&&t.onFriendProfileModified({dataList:e.dataList})}_onRelationChainModified(e){this._sessionM.get(Es).onRelationChainModified({dataList:e.dataList});var t=this._sessionM.get(Ls);t&&t.onRelationChainModified({dataList:e.dataList})}_onRecentContact(e){e=e.dataList;if(Ve(e)){let n=this._sessionM.get(Os);n&&e.forEach(o=>{let e=o["pushType"];if(1===e){let e=o["recentContactDeleteItem"];n.onConvDeleted(e.recentContactList)}else if(2===e){let e=o["recentContactTopItem"];n.onConvPinnedStatus(e.recentContactList,!0)}else if(3===e){let e=o["recentContactTopItem"];n.onConvPinnedStatus(e.recentContactList,!1)}else if(4===e){let e=o["recentContactMarkContact"];n.onConvMarkUpdated(e.recentContactMarkContactItem)}else if(5===e){let e=o["recentContactCreateContactGroup"];n.onConvGroupCreated(e.msgContactGroupContactItem)}else if(6===e){let e=o["recentContactDelContactGroup"];n.onConvGroupDeleted(e.msgGroupItem)}else if(7===e){let e=o["recentContactUpdateContactGroup"],{updateType:t,msgUpdateGroup:s,msgUpdateContact:i}=e;if(1===t){let e=s["updateGroupType"];1===e?n.onConvGroupNameUpdated(s):2===e&&n.onConvInGroupUpdated(s)}else 2===t&&n.onConvAddedToOrDeletedFromGroup(i)}})}}_onAllMsgRead(e){var e=e["dataList"],t=this._sessionM.get(Os);t&&t.onPushedAllMessageRead(e)}_onUserStatusList(e){this._sessionM.get(Es).onUserStatusUpdated(e)}_onMsgExtNotify(e){this._sessionM.get(Ss).onMsgExtNotify(e)}_onMsgReactionNotifyList(e){this._sessionM.get(Xs).onReactionNotifyList(e)}_onMsgReactionNotify(e){this._sessionM.get(Xs).onReactionNotify(e)}_onFollowNotify(e){this._sessionM.get(Zs).onFollowNotify(e)}_onTopicLatestMsg(e){this._sessionM.get(As).onTopicLatestMsg(e)}onMessage(e){var t=e["body"];if(this._filterMsgFromIMOpenPush(e)){var{eventArray:s,isInstantMessage:i,isSyncingEnded:o,needSync:n}=t;if(Ve(s)){var r,a,l;for(let e=0,t=s.length;e<t;e++)if(100===(l=(r=s[e]).event))this._onRoomCustomData(r.content);else if(24===l)this._onAllRcvMsgOptNotify(r);else if(26===l)this._onTopicLatestMsg(r);else{let e=Object.keys(r).find(e=>-1!==this._keys.indexOf(e));e?(a=14===l?{readAllC2CMessage:r[e],groupMessageReadInfoList:r.groupMessageReadNotice||[]}:16===l?{userID:r.userID,timestamp:r.timestamp,readReceiptList:r[e]}:r[e],this._eventHandlerMap.get(e)({event:l,dataList:a,isInstantMessage:i,isSyncingEnded:o,needSync:n})):Se.l(this._n+".onMessage unknown eventItem:",r)}}}}_onRoomCustomData(e){this._sessionM.get(Ys).onRoomCustomDataReceived(e),Se.l(this._n+"._onRoomCustomData data:"+e)}_onAllRcvMsgOptNotify(e){this._sessionM.get(Os).onAllRcvMsgOptNotify(e)}_filterMsgFromIMOpenPush(e){let{head:t,body:s}=e,i=t["servcmd"],o=!1;if(!(o=Be(i)?o:i.includes(f.NAME.IM_CONFIG_MANAGER)||i.includes(f.NAME.OVERLOAD_PUSH)||i.includes(f.NAME.STAT_SERVICE)))return!0;if(i.includes(ui.PUSHED_CLOUD_CTRL_CONFIG))this._sessionM.get(qs).onPushedConfig(s);else if(i.includes(ui.PUSHED_COMMERCIAL_CONFIG))this._sessionM.get(Ks).onPushedConfig(s);else if(i.includes(ui.OVERLOAD_NOTIFY))this._sessionM.onPushedServerOverload(s);else if(i.includes(ui.KICK_OTHER)){let e=Date.now(),t=(this._sessionM.reLoginOnKickOther(),new Ei("kickOther")),s=this._sessionM.get(ys).getLastWsHelloTs(),i=e-s;t.setMessage(`last wshello time:${s} diff:${i}ms`).end()}return!1}}let vo=[{cmd:ui.GET_GRP_PROFILE,interval:1,count:8},{cmd:ui.UPDATE_GRP_PROFILE,interval:1,count:8},{cmd:ui.GET_GRP_PENDENCY,interval:1,count:15},{cmd:ui.GET_TOPIC_LIST,interval:1,count:10},{cmd:ui.SET_GRP_ATTR,interval:5,count:10},{cmd:ui.MODIFY_GRP_ATTR,interval:5,count:10},{cmd:ui.DEL_GRP_ATTR,interval:5,count:10},{cmd:ui.CLEAR_GRP_ATTR,interval:5,count:10},{cmd:ui.GET_GRP_ATTR,interval:5,count:20},{cmd:ui.UPDATE_GRP_COUNTER,interval:5,count:20},{cmd:ui.GET_GRP_COUNTER,interval:5,count:20},{cmd:ui.SET_ALL_MSG_READ,interval:1,count:1},{cmd:ui.GET_USER_STATUS,interval:5,count:20},{cmd:ui.SUB_USER_STATUS,interval:5,count:20},{cmd:ui.UNSUB_USER_STATUS,interval:5,count:20},{cmd:ui.CS,interval:5,count:20},{cmd:ui.GRP_CS,interval:5,count:20},{cmd:ui.MBR_CS,interval:5,count:20},{cmd:ui.USER_CS,interval:5,count:20},{cmd:ui.CHECK_FOLLOW_TYPE,interval:5,count:20},{cmd:ui.GET_GRP_ROAMING_MSG,interval:1,count:20},{cmd:ui.GET_C2C_ROAMING_MSG,interval:1,count:20}],So=new Map,Eo=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F"];for(let e=0,t=Eo.length;e<t;e++)So.set(e,Eo[e]);function Do(s){let i,o,n=s,r="";for(let e=0,t=(n=s.length%8!=0?"0".repeat(8-s.length%8)+s:n).length;e<t;e+=8)i=parseInt(n.slice(e,e+4),2),o=parseInt(n.slice(e+4,e+8),2),r+=So.get(i)+So.get(o);return r}class Ro extends li{constructor(e){super(e),this._n="SessionModule",this._platform=this.getPlatform(),this._pHandler=new Co(this),this._msgDispatcher=new yo(this),this._cmdFreqLimitMap=new Map,this._cmdReqInfoMap=new Map,this._serverOverloadInfoMap=new Map,this._incrementalPullContactFlag=!0,this._init(),this.getIEmitInst().on(Qi.CLOUD_CONFIG,this._onCloudConfig,this)}_init(){this._updateCmdFreqLimitMap(vo)}_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){Se.d(this._n+".req options:",e);var t=e["P"];if(!this._pHandler.has(t))return Se.w(this._n+".req unknown P:"+t),ci({code:ni.NO_PROTOCOL});var e=this.getProtocolData(e),s=e.head["servcmd"];let i;return this._isFreqOverLimit(s)?(i=ni.OVER_FREQUENCY_LIMIT,ci({code:i,message:this.getErrMsg(i,this._getCmd(s))})):this._isServerOverload(s)?(i=ni.OPEN_SERVICE_OVERLOAD_ERROR,ci({code:i,message:this.getErrMsg(i,this._getCmd(s))})):(s=this.get($s),To.includes(t)?s.simplySend(e):s.send(e))}getKeyMap(e){return this._pHandler.getKeyMap(e)}genCommonHead(){var e=this.get(Ns);return{ver:"v4",platform:this._platform,websdkappid:a,websdkversion:r,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:Do(""),cappid:e.getApplicationID(),cs:0}}genCosSpecifiedHead(){var e=this.get(Ns);return{ver:"v4",platform:this._platform,websdkappid:a,websdkversion:r,sdkappid:e.getSDKAppID(),contenttype:e.getContentType(),reqtime:0,identifier:e.getUserID(),usersig:e.getUserSig(),status_instid:e.getStatusInstanceID(),sdkability:75689843,sdkability_ext:Do(""),cappid:e.getApplicationID(),cs:0}}genSSOReportHead(){var e=this.get(Ns);return{ver:"v4",platform:this._platform,websdkappid:a,websdkversion:r,sdkappid:e.getSDKAppID(),contenttype:"",reqtime:0,identifier:"",usersig:"",status_instid:e.getStatusInstanceID(),sdkability:75689843,sdkability_ext:Do(""),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($s).send(e)}sendComboMessage(e){var{servcmd:e,data:t}=e,e={head:{...this.genCommonHead(),servcmd:e},body:t};return this.get($s).send(e)}onErrorCodeNotZero(s){let e=s["errorCode"];if(e===ni.HELLO_ANSWER_KICKED_OUT){let{kickType:e,newInstanceInfo:t={}}=s;1===e?this.onMultipleAccountKickedOut(t):2===e?this.onMultipleDeviceKickedOut(t):3===e&&this.onRestApiKickedOut(t)}e!==ni.MSG_A2KEY_EXPIRED&&e!==ni.ACCOUNT_A2KEY_EXPIRED||(this._onUserSigExpired(),this.get($s).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(){Se.l(this._n+".reLoginOnKickOther"),this._reLogin()}_reLoginOnReconnected(){Se.l(this._n+"._reLoginOnReconnected"),this._reLogin()}_reLogin(){let a=this._n+"._reLogin";if(this.isLoggedIn()){let e=0;var s=this.get(ys).getPushModule();s&&(e=s.getUniAppPlatform());let r=new Ei("reLogin");this.req({P:ui.LOGIN,data:{isWebUniapp:e,customInfo:this.get(Ns).getCustomLoginInfo()}}).then(e=>{var{instanceID:e,customStatus:s}=e.data,i=this.get(Ns),o=Dn(s),n=(i.setStatusInstanceID(e),this.get($s)),e=`socketID:${n.getSocketID()} instanceID:${e} customStatus:`+o,e=(r.setMessage(e).end(!0),Se.l(a+" ok. "+e),i.getCustomStatus()!==o&&this.get(Es).onUserStatusUpdated({dataList:[{to:this.getMyUserID(),statusType:t.USER_STATUS_ONLINE,customStatus:s}]}),n.diagnose(),this.get(Os).syncConvList(this._incrementalPullContactFlag).then(()=>{Se.l(a+", sync conv list ok."),this.get(Vs).start()}),this.get(Rs)),i=(e&&e.updateLocalMainSequenceOnReconnected(),this.get(As)),o=(i.resetGetTopicTime(),i.getTopicListOnReconnected(),this.get(Ls));o&&o.updateCacheOnReconnected()})}}onMultipleAccountKickedOut(e){this.get(ys).onMultipleAccountKickedOut(e)}onMultipleDeviceKickedOut(e){this.get(ys).onMultipleDeviceKickedOut(e)}_onUserSigExpired(){this.get(ys).onUserSigExpired()}onRestApiKickedOut(e){this.get(ys).onRestApiKickedOut(e)}_sendACK(e){this.req({P:ui.MSG_PUSH_ACK,data:{sessionData:e}})}_isFreqOverLimit(e){e=e.split(".")[1];if(!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?!0:!1;return n}_isServerOverload(e){if(!this._serverOverloadInfoMap.has(e))return!1;var{overloadTime:t,waitingTime:s}=this._serverOverloadInfoMap.get(e);let i=!1;return i=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 ui)if(ui[s]===i){t=s;break}}return t}onPushedServerOverload(e){var{overloadCommand:e,waitingTime:t}=e;this._serverOverloadInfoMap.set(e,{overloadTime:Date.now(),waitingTime:t}),Se.w(this._n+`.onPushedServerOverload waitingTime:${t}s cmd:`+this._getCmd(e))}reset(){Se.l(this._n+".reset"),this._updateCmdFreqLimitMap(vo),this._cmdReqInfoMap.clear(),this._serverOverloadInfoMap.clear(),this._incrementalPullContactFlag=!0}}class Lo 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 o=this._n+".fetchConfig",e=this._canFetch();if(Se.l(o+" canFetch:"+e),e){let i=new Ei("fetchCloudCtrlConfig"),e=this.get(Ns).getSDKAppID();this._isFetching=!0,this.req({P:ui.FETCH_CLOUD_CTRL_CONFIG,data:{SDKAppID:e,version:this._version}}).then(e=>{this._isFetching=!1;var{version:t,cloudControlConfig:s}=e.data;i.setMessage(`version:${this._version} newVersion:${t} config:`+s).end(),Se.l(o+" ok"),this._parse(e.data)}).catch(e=>{this._isFetching=!1,i.setError(e).end(),Se.l(o+" failed. error:",e),this._setExpiredTime(12e4)})}}onPushedConfig(e){Se.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(t){var s=this._n+"._parse",{errorCode:i,errorMessage:o,cloudControlConfig:n,version:r,expiredTime:a}=t;if(0===i){if(this._version!==r){let t=null;try{t=JSON.parse(n)}catch(e){this.isPrivateNetWork()||Se.e(s+" failed. config:",n)}t&&(this._cloudConfig.clear(),Object.keys(t).forEach(e=>{this._cloudConfig.set(e,t[e])}),this._version=r,this.emitIEvt(Qi.CLOUD_CONFIG),this.emitOEvt(e.SERVER_CONFIG_UPDATED,{config:t}))}this._setExpiredTime(1e3*a)}else Be(i)?(Se.l(s+" failed. Invalid message format:",t),this._setExpiredTime(36e5)):(Se.e(s+` errorCode:${i} errorMessage:`+o),this._setExpiredTime(12e4))}_setExpiredTime(e){this._expiredTime=Date.now()+e}reset(){Se.l(this._n+".reset"),this._cloudConfig.clear(),this._expiredTime=0,this._version=0,this._isFetching=!1}}class Ao extends li{constructor(e){super(e),this._n="RecoverMsgModule",this.PULL_LIMIT_COUNT=15}start(){this._recoverGroupChat(),this._recoverC2CChat()}_recoverGroupChat(){let e=this._getLocalConvList().filter(e=>e.type===t.CONV_GROUP&&e.groupProfile.type!==t.GRP_AVCHATROOM),i=this.get(Os),o,n,r,a,l,d=[];e.forEach(e=>{var{conversationID:e,lastMessage:s}=e;n=e.replace(t.CONV_GROUP,""),o=i.getLocalLastMessage(e),s&&0!==s.lastSequence&&o&&(a=s.lastSequence,r=o.sequence,l=a-r,0<r)&&1<=l&&l<300?this._recoverGroupMsg({groupID:n,localLastMessageSequence:r,remoteLastMessageSequence:a}):d.push(n)}),this._getGroupNotice(d)}_recoverC2CChat(){let e=this._getLocalConvList().filter(e=>e.type===t.CONV_C2C),s=this.get(Os),i,o,n,r,a=[Promise.resolve()],l=[];e.forEach(e=>{var{conversationID:e,lastMessage:t}=e;i=s.getLocalLastMessage(e),t&&0!==t.lastTime&&i&&(n=t.lastTime,o=i.time,r=n-o,0<o)&&1<=r&&r<=600&&(a.push(this._recoverC2CMsg({conversationID:e,localLastMessageTime:o,remoteLastMessageTime:n})),l.push(e))}),Promise.all(a).then(()=>{Se.l(this._n+"._recoverC2CChat all done, convIDList:",l),this.get(bs).syncOnReconnected()})}_getLocalConvList(){return this.get(Os).getLocalConvList()}_recoverGroupMsg(e){let l=this._n+"._recoverGroupMsg",{groupID:d,localLastMessageSequence:u,remoteLastMessageSequence:c}=(Se.l(l+" options:",e),e),_=JSON.stringify(e),h=new Ei("_recoverGroupMsg");h.setMessage(_),this._getGroupRoamingMsg({groupID:d,sequence:u}).then(e=>{var{complete:n,messageList:r}=e.data;if(!Be(r)){let e=r[0].sequence,s=r.map(e=>e.sequence),i=_+` complete:${n} sequenceList:`+s;Se.l(l+" "+i),e!==u&&e<c&&2!==n&&this._recoverGroupMsg({groupID:d,localLastMessageSequence:e,remoteLastMessageSequence:c}),h.setMessage(i).end();var a=this.get(Rs);1<r.length&&r.sort((e,t)=>e.sequence-t.sequence);let o=!1;for(let e=0,s=r.length;e<s;e++)if(r[e].from===t.CONV_SYSTEM){o=!0;break}if(o)for(let s=0,e=r.length;s<e;s++){let e=r[s];e.from!==t.CONV_SYSTEM?a.onNewMessage({dataList:[e],isInstantMessage:!1,updateUnreadCount:!1}):a.onNewGroupTips({event:e.event,dataList:[e]})}else a.onNewMessage({dataList:r,isInstantMessage:!1,updateUnreadCount:!1})}}).catch(e=>{h.setError(e).end(),Se.w(l+" failed. error:",e)})}_getGroupNotice(s){var e=s.length;if(Se.l(this._n+"._getGroupNotice length:"+e),0!==e){var i=this.get(Rs);if(e<=10)i.getNotice(s);else{let t=Math.floor(e/10);5<=t&&(t=5);for(let e=0;e<=t;e++)i.getNotice(s.slice(10*e,10*(e+1)))}}}_getGroupRoamingMsg(e){var{groupID:e,sequence:t}=e;return this.req({P:ui.GET_GRP_ROAMING_MSG,data:{groupID:e,count:this.PULL_LIMIT_COUNT,sequence:t+this.PULL_LIMIT_COUNT-1}})}_recoverC2CMsg(e){let o=this._n+"._recoverC2CMsg",{conversationID:n,localLastMessageTime:t,remoteLastMessageTime:r}=(Se.l(o+" options:",e),e),a=JSON.stringify(e),l=new Ei("_recoverC2CMsg");return l.setMessage(a),this._getC2CRoamingMsg({conversationID:n,time:t}).then(e=>{var{complete:t,messageList:s}=e.data;if(!Be(s)){let e=s.length;this.get(Ds).onNewMessage({dataList:s,isInstantMessage:!0});var i=s[e-1].time,s=s.map(e=>e.random),s=a+` complete:${t} randomList:`+s;if(Se.l(o+" "+s),l.setMessage(s).end(),i<r&&1!==t)return this._recoverC2CMsg({conversationID:n,localLastMessageTime:i,remoteLastMessageTime:r})}}).catch(e=>{l.setError(e).end(),Se.w(o+" failed. error:",e)})}_getC2CRoamingMsg(e){var{conversationID:e,time:s}=e;return this.req({P:ui.GET_C2C_ROAMING_MSG,data:{peerAccount:e.replace(t.CONV_C2C,""),count:this.PULL_LIMIT_COUNT+1,lastMessageTime:s,direction:1}})}reset(){Se.l(this._n+".reset")}}class Oo{constructor(){this._n="AvgE2EDelay",this._e2eDelayArray=[]}addMessageDelay(e){e=Ce()-e;0<=e&&this._e2eDelayArray.push(e)}_calcAvg(e,t){if(0===t)return 0;let s=0;return e.forEach(e=>{s+=e}),yt(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=yt(e/t*100,2);return s=100<s?100:s}_checkE2EDelayException(n,t){var r=n.filter(e=>t<e);if(0<r.length){let e=r.length,t=Math.min(...r),s=Math.max(...r),i=this._calcAvg(r,e),o=yt(e/n.length*100,2);50<o&&new Ei("messageE2EDelayException").setMessage(`count:${e} min:${t} max:${s} avg:${i} percent:`+o).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 No{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=yt(e/t*100,2);return s=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),Se.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 Po{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=yt(e.successCount/e.totalCount*100,2);return t=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 s=100<(s=yt(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===fi?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 Uo{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(s){let{key:i,message:e}=s;if(Be(i)||!this._lastMap.has(i)||!this._currentMap.has(i))return!1;var{conversationID:o,sequence:n}=e,o=o.replace(t.CONV_GROUP,"");if(0===this._lastMap.get(i).size)this._addCurrentMap(s);else if(this._lastMap.get(i).has(o)){let e=this._lastMap.get(i).get(o),t=e.length-1;n>e[0]&&n<e[t]?(e.push(n),e.sort(),this._lastMap.get(i).set(o,e)):this._addCurrentMap(s)}else this._addCurrentMap(s);return!0}_addCurrentMap(e){var{key:e,message:s}=e,{conversationID:s,sequence:i}=s,s=s.replace(t.CONV_GROUP,"");this._currentMap.get(e).has(s)||this._currentMap.get(e).set(s,[]),this._currentMap.get(e).get(s).push(i)}_copyData(t){if(!Be(t)){this._lastMap.set(t,new Map);let e=this._lastMap.get(t);for(var[s,i]of this._currentMap.get(t))e.set(s,i);e=null,this._currentMap.set(t,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 i=0,o=0;if(this._lastMap.get(e).forEach((e,t)=>{var e=[...e.values()],s=e.length;i+=e[s-1]-e[0]+1,o+=s}),0===i)return null;let t=yt(o/i*100,2);return 100<t&&(t=100),this._copyData(e),{totalCount:i,successCountOfMessageReceived:o,successRateOfMessageReceived:t}}reset(){this._currentMap.clear(),this._lastMap.clear()}}class Go extends li{constructor(e){super(e),this._n="QualityStatModule",this.TAG="im-ssolog-quality-stat",this.reportIndex=0,this.wholePeriod=!1,this._qualityItems=[di,_i,hi,pi,gi,mi,fi,Mi,Ii,Ci],this._messageSentItems=[hi,pi,gi,mi,fi],this._messageReceivedItems=[Mi,Ii,Ci],this.REPORT_INTERVAL=120,this.REPORT_SDKAPPID_BLACKLIST=[],this.REPORT_TINYID_WHITELIST=[],this._statInfoArr=[],this._avgRTT=new No,this._avgE2EDelay=new Oo,this._rateMessageSent=new Po,this._rateMessageReceived=new Uo;e=this.getIEmitInst();e.on(Qi.A2KEY_AND_TINYID_UPDATED,this._onLoginSuccess,this),e.on(Qi.CLOUD_CONFIG,this._onCloudConfig,this)}_onLoginSuccess(){this._rateMessageSent.initMap(this._messageSentItems),this._rateMessageReceived.initMap(this._messageReceivedItems);var e=this.get(Ps),t=e.getItem(this.TAG,!1);!Ge(t)&&He(t.forEach)&&(Se.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)||Se.w(this._n+".addTotalCount invalid key:",e)}addSuccessCount(e){this._rateMessageSent.addSuccessCount(e)||Se.w(this._n+".addSuccessCount invalid key:",e)}addFailedCountOfUserSide(e){this._rateMessageSent.addFailedCountOfUserSide(e)||Se.w(this._n+".addFailedCountOfUserSide invalid key:",e)}addCost(e,t){this._rateMessageSent.addCost(e,t)||Se.w(this._n+".addCost invalid key or cost:",e,t)}addFileSize(e,t){this._rateMessageSent.addFileSize(e,t)||Se.w(this._n+".addFileSize invalid key or size:",e,t)}addMessageSequence(e){this._rateMessageReceived.addMessageSequence(e)||Se.w(this._n+".addMessageSequence invalid key:",e.key)}_getQualityItem(e){let t={},s=vi[this.get(Gs).getNetworkType()];Be(s)&&(s=8);var i={qualityType:Ti[e],timestamp:Me(),networkType:s,extension:""};switch(e){case di:t=this._avgRTT.getStatResult();break;case _i:t=this._avgE2EDelay.getStatResult();break;case hi:case pi:case gi:case mi:case fi:t=this._rateMessageSent.getStatResult(e);break;case Mi:case Ii:case Ci: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)),Se.d(this._n+"._report",t),0<this._statInfoArr.length&&(t=t.concat(this._statInfoArr),this._statInfoArr=[]);var e=this.get(Ns),i=e.getSDKAppID(),e=e.getTinyID();0<(t=vt(this.REPORT_SDKAPPID_BLACKLIST,i)&&!St(this.REPORT_TINYID_WHITELIST,e)?[]:t).length&&this._doReport(t)}_doReport(t){var e={header:kn(this),quality:t};this.req({P:ui.SSO_STAT,data:{...e}}).then(()=>{this.reportIndex++,this.wholePeriod=!1}).catch(e=>{Se.w(this._n+"._doReport failed. error:",e),this._statInfoArr=this._statInfoArr.concat(t),this._flushAtOnce()})}_flushAtOnce(){var t=this.get(Ps),s=t.getItem(this.TAG,!1),i=this._statInfoArr,o=this._n+"._flushAtOnce";if(Ge(s))Se.l(o+" count:"+i.length),t.setItem(this.TAG,i,!0,!1);else{let e=i.concat(s);10<e.length&&(e=e.slice(0,10)),Se.l(o+" count:"+e.length),t.setItem(this.TAG,e,!0,!1)}this._statInfoArr=[]}reset(){Se.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 ko extends li{constructor(e){super(e),this._n="WorkerTimerModule",this._isWorkerEnabled=!0,this._workerTimer=null,this._timerID=-1,this._init(),this.getIEmitInst().on(Qi.CLOUD_CONFIG,this._onCloudConfig,this)}isWorkerEnabled(){return this._isWorkerEnabled&&ae}startWorkerTimer(){Se.l(this._n+".startWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("start")}stopWorkerTimer(){Se.l(this._n+".stopWorkerTimer"),this._workerTimer&&this._workerTimer.postMessage("stop")}_init(){if(ae){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,Se.l(t._n+"._init seed:"+t._timerID)):t._m.onCheckTimer()}}}_onCloudConfig(){var e=this.getCloudConfig("enable_worker");Se.l(this._n+"._onCloudConfig enableWorker:"+e),Be(e)||"1"===e?!this._isWorkerEnabled&&ae&&(this._isWorkerEnabled=!0,this.startWorkerTimer(),this._m.onWorkerTimerEnabled()):this._isWorkerEnabled&&ae&&(this._isWorkerEnabled=!1,this.stopWorkerTimer(),this._m.onWorkerTimerDisabled())}terminate(){Se.l(this._n+".terminate"),this._workerTimer&&(this._workerTimer.terminate(),this._workerTimer=null,this._timerID=-1)}getTimerID(){return this._timerID}reset(){Se.l(this._n+".reset")}}class wo{constructor(e){this._commercialConfigM=e,this._n="PurchasedFeatureHandler",this._isCSPluginReported=!1,this._featureMap=new Map,this._commercialAbility="0"}isValidPurchaseBits(e){return e&&"string"==typeof e&&1<=e.length&&e.length<=64&&/[01]{1,64}/.test(e)}parsePurchaseBits(s){if(this.isValidPurchaseBits(s)){this._commercialAbility=s,this._featureMap.clear();var o;for(let e=s.length-1,t=0;0<=e;e--,t++)o=(t<32?new i(0,Math.pow(2,t)):new i(Math.pow(2,t-32),0)).toString(),"1"===s[e]?this._featureMap.set(o,!0):this._featureMap.set(o,!1)}else Se.w(this._n+".parsePurchaseBits invalid purchasebits:"+s)}hasPurchasedFeature(e){return!!this._featureMap.get(e)}isFeatureEnabled(e){var s=parseInt(e).toString(2);let o=void 0,n=!0;for(let e=s.length-1,t=0;0<=e;e--,t++)if("1"===s.charAt(e)&&(o=(t<32?new i(0,Math.pow(2,t)):new i(Math.pow(2,t-32),0)).toString(),!this._featureMap.get(o))){n=!1;break}return Se.l(`${this._n}.isFeatureEnabled decimalNumber:${e} key:${o} ret:`+n),ai({enabled:n})}isFeatureEnabledForStat(e){var s=parseInt(e).toString(2);let o=void 0;for(let e=s.length-1,t=0;0<=e;e--,t++)if("1"===s.charAt(e)){if(o=(t<32?new i(0,Math.pow(2,t)):new i(Math.pow(2,t-32),0)).toString(),!this._featureMap.get(o))break;{let t="",s=0;if(o===M.PLUGIN_TRANSLATE?(t="plugin_translate",s=16):o===M.PLUGIN_VOICE_TO_TEXT?(t="plugin_voice_to_text",s=17):o===M.PLUGIN_CS?(t="plugin_cs",s=14):o===M.PLUGIN_PUSH?(t="plugin_push",s=13):o===M.PLUGIN_BOT?(t="plugin_bot",s=15):o===M.MSG_REACTION&&(t="plugin_emoji_reaction",s=18),""!==t){let e=this._commercialConfigM.get(Ns).getUIPlatform();new Ei(t).setCode(s).setUIPlatform(e).end(),Se.l(`${this._n}.isFeatureEnabledForStat ${t} code:${s} uiPlatform:`+e)}}}}isCSPluginEnabled(){var e;this._isCSPluginReported||(e=this._commercialConfigM.get(Ns).getUIPlatform(),new Ei("plugin_search").setCode(6).setUIPlatform(e).end(),this._isCSPluginReported=!0)}queryCommercialAbility(){return this._commercialAbility}clear(){this._featureMap.clear(),this._isCSPluginReported=!1,this._commercialAbility="0"}}class bo{constructor(e){this._m=e,this._n="CommercialConfigModule",this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler=new wo(this)}_canFetch(){return this.get(Ns).isLoggedIn()?!this._isFetching&&Date.now()>=this._expiredTime:(this._expiredTime=Date.now()+2e3,!1)}onCheckTimer(e){this._canFetch()&&this.fetchConfig()}fetchConfig(){let e=this._canFetch(),i=this._n+".fetchConfig";if(Se.l(i+" canFetch:"+e),e){let t=new Ei("fetchCommercialConfig"),e=this.get(Ns).getSDKAppID(),s=this.get(Fs);this._isFetching=!0,s.req({P:ui.FETCH_COMMERCIAL_CONFIG,data:{SDKAppID:e}}).then(e=>{t.setMessage("purchaseBits:"+e.data.purchaseBits).end(),Se.l(i+" ok."),this._parseConfig(e.data),this._isFetching=!1}).catch(e=>{t.setError(e).end(),this._isFetching=!1})}}onPushedConfig(e){var t=this._n+".onPushedConfig data:"+JSON.stringify(e);Se.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)?(Se.l(t+" failed. Invalid message format:",e),this._setExpiredTimeOnResponseError(36e5)):(Se.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()}queryCommercialAbility(){return this._purchasedFeatureHandler.queryCommercialAbility()}get(e){return this._m.get(e)}reset(){Se.l(this._n+".reset"),this._expiredTime=0,this._isFetching=!1,this._purchasedFeatureHandler.clear()}}class Fo 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,u,c,_,h;w?(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:u,oppoAppSecret:c,honorBusinessID:_,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=u,this._androidPushConfig.oppoPushAppSecret=c,this._androidPushConfig.honorPushBussinessId=_,new Ei("registerPlugin").setMessage("tim-offline-push-plugin").setMoreMessage("isExist:"+!Be(this._offlinePushPlugin)).end(!0),Se.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 a=this._n+"._getDeviceToken";if(He(this._offlinePushPlugin.getDeviceToken)){let r=`androidPushConfig:${JSON.stringify(this._androidPushConfig)}, iosBusinessID:`+this._iosBusinessID;Se.l(a+" start. "+r),new Ei("_getDeviceToken").setMessage(r).end(!0),this._offlinePushPlugin.getDeviceToken(this._androidPushConfig,o=>{let n=new Ei("getDeviceTokenRes"),{code:e,msg:t}=o;if(0===e){let{deviceToken:e,deviceBrand:t,deviceType:s,bussinessId:i}=o.data;this._deviceToken=e,this._businessID=i||this._iosBusinessID,r=`deviceToken:${e}, deviceBrand:${t||s}, businessID:`+this._businessID,Se.l(a+" ok. "+r),n.setMessage(r).end(!0),this._setToken()}else n.setMessage(`code:${e}, msg:`+t).end(!0),Se.e(a+" failed. error:",o)})}else Se.e(a+" getDeviceToken is not a function")}canIUseOfflinePush(){return w&&!Be(this._offlinePushPlugin)}_setAppShowListener(){let t=this._n+"._setAppShowListener";Be(this._offlinePushPlugin)?Se.e(t+" offlinePushPlugin is undefined"):He(this._offlinePushPlugin.setAppShowListener)?(new Ei("_setAppShowListener").end(!0),Se.l(t+" start"),this._offlinePushPlugin.setAppShowListener(e=>{e=(e||{}).appShow;new Ei("setAppShowListenerRes").setMessage("appShow:"+e).end(!0),Se.l(t+" ok. appShow:"+e),this._m.isReady()&&(0===e?(this._getConvUnreadCount(),this._onBackground()):1===e&&this._onForeground())})):Se.e(t+" setAppShowListener is not a function")}getDeviceBrand(){var e;if(!Be(this._offlinePushPlugin)&&He(this._offlinePushPlugin.getDeviceType))return e=(this._offlinePushPlugin.getDeviceType()||{})["deviceType"],Se.l(this._n+".getDeviceBrand ok. deviceType:"+e),e}_setToken(){let t=this._n+"._setToken",e=this.get(Ns),s,i=1,n="",r="";Ge(this._deviceToken)&&(i=0);var a=this.getUniAppPlatform(),l=this.getDeviceBrand();a===o.IOS||a===o.IPAD||a===o.MAC?r=this._deviceToken:a===o.ANDROID&&(n=this._deviceToken);let d=new Ei("offlinePushSetToken");return s=`deviceToken:${r||n}, businessID:${this._businessID}, deviceBrand:${l}, isWebUniapp:${this._isWebUniapp}, pushMsg:${i}, platform:`+a,d.setMessage(s),Se.l(t+" "+s),this.req({P:ui.SET_TOKEN,data:{tokenID:n,pushMsg:i,sdkAppID:e.getSDKAppID(),businessID:parseInt(this._businessID),deviceBrand:l,deviceToken:r,isWebUniapp:this._isWebUniapp}}).then(e=>(d.end(),Se.l(t+" ok"),e)).catch(e=>(d.setError(e).end(),Se.e(t+" failed. error:",e),ci(e)))}_getConvUnreadCount(){this._c2cUnreadCount=0,this._groupUnreadCount=0,this.get(Os).getLocalConvList().forEach(e=>{e.type===t.CONV_C2C&&(this._c2cUnreadCount+=e.unreadCount),e.type===t.CONV_GROUP&&(this._groupUnreadCount+=e.unreadCount)})}_onBackground(){let t=this._n+"._onBackground",s=new Ei("_onBackground");this.req({P:ui.STAT_BACKGROUND,data:{c2cUnreadCount:this._c2cUnreadCount,groupUnreadCount:this._groupUnreadCount,isWebUniapp:this._isWebUniapp}}).then(e=>(s.setMessage(`c2cUnreadCount: ${this._c2cUnreadCount}, groupUnreadCount: `+this._groupUnreadCount).end(),Se.l(t+" ok"),e)).catch(e=>{s.setError(e).end(),Se.e(t+" failed. error:",e)})}_onForeground(){let t=this._n+"._onForeground",s=new Ei("_onForeground");this.req({P:ui.STAT_FOREGROUND,data:{isWebUniapp:this._isWebUniapp}}).then(e=>(s.end(),Se.l(t+" ok"),e)).catch(e=>{s.setError(e).end(),Se.e(t+" failed. error:",e)})}getUniAppPlatform(){var e=uni.getSystemInfoSync().platform,t=this.getDeviceBrand();return"ios"===e?o.IOS:"android"===e?o.ANDROID:1002===t?o.IPAD:1001===t?o.MAC:void 0}reset(){this._deviceToken="",this._businessID=0,this._c2cUnreadCount=0,this._groupUnreadCount=0,this._isWebUniapp=0,Se.l(this._n+".reset")}}class $o 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;w?(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),Se.l(t+" ok. pushConfig:"+JSON.stringify(e.pushConfig)),i?(this._setAppShowListener(),this._setPushEventReportListener()):Se.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 n=this._n+"._reportEventCacheList";He(this._pushPlugin.getPushEventCacheList)?(new Ei("_reportEventCacheList").end(!0),this._pushPlugin.getPushEventCacheList(e=>{var{code:t,data:{eventList:s}}=e,i=new Ei("getPushEventCacheListRes");if(i.setCode(t),0!==t)i.setMessage("res:"+JSON.stringify(e)).end(!0),Se.e(n+" failed. error:"+JSON.stringify(e));else{t=s.length<10?"eventList:"+JSON.stringify(s):"eventList.length:"+s.length;Se.l(n+" ok. "+t),i.setMessage(t).end(!0);for(var o={...e.data,eventList:[]};0<s.length;)o.eventList=s.splice(0,40),this._pushReport(o)}})):Se.e(this._pluginName+".getPushEventCacheList is not a function")}_getDeviceToken(){let a=this._n+"._getDeviceToken";if(He(this._pushPlugin.getDeviceToken)){let r=`androidPushConfig:${JSON.stringify(this._androidPushConfig)} iOSBusinessID:`+this._iOSBusinessID;Se.l(a+" start. "+r),new Ei("_getDeviceToken").setMessage(r).end(!0),this._pushPlugin.getDeviceToken(this._androidPushConfig,o=>{let{code:e,msg:t}=o,n=new Ei("getDeviceTokenRes");if(n.setCode(e),0===e){let{deviceToken:e,deviceBrand:t,deviceType:s,bussinessId:i}=o.data;this._deviceToken=e,this._businessID=i||this._iOSBusinessID,r=`deviceToken:${e} deviceBrand:${t||s} businessID:`+this._businessID,Se.l(a+" ok. "+r),n.setMessage(r).end(!0),void this._setToken()}else n.setMessage(t).end(!0),Se.e(a+" failed. error:"+JSON.stringify(o))})}else Se.e(this._pluginName+".getDeviceToken is not a function")}_getDeviceInfo(){var o=this._n+"._getDeviceInfo";if(He(this._pushPlugin.getDeviceInfo)){let e=this._pushPlugin.getDeviceInfo(),{code:t,data:s}=e,i=new Ei("_getDeviceInfo");if(i.setCode(t),0===t){this._deviceInfo={...this._deviceInfo,...s},this._deviceInfo.pushVersion||(this._deviceInfo.pushVersion="1.0.1");let e="deviceInfo:"+JSON.stringify(this._deviceInfo);Se.l(o+" ok. "+e),void i.setMessage(e).end(!0)}else i.setMessage("deviceInfoRes:"+JSON.stringify(e)).end(!0),Se.e(o+" failed. error:"+JSON.stringify(e))}else Se.e(this._pluginName+".getDeviceInfo is not a function")}canIUseTIMPush(){return w&&!Be(this._pushPlugin)}_setAppShowListener(){let t=this._n+"._setAppShowListener";He(this._pushPlugin.setAppShowListener)?(new Ei("_setAppShowListener").end(!0),Se.l(t+" start"),this._pushPlugin.setAppShowListener(e=>{e=(e||{}).appShow;new Ei("setAppShowListenerRes").setMessage("appShow:"+e).end(!0),Se.l(t+" ok. appShow:"+e),this._m.isReady()&&(0===e?(this._getConvUnreadCount(),this._onBackground()):1===e&&this._onForeground())})):Se.e(this._pluginName+".setAppShowListener is not a function")}_setPushEventReportListener(){let n=this._n+"._setPushEventReportListener";He(this._pushPlugin.setPushEventReportListener)?(new Ei("_setPushEventReportListener").end(!0),this._pushPlugin.setPushEventReportListener(e=>{var{code:t,data:s}=e,i=s["eventList"],o=new Ei("setPushEventReportListenerRes");if(o.setCode(t),0===t){let e="eventList:"+JSON.stringify(i);Se.l(n+" ok. "+e),o.setMessage(e).end(!0),void(this._m.isReady()&&Ve(i)&&0<i.length&&this._pushReport(s))}else o.setMessage("res:"+JSON.stringify(e)).end(!0),Se.e(n+" failed. error:"+JSON.stringify(e))})):Se.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"],Se.l(this._n+".getDeviceBrand ok. deviceType:"+e),e}_setToken(){let t=this._n+"._setToken",e=this.get(Ns),s,i=1,n="",r="";Ge(this._deviceToken)&&(i=0);var a=this.getUniAppPlatform(),l=this.getDeviceBrand();a===o.IOS||a===o.IPAD||a===o.MAC?r=this._deviceToken:a===o.ANDROID&&(n=this._deviceToken);let d={tokenID:n,pushMsg:i,sdkAppID:e.getSDKAppID(),businessID:parseInt(this._businessID),deviceBrand:l,deviceToken:r,isWebUniapp:this._isWebUniapp,...this._deviceInfo},u=new Ei("_setToken");s="data:"+JSON.stringify(d),u.setMessage(s),Se.l(t+" "+s),this.req({P:ui.SET_TOKEN,data:d}).then(()=>{u.end(),Se.w(t+" ok")}).catch(e=>{u.setError(e).end(),Se.e(t+" failed. error:",e),ci(e)})}_getConvUnreadCount(){this._c2cUnreadCount=0,this._groupUnreadCount=0,this.get(Os).getLocalConvList().forEach(e=>{e.type===t.CONV_C2C&&(this._c2cUnreadCount+=e.unreadCount),e.type===t.CONV_GROUP&&(this._groupUnreadCount+=e.unreadCount)})}_onBackground(){let t=this._n+"._onBackground",s=new Ei("_onBackground");this.req({P:ui.STAT_BACKGROUND,data:{c2cUnreadCount:this._c2cUnreadCount,groupUnreadCount:this._groupUnreadCount,isWebUniapp:this._isWebUniapp}}).then(()=>{s.setMessage(`c2cUnreadCount:${this._c2cUnreadCount} groupUnreadCount:`+this._groupUnreadCount).end(),Se.l(t+" ok")}).catch(e=>{s.setError(e).end(),Se.e(t+" failed. error:",e)})}_onForeground(){let t=this._n+"._onForeground",s=new Ei("_onForeground");this.req({P:ui.STAT_FOREGROUND,data:{isWebUniapp:this._isWebUniapp}}).then(()=>{s.end(),Se.l(t+" ok")}).catch(e=>{s.setError(e).end(),Se.e(t+" failed. error:",e)})}_pushReport(e){let t=this._n+"._pushReport",s=new Ei("_pushReport");this.req({P:ui.PUSH_REPORT,data:{eventList:e.eventList}}).then(()=>{s.end(),this._notifyReportSuccess(e)}).catch(e=>{s.setError(e).end(),Se.e(t+" failed. error:",e)})}_notifyReportSuccess(e){!Be(this._pushPlugin)&&He(this._pushPlugin.notifyReportSuccess)&&(this._pushPlugin.notifyReportSuccess(e),Se.l(this._n+"._notifyReportSuccess ok"))}getUniAppPlatform(){var e=uni.getSystemInfoSync().platform,t=this.getDeviceBrand();return"ios"===e?o.IOS:"android"===e?o.ANDROID:1002===t?o.IPAD:1001===t?o.MAC:void 0}reset(){this._deviceToken="",this._businessID=0,this._c2cUnreadCount=0,this._groupUnreadCount=0,this._isWebUniapp=0,Se.l(this._n+".reset")}}class qo 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(ws).getPlugin("tim-profanity-filter-plugin");e&&(this._plugin=new e({logger:Se,isArray:Ve,isMap:ke,isDevMode:this.isDevMode()}),this._getLexicon())}onCheckTimer(){this._plugin&&this._canIUseLexicon&&this.isLoggedIn()&&!this._isFetching&&Date.now()>=this._expiredTime&&this._getLexicon()}filterMessage(r,e){let a=!0;if(this._plugin&&this._canIUseLexicon&&(!e||!e.messageControlInfo||!0!==e.messageControlInfo.excludedFromContentModeration)){let{type:s,conversationType:n}=r;if(s===t.MSG_TEXT||s===t.MSG_CUSTOM){let e=this._n+".filterMessage",o;if(Se.l(""+e),s===t.MSG_TEXT){if(n===t.CONV_C2C?o=I:n===t.CONV_GROUP&&(o=T),!this._isConfigOn(o))return a;let{type:e,modifiedText:s}=this._plugin.filter(r.payload.text);1===e?a=!1:2===e&&(r.payload.text=s)}else if(s===t.MSG_CUSTOM){if(n===t.CONV_C2C?o=C:n===t.CONV_GROUP&&(o=y),!this._isConfigOn(o))return a;let e=this._plugin.filter(r.payload.data),s=this._plugin.filter(r.payload.description),i=this._plugin.filter(r.payload.extension);1===e.type||1===s.type||1===i.type?a=!1:(2===e.type&&(r.payload.data=e.modifiedText),2===s.type&&(r.payload.description=s.modifiedText),2===i.type&&(r.payload.extension=i.modifiedText))}Se.l(e+" done. isAllowedToSend:"+a)}}return a}filterText(e,t){var s=this._n+".filterText",i={isAllowedToSend:!0,modifiedText:e};return this._plugin&&this._canIUseLexicon&&this._isConfigOn(t)&&(Se.l(s),{type:t,modifiedText:e}=this._plugin.filter(e),1===t?i.isAllowedToSend=!1:2===t&&(i.modifiedText=e),Se.l(s+" done. ret:",i)),i}_getLexicon(){let u=new Ei("profanityFilter"),c=this._n+"._getLexicon";this._isFetching=!0,this.req({P:ui.GET_PROFANITY_LIST,data:{startIndex:this._startIndex,version:this._version}}).then(e=>{var{errorInfo:e,filterConfig:t,lexicon:s,strToken:i,completeFlag:o,nextStartIndex:n,version:r,expiredTime:a}=e.data,{errorCode:l,errorMessage:d}=e;return 0!==l?(this._isFetching=!1,Se.w(c+" failed. error:",e),void u.setCode(l).setMessage(d).end()):(this._onFilterConfig(t),this._getToken(i),1===o?(Se.l(c+` done. version:${r} expiredTime:`+a),this._version=r,this._canIUseLexicon=!0,this._isFetching=!1,this._expiredTime=Date.now()+1e3*a,void this._plugin.onLexiconCompleted(s)):(this._startIndex=n,this._plugin.onLexiconSliced(s),void this._getLexicon()))}).catch(e=>{u.setError(e).end(),this._isFetching=!1,Se.l(c+" failed. error:",e)})}_onFilterConfig(t){Ge(t)||(this._filterConfigMap.clear(),Object.keys(t).forEach(e=>{this._filterConfigMap.set(e,t[e])}),Se.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(s){if($e(s)){var i=s.length;let t="";if(i%2==0)for(let e=0;e<=i-1;e+=2)t=(t+=s[e+1])+s[e];else{for(let e=0;e<i-1;e+=2)t=(t+=s[e+1])+s[e];t+=s[i-1]}this._plugin.onToken(t)}}reset(){Se.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 xo{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(Qi.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 s;for(let e=0,t=this._TRTCCommandList.length;e<t;e++)s=this._TRTCCommandList[e].split(".")[0],this._TRTCCommandMap.set(s,1)}onRoomCustomDataReceived(t){this._m.getOEmitInst().emit(e.ROOM_CUSTOM_DATA_RECEIVED,t)}sendTRTCCustomData(e){var{serviceCommand:e,data:t}=e;let s=f.NAME.TUIROOM_SVR+".*";return Be(e)||(s=e),this._isValidServiceCommand(s)?this._trans({servcmd:s,data:t}):ci({code:ni.INVALID_TRTC_CMD})}_trans(e){Se.d(this._n+"._trans. options:"+JSON.stringify(e));var{servcmd:e,data:t}=e;return this._m.get(Fs).trans({servcmd:e,data:$e(t)?JSON.parse(t):t})}_isValidServiceCommand(e){return e.endsWith(".*")?this._TRTCCommandList.includes(e):(e=e.split(".")[0],this._TRTCCommandMap.has(e))}isTRTCCommand(e){e=e.split(".")[0];return this._TRTCCommandMap.has(e)}reset(){Se.l(this._n+".reset")}}class Vo{constructor(e){this._m=e,this._n="ErrMsgModule",this.TIM_ERROR_ASSISTANCE="tim_error_assistance",this.STORAGE_EXPIRES_TIME=6048e5,this.CURRENT_DOMAIN=E,this._map=new Map,this._init()}_init(){var t=this._getStorageModule().getItem(this.TIM_ERROR_ASSISTANCE,!1);if(t){let e;try{e=JSON.parse(t)}catch(e){this._getStorageModule().removeItem(this.TIM_ERROR_ASSISTANCE,!1),Se.w(this._n+"._init error:",e)}e&&(this._needToUpdate(e)?this._fetch():this._fillMap(e.message))}else this._fetch()}_needToUpdate(e){var{localSavedTime:e,localSavedVersion:t}=e,e=e&&(new Date).getTime()-e>=this.STORAGE_EXPIRES_TIME,t=!t||"3.6.5"!==t;return Se.l(this._n+`._needToUpdate isTimeout:${e} isDifferentVersion:`+t),e||t}_fetch(){this._m.get(Ns).isPrivateNetWork()||this._fetchWithRetry()}_fetchWithRetry(){this._fetchAdapter().catch(()=>{this.CURRENT_DOMAIN!==R&&(this._generateCurrentDomain(),this._fetchWithRetry())})}_generateCurrentDomain(){this.CURRENT_DOMAIN===E?this.CURRENT_DOMAIN=D:this.CURRENT_DOMAIN===D&&(this.CURRENT_DOMAIN=R)}_fetchAdapter(){let o=`https://${this.CURRENT_DOMAIN}/im/download/error-message/v3/0.0.7/tim-error-message.txt`,n="application/x-www-form-urlencoded;charset=UTF-8",r=this._n+"._fetchAdapter ok in",a=this;return new Promise((s,i)=>{if($)B.request({url:o,method:"GET",timeout:3e3,header:{"content-type":n},dataType:"text",success:e=>{a._fillAndSave(e.data),Se.l(r+" mini program."),s()},fail:e=>{i(e)}});else{let e=new XMLHttpRequest,t=setTimeout(()=>{e.abort()},3e3);e.onreadystatechange=function(){4===e.readyState&&(t&&clearTimeout(t),200===e.status||304===e.status?(Se.l(r+" browser."),a._fillAndSave(e.responseText),s()):i(e.status))},e.onerror=function(e){i(e)},e.open("GET",o,!0),e.setRequestHeader("Content-type",n),e.send()}})}_fillAndSave(e){this._fillMap(e),this._getStorageModule().setItem(this.TIM_ERROR_ASSISTANCE,JSON.stringify({message:e,localSavedTime:(new Date).getTime(),localSavedVersion:"3.6.5"}),!0,!1)}_getStorageModule(){return this._m.get(Ps)}_fillMap(e){this._map.clear();var t,s,i=e.split(";\n"),o=i.length,n=new RegExp(/'/g);for(let e=0;e<o;e++)if(s=i[e].indexOf(":"),t=i[e].slice(0,s),s=i[e].slice(s+1,i[e].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(){Se.l(this._n+".reset")}}var Bo=qn(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)}),Ko=(Bo.assign,Bo.shrinkBuf,Bo.setTyped,Bo.Buf8,Bo.Buf16,Bo.Buf32,function(e,t,s,i){for(var o=65535&e|0,n=e>>>16&65535|0,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|0}),Ho=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}(),Wo=function(e,t,s,i){var o=Ho,n=i+s;e^=-1;for(var r=i;r<n;r++)e=e>>>8^o[255&(e^t[r])];return-1^e},Yo=function(e,t){var s,i,o,n,r,a,l=e.state,d=e.next_in,u=e.input,c=d+(e.avail_in-5),_=e.next_out,h=e.output,p=_-(t-e.avail_out),g=_+(e.avail_out-257),m=l.dmax,f=l.wsize,M=l.whave,I=l.wnext,C=l.window,v=l.hold,S=l.bits,T=l.lencode,y=l.distcode,E=(1<<l.lenbits)-1,D=(1<<l.distbits)-1;e:do{for(S<15&&(v+=u[d++]<<S,S+=8,v+=u[d++]<<S,S+=8),s=T[v&E];;){if(v>>>=i=s>>>24,S-=i,0==(i=s>>>16&255))h[_++]=65535&s;else{if(!(16&i)){if(0==(64&i)){s=T[(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)&&(S<i&&(v+=u[d++]<<S,S+=8),o+=v&(1<<i)-1,v>>>=i,S-=i),S<15&&(v+=u[d++]<<S,S+=8,v+=u[d++]<<S,S+=8),s=y[v&D];;){if(v>>>=i=s>>>24,S-=i,!(16&(i=s>>>16&255))){if(0==(64&i)){s=y[(65535&s)+(v&(1<<i)-1)];continue}e.msg="invalid distance code",l.mode=30;break e}if(n=65535&s,S<(i&=15)&&(v+=u[d++]<<S,(S+=8)<i)&&(v+=u[d++]<<S,S+=8),(n+=v&(1<<i)-1)>m){e.msg="invalid distance too far back",l.mode=30;break e}if(v>>>=i,S-=i,n>(i=_-p)){if((i=n-i)>M&&l.sane){e.msg="invalid distance too far back",l.mode=30;break e}if(a=C,(r=0)===I){if(r+=f-i,i<o){for(o-=i;h[_++]=C[r++],--i;);r=_-n,a=h}}else if(I<i){if(r+=f+I-i,(i-=I)<o){for(o-=i;h[_++]=C[r++],--i;);if(r=0,I<o){for(o-=i=I;h[_++]=C[r++],--i;);r=_-n,a=h}}}else if(r+=I-i,i<o){for(o-=i;h[_++]=C[r++],--i;);r=_-n,a=h}for(;2<o;)h[_++]=a[r++],h[_++]=a[r++],h[_++]=a[r++],o-=3;o&&(h[_++]=a[r++],1<o)&&(h[_++]=a[r++])}else{for(r=_-n;h[_++]=h[r++],h[_++]=h[r++],h[_++]=h[r++],2<(o-=3););o&&(h[_++]=h[r++],1<o)&&(h[_++]=h[r++])}break}}break}}while(d<c&&_<g);d-=o=S>>3,v&=(1<<(S-=o<<3))-1,e.next_in=d,e.next_out=_,e.avail_in=d<c?c-d+5:5-(d-c),e.avail_out=_<g?g-_+257:257-(_-g),l.hold=v,l.bits=S},zo=[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],jo=[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],Jo=[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],Xo=[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],Zo=function(e,t,s,i,o,n,r,a){for(var l,d,u,c,_,h,p,g,m,f=a.bits,M=0,I=0,C=0,v=0,S=0,T=0,y=0,E=0,D=0,R=0,L=null,A=0,O=new Bo.Buf16(16),N=new Bo.Buf16(16),P=null,U=0,M=0;M<=15;M++)O[M]=0;for(I=0;I<i;I++)O[t[s+I]]++;for(S=f,v=15;1<=v&&0===O[v];v--);if(v<S&&(S=v),0===v)o[n++]=20971520,o[n++]=20971520,a.bits=1;else{for(C=1;C<v&&0===O[C];C++);for(S<C&&(S=C),M=E=1;M<=15;M++)if((E=(E<<1)-O[M])<0)return-1;if(0<E&&(0===e||1!==v))return-1;for(N[1]=0,M=1;M<15;M++)N[M+1]=N[M]+O[M];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=zo,A-=257,P=jo,U-=257,256):(L=Jo,P=Xo,-1),M=C,_=n,y=I=R=0,u=-1,c=(D=1<<(T=S))-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=M-y),C=d=1<<T;o[_+(R>>y)+(d-=l)]=p<<24|g<<16|m|0,0!==d;);for(l=1<<M-1;R&l;)l>>=1;if(0!==l?R=(R&l-1)+l:R=0,I++,0==--O[M]){if(M===v)break;M=t[s+r[I]]}if(S<M&&(R&c)!==u){for(_+=C,E=1<<(T=M-(y=0===y?S:y));T+y<v&&!((E-=O[T+y])<=0);)T++,E<<=1;if(D+=1<<T,1===e&&852<D||2===e&&592<D)return 1;o[u=R&c]=S<<24|T<<16|_-n|0}}0!==R&&(o[_+R]=M-y<<24|64<<16|0),a.bits=S}return 0};function Qo(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function er(){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 Bo.Buf16(320),this.work=new Bo.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function tr(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 Bo.Buf32(852),t.distcode=t.distdyn=new Bo.Buf32(592),t.sane=1,t.back=-1,0):-2}function sr(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,tr(e)):-2}function ir(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,sr(e))}function nr(e,t){var s;return e?(s=new er,(e.state=s).window=null,0!==(s=ir(e,t))&&(e.state=null),s):-2}var or,rr,ar=!0;function cr(e){if(ar){var t;for(or=new Bo.Buf32(512),rr=new Bo.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(Zo(1,e.lens,0,288,or,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Zo(2,e.lens,0,32,rr,0,e.work,{bits:5}),ar=!1}e.lencode=or,e.lenbits=9,e.distcode=rr,e.distbits=5}function lr(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 Bo.Buf8(e.wsize)),i>=e.wsize?(Bo.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),Bo.arraySet(e.window,t,s-i,o,e.wnext),(i-=o)?(Bo.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 ur={inflateReset:sr,inflateReset2:ir,inflateResetKeep:tr,inflateInit:function(e){return nr(e,15)},inflateInit2:nr,inflate:function(e,t){var s,i,o,n,r,a,l,d,u,c,_,h,p,g,m,f,M,I,C,v,S,T,y,E,D=0,R=new Bo.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,u=s.bits,c=a,_=l,T=0;e:for(;;)switch(s.mode){case 1:if(0===s.wrap)s.mode=13;else{for(;u<16;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}if(2&s.wrap&&35615===d)R[s.check=0]=255&d,R[1]=d>>>8&255,s.check=Wo(s.check,R,2,0),u=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(u-=4,S=8+(15&(d>>>=4)),0===s.wbits)s.wbits=S;else if(S>s.wbits){e.msg="invalid window size",s.mode=30;break}s.dmax=1<<S,e.adler=s.check=1,s.mode=512&d?10:12,u=d=0}}break;case 2:for(;u<16;){if(0===a)break e;a--,d+=i[n++]<<u,u+=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=Wo(s.check,R,2,0)),u=d=0,s.mode=3;case 3:for(;u<32;){if(0===a)break e;a--,d+=i[n++]<<u,u+=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=Wo(s.check,R,4,0)),u=d=0,s.mode=4;case 4:for(;u<16;){if(0===a)break e;a--,d+=i[n++]<<u,u+=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=Wo(s.check,R,2,0)),u=d=0,s.mode=5;case 5:if(1024&s.flags){for(;u<16;){if(0===a)break e;a--,d+=i[n++]<<u,u+=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=Wo(s.check,R,2,0)),u=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&&(S=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Array(s.head.extra_len)),Bo.arraySet(s.head.extra,i,n,h,S)),512&s.flags&&(s.check=Wo(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;S=i[n+h++],s.head&&S&&s.length<65536&&(s.head.name+=String.fromCharCode(S)),S&&h<a;);if(512&s.flags&&(s.check=Wo(s.check,i,h,n)),a-=h,n+=h,S)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;S=i[n+h++],s.head&&S&&s.length<65536&&(s.head.comment+=String.fromCharCode(S)),S&&h<a;);if(512&s.flags&&(s.check=Wo(s.check,i,h,n)),a-=h,n+=h,S)break e}else s.head&&(s.head.comment=null);s.mode=9;case 9:if(512&s.flags){for(;u<16;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}if(d!==(65535&s.check)){e.msg="header crc mismatch",s.mode=30;break}u=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(;u<32;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}e.adler=s.check=Qo(d),u=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=u,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&u,u-=7&u,s.mode=27;else{for(;u<3;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}switch(s.last=1&d,--u,3&(d>>>=1)){case 0:s.mode=14;break;case 1:if(cr(s),s.mode=20,6!==t)break;d>>>=2,u-=2;break e;case 2:s.mode=17;break;case 3:e.msg="invalid block type",s.mode=30}d>>>=2,u-=2}break;case 14:for(d>>>=7&u,u-=7&u;u<32;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}if((65535&d)!=(d>>>16^65535)){e.msg="invalid stored block lengths",s.mode=30;break}if(s.length=65535&d,u=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;Bo.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(;u<14;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}if(s.nlen=257+(31&d),d>>>=5,u-=5,s.ndist=1+(31&d),d>>>=5,u-=5,s.ncode=4+(15&d),d>>>=4,u-=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(;u<3;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}s.lens[L[s.have++]]=7&d,d>>>=3,u-=3}for(;s.have<19;)s.lens[L[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,y={bits:s.lenbits},T=Zo(0,s.lens,0,19,s.lencode,0,s.work,y),s.lenbits=y.bits,T){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(;f=(D=s.lencode[d&(1<<s.lenbits)-1])>>>16&255,M=65535&D,!((m=D>>>24)<=u);){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}if(M<16)d>>>=m,u-=m,s.lens[s.have++]=M;else{if(16===M){for(E=m+2;u<E;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}if(d>>>=m,u-=m,0===s.have){e.msg="invalid bit length repeat",s.mode=30;break}S=s.lens[s.have-1],h=3+(3&d),d>>>=2,u-=2}else if(17===M){for(E=m+3;u<E;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}S=0,h=3+(7&(d>>>=m)),d>>>=3,u=u-m-3}else{for(E=m+7;u<E;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}S=0,h=11+(127&(d>>>=m)),d>>>=7,u=u-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++]=S}}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,y={bits:s.lenbits},T=Zo(1,s.lens,0,s.nlen,s.lencode,0,s.work,y),s.lenbits=y.bits,T){e.msg="invalid literal/lengths set",s.mode=30;break}if(s.distbits=6,s.distcode=s.distdyn,y={bits:s.distbits},T=Zo(2,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,y),s.distbits=y.bits,T){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=u,Yo(e,_),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,u=s.bits,12===s.mode&&(s.back=-1);break}for(s.back=0;f=(D=s.lencode[d&(1<<s.lenbits)-1])>>>16&255,M=65535&D,!((m=D>>>24)<=u);){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}if(f&&0==(240&f)){for(I=m,C=f,v=M;f=(D=s.lencode[v+((d&(1<<I+C)-1)>>I)])>>>16&255,M=65535&D,!(I+(m=D>>>24)<=u);){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}d>>>=I,u-=I,s.back+=I}if(d>>>=m,u-=m,s.back+=m,s.length=M,0===f){s.mode=26;break}if(32&f){s.back=-1,s.mode=12;break}if(64&f){e.msg="invalid literal/length code",s.mode=30;break}s.extra=15&f,s.mode=22;case 22:if(s.extra){for(E=s.extra;u<E;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}s.length+=d&(1<<s.extra)-1,d>>>=s.extra,u-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=23;case 23:for(;f=(D=s.distcode[d&(1<<s.distbits)-1])>>>16&255,M=65535&D,!((m=D>>>24)<=u);){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}if(0==(240&f)){for(I=m,C=f,v=M;f=(D=s.distcode[v+((d&(1<<I+C)-1)>>I)])>>>16&255,M=65535&D,!(I+(m=D>>>24)<=u);){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}d>>>=I,u-=I,s.back+=I}if(d>>>=m,u-=m,s.back+=m,64&f){e.msg="invalid distance code",s.mode=30;break}s.offset=M,s.extra=15&f,s.mode=24;case 24:if(s.extra){for(E=s.extra;u<E;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}s.offset+=d&(1<<s.extra)-1,d>>>=s.extra,u-=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=_-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(;u<32;){if(0===a)break e;a--,d|=i[n++]<<u,u+=8}if(_-=l,e.total_out+=_,s.total+=_,_&&(e.adler=s.check=(s.flags?Wo:Ko)(s.check,o,_,r-_)),_=l,(s.flags?d:Qo(d))!==s.check){e.msg="incorrect data check",s.mode=30;break}u=d=0}s.mode=28;case 28:if(s.wrap&&s.flags){for(;u<32;){if(0===a)break e;a--,d+=i[n++]<<u,u+=8}if(d!==(4294967295&s.total)){e.msg="incorrect length check",s.mode=30;break}u=d=0}s.mode=29;case 29:T=1;break e;case 30:T=-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=u,(s.wsize||_!==e.avail_out&&s.mode<30&&(s.mode<27||4!==t))&&lr(e,e.output,e.next_out,_-e.avail_out),c-=e.avail_in,_-=e.avail_out,e.total_in+=c,e.total_out+=_,s.total+=_,s.wrap&&_&&(e.adler=s.check=(s.flags?Wo:Ko)(s.check,o,_,e.next_out-_)),e.data_type=s.bits+(s.last?64:0)+(12===s.mode?128:0)+(20===s.mode||15===s.mode?256:0),T=(0==c&&0===_||4===t)&&0===T?-5:T},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)?-2:((e.head=t).done=!1,0)},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&&Ko(1,t,i,0)!==s.check?-3:lr(e,t,i,i)?(s.mode=31,-4):(s.havedict=1,0)},inflateInfo:"pako inflate (from Nodeca project)"},dr=!0,_r=!0;try{String.fromCharCode.apply(null,[0])}catch(e){dr=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){_r=!1}for(var hr=new Bo.Buf8(256),pr=0;pr<256;pr++)hr[pr]=252<=pr?6:248<=pr?5:240<=pr?4:224<=pr?3:192<=pr?2:1;function gr(e,t){if(t<65534&&(e.subarray&&_r||!e.subarray&&dr))return String.fromCharCode.apply(null,Bo.shrinkBuf(e,t));for(var s="",i=0;i<t;i++)s+=String.fromCharCode(e[i]);return s}hr[254]=hr[254]=1;var mr=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 Bo.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},fr=function(e){for(var t=new Bo.Buf8(e.length),s=0,i=t.length;s<i;s++)t[s]=e.charCodeAt(s);return t},Mr=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=hr[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 gr(n,r)},Ir=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+hr[e[s]]>t?s:t},Cr={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},Tr={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"},yr=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},vr=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},Sr=Object.prototype.toString;function Er(e){if(!(this instanceof Er))return new Er(e);this.options=Bo.assign({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options,e=(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 yr,this.strm.avail_out=0,ur.inflateInit2(this.strm,t.windowBits));if(e!==Cr.Z_OK)throw new Error(Tr[e]);if(this.header=new vr,ur.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=mr(t.dictionary):"[object ArrayBuffer]"===Sr.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw)&&(e=ur.inflateSetDictionary(this.strm,t.dictionary))!==Cr.Z_OK)throw new Error(Tr[e])}function Dr(e,t){t=new Er(t);if(t.push(e,!0),t.err)throw t.msg||Tr[t.err];return t.result}Er.prototype.push=function(e,t){var s,i,o,n,r,a=this.strm,l=this.options.chunkSize,d=this.options.dictionary,u=!1;if(this.ended)return!1;i=t===~~t?t:!0===t?Cr.Z_FINISH:Cr.Z_NO_FLUSH,"string"==typeof e?a.input=fr(e):"[object ArrayBuffer]"===Sr.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 Bo.Buf8(l),a.next_out=0,a.avail_out=l),(s=(s=ur.inflate(a,Cr.Z_NO_FLUSH))===Cr.Z_NEED_DICT&&d?ur.inflateSetDictionary(this.strm,d):s)===Cr.Z_BUF_ERROR&&!0===u&&(s=Cr.Z_OK,u=!1),s!==Cr.Z_STREAM_END&&s!==Cr.Z_OK)return this.onEnd(s),!(this.ended=!0)}while(!a.next_out||0!==a.avail_out&&s!==Cr.Z_STREAM_END&&(0!==a.avail_in||i!==Cr.Z_FINISH&&i!==Cr.Z_SYNC_FLUSH)||("string"===this.options.to?(o=Ir(a.output,a.next_out),n=a.next_out-o,r=Mr(a.output,o),a.next_out=n,a.avail_out=l-n,n&&Bo.arraySet(a.output,a.output,o,n,0),this.onData(r)):this.onData(Bo.shrinkBuf(a.output,a.next_out))),0===a.avail_in&&0===a.avail_out&&(u=!0),(0<a.avail_in||0===a.avail_out)&&s!==Cr.Z_STREAM_END);return(i=s===Cr.Z_STREAM_END?Cr.Z_FINISH:i)===Cr.Z_FINISH?(s=ur.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===Cr.Z_OK):i!==Cr.Z_SYNC_FLUSH||(this.onEnd(Cr.Z_OK),!(a.avail_out=0))},Er.prototype.onData=function(e){this.chunks.push(e)},Er.prototype.onEnd=function(e){e===Cr.Z_OK&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Bo.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Rr={Inflate:Er,inflate:Dr,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Dr(e,t)},ungzip:Dr},Lr={},Ar=((0,Bo.assign)(Lr,Rr,Cr),Lr);class Or{constructor(e){this._m=e,this._n="InflateModule",this._bLogForInflateOK=!1,this._bLogForInflateError=!1}inflate(e){var e=new Uint8Array(e).slice(4),t=Date.now();let s;try{s=Ar.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())}var e=e.length+4,i=s.length;return Se.d(`inflate ok. zipped:${e} unzipped:${i} compression ratio:${Math.round(100*(i-e)/i)}% cost:`+(Date.now()-t)),s}reset(){Se.l(this._n+".reset"),this._bLogForInflateOK=!1,this._bLogForInflateError=!1}}class Nr{constructor(s){var e=new Ei("sdkConstruct");if(this._n="ModuleManager",this._isReady=!1,this._reason=ni.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(Ns,new An(this,s)),this._map.set(ei,new Or(this)),this._map.set(Gs,new $n(this)),this._map.set(Ks,new bo(this)),this._map.set(qs,new Lo(this)),this._map.set(xs,new ko(this)),this._map.set(Bs,new Go(this)),this._map.set($s,new Io(this)),this._map.set(Fs,new Ro(this)),this._map.set(ys,new Nn(this)),this._map.set(vs,new Jn(this)),this._map.set(Ss,new Xn(this)),this._map.set(Xs,new Zn(this)),this._map.set(zs,new Qn(this)),this._map.set(Es,new Ln(this)),this._map.set(Ds,new Zi(this)),this._map.set(Os,new Mn(this)),this._map.set(As,new yn(this)),this._map.set(Ps,new Un(this)),this._map.set(js,new Vo(this)),this._map.set(Us,new wn(this)),this._map.set(ks,new Hn(this)),this._map.set(ws,new eo(this)),this._map.set(bs,new to(this)),this._map.set(Vs,new Ao(this)),this._map.set(Hs,new Fo(this)),this._map.set(Qs,new $o(this)),this._map.set(Ws,new qo(this)),this._map.set(Ys,new xo(this)),this._eventThrottleMap=new Map,this._eventThrottling=s.eventThrottling,this._map.get(Ns).isPartialUpdatedConvs()&&(this._eventThrottling=!1),xe(s.modules)){let t;Object.keys(s.modules).forEach(e=>{t=s.modules[e],"group-module"===e?this._map.set(Rs,new t(this)):"relationship-module"===e?this._map.set(Ls,new t(this)):"signaling-module"===e?this._map.set(Js,new t(this)):"follow-module"===e?this._map.set(Zs,new t(this)):"cloud-search-module"===e&&this._map.set(ti,new t(this)),this._optionalModuleMap.set(e,1)}),this._map.get(Ns).setUsingChatCore(!0)}else this._map.has(Rs)||this._map.get(Ns).setUsingChatCore(!0);var{instanceID:t,SDKAppID:i}=s,t=`instanceID:${t} SDKAppID:${i} isIntl:${this._map.get(Ns).isIntl()} isUsingChatCore:${this._map.get(Ns).isUsingChatCore()} host:${ft()} isIOSWebView:${ue} platform:${W} canIUseInflate:${this.canIUseInflate()} workerAvailable:${ae} eventThrottling:${this._eventThrottling} UserAgent:`+K;Ei.bindEventStatModule(this._map.get(Us)),Ei.bindNetMonitorModule(this._map.get(Gs)),e.setMessage(t+" "+function(){let t="";if($)try{var{model:e,version:s,system:i,platform:o,SDKVersion:n}=B.getSystemInfoSync();t=`model:${e} version:${s} system:${i} platform:${o} SDKVersion:`+n}catch(e){t=""}return t}()).end(),Se.i("SDK "+t),ii.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();Se.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)),Se.l(this._n+"._startMainThreadTimer seed:"+this._checkTimer)}stopTimer(){var e=this._map.get(xs),t=e.isWorkerEnabled();Se.l(this._n+`.stopTimer isWorkerEnabled:${t} seed:`+this._checkTimer),t?e.stopWorkerTimer():this._stopMainThreadTimer()}_stopMainThreadTimer(){Se.l(this._n+"._stopMainThreadTimer"),0<this._checkTimer&&(clearInterval(this._checkTimer),this._checkTimer=-1,this._checkCount=0)}_stopMainThreadSocket(){Se.l(this._n+"._stopMainThreadSocket");var e=this._map.get($s);e.setIsWorkerEnabled(!0),e.reConnect()}_startMainThreadSocket(){Se.l(this._n+"._startMainThreadSocket");var e=this._map.get($s);e.setIsWorkerEnabled(!1),e.reConnect()}onWorkerTimerEnabled(){Se.l(this._n+".onWorkerTimerEnabled, disable main thread timer and socket"),this._stopMainThreadTimer(),this._stopMainThreadSocket()}onWorkerTimerDisabled(){Se.l(this._n+".onWorkerTimerDisabled, enable main thread timer and socket"),this._startMainThreadTimer(),this._startMainThreadSocket()}onCheckTimer(){this._checkCount+=1;for(var[,e]of this._map)e.onCheckTimer&&e.onCheckTimer(this._checkCount)}_initReadyList(){this._readyList=[this._map.get(ys)],this._readyList.forEach(e=>{e.ready(()=>this._onModuleReady())})}_onModuleReady(){let t=!0;if(this._readyList.forEach(e=>{e.isReady()||(t=!1)}),t&&!this._isReady){this._isReady=!0,this._oEmitter.emit(e.SDK_READY);let t=Date.now()-this._startLoginTs;Se.w(`SDK is ready. cost ${t} ms`),this._startLoginTs=Date.now();var s=this._ssoLogForReady.getStartTs()+fe;this._ssoLogForReady.setMessage(t).start(s).end()}}login(){0===this._startLoginTs&&(Ie(),this._startLoginTs=Date.now(),this._startTimer(),this._map.get(Gs).start(),this._ssoLogForReady=new Ei("sdkReady"),this._reason=ni.LOGGING_IN)}onLoginFailed(){this._startLoginTs=0}getOEmitInst(){return null===this._oEmitter&&(this._oEmitter=new xn,ri(this._oEmitter),this._oEmitter._emit=this._oEmitter.emit,this._oEmitter.emit=function(s,t){if(this._canIUseSignaling()&&(s===e.MESSAGE_RECEIVED&&this.get(Js).onNewMessageList(t),s===e.MESSAGE_MODIFIED)&&this.get(Js).onMessageModified(t),s===e.CONVERSATION_LIST_UPDATED||s===e.FRIEND_LIST_UPDATED||s===e.GROUP_LIST_UPDATED||s===e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED)if(!1!==this._eventThrottling)if(this._eventThrottleMap.has(s)){let e=Date.now(),t=this._eventThrottleMap.get(s);e-t.last<=1e3?(-1<t.timeoutID&&clearTimeout(t.timeoutID),t.timeoutID=setTimeout(()=>{t.last=Date.now(),this._oEmitter._emit.apply(this._oEmitter,[s,{name:s,...this._getEventData(s)}])},1e3)):(t.last=e,this._oEmitter._emit.apply(this._oEmitter,[s,{name:s,...this._getEventData(s)}]))}else this._eventThrottleMap.set(s,{last:Date.now(),timeoutID:-1}),this._oEmitter._emit.apply(this._oEmitter,[s,{name:s,...this._getEventData(s)}]);else this._oEmitter._emit.apply(this._oEmitter,[s,{name:s,...this._getEventData(s)}]);else this._oEmitter._emit.apply(this._oEmitter,[s,{name:s,data:t}])}.bind(this)),this._oEmitter}_canIUseSignaling(){var e=this.get(Js);return!!e&&e.canIUseSignaling()}_getEventData(t){if(t!==e.CONVERSATION_LIST_UPDATED)return t===e.FRIEND_LIST_UPDATED?{data:this._map.get(Ls).getLocalFriendList(!1)}:t===e.GROUP_LIST_UPDATED?{data:this._map.get(Rs).getLocalGroupList()}:t===e.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED?{data:this._map.get(Os).getTotalUnreadCount()}:t===e.CONVERSATION_ID_LIST_UPDATED?{data:this._map.get(Os).getUpdatedConvIDList()}:void 0;{let e=this._map.get(Os),t={isSyncCompleted:e.isSyncCompleted()};return this._map.get(Ns).isPartialUpdatedConvs()?t.data=e.getPartialUpdatedConvs():t.data=e.getLocalConvList(),t}}getIEmitInst(){return null===this._iEmitter&&(this._iEmitter=new xn,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(Ns).isUsingChatCore()||this._optionalModuleMap.has(e)}canIUseInflate(){return!!this._map.get(ei)}isReady(){return this._isReady}isIntl(){return this.get(Ns).isIntl()}getNotReadyReason(){return this._reason}setNotReadyReason(e){this._reason=e}getErrMsg(e,t,s){return this._map.get(js).get({key:e,replacement1:t,replacement2:s,isIntl:this.isIntl()})}warn(e,t,s){e=this.getErrMsg(e,t,s);e&&Se.w(e)}onError(t){var s=`code:${t.code} message:`+t.message;Se.w("Oops! "+s),new Ei("error").setMessage(s).setLevel("error").end(),this.getOEmitInst().emit(e.ERROR,t)}restartTimer(){Se.l(this._n+".restartTimer"),this.stopTimer(),this._startTimer();var e=this.get(Rs);e&&e.restartPolling()}getTimerID(){var e=this._map.get(xs);return e.isWorkerEnabled()?e.getTimerID():this._checkTimer}getPollingTimerID(e){return this._map.get(Rs).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(Ns).getUIPlatform(),new Ei("tui_key_features").setCode(e).setMessage(t).setUIPlatform(s).end())}reset(){Se.l(this._n+".reset"),Ie();for(let[,e]of this._map)e.reset&&e.reset();this._startLoginTs=0,this._initReadyList(),this._isReady=!1,this.stopTimer(),this._oEmitter.emit(e.SDK_NOT_READY);for(let[,e]of this._eventThrottleMap)-1<e.timeoutID&&clearTimeout(e.timeoutID);this._eventThrottleMap.clear(),this._codeMsgForTUIMap.clear()}}class Pr{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(t,s,i){let n=this;return function(){try{s.apply(i,Array.from(arguments))}catch(s){let i=Object.values(e).indexOf(t),o="CallbackError";if(-1!==i){let t=Object.keys(e)[i];n._m.warn(o,t,s)}n._reportCount<5&&(new Ei(o).setMessage("eventName:"+t).setMoreMessage(s.message).end(),n._reportCount+=1)}}}destroy(){this._funcMap.clear()}reset(){Se.l(this._n+".reset"),this._reportCount=0}}class Ur{constructor(e){e={SDKAppID:e.SDKAppID,unlimitedAVChatRoom:e.unlimitedAVChatRoom||!1,scene:e.scene||"",oversea:e.oversea||!1,instanceID:mt(),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 Nr(e),this._safetyCallbackFactory=new Pr(this._m)}onError(e){this._m.onError(e)}login(e){return this._m.login(),this._get(ys).login(e)}logout(){return this._get(ys).logout().then(e=>(this._safetyCallbackFactory.reset(),this._m.reset(),e))}getLoginUser(){return this._get(ys).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 t=this._get(Ns),s=t.getSDKAppID();return Se.w(`destroy ${s} `+t.getInstanceID()),this.logout().finally(()=>{this._safetyCallbackFactory.destroy(),this._m.stopTimer(),this._get(xs).terminate(),this._get($s).dealloc(),this._m.getOEmitInst().emit(e.SDK_DESTROY,{SDKAppID:s})})}on(e,t,s){Se.d("on","eventName:"+e),this._m.getOEmitInst().on(e,this._safetyCallbackFactory.defense(e,t,s),s)}once(e,t,s){Se.d("once","eventName:"+e),this._m.getOEmitInst().once(e,this._safetyCallbackFactory.defenseOnce(e,t,s),s||this)}off(e,t,s,i){Se.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(ws):this._get(Hs):this._get(Qs)).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 ->";Lt()?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=(t&&console.log(t),this.getErrMsg("IOS_WEBVIEW_WARNING"));ue&&t&&console.warn(t)}Se.setLevel(e)}createTextMessage(e){return this._get(vs).createTextMessage(e)}createTextAtMessage(e){return this._get(vs).createTextMessage(e)}createImageMessage(e){return this._get(vs).createImageMessage(e)}createAudioMessage(e){return this._get(vs).createAudioMessage(e)}createVideoMessage(e){return this._get(vs).createVideoMessage(e)}createCustomMessage(e){return this._get(vs).createCustomMessage(e)}createFaceMessage(e){return this._get(vs).createFaceMessage(e)}createFileMessage(e){return this._get(vs).createFileMessage(e)}createLocationMessage(e){return this._get(vs).createLocationMessage(e)}createMergerMessage(e){return this._get(vs).createMergerMessage(e)}downloadMergerMessage(e){return e.type!==t.MSG_MERGER?ci({code:ni.MSG_MERGER_TYPE_INVALID}):Ge(e.payload.downloadKey)?ci({code:ni.MSG_MERGER_KEY_INVALID}):this._get(vs).downloadMergerMessage(e).catch(e=>ci({code:ni.MSG_MERGER_DOWNLOAD_FAIL}))}createForwardMessage(e){return this._get(vs).createForwardMessage(e)}sendMessage(e,t){return e instanceof Ki?this._get(vs).sendMessageInstance(e,t):ci({code:ni.MSG_INSTANCE_REQUIRED})}callExperimentalAPI(e,t){return"sendComboMessage"===e?this._get(zs).sendMessage(t):"handleGroupInvitation"===e?this._get(Rs).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(Ys).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(Rs).startMessageLongPolling(t):"stopMessageLongPolling"===e?this._get(Rs).stopMessageLongPolling(t):"disableMessagePullOnInvite"===e?this._get(Os).disableMsgPullOnInvite(t):"clearLocalMessage"===e?this._get(Os).clearMemMsg(t,!1):"setCustomLoginInfo"===e?this._get(Ns).setCustomLoginInfo(t):"statTUIKeyFeatures"===e?this._m.statTUIKeyFeatures(t):"getGroupReceiptsByUsers"===e?this._get(Rs).getGroupReceiptsByUsers(t):"queryCommercialAbility"===e?this._get(Ks).queryCommercialAbility():ci({code:ni.INVALID_OPERATION}):(this._get(Ns).setApplicationID(t),void this._get(Fs).updateProtocolConfig())}revokeMessage(e){return this._get(vs).revokeMessage(e)}resendMessage(e,t){return e instanceof Ki?this._get(vs).resendMessage(e,t):ci({code:ni.MSG_INSTANCE_REQUIRED})}deleteMessage(e){return this._get(vs).deleteMessage(e)}translateText(e){return this._get(vs).translateText(e)}convertVoiceToText(e){return this._get(vs).convertVoiceToText(e)}setMessageExtensions(e,t){return this._get(Ss).setMessageExtensions(e,t)}getMessageExtensions(e){return this._get(Ss).getMessageExtensions(e)}deleteMessageExtensions(e,t){return this._get(Ss).deleteMessageExtensions(e,t)}addMessageReaction(e,t){return this._get(Xs).addMessageReaction(e,t)}removeMessageReaction(e,t){return this._get(Xs).removeMessageReaction(e,t)}getMessageReactions(e){return this._get(Xs).getMessageReactions(e)}getAllUserListOfMessageReaction(e){return this._get(Xs).getAllUserListOfMessageReaction(e)}modifyMessage(e){return this._get(vs).modifyRemoteMessage(e)}getMessageList(e){return this._get(Os).getMessageList(e)}getMessageListHopping(e){return this._get(Os).getMessageListHopping(e)}sendMessageReadReceipt(e){return this._get(Os).sendReadReceipt(e)}getMessageReadReceiptList(e){return this._get(Os).getReadReceiptList(e)}getGroupMessageReadMemberList(e){var t=this._get(Rs);return t?t.getReadReceiptDetail(e):ci({code:ni.NO_MODULE})}findMessage(e){return this._get(Os).findMessage(e)}setMessageRead(e){return this._get(Os).setMessageRead(e)}getConversationList(e){return this._get(Os).getConvList(e)}getConversationProfile(e){return this._get(Os).getConversationProfile(e)}deleteConversation(e){return this._get(Os).deleteConversation(e)}setConversationDraft(e){return this._get(Os).setConvDraft(e)}clearHistoryMessage(e){return this._get(Os).clearHistoryMessage(e)}pinConversation(e){return this._get(Os).pinConversation(e)}setAllMessageRead(e){return this._get(Os).setAllMessageRead(e)}setMessageRemindType(e){return this._get(Os).setMessageRemindType(e)}setAllReceiveMessageOpt(e){return this._get(Os).setAllRcvMsgOpt(e)}getAllReceiveMessageOpt(){return this._get(Os).getAllRcvMsgOpt()}getTotalUnreadMessageCount(){return this._get(Os).getTotalUnreadCount()}setConversationCustomData(e){return this._get(Os).setConvCustomData(e)}markConversation(e){return this._get(Os).markConv(e)}getConversationGroupList(){return this._get(Os).getConvGroupList()}createConversationGroup(e){return this._get(Os).createConvGroup(e)}deleteConversationGroup(e){return this._get(Os).deleteConvGroup(e)}renameConversationGroup(e){return this._get(Os).renameConvGroup(e)}addConversationsToGroup(e){return this._get(Os).addConvsToGroup(e)}deleteConversationsFromGroup(e){return this._get(Os).deleteConvsFromGroup(e)}searchCloudMessages(e){var t=this._get(ti);return t?t.searchCloudMessages(e):ci({code:ni.NO_MODULE})}searchCloudUsers(e){var t=this._get(ti);return t?t.searchCloudUsers(e):ci({code:ni.NO_MODULE})}searchCloudGroups(e){var t=this._get(ti);return t?t.searchCloudGroups(e):ci({code:ni.NO_MODULE})}searchCloudGroupMembers(e){var t=this._get(ti);return t?t.searchCloudGroupMembers(e):ci({code:ni.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(Ls);return e?e.getLocalFriendList():ci({code:ni.NO_MODULE})}addFriend(e){var t=this._get(Ls);return t?t.addFriend(e):ci({code:ni.NO_MODULE})}deleteFriend(e){var t=this._get(Ls);return t?t.deleteFriend(e):ci({code:ni.NO_MODULE})}checkFriend(e){var t=this._get(Ls);return t?t.checkFriend(e):ci({code:ni.NO_MODULE})}getFriendProfile(e){var t=this._get(Ls);return t?t.getFriendProfile(e):ci({code:ni.NO_MODULE})}updateFriend(e){var t=this._get(Ls);return t?t.updateFriend(e):ci({code:ni.NO_MODULE})}getFriendApplicationList(){var e=this._get(Ls);return e?e.getLocalFriendApplicationList():ci({code:ni.NO_MODULE})}acceptFriendApplication(e){var t=this._get(Ls);return t?t.acceptFriendApplication(e):ci({code:ni.NO_MODULE})}refuseFriendApplication(e){var t=this._get(Ls);return t?t.refuseFriendApplication(e):ci({code:ni.NO_MODULE})}deleteFriendApplication(e){var t=this._get(Ls);return t?t.deleteFriendApplication(e):ci({code:ni.NO_MODULE})}setFriendApplicationRead(){var e=this._get(Ls);return e?e.setFriendApplicationRead():ci({code:ni.NO_MODULE})}getFriendGroupList(){var e=this._get(Ls);return e?e.getLocalFriendGroupList():ci({code:ni.NO_MODULE})}createFriendGroup(e){var t=this._get(Ls);return t?t.createFriendGroup(e):ci({code:ni.NO_MODULE})}deleteFriendGroup(e){var t=this._get(Ls);return t?t.deleteFriendGroup(e):ci({code:ni.NO_MODULE})}addToFriendGroup(e){var t=this._get(Ls);return t?t.addToFriendGroup(e):ci({code:ni.NO_MODULE})}removeFromFriendGroup(e){var t=this._get(Ls);return t?t.removeFromFriendGroup(e):ci({code:ni.NO_MODULE})}renameFriendGroup(e){var t=this._get(Ls);return t?t.renameFriendGroup(e):ci({code:ni.NO_MODULE})}followUser(e){var t=this._get(Zs);return t?t.followUser(e):ci({code:ni.NO_MODULE})}unfollowUser(e){var t=this._get(Zs);return t?t.unfollowUser(e):ci({code:ni.NO_MODULE})}getMyFollowersList(e){var t=this._get(Zs);return t?t.getMyFollowersList(e):ci({code:ni.NO_MODULE})}getMyFollowingList(e){var t=this._get(Zs);return t?t.getMyFollowingList(e):ci({code:ni.NO_MODULE})}getMutualFollowersList(e){var t=this._get(Zs);return t?t.getMutualFollowersList(e):ci({code:ni.NO_MODULE})}getUserFollowInfo(e){var t=this._get(Zs);return t?t.getUserFollowInfo(e):ci({code:ni.NO_MODULE})}checkFollowType(e){var t=this._get(Zs);return t?t.checkFollowType(e):ci({code:ni.NO_MODULE})}getGroupList(){var e=this._get(Rs);return e?e.getGroupList():ci({code:ni.NO_MODULE})}getGroupProfile(e){var t=this._get(Rs);return t?t.getGroupProfile(e):ci({code:ni.NO_MODULE})}createGroup(e){var t=this._get(Rs);return t?t.createGroup(e):ci({code:ni.NO_MODULE})}dismissGroup(e){var t=this._get(Rs);return t?t.dismissGroup(e):ci({code:ni.NO_MODULE})}updateGroupProfile(e){var t=this._get(Rs);return t?t.updateGroupProfile(e):ci({code:ni.NO_MODULE})}joinGroup(e){var t=this._get(Rs);return t?t.joinGroup(e):ci({code:ni.NO_MODULE})}quitGroup(e){var t=this._get(Rs);return t?t.quitGroup(e):ci({code:ni.NO_MODULE})}pinGroupMessage(e){var t=this._get(Rs);return t?t.pinGroupMessage(e):ci({code:ni.NO_MODULE})}getPinnedGroupMessageList(e){var t=this._get(Rs);return t?t.getPinnedGroupMessageList(e):ci({code:ni.NO_MODULE})}searchGroupByID(e){var t=this._get(Rs);return t?t.searchGroupByID(e):ci({code:ni.NO_MODULE})}getGroupOnlineMemberCount(e){var t=this._get(Rs);return t?t.getGroupOnlineMemberCount(e):ci({code:ni.NO_MODULE})}changeGroupOwner(e){var t=this._get(Rs);return t?t.changeGroupOwner(e):ci({code:ni.NO_MODULE})}getGroupApplicationList(){var e=this._get(Rs);return e?e.getGroupApplicationList():ci({code:ni.NO_MODULE})}handleGroupApplication(e){var t=this._get(Rs);return t?t.handleGroupApplication(e):ci({code:ni.NO_MODULE})}initGroupAttributes(e){var t=this._get(Rs);return t?t.initGroupAttributes(e):ci({code:ni.NO_MODULE})}setGroupAttributes(e){var t=this._get(Rs);return t?t.setGroupAttributes(e):ci({code:ni.NO_MODULE})}deleteGroupAttributes(e){var t=this._get(Rs);return t?t.deleteGroupAttributes(e):ci({code:ni.NO_MODULE})}getGroupAttributes(e){var t=this._get(Rs);return t?t.getGroupAttributes(e):ci({code:ni.NO_MODULE})}setGroupCounters(e){var t=this._get(Rs);return t?t.setGroupCounters(e):ci({code:ni.NO_MODULE})}increaseGroupCounter(e){var t=this._get(Rs);return t?t.increaseGroupCounter(e):ci({code:ni.NO_MODULE})}decreaseGroupCounter(e){var t=this._get(Rs);return t?t.decreaseGroupCounter(e):ci({code:ni.NO_MODULE})}getGroupCounters(e){var t=this._get(Rs);return t?t.getGroupCounters(e):ci({code:ni.NO_MODULE})}getGroupMemberList(e){var t=this._get(Rs);return t?t.getGroupMemberList(e):ci({code:ni.NO_MODULE})}getGroupMemberProfile(e){var t=this._get(Rs);return t?t.getGroupMemberProfile(e):ci({code:ni.NO_MODULE})}addGroupMember(e){var t=this._get(Rs);return t?t.addGroupMember(e):ci({code:ni.NO_MODULE})}deleteGroupMember(e){var t=this._get(Rs);return t?t.deleteGroupMember(e):ci({code:ni.NO_MODULE})}setGroupMemberMuteTime(e){var t=this._get(Rs);return t?t.setGroupMemberMuteTime(e):ci({code:ni.NO_MODULE})}setGroupMemberRole(e){var t=this._get(Rs);return t?t.setGroupMemberRole(e):ci({code:ni.NO_MODULE})}setGroupMemberNameCard(e){var t=this._get(Rs);return t?t.setGroupMemberNameCard(e):ci({code:ni.NO_MODULE})}setGroupMemberCustomField(e){var t=this._get(Rs);return t?t.setGroupMemberCustomField(e):ci({code:ni.NO_MODULE})}markGroupMemberList(e){var t=this._get(Rs);return t?t.markGroupMemberList(e):ci({code:ni.NO_MODULE})}getJoinedCommunityList(){return this._get(As).getJoinedCommunityList()}createTopicInCommunity(e){return this._get(As).createTopicInCommunity(e)}deleteTopicFromCommunity(e){return this._get(As).deleteTopicFromCommunity(e)}updateTopicProfile(e){return this._get(As).updateTopicProfile(e)}getTopicList(e){return this._get(As).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):ci({code:ni.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):ci({code:ni.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):ci({code:ni.NO_MODULE})}accept(e){var t=this._get(Js);return t?t.accept(e):ci({code:ni.NO_MODULE})}reject(e){var t=this._get(Js);return t?t.reject(e):ci({code:ni.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):ci({code:ni.NO_MODULE})}}let Gr={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 kr(e,t){var s;return!(!e.isReady()&&1!==Gr[t])||(s={code:s=e.getNotReadyReason(),message:e.getErrMsg(s)+` | ${t} | `+e.getErrMsg(ni.SDK_IS_NOT_READY)},e.onError(s),s)}let wr={},br={create:function(t){var i="TencentCloudChat.create";let o=0;var n=t["SDKAppID"];if(Fe(n))o=n;else if(o=parseInt(n),isNaN(n))return Se.e(i+" failed. Failed to parse the SDKAppID, please check the arguments"),null;if(o&&wr[o])return wr[o];Se.l(i);n=new Ur({...t,SDKAppID:o}),n.on(e.SDK_DESTROY,e=>{wr[e.data.SDKAppID]=null,delete wr[e.data.SDKAppID]}),t=function(o){let e=Object.create(null);return Object.keys(Ts).forEach(i=>{if(o[i]){let t=new s;e[i]=function(){var e=Array.from(arguments);return t.use(function(e,t){var s=kr(o,i);return!0===s?t():ci(s)}).use(function(e,t){if(!0===Pt(e,Cs[i],i))return t()}).use(function(e,t){return o[i].apply(o,e)}),t.run(e)}}}),e}(n);return wr[o]=t,Cs.hookGetAPITips(n.getErrMsg.bind(n)),Se.l(i+" ok"),t}};br.TYPES=t,br.EVENT=e,br.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},br.VERSION="3.6.5",Se.l("TencentCloudChat.VERSION:"+br.VERSION);export{br as default};