Files
zyt/server/public/admin/assets/@tencentcloud/chat-uikit-engine-zx802ozq.js
T
2026-07-06 15:00:10 +08:00

3 lines
159 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{T as Q}from"./chat-AC2Y2r2A.js";import{t as zt}from"../tim-upload-plugin-HO4N4AW9.js";import{s as Jt}from"../tim-profanity-filter-plugin-Dn_Cf-mP.js";function G(r,e){var t={};for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&e.indexOf(s)<0&&(t[s]=r[s]);if(r!=null&&typeof Object.getOwnPropertySymbols=="function"){var n=0;for(s=Object.getOwnPropertySymbols(r);n<s.length;n++)e.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(r,s[n])&&(t[s[n]]=r[s[n]])}return t}function j(r,e,t,s){return new(t||(t=Promise))(function(n,i){function a(g){try{o(s.next(g))}catch(l){i(l)}}function u(g){try{o(s.throw(g))}catch(l){i(l)}}function o(g){var l;g.done?n(g.value):(l=g.value,l instanceof t?l:new t(function(p){p(l)})).then(a,u)}o((s=s.apply(r,[])).next())})}class oe{constructor(e){return oe.instance||(oe.instance=this,this.engine=e,this.events={},this.bindIMEvents()),oe.instance}addEvent(e,t){this.events[e]||(this.events[e]=new Map),this.events[e].set(t,1)}removeEvents(){Object.keys(this.events).forEach(e=>{this.events[e].clear()}),this.events={}}dispatch(e,t){if(this.events[e])for(const s of this.events[e].keys())s.call(this,t)}bindIMEvents(){this.engine.chat.on(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.on(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.on(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.on(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated,this),this.engine.chat.on(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.on(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.on(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this),this.engine.chat.on(this.engine.EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated,this),this.engine.chat.on(this.engine.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_LIST_UPDATED,this.onGroupListUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,this.onGroupAttributesUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_COUNTER_UPDATED,this.onGroupCounterUpdated,this),this.engine.chat.on(this.engine.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated,this),this.engine.chat.on(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated,this),this.engine.chat.on(this.engine.EVENT.FRIEND_GROUP_LIST_UPDATED,this.onFriendGroupListUpdated,this)}unbindIMEvents(){this.engine.chat.off(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.off(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.off(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.off(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated,this),this.engine.chat.off(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.off(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.off(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this),this.engine.chat.off(this.engine.EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated,this),this.engine.chat.off(this.engine.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_LIST_UPDATED,this.onGroupListUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,this.onGroupAttributesUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_COUNTER_UPDATED,this.onGroupCounterUpdated,this),this.engine.chat.off(this.engine.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated,this),this.engine.chat.off(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated,this),this.engine.chat.off(this.engine.EVENT.FRIEND_GROUP_LIST_UPDATED,this.onFriendGroupListUpdated,this),oe.instance=null}onSDKReady(e){this.dispatch(this.engine.EVENT.SDK_READY,e.data)}onSDKNotReady(e){this.dispatch(this.engine.EVENT.SDK_NOT_READY,e.data)}onKickedOut(e){this.dispatch(this.engine.EVENT.KICKED_OUT,e.data)}onNetStateChange(e){this.dispatch(this.engine.EVENT.NET_STATE_CHANGE,e.data)}onReceiveMessage(e){this.dispatch(this.engine.EVENT.MESSAGE_RECEIVED,e.data)}onMessageModified(e){this.dispatch(this.engine.EVENT.MESSAGE_MODIFIED,e.data)}onMessageRevoked(e){this.dispatch(this.engine.EVENT.MESSAGE_REVOKED,e.data)}onMessageReadByPeer(e){this.dispatch(this.engine.EVENT.MESSAGE_READ_BY_PEER,e.data)}onMessageReadReceiptReceived(e){this.dispatch(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,e.data)}onMessageReactionsUpdated(e){this.dispatch(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,e.data)}onConversationListUpdated(e){this.dispatch(this.engine.EVENT.CONVERSATION_LIST_UPDATED,e.data)}onTotalMessageCountUpdated(e){this.dispatch(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,e.data)}onProfileUpdated(e){this.dispatch(this.engine.EVENT.PROFILE_UPDATED,e.data)}onBlacklistUpdated(e){this.dispatch(this.engine.EVENT.BLACKLIST_UPDATED,e.data)}onUserStatusUpdated(e){this.dispatch(this.engine.EVENT.USER_STATUS_UPDATED,e.data)}onGroupListUpdated(e){this.dispatch(this.engine.EVENT.GROUP_LIST_UPDATED,e.data)}onGroupAttributesUpdated(e){this.dispatch(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,e.data)}onGroupCounterUpdated(e){this.dispatch(this.engine.EVENT.GROUP_COUNTER_UPDATED,e.data)}onFriendListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_LIST_UPDATED,e.data)}onFriendApplicationListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,e.data)}onFriendGroupListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_GROUP_LIST_UPDATED,e.data)}}var A,c,Le,P,tt,ye,q,be,z;(function(r){r.TUIStore="TUIStore",r.TUITranslate="TUITranslate",r.TUIConversation="TUIConversation",r.TUIChat="TUIChat",r.TUIGroup="TUIGroup",r.TUIUser="TUIUser",r.TUIFriend="TUIFriend",r.TUIReport="TUIReport",r.TUISearch="TUISearch"})(A||(A={})),(function(r){r.APP="application",r.CONV="conversation",r.CHAT="chat",r.GRP="group",r.USER="user",r.FRIEND="friend",r.SEARCH="search",r.CUSTOM="custom"})(c||(c={})),(function(r){r[r.UNSUB_USER=-1]="UNSUB_USER"})(Le||(Le={})),(function(r){r.BUSINESS_ID="user_typing_status",r[r.STATUS_START=1]="STATUS_START",r[r.STATUS_END=0]="STATUS_END",r[r.VERSION=1]="VERSION",r[r.ACTION_START_ID=14]="ACTION_START_ID",r[r.ACTION_END_ID=0]="ACTION_END_ID",r.ACTION_START="EIMAMSG_InputStatus_Ing",r.ACTION_END="EIMAMSG_InputStatus_End",r[r.NEED_TYPING=1]="NEED_TYPING"})(P||(P={})),(function(r){r.ADD="add",r.REMOVE="remove"})(tt||(tt={})),(function(r){r[r.MSG_MODIFY_CONFLICT=2480]="MSG_MODIFY_CONFLICT",r[r.MSG_MODIFY_DISABLED_IN_AVCHATROOM=2481]="MSG_MODIFY_DISABLED_IN_AVCHATROOM",r[r.MODIFY_MESSAGE_NOT_EXIST=20026]="MODIFY_MESSAGE_NOT_EXIST"})(ye||(ye={})),(function(r){r[r.NOT_INIT=-1e5]="NOT_INIT",r[r.INVALID_CONV_ID=-100001]="INVALID_CONV_ID",r[r.CONV_ID_SAME=-100002]="CONV_ID_SAME",r[r.CONV_NOT_EXIST=-100003]="CONV_NOT_EXIST",r[r.GET_MSG_LIST_ERROR=-100004]="GET_MSG_LIST_ERROR",r[r.MISMATCH_TYPE_AND_PAYLOAD=-100005]="MISMATCH_TYPE_AND_PAYLOAD"})(q||(q={})),(function(r){r.MSG_MODIFY_CONFLICT="MODIFY_MESSAGE_ERROR,修改消息发生冲突, data.message 是最新的消息",r.MSG_MODIFY_DISABLED_IN_AVCHATROOM="MODIFY_MESSAGE_ERROR,不支持修改直播群消息.",r.MODIFY_MESSAGE_NOT_EXIST="MODIFY_MESSAGE_ERROR,消息不存在."})(be||(be={})),(function(r){r.NOT_INIT="TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。",r.INVALID_CONV_ID="会话 ID 无效",r.CONV_ID_SAME="您切换的是同一个会话 ID",r.CONV_NOT_EXIST="会话不存在",r.GET_MSG_LIST_ERROR="Chat SDK is not ready.",r.MISMATCH_TYPE_AND_PAYLOAD="type 与 payload 不匹配."})(z||(z={}));const $e={logout:1,destroy:1},Wt={deleteConversation:1,pinConversation:1,muteConversation:1,switchConversation:1,getConversationProfile:1,clearHistoryMessage:1,setMessageRead:1,markConversation:1},Xt={modifyMessage:1,revokeMessage:1,resendMessage:1,deleteMessage:1,quoteMessage:1,replyMessage:1,setMessageExtensions:1,deleteMessageExtensions:1,getMessageExtensions:1,sendTextMessage:1,sendTextAtMessage:1,sendImageMessage:1,sendAudioMessage:1,sendVideoMessage:1,sendFileMessage:1,sendCustomMessage:1,sendFaceMessage:1,sendLocationMessage:1,sendForwardMessage:1,enterTypingState:1,leaveTypingState:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageList:1,downloadMergedMessages:1,setTranslationLanguage:1,translateText:1,searchCloudMessages:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1},Qt={switchGroup:1,getGroupProfile:1,updateGroupProfile:1,createGroup:1,dismissGroup:1,searchGroupByID:1,joinGroup:1,quitGroup:1,getGroupApplicationList:1,handleGroupApplication:1,getGroupOnlineMemberCount:1,changeGroupOwner:1,initGroupAttributes:1,setGroupAttributes:1,deleteGroupAttributes:1,getGroupAttributes:1,setGroupCounters:1,increaseGroupCounter:1,decreaseGroupCounter:1,getGroupCounters:1,getGroupMemberList:1,getGroupMemberProfile:1,addGroupMember:1,deleteGroupMember:1,setGroupMemberMuteTime:1,setGroupMemberRole:1,setGroupMemberNameCard:1,setGroupMemberCustomField:1,markGroupMemberList:1},Zt={switchUserStatus:1,switchMessageReadStatus:1,getUserProfile:1,updateMyProfile:1,addToBlacklist:1,removeFromBlacklist:1},es={getFriendList:1,addFriend:1,deleteFriend:1,checkFriend:1,getFriendProfile:1,updateFriend:1,acceptFriendApplication:1,refuseFriendApplication:1,deleteFriendApplication:1,setFriendApplicationRead:1},D=function(r){return r===void 0},Ue=function(r){return r.startsWith("_")},He=function(r){return/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(r)},_=function(r){return r&&(function(e){if(typeof e=="string")try{return!!JSON.parse(e)}catch{return!1}return!1})(r)?JSON.parse(r):r},ts=function(r){let e="";return e=r>=1048576?`${(r/1048576).toFixed(2)} Mb`:r>=1024?`${(r/1024).toFixed(2)} Kb`:`${r.toFixed(2)}B`,e},ss="https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_16.png",ns="https://web.sdk.qcloud.com/im/demo/TUIkit/web/img/constomer.png",is="https://web.sdk.qcloud.com/component/TUIKit/assets/group_avatar.png",rs="https://web.sdk.qcloud.com/im/assets/emoji-plugin/",as="https://web.sdk.qcloud.com/im/assets/face-elem/",os="https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&",us="https://apis.map.qq.com/ws/staticmap/v2/?",st={"[TUIEmoji_Expect]":"emoji_0@2x.png","[TUIEmoji_Blink]":"emoji_1@2x.png","[TUIEmoji_Guffaw]":"emoji_2@2x.png","[TUIEmoji_KindSmile]":"emoji_3@2x.png","[TUIEmoji_Haha]":"emoji_4@2x.png","[TUIEmoji_Cheerful]":"emoji_5@2x.png","[TUIEmoji_Smile]":"emoji_6@2x.png","[TUIEmoji_Sorrow]":"emoji_7@2x.png","[TUIEmoji_Speechless]":"emoji_8@2x.png","[TUIEmoji_Amazed]":"emoji_9@2x.png","[TUIEmoji_Complacent]":"emoji_10@2x.png","[TUIEmoji_Lustful]":"emoji_11@2x.png","[TUIEmoji_Stareyes]":"emoji_12@2x.png","[TUIEmoji_Giggle]":"emoji_13@2x.png","[TUIEmoji_Daemon]":"emoji_14@2x.png","[TUIEmoji_Rage]":"emoji_15@2x.png","[TUIEmoji_Yawn]":"emoji_16@2x.png","[TUIEmoji_TearsLaugh]":"emoji_17@2x.png","[TUIEmoji_Silly]":"emoji_18@2x.png","[TUIEmoji_Wail]":"emoji_19@2x.png","[TUIEmoji_Kiss]":"emoji_20@2x.png","[TUIEmoji_Trapped]":"emoji_21@2x.png","[TUIEmoji_Fear]":"emoji_22@2x.png","[TUIEmoji_BareTeeth]":"emoji_23@2x.png","[TUIEmoji_FlareUp]":"emoji_24@2x.png","[TUIEmoji_Tact]":"emoji_25@2x.png","[TUIEmoji_Shit]":"emoji_26@2x.png","[TUIEmoji_ShutUp]":"emoji_27@2x.png","[TUIEmoji_Sigh]":"emoji_28@2x.png","[TUIEmoji_Hehe]":"emoji_29@2x.png","[TUIEmoji_Silent]":"emoji_30@2x.png","[TUIEmoji_Skull]":"emoji_31@2x.png","[TUIEmoji_Mask]":"emoji_32@2x.png","[TUIEmoji_Beer]":"emoji_33@2x.png","[TUIEmoji_Cake]":"emoji_34@2x.png","[TUIEmoji_RedPacket]":"emoji_35@2x.png","[TUIEmoji_Bombs]":"emoji_36@2x.png","[TUIEmoji_Ai]":"emoji_37@2x.png","[TUIEmoji_Celebrate]":"emoji_38@2x.png","[TUIEmoji_Bless]":"emoji_39@2x.png","[TUIEmoji_Flower]":"emoji_40@2x.png","[TUIEmoji_Watermelon]":"emoji_41@2x.png","[TUIEmoji_Cow]":"emoji_42@2x.png","[TUIEmoji_Fool]":"emoji_43@2x.png","[TUIEmoji_Surprised]":"emoji_44@2x.png","[TUIEmoji_Askance]":"emoji_45@2x.png","[TUIEmoji_Monster]":"emoji_46@2x.png","[TUIEmoji_Pig]":"emoji_47@2x.png","[TUIEmoji_Coffee]":"emoji_48@2x.png","[TUIEmoji_Ok]":"emoji_49@2x.png","[TUIEmoji_Heart]":"emoji_50@2x.png","[TUIEmoji_Sun]":"emoji_51@2x.png","[TUIEmoji_Moon]":"emoji_52@2x.png","[TUIEmoji_Star]":"emoji_53@2x.png","[TUIEmoji_Rich]":"emoji_54@2x.png","[TUIEmoji_Fortune]":"emoji_55@2x.png","[TUIEmoji_857]":"emoji_56@2x.png","[TUIEmoji_666]":"emoji_57@2x.png","[TUIEmoji_Prohibit]":"emoji_58@2x.png","[TUIEmoji_Convinced]":"emoji_59@2x.png","[TUIEmoji_Knife]":"emoji_60@2x.png","[TUIEmoji_Like]":"emoji_61@2x.png"},gs={"[TUIEmoji_Smile]":"[微笑]","[TUIEmoji_Expect]":"[期待]","[TUIEmoji_Blink]":"[眨眼]","[TUIEmoji_Guffaw]":"[大笑]","[TUIEmoji_KindSmile]":"[姨母笑]","[TUIEmoji_Haha]":"[哈哈哈]","[TUIEmoji_Cheerful]":"[愉快]","[TUIEmoji_Speechless]":"[无语]","[TUIEmoji_Amazed]":"[惊讶]","[TUIEmoji_Sorrow]":"[悲伤]","[TUIEmoji_Complacent]":"[得意]","[TUIEmoji_Silly]":"[傻了]","[TUIEmoji_Lustful]":"[色]","[TUIEmoji_Giggle]":"[憨笑]","[TUIEmoji_Kiss]":"[亲亲]","[TUIEmoji_Wail]":"[大哭]","[TUIEmoji_TearsLaugh]":"[哭笑]","[TUIEmoji_Trapped]":"[困]","[TUIEmoji_Mask]":"[口罩]","[TUIEmoji_Fear]":"[恐惧]","[TUIEmoji_BareTeeth]":"[龇牙]","[TUIEmoji_FlareUp]":"[发怒]","[TUIEmoji_Yawn]":"[打哈欠]","[TUIEmoji_Tact]":"[机智]","[TUIEmoji_Stareyes]":"[星星眼]","[TUIEmoji_ShutUp]":"[闭嘴]","[TUIEmoji_Sigh]":"[叹气]","[TUIEmoji_Hehe]":"[呵呵]","[TUIEmoji_Silent]":"[收声]","[TUIEmoji_Surprised]":"[惊喜]","[TUIEmoji_Askance]":"[白眼]","[TUIEmoji_Ok]":"[OK]","[TUIEmoji_Shit]":"[便便]","[TUIEmoji_Monster]":"[怪兽]","[TUIEmoji_Daemon]":"[恶魔]","[TUIEmoji_Rage]":"[恶魔怒]","[TUIEmoji_Fool]":"[衰]","[TUIEmoji_Pig]":"[猪]","[TUIEmoji_Cow]":"[牛]","[TUIEmoji_Ai]":"[AI]","[TUIEmoji_Skull]":"[骷髅]","[TUIEmoji_Bombs]":"[炸弹]","[TUIEmoji_Coffee]":"[咖啡]","[TUIEmoji_Cake]":"[蛋糕]","[TUIEmoji_Beer]":"[啤酒]","[TUIEmoji_Flower]":"[花]","[TUIEmoji_Watermelon]":"[瓜]","[TUIEmoji_Rich]":"[壕]","[TUIEmoji_Heart]":"[爱心]","[TUIEmoji_Moon]":"[月亮]","[TUIEmoji_Sun]":"[太阳]","[TUIEmoji_Star]":"[星星]","[TUIEmoji_RedPacket]":"[红包]","[TUIEmoji_Celebrate]":"[庆祝]","[TUIEmoji_Bless]":"[福]","[TUIEmoji_Fortune]":"[发]","[TUIEmoji_Convinced]":"[服]","[TUIEmoji_Prohibit]":"[禁]","[TUIEmoji_666]":"[666]","[TUIEmoji_857]":"[857]","[TUIEmoji_Knife]":"[刀]","[TUIEmoji_Like]":"[赞]"},nt={enabledMessageReadReceipt:Math.pow(2,5),enabledEmojiPlugin:Math.pow(2,48),enabledOnlineStatus:Math.pow(2,7),enabledCustomerServicePlugin:Math.pow(2,40),enabledTranslationPlugin:Math.pow(2,38),enabledVoiceToText:Math.pow(2,39)},cs=["messageList","conversationList","newMessageList"],ls=["translateTextInfo","voiceToTextInfo"],Y=typeof wx<"u"&&typeof wx.getSystemInfoSync=="function"&&!!wx.getSystemInfoSync().fontSizeSetting,Ae=typeof uni<"u"&&typeof window>"u",Ke=Y||Ae,hs=typeof uni<"u",kt=(typeof uni<"u"||typeof window<"u")&&!Ke,qe=Y?wx:hs?uni:typeof window<"u"?window:{},me=kt&&window&&window.navigator&&window.navigator.userAgent||"",ps=/Android/i.test(me),ds=/(?:Windows Phone)/.test(me),fs=/(?:SymbianOS)/.test(me),ms=/iPad/i.test(me)||/iPhone/i.test(me)||/iPod/i.test(me),Nt=ps||ds||fs||ms,Es=kt&&!Nt;class Z{constructor(){this.global=qe,this.isOfficial=!1}static getInstance(){return Z.instance||(Z.instance=new Z),Z.instance}initOfficial(e){this.isOfficial=e}getPlatform(){let e="";return Es?e="pc":Nt?e="h5":Y?e="wechat":Ae&&!Y&&(e="app"),e}}const vs="group-module",Ts="relationship-module";class ee{constructor(){this.EVENT=Q.EVENT,this.TYPES=Q.TYPES,this.loginStatusPromise=new Map,this.userID="",this.isInited=!1}static getInstance(){return ee.instance||(ee.instance=new ee),ee.instance}mount(e,t){this[e]=t}login(e){const{chat:t,SDKAppID:s,userID:n}=e,i=s===1400187352||s===1400188366;return this.createChat(e),this.userID=n,Z.getInstance().initOfficial(i),this.TUIStore.update(c.APP,"isOfficial",i),this.TUIStore.update(c.APP,"SDKVersion",Q.VERSION),this.eventCenter=new oe(this),this.eventCenter.removeEvents(),this.resetStore(),this.initService(),t&&t.isReady()?(console.log("TUIChatEngine.login ok, from TUICore."),this.TUIUser.getUserProfile(),this.checkCommercialAbility(),Promise.resolve({})):(this.registerPlugin(e),this.eventCenter.addEvent(this.EVENT.SDK_READY,()=>{this.onSDKReady()}),this.eventCenter.addEvent(this.EVENT.SDK_NOT_READY,()=>{this.onSDKNotReady()}),this.loginChat(e))}logout(){return this.userID="",this.isInited=!1,this.resetStore(),this.chat.logout()}isReady(){var e;return((e=this.chat)===null||e===void 0?void 0:e.isReady())||!1}setLogLevel(e){this.chat?this.chat.setLogLevel(e):console.warn("TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。")}destroy(){return this.eventCenter.unbindIMEvents(),this.isInited=!1,this.resetStore(),this.chat.destroy()}getMyUserID(){return this.userID}resetStore(){this.TUIStore.reset(c.CHAT),this.TUIStore.reset(c.CONV),this.TUIStore.reset(c.GRP),this.TUIStore.reset(c.USER),this.TUIStore.reset(c.SEARCH),this.TUIStore.reset(c.FRIEND),this.TUIStore.reset(c.CUSTOM),console.log("TUIChatEngine.resetStore ok.")}initService(){this.TUIChat.init(),this.TUIConversation.init(),this.TUIUser.init(),this.initOptionalServices(),this.isInited=!0,console.log("TUIChatEngine.initService ok.")}initOptionalServices(){const e=Q.VERSION.split(".");e[0]>3||e[0]===3&&e[1]>=3&&e[2]>0?(this.chat.callExperimentalAPI("canIUseModule",[vs])===!0&&this.TUIGroup.init(),this.chat.callExperimentalAPI("canIUseModule",[Ts])===!0&&this.TUIFriend.init()):(this.TUIGroup.init(),this.TUIFriend.init())}createChat(e){const{chat:t}=e,s=G(e,["chat"]);D(t)?this.chat=Q.create(Object.assign(Object.assign({},s),{scene:"chat-uikit-engine"})):this.chat=t}loginChat(e){const{userID:t,userSig:s}=e;return new Promise((n,i)=>{this.chat.login({userID:t,userSig:s}).then(a=>{console.log("TUIChatEngine.loginChat ok."),this.checkCommercialAbility(),a.data.repeatLogin&&this.chat.isReady()&&n(a),this.loginStatusPromise.set("login",{resolve:n,reject:i,imResponse:a})}).catch(a=>{i(a)})})}registerPlugin(e){const{useUploadPlugin:t=!1,useProfanityFilterPlugin:s=!1,TIMPush:n,pushConfig:i,TUIOfflinePush:a,offlinePushConfig:u}=e;t===!0&&this.chat.registerPlugin({"tim-upload-plugin":zt}),s===!0&&this.chat.registerPlugin({"tim-profanity-filter-plugin":Jt}),!Ae||Y||D(n)||D(i)||this.chat.registerPlugin({"tim-push":n,pushConfig:i}),!Ae||Y||D(a)||D(u)||this.chat.registerPlugin({"tim-offline-push-plugin":a,offlinePushConfig:u})}onSDKReady(){if(this.loginStatusPromise.has("login")){const e=this.loginStatusPromise.get("login");e.resolve(e.imResponse),this.TUIUser.getUserProfile()}this.loginStatusPromise.delete("login")}onSDKNotReady(){this.loginStatusPromise.has("login")&&this.loginStatusPromise.get("login").reject(new Error("sdk not ready")),this.loginStatusPromise.delete("login"),this.resetStore()}checkCommercialAbility(){Object.keys(nt).forEach(e=>{const t=nt[e];this.chat.callExperimentalAPI("isCommercialAbilityEnabled",t).then(s=>{const{enabled:n=!1}=s.data;this.TUIStore.update(c.APP,e,n)})})}}class Ss{constructor(){this.defaultStore={enabledMessageReadReceipt:!1,enabledEmojiPlugin:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,enableAutoMessageRead:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}},this.store={enabledEmojiPlugin:!1,enabledMessageReadReceipt:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,enableAutoMessageRead:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((t,s)=>Object.assign(Object.assign({},t),{[s]:this.defaultStore[s]}),{}))}}class Is{constructor(){this.defaultStore={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"},this.store={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"}}update(e,t){e==="userStatusList"?this.updateUserStatusList(t):this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((t,s)=>Object.assign(Object.assign({},t),{[s]:this.defaultStore[s]}),{}))}updateUserStatusList(e){e.length!==0?e.forEach(t=>{const{userID:s,statusType:n=0,customStatus:i=""}=t;n===Le.UNSUB_USER?this.store.userStatusList.delete(s):this.store.userStatusList.set(s,{statusType:n,customStatus:i})}):this.store.userStatusList.clear()}}class F{getEngine(){return ee.getInstance()}}const Gt=function(r){if(r==null)return!0;if(typeof r=="boolean")return!1;if(typeof r=="number")return r===0;if(typeof r=="string"||typeof r=="function"||Array.isArray(r))return r.length===0;if(r instanceof Error)return r.message==="";if((function(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);if(t===null)return!0;let s=t;for(;Object.getPrototypeOf(s)!==null;)s=Object.getPrototypeOf(s);return t===s})(r)){for(const e in r)if(Object.prototype.hasOwnProperty.call(r,e))return!1;return!0}return!1},it=["[图片]","[语音]","[视频]","[文件]","[位置]","[地理位置]","[动画表情]","[自定义消息]","[群提示消息]","[聊天记录]"];class je extends F{constructor(e){super(),this.initProxy(e),this.isMuted=this.messageRemindType===this.getEngine().TYPES.MSG_REMIND_ACPT_NOT_NOTE||this.messageRemindType===this.getEngine().TYPES.MSG_REMIND_DISCARD,this.operationType=0,this._conversation=e}initProxy(e){Object.keys(e).forEach(t=>{Ue(t)||(this[t]=e[t])})}updateProperties(e){Object.keys(e).forEach(t=>{Ue(t)||(this[t]=e[t])})}updateOperationType(e){this.operationType=e}getConversation(){return this._conversation}deleteConversation(e=!0){return this.getEngine().TUIConversation.deleteConversation({conversationIDList:[this.conversationID],clearHistoryMessage:e})}pinConversation(){return this.getEngine().TUIConversation.pinConversation({conversationID:this.conversationID,isPinned:!this.isPinned})}muteConversation(){const e=this.getEngine(),t={messageRemindType:this.isMuted===!0?e.TYPES.MSG_REMIND_ACPT_AND_NOTE:e.TYPES.MSG_REMIND_ACPT_NOT_NOTE};if(this.type===e.TYPES.CONV_C2C){const s=this.conversationID.replace(e.TYPES.CONV_C2C,"");t.userIDList=[s]}else if(this.type===e.TYPES.CONV_GROUP){const s=this.conversationID.replace(e.TYPES.CONV_GROUP,"");t.groupID=s}return e.TUIConversation.muteConversation(t)}setMessageRead(){return this.getEngine().TUIConversation.setMessageRead(this.conversationID)}getAvatar(){var e,t,s,n,i,a;const u=this.getEngine();let o="";switch(this.type){case u.TYPES.CONV_C2C:o=He((e=this.userProfile)===null||e===void 0?void 0:e.avatar)?(t=this.userProfile)===null||t===void 0?void 0:t.avatar:ss;break;case u.TYPES.CONV_GROUP:o=He((s=this.groupProfile)===null||s===void 0?void 0:s.avatar)?(n=this.groupProfile)===null||n===void 0?void 0:n.avatar:ns;break;case u.TYPES.CONV_SYSTEM:o=He((i=this.groupProfile)===null||i===void 0?void 0:i.avatar)?(a=this.groupProfile)===null||a===void 0?void 0:a.avatar:is}return o}getShowName(){var e,t,s,n;const i=this.getEngine();let a="";switch(this.type){case i.TYPES.CONV_C2C:a=this.remark||((e=this.userProfile)===null||e===void 0?void 0:e.nick)||((t=this.userProfile)===null||t===void 0?void 0:t.userID)||"";break;case i.TYPES.CONV_GROUP:a=((s=this.groupProfile)===null||s===void 0?void 0:s.name)||((n=this.groupProfile)===null||n===void 0?void 0:n.groupID)||"";break;case i.TYPES.CONV_SYSTEM:a=i.TUITranslate.t("系统通知")}return a}getGroupAtInfo(){const e=this.getEngine(),t=e.TUITranslate.t.bind(e.TUITranslate),s=[`[${t("TUIConversation.有人@我")}]`,`[${t("TUIConversation.@所有人")}]`,`[${t("TUIConversation.@所有人")}][${t("TUIConversation.有人@我")}]`];let n="";for(let i=0;i<this.groupAtInfoList.length;i++)this.groupAtInfoList[i].atTypeArray[0]&&(n=s[this.groupAtInfoList[i].atTypeArray[0]-1]);return n}getLastMessage(e){return e==="time"?this.getLastMessageTime():e==="text"?this.getLastMessageText():(console.warn(`ConversationModel.getLastMessage key:${e} is invalid.`),null)}getLastMessageTime(){var e;const t=this.getEngine();let s="";return((e=this.lastMessage)===null||e===void 0?void 0:e.lastTime)>0&&(s=(function(n,i){const l=new Date().getTime()-n;let p="";if(l<0)return p;const h=l/6e4,f=l/36e5,m=l/864e5,E=l/6048e5;if(E>=1&&E<=4)p=` ${parseInt(`${E}`,10)} ${i("time.周")}${i("time.前")}`;else if(m>=1&&m<=6)p=` ${parseInt(`${m}`,10)} ${i("time.天")}${i("time.前")}`;else if(f>=1&&f<=23)p=` ${parseInt(`${f}`,10)} ${i("time.小时")}${i("time.前")}`;else if(h>=1&&h<=59)p=` ${parseInt(`${h}`,10)} ${i("time.分钟")}${i("time.前")}`;else if(l>=0&&l<=6e4)p=`${i("time.刚刚")}`;else{const d=new Date;d.setTime(n),p=`${d.getFullYear()}-${d.getMonth()+1<10?`0${d.getMonth()+1}`:d.getMonth()+1}-${d.getDate()<10?`0${d.getDate()}`:d.getDate()}`}return p})(1e3*this.lastMessage.lastTime,t.TUITranslate.t.bind(t.TUITranslate))),s}getLastMessageText(){var e;if(this.draftText)return _(this.draftText).abstract;const t=this.getEngine(),s=t.TUITranslate.t.bind(t.TUITranslate);if(this.operationType===4)return s("TUIConversation.您已被群管理员移出群聊");if(this.operationType===5)return s("TUIConversation.该群聊已被解散");if(this.operationType===8)return s("TUIConversation.您已退出该群聊");const n=this._conversation,{lastMessage:i}=this;let a="",u="";const o=n.unreadCount>0&&n.messageRemindType===t.TYPES.MSG_REMIND_ACPT_NOT_NOTE?`[${n.unreadCount>99?"99+":n.unreadCount}${s("TUIConversation.条")}]`:"";if(n.type===t.TYPES.CONV_GROUP)if(i.fromAccount===t.getMyUserID())a=s("TUIConversation.我");else{const g=i.fromAccount;a=t.TUIFriend.getFriendRemark([g])[g]||i.nameCard||i.nick||g}if(i.type===t.TYPES.MSG_TEXT)u=this.decodeTextMessage(i.payload.text);else if(i.type===t.TYPES.MSG_CUSTOM){const g=_((e=i==null?void 0:i.payload)===null||e===void 0?void 0:e.data);if((g==null?void 0:g.businessID)===1)return u=t.TUIChat.messageHandler.handleCallKitSignaling(i),u;u=it.includes(i.messageForShow)?s(`TUIChat.${i.messageForShow}`):i.messageForShow}else u=it.includes(i.messageForShow)?s(`TUIChat.${i.messageForShow}`):i.messageForShow;return i.isRevoked&&(u=s("TUIChat.撤回了一条消息")),n.type===t.TYPES.CONV_GROUP&&i.type===t.TYPES.MSG_GRP_TIP?u:`${o}${a?`${a}:`:""}${u}`}decodeTextMessage(e){if(Gt(e))return e;const t=/(\[.+?\])/g;let s=e;if(t.test(e)){const n=this.getEngine(),i=n.TUITranslate.t.bind(n.TUITranslate);s=e.replace(t,a=>{const u=i(`Emoji.${a}`);return Y||!u||u.startsWith("Emoji.")?gs[a]||a:u})}return s}}class ys{constructor(){this.defaultStore={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map},this.store={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map}}update(e,t){switch(e){case"conversationList":this.updateConversationList(t);break;case"operationTypeMap":this.updateOperationTypeMap(t);break;default:this.store[e]=t}}getData(e){return this.store[e]}getModel(e){return this.store.conversationList.find(t=>t.conversationID===e)}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((t,s)=>Object.assign(Object.assign({},t),{[s]:this.defaultStore[s]}),{}))}updateConversationList(e){const t=[];e.forEach(s=>{let n=s;s instanceof je?n.updateProperties(s):n=new je(s);const i=this.getOperationType(s);n.updateOperationType(i),t.push(n)}),this.store.conversationList=t}updateOperationTypeMap(e){const{conversationID:t,operationType:s=0}=e;this.store.operationTypeMap.set(t,s)}getOperationType(e){const{conversationID:t}=e;return this.store.operationTypeMap.get(t)||0}}class Me extends F{constructor(e){super(),this.messageHandlers={[this.getEngine().TYPES.MSG_TEXT]:t=>this.getEngine().TUIChat.messageHandler.handleTextMessage(t),[this.getEngine().TYPES.MSG_FACE]:t=>this.getEngine().TUIChat.messageHandler.handleFaceMessage(t),[this.getEngine().TYPES.MSG_LOCATION]:t=>this.getEngine().TUIChat.messageHandler.handleLocationMessage(t),[this.getEngine().TYPES.MSG_IMAGE]:t=>this.getEngine().TUIChat.messageHandler.handleImageMessage(t),[this.getEngine().TYPES.MSG_AUDIO]:t=>this.getEngine().TUIChat.messageHandler.handleAudioMessage(t),[this.getEngine().TYPES.MSG_VIDEO]:t=>this.getEngine().TUIChat.messageHandler.handleVideoMessage(t),[this.getEngine().TYPES.MSG_FILE]:t=>this.getEngine().TUIChat.messageHandler.handleFileMessage(t),[this.getEngine().TYPES.MSG_CUSTOM]:t=>this.getEngine().TUIChat.messageHandler.handleCustomMessage(t),[this.getEngine().TYPES.MSG_MERGER]:t=>this.getEngine().TUIChat.messageHandler.handleMergeMessage(t),[this.getEngine().TYPES.MSG_GRP_TIP]:t=>this.getEngine().TUIChat.messageHandler.handleGroupTipsMessage(t)},this._message=e,this._signalingInfo=void 0,this.progress=0,this.reactionList=[],this.initProperties(e)}initProperties(e){Object.keys(e).forEach(t=>{Ue(t)||(this[t]=e[t])})}updateProperties(e){this._message=e,Object.keys(e).forEach(t=>{Ue(t)||(this[t]=e[t])})}getMessage(){return this._message}modifyMessage(e){return e.type&&this._message.type!==e.type&&!e.payload?Promise.reject({code:q.MISMATCH_TYPE_AND_PAYLOAD,message:z.MISMATCH_TYPE_AND_PAYLOAD}):(this._message.type=e.type||this._message.type,this._message.payload=e.payload||this._message.payload,this._message.cloudCustomData=e.cloudCustomData||this._message.cloudCustomData,this.getEngine().TUIChat.modifyMessage(this._message))}revokeMessage(){return this.getEngine().TUIChat.revokeMessage(this._message)}resendMessage(){return this.getEngine().TUIChat.resendMessage(this._message)}deleteMessage(){return this.getEngine().TUIChat.deleteMessage([this._message])}quoteMessage(){return this.getEngine().TUIChat.quoteMessage(this._message)}replyMessage(){return this.getEngine().TUIChat.replyMessage(this._message)}setMessageExtensions(e){return this.getEngine().TUIChat.setMessageExtensions(this._message,e)}getMessageExtensions(){return this.getEngine().TUIChat.getMessageExtensions(this._message)}deleteMessageExtensions(e){return this.getEngine().TUIChat.deleteMessageExtensions(this._message,e)}getSignalingInfo(){return this.type!==this.getEngine().TYPES.MSG_CUSTOM?null:D(this._signalingInfo)?(this._signalingInfo=this.getEngine().chat.getSignalingInfo(this._message),this._signalingInfo):this._signalingInfo}getMessageContent(){const e=this.messageHandlers[this.type];if(D(e))return{};if(this.type===this.getEngine().TYPES.MSG_GRP_TIP)return e(this._message);const t=this.getEngine().TUIFriend.getFriendRemark([this.from]);return Object.assign(Object.assign({},e(this._message)),{showName:t[this.from]||this.nameCard||this.nick||this.from})}sendForwardMessage(e){return this.getEngine().TUIChat.sendForwardMessage(e,[this._message])}}class bs{constructor(){this.defaultStore={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}},this.store={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}}}update(e,t){switch(e){case"messageList":this.updateMessageList(t);break;case"translateTextInfo":this.updateTranslateTextInfo(t);break;case"voiceToTextInfo":this.updateVoiceToTextInfo(t);break;default:this.store[e]=t}}getData(e){return this.store[e]}getModel(e){return this.store.messageList.find(t=>t.ID===e)}reset(e=[]){const t=e.filter(s=>!ls.includes(s));this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),t==null?void 0:t.reduce((s,n)=>Object.assign(Object.assign({},s),{[n]:this.defaultStore[n]}),{}))}updateMessageList(e){const t=[];e.forEach(s=>{let n=s;s instanceof Me||(n=this.getModel(s.ID),n?n.updateProperties(s):n=new Me(s)),t.push(n)}),this.store.messageList=t}updateTranslateTextInfo(e){this.updateBykey("translateTextInfo",e)}updateVoiceToTextInfo(e){this.updateBykey("voiceToTextInfo",e)}updateBykey(e,t){const{conversationID:s,messageID:n,visible:i=!1}=t;this.store[e]||(this.store[e]=new Map),this.store[e].has(s)||this.store[e].set(s,[]);const a=this.store[e].get(s)||[];let u=!0;for(let o=0;o<a.length;o++)if(a[o].messageID===n){a[o].visible=i,u=!1;break}u&&a.push({messageID:n,visible:i}),this.store[e].set(s,a)}}class Pe{constructor(e){this.groupAttributes={},this.groupCounters={},this.initProxy(e)}initProxy(e){Object.keys(e).forEach(t=>{Ue(t)||(this[t]=e[t])})}}class Us{constructor(){this.defaultStore={currentGroupID:"",currentGroup:{},currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[],isCompleted:!1,offset:0},this.store={currentGroupID:"",currentGroup:void 0,currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[],isCompleted:!1,offset:0}}update(e,t){switch(e){case"groupList":this.updateGroupList(t);break;case"currentGroup":this.store.currentGroup=t instanceof Pe?t:new Pe(t);break;default:this.store[e]=t}}getData(e){if(e==="groupSystemNoticeList"){const t=[...this.store.groupSystemNoticeList];return this.store.groupSystemNoticeList.length=0,t}return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((t,s)=>Object.assign(Object.assign({},t),{[s]:this.defaultStore[s]}),{}))}updateGroupList(e){this.store.groupList=e.map(t=>t instanceof Pe?t:new Pe(t))}}class rt{constructor(){this.store={}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){e.length===0&&(this.store={}),this.store=Object.assign(Object.assign({},this.store),e.reduce((t,s)=>Object.assign(Object.assign({},t),{[s]:void 0}),{}))}}class Ms{constructor(){this.defaultStore={friendList:[],friendApplicationList:[],friendApplicationUnreadCount:0,friendGroupList:[]},this.store={friendList:[],friendApplicationList:[],friendApplicationUnreadCount:0,friendGroupList:[]}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((t,s)=>Object.assign(Object.assign({},t),{[s]:this.defaultStore[s]}),{}))}}class Cs{constructor(){this.defaultStore={searchMessagesResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchChatMessagesResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchUserResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchGroupResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchMessageParams:{},searchChatMessageParams:{},searchUserParams:{},searchGroupParams:{},error:null},this.store=this.defaultStore}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e==null?void 0:e.reduce((t,s)=>Object.assign(Object.assign({},t),{[s]:this.defaultStore[s]}),{}))}}class ue{constructor(){this.storeMap={[c.APP]:new Ss,[c.USER]:new Is,[c.CONV]:new ys,[c.CHAT]:new bs,[c.GRP]:new Us,[c.FRIEND]:new Ms,[c.SEARCH]:new Cs},this.task={}}static getInstance(){return ue.instance||(ue.instance=new ue),ue.instance}watch(e,t){this.task[e]||(this.task[e]={});const s=this.task[e];Object.keys(t).forEach(n=>{const i=t[n];s[n]||(s[n]=new Map),s[n].set(i,1),this.notifyOnWatch(e,n,i)})}unwatch(e,t){if(!this.task[e])return;const s=this.task[e];Object.keys(t).forEach(n=>{var i;(i=s[n])===null||i===void 0||i.delete(t[n])})}update(e,t,s){var n;e!==c.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new rt),(n=this.storeMap[e])===null||n===void 0||n.update(t,s),this.notify(e,t)}getData(e,t){var s;return e!==c.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new rt),(s=this.storeMap[e])===null||s===void 0?void 0:s.getData(t)}getConversationModel(e){var t;return(t=this.storeMap[c.CONV])===null||t===void 0?void 0:t.getModel(e)}getMessageModel(e){var t;return(t=this.storeMap[c.CHAT])===null||t===void 0?void 0:t.getModel(e)}reset(e,t=[],s=!1){if(e in this.storeMap){const n=this.storeMap[e];t.length===0&&(t=Object.keys(n==null?void 0:n.store)),n.reset(t),s&&t.forEach(i=>{this.notify(e,i)})}}notifyOnWatch(e,t,s){const n=this.getData(e,t);cs.indexOf(t)>-1&&n.length===0||s&&s.call(this,n)}notify(e,t){if(!this.task[e])return;const s=this.task[e];if(s[t]){const n=s[t],i=this.getData(e,t);for(const[a]of n.entries())a.call(this,i)}}}function R(r){return R=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},R(r)}function V(r,e){if(!(r instanceof e))throw new TypeError("Cannot call a class as a function")}function xt(r){var e=(function(t,s){if(R(t)!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var i=n.call(t,s);if(R(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)})(r,"string");return R(e)=="symbol"?e:e+""}function at(r,e){for(var t=0;t<e.length;t++){var s=e[t];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(r,xt(s.key),s)}}function $(r,e,t){return e&&at(r.prototype,e),t&&at(r,t),Object.defineProperty(r,"prototype",{writable:!1}),r}function J(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Be(r,e){return Be=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,s){return t.__proto__=s,t},Be(r,e)}function xe(r,e){if(typeof e!="function"&&e!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(e&&e.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),e&&Be(r,e)}function Ce(r,e){if(e&&(R(e)=="object"||typeof e=="function"))return e;if(e!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return J(r)}function w(r){return w=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},w(r)}function X(r,e,t){return(e=xt(e))in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function ot(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,s=Array(e);t<e;t++)s[t]=r[t];return s}function Os(r){return(function(e){if(Array.isArray(e))return e})(r)||(function(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)})(r)||(function(e,t){if(e){if(typeof e=="string")return ot(e,t);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?ot(e,t):void 0}})(r)||(function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)})()}function ut(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,s)}return t}function gt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ut(Object(t),!0).forEach(function(s){X(r,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ut(Object(t)).forEach(function(s){Object.defineProperty(r,s,Object.getOwnPropertyDescriptor(t,s))})}return r}var Ds={type:"logger",log:function(r){this.output("log",r)},warn:function(r){this.output("warn",r)},error:function(r){this.output("error",r)},output:function(r,e){console&&console[r]&&console[r].apply(console,e)}},x=new((function(){function r(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};V(this,r),this.init(e,t)}return $(r,[{key:"init",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||Ds,this.options=t,this.debug=t.debug}},{key:"setDebug",value:function(e){this.debug=e}},{key:"log",value:function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,s,n){return n&&!this.debug?null:(typeof e[0]=="string"&&(e[0]="".concat(s).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(e){return new r(this.logger,gt(gt({},{prefix:"".concat(this.prefix,":").concat(e,":")}),this.options))}},{key:"clone",value:function(e){return(e=e||this.options).prefix=e.prefix||this.prefix,new r(this.logger,e)}}]),r})()),W=(function(){function r(){V(this,r),this.observers={}}return $(r,[{key:"on",value:function(e,t){var s=this;return e.split(" ").forEach(function(n){s.observers[n]=s.observers[n]||[],s.observers[n].push(t)}),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter(function(s){return s!==t}):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,s=new Array(t>1?t-1:0),n=1;n<t;n++)s[n-1]=arguments[n];this.observers[e]&&[].concat(this.observers[e]).forEach(function(i){i.apply(void 0,s)}),this.observers["*"]&&[].concat(this.observers["*"]).forEach(function(i){i.apply(i,[e].concat(s))})}}]),r})();function Ie(){var r,e,t=new Promise(function(s,n){r=s,e=n});return t.resolve=r,t.reject=e,t}function ct(r){return r==null?"":""+r}function ze(r,e,t){function s(u){return u&&u.indexOf("###")>-1?u.replace(/###/g,"."):u}function n(){return!r||typeof r=="string"}for(var i=typeof e!="string"?[].concat(e):e.split(".");i.length>1;){if(n())return{};var a=s(i.shift());!r[a]&&t&&(r[a]=new t),r=Object.prototype.hasOwnProperty.call(r,a)?r[a]:{}}return n()?{}:{obj:r,k:s(i.shift())}}function lt(r,e,t){var s=ze(r,e,Object);s.obj[s.k]=t}function ke(r,e){var t=ze(r,e),s=t.obj,n=t.k;if(s)return s[n]}function wt(r,e,t){for(var s in e)s!=="__proto__"&&s!=="constructor"&&(s in r?typeof r[s]=="string"||r[s]instanceof String||typeof e[s]=="string"||e[s]instanceof String?t&&(r[s]=e[s]):wt(r[s],e[s],t):r[s]=e[s]);return r}function re(r){return r.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var Ps={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};function _s(r){return typeof r=="string"?r.replace(/[&<>"'\/]/g,function(e){return Ps[e]}):r}var we=typeof window<"u"&&window.navigator&&window.navigator.userAgentData===void 0&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,Rs=[" ",",","?","!",";"];function Ne(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(r){if(r[e])return r[e];for(var s=e.split(t),n=r,i=0;i<s.length;++i){if(!n||typeof n[s[i]]=="string"&&i+1<s.length)return;if(n[s[i]]===void 0){for(var a=2,u=s.slice(i,i+a).join(t),o=n[u];o===void 0&&s.length>i+a;)a++,o=n[u=s.slice(i,i+a).join(t)];if(o===void 0)return;if(o===null)return null;if(e.endsWith(u)){if(typeof o=="string")return o;if(u&&typeof o[u]=="string")return o[u]}var g=s.slice(i+a).join(t);return g?Ne(o,g,t):void 0}n=n[s[i]]}return n}}function ht(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,s)}return t}function _e(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ht(Object(t),!0).forEach(function(s){X(r,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):ht(Object(t)).forEach(function(s){Object.defineProperty(r,s,Object.getOwnPropertyDescriptor(t,s))})}return r}function Ls(r){var e=(function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}})();return function(){var t,s=w(r);if(e){var n=w(this).constructor;t=Reflect.construct(s,arguments,n)}else t=s.apply(this,arguments);return Ce(this,t)}}var As=(function(){xe(e,W);var r=Ls(e);function e(t){var s,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};return V(this,e),s=r.call(this),we&&W.call(J(s)),s.data=t||{},s.options=n,s.options.keySeparator===void 0&&(s.options.keySeparator="."),s.options.ignoreJSONStructure===void 0&&(s.options.ignoreJSONStructure=!0),s}return $(e,[{key:"addNamespaces",value:function(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}},{key:"removeNamespaces",value:function(t){var s=this.options.ns.indexOf(t);s>-1&&this.options.ns.splice(s,1)}},{key:"getResource",value:function(t,s,n){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},a=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,u=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure,o=[t,s];n&&typeof n!="string"&&(o=o.concat(n)),n&&typeof n=="string"&&(o=o.concat(a?n.split(a):n)),t.indexOf(".")>-1&&(o=t.split("."));var g=ke(this.data,o);return g||!u||typeof n!="string"?g:Ne(this.data&&this.data[t]&&this.data[t][s],n,a)}},{key:"addResource",value:function(t,s,n,i){var a=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1},u=a.keySeparator!==void 0?a.keySeparator:this.options.keySeparator,o=[t,s];n&&(o=o.concat(u?n.split(u):n)),t.indexOf(".")>-1&&(i=s,s=(o=t.split("."))[1]),this.addNamespaces(s),lt(this.data,o,i),a.silent||this.emit("added",t,s,n,i)}},{key:"addResources",value:function(t,s,n){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(var a in n)typeof n[a]!="string"&&Object.prototype.toString.apply(n[a])!=="[object Array]"||this.addResource(t,s,a,n[a],{silent:!0});i.silent||this.emit("added",t,s,n)}},{key:"addResourceBundle",value:function(t,s,n,i,a){var u=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1},o=[t,s];t.indexOf(".")>-1&&(i=n,n=s,s=(o=t.split("."))[1]),this.addNamespaces(s);var g=ke(this.data,o)||{};i?wt(g,n,a):g=_e(_e({},g),n),lt(this.data,o,g),u.silent||this.emit("added",t,s,n)}},{key:"removeResourceBundle",value:function(t,s){this.hasResourceBundle(t,s)&&delete this.data[t][s],this.removeNamespaces(s),this.emit("removed",t,s)}},{key:"hasResourceBundle",value:function(t,s){return this.getResource(t,s)!==void 0}},{key:"getResourceBundle",value:function(t,s){return s||(s=this.options.defaultNS),this.options.compatibilityAPI==="v1"?_e(_e({},{}),this.getResource(t,s)):this.getResource(t,s)}},{key:"getDataByLanguage",value:function(t){return this.data[t]}},{key:"hasLanguageSomeTranslations",value:function(t){var s=this.getDataByLanguage(t);return!!(s&&Object.keys(s)||[]).find(function(n){return s[n]&&Object.keys(s[n]).length>0})}},{key:"toJSON",value:function(){return this.data}}]),e})(),Ft={processors:{},addPostProcessor:function(r){this.processors[r.name]=r},handle:function(r,e,t,s,n){var i=this;return r.forEach(function(a){i.processors[a]&&(e=i.processors[a].process(e,t,s,n))}),e}};function pt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,s)}return t}function O(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?pt(Object(t),!0).forEach(function(s){X(r,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):pt(Object(t)).forEach(function(s){Object.defineProperty(r,s,Object.getOwnPropertyDescriptor(t,s))})}return r}function js(r){var e=(function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}})();return function(){var t,s=w(r);if(e){var n=w(this).constructor;t=Reflect.construct(s,arguments,n)}else t=s.apply(this,arguments);return Ce(this,t)}}var dt={},ft=(function(){xe(e,W);var r=js(e);function e(t){var s,n,i,a,u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return V(this,e),s=r.call(this),we&&W.call(J(s)),n=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],i=t,a=J(s),n.forEach(function(o){i[o]&&(a[o]=i[o])}),s.options=u,s.options.keySeparator===void 0&&(s.options.keySeparator="."),s.logger=x.create("translator"),s}return $(e,[{key:"changeLanguage",value:function(t){t&&(this.language=t)}},{key:"exists",value:function(t){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};if(t==null)return!1;var n=this.resolve(t,s);return n&&n.res!==void 0}},{key:"extractFromKey",value:function(t,s){var n=s.nsSeparator!==void 0?s.nsSeparator:this.options.nsSeparator;n===void 0&&(n=":");var i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=s.ns||this.options.defaultNS||[],u=n&&t.indexOf(n)>-1,o=!(this.options.userDefinedKeySeparator||s.keySeparator||this.options.userDefinedNsSeparator||s.nsSeparator||(function(p,h,f){h=h||"",f=f||"";var m=Rs.filter(function(S){return h.indexOf(S)<0&&f.indexOf(S)<0});if(m.length===0)return!0;var E=new RegExp("(".concat(m.map(function(S){return S==="?"?"\\?":S}).join("|"),")")),d=!E.test(p);if(!d){var T=p.indexOf(f);T>0&&!E.test(p.substring(0,T))&&(d=!0)}return d})(t,n,i));if(u&&!o){var g=t.match(this.interpolator.nestingRegexp);if(g&&g.length>0)return{key:t,namespaces:a};var l=t.split(n);(n!==i||n===i&&this.options.ns.indexOf(l[0])>-1)&&(a=l.shift()),t=l.join(i)}return typeof a=="string"&&(a=[a]),{key:t,namespaces:a}}},{key:"translate",value:function(t,s,n){var i=this;if(R(s)!=="object"&&this.options.overloadTranslationOptionHandler&&(s=this.options.overloadTranslationOptionHandler(arguments)),R(s)==="object"&&(s=O({},s)),s||(s={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);var a=s.returnDetails!==void 0?s.returnDetails:this.options.returnDetails,u=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,o=this.extractFromKey(t[t.length-1],s),g=o.key,l=o.namespaces,p=l[l.length-1],h=s.lng||this.language,f=s.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(h&&h.toLowerCase()==="cimode"){if(f){var m=s.nsSeparator||this.options.nsSeparator;return a?{res:"".concat(p).concat(m).concat(g),usedKey:g,exactUsedKey:g,usedLng:h,usedNS:p}:"".concat(p).concat(m).concat(g)}return a?{res:g,usedKey:g,exactUsedKey:g,usedLng:h,usedNS:p}:g}var E=this.resolve(t,s),d=E&&E.res,T=E&&E.usedKey||g,S=E&&E.exactUsedKey||g,v=Object.prototype.toString.apply(d),b=s.joinArrays!==void 0?s.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject;if(y&&d&&typeof d!="string"&&typeof d!="boolean"&&typeof d!="number"&&["[object Number]","[object Function]","[object RegExp]"].indexOf(v)<0&&(typeof b!="string"||v!=="[object Array]")){if(!s.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var I=this.options.returnedObjectHandler?this.options.returnedObjectHandler(T,d,O(O({},s),{},{ns:l})):"key '".concat(g," (").concat(this.language,")' returned an object instead of string.");return a?(E.res=I,E):I}if(u){var k=v==="[object Array]",B=k?[]:{},Bt=k?S:T;for(var se in d)if(Object.prototype.hasOwnProperty.call(d,se)){var Je="".concat(Bt).concat(u).concat(se);B[se]=this.translate(Je,O(O({},s),{joinArrays:!1,ns:l})),B[se]===Je&&(B[se]=d[se])}d=B}}else if(y&&typeof b=="string"&&v==="[object Array]")(d=d.join(b))&&(d=this.extendTranslation(d,t,s,n));else{var Oe=!1,Ee=!1,We=s.count!==void 0&&typeof s.count!="string",Fe=e.hasDefaultValue(s),Kt=We?this.pluralResolver.getSuffix(h,s.count,s):"",ve=s["defaultValue".concat(Kt)]||s.defaultValue;!this.isValidLookup(d)&&Fe&&(Oe=!0,d=ve),this.isValidLookup(d)||(Ee=!0,d=g);var qt=(s.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&Ee?void 0:d,Te=Fe&&ve!==d&&this.options.updateMissing;if(Ee||Oe||Te){if(this.logger.log(Te?"updateKey":"missingKey",h,p,g,Te?ve:d),u){var Xe=this.resolve(g,O(O({},s),{},{keySeparator:!1}));Xe&&Xe.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}var Se=[],De=this.languageUtils.getFallbackCodes(this.options.fallbackLng,s.lng||this.language);if(this.options.saveMissingTo==="fallback"&&De&&De[0])for(var Ve=0;Ve<De.length;Ve++)Se.push(De[Ve]);else this.options.saveMissingTo==="all"?Se=this.languageUtils.toResolveHierarchy(s.lng||this.language):Se.push(s.lng||this.language);var Qe=function(ne,ie,Ze){var et=Fe&&Ze!==d?Ze:qt;i.options.missingKeyHandler?i.options.missingKeyHandler(ne,p,ie,et,Te,s):i.backendConnector&&i.backendConnector.saveMissing&&i.backendConnector.saveMissing(ne,p,ie,et,Te,s),i.emit("missingKey",ne,p,ie,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&We?Se.forEach(function(ne){i.pluralResolver.getSuffixes(ne,s).forEach(function(ie){Qe([ne],g+ie,s["defaultValue".concat(ie)]||ve)})}):Qe(Se,g,ve))}d=this.extendTranslation(d,t,s,E,n),Ee&&d===g&&this.options.appendNamespaceToMissingKey&&(d="".concat(p,":").concat(g)),(Ee||Oe)&&this.options.parseMissingKeyHandler&&(d=this.options.compatibilityAPI!=="v1"?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(p,":").concat(g):g,Oe?d:void 0):this.options.parseMissingKeyHandler(d))}return a?(E.res=d,E):d}},{key:"extendTranslation",value:function(t,s,n,i,a){var u=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,O(O({},this.options.interpolation.defaultVariables),n),i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(O(O({},n),{interpolation:O(O({},this.options.interpolation),n.interpolation)}));var o,g=typeof t=="string"&&(n&&n.interpolation&&n.interpolation.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(g){var l=t.match(this.interpolator.nestingRegexp);o=l&&l.length}var p=n.replace&&typeof n.replace!="string"?n.replace:n;if(this.options.interpolation.defaultVariables&&(p=O(O({},this.options.interpolation.defaultVariables),p)),t=this.interpolator.interpolate(t,p,n.lng||this.language,n),g){var h=t.match(this.interpolator.nestingRegexp);o<(h&&h.length)&&(n.nest=!1)}!n.lng&&this.options.compatibilityAPI!=="v1"&&i&&i.res&&(n.lng=i.usedLng),n.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var E=arguments.length,d=new Array(E),T=0;T<E;T++)d[T]=arguments[T];return a&&a[0]===d[0]&&!n.context?(u.logger.warn("It seems you are nesting recursively key: ".concat(d[0]," in key: ").concat(s[0])),null):u.translate.apply(u,d.concat([s]))},n)),n.interpolation&&this.interpolator.reset()}var f=n.postProcess||this.options.postProcess,m=typeof f=="string"?[f]:f;return t!=null&&m&&m.length&&n.applyPostProcessor!==!1&&(t=Ft.handle(m,t,s,this.options&&this.options.postProcessPassResolved?O({i18nResolved:i},n):n,this)),t}},{key:"resolve",value:function(t){var s,n,i,a,u,o=this,g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return typeof t=="string"&&(t=[t]),t.forEach(function(l){if(!o.isValidLookup(s)){var p=o.extractFromKey(l,g),h=p.key;n=h;var f=p.namespaces;o.options.fallbackNS&&(f=f.concat(o.options.fallbackNS));var m=g.count!==void 0&&typeof g.count!="string",E=m&&!g.ordinal&&g.count===0&&o.pluralResolver.shouldUseIntlApi(),d=g.context!==void 0&&(typeof g.context=="string"||typeof g.context=="number")&&g.context!=="",T=g.lngs?g.lngs:o.languageUtils.toResolveHierarchy(g.lng||o.language,g.fallbackLng);f.forEach(function(S){o.isValidLookup(s)||(u=S,!dt["".concat(T[0],"-").concat(S)]&&o.utils&&o.utils.hasLoadedNamespace&&!o.utils.hasLoadedNamespace(u)&&(dt["".concat(T[0],"-").concat(S)]=!0,o.logger.warn('key "'.concat(n,'" for languages "').concat(T.join(", "),`" won't get resolved as namespace "`).concat(u,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),T.forEach(function(v){if(!o.isValidLookup(s)){a=v;var b,y=[h];if(o.i18nFormat&&o.i18nFormat.addLookupKeys)o.i18nFormat.addLookupKeys(y,h,v,S,g);else{var I;m&&(I=o.pluralResolver.getSuffix(v,g.count,g));var k="".concat(o.options.pluralSeparator,"zero");if(m&&(y.push(h+I),E&&y.push(h+k)),d){var B="".concat(h).concat(o.options.contextSeparator).concat(g.context);y.push(B),m&&(y.push(B+I),E&&y.push(B+k))}}for(;b=y.pop();)o.isValidLookup(s)||(i=b,s=o.getResource(v,S,b,g))}}))})}}),{res:s,usedKey:n,exactUsedKey:i,usedLng:a,usedNS:u}}},{key:"isValidLookup",value:function(t){return!(t===void 0||!this.options.returnNull&&t===null||!this.options.returnEmptyString&&t==="")}},{key:"getResource",value:function(t,s,n){var i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,s,n,i):this.resourceStore.getResource(t,s,n,i)}}],[{key:"hasDefaultValue",value:function(t){var s="defaultValue";for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n)&&s===n.substring(0,12)&&t[n]!==void 0)return!0;return!1}}]),e})();function Ye(r){return r.charAt(0).toUpperCase()+r.slice(1)}var mt=(function(){function r(e){V(this,r),this.options=e,this.supportedLngs=this.options.supportedLngs||!1,this.logger=x.create("languageUtils")}return $(r,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return t.length===2?null:(t.pop(),t[t.length-1].toLowerCase()==="x"?null:this.formatLanguageCode(t.join("-")))}},{key:"getLanguagePartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return e;var t=e.split("-");return this.formatLanguageCode(t[0])}},{key:"formatLanguageCode",value:function(e){if(typeof e=="string"&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],s=e.split("-");return this.options.lowerCaseLng?s=s.map(function(n){return n.toLowerCase()}):s.length===2?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),t.indexOf(s[1].toLowerCase())>-1&&(s[1]=Ye(s[1].toLowerCase()))):s.length===3&&(s[0]=s[0].toLowerCase(),s[1].length===2&&(s[1]=s[1].toUpperCase()),s[0]!=="sgn"&&s[2].length===2&&(s[2]=s[2].toUpperCase()),t.indexOf(s[1].toLowerCase())>-1&&(s[1]=Ye(s[1].toLowerCase())),t.indexOf(s[2].toLowerCase())>-1&&(s[2]=Ye(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,s=this;return e?(e.forEach(function(n){if(!t){var i=s.formatLanguageCode(n);s.options.supportedLngs&&!s.isSupportedCode(i)||(t=i)}}),!t&&this.options.supportedLngs&&e.forEach(function(n){if(!t){var i=s.getLanguagePartFromCode(n);if(s.isSupportedCode(i))return t=i;t=s.options.supportedLngs.find(function(a){return a===i?a:a.indexOf("-")<0&&i.indexOf("-")<0?void 0:a.indexOf(i)===0?a:void 0})}}),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if(typeof e=="function"&&(e=e(t)),typeof e=="string"&&(e=[e]),Object.prototype.toString.apply(e)==="[object Array]")return e;if(!t)return e.default||[];var s=e[t];return s||(s=e[this.getScriptPartFromCode(t)]),s||(s=e[this.formatLanguageCode(t)]),s||(s=e[this.getLanguagePartFromCode(t)]),s||(s=e.default),s||[]}},{key:"toResolveHierarchy",value:function(e,t){var s=this,n=this.getFallbackCodes(t||this.options.fallbackLng||[],e),i=[],a=function(u){u&&(s.isSupportedCode(u)?i.push(u):s.logger.warn("rejecting language code not found in supportedLngs: ".concat(u)))};return typeof e=="string"&&e.indexOf("-")>-1?(this.options.load!=="languageOnly"&&a(this.formatLanguageCode(e)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&a(this.getScriptPartFromCode(e)),this.options.load!=="currentOnly"&&a(this.getLanguagePartFromCode(e))):typeof e=="string"&&a(this.formatLanguageCode(e)),n.forEach(function(u){i.indexOf(u)<0&&a(s.formatLanguageCode(u))}),i}}]),r})(),ks=[{lngs:["ach","ak","am","arn","br","fil","gun","ln","mfe","mg","mi","oc","pt","pt-BR","tg","tl","ti","tr","uz","wa"],nr:[1,2],fc:1},{lngs:["af","an","ast","az","bg","bn","ca","da","de","dev","el","en","eo","es","et","eu","fi","fo","fur","fy","gl","gu","ha","hi","hu","hy","ia","it","kk","kn","ku","lb","mai","ml","mn","mr","nah","nap","nb","ne","nl","nn","no","nso","pa","pap","pms","ps","pt-PT","rm","sco","se","si","so","son","sq","sv","sw","ta","te","tk","ur","yo"],nr:[1,2],fc:2},{lngs:["ay","bo","cgg","fa","ht","id","ja","jbo","ka","km","ko","ky","lo","ms","sah","su","th","tt","ug","vi","wo","zh"],nr:[1],fc:3},{lngs:["be","bs","cnr","dz","hr","ru","sr","uk"],nr:[1,2,5],fc:4},{lngs:["ar"],nr:[0,1,2,3,11,100],fc:5},{lngs:["cs","sk"],nr:[1,2,5],fc:6},{lngs:["csb","pl"],nr:[1,2,5],fc:7},{lngs:["cy"],nr:[1,2,3,8],fc:8},{lngs:["fr"],nr:[1,2],fc:9},{lngs:["ga"],nr:[1,2,3,7,11],fc:10},{lngs:["gd"],nr:[1,2,3,20],fc:11},{lngs:["is"],nr:[1,2],fc:12},{lngs:["jv"],nr:[0,1],fc:13},{lngs:["kw"],nr:[1,2,3,4],fc:14},{lngs:["lt"],nr:[1,2,10],fc:15},{lngs:["lv"],nr:[1,2,0],fc:16},{lngs:["mk"],nr:[1,2],fc:17},{lngs:["mnk"],nr:[0,1,2],fc:18},{lngs:["mt"],nr:[1,2,11,20],fc:19},{lngs:["or"],nr:[2,1],fc:2},{lngs:["ro"],nr:[1,2,20],fc:20},{lngs:["sl"],nr:[5,1,2,3],fc:21},{lngs:["he","iw"],nr:[1,2,20,21],fc:22}],Ns={1:function(r){return+(r>1)},2:function(r){return+(r!=1)},3:function(r){return 0},4:function(r){return r%10==1&&r%100!=11?0:r%10>=2&&r%10<=4&&(r%100<10||r%100>=20)?1:2},5:function(r){return r==0?0:r==1?1:r==2?2:r%100>=3&&r%100<=10?3:r%100>=11?4:5},6:function(r){return r==1?0:r>=2&&r<=4?1:2},7:function(r){return r==1?0:r%10>=2&&r%10<=4&&(r%100<10||r%100>=20)?1:2},8:function(r){return r==1?0:r==2?1:r!=8&&r!=11?2:3},9:function(r){return+(r>=2)},10:function(r){return r==1?0:r==2?1:r<7?2:r<11?3:4},11:function(r){return r==1||r==11?0:r==2||r==12?1:r>2&&r<20?2:3},12:function(r){return+(r%10!=1||r%100==11)},13:function(r){return+(r!==0)},14:function(r){return r==1?0:r==2?1:r==3?2:3},15:function(r){return r%10==1&&r%100!=11?0:r%10>=2&&(r%100<10||r%100>=20)?1:2},16:function(r){return r%10==1&&r%100!=11?0:r!==0?1:2},17:function(r){return r==1||r%10==1&&r%100!=11?0:1},18:function(r){return r==0?0:r==1?1:2},19:function(r){return r==1?0:r==0||r%100>1&&r%100<11?1:r%100>10&&r%100<20?2:3},20:function(r){return r==1?0:r==0||r%100>0&&r%100<20?1:2},21:function(r){return r%100==1?1:r%100==2?2:r%100==3||r%100==4?3:0},22:function(r){return r==1?0:r==2?1:(r<0||r>10)&&r%10==0?2:3}},Gs=["v1","v2","v3"],Et={zero:0,one:1,two:2,few:3,many:4,other:5},xs=(function(){function r(e){var t,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};V(this,r),this.languageUtils=e,this.options=s,this.logger=x.create("pluralResolver"),this.options.compatibilityJSON&&this.options.compatibilityJSON!=="v4"||typeof Intl<"u"&&Intl.PluralRules||(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=(t={},ks.forEach(function(n){n.lngs.forEach(function(i){t[i]={numbers:n.nr,plurals:Ns[n.fc]}})}),t)}return $(r,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch{return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=this.getRule(e,t);return this.shouldUseIntlApi()?s&&s.resolvedOptions().pluralCategories.length>1:s&&s.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(e,s).map(function(n){return"".concat(t).concat(n)})}},{key:"getSuffixes",value:function(e){var t=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=this.getRule(e,s);return n?this.shouldUseIntlApi()?n.resolvedOptions().pluralCategories.sort(function(i,a){return Et[i]-Et[a]}).map(function(i){return"".concat(t.options.prepend).concat(i)}):n.numbers.map(function(i){return t.getSuffix(e,i,s)}):[]}},{key:"getSuffix",value:function(e,t){var s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=this.getRule(e,s);return n?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(n.select(t)):this.getSuffixRetroCompatible(n,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var s=this,n=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),i=e.numbers[n];this.options.simplifyPluralSuffix&&e.numbers.length===2&&e.numbers[0]===1&&(i===2?i="plural":i===1&&(i=""));var a=function(){return s.options.prepend&&i.toString()?s.options.prepend+i.toString():i.toString()};return this.options.compatibilityJSON==="v1"?i===1?"":typeof i=="number"?"_plural_".concat(i.toString()):a():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&e.numbers.length===2&&e.numbers[0]===1?a():this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString()}},{key:"shouldUseIntlApi",value:function(){return!Gs.includes(this.options.compatibilityJSON)}}]),r})();function vt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,s)}return t}function L(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?vt(Object(t),!0).forEach(function(s){X(r,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):vt(Object(t)).forEach(function(s){Object.defineProperty(r,s,Object.getOwnPropertyDescriptor(t,s))})}return r}function Tt(r,e,t){var s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",n=!(arguments.length>4&&arguments[4]!==void 0)||arguments[4],i=(function(a,u,o){var g=ke(a,o);return g!==void 0?g:ke(u,o)})(r,e,t);return!i&&n&&typeof t=="string"&&(i=Ne(r,t,s))===void 0&&(i=Ne(e,t,s)),i}var ws=(function(){function r(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};V(this,r),this.logger=x.create("interpolator"),this.options=e,this.format=e.interpolation&&e.interpolation.format||function(t){return t},this.init(e)}return $(r,[{key:"init",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=t.escape!==void 0?t.escape:_s,this.escapeValue=t.escapeValue===void 0||t.escapeValue,this.useRawValueToEscape=t.useRawValueToEscape!==void 0&&t.useRawValueToEscape,this.prefix=t.prefix?re(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?re(t.suffix):t.suffixEscaped||"}}",this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||",",this.unescapePrefix=t.unescapeSuffix?"":t.unescapePrefix||"-",this.unescapeSuffix=this.unescapePrefix?"":t.unescapeSuffix||"",this.nestingPrefix=t.nestingPrefix?re(t.nestingPrefix):t.nestingPrefixEscaped||re("$t("),this.nestingSuffix=t.nestingSuffix?re(t.nestingSuffix):t.nestingSuffixEscaped||re(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=t.alwaysFormat!==void 0&&t.alwaysFormat,this.resetRegExp()}},{key:"reset",value:function(){this.options&&this.init(this.options)}},{key:"resetRegExp",value:function(){var e="".concat(this.prefix,"(.+?)").concat(this.suffix);this.regexp=new RegExp(e,"g");var t="".concat(this.prefix).concat(this.unescapePrefix,"(.+?)").concat(this.unescapeSuffix).concat(this.suffix);this.regexpUnescape=new RegExp(t,"g");var s="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(s,"g")}},{key:"interpolate",value:function(e,t,s,n){var i,a,u,o=this,g=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function l(m){return m.replace(/\$/g,"$$$$")}var p=function(m){if(m.indexOf(o.formatSeparator)<0){var E=Tt(t,g,m,o.options.keySeparator,o.options.ignoreJSONStructure);return o.alwaysFormat?o.format(E,void 0,s,L(L(L({},n),t),{},{interpolationkey:m})):E}var d=m.split(o.formatSeparator),T=d.shift().trim(),S=d.join(o.formatSeparator).trim();return o.format(Tt(t,g,T,o.options.keySeparator,o.options.ignoreJSONStructure),S,s,L(L(L({},n),t),{},{interpolationkey:T}))};this.resetRegExp();var h=n&&n.missingInterpolationHandler||this.options.missingInterpolationHandler,f=n&&n.interpolation&&n.interpolation.skipOnVariables!==void 0?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(m){return l(m)}},{regex:this.regexp,safeValue:function(m){return o.escapeValue?l(o.escape(m)):l(m)}}].forEach(function(m){for(u=0;i=m.regex.exec(e);){var E=i[1].trim();if((a=p(E))===void 0)if(typeof h=="function"){var d=h(e,i,n);a=typeof d=="string"?d:""}else if(n&&Object.prototype.hasOwnProperty.call(n,E))a="";else{if(f){a=i[0];continue}o.logger.warn("missed to pass in variable ".concat(E," for interpolating ").concat(e)),a=""}else typeof a=="string"||o.useRawValueToEscape||(a=ct(a));var T=m.safeValue(a);if(e=e.replace(i[0],T),f?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=i[0].length):m.regex.lastIndex=0,++u>=o.maxReplaces)break}}),e}},{key:"nest",value:function(e,t){var s,n,i,a=this,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};function o(h,f){var m=this.nestingOptionsSeparator;if(h.indexOf(m)<0)return h;var E=h.split(new RegExp("".concat(m,"[ ]*{"))),d="{".concat(E[1]);h=E[0];var T=(d=this.interpolate(d,i)).match(/'/g),S=d.match(/"/g);(T&&T.length%2==0&&!S||S.length%2!=0)&&(d=d.replace(/'/g,'"'));try{i=JSON.parse(d),f&&(i=L(L({},f),i))}catch(v){return this.logger.warn("failed parsing options string in nesting for key ".concat(h),v),"".concat(h).concat(m).concat(d)}return delete i.defaultValue,h}for(;s=this.nestingRegexp.exec(e);){var g=[];(i=(i=L({},u)).replace&&typeof i.replace!="string"?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;var l=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){var p=s[1].split(this.formatSeparator).map(function(h){return h.trim()});s[1]=p.shift(),g=p,l=!0}if((n=t(o.call(this,s[1].trim(),i),i))&&s[0]===e&&typeof n!="string")return n;typeof n!="string"&&(n=ct(n)),n||(this.logger.warn("missed to resolve ".concat(s[1]," for nesting ").concat(e)),n=""),l&&(n=g.reduce(function(h,f){return a.format(h,f,u.lng,L(L({},u),{},{interpolationkey:s[1].trim()}))},n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}}]),r})();function St(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,s)}return t}function H(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?St(Object(t),!0).forEach(function(s){X(r,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):St(Object(t)).forEach(function(s){Object.defineProperty(r,s,Object.getOwnPropertyDescriptor(t,s))})}return r}function ae(r){var e={};return function(t,s,n){var i=s+JSON.stringify(n),a=e[i];return a||(a=r(s,n),e[i]=a),a(t)}}var Fs=(function(){function r(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};V(this,r),this.logger=x.create("formatter"),this.options=e,this.formats={number:ae(function(t,s){var n=new Intl.NumberFormat(t,H({},s));return function(i){return n.format(i)}}),currency:ae(function(t,s){var n=new Intl.NumberFormat(t,H(H({},s),{},{style:"currency"}));return function(i){return n.format(i)}}),datetime:ae(function(t,s){var n=new Intl.DateTimeFormat(t,H({},s));return function(i){return n.format(i)}}),relativetime:ae(function(t,s){var n=new Intl.RelativeTimeFormat(t,H({},s));return function(i){return n.format(i,s.range||"day")}}),list:ae(function(t,s){var n=new Intl.ListFormat(t,H({},s));return function(i){return n.format(i)}})},this.init(e)}return $(r,[{key:"init",value:function(e){var t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}}).interpolation;this.formatSeparator=t.formatSeparator?t.formatSeparator:t.formatSeparator||","}},{key:"add",value:function(e,t){this.formats[e.toLowerCase().trim()]=t}},{key:"addCached",value:function(e,t){this.formats[e.toLowerCase().trim()]=ae(t)}},{key:"format",value:function(e,t,s){var n=this,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return t.split(this.formatSeparator).reduce(function(a,u){var o=(function(m){var E=m.toLowerCase().trim(),d={};if(m.indexOf("(")>-1){var T=m.split("(");E=T[0].toLowerCase().trim();var S=T[1].substring(0,T[1].length-1);E==="currency"&&S.indexOf(":")<0?d.currency||(d.currency=S.trim()):E==="relativetime"&&S.indexOf(":")<0?d.range||(d.range=S.trim()):S.split(";").forEach(function(v){if(v){var b=Os(v.split(":")),y=b[0],I=b.slice(1).join(":").trim().replace(/^'+|'+$/g,"");d[y.trim()]||(d[y.trim()]=I),I==="false"&&(d[y.trim()]=!1),I==="true"&&(d[y.trim()]=!0),isNaN(I)||(d[y.trim()]=parseInt(I,10))}})}return{formatName:E,formatOptions:d}})(u),g=o.formatName,l=o.formatOptions;if(n.formats[g]){var p=a;try{var h=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},f=h.locale||h.lng||i.locale||i.lng||s;p=n.formats[g](a,f,H(H(H({},l),i),h))}catch(m){n.logger.warn(m)}return p}return n.logger.warn("there was no format function for ".concat(g)),a},e)}}]),r})();function It(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,s)}return t}function yt(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?It(Object(t),!0).forEach(function(s){X(r,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):It(Object(t)).forEach(function(s){Object.defineProperty(r,s,Object.getOwnPropertyDescriptor(t,s))})}return r}function Vs(r){var e=(function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}})();return function(){var t,s=w(r);if(e){var n=w(this).constructor;t=Reflect.construct(s,arguments,n)}else t=s.apply(this,arguments);return Ce(this,t)}}var $s=(function(){xe(e,W);var r=Vs(e);function e(t,s,n){var i,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return V(this,e),i=r.call(this),we&&W.call(J(i)),i.backend=t,i.store=s,i.services=n,i.languageUtils=n.languageUtils,i.options=a,i.logger=x.create("backendConnector"),i.waitingReads=[],i.maxParallelReads=a.maxParallelReads||10,i.readingCalls=0,i.maxRetries=a.maxRetries>=0?a.maxRetries:5,i.retryTimeout=a.retryTimeout>=1?a.retryTimeout:350,i.state={},i.queue=[],i.backend&&i.backend.init&&i.backend.init(n,a.backend,a),i}return $(e,[{key:"queueLoad",value:function(t,s,n,i){var a=this,u={},o={},g={},l={};return t.forEach(function(p){var h=!0;s.forEach(function(f){var m="".concat(p,"|").concat(f);!n.reload&&a.store.hasResourceBundle(p,f)?a.state[m]=2:a.state[m]<0||(a.state[m]===1?o[m]===void 0&&(o[m]=!0):(a.state[m]=1,h=!1,o[m]===void 0&&(o[m]=!0),u[m]===void 0&&(u[m]=!0),l[f]===void 0&&(l[f]=!0)))}),h||(g[p]=!0)}),(Object.keys(u).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(u),pending:Object.keys(o),toLoadLanguages:Object.keys(g),toLoadNamespaces:Object.keys(l)}}},{key:"loaded",value:function(t,s,n){var i=t.split("|"),a=i[0],u=i[1];s&&this.emit("failedLoading",a,u,s),n&&this.store.addResourceBundle(a,u,n),this.state[t]=s?-1:2;var o={};this.queue.forEach(function(g){var l,p,h,f,m;l=g.loaded,p=u,h=ze(l,[a],Object),f=h.obj,m=h.k,f[m]=f[m]||[],f[m].push(p),(function(E,d){E.pending[d]!==void 0&&(delete E.pending[d],E.pendingCount--)})(g,t),s&&g.errors.push(s),g.pendingCount!==0||g.done||(Object.keys(g.loaded).forEach(function(E){o[E]||(o[E]={});var d=g.loaded[E];d.length&&d.forEach(function(T){o[E][T]===void 0&&(o[E][T]=!0)})}),g.done=!0,g.errors.length?g.callback(g.errors):g.callback())}),this.emit("loaded",o),this.queue=this.queue.filter(function(g){return!g.done})}},{key:"read",value:function(t,s,n){var i=this,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,u=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!t.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)this.waitingReads.push({lng:t,ns:s,fcName:n,tried:a,wait:u,callback:o});else{this.readingCalls++;var g=function(h,f){if(i.readingCalls--,i.waitingReads.length>0){var m=i.waitingReads.shift();i.read(m.lng,m.ns,m.fcName,m.tried,m.wait,m.callback)}h&&f&&a<i.maxRetries?setTimeout(function(){i.read.call(i,t,s,n,a+1,2*u,o)},u):o(h,f)},l=this.backend[n].bind(this.backend);if(l.length!==2)return l(t,s,g);try{var p=l(t,s);p&&typeof p.then=="function"?p.then(function(h){return g(null,h)}).catch(g):g(null,p)}catch(h){g(h)}}}},{key:"prepareLoading",value:function(t,s){var n=this,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},a=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),a&&a();typeof t=="string"&&(t=this.languageUtils.toResolveHierarchy(t)),typeof s=="string"&&(s=[s]);var u=this.queueLoad(t,s,i,a);if(!u.toLoad.length)return u.pending.length||a(),null;u.toLoad.forEach(function(o){n.loadOne(o)})}},{key:"load",value:function(t,s,n){this.prepareLoading(t,s,{},n)}},{key:"reload",value:function(t,s,n){this.prepareLoading(t,s,{reload:!0},n)}},{key:"loadOne",value:function(t){var s=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",i=t.split("|"),a=i[0],u=i[1];this.read(a,u,"read",void 0,void 0,function(o,g){o&&s.logger.warn("".concat(n,"loading namespace ").concat(u," for language ").concat(a," failed"),o),!o&&g&&s.logger.log("".concat(n,"loaded namespace ").concat(u," for language ").concat(a),g),s.loaded(t,o,g)})}},{key:"saveMissing",value:function(t,s,n,i,a){var u=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},o=arguments.length>6&&arguments[6]!==void 0?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(s))this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(s,'" was not yet loaded'),"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");else if(n!=null&&n!==""){if(this.backend&&this.backend.create){var g=yt(yt({},u),{},{isUpdate:a}),l=this.backend.create.bind(this.backend);if(l.length<6)try{var p;(p=l.length===5?l(t,s,n,i,g):l(t,s,n,i))&&typeof p.then=="function"?p.then(function(h){return o(null,h)}).catch(o):o(null,p)}catch(h){o(h)}else l(t,s,n,i,o,g)}t&&t[0]&&this.store.addResource(t[0],s,n,i)}}}]),e})();function bt(){return{debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!0,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:function(r){var e={};if(R(r[1])==="object"&&(e=r[1]),typeof r[1]=="string"&&(e.defaultValue=r[1]),typeof r[2]=="string"&&(e.tDescription=r[2]),R(r[2])==="object"||R(r[3])==="object"){var t=r[3]||r[2];Object.keys(t).forEach(function(s){e[s]=t[s]})}return e},interpolation:{escapeValue:!0,format:function(r,e,t,s){return r},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function Ut(r){return typeof r.ns=="string"&&(r.ns=[r.ns]),typeof r.fallbackLng=="string"&&(r.fallbackLng=[r.fallbackLng]),typeof r.fallbackNS=="string"&&(r.fallbackNS=[r.fallbackNS]),r.supportedLngs&&r.supportedLngs.indexOf("cimode")<0&&(r.supportedLngs=r.supportedLngs.concat(["cimode"])),r}function Mt(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(r);e&&(s=s.filter(function(n){return Object.getOwnPropertyDescriptor(r,n).enumerable})),t.push.apply(t,s)}return t}function N(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Mt(Object(t),!0).forEach(function(s){X(r,s,t[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Mt(Object(t)).forEach(function(s){Object.defineProperty(r,s,Object.getOwnPropertyDescriptor(t,s))})}return r}function Hs(r){var e=(function(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}})();return function(){var t,s=w(r);if(e){var n=w(this).constructor;t=Reflect.construct(s,arguments,n)}else t=s.apply(this,arguments);return Ce(this,t)}}function Re(){}var Ge=(function(){xe(e,W);var r=Hs(e);function e(){var t,s,n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},i=arguments.length>1?arguments[1]:void 0;if(V(this,e),t=r.call(this),we&&W.call(J(t)),t.options=Ut(n),t.services={},t.logger=x,t.modules={external:[]},s=J(t),Object.getOwnPropertyNames(Object.getPrototypeOf(s)).forEach(function(a){typeof s[a]=="function"&&(s[a]=s[a].bind(s))}),i&&!t.isInitialized&&!n.isClone){if(!t.options.initImmediate)return t.init(n,i),Ce(t,J(t));setTimeout(function(){t.init(n,i)},0)}return t}return $(e,[{key:"init",value:function(){var t=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;typeof s=="function"&&(n=s,s={}),!s.defaultNS&&s.defaultNS!==!1&&s.ns&&(typeof s.ns=="string"?s.defaultNS=s.ns:s.ns.indexOf("translation")<0&&(s.defaultNS=s.ns[0]));var i=bt();function a(f){return f?typeof f=="function"?new f:f:null}if(this.options=N(N(N({},i),this.options),Ut(s)),this.options.compatibilityAPI!=="v1"&&(this.options.interpolation=N(N({},i.interpolation),this.options.interpolation)),s.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=s.keySeparator),s.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=s.nsSeparator),!this.options.isClone){var u;this.modules.logger?x.init(a(this.modules.logger),this.options):x.init(null,this.options),this.modules.formatter?u=this.modules.formatter:typeof Intl<"u"&&(u=Fs);var o=new mt(this.options);this.store=new As(this.options.resources,this.options);var g=this.services;g.logger=x,g.resourceStore=this.store,g.languageUtils=o,g.pluralResolver=new xs(o,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!u||this.options.interpolation.format&&this.options.interpolation.format!==i.interpolation.format||(g.formatter=a(u),g.formatter.init(g,this.options),this.options.interpolation.format=g.formatter.format.bind(g.formatter)),g.interpolator=new ws(this.options),g.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},g.backendConnector=new $s(a(this.modules.backend),g.resourceStore,g,this.options),g.backendConnector.on("*",function(f){for(var m=arguments.length,E=new Array(m>1?m-1:0),d=1;d<m;d++)E[d-1]=arguments[d];t.emit.apply(t,[f].concat(E))}),this.modules.languageDetector&&(g.languageDetector=a(this.modules.languageDetector),g.languageDetector.init&&g.languageDetector.init(g,this.options.detection,this.options)),this.modules.i18nFormat&&(g.i18nFormat=a(this.modules.i18nFormat),g.i18nFormat.init&&g.i18nFormat.init(this)),this.translator=new ft(this.services,this.options),this.translator.on("*",function(f){for(var m=arguments.length,E=new Array(m>1?m-1:0),d=1;d<m;d++)E[d-1]=arguments[d];t.emit.apply(t,[f].concat(E))}),this.modules.external.forEach(function(f){f.init&&f.init(t)})}if(this.format=this.options.interpolation.format,n||(n=Re),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var l=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);l.length>0&&l[0]!=="dev"&&(this.options.lng=l[0])}this.services.languageDetector||this.options.lng||this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(function(f){t[f]=function(){var m;return(m=t.store)[f].apply(m,arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(function(f){t[f]=function(){var m;return(m=t.store)[f].apply(m,arguments),t}});var p=Ie(),h=function(){var f=function(m,E){t.isInitialized&&!t.initializedStoreOnce&&t.logger.warn("init: i18next is already initialized. You should call init just once!"),t.isInitialized=!0,t.options.isClone||t.logger.log("initialized",t.options),t.emit("initialized",t.options),p.resolve(E),n(m,E)};if(t.languages&&t.options.compatibilityAPI!=="v1"&&!t.isInitialized)return f(null,t.t.bind(t));t.changeLanguage(t.options.lng,f)};return this.options.resources||!this.options.initImmediate?h():setTimeout(h,0),p}},{key:"loadResources",value:function(t){var s=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Re,i=typeof t=="string"?t:this.language;if(typeof t=="function"&&(n=t),!this.options.resources||this.options.partialBundledLanguages){if(i&&i.toLowerCase()==="cimode")return n();var a=[],u=function(o){o&&s.services.languageUtils.toResolveHierarchy(o).forEach(function(g){a.indexOf(g)<0&&a.push(g)})};i?u(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(function(o){return u(o)}),this.options.preload&&this.options.preload.forEach(function(o){return u(o)}),this.services.backendConnector.load(a,this.options.ns,function(o){o||s.resolvedLanguage||!s.language||s.setResolvedLanguage(s.language),n(o)})}else n(null)}},{key:"reloadResources",value:function(t,s,n){var i=Ie();return t||(t=this.languages),s||(s=this.options.ns),n||(n=Re),this.services.backendConnector.reload(t,s,function(a){i.resolve(),n(a)}),i}},{key:"use",value:function(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&Ft.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}},{key:"setResolvedLanguage",value:function(t){if(t&&this.languages&&!(["cimode","dev"].indexOf(t)>-1))for(var s=0;s<this.languages.length;s++){var n=this.languages[s];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(t,s){var n=this;this.isLanguageChangingTo=t;var i=Ie();this.emit("languageChanging",t);var a=function(o){n.language=o,n.languages=n.services.languageUtils.toResolveHierarchy(o),n.resolvedLanguage=void 0,n.setResolvedLanguage(o)},u=function(o){t||o||!n.services.languageDetector||(o=[]);var g=typeof o=="string"?o:n.services.languageUtils.getBestMatchFromCodes(o);g&&(n.language||a(g),n.translator.language||n.translator.changeLanguage(g),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage&&n.services.languageDetector.cacheUserLanguage(g)),n.loadResources(g,function(l){(function(p,h){h?(a(h),n.translator.changeLanguage(h),n.isLanguageChangingTo=void 0,n.emit("languageChanged",h),n.logger.log("languageChanged",h)):n.isLanguageChangingTo=void 0,i.resolve(function(){return n.t.apply(n,arguments)}),s&&s(p,function(){return n.t.apply(n,arguments)})})(l,g)})};return t||!this.services.languageDetector||this.services.languageDetector.async?!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(u):this.services.languageDetector.detect(u):u(t):u(this.services.languageDetector.detect()),i}},{key:"getFixedT",value:function(t,s,n){var i=this,a=function u(o,g){var l;if(R(g)!=="object"){for(var p=arguments.length,h=new Array(p>2?p-2:0),f=2;f<p;f++)h[f-2]=arguments[f];l=i.options.overloadTranslationOptionHandler([o,g].concat(h))}else l=N({},g);l.lng=l.lng||u.lng,l.lngs=l.lngs||u.lngs,l.ns=l.ns||u.ns,l.keyPrefix=l.keyPrefix||n||u.keyPrefix;var m,E=i.options.keySeparator||".";return m=l.keyPrefix&&Array.isArray(o)?o.map(function(d){return"".concat(l.keyPrefix).concat(E).concat(d)}):l.keyPrefix?"".concat(l.keyPrefix).concat(E).concat(o):o,i.t(m,l)};return typeof t=="string"?a.lng=t:a.lngs=t,a.ns=s,a.keyPrefix=n,a}},{key:"t",value:function(){var t;return this.translator&&(t=this.translator).translate.apply(t,arguments)}},{key:"exists",value:function(){var t;return this.translator&&(t=this.translator).exists.apply(t,arguments)}},{key:"setDefaultNamespace",value:function(t){this.options.defaultNS=t}},{key:"hasLoadedNamespace",value:function(t){var s=this,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;var i=n.lng||this.resolvedLanguage||this.languages[0],a=!!this.options&&this.options.fallbackLng,u=this.languages[this.languages.length-1];if(i.toLowerCase()==="cimode")return!0;var o=function(l,p){var h=s.services.backendConnector.state["".concat(l,"|").concat(p)];return h===-1||h===2};if(n.precheck){var g=n.precheck(this,o);if(g!==void 0)return g}return!!this.hasResourceBundle(i,t)||!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(i,t)||a&&!o(u,t))}},{key:"loadNamespaces",value:function(t,s){var n=this,i=Ie();return this.options.ns?(typeof t=="string"&&(t=[t]),t.forEach(function(a){n.options.ns.indexOf(a)<0&&n.options.ns.push(a)}),this.loadResources(function(a){i.resolve(),s&&s(a)}),i):(s&&s(),Promise.resolve())}},{key:"loadLanguages",value:function(t,s){var n=Ie();typeof t=="string"&&(t=[t]);var i=this.options.preload||[],a=t.filter(function(u){return i.indexOf(u)<0});return a.length?(this.options.preload=i.concat(a),this.loadResources(function(u){n.resolve(),s&&s(u)}),n):(s&&s(),Promise.resolve())}},{key:"dir",value:function(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";var s=this.services&&this.services.languageUtils||new mt(bt());return["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"].indexOf(s.getLanguagePartFromCode(t))>-1||t.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var t=this,s=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Re,i=N(N(N({},this.options),s),{isClone:!0}),a=new e(i);return s.debug===void 0&&s.prefix===void 0||(a.logger=a.logger.clone(s)),["store","services","language"].forEach(function(u){a[u]=t[u]}),a.services=N({},this.services),a.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a.translator=new ft(a.services,a.options),a.translator.on("*",function(u){for(var o=arguments.length,g=new Array(o>1?o-1:0),l=1;l<o;l++)g[l-1]=arguments[l];a.emit.apply(a,[u].concat(g))}),a.init(i,n),a.translator.options=a.options,a.translator.backendConnector.services.utils={hasLoadedNamespace:a.hasLoadedNamespace.bind(a)},a}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),e})();X(Ge,"createInstance",function(){return new Ge(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},arguments.length>1?arguments[1]:void 0)});var U,Ct,Ot,M=Ge.createInstance();M.createInstance=Ge.createInstance,M.createInstance,M.dir,M.init,M.loadResources,M.reloadResources,M.use,M.changeLanguage,M.getFixedT,M.t,M.exists,M.setDefaultNamespace,M.hasLoadedNamespace,M.loadNamespaces,M.loadLanguages;class ge extends F{constructor(){super(),this.languages=null,this.keyMap={}}static getInstance(){return ge.instance||(ge.instance=new ge),ge.instance}provideLanguages(e){var t;Y||(this.languages=e,!((t=e["zh-CN"])===null||t===void 0)&&t.Chat&&this.setKeyMap(e["zh-CN"]),console.log("TUITranslateService.provideLanguages ok."))}useI18n(e){var t;if(Y)return;if(!this.languages)return void console.warn("TUITranslateService.useI18next not have messages.");const s={};for(const[i,a]of Object.entries(this.languages))s[i==="zh_cn"?"zh":i]={translation:a};M.init({compatibilityJSON:"v3",lng:e||"zh",fallbackLng:"zh",detection:{order:["querystring","navigator"],caches:["localStorage","cookie"]},resources:s});let n=this.normalizeLanguageKey(e||"zh");(t=this.getEngine().TUIReport)===null||t===void 0||t.reportFeature(201,n)}changeLanguage(e){let t=this.normalizeLanguageKey(e);return this.getEngine().TUIReport.reportFeature(201,t),M.changeLanguage(e)}normalizeLanguageKey(e){return e.includes("en")?"en-us":e.includes("tw")?"zh-tw":e.includes("zh")||e.includes("cn")?"zh-cn":e.includes("ko")||e.includes("kr")?"ko-kr":e.includes("ja")||e.includes("jp")?"ja-jp":"other-"+e}t(e){if(!this.languages){let s=e;return!D(e)&&e.indexOf(".")>-1&&(s=e.split(".").pop()||""),s}const t=this.keyMap[e];return t?M.t(t):M.t(e)}setKeyMap(e,t){for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const n=t?`${t}.${s}`:s;if(e[s]&&typeof e[s]=="object"&&!Array.isArray(e[s])&&e[s]!==null)this.setKeyMap(e[s],n);else{let i=t?`${t}.${e[s]}`:e[s];i=this.replaceKey(i),this.keyMap[i]=`${t}.${s}`}}}replaceKey(e){return e.startsWith("Chat")?e.replace("Chat","TUIChat"):e.startsWith("Conversation")?e.replace("Conversation","TUIConversation"):e.startsWith("Message")?e.replace("Message","message.tip"):e.startsWith("Call")?e.replace("Call","message.custom"):e}}class te extends F{constructor(){super(),this.serv="TUIConversationService"}static getInstance(){return te.instance||(te.instance=new te),te.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalUnreadCountUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),this.getConversationInitData()}onConversationListUpdated(e){const t=this.filterSystemConversation(e);this.getEngine().TUIStore.update(c.CONV,"conversationList",t),this.updateCurrentConversation()}onTotalUnreadCountUpdated(e){this.getEngine().TUIStore.update(c.CONV,"totalUnreadCount",e)}onMessageReceived(e){const t=this.getEngine(),s=this.getEngine().TUIStore.getData(c.CONV,"conversationList");let n=!1;for(let i=0;i<e.length;i++){if(e[i].type!==t.TYPES.MSG_GRP_SYS_NOTICE)continue;const{operationType:a}=e[i].payload,u=`GROUP${e[i].to}`,o=a===4||a===5||a===8,g=a===2||a===6||a===7;if(o||g){for(let l=0;l<s.length;l++)if(s[l].type!==t.TYPES.CONV_C2C&&s[l].conversationID===u){if(o){this.getEngine().TUIStore.update(c.CONV,"operationTypeMap",{conversationID:u,operationType:a}),n=!0;break}if(g&&s[l].operationType>0){this.getEngine().TUIStore.update(c.CONV,"operationTypeMap",{conversationID:u,operationType:0}),n=!0;break}}}}if(n){this.getEngine().TUIStore.update(c.CONV,"conversationList",s);const i=this.getEngine().TUIStore.getData(c.CONV,"currentConversationID")||"",a=this.findConversation(i);a&&this.getEngine().TUIStore.update(c.CONV,"currentConversation",a)}}getConversationInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getConversationList().then(t=>{const{conversationList:s,isSyncCompleted:n}=t.data;if(console.log(`${this.serv}.init, getConversationList count:${s.length} isSyncCompleted:${n}`),s.length>0){this.onConversationListUpdated(s);const i=e.chat.getTotalUnreadMessageCount();this.onTotalUnreadCountUpdated(i)}})}switchConversation(e){return j(this,void 0,void 0,function*(){const t=`${this.serv}.switchConversation`,s=this.getEngine();if(!e)return s.TUIStore.reset(c.CHAT,["messageList","isCompleted","nextReqMessageID"]),s.TUIStore.update(c.CONV,"currentConversationID",""),s.TUIStore.update(c.CONV,"currentConversation",null),console.log(`${t} conversationID is empty, conversationID:${e}`),Promise.resolve({});if(!e.startsWith(s.TYPES.CONV_C2C)&&!e.startsWith(s.TYPES.CONV_GROUP))return console.warn(`${t} conversationID is invalid, conversationID:${e}`),Promise.reject({code:q.INVALID_CONV_ID,message:z.INVALID_CONV_ID});const n=s.TUIStore.getData(c.APP,"enableAutoMessageRead"),i=s.TUIStore.getData(c.CONV,"currentConversationID");if(i&&i===e)return n&&this.setMessageRead(i),console.warn(`${t} please check conversationID, conversationID:${e}`),Promise.resolve({code:q.CONV_ID_SAME,message:z.CONV_ID_SAME});const a=yield this.getConversationModel(e);return D(a)?(console.warn(`${t} target conversation is not exist, conversationID:${e}`),Promise.reject({code:q.CONV_NOT_EXIST,message:z.CONV_NOT_EXIST})):(n&&(i&&this.setMessageRead(i),e&&this.setMessageRead(e)),s.TUIStore.reset(c.CHAT,["messageList","isCompleted","nextReqMessageID"]),s.TUIStore.update(c.CONV,"currentConversationID",e),s.TUIStore.update(c.CONV,"currentConversation",a),Promise.resolve(a))})}getConversationModel(e){return j(this,void 0,void 0,function*(){let t=this.findConversation(e);if(D(t))try{const s=yield this.getConversationProfile(e);s.data&&s.data.conversation&&(t=new je(s.data.conversation))}catch{t=void 0}return t})}findConversation(e){let t;const s=this.getEngine().TUIStore.getData(c.CONV,"conversationList");for(let n=0;n<s.length;n++)if(s[n].conversationID===e){t=s[n];break}return t}updateCurrentConversation(){const e=this.getEngine(),t=e.TUIStore.getData(c.CONV,"currentConversationID"),s=this.findConversation(t);s&&e.TUIStore.update(c.CONV,"currentConversation",s)}getConversationList(){return this.getEngine().chat.getConversationList()}getConversationProfile(e){return this.getEngine().chat.getConversationProfile(e)}deleteConversation(e){const t=typeof e=="string"?e:e.conversationIDList[0];return this.getEngine().chat.deleteConversation(e).then(s=>{const n=this.getEngine().TUIStore.getData(c.CONV,"currentConversationID");return console.log(`${this.serv}.deleteConversation conversationID:${t} currentConversationID:${n}`),this.getEngine().TUIStore.update(c.CONV,"operationTypeMap",{conversationID:t,operationType:0}),t===n&&(this.getEngine().TUIStore.update(c.CONV,"currentConversationID",""),this.getEngine().TUIStore.update(c.CONV,"currentConversation",null)),s})}pinConversation(e){return this.getEngine().chat.pinConversation(e)}muteConversation(e){return this.getEngine().chat.setMessageRemindType(e)}clearHistoryMessage(e){return this.getEngine().chat.clearHistoryMessage(e).then(t=>(this.getEngine().TUIStore.update(c.CHAT,"messageList",[]),this.getEngine().TUIStore.update(c.CHAT,"nextReqMessageID",""),this.getEngine().TUIStore.update(c.CHAT,"isCompleted",!0),t))}setMessageRead(e){return this.getEngine().chat.setMessageRead({conversationID:e})}setConversationDraft(e){const{conversationID:t,draftInfo:s,draftText:n=""}=e;return this.getEngine().chat.setConversationDraft({conversationID:t,draftText:n||(s?JSON.stringify(s):"")}).then(i=>{const{conversation:a}=i.data;this.updateConversation(a)})}updateConversation(e){let t=!1;const s=this.getEngine().TUIStore.getData(c.CONV,"conversationList");for(let n=0;n<s.length;n++)if(s[n].conversationID===e.conversationID){s[n]=e,t=!0;break}t&&this.getEngine().TUIStore.update(c.CONV,"conversationList",s)}filterSystemConversation(e){return e.filter(t=>t.type!==this.getEngine().TYPES.CONV_SYSTEM)}markConversation(e){return this.getEngine().chat.markConversation(e)}}class Ys{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.PROFILE_UPDATED,this.onProfileUpdated.bind(this)),this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated.bind(this)),this.getUserProfileInitData()}onProfileUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(c.USER,"userProfile");e.forEach(n=>{n.userID===s.userID&&t.TUIStore.update(c.USER,"userProfile",n)})}onBlacklistUpdated(e){const t=this.getEngine();this.getBlacklistProfile(e).then(s=>{t.TUIStore.update(c.USER,"userBlacklist",s)})}getUserProfileInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getBlacklist().then(t=>{const s=t.data||[];console.log(`TUIUserProfileHandler.init, getBlacklist count:${s.length}`),s.length>0&&this.onBlacklistUpdated(s)})}getBlacklistProfile(e){const t=[];let s=0;for(;s<e.length;)t.push(e.slice(s,s+=100));const n=[];t.forEach(a=>{n.push(this.TUIUserService.getUserProfile({userIDList:a}))});const i=[];return Promise.all(n).then(a=>(a.forEach(u=>{const o=u.data.map(g=>{const{userID:l,nick:p,avatar:h}=g;return{userID:l,nick:p,avatar:h}});i.push(...o)}),i))}getUserProfile(e){const t=this.getEngine();return D(e)?t.chat.getMyProfile().then(s=>(t.TUIStore.update(c.USER,"userProfile",s.data),s)).catch(s=>Promise.reject(s)):t.chat.getUserProfile(e)}updateMyProfile(e){return this.getEngine().chat.updateMyProfile(e)}addToBlacklist(e){return this.getEngine().chat.addToBlacklist(e)}removeFromBlacklist(e){return this.getEngine().chat.removeFromBlacklist(e)}}function Vt(r,e,t=!0){(function(s,n){Ke?qe.setStorageSync(s,n):Yt()&&localStorage.setItem(s,JSON.stringify(n))})(t?Ht(r):r,e)}function $t(r,e=!0){try{return(function(t){if(Ke)return qe.getStorageSync(t);if(Yt()){const s=localStorage.getItem(t);if(s!=="undefined")return JSON.parse(s)}})(e?Ht(r):r)}catch(t){return void console.warn("Storage.getStorageItem error:",t)}}function Ht(r){return`chat_engine_${r}`}function Yt(){return navigator&&navigator.cookieEnabled&&localStorage}class Bs{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){const e=this.getEngine(),t=$t("displayOnlineStatus")||!1;e.TUIStore.update(c.USER,"displayOnlineStatus",t),e.eventCenter.addEvent(e.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated.bind(this)),this.onConversationListUpdated()}onConversationListUpdated(){const e=this.getEngine();e.TUIStore.watch(c.CONV,{conversationList:()=>{const t=e.TUIStore.getData(c.APP,"enabledOnlineStatus"),s=e.TUIStore.getData(c.USER,"displayOnlineStatus");t&&s&&this.startToSubscribe()}})}onUserStatusUpdated(e){this.getEngine().TUIStore.update(c.USER,"userStatusList",e)}switchUserStatus(e){const t=this.getEngine(),{displayOnlineStatus:s=!1}=e;t.TUIStore.update(c.USER,"displayOnlineStatus",s),Vt("displayOnlineStatus",s);const n=t.TUIStore.getData(c.APP,"enabledOnlineStatus");n?s===!0?this.startToSubscribe():this.unsubscribeUserStatus().catch(i=>{console.warn("UserStatusHandler.switchUserStatus error:",i)}):console.warn(`UserStatusHandler.switchUserStatus enabledOnlineStatus:${n} displayOnlineStatus:${s}`)}getUserStatus(e){const t=this.getEngine();return t.chat.getUserStatus(e).then(s=>{const{successUserList:n}=s.data;return n.length>0&&t.TUIStore.update(c.USER,"userStatusList",n),s}).catch(s=>Promise.reject(s))}subscribeUserStatus(e){var t;const s=((t=e==null?void 0:e.userIDList)===null||t===void 0?void 0:t.length)||0;return s===0?(console.warn(`UserStatusHandler.subscribeUserStatus userID count:${s}`),Promise.resolve()):this.getEngine().chat.subscribeUserStatus(e)}unsubscribeUserStatus(e){const t=this.getEngine(),{userIDList:s=[]}=e||{};return t.chat.unsubscribeUserStatus({userIDList:s}).then(n=>{const{failureUserList:i}=n.data,a=[];return s.forEach(u=>{i.includes(u)||a.push({userID:u,statusType:Le.UNSUB_USER})}),t.TUIStore.update(c.USER,"userStatusList",a),n}).catch(n=>Promise.reject(n))}startToSubscribe(){const e=this.getEngine(),t=e.TUIStore.getData(c.CONV,"conversationList"),s=e.TUIStore.getData(c.USER,"userStatusList"),n=[];t.forEach(i=>{if(i.type===e.TYPES.CONV_C2C){const a=i.conversationID.replace(e.TYPES.CONV_C2C,"");s.has(a)||n.push(a)}}),n.length!==0&&e.chat.isReady()&&(this.subscribeUserStatus({userIDList:n}).catch(i=>{console.warn("UserStatusHandler.startToSubscribe,",i)}),this.getUserStatus({userIDList:n}).catch(i=>{console.warn("UserStatusHandler.startToSubscribe,",i)}))}}class ce extends F{constructor(){super(),this.userProfileHandler=new Ys(this),this.userStatusHandler=new Bs(this)}static getInstance(){return ce.instance||(ce.instance=new ce),ce.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.KICKED_OUT,this.onKickedOut.bind(this)),e.eventCenter.addEvent(e.EVENT.NET_STATE_CHANGE,this.onNetStateChange.bind(this)),this.userProfileHandler.init(),this.userStatusHandler.init(),this.initMessageReadReceipt()}onKickedOut(e){this.getEngine().TUIStore.update(c.USER,"kickedOut",e.type)}onNetStateChange(e){this.getEngine().TUIStore.update(c.USER,"netStateChange",e.state)}initMessageReadReceipt(){const e=$t("displayMessageReadReceipt")||!0;this.getEngine().TUIStore.update(c.USER,"displayMessageReadReceipt",e)}switchUserStatus(e){return this.userStatusHandler.switchUserStatus(e)}switchMessageReadStatus(e){this.getEngine().TUIStore.update(c.USER,"displayMessageReadReceipt",e),Vt("displayMessageReadReceipt",e)}getUserProfile(e){return this.userProfileHandler.getUserProfile(e)}updateMyProfile(e){return this.userProfileHandler.updateMyProfile(e)}addToBlacklist(e){return this.userProfileHandler.addToBlacklist(e)}removeFromBlacklist(e){return this.userProfileHandler.removeFromBlacklist(e)}getUserStatus(e){return this.userStatusHandler.getUserStatus(e)}subscribeUserStatus(e){return this.userStatusHandler.subscribeUserStatus(e)}unsubscribeUserStatus(e){return this.userStatusHandler.unsubscribeUserStatus(e)}}class Ks{constructor(e){this.TUIChatService=e,this.userShowNameMap=new Map,this.requestedUserMap=new Map}getEngine(){return this.TUIChatService.getEngine()}t(e){return this.getEngine().TUITranslate.t(e)}handleTextMessage(e){return{text:this.decodeText(e.payload)}}handleFaceMessage(e){const t={name:"",url:"",type:""};return e.payload.data.indexOf("@custom")>-1?(t.name=e.payload.data,t.type="custom",t):(t.name=e.payload.data.indexOf("@2x")<0?`${e.payload.data}@2x`:e.payload.data,t.url=`${as}${t.name}.png`,t)}handleLocationMessage(e){const t={lon:"",lat:"",href:"",url:"",description:""};return t.lon=e.payload.longitude.toFixed(6),t.lat=e.payload.latitude.toFixed(6),t.href=`${os}pointx=${t.lon}&pointy=${t.lat}&name=${e.payload.description}`,t.url=`${us}center=${t.lat},${t.lon}&zoom=10&size=300*150&maptype=roadmap&markers=size:large|color:0xFFCCFF|label:k|${t.lat},${t.lon}&key=UBNBZ-PTP3P-TE7DB-LHRTI-Y4YLE-VWBBD`,t.description=e.payload.description,t}handleImageMessage(e){return{url:e.payload.imageInfoArray[0].url,width:e.payload.imageInfoArray[0].width,height:e.payload.imageInfoArray[0].height}}handleAudioMessage(e){return{url:e.payload.url,second:e.payload.second}}handleVideoMessage(e){return{url:e.payload.videoUrl,snapshotUrl:e.payload.snapshotUrl,snapshotWidth:e.payload.snapshotWidth,snapshotHeight:e.payload.snapshotHeight}}handleFileMessage(e){return{url:e.payload.fileUrl,name:e.payload.fileName,size:ts(e.payload.fileSize)}}handleCustomMessage(e){var t;const s=this.handleCreateGroupCustomMessage(e);return{custom:this.handleCallKitSignaling(e)||s||((t=e==null?void 0:e.payload)===null||t===void 0?void 0:t.extension)||`${this.t("TUIChat.[自定义消息]")}`,businessID:s?"group_create":""}}handleMergeMessage(e){return Object.assign({},e.payload)}handleGroupTipsMessage(e){var t,s,n,i,a,u;const o=this.getEngine(),g={text:""};let l=(e==null?void 0:e.nick)||((s=(t=e==null?void 0:e.payload)===null||t===void 0?void 0:t.userIDList)===null||s===void 0?void 0:s.join(","));switch(((i=(n=e==null?void 0:e.payload)===null||n===void 0?void 0:n.memberList)===null||i===void 0?void 0:i.length)>0&&(l="",(u=(a=e==null?void 0:e.payload)===null||a===void 0?void 0:a.memberList)===null||u===void 0||u.map(p=>{const h=(p==null?void 0:p.nick)||(p==null?void 0:p.userID);return l+=`${this.substringByLength(h)},`,p}),l=l==null?void 0:l.slice(0,-1)),e.payload.operationType){case o.TYPES.GRP_TIP_MBR_JOIN:g.text=`${l} ${this.t("message.tip.加入群组")}`;break;case o.TYPES.GRP_TIP_MBR_QUIT:g.text=`${this.t("message.tip.群成员")}${l} ${this.t("message.tip.退出群组")}`;break;case o.TYPES.GRP_TIP_MBR_KICKED_OUT:g.text=`${this.t("message.tip.群成员")}${l} ${this.t("message.tip.被")}${this.t("message.tip.踢出群组")}`;break;case o.TYPES.GRP_TIP_MBR_SET_ADMIN:g.text=`${this.t("message.tip.群成员")}${l} ${this.t("message.tip.成为管理员")}`;break;case o.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:g.text=`${this.t("message.tip.群成员")}${l} ${this.t("message.tip.被撤销管理员")}`;break;case o.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:g.text=this.handleGroupProfileUpdated(e);break;case o.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:for(const p of e.payload.memberList)p.muteTime>0?g.text=`${this.t("message.tip.群成员")}${l} ${this.t("message.tip.被禁言")}`:g.text=`${this.t("message.tip.群成员")}${l} ${this.t("message.tip.被取消禁言")}`;break;default:g.text=`[${this.t("message.tip.群提示消息")}]`}return g}handleGroupSystemMessage(e){const t=e.payload.groupProfile.name||e.payload.groupProfile.groupID,s={text:""};switch(e.payload.operationType){case 1:s.text=`${e.payload.operatorID} ${this.t("message.tip.申请加入群组")}${t}`;break;case 2:s.text=`${this.t("message.tip.成功加入群组")}${t}`;break;case 3:s.text=`${this.t("message.tip.申请加入群组")}${t} ${this.t("message.tip.被拒绝")}`;break;case 4:s.text=`${this.t("message.tip.你被管理员")}${e.payload.operatorID} ${this.t("message.tip.踢出群组")}${t}`;break;case 5:s.text=`${this.t("message.tip.群")}${t} ${this.t("message.tip.被")} ${e.payload.operatorID} ${this.t("message.tip.解散")}`;break;case 6:s.text=`${e.payload.operatorID} ${this.t("message.tip.创建群")}${t}`;break;case 7:case 12:s.text=`${e.payload.operatorID} ${this.t("message.tip.邀请你加群")}${t}`;break;case 8:s.text=`${this.t("message.tip.你退出群组")}${t}`;break;case 9:s.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.设置为群")}${t} ${this.t("message.tip.的管理员")}`;break;case 10:s.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.撤销群")}${t} ${this.t("message.tip.的管理员身份")}`;break;case 13:s.text=`${e.payload.operatorID} ${this.t("message.tip.同意加群")}${t}`;break;case 14:s.text=`${e.payload.operatorID} ${this.t("message.tip.拒接加群")}${t}`;break;case 255:s.text=`${this.t("message.tip.自定义群系统通知")}: ${e.payload.userDefinedField}`;break;default:s.text="未解析的群系统通知"}return s}handleCallKitSignaling(e){var t,s,n,i,a,u,o,g,l,p;const h=_(e.payload.data);if((h==null?void 0:h.businessID)!==1)return"";const f=_(h==null?void 0:h.data),m=e.fromAccount||e.from,E=this.getEngine().TUIFriend.getFriendRemark([m]),d=this.getEngine().getMyUserID();let T=E[m]||e.nameCard||e.nick||m;switch(T=this.substringByLength(T),h==null?void 0:h.actionType){case 1:return((t=f==null?void 0:f.data)===null||t===void 0?void 0:t.cmd)!=="audioCall"&&((s=f==null?void 0:f.data)===null||s===void 0?void 0:s.cmd)!=="videoCall"||!(h!=null&&h.groupID)?((n=f==null?void 0:f.data)===null||n===void 0?void 0:n.cmd)==="hangup"?h!=null&&h.groupID?`${this.t("message.custom.通话结束")}`:`${this.t("message.custom.通话时长")}${(function(S){const v=S;let b,y,I,k="";return v>=3600?(b=parseInt(""+v/3600,10)<10?`0${parseInt(""+v/3600,10)}`:parseInt(""+v/3600,10),y=parseInt(""+v%60/60,10)<10?`0${parseInt(""+v%60/60,10)}`:parseInt(""+v%60/60,10),I=v%3600<10?"0"+v%3600:v%3600,I>60&&(y=parseInt(""+I/60,10)<10?`0${parseInt(""+I/60,10)}`:parseInt(""+I/60,10),I=I%60<10?"0"+I%60:I%60),k=`${b}:${y}:${I}`):v>=60&&v<3600?(y=parseInt(""+v/60,10)<10?`0${parseInt(""+v/60,10)}`:parseInt(""+v/60,10),I=v%60<10?"0"+v%60:v%60,k=`00:${y}:${I}`):v<60&&(I=v<10?`0${v}`:v,k=`00:00:${I}`),k})(f==null?void 0:f.call_end)}`:((i=f==null?void 0:f.data)===null||i===void 0?void 0:i.cmd)==="switchToAudio"?`${this.t("message.custom.切换语音通话")}`:((a=f==null?void 0:f.data)===null||a===void 0?void 0:a.cmd)==="switchToVideo"?`${this.t("message.custom.切换视频通话")}`:`${this.t("message.custom.发起通话")}`:`${T} ${this.t("message.custom.发起通话")}`;case 2:return h!=null&&h.groupID?`${T} ${this.t("message.custom.取消通话")}`:this.isOldUIKit("message.custom.已取消")?this.t("message.custom.取消通话"):(h==null?void 0:h.inviter)===d?this.t("message.custom.已取消"):this.t("message.custom.对方已取消");case 3:return((u=f==null?void 0:f.data)===null||u===void 0?void 0:u.cmd)==="switchToAudio"?`${this.t("message.custom.切换语音通话")}`:((o=f==null?void 0:f.data)===null||o===void 0?void 0:o.cmd)==="switchToVideo"?`${this.t("message.custom.切换视频通话")}`:h!=null&&h.groupID?`${T} ${this.t("message.custom.已接听")}`:this.t("message.custom.已接听");case 4:return h!=null&&h.groupID?`${T} ${this.t("message.custom.拒绝通话")}`:this.isOldUIKit("message.custom.已拒绝")?this.t("message.custom.拒绝通话"):(f==null?void 0:f.line_busy)==="line_busy"||(f==null?void 0:f.data.message)==="lineBusy"?(h==null?void 0:h.inviter)===d?this.t("message.custom.对方忙线中"):this.t("message.custom.忙线未接听"):(h==null?void 0:h.inviter)===d?this.t("message.custom.对方已拒绝"):this.t("message.custom.已拒绝");case 5:if(((g=f==null?void 0:f.data)===null||g===void 0?void 0:g.cmd)==="switchToAudio")return`${this.t("message.custom.切换语音通话")}`;if(((l=f==null?void 0:f.data)===null||l===void 0?void 0:l.cmd)==="switchToVideo")return`${this.t("message.custom.切换视频通话")}`;if(h!=null&&h.groupID){if(m===(h==null?void 0:h.inviter)){this.handleCallkitTimeoutSignaling(h.inviteeList);let S="";return(p=h.inviteeList)===null||p===void 0||p.forEach(v=>{const b=this.userShowNameMap.get(v)||v;S+=`${this.substringByLength(b)}、`}),S=S.substring(0,S.lastIndexOf("、")),`${S} ${this.t("message.custom.无应答")}`}return`${T} ${this.t("message.custom.无应答")}`}return this.isOldUIKit("message.custom.对方无应答")?this.t("message.custom.无应答"):(h==null?void 0:h.inviter)===d?this.t("message.custom.对方无应答"):this.t("message.custom.超时无应答");default:return""}}handleCreateGroupCustomMessage(e){let t;const s=_(e.payload.data);return(s==null?void 0:s.businessID)==="group_create"&&(t=`${s.opUser} ${s.content}`),t}decodeText(e){const t=[];let s=e.text,n=-1,i=-1;for(;s!=="";)switch(n=s.indexOf("["),i=s.indexOf("]"),n){case 0:if(i===-1)t.push({name:"text",text:s}),s="";else{const a=s.slice(0,i+1);a.indexOf("@custom")>-1?(t.push({name:"img",src:"",type:"custom",emojiKey:a}),s=s.substring(i+1)):st[a]?(t.push({name:"img",src:rs+st[a],emojiKey:a}),s=s.substring(i+1)):(t.push({name:"text",text:"["}),s=s.slice(1))}break;case-1:t.push({name:"text",text:s}),s="";break;default:t.push({name:"text",text:s.slice(0,n)}),s=s.substring(n)}return t}handleGroupProfileUpdated(e){const{nick:t,payload:s}=e,{newGroupProfile:n,memberList:i,operatorID:a}=s;let u="";const o=t||a,g=Object.keys(n)[0];switch(g){case"muteAllMembers":u=n[g]?`${this.t("message.tip.管理员")} ${o} ${this.t("message.tip.开启全员禁言")}`:`${this.t("message.tip.管理员")} ${o} ${this.t("message.tip.取消全员禁言")}`;break;case"ownerID":u=`${i[0].nick||i[0].userID} ${this.t("message.tip.成为新的群主")}`;break;case"groupName":u=`${o} ${this.t("message.tip.修改群名为")} ${n[g]}`;break;case"notification":u=this.isOldUIKit("message.tip.把群公告修改为")?`${o} ${this.t("message.tip.发布新公告")}`:`${o} ${this.t("message.tip.把群公告修改为")} "${n[g]}"`}return u}handleCallkitTimeoutSignaling(e=[]){if(e.length===0)return;const t=this.getEngine().TUIFriend.getFriendRemark(e),s=[];e.forEach(n=>{const i=t[n];i?this.userShowNameMap.set(n,i):this.requestedUserMap.has(n)||(s.push(n),this.requestedUserMap.set(n,1))}),s.length>0&&this.getEngine().TUIUser.getUserProfile({userIDList:s}).then(n=>{(n.data||[]).forEach(i=>{const{userID:a,nick:u}=i,o=u||a;this.userShowNameMap.set(a,o)})}).catch(()=>{})}substringByLength(e,t=12){return e.length>t?`${e.slice(0,t)}...`:e}isOldUIKit(e){var t;const s=e.lastIndexOf("."),n=e.slice(0,s+1);return(t=this.t(e))===null||t===void 0?void 0:t.startsWith(n)}}class qs{constructor(e){this.TUIChatService=e,this.typingTo="",this.timer=null}getEngine(){return this.TUIChatService.getEngine()}clearTypingStatus(){this.getEngine().TUIStore.getData(c.CHAT,"typingStatus")&&this.getEngine().TUIStore.update(c.CHAT,"typingStatus",!1),this.timer&&clearTimeout(this.timer),this.timer=null}handleLastMessage(e){const t=this.getEngine(),s=t.TUIStore.getData(c.CHAT,"typingStatus");if(e.type===this.getEngine().TYPES.MSG_CUSTOM&&e.flow==="in"){const n=_(e.payload.data);if(n.businessID===P.BUSINESS_ID){const{typingStatus:i,userAction:a}=n;if(i===P.STATUS_START||a===P.ACTION_START_ID)return s?(this.timer&&clearTimeout(this.timer),this.timer=null):t.TUIStore.update(c.CHAT,"typingStatus",!0),this.timer=setTimeout(()=>{this.clearTypingStatus()},3e4),t.TUIStore.getData(c.CHAT,"typingStatus");i!==P.STATUS_END&&a!==P.ACTION_END_ID||this.clearTypingStatus()}}}filterTypingMessage(e=[]){return e.length===0?[]:(this.getEngine().TUIStore.getData(c.APP,"enableTyping")&&this.handleLastMessage(e[e.length-1]),e.filter(t=>t.type===this.getEngine().TYPES.MSG_CUSTOM?_(t.payload.data).businessID!==P.BUSINESS_ID:!0))}createTypingMessage(e=P.STATUS_END,t=""){const{BUSINESS_ID:s,STATUS_START:n,VERSION:i,ACTION_START_ID:a,ACTION_END_ID:u,ACTION_START:o,ACTION_END:g,NEED_TYPING:l}=P;return{to:t,conversationType:this.getEngine().TYPES.CONV_C2C,payload:{data:JSON.stringify({businessID:s,typingStatus:e,version:i,userAction:e===n?a:u,actionParam:e===n?o:g}),description:"",extension:""},cloudCustomData:JSON.stringify({messageFeature:{needTyping:l,version:i}})}}sendTyping(e=!1,t=""){if(e){this.typingTo=t;const s=this.createTypingMessage(P.STATUS_START,t);this.getEngine().TUIChat.sendCustomMessage(s,{onlineUserOnly:!0})}else this.sendTypingEnd()}sendTypingEnd(){if(this.typingTo){const e=this.createTypingMessage(P.STATUS_END,this.typingTo);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}this.typingTo=""}}class zs{constructor(e){this.TUIChatService=e}getEngine(){return this.TUIChatService.getEngine()}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived.bind(this))}onMessageReadReceiptReceived(e){const t=this.getEngine(),s=t.TUIStore.getData(c.CONV,"currentConversationID"),n=[];e.forEach(i=>{const{messageID:a}=i,u=t.chat.findMessage(a);u&&s===u.conversationID&&n.push(u)}),n.length>0&&t.TUIChat.updateMessageList(n,"edit")}sendMessageReadReceipt(e){const t=[];return e.forEach(s=>{const n=s.getMessage();t.push(n)}),this.getEngine().chat.sendMessageReadReceipt(t)}getGroupMessageReadMemberList(e){const t=e.message.getMessage(),s=Object.assign(Object.assign({},e),{message:t});return this.getEngine().chat.getGroupMessageReadMemberList(s)}getMessageReadReceiptList(e){const t=this.getEngine(),s=t.TUIStore.getData(c.APP,"enabledMessageReadReceipt"),n=t.TUIStore.getData(c.USER,"displayMessageReadReceipt");!s||!n||e.length===0||e[0].conversationType!==t.TYPES.CONV_GROUP||t.chat.getMessageReadReceiptList(e).then(i=>{const{messageList:a}=i.data;this.TUIChatService.updateMessageList(a,"edit")}).catch(i=>{console.warn(`ReadReceiptHandler.getMessageReadReceiptList error:${i.message}`)})}}class le extends F{constructor(){super(),this.serv="TUIChatService",this.messageHandler=new Ks(this),this.typingHandler=new qs(this),this.readReceiptHandler=new zs(this),this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap=new Map}static getInstance(){return le.instance||(le.instance=new le),le.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_MODIFIED,this.onMessageModified.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_REVOKED,this.onMessageRevoked.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated.bind(this)),this.onCurrentConversationIDUpdated(),this.onMessageSource(),this.readReceiptHandler.init()}onMessageReceived(e){this.updateMessageList(e,"received"),this.getEngine().TUIStore.update(c.CHAT,"newMessageList",e)}onMessageModified(e){this.updateMessageList(e,"edit")}onMessageRevoked(e){this.updateMessageList(e,"edit")}onMessageReadByPeer(e){this.updateMessageList(e,"edit")}onMessageReactionsUpdated(e){this.updateMessageReactionList([e])}onCurrentConversationIDUpdated(){const e=this.getEngine();e.TUIStore.watch(c.CONV,{currentConversationID:t=>{this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.clear(),e.TUIStore.reset(c.CHAT),this.typingHandler.clearTypingStatus(),this.typingHandler.sendTypingEnd(),Gt(t)||this.getMessageList().finally(()=>{this.isSwitching=!1,this.delayGetHoppingFunction&&this.delayGetHoppingFunction()})}})}onMessageSource(){const e=this.getEngine();e.TUIStore.watch(c.CHAT,{messageSource:t=>{const s=this.getStoreData(c.CONV,"currentConversationID");if(!s||t&&t.conversationID!==s)return;if(D(t))return this.hoppingConfigMap.clear(),e.TUIStore.update(c.CHAT,"messageList",[]),e.TUIStore.update(c.CHAT,"nextReqMessageID",""),e.TUIStore.update(c.CHAT,"isCompleted",!1),void this.getMessageList();const n=this.getStoreData(c.CHAT,"messageList");n&&n.find(i=>t&&i.ID===t.ID)||(this.isSwitching?this.delayGetHoppingFunction=this.getMessageListHoppingForDown:this.getMessageListHoppingForDown())}})}getMessageListHoppingForDown(){const e=this.getStoreData(c.CHAT,"messageList"),{conversationID:t,sequence:s,time:n,ID:i}=this.getStoreData(c.CHAT,"messageSource");if(e&&e.find(u=>i&&u.ID===i))return;const a=this.getEngine();a.TUIStore.update(c.CHAT,"messageList",[]),a.TUIStore.update(c.CHAT,"nextReqMessageID",""),a.TUIStore.update(c.CHAT,"isCompleted",!1),this.getMessageListHopping({conversationID:t,sequence:s,time:n,direction:1})}getStoreData(e,t){return this.getEngine().TUIStore.getData(e,t)}sendMessage(e,t){this.updateMessageList([e],"send");const s=this.getEngine().chat.sendMessage(e,t);return this.getResponse(s)}getResponse(e,t=!0,s=!0){return e.then(n=>{const i=n.data.messageList?n.data.messageList:[n.data.message];return t&&this.updateMessageList(i,"edit"),n}).catch(n=>{var i;return s&&(!((i=n==null?void 0:n.data)===null||i===void 0)&&i.message)&&this.updateMessageList([n.data.message],"edit"),Promise.reject(n)})}updateMessageList(e,t=""){if(this.getStoreData(c.CHAT,"messageSource")&&t!=="unshift"&&t!=="edit")return;const s=this.getStoreData(c.CHAT,"messageList"),n=this.updateTargetMessageList(e,s,t);this.getEngine().TUIStore.update(c.CHAT,"messageList",n)}updateTargetMessageList(e,t,s=""){const n=this.getStoreData(c.CONV,"currentConversationID");let i=e.filter(g=>g.conversationID===n);if(i=this.handleC2CCallSignaling(i),!s||i.length===0)return t;const a=t||[];let u=[];if(s==="send"||s==="push"||s==="received"){const g=this.getStoreData(c.CHAT,"userInfo");Object.keys(g).length>0&&this.updateLocalMessage(i,g)}const o=this.getStoreData(c.APP,"enableAutoMessageRead");switch(s){case"edit":for(const g of t){const l=i.find(p=>p.ID===g.ID);u.push(l||g)}break;case"resend":u=a.filter(g=>g.ID!==i[0].ID).concat(i);break;case"send":u=a.concat(this.typingHandler.filterTypingMessage(i));break;case"push":u=a.concat(this.typingHandler.filterTypingMessage(i)),this.getEngine().chat.setMessageRead({conversationID:n});break;case"received":u=a.concat(this.typingHandler.filterTypingMessage(i)),u=this.sortMessageList(u),o&&this.getEngine().chat.setMessageRead({conversationID:n});break;case"unshift":u=i.filter(g=>a.length===0||!a.find(l=>l.ID===g.ID)),u.push(...a),u=this.sortMessageList(u)}return u}enterTypingState(){this.getStoreData(c.APP,"enableTyping")&&this.sendTyping(!0)}leaveTypingState(){this.getStoreData(c.APP,"enableTyping")&&this.sendTyping(!1)}sendTyping(e){const t=this.getEngine(),s=this.getStoreData(c.CONV,"currentConversationID");if(!s.startsWith(t.TYPES.CONV_C2C))return;const n=s.replace(t.TYPES.CONV_C2C,"");if(e){const i=this.getStoreData(c.CHAT,"messageList").filter(u=>u.flow==="in");if(i.length===0)return;const a=1e3*i[i.length-1].time;if(new Date().getTime()-a>3e4)return}this.typingHandler.sendTyping(e,n)}quoteMessage(e){var t;return this.getEngine().TUIStore.update(c.CHAT,"quoteMessage",{message:e,type:"quote"}),(t=this.getEngine().TUIReport)===null||t===void 0||t.reportFeature(205),e}replyMessage(e){return this.getEngine().TUIStore.update(c.CHAT,"quoteMessage",{message:e,type:"reply"}),e}getCurrentConvInfo(){const{conversationID:e="",type:t}=this.getStoreData(c.CONV,"currentConversation")||{};return{to:e.replace(t,""),conversationType:t}}t(e){return this.getEngine().TUITranslate.t(e)||e}getMessageAbstractAndType(e){var t,s;const n=this.getEngine(),i={abstract:"",type:0};switch(e.type){case n.TYPES.MSG_TEXT:i.abstract=(t=e==null?void 0:e.payload)===null||t===void 0?void 0:t.text,i.type=1;break;case n.TYPES.MSG_CUSTOM:i.abstract="[自定义消息]",i.type=2;break;case n.TYPES.MSG_IMAGE:i.abstract="[图片]",i.type=3;break;case n.TYPES.MSG_AUDIO:i.abstract="[语音]",i.type=4;break;case n.TYPES.MSG_VIDEO:i.abstract="[视频]",i.type=5;break;case n.TYPES.MSG_FILE:i.abstract="[文件]",i.type=6;break;case n.TYPES.MSG_LOCATION:i.type=7;break;case n.TYPES.MSG_FACE:i.abstract="[表情]",i.type=8;break;case n.TYPES.MSG_GRP_TIP:i.type=9;break;case n.TYPES.MSG_MERGER:i.abstract=(s=e==null?void 0:e.payload)===null||s===void 0?void 0:s.title,i.type=10}return i}genMessageReply(e,t){if(t!=="reply"&&t!=="quote")return{};const{abstract:s,type:n}=this.getMessageAbstractAndType(e),i={messageAbstract:s,messageSender:e.nick||e.from,messageID:e.ID},a=Object.assign(Object.assign({},i),{messageType:n,messageTime:e==null?void 0:e.time,messageSequence:e==null?void 0:e.sequence,version:1});if(t==="reply"&&(a.messageRootID=e.ID,e.cloudCustomData)){const u=_(e.cloudCustomData);u.messageReply&&u.messageReply.messageRootID&&(a.messageRootID=u.messageReply.messageRootID)}return{messageReply:a,messageReplyRoot:i}}getMessageInfo(e,t,s){const{messageReply:n,messageReplyRoot:i}=this.genMessageReply(t,s),a=e.cloudCustomData?_(e.cloudCustomData):{};let u;if(a.messageReply?a.messageReply=Object.assign(Object.assign({},n),a.messageReply):a.messageReply=n,s==="reply"){const{messageRootID:g}=n;u=this.getEngine().chat.findMessage(g);const l=u!=null&&u.cloudCustomData?_(u.cloudCustomData):{};l.messageReplies||(l.messageReplies={}),o=l.messageReplies.replies,(typeof Array.isArray=="function"?Array.isArray(o):Object.prototype.toString.call(o).match(/^\[object (.*)\]$/)[1].toLowerCase()==="array")||(l.messageReplies.replies=[]),l.messageReplies.replies.push(i),u.cloudCustomData=JSON.stringify(l)}var o;return{cloudCustomData:JSON.stringify(a),rootMessage:u}}sendTextMessage(e,t){const s=this.getEngine(),{message:n,type:i}=this.getStoreData(c.CHAT,"quoteMessage");let a={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};n&&(a=this.getMessageInfo(e,n,i));const u=s.chat.createTextMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:a.cloudCustomData}));return this.sendMessage(u,t).then(o=>(a.rootMessage&&this.modifyMessage(a.rootMessage),s.TUIStore.reset(c.CHAT,["quoteMessage"],!0),o))}sendTextAtMessage(e,t){const s=this.getEngine(),{message:n,type:i}=this.getStoreData(c.CHAT,"quoteMessage");let a={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};n&&(a=this.getMessageInfo(e,n,i));const u=s.chat.createTextAtMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:a.cloudCustomData}));return this.sendMessage(u,t).then(o=>(a.rootMessage&&this.modifyMessage(a.rootMessage),s.TUIStore.reset(c.CHAT,["quoteMessage"],!0),o))}sendImageMessage(e,t){const s=this.getEngine().chat.createImageMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:n=>{this.onProgress(s.ID,n)}}));return this.sendMessage(s,t)}sendAudioMessage(e,t){const s=this.getEngine().chat.createAudioMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:n=>{this.onProgress(s.ID,n)}}));return this.sendMessage(s,t)}sendVideoMessage(e,t){const s=this.getEngine().chat.createVideoMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:n=>{this.onProgress(s.ID,n)}}));return this.sendMessage(s,t)}sendCustomMessage(e,t){const s=this.getEngine().chat.createCustomMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(s,t)}sendFaceMessage(e,t){const s=this.getEngine().chat.createFaceMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(s,t)}sendFileMessage(e,t){const s=this.getEngine().chat.createFileMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:n=>{this.onProgress(s.ID,n)}}));return this.sendMessage(s,t)}sendLocationMessage(e,t){const s=this.getEngine().chat.createLocationMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(s,t)}onProgress(e,t){const s=this.getEngine().TUIStore.getMessageModel(e);s&&(t-s.progress>=.1||t===1)&&(s.progress=t,this.updateMessageList([s],"edit"))}setAbstractList(e){const t=this.getEngine(),s=e.nick||e.from;let n="";switch(e.type){case t.TYPES.MSG_TEXT:n=e.payload.text||"",n.length>20&&(n=n.slice(0,20));break;case t.TYPES.MSG_MERGER:n=`${this.t("TUIChat.[聊天记录]")}`;break;case t.TYPES.MSG_IMAGE:n=`${this.t("TUIChat.[图片]")}`;break;case t.TYPES.MSG_AUDIO:n=`${this.t("TUIChat.[音频]")}`;break;case t.TYPES.MSG_VIDEO:n=`${this.t("TUIChat.[视频]")}`;break;case t.TYPES.MSG_CUSTOM:n=`${this.t("TUIChat.[自定义消息]")}`;break;case t.TYPES.MSG_FILE:n=`${this.t("TUIChat.[文件]")}`;break;case t.TYPES.MSG_FACE:n=`${this.t("TUIChat.[动画表情]")}`}return`${s}: ${n}`}genMergerForwardPayload(e,t){const{abstractList:s=[],compatibleText:n="",title:i}=t;return s.length===0&&e.forEach(a=>{s.push(this.setAbstractList(a))}),{messageList:e,title:i,abstractList:s,compatibleText:n||this.t("TUIChat.请升级IMSDK到v2.10.1或更高版本查看此消息")}}genSendMergerForwardMessage(e){const{conversationList:t,messageList:s,params:n,mergeInfo:i,sendMessageOptions:a}=e,u=[];for(let o=0;o<t.length;o++){const{conversationID:g,type:l}=t[o],p=Object.assign({to:g.replace(`${l}`,""),conversationType:l,payload:this.genMergerForwardPayload(s,i)},n),h=this.getEngine().chat.createMergerMessage(p);u.push(this.sendMessage(h,a))}return u}genTitle(e,t){const{nick:s,from:n,to:i}=e;return`${s||n} ${this.t("TUIChat.和")} ${t||i} ${this.t("TUIChat.的聊天记录")}`}genMergeInfo(e){var t;return j(this,void 0,void 0,function*(){const{messageList:s,mergeInfo:n}=e;if(n.title)return n;if(s[0].conversationType===this.getEngine().TYPES.CONV_GROUP)return n.title=this.t("TUIChat.群聊的聊天记录"),n;try{const{data:i=[]}=yield this.getEngine().TUIUser.getUserProfile({userIDList:[s[0].to]});n.title=this.genTitle(s[0],(t=i[0])===null||t===void 0?void 0:t.nick)}catch{n.title=this.genTitle(s[0])}return n})}sendMergerForwardMessage(e){return j(this,void 0,void 0,function*(){return e.mergeInfo=yield this.genMergeInfo(e),Promise.all(this.genSendMergerForwardMessage(e))})}getOriginMessageList(e){return e.map(t=>t instanceof Me?t.getMessage():t)}sendForwardMessage(e,t,s){t=this.getOriginMessageList(t);const n=s||{},{needMerge:i=!1,params:a={},mergeInfo:u={}}=n,o=G(n,["needMerge","params","mergeInfo"]);if(i)return this.sendMergerForwardMessage({conversationList:e,messageList:t,params:a,mergeInfo:u,sendMessageOptions:o});const g=[];for(let l=0;l<e.length;l++){const{conversationID:p,type:h}=e[l],f=Object.assign({to:p.replace(`${h}`,""),conversationType:h},a),m=o[p]||o;for(let E=0;E<t.length;E++){Reflect.set(f,"payload",t[E]);const d=this.getEngine().chat.createForwardMessage(f);g.push(this.sendMessage(d,m))}}return Promise.all(g)}revokeMessage(e){const t=this.getEngine().chat.revokeMessage(e);return this.getResponse(t,!0,!1)}resendMessage(e){e.status="unSend",this.updateMessageList([e],"resend");const t=this.getEngine().chat.resendMessage(e);return this.getResponse(t,!0,!0)}deleteMessage(e){const t=this.getEngine().chat.deleteMessage(e);return this.getResponse(t,!0,!1)}setMessageExtensions(e,t){return this.getEngine().chat.setMessageExtensions(e,t)}getMessageExtensions(e){return this.getEngine().chat.getMessageExtensions(e)}deleteMessageExtensions(e,t){return this.getEngine().chat.deleteMessageExtensions(e,t)}modifyMessage(e){const t=this.getEngine().chat.modifyMessage(e);return this.getResponse(t,!0,!1).catch(s=>{const{code:n=0,data:i={}}=s.code;throw n===ye.MSG_MODIFY_CONFLICT?console.warn(`${be.MSG_MODIFY_CONFLICT} data.message: ${i==null?void 0:i.message}`):n===ye.MSG_MODIFY_DISABLED_IN_AVCHATROOM?console.warn(be.MSG_MODIFY_DISABLED_IN_AVCHATROOM):n===ye.MODIFY_MESSAGE_NOT_EXIST&&console.warn(be.MODIFY_MESSAGE_NOT_EXIST),s})}getMessageList(e={conversationID:this.getStoreData(c.CONV,"currentConversationID"),nextReqMessageID:this.getStoreData(c.CHAT,"nextReqMessageID")}){const t=this.getEngine();if(!t.chat.isReady())return Promise.reject({code:q.GET_MSG_LIST_ERROR,message:z.GET_MSG_LIST_ERROR});if(this.getStoreData(c.CHAT,"isCompleted"))return Promise.resolve({data:{messageList:[],nextReqMessageID:"",isCompleted:!0}});const s=this.getStoreData(c.CHAT,"messageSource"),n=this.hoppingConfigMap.get("nextMessageSeq"),i=this.hoppingConfigMap.get("nextMessageTime"),a=n||i;return s&&s.conversationID===(e==null?void 0:e.conversationID)&&a?this.getMessageListHopping():t.chat.getMessageList(e).then(u=>{var o;const{messageList:g,nextReqMessageID:l,isCompleted:p}=u.data,h=this.getStoreData(c.CHAT,"userInfo");Object.keys(h).length>0&&this.updateLocalMessage(g,h),this.updateMessageList(g,"unshift"),t.TUIStore.update(c.CHAT,"nextReqMessageID",l),t.TUIStore.update(c.CHAT,"isCompleted",p);const f=(o=g[0])===null||o===void 0?void 0:o.conversationID,{operationType:m=0}=this.getEngine().TUIStore.getConversationModel(f)||{};return m===0&&(this.getMessageReactions({messageList:g}),this.readReceiptHandler.getMessageReadReceiptList(g)),u}).catch(u=>Promise.reject(u))}getMessageListHopping(e){var t;e===void 0&&(e={conversationID:(t=this.getStoreData(c.CHAT,"messageSource"))===null||t===void 0?void 0:t.conversationID,sequence:this.hoppingConfigMap.get("nextMessageSeq"),time:this.hoppingConfigMap.get("nextMessageTime")});const s=this.getEngine();return s.chat.getMessageListHopping(e).then(n=>{const{messageList:i,nextMessageSeq:a,nextMessageTime:u,isCompleted:o}=n.data,g=e.direction===1?e.sequence:a,l=e.direction===1?e.time:u;return this.updateMessageList(i,"unshift"),this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.set("nextMessageSeq",g),this.hoppingConfigMap.set("nextMessageTime",l),s.TUIStore.update(c.CHAT,"isCompleted",o),n}).catch(n=>Promise.reject(n))}sendMessageReadReceipt(e){return this.readReceiptHandler.sendMessageReadReceipt(e)}getGroupMessageReadMemberList(e){return this.readReceiptHandler.getGroupMessageReadMemberList(e).then(t=>{const{isCompleted:s,cursor:n,messageID:i,unreadUserIDList:a,readUserIDList:u}=t.data,o={code:0,data:{cursor:n,isCompleted:s,messageID:i,unreadUserInfoList:[],readUserInfoList:[]}},g=[...a,...u];return g.length===0?o:this.getEngine().TUIUser.getUserProfile({userIDList:g}).then(l=>(a.length>0?l.data.forEach(p=>{const{userID:h,nick:f="",avatar:m=""}=p;o.data.unreadUserInfoList.push({userID:h,nick:f,avatar:m})}):l.data.forEach(p=>{const{userID:h,nick:f="",avatar:m=""}=p;o.data.readUserInfoList.push({userID:h,nick:f,avatar:m})}),o))})}downloadMergedMessages(e){return this.getEngine().chat.downloadMergerMessage(e)}setTranslationLanguage(e){this.getEngine().TUIStore.update(c.USER,"targetLanguage",e)}translateText(e){const t=this.getStoreData(c.USER,"targetLanguage"),s=Object.assign({targetLanguage:t,sourceLanguage:"auto"},e);return this.getEngine().chat.translateText(s)}searchCloudMessages(e){return this.getEngine().TUISearch.searchCloudMessages(e)}addMessageReaction(e,t){return this.getEngine().chat.addMessageReaction(e.getMessage(),t)}removeMessageReaction(e,t){return this.getEngine().chat.removeMessageReaction(e.getMessage(),t)}getMessageReactions(e){const{messageList:t=[]}=e,s=this.getStoreData(c.APP,"enabledEmojiPlugin");console.log(`TUIChatService.getMessageReactions enabledEmojiPlugin:${s} messageList length:${t.length}`),s&&t.length>0&&this.getEngine().chat.getMessageReactions(e).then(n=>{const i=n.data.resultList||n.data;this.updateMessageReactionList(i)}).catch(()=>{})}getAllUserListOfMessageReaction(e){var t;return this.getEngine().chat.getAllUserListOfMessageReaction(Object.assign(Object.assign({},e),{message:(t=e==null?void 0:e.message)===null||t===void 0?void 0:t.getMessage()}))}updateMessageReactionList(e){const t=[];e.forEach(s=>{const{messageID:n,reactionList:i}=s,a=this.getEngine().TUIStore.getMessageModel(n);if(a){const u=[];for(let o=0;o<i.length;o++){let g=!0;for(let l=0;l<a.reactionList.length;l++)if(i[o].reactionID===a.reactionList[l].reactionID){a.reactionList[l]=i[o],g=!1;break}g&&u.push(i[o])}a.reactionList.push(...u),u.length=0,t.push(a)}}),t.length>0&&this.updateMessageList(t,"edit")}convertVoiceToText(e){const{message:t,language:s="zh"}=e,n=t.getMessage();return this.getEngine().chat.convertVoiceToText({message:n,language:s})}clearHistoryMessage(e){const t=this.getEngine();return t.chat.clearHistoryMessage(e).then(s=>(t.TUIStore.update(c.CHAT,"messageList",[]),t.TUIStore.update(c.CHAT,"nextReqMessageID",""),t.TUIStore.update(c.CHAT,"isCompleted",!1),s))}updateMessageInfo(e){const t=this.getStoreData(c.CHAT,"userInfo");this.getEngine().TUIStore.update(c.CHAT,"userInfo",Object.assign(t,e));const s=this.getStoreData(c.CHAT,"messageList");s.length>0&&this.updateLocalMessage(s,e)&&this.getEngine().TUIStore.update(c.CHAT,"messageList",s)}updateLocalMessage(e,t){let s=!1;return e.forEach(n=>{if(t[n.from]){const{nick:i,nameCard:a,avatar:u}=t[n.from];i&&(n.nick=i,s=!0),a&&(n.nameCard=a,s=!0),u&&(n.avatar=u,s=!0)}}),s}handleC2CCallSignaling(e=[]){var t,s,n,i,a;const u=[],o=this.getEngine(),g=o.getMyUserID();for(let l=0;l<e.length;l++){const p=e[l],{conversationType:h,type:f,payload:m}=p;let E=!0;if(h===o.TYPES.CONV_C2C&&f===o.TYPES.MSG_CUSTOM&&o.chat.getSignalingInfo(p)){const d=_(m.data);if((d==null?void 0:d.businessID)===1){const T=_(d.data);if(E=!(p._isExcludedFromUnreadCount&&p._isExcludedFromLastMessage),E&&((t=T==null?void 0:T.data)===null||t===void 0?void 0:t.consumed)!==!0){let S=(s=T==null?void 0:T.data)===null||s===void 0?void 0:s.inviter;(T==null?void 0:T.line_busy)!=="line_busy"&&((n=T==null?void 0:T.data)===null||n===void 0?void 0:n.message)!=="lineBusy"||(S=d.inviter);const v=JSON.parse(JSON.stringify(p)),{from:b,to:y}=v;if(S!==g&&v.from===g){const I=this.getStoreData(c.CONV,"currentConversation");v.from=y,v.to=b,v.flow="in",v.avatar=((i=I==null?void 0:I.userProfile)===null||i===void 0?void 0:i.avatar)||""}if(S===g&&v.from!==g){const I=this.getStoreData(c.USER,"userProfile");v.from=y,v.to=b,v.flow="out",v.avatar=I==null?void 0:I.avatar}console.log(`${this.serv}.handleC2CCallSignaling myUserID:${g} callSignaling.inviter:${d.inviter} customData.data.inviter:${(a=T==null?void 0:T.data)===null||a===void 0?void 0:a.inviter}`),u.push(v);continue}}}u.push(p)}return u}sortMessageList(e){const{conversationType:t}=e[0];if(t===this.getEngine().TYPES.CONV_C2C)return e.sort((n,i)=>n.time-i.time);const s=e.filter(n=>n.status==="success").sort((n,i)=>n.sequence-i.sequence);for(let n=0;n<e.length;n++)e[n].status!=="success"&&s.splice(n,0,e[n]);return s}}class he extends F{constructor(){super(),this.groupMap=new Map}static getInstance(){return he.instance||(he.instance=new he),he.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.GROUP_LIST_UPDATED,this.onGroupListUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.GROUP_ATTRIBUTES_UPDATED,this.onGroupAttributesUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.GROUP_COUNTER_UPDATED,this.onGroupCounterUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),this.getGroupInitData()}onGroupListUpdated(e){const t=this.getEngine();t.TUIStore.update(c.GRP,"groupList",e);const s=t.TUIStore.getData(c.GRP,"currentGroupID");e.forEach(n=>{n.groupID===s&&t.TUIStore.update(c.GRP,"currentGroup",n)})}onGroupAttributesUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(c.GRP,"currentGroupID");let n=t.TUIStore.getData(c.GRP,"groupList");const{groupID:i,groupAttributes:a}=e;s===i&&t.TUIStore.update(c.GRP,"currentGroupAttributes",a),n=n.map(u=>(u.groupID===i&&(u.groupAttributes=a),u)),t.TUIStore.update(c.GRP,"groupList",n)}onGroupCounterUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(c.GRP,"currentGroupID"),n=t.TUIStore.getData(c.GRP,"currentGroupCounters")||{};let i=t.TUIStore.getData(c.GRP,"groupList");const{groupID:a,key:u,value:o}=e;s===a&&(n[u]=o,t.TUIStore.update(c.GRP,"currentGroupCounters",n)),i=i.map(g=>(g.groupID===a&&(g.groupCounters=Object.assign(Object.assign({},g.groupCounters),{[u]:o})),g)),t.TUIStore.update(c.GRP,"groupList",i)}onMessageReceived(e){const t=this.getEngine(),s=[];e.forEach(n=>{if(n.type===t.TYPES.MSG_GRP_TIP){const{payload:i}=n,{operationType:a,userIDList:u}=i;switch(a){case t.TYPES.GRP_TIP_MBR_JOIN:this.addMemberList(u);break;case t.TYPES.GRP_TIP_MBR_QUIT:case t.TYPES.GRP_TIP_MBR_KICKED_OUT:this.removeMemberList(u);break;case t.TYPES.GRP_TIP_MBR_SET_ADMIN:case t.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:this.updateGroupMember(u);break;case t.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:break;case t.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:case t.TYPES.GRP_TIP_BAN_AVCHATROOM_MEMBER:case t.TYPES.GRP_TIP_UNBAN_AVCHATROOM_MEMBER:this.updateGroupMember(u)}}n.type===t.TYPES.MSG_GRP_SYS_NOTICE&&s.push(n)}),s.length>0&&t.TUIStore.update(c.GRP,"groupSystemNoticeList",s)}getGroupInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getGroupList().then(t=>{const{groupList:s=[]}=t.data;console.log(`TUIGroupService.init, getGroupList count:${s.length}`),s.length>0&&this.onGroupListUpdated(s)})}updateGroupMember(e){return j(this,void 0,void 0,function*(){const t=this.getEngine().TUIStore.getData(c.GRP,"currentGroupID");if(t){const s=yield this.getGroupMemberProfile({groupID:t,userIDList:e}),{memberList:n}=s.data;this.updateMemberList(n)}})}resetCurrentStore(){this.getEngine().TUIStore.reset(c.GRP,["currentGroupID","currentGroup","currentGroupAttributes","currentGroupCounters","currentGroupMemberList"],!0)}switchGroup(e){return j(this,void 0,void 0,function*(){const t=this.getEngine();t.TUIStore.update(c.GRP,"offset",0),t.TUIStore.update(c.GRP,"isCompleted",!1);const s=t.TUIStore.getConversationModel(`GROUP${e}`);if((s==null?void 0:s.operationType)>0){const u=t.TUIStore.getData(c.GRP,"currentGroup");return Promise.resolve(u)}const n=t.TUIStore.getData(c.GRP,"currentGroupID");if(!e)return this.resetCurrentStore(),Promise.resolve({});if(n===e){const u=t.TUIStore.getData(c.GRP,"currentGroup");return Promise.resolve(u)}this.resetCurrentStore(),t.TUIStore.update(c.GRP,"currentGroupID",e);try{yield this.getGroupInfo(e)}catch(u){Promise.reject(u)}const i=setTimeout(()=>{this.groupMap.delete(e),clearTimeout(i)},5e3),a=t.TUIStore.getData(c.GRP,"currentGroup");return Promise.resolve(a)})}getGroupInfo(e){return j(this,void 0,void 0,function*(){const t=this.getEngine(),s=this.groupMap.get(e);if(s)return this.updateMemberList((s==null?void 0:s.memberList)||[]),t.TUIStore.update(c.GRP,"currentGroup",s.group),t.TUIStore.update(c.GRP,"currentGroupAttributes",s.groupAttributes||{}),void t.TUIStore.update(c.GRP,"currentGroupCounters",s.counters||{});const n={group:{},memberList:[],groupAttributes:void 0,counters:void 0},{data:{group:i}}=yield this.getGroupProfile({groupID:e});n.group=i;const{data:{memberList:a}}=yield this.getGroupMemberList({groupID:e});n.memberList=a;const u=yield this.getGroupAttributes({groupID:e,keyList:[]}),{groupAttributes:o}=u.data;n.groupAttributes=o,t.TUIStore.update(c.GRP,"currentGroupAttributes",o);try{const g=yield this.getGroupCounters({groupID:e,keyList:[]}),{counters:l}=g.data;n.counters=l,t.TUIStore.update(c.GRP,"currentGroupCounters",l)}catch(g){console.warn(g==null?void 0:g.message)}this.groupMap.set(e,n)})}getGroupProfile(e){const t=this.getEngine();return t.chat.getGroupProfile(e).then(s=>j(this,void 0,void 0,function*(){if(t.TUIStore.getData(c.GRP,"currentGroupID")===e.groupID){const{group:n}=s.data;t.TUIStore.update(c.GRP,"currentGroup",n)}return s}))}updateGroupProfile(e){return this.getEngine().chat.updateGroupProfile(e)}createGroup(e){return this.getEngine().chat.createGroup(e)}dismissGroup(e){return this.getEngine().chat.dismissGroup(e)}searchGroupByID(e){const t=this.getEngine();return t.chat.searchGroupByID(e).then(s=>{const{group:n}=s.data,i=t.TUIStore.getData(c.GRP,"groupList");return s.data.group.isJoinedGroup=i.some(a=>a.groupID===n.groupID),s})}joinGroup(e){return this.getEngine().chat.joinGroup(e)}quitGroup(e){return this.getEngine().chat.quitGroup(e)}getGroupApplicationList(){return this.getEngine().chat.getGroupApplicationList()}handleGroupApplication(e){return this.getEngine().chat.handleGroupApplication(e)}getGroupOnlineMemberCount(e){return this.getEngine().chat.getGroupOnlineMemberCount(e)}changeGroupOwner(e){return this.getEngine().chat.changeGroupOwner(e)}initGroupAttributes(e){return this.getEngine().chat.initGroupAttributes(e)}setGroupAttributes(e){return this.getEngine().chat.setGroupAttributes(e)}deleteGroupAttributes(e){return this.getEngine().chat.deleteGroupAttributes(e)}getGroupAttributes(e){return this.getEngine().chat.getGroupAttributes(e)}setGroupCounters(e){return this.getEngine().chat.setGroupCounters(e)}increaseGroupCounter(e){return this.getEngine().chat.increaseGroupCounter(e)}decreaseGroupCounter(e){return this.getEngine().chat.decreaseGroupCounter(e)}getGroupCounters(e){return this.getEngine().chat.getGroupCounters(e)}updateMemberList(e){const t=this.getEngine(),s=[...(t.TUIStore.getData(c.GRP,"currentGroupMemberList")||[]).filter(n=>!e.find(i=>i.userID===n.userID)),...e];t.TUIStore.update(c.GRP,"currentGroupMemberList",s)}addMemberList(e){return j(this,void 0,void 0,function*(){const t=this.getEngine().TUIStore.getData(c.GRP,"currentGroupID");if(t)try{const s=yield this.getGroupMemberProfile({groupID:t,userIDList:e}),{memberList:n}=s.data;this.updateMemberList(n)}catch{const n=e.map(i=>({userID:i,avatar:"",nick:"",role:"",joinTime:0,nameCard:"",muteUntil:0,memberCustomField:[]}));this.updateMemberList(n)}})}removeMemberList(e){const t=this.getEngine(),s=t.TUIStore.getData(c.GRP,"currentGroupMemberList").filter(n=>e.indexOf(n.userID)===-1);t.TUIStore.update(c.GRP,"currentGroupMemberList",s)}getGroupMemberList(e){const t=this.getEngine();if(D(e.offset)){const s=t.TUIStore.getData(c.GRP,"offset");e.offset=s}return t.chat.getGroupMemberList(e).then(s=>{if(t.TUIStore.getData(c.GRP,"currentGroupID")===e.groupID){const{memberList:n,offset:i=0}=s.data;this.updateMemberList(n),t.TUIStore.update(c.GRP,"offset",i),i===0&&t.TUIStore.update(c.GRP,"isCompleted",!0)}return s})}getGroupMemberProfile(e){return this.getEngine().chat.getGroupMemberProfile(e)}addGroupMember(e){const t=this.getEngine();return t.chat.addGroupMember(e).then(s=>j(this,void 0,void 0,function*(){if(t.TUIStore.getData(c.GRP,"currentGroupID")===e.groupID){const{successUserIDList:n,group:i}=s.data;t.TUIStore.update(c.GRP,"currentGroup",i),this.addMemberList(n)}return s}))}deleteGroupMember(e){const t=this.getEngine();return t.chat.deleteGroupMember(e).then(s=>{if(t.TUIStore.getData(c.GRP,"currentGroupID")===e.groupID){const{userIDList:n,group:i}=s.data;this.removeMemberList(n),t.TUIStore.update(c.GRP,"currentGroup",i)}return s})}setGroupMemberMuteTime(e){return this.getEngine().chat.setGroupMemberMuteTime(e)}setGroupMemberRole(e){return this.getEngine().chat.setGroupMemberRole(e)}setGroupMemberNameCard(e){return this.getEngine().chat.setGroupMemberNameCard(e)}setGroupMemberCustomField(e){return this.getEngine().chat.setGroupMemberCustomField(e)}markGroupMemberList(e){return this.getEngine().chat.markGroupMemberList(e)}}class pe extends F{constructor(){super(),this.tobeUpdatedFriendGroupList=void 0}static getInstance(){return pe.instance||(pe.instance=new pe),pe.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.FRIEND_GROUP_LIST_UPDATED,this.onFriendGroupListUpdated.bind(this)),this.getFriendInitData()}onFriendListUpdated(e){this.getEngine().TUIStore.update(c.FRIEND,"friendList",e),this.updatedFriendGroupList(e,this.tobeUpdatedFriendGroupList)}onFriendApplicationListUpdated(e){const{friendApplicationList:t,unreadCount:s=0}=e,n=this.getEngine();n.TUIStore.update(c.FRIEND,"friendApplicationList",t),n.TUIStore.update(c.FRIEND,"friendApplicationUnreadCount",s)}onFriendGroupListUpdated(e){const t=this.getEngine().TUIStore.getData(c.FRIEND,"friendList");t.length>0?this.updatedFriendGroupList(t,e):this.tobeUpdatedFriendGroupList=e}updatedFriendGroupList(e,t){const s=this.getEngine();if(t&&t.length>0){const n=t.map(i=>{const{userIDList:a}=i,u=G(i,["userIDList"]),o=a.map(g=>e.find(l=>l.userID===g));return Object.assign(Object.assign({},u),{friendList:o})});s.TUIStore.update(c.FRIEND,"friendGroupList",n),this.tobeUpdatedFriendGroupList=void 0}}getFriendInitData(){const e=this.getEngine();e.chat.isReady()&&(e.chat.getFriendList().then(t=>{const s=t.data||[];console.log(`TUIFriendService.init, getFriendList count:${s.length}`),s.length>0&&this.onFriendListUpdated(s)}),e.chat.getFriendGroupList().then(t=>{const s=t.data||[];console.log(`TUIFriendService.init, getFriendGroupList count:${s.length}`),s.length>0&&this.onFriendGroupListUpdated(s)}),e.chat.getFriendApplicationList().then(t=>{this.onFriendApplicationListUpdated(t.data)}))}getFriendList(){return this.getEngine().chat.getFriendList()}getFriendRemark(e){const t=this.getEngine().TUIStore.getData(c.FRIEND,"friendList"),s={};return e.forEach(n=>{for(let i=0;i<t.length;i++)t[i].userID!==n||(s[n]=t[i].remark)}),s}addFriend(e){return this.getEngine().chat.addFriend(e)}deleteFriend(e){return this.getEngine().chat.deleteFriend(e)}checkFriend(e){return this.getEngine().chat.checkFriend(e)}getFriendProfile(e){return this.getEngine().chat.getFriendProfile(e)}updateFriend(e){return this.getEngine().chat.updateFriend(e)}acceptFriendApplication(e){return this.getEngine().chat.acceptFriendApplication(e)}refuseFriendApplication(e){return this.getEngine().chat.refuseFriendApplication({userID:e})}deleteFriendApplication(e){return this.getEngine().chat.deleteFriendApplication(e)}setFriendApplicationRead(){return this.getEngine().chat.setFriendApplicationRead()}createFriendGroup(e){return this.getEngine().chat.createFriendGroup(e)}deleteFriendGroup(e){return this.getEngine().chat.deleteFriendGroup({name:e})}addToFriendGroup(e){return this.getEngine().chat.addToFriendGroup(e)}removeFromFriendGroup(e){return this.getEngine().chat.removeFromFriendGroup(e)}renameFriendGroup(e){return this.getEngine().chat.renameFriendGroup(e)}}class de extends F{static getInstance(){return de.instance||(de.instance=new de),de.instance}reportFeature(e,t){var s;return(s=this.getEngine().chat)===null||s===void 0?void 0:s.callExperimentalAPI("statTUIKeyFeatures",{code:e,msg:t?`${e}-${t}`:""})}}(function(r){r.MESSAGE="message",r.CHAT_MESSAGE="chat_message",r.USER="user",r.GROUP="group"})(U||(U={})),(function(r){r.MSG_TEXT="TIMTextElem",r.MSG_IMAGE="TIMImageElem",r.MSG_SOUND="TIMSoundElem",r.MSG_FILE="TIMFileElem",r.MSG_VIDEO="TIMVideoFileElem",r.MSG_LOCATION="TIMLocationElem",r.MSG_CUSTOM="TIMCustomElem",r.MSG_MERGER="TIMRelayElem"})(Ct||(Ct={})),(function(r){r.GRP_WORK="Private",r.GRP_PUBLIC="Public",r.GRP_MEETING="ChatRoom",r.GRP_COMMUNITY="Community"})(Ot||(Ot={}));class fe extends F{constructor(){super(),this.resultKeyMap={[U.MESSAGE]:"searchMessagesResult",[U.CHAT_MESSAGE]:"searchChatMessagesResult",[U.USER]:"searchUserResult",[U.GROUP]:"searchGroupResult"},this.paramsKeyMap={[U.MESSAGE]:"searchMessageParams",[U.CHAT_MESSAGE]:"searchChatMessageParams",[U.USER]:"searchUserParams",[U.GROUP]:"searchGroupParams"}}static getInstance(){return fe.instance||(fe.instance=new fe),fe.instance}getStoreData(e,t){return this.getEngine().TUIStore.getData(e,t)}handleSearchResult(e,t){const{resultList:s}=this.getStoreData(c.SEARCH,this.resultKeyMap[e]),{cursor:n,searchResultList:i,params:a,totalCount:u}=t,o=[];if(e===U.CHAT_MESSAGE){const{conversation:g}=s[0]||{},{conversation:l}=i[0]||{};(g==null?void 0:g.conversationID)===(l==null?void 0:l.conversationID)&&s.length===1&&(i[0].messageList=[...s[0].messageList,...i[0].messageList]),o.push(...i)}else o.push(...s,...i);this.getEngine().TUIStore.update(c.SEARCH,this.resultKeyMap[e],{resultList:o,params:a,hasMore:!!n,cursor:n,totalCount:u})}searchParamsValidate(e,t){const s=this.getStoreData(c.SEARCH,this.paramsKeyMap[e]),{cursor:n}=s,i=G(s,["cursor"]),{cursor:a}=t,u=G(t,["cursor"]),o=JSON.stringify(i)===JSON.stringify(u),g=!!a;return o?o&&!g?(this.getEngine().TUIStore.reset(c.SEARCH,[this.resultKeyMap[e]]),this.getEngine().TUIStore.update(c.SEARCH,this.paramsKeyMap[e],t),!0):!(!o||!g||a===n):(this.getEngine().TUIStore.reset(c.SEARCH,[this.resultKeyMap[e]]),this.getEngine().TUIStore.update(c.SEARCH,this.paramsKeyMap[e],t),!0)}searchCloudMessages(e){const{keyword:t,keywordList:s,conversationID:n}=e,i=G(e,["keyword","keywordList","conversationID"]);let a=!0;if(a=n?this.searchParamsValidate(U.CHAT_MESSAGE,e):this.searchParamsValidate(U.MESSAGE,e),!a)return Promise.resolve();const u=this.getStoreData(c.CONV,"conversationList");return this.getEngine().chat.searchCloudMessages(Object.assign({keywordList:t?[t]:s||void 0,keywordListMatchType:"or",conversationID:n},i)).then(o=>j(this,void 0,void 0,function*(){const{searchResultList:g}=o.data;if((g==null?void 0:g.length)>0){const l=[];if(o.data.searchResultList=g.map(p=>{const{messageList:h,conversationID:f}=p,m=G(p,["messageList","conversationID"]),E=h.map(T=>new Me(T)),d=u.find(T=>T.conversationID===f);return D(d)&&l.push(te.getInstance().getConversationProfile(f)),Object.assign(Object.assign({},m),{messageList:E.sort((T,S)=>S.time-T.time),conversation:d})}),l.length>0)try{const p=yield Promise.all(l);o.data.searchResultList=g.map(h=>{const{messageList:f,conversationID:m}=h,E=G(h,["messageList","conversationID"]),d=f.map(v=>new Me(v)),{data:{conversation:T}}=p.find(v=>v.data.conversation.conversationID===m),S=new je(T);return Object.assign(Object.assign({},E),{messageList:d.sort((v,b)=>b.time-v.time),conversation:S})})}catch(p){console.log("fetch conversation error",p)}}return o.data.params=e,n?this.handleSearchResult(U.CHAT_MESSAGE,o.data):this.handleSearchResult(U.MESSAGE,o.data),o})).catch(o=>(this.getEngine().TUIStore.update(c.SEARCH,"error",o),Promise.reject(o)))}searchCloudUsers(e){const{keyword:t,keywordList:s}=e,n=G(e,["keyword","keywordList"]),i=this.getStoreData(c.FRIEND,"friendList");return this.searchParamsValidate(U.USER,e)?this.getEngine().chat.searchCloudUsers(Object.assign({keywordList:t?[t]:s||void 0,keywordListMatchType:"or"},n)).then(a=>{const{searchResultList:u}=a.data;if(u.length>0){const o=new Map(u.map(g=>[g.userID,{profile:g,relation:Q.TYPES.SNS_TYPE_NO_RELATION}]));i.forEach(g=>{const{userID:l}=g,p=o.get(l);p&&(p.relation=Q.TYPES.SNS_TYPE_BOTH_WAY)}),a.data.searchResultList=Array.from(o.values())}return a.data.params=e,this.handleSearchResult(U.USER,a.data),a}).catch(a=>(this.getEngine().TUIStore.update(c.SEARCH,"error",a),Promise.reject(a))):Promise.resolve()}searchCloudGroups(e){const{keyword:t,keywordList:s}=e,n=G(e,["keyword","keywordList"]),i=this.getStoreData(c.CONV,"conversationList"),a=this.getStoreData(c.GRP,"groupList");return this.searchParamsValidate(U.GROUP,e)?this.getEngine().chat.searchCloudGroups(Object.assign({keywordList:t?[t]:s||void 0,keywordListMatchType:"or"},n)).then(u=>{const{searchResultList:o}=u.data;return o.length>0&&(u.data.searchResultList=o.map(g=>{const l=a.find(h=>h.groupID===g.groupID),p=i.find(h=>h.conversationID===`GROUP${g.groupID}`);return{groupInfo:l||g,conversation:p}})),u.data.params=e,this.handleSearchResult(U.GROUP,u.data),u}).catch(u=>(this.getEngine().TUIStore.update(c.SEARCH,"error",u),Promise.reject(u))):Promise.resolve()}}class Js{constructor(){this.cache=[],this.middlewares=[],this.options=null}use(e){return typeof e!="function"&&console.error("middleware must be a function"),this.cache.push(e),this}next(){if(this.middlewares&&this.middlewares.length>0)return this.middlewares.shift().call(this,this.options,this.next.bind(this))}run(e){return this.middlewares=this.cache.map(t=>t),this.options=e,this.next()}}function K(r,e,t){const s=Object.create(null);Object.keys(t).forEach(n=>{if(!e[n])return;s[n]=e[n];const i=new Js;e[n]=function(){const a=Array.from(arguments);return i.use((u,o)=>r.isInited?o():Promise.reject({code:q.NOT_INIT,message:`${n} | ${z.NOT_INIT}`})).use(u=>s[n].apply(e,u)),i.run(a)}})}console.log("TUIChatEngine.VERSION:2.5.8");const C=ee.getInstance();Z.getInstance();const Ws=ue.getInstance(),Xs=ge.getInstance(),Dt=te.getInstance(),Pt=ce.getInstance(),_t=le.getInstance(),Rt=he.getInstance(),Lt=pe.getInstance(),At=de.getInstance(),jt=fe.getInstance();C.mount(A.TUIStore,Ws),C.mount(A.TUITranslate,Xs),C.mount(A.TUIConversation,Dt),C.mount(A.TUIUser,Pt),C.mount(A.TUIChat,_t),C.mount(A.TUIGroup,Rt),C.mount(A.TUIFriend,Lt),C.mount(A.TUIReport,At),C.mount(A.TUISearch,jt),K(C,C,$e),K(C,Dt,Wt),K(C,_t,Xt),K(C,Rt,Qt),K(C,Pt,Zt),K(C,Lt,es),K(C,At,$e),K(C,jt,$e);export{Ws as Q,C as X,Rt as i,_t as n,c as o,Lt as r,Pt as s,Dt as t};