@tencentcloud/chat-uikit-engine 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +28 -4
- package/index.js +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -140,6 +140,7 @@ interface IMessageModel {
|
|
|
140
140
|
};
|
|
141
141
|
revokeReason: string;
|
|
142
142
|
hasRiskContent: boolean;
|
|
143
|
+
reactionList: Array<ReactionInfo>;
|
|
143
144
|
updateProperties(options: Message): void;
|
|
144
145
|
getMessage(): Message;
|
|
145
146
|
modifyMessage(options: ModifyMessageParams): Promise<any>;
|
|
@@ -151,9 +152,6 @@ interface IMessageModel {
|
|
|
151
152
|
setMessageExtensions(extensions: Array<object>): Promise<any>;
|
|
152
153
|
deleteMessageExtensions(keyList?: Array<string>): Promise<any>;
|
|
153
154
|
getMessageExtensions(): Promise<any>;
|
|
154
|
-
addMessageReaction(emojiKey: string): Promise<any> | void;
|
|
155
|
-
deleteMessageReaction(emojiKey: string): Promise<any> | void;
|
|
156
|
-
getMessageReaction(): Object | undefined;
|
|
157
155
|
getSignalingInfo(): Record<string, any> | null;
|
|
158
156
|
getMessageContent(): Record<string, any>;
|
|
159
157
|
}
|
|
@@ -163,6 +161,8 @@ interface LoginParams {
|
|
|
163
161
|
userID: string;
|
|
164
162
|
userSig: string;
|
|
165
163
|
chat?: any;
|
|
164
|
+
TIMPush?: any;
|
|
165
|
+
pushConfig?: any;
|
|
166
166
|
TUIOfflinePush?: any;
|
|
167
167
|
offlinePushConfig?: any;
|
|
168
168
|
useUploadPlugin?: boolean;
|
|
@@ -280,6 +280,26 @@ interface GetGroupMessageReadParams {
|
|
|
280
280
|
cursor: string;
|
|
281
281
|
count: number;
|
|
282
282
|
}
|
|
283
|
+
interface GetMessageReactionsParams {
|
|
284
|
+
messageList: Array<Message>;
|
|
285
|
+
maxUserCountPerReaction?: number;
|
|
286
|
+
}
|
|
287
|
+
interface ReactionInfo {
|
|
288
|
+
reactionID: string;
|
|
289
|
+
totalUserCount: number;
|
|
290
|
+
partialUserList: Array<ReactionUserInfo>;
|
|
291
|
+
}
|
|
292
|
+
interface ReactionUserInfo {
|
|
293
|
+
userID: string;
|
|
294
|
+
nick: string;
|
|
295
|
+
avatar: string;
|
|
296
|
+
}
|
|
297
|
+
interface GetAllUserListOfMessageReactionParams {
|
|
298
|
+
message: IMessageModel;
|
|
299
|
+
reatcionID: string;
|
|
300
|
+
nextSeq: number;
|
|
301
|
+
count?: number;
|
|
302
|
+
}
|
|
283
303
|
interface ModifyMessageParams {
|
|
284
304
|
type?: TencentCloudChat.TYPES;
|
|
285
305
|
payload?: any;
|
|
@@ -604,6 +624,10 @@ interface ITUIChatService extends TUIBase {
|
|
|
604
624
|
downloadMergedMessages(message: IMessageModel): Promise<any>;
|
|
605
625
|
translateText(options: TranslateTextParams): Promise<any>;
|
|
606
626
|
searchCloudMessages(options: SearchCloudMessagesParams): Promise<any>;
|
|
627
|
+
addMessageReaction(message: IMessageModel, reactionID: string): Promise<any>;
|
|
628
|
+
removeMessageReaction(message: IMessageModel, reactionID: string): Promise<any>;
|
|
629
|
+
getMessageReactions(options: GetMessageReactionsParams): void;
|
|
630
|
+
getAllUserListOfMessageReaction(options: GetAllUserListOfMessageReactionParams): Promise<any>;
|
|
607
631
|
}
|
|
608
632
|
|
|
609
633
|
interface ITUIGroupService {
|
|
@@ -706,4 +730,4 @@ declare const tuiChat: ITUIChatService;
|
|
|
706
730
|
declare const tuiGroup: ITUIGroupService;
|
|
707
731
|
declare const tuiFriend: ITUIFriendService;
|
|
708
732
|
|
|
709
|
-
export { AcceptFriendApplicationParams, AddFriendParams, AddMemberParams, ChangGroupOwnerParams, CheckFriendParams, CountersParams, CreateGroupParams, DeleteFriendApplicationParams, DeleteFriendParams, DeleteMemberParams, ForwardMessageParams, Friend, FriendApplication, GetFriendProfileParams, GetGroupMessageReadParams, GetGroupProfileParams, GetMemberListParams, GetMemberProfileParams, GetMessageListHoppingParams, GetMessageListParams, GroupAttrParams, GroupServiceBasicParams, IConversationModel, IGroupModel, IMessageModel, JoinGroupParams, KeyListParams, LoginParams, MAddMemberParams, MChangGroupOwnerParams, MCountersParams, MDeleteMemberParams, MGetMemberListParams, MGetMemberProfileParams, MGroupAttrParams, MJoinGroupParams, MKeyListParams, MMarkMemberParams, MSetCountersParams, MSetMemberCustomFiledParams, MSetMemberMuteParams, MSetMemberNameCardParams, MSetMemberRoleParams, MUpdateGroupParams, MarkMemberParams, MessageControlInfo, ModifyMessageParams, MuteConversationParams, OfflinePushInfo, PinConversationParams, SearchCloudMessagesParams, SendForwardMessageOptions, SendMessageOptions, SendMessageParams, SetCountersParams, SetMemberCustomFiledParams, SetMemberMuteParams, SetMemberNameCardParams, SetMemberRoleParams, StoreName, SwitchUserStatusParams, tuiChat as TUIChatService, tuiConversation as TUIConversationService, tuiFriend as TUIFriendService, tuiGlobal as TUIGlobal, tuiGroup as TUIGroupService, tuiStore as TUIStore, tuiTranslate as TUITranslateService, tuiUser as TUIUserService, TranslateTextParams, UpdateFriendParams, UpdateGroupParams, UpdateMyProfileParams, UserIDListParams, TUIChatEngine as default, handleGroupApplicationParams };
|
|
733
|
+
export { AcceptFriendApplicationParams, AddFriendParams, AddMemberParams, ChangGroupOwnerParams, CheckFriendParams, CountersParams, CreateGroupParams, DeleteFriendApplicationParams, DeleteFriendParams, DeleteMemberParams, ForwardMessageParams, Friend, FriendApplication, GetAllUserListOfMessageReactionParams, GetFriendProfileParams, GetGroupMessageReadParams, GetGroupProfileParams, GetMemberListParams, GetMemberProfileParams, GetMessageListHoppingParams, GetMessageListParams, GetMessageReactionsParams, GroupAttrParams, GroupServiceBasicParams, IConversationModel, IGroupModel, IMessageModel, JoinGroupParams, KeyListParams, LoginParams, MAddMemberParams, MChangGroupOwnerParams, MCountersParams, MDeleteMemberParams, MGetMemberListParams, MGetMemberProfileParams, MGroupAttrParams, MJoinGroupParams, MKeyListParams, MMarkMemberParams, MSetCountersParams, MSetMemberCustomFiledParams, MSetMemberMuteParams, MSetMemberNameCardParams, MSetMemberRoleParams, MUpdateGroupParams, MarkMemberParams, MessageControlInfo, ModifyMessageParams, MuteConversationParams, OfflinePushInfo, PinConversationParams, ReactionInfo, SearchCloudMessagesParams, SendForwardMessageOptions, SendMessageOptions, SendMessageParams, SetCountersParams, SetMemberCustomFiledParams, SetMemberMuteParams, SetMemberNameCardParams, SetMemberRoleParams, StoreName, SwitchUserStatusParams, tuiChat as TUIChatService, tuiConversation as TUIConversationService, tuiFriend as TUIFriendService, tuiGlobal as TUIGlobal, tuiGroup as TUIGroupService, tuiStore as TUIStore, tuiTranslate as TUITranslateService, tuiUser as TUIUserService, TranslateTextParams, UpdateFriendParams, UpdateGroupParams, UpdateMyProfileParams, UserIDListParams, TUIChatEngine as default, handleGroupApplicationParams };
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"@tencentcloud/chat";import t from"tim-upload-plugin";import n from"tim-profanity-filter-plugin";function s(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(s=Object.getOwnPropertySymbols(e);i<s.length;i++)t.indexOf(s[i])<0&&Object.prototype.propertyIsEnumerable.call(e,s[i])&&(n[s[i]]=e[s[i]])}return n}function i(e,t,n,s){return new(n||(n=Promise))((function(i,r){function o(e){try{u(s.next(e))}catch(e){r(e)}}function a(e){try{u(s.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}u((s=s.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class r{constructor(e){return r.instance||(r.instance=this,this.engine=e,this.events={},this.bindIMEvents()),r.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 n of this.events[e].keys())n.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.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)}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_MODIFIED,this.onMessageReadReceiptReceived,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)}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)}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)}}var o,a,u,g,c,l,p,h,d;!function(e){e.TUIStore="TUIStore",e.TUITranslate="TUITranslate",e.TUIConversation="TUIConversation",e.TUIChat="TUIChat",e.TUIGroup="TUIGroup",e.TUIUser="TUIUser",e.TUIFriend="TUIFriend"}(o||(o={})),function(e){e.APP="application",e.CONV="conversation",e.CHAT="chat",e.GRP="group",e.USER="user",e.FRIEND="friend",e.CUSTOM="custom"}(a||(a={})),function(e){e[e.UNSUB_USER=-1]="UNSUB_USER"}(u||(u={})),function(e){e.BUSINESS_ID="user_typing_status",e[e.STATUS_START=1]="STATUS_START",e[e.STATUS_END=0]="STATUS_END",e[e.VERSION=1]="VERSION",e[e.ACTION_START_ID=14]="ACTION_START_ID",e[e.ACTION_END_ID=0]="ACTION_END_ID",e.ACTION_START="EIMAMSG_InputStatus_Ing",e.ACTION_END="EIMAMSG_InputStatus_End",e[e.NEED_TYPING=1]="NEED_TYPING"}(g||(g={})),function(e){e.ADD="add",e.REMOVE="remove"}(c||(c={})),function(e){e[e.MSG_MODIFY_CONFLICT=2480]="MSG_MODIFY_CONFLICT",e[e.MSG_MODIFY_DISABLED_IN_AVCHATROOM=2481]="MSG_MODIFY_DISABLED_IN_AVCHATROOM",e[e.MODIFY_MESSAGE_NOT_EXIST=20026]="MODIFY_MESSAGE_NOT_EXIST"}(l||(l={})),function(e){e[e.NOT_INIT=-1e5]="NOT_INIT",e[e.INVALID_CONV_ID=-100001]="INVALID_CONV_ID",e[e.CONV_ID_SAME=-100002]="CONV_ID_SAME",e[e.CONV_NOT_EXIST=-100003]="CONV_NOT_EXIST",e[e.GET_MSG_LIST_ERROR=-100004]="GET_MSG_LIST_ERROR",e[e.MISMATCH_TYPE_AND_PAYLOAD=-100005]="MISMATCH_TYPE_AND_PAYLOAD"}(p||(p={})),function(e){e.MSG_MODIFY_CONFLICT="MODIFY_MESSAGE_ERROR,修改消息发生冲突, data.message 是最新的消息",e.MSG_MODIFY_DISABLED_IN_AVCHATROOM="MODIFY_MESSAGE_ERROR,不支持修改直播群消息.",e.MODIFY_MESSAGE_NOT_EXIST="MODIFY_MESSAGE_ERROR,消息不存在."}(h||(h={})),function(e){e.NOT_INIT="TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。",e.INVALID_CONV_ID="会话 ID 无效",e.CONV_ID_SAME="您切换的是同一个会话 ID",e.CONV_NOT_EXIST="会话不存在",e.GET_MSG_LIST_ERROR="Chat SDK is not ready.",e.MISMATCH_TYPE_AND_PAYLOAD="type 与 payload 不匹配."}(d||(d={}));const f={logout:1,destroy:1},m={deleteConversation:1,pinConversation:1,muteConversation:1,switchConversation:1,getConversationProfile:1,clearHistoryMessage:1},v={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,translateText:1,searchCloudMessages:1},E={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},S={switchUserStatus:1,switchMessageReadStatus:1,getUserProfile:1,updateMyProfile:1,addToBlacklist:1,removeFromBlacklist:1},y={getFriendList:1,addFriend:1,deleteFriend:1,checkFriend:1,getFriendProfile:1,updateFriend:1,acceptFriendApplication:1,refuseFriendApplication:1,deleteFriendApplication:1,setFriendApplicationRead:1},T=function(e){return void 0===e},I=function(e){return e.startsWith("_")},b=function(e){return/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(e)};const O=function(e){return e&&function(e){if("string"==typeof e)try{return!!JSON.parse(e)}catch(e){return!1}return!1}(e)?JSON.parse(e):e},D=function(e){let t="";return t=e>=1048576?`${(e/1048576).toFixed(2)} Mb`:e>=1024?`${(e/1024).toFixed(2)} Kb`:`${e.toFixed(2)}B`,t},M=(e,t=6,n=.5)=>{let s=t;return e.catch((e=>{if(0===s)throw e;const t=setTimeout((()=>{clearTimeout(t),s--}),1e3*n)}))},C="https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png",_="https://web.sdk.qcloud.com/im/demo/TUIkit/web/img/constomer.svg",P="https://web.sdk.qcloud.com/component/TUIKit/assets/group_avatar.png",U="https://web.sdk.qcloud.com/im/assets/emoji/",R="https://web.sdk.qcloud.com/im/assets/face-elem/",x="https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&",L="https://apis.map.qq.com/ws/staticmap/v2/?",G={"[NO]":"emoji_0@2x.png","[OK]":"emoji_1@2x.png","[下雨]":"emoji_2@2x.png","[么么哒]":"emoji_3@2x.png","[乒乓]":"emoji_4@2x.png","[便便]":"emoji_5@2x.png","[信封]":"emoji_6@2x.png","[偷笑]":"emoji_7@2x.png","[傲慢]":"emoji_8@2x.png","[再见]":"emoji_9@2x.png","[冷汗]":"emoji_10@2x.png","[凋谢]":"emoji_11@2x.png","[刀]":"emoji_12@2x.png","[删除]":"emoji_13@2x.png","[勾引]":"emoji_14@2x.png","[发呆]":"emoji_15@2x.png","[发抖]":"emoji_16@2x.png","[可怜]":"emoji_17@2x.png","[可爱]":"emoji_18@2x.png","[右哼哼]":"emoji_19@2x.png","[右太极]":"emoji_20@2x.png","[右车头]":"emoji_21@2x.png","[吐]":"emoji_22@2x.png","[吓]":"emoji_23@2x.png","[咒骂]":"emoji_24@2x.png","[咖啡]":"emoji_25@2x.png","[啤酒]":"emoji_26@2x.png","[嘘]":"emoji_27@2x.png","[回头]":"emoji_28@2x.png","[困]":"emoji_29@2x.png","[坏笑]":"emoji_30@2x.png","[多云]":"emoji_31@2x.png","[大兵]":"emoji_32@2x.png","[大哭]":"emoji_33@2x.png","[太阳]":"emoji_34@2x.png","[奋斗]":"emoji_35@2x.png","[奶瓶]":"emoji_36@2x.png","[委屈]":"emoji_37@2x.png","[害羞]":"emoji_38@2x.png","[尴尬]":"emoji_39@2x.png","[左哼哼]":"emoji_40@2x.png","[左太极]":"emoji_41@2x.png","[左车头]":"emoji_42@2x.png","[差劲]":"emoji_43@2x.png","[弱]":"emoji_44@2x.png","[强]":"emoji_45@2x.png","[彩带]":"emoji_46@2x.png","[彩球]":"emoji_47@2x.png","[得意]":"emoji_48@2x.png","[微笑]":"emoji_49@2x.png","[心碎了]":"emoji_50@2x.png","[快哭了]":"emoji_51@2x.png","[怄火]":"emoji_52@2x.png","[怒]":"emoji_53@2x.png","[惊恐]":"emoji_54@2x.png","[惊讶]":"emoji_55@2x.png","[憨笑]":"emoji_56@2x.png","[手枪]":"emoji_57@2x.png","[打哈欠]":"emoji_58@2x.png","[抓狂]":"emoji_59@2x.png","[折磨]":"emoji_60@2x.png","[抠鼻]":"emoji_61@2x.png","[抱抱]":"emoji_62@2x.png","[抱拳]":"emoji_63@2x.png","[拳头]":"emoji_64@2x.png","[挥手]":"emoji_65@2x.png","[握手]":"emoji_66@2x.png","[撇嘴]":"emoji_67@2x.png","[擦汗]":"emoji_68@2x.png","[敲打]":"emoji_69@2x.png","[晕]":"emoji_70@2x.png","[月亮]":"emoji_71@2x.png","[棒棒糖]":"emoji_72@2x.png","[汽车]":"emoji_73@2x.png","[沙发]":"emoji_74@2x.png","[流汗]":"emoji_75@2x.png","[流泪]":"emoji_76@2x.png","[激动]":"emoji_77@2x.png","[灯泡]":"emoji_78@2x.png","[炸弹]":"emoji_79@2x.png","[熊猫]":"emoji_80@2x.png","[爆筋]":"emoji_81@2x.png","[爱你]":"emoji_82@2x.png","[爱心]":"emoji_83@2x.png","[爱情]":"emoji_84@2x.png","[猪头]":"emoji_85@2x.png","[猫咪]":"emoji_86@2x.png","[献吻]":"emoji_87@2x.png","[玫瑰]":"emoji_88@2x.png","[瓢虫]":"emoji_89@2x.png","[疑问]":"emoji_90@2x.png","[白眼]":"emoji_91@2x.png","[皮球]":"emoji_92@2x.png","[睡觉]":"emoji_93@2x.png","[磕头]":"emoji_94@2x.png","[示爱]":"emoji_95@2x.png","[礼品袋]":"emoji_96@2x.png","[礼物]":"emoji_97@2x.png","[篮球]":"emoji_98@2x.png","[米饭]":"emoji_99@2x.png","[糗大了]":"emoji_100@2x.png","[红双喜]":"emoji_101@2x.png","[红灯笼]":"emoji_102@2x.png","[纸巾]":"emoji_103@2x.png","[胜利]":"emoji_104@2x.png","[色]":"emoji_105@2x.png","[药]":"emoji_106@2x.png","[菜刀]":"emoji_107@2x.png","[蛋糕]":"emoji_108@2x.png","[蜡烛]":"emoji_109@2x.png","[街舞]":"emoji_110@2x.png","[衰]":"emoji_111@2x.png","[西瓜]":"emoji_112@2x.png","[调皮]":"emoji_113@2x.png","[象棋]":"emoji_114@2x.png","[跳绳]":"emoji_115@2x.png","[跳跳]":"emoji_116@2x.png","[车厢]":"emoji_117@2x.png","[转圈]":"emoji_118@2x.png","[鄙视]":"emoji_119@2x.png","[酷]":"emoji_120@2x.png","[钞票]":"emoji_121@2x.png","[钻戒]":"emoji_122@2x.png","[闪电]":"emoji_123@2x.png","[闭嘴]":"emoji_124@2x.png","[闹钟]":"emoji_125@2x.png","[阴险]":"emoji_126@2x.png","[难过]":"emoji_127@2x.png","[雨伞]":"emoji_128@2x.png","[青蛙]":"emoji_129@2x.png","[面条]":"emoji_130@2x.png","[鞭炮]":"emoji_131@2x.png","[风车]":"emoji_132@2x.png","[飞吻]":"emoji_133@2x.png","[飞机]":"emoji_134@2x.png","[饥饿]":"emoji_135@2x.png","[香蕉]":"emoji_136@2x.png","[骷髅]":"emoji_137@2x.png","[麦克风]":"emoji_138@2x.png","[麻将]":"emoji_139@2x.png","[鼓掌]":"emoji_140@2x.png","[龇牙]":"emoji_141@2x.png"},j={enabledMessageReadReceipt:Math.pow(2,5),enabledEmojiPlugin:Math.pow(2,48),enabledOnlineStatus:Math.pow(2,7),enabledCustomerServicePlugin:Math.pow(2,40)},A=["messageList","conversationList","newMessageList"],N="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),k="undefined"!=typeof uni&&"undefined"==typeof window,w=N||k,V="undefined"!=typeof uni,$=("undefined"!=typeof uni||"undefined"!=typeof window)&&!w,F=N?wx:V?uni:window,H=$&&window&&window.navigator&&window.navigator.userAgent||"",Y=/Android/i.test(H),B=/(?:Windows Phone)/.test(H),K=/(?:SymbianOS)/.test(H),q=/iPad/i.test(H)||/iPhone/i.test(H)||/iPod/i.test(H),J=Y||B||K||q,z=$&&!J;class W{constructor(){this.global=F,this.isOfficial=!1}static getInstance(){return W.instance||(W.instance=new W),W.instance}initOfficial(e){this.isOfficial=e}getPlatform(){let e="";return z?e="pc":J?e="h5":N?e="wechat":k&&!N&&(e="app"),e}}class X{constructor(){this.EVENT=e.EVENT,this.TYPES=e.TYPES,this.loginStatusPromise=new Map,this.userID="",this.isInited=!1}static getInstance(){return X.instance||(X.instance=new X),X.instance}mount(e,t){this[e]=t}login(t){const{chat:n,SDKAppID:s,userID:i}=t,o=1400187352===s||1400188366===s;return this.createChat(t),this.userID=i,W.getInstance().initOfficial(o),this.TUIStore.update(a.APP,"isOfficial",o),this.TUIStore.update(a.APP,"SDKVersion",e.VERSION),this.eventCenter=new r(this),this.eventCenter.removeEvents(),this.initStore(),this.initService(),n&&n.isReady()?(console.log("TUIChatEngine.login ok, from TUICore."),this.checkCommercialAbility(),Promise.resolve({})):(this.registerPlugin(t),this.eventCenter.addEvent(this.EVENT.SDK_READY,(()=>{this.onSDKReady()})),this.eventCenter.addEvent(this.EVENT.SDK_NOT_READY,(()=>{this.onSDKNotReady()})),this.loginChat(t))}logout(){return this.userID="",this.isInited=!1,this.chat.logout()}isReady(){var e;return(null===(e=this.chat)||void 0===e?void 0:e.isReady())||!1}setLogLevel(e){if(this.chat)return this.chat.setLogLevel(e);console.warn("TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。")}destroy(){return this.eventCenter.unbindIMEvents(),this.isInited=!1,this.chat.destroy()}getMyUserID(){return this.userID}initStore(){this.TUIStore.reset(a.CHAT),this.TUIStore.reset(a.CONV),this.TUIStore.reset(a.GRP),this.TUIStore.reset(a.USER),console.log("TUIEngine.initStore ok.")}initService(){this.TUIChat.init(),this.TUIConversation.init(),this.TUIGroup.init(),this.TUIUser.init(),this.TUIFriend.init(),this.isInited=!0,console.log("TUIEngine.initService ok.")}createChat(t){const{chat:n}=t,i=s(t,["chat"]);T(n)?this.chat=e.create(Object.assign(Object.assign({},i),{scene:"chat-uikit-engine"})):this.chat=n}loginChat(e){const{userID:t,userSig:n}=e;return new Promise(((e,s)=>{this.chat.login({userID:t,userSig:n}).then((t=>{console.log("TUIChatEngine.loginChat ok."),this.checkCommercialAbility(),t.data.repeatLogin&&this.chat.isReady()&&e(t),this.loginStatusPromise.set("login",{resolve:e,reject:s,imResponse:t})})).catch((e=>{s(e)}))}))}registerPlugin(e){const{useUploadPlugin:s=!1,useProfanityFilterPlugin:i=!1,TUIOfflinePush:r,offlinePushConfig:o}=e;!0===s&&this.chat.registerPlugin({"tim-upload-plugin":t}),!0===i&&this.chat.registerPlugin({"tim-profanity-filter-plugin":n}),!k||N||T(r)||T(o)||this.chat.registerPlugin({"tim-offline-push-plugin":r,offlinePushConfig:o})}onSDKReady(){if(this.loginStatusPromise.has("login")){const e=this.loginStatusPromise.get("login");e.resolve(e.imResponse),this.TUIUser.getUserProfile()}this.loginStatusPromise.delete("login")}onSDKNotReady(){if(this.loginStatusPromise.has("login")){this.loginStatusPromise.get("login").reject(new Error("sdk not ready"))}this.loginStatusPromise.delete("login")}checkCommercialAbility(){Object.keys(j).forEach((e=>{const t=j[e];this.chat.callExperimentalAPI("isCommercialAbilityEnabled",t).then((t=>{const{enabled:n=!1}=t.data;this.TUIStore.update(a.APP,e,n)}))}))}}class Z{constructor(){this.defaultStore={enabledMessageReadReceipt:!1,enabledEmojiPlugin:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enableTyping:!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}},this.store={enabledEmojiPlugin:!1,enabledMessageReadReceipt:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enableTyping:!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}}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}}class Q{constructor(){this.defaultStore={userProfile:{},displayOnlineStatus:!1,autoSubOnlineStatus:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",displayMessageReadReceipt:!0,userBlacklist:[]},this.store={userProfile:{},displayOnlineStatus:!1,autoSubOnlineStatus:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",displayMessageReadReceipt:!0,userBlacklist:[]}}update(e,t){if("userStatusList"===e)this.updateUserStatusList(t);else this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateUserStatusList(e){0!==e.length?e.forEach((e=>{const{userID:t,statusType:n=0,customStatus:s=""}=e;n===u.UNSUB_USER?this.store.userStatusList.delete(t):this.store.userStatusList.set(t,{statusType:n,customStatus:s})})):this.store.userStatusList.clear()}}class ee{getEngine(){return X.getInstance()}}class te extends ee{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=>{I(t)||(this[t]=e[t])}))}updateProperties(e){this._conversation=e,Object.keys(e).forEach((t=>{I(t)||(this[t]=e[t])}))}getConversation(){return this._conversation}deleteConversation(){return this.getEngine().TUIConversation.deleteConversation(this.conversationID)}pinConversation(){return this.getEngine().TUIConversation.pinConversation({conversationID:this.conversationID,isPinned:!this.isPinned})}muteConversation(){const e=this.getEngine(),t={messageRemindType:!0===this.isMuted?e.TYPES.MSG_REMIND_ACPT_AND_NOTE:e.TYPES.MSG_REMIND_ACPT_NOT_NOTE};if(this.type===e.TYPES.CONV_C2C){const n=this.conversationID.replace(e.TYPES.CONV_C2C,"");t.userIDList=[n]}else if(this.type===e.TYPES.CONV_GROUP){const n=this.conversationID.replace(e.TYPES.CONV_GROUP,"");t.groupID=n}return e.TUIConversation.muteConversation(t)}getAvatar(){var e,t,n,s,i,r;const o=this.getEngine();let a="";switch(this.type){case o.TYPES.CONV_C2C:a=b(null===(e=this.userProfile)||void 0===e?void 0:e.avatar)?null===(t=this.userProfile)||void 0===t?void 0:t.avatar:C;break;case o.TYPES.CONV_GROUP:a=b(null===(n=this.groupProfile)||void 0===n?void 0:n.avatar)?null===(s=this.groupProfile)||void 0===s?void 0:s.avatar:_;break;case o.TYPES.CONV_SYSTEM:a=b(null===(i=this.groupProfile)||void 0===i?void 0:i.avatar)?null===(r=this.groupProfile)||void 0===r?void 0:r.avatar:P}return a}getShowName(){var e,t,n,s;const i=this.getEngine();let r="";switch(this.type){case i.TYPES.CONV_C2C:r=this.remark||(null===(e=this.userProfile)||void 0===e?void 0:e.nick)||(null===(t=this.userProfile)||void 0===t?void 0:t.userID)||"";break;case i.TYPES.CONV_GROUP:r=(null===(n=this.groupProfile)||void 0===n?void 0:n.name)||(null===(s=this.groupProfile)||void 0===s?void 0:s.groupID)||"";break;case i.TYPES.CONV_SYSTEM:r=i.TUITranslate.t("系统通知")}return r}getGroupAtInfo(){const e=this.getEngine(),t=e.TUITranslate.t.bind(e.TUITranslate),n=[`[${t("TUIConversation.有人@我")}]`,`[${t("TUIConversation.@所有人")}]`,`[${t("TUIConversation.@所有人")}][${t("TUIConversation.有人@我")}]`];let s="";for(let e=0;e<this.groupAtInfoList.length;e++)this.groupAtInfoList[e].atTypeArray[0]&&this.unreadCount>0&&(s=n[this.groupAtInfoList[e].atTypeArray[0]-1]);return s}getLastMessage(e){return"time"===e?this.getLastMessageTime():"text"===e?this.getLastMessageText():(console.warn(`ConversationModel.getLastMessage key:${e} is invalid.`),null)}getLastMessageTime(){var e;const t=this.getEngine();let n="";return(null===(e=this.lastMessage)||void 0===e?void 0:e.lastTime)>0&&(n=function(e,t){const n=6e4,s=36e5,i=24*s,r=(new Date).getTime()-e;let o="";if(r<0)return o;const a=r/n,u=r/s,g=r/i,c=r/6048e5;if(c>=1&&c<=4)o=` ${parseInt(`${c}`,10)} ${t("time.周")}${t("time.前")}`;else if(g>=1&&g<=6)o=` ${parseInt(`${g}`,10)} ${t("time.天")}${t("time.前")}`;else if(u>=1&&u<=23)o=` ${parseInt(`${u}`,10)} ${t("time.小时")}${t("time.前")}`;else if(a>=1&&a<=59)o=` ${parseInt(`${a}`,10)} ${t("time.分钟")}${t("time.前")}`;else if(r>=0&&r<=n)o=`${t("time.刚刚")}`;else{const t=new Date;t.setTime(e),o=`${t.getFullYear()}-${t.getMonth()+1<10?`0${t.getMonth()+1}`:t.getMonth()+1}-${t.getDate()<10?`0${t.getDate()}`:t.getDate()}`}return o}(1e3*this.lastMessage.lastTime,t.TUITranslate.t.bind(t.TUITranslate))),n}getLastMessageText(){var e;const t=this.getEngine(),n=t.TUITranslate.t.bind(t.TUITranslate);if(4===this.operationType)return n("TUIConversation.您已被群管理员移出群聊");if(5===this.operationType)return n("TUIConversation.该群聊已被解散");if(8===this.operationType)return n("TUIConversation.您已退出该群聊");const s=this._conversation,i=this.lastMessage;let r="",o="";const a=s.unreadCount>0&&s.messageRemindType===t.TYPES.MSG_REMIND_ACPT_NOT_NOTE?n(`[${s.unreadCount>99?"99+":s.unreadCount}条]`):"";if(s.type===t.TYPES.CONV_GROUP)if(i.fromAccount===t.getMyUserID())r=n("TUIConversation.我");else{const e=i.fromAccount;r=t.TUIFriend.getFriendRemark([e])[e]||i.nameCard||i.nick||e}if(i.type===t.TYPES.MSG_TEXT)o=i.payload.text;else if(i.type===t.TYPES.MSG_CUSTOM){const n=O(null===(e=null==i?void 0:i.payload)||void 0===e?void 0:e.data);if(1===(null==n?void 0:n.businessID))return o=t.TUIChat.messageHandler.handleCallKitSignaling(i),o;o=i.messageForShow}else o=i.messageForShow;return i.isRevoked&&(o=n("TUIChat.撤回了一条消息")),s.type===t.TYPES.CONV_GROUP&&i.type===t.TYPES.MSG_GRP_TIP?o:`${a}${r?`${r}:`:""}${o}`}}class ne{constructor(){this.defaultStore={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null},this.store={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null}}update(e,t){if("conversationList"===e)this.updateConversationList(t);else this.store[e]=t}getData(e){return this.store[e]}getModel(e){return this.store.conversationList.find((t=>t.conversationID===e))}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateConversationList(e){const t=[];e.forEach((e=>{let n=e;e instanceof te?n.updateProperties(e):n=new te(e),t.push(n)})),this.store.conversationList=t}}class se extends ee{constructor(e){super(),this.messageHandlers={[this.getEngine().TYPES.MSG_TEXT]:e=>this.getEngine().TUIChat.messageHandler.handleTextMessage(e),[this.getEngine().TYPES.MSG_FACE]:e=>this.getEngine().TUIChat.messageHandler.handleFaceMessage(e),[this.getEngine().TYPES.MSG_LOCATION]:e=>this.getEngine().TUIChat.messageHandler.handleLocationMessage(e),[this.getEngine().TYPES.MSG_IMAGE]:e=>this.getEngine().TUIChat.messageHandler.handleImageMessage(e),[this.getEngine().TYPES.MSG_AUDIO]:e=>this.getEngine().TUIChat.messageHandler.handleAudioMessage(e),[this.getEngine().TYPES.MSG_VIDEO]:e=>this.getEngine().TUIChat.messageHandler.handleVideoMessage(e),[this.getEngine().TYPES.MSG_FILE]:e=>this.getEngine().TUIChat.messageHandler.handleFileMessage(e),[this.getEngine().TYPES.MSG_CUSTOM]:e=>this.getEngine().TUIChat.messageHandler.handleCustomMessage(e),[this.getEngine().TYPES.MSG_MERGER]:e=>this.getEngine().TUIChat.messageHandler.handleMergeMessage(e),[this.getEngine().TYPES.MSG_GRP_TIP]:e=>this.getEngine().TUIChat.messageHandler.handleGroupTipsMessage(e)},this._message=e,this._signalingInfo=void 0,this.progress=0,this.initProperties(e)}initProperties(e){Object.keys(e).forEach((t=>{I(t)||(this[t]=e[t])}))}updateProperties(e){this._message=e,Object.keys(e).forEach((t=>{I(t)||(this[t]=e[t])}))}getMessage(){return this._message}modifyMessage(e){return e.type&&this._message.type!==e.type&&!e.payload?Promise.reject({code:p.MISMATCH_TYPE_AND_PAYLOAD,message:d.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:T(this._signalingInfo)?(this._signalingInfo=this.getEngine().chat.getSignalingInfo(this._message),this._signalingInfo):this._signalingInfo}getMessageContent(){const e=this.messageHandlers[this.type];if(T(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})}getMessageReaction(){const e=Object.assign({},this._message.cloudCustomData?O(this._message.cloudCustomData):{});return e.messageReact?e.messageReact:void 0}addMessageReaction(e){const t=this.setMessageReaction(e);if(t)return M(this.getEngine().TUIChat.modifyMessage(t))}deleteMessageReaction(e){const t=this.setMessageReaction(e,c.REMOVE);if(t)return M(this.getEngine().TUIChat.modifyMessage(t))}setMessageReaction(e,t=c.ADD){const n=this.getEngine().getMyUserID(),s=this._message,i=Object.assign({messageReact:{}},s.cloudCustomData?O(s.cloudCustomData):{}),r=Object.assign({reacts:{},version:1},i.messageReact),o=r.reacts[e]||[],a=o.indexOf(n),u=-1===a&&t===c.REMOVE,g=a>=0&&t===c.ADD;if(!u&&!g)return-1===a?o.push(n):o.splice(a,1),r.reacts[e]=o,r.reacts=Object.keys(r.reacts).filter((e=>r.reacts[e].length>0)).reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:r.reacts[t]})),{}),i.messageReact=r,s.cloudCustomData=JSON.stringify(i),s}sendForwardMessage(e){return this.getEngine().TUIChat.sendForwardMessage(e,[this._message])}}class ie{constructor(){this.defaultStore={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0},this.store={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0}}update(e,t){if("messageList"===e)this.updateMessageList(t);else this.store[e]=t}getData(e){return this.store[e]}getModel(e){return this.store.messageList.find((t=>t.ID===e))}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),null==e?void 0:e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateMessageList(e){const t=[];e.forEach((e=>{let n=e;e instanceof se||(n=this.getModel(e.ID),n?n.updateProperties(e):n=new se(e)),t.push(n)})),this.store.messageList=t}}class re extends ee{constructor(e){super(),this.groupAttributes={},this.groupCounters={},this.initProxy(e)}initProxy(e){Object.keys(e).forEach((t=>{I(t)||(this[t]=e[t])})),this._group=e}getGroup(){return this._group}switchGroup(){return this.getEngine().TUIGroup.switchGroup(this.groupID)}getGroupProfile(e){return this.getEngine().TUIGroup.getGroupProfile({groupID:this.groupID,groupCustomFieldFilter:e})}updateGroupProfile(e){return this.getEngine().TUIGroup.updateGroupProfile(Object.assign({groupID:this.groupID},e))}joinGroup(e){return this.getEngine().TUIGroup.joinGroup({groupID:this.groupID,applyMessage:e})}quitGroup(){return this.getEngine().TUIGroup.quitGroup(this.groupID)}dismissGroup(){return this.getEngine().TUIGroup.dismissGroup(this.groupID)}getGroupOnlineMemberCount(){return this.getEngine().TUIGroup.getGroupOnlineMemberCount(this.groupID)}changeGroupOwner(e){return this.getEngine().TUIGroup.changeGroupOwner(Object.assign({groupID:this.groupID},e))}initGroupAttributes(e){return this.getEngine().TUIGroup.initGroupAttributes(Object.assign({groupID:this.groupID},e))}setGroupAttributes(e){return this.getEngine().TUIGroup.setGroupAttributes(Object.assign({groupID:this.groupID},e))}deleteGroupAttributes(e){return this.getEngine().TUIGroup.deleteGroupAttributes(Object.assign({groupID:this.groupID},e))}getGroupAttributes(e){return this.getEngine().TUIGroup.getGroupAttributes(Object.assign({groupID:this.groupID},e))}setGroupCounters(e){return this.getEngine().TUIGroup.setGroupCounters(Object.assign({groupID:this.groupID},e))}increaseGroupCounter(e){return this.getEngine().TUIGroup.increaseGroupCounter(Object.assign({groupID:this.groupID},e))}decreaseGroupCounter(e){return this.getEngine().TUIGroup.decreaseGroupCounter(Object.assign({groupID:this.groupID},e))}getGroupCounters(e){return this.getEngine().TUIGroup.getGroupCounters(Object.assign({groupID:this.groupID},e))}addGroupMember(e){return this.getEngine().TUIGroup.addGroupMember(Object.assign({groupID:this.groupID},e))}getGroupMemberList(e){return this.getEngine().TUIGroup.getGroupMemberList(Object.assign({groupID:this.groupID},e))}getGroupMemberProfile(e){return this.getEngine().TUIGroup.getGroupMemberProfile(Object.assign({groupID:this.groupID},e))}deleteGroupMember(e){return this.getEngine().TUIGroup.deleteGroupMember(Object.assign({groupID:this.groupID},e))}setGroupMemberMuteTime(e){return this.getEngine().TUIGroup.setGroupMemberMuteTime(Object.assign({groupID:this.groupID},e))}setGroupMemberRole(e){return this.getEngine().TUIGroup.setGroupMemberRole(Object.assign({groupID:this.groupID},e))}setGroupMemberNameCard(e){return this.getEngine().TUIGroup.setGroupMemberNameCard(Object.assign({groupID:this.groupID},e))}setGroupMemberCustomField(e){return this.getEngine().TUIGroup.setGroupMemberCustomField(Object.assign({groupID:this.groupID},e))}markGroupMemberList(e){return this.getEngine().TUIGroup.markGroupMemberList(Object.assign({groupID:this.groupID},e))}}class oe{constructor(){this.defaultStore={currentGroupID:"",currentGroup:{},currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[]},this.store={currentGroupID:"",currentGroup:void 0,currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[]}}update(e,t){switch(e){case"groupList":this.updateGroupList(t);break;case"currentGroup":this.store.currentGroup=t instanceof re?t:new re(t);break;default:this.store[e]=t}}getData(e){if("groupSystemNoticeList"===e){const e=[...this.store.groupSystemNoticeList];return this.store.groupSystemNoticeList.length=0,e}return this.store[e]}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateGroupList(e){this.store.groupList=e.map((e=>e instanceof re?e:new re(e)))}}class ae{constructor(){this.store={}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){0===e.length&&(this.store={}),this.store=Object.assign(Object.assign({},this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:void 0})),{}))}}class ue{constructor(){this.defaultStore={friendList:[],friendApplicationList:[],friendApplicationUnreadCount:0},this.store={friendList:[],friendApplicationList:[],friendApplicationUnreadCount:0}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}}class ge{constructor(){this.storeMap={[a.APP]:new Z,[a.USER]:new Q,[a.CONV]:new ne,[a.CHAT]:new ie,[a.GRP]:new oe,[a.FRIEND]:new ue},this.task={}}static getInstance(){return ge.instance||(ge.instance=new ge),ge.instance}watch(e,t){this.task[e]||(this.task[e]={});const n=this.task[e];Object.keys(t).forEach((s=>{const i=t[s];n[s]||(n[s]=new Map),n[s].set(i,1),this.notifyOnWatch(e,s,i)}))}unwatch(e,t){if(!this.task[e])return;const n=this.task[e];Object.keys(t).forEach((e=>{n[e].delete(t[e])}))}update(e,t,n){var s;e!==a.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new ae),null===(s=this.storeMap[e])||void 0===s||s.update(t,n),this.notify(e,t)}getData(e,t){var n;return e!==a.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new ae),null===(n=this.storeMap[e])||void 0===n?void 0:n.getData(t)}getConversationModel(e){var t;return null===(t=this.storeMap[a.CONV])||void 0===t?void 0:t.getModel(e)}getMessageModel(e){var t;return null===(t=this.storeMap[a.CHAT])||void 0===t?void 0:t.getModel(e)}reset(e,t=[],n=!1){if(e in this.storeMap){const s=this.storeMap[e];0===t.length&&(t=Object.keys(null==s?void 0:s.store)),s.reset(t),n&&t.forEach((t=>{this.notify(e,t)}))}}notifyOnWatch(e,t,n){const s=this.getData(e,t);A.indexOf(t)>-1&&0===s.length||n&&n.call(this,s)}notify(e,t){if(!this.task[e])return;const n=this.task[e];if(n[t]){const s=n[t],i=this.getData(e,t);for(const[e]of s.entries())e.call(this,i)}}}function ce(e){return ce="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},ce(e)}function le(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pe(e){var t=function(e,t){if("object"!=ce(e)||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var s=n.call(e,t||"default");if("object"!=ce(s))return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==ce(t)?t:String(t)}function he(e,t){for(var n=0;n<t.length;n++){var s=t[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(e,pe(s.key),s)}}function de(e,t,n){return t&&he(e.prototype,t),n&&he(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function fe(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function me(e,t){return me=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},me(e,t)}function ve(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&me(e,t)}function Ee(e,t){if(t&&("object"===ce(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return fe(e)}function Se(e){return Se=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Se(e)}function ye(e,t,n){return(t=pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function Ie(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Te(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Te(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function Oe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?be(Object(n),!0).forEach((function(t){ye(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):be(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}var De={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},Me=new(function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};le(this,e),this.init(t,n)}return de(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||De,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),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"log","",!0)}},{key:"warn",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","",!0)}},{key:"error",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"error","")}},{key:"deprecate",value:function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return this.forward(t,"warn","WARNING DEPRECATED: ",!0)}},{key:"forward",value:function(e,t,n,s){return s&&!this.debug?null:("string"==typeof e[0]&&(e[0]="".concat(n).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,Oe(Oe({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),Ce=function(){function e(){le(this,e),this.observers={}}return de(e,[{key:"on",value:function(e,t){var n=this;return e.split(" ").forEach((function(e){n.observers[e]=n.observers[e]||[],n.observers[e].push(t)})),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter((function(e){return e!==t})):delete this.observers[e])}},{key:"emit",value:function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];this.observers[e]&&[].concat(this.observers[e]).forEach((function(e){e.apply(void 0,n)}));this.observers["*"]&&[].concat(this.observers["*"]).forEach((function(t){t.apply(t,[e].concat(n))}))}}]),e}();function _e(){var e,t,n=new Promise((function(n,s){e=n,t=s}));return n.resolve=e,n.reject=t,n}function Pe(e){return null==e?"":""+e}function Ue(e,t,n){function s(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}for(var r="string"!=typeof t?[].concat(t):t.split(".");r.length>1;){if(i())return{};var o=s(r.shift());!e[o]&&n&&(e[o]=new n),e=Object.prototype.hasOwnProperty.call(e,o)?e[o]:{}}return i()?{}:{obj:e,k:s(r.shift())}}function Re(e,t,n){var s=Ue(e,t,Object);s.obj[s.k]=n}function xe(e,t){var n=Ue(e,t),s=n.obj,i=n.k;if(s)return s[i]}function Le(e,t,n){for(var s in t)"__proto__"!==s&&"constructor"!==s&&(s in e?"string"==typeof e[s]||e[s]instanceof String||"string"==typeof t[s]||t[s]instanceof String?n&&(e[s]=t[s]):Le(e[s],t[s],n):e[s]=t[s]);return e}function Ge(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var je={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function Ae(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return je[e]})):e}var Ne="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,ke=[" ",",","?","!",";"];function we(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var s=t.split(n),i=e,r=0;r<s.length;++r){if(!i)return;if("string"==typeof i[s[r]]&&r+1<s.length)return;if(void 0===i[s[r]]){for(var o=2,a=s.slice(r,r+o).join(n),u=i[a];void 0===u&&s.length>r+o;)o++,u=i[a=s.slice(r,r+o).join(n)];if(void 0===u)return;if(null===u)return null;if(t.endsWith(a)){if("string"==typeof u)return u;if(a&&"string"==typeof u[a])return u[a]}var g=s.slice(r+o).join(n);return g?we(u,g,n):void 0}i=i[s[r]]}return i}}function Ve(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function $e(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ve(Object(n),!0).forEach((function(t){ye(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ve(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Fe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,s=Se(e);if(t){var i=Se(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return Ee(this,n)}}var He=function(e){ve(n,Ce);var t=Fe(n);function n(e){var s,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return le(this,n),s=t.call(this),Ne&&Ce.call(fe(s)),s.data=e||{},s.options=i,void 0===s.options.keySeparator&&(s.options.keySeparator="."),void 0===s.options.ignoreJSONStructure&&(s.options.ignoreJSONStructure=!0),s}return de(n,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=void 0!==s.keySeparator?s.keySeparator:this.options.keySeparator,r=void 0!==s.ignoreJSONStructure?s.ignoreJSONStructure:this.options.ignoreJSONStructure,o=[e,t];n&&"string"!=typeof n&&(o=o.concat(n)),n&&"string"==typeof n&&(o=o.concat(i?n.split(i):n)),e.indexOf(".")>-1&&(o=e.split("."));var a=xe(this.data,o);return a||!r||"string"!=typeof n?a:we(this.data&&this.data[e]&&this.data[e][t],n,i)}},{key:"addResource",value:function(e,t,n,s){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},r=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,o=[e,t];n&&(o=o.concat(r?n.split(r):n)),e.indexOf(".")>-1&&(s=t,t=(o=e.split("."))[1]),this.addNamespaces(t),Re(this.data,o,s),i.silent||this.emit("added",e,t,n,s)}},{key:"addResources",value:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var i in n)"string"!=typeof n[i]&&"[object Array]"!==Object.prototype.toString.apply(n[i])||this.addResource(e,t,i,n[i],{silent:!0});s.silent||this.emit("added",e,t,n)}},{key:"addResourceBundle",value:function(e,t,n,s,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},o=[e,t];e.indexOf(".")>-1&&(s=n,n=t,t=(o=e.split("."))[1]),this.addNamespaces(t);var a=xe(this.data,o)||{};s?Le(a,n,i):a=$e($e({},a),n),Re(this.data,o,a),r.silent||this.emit("added",e,t,n)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?$e($e({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((function(e){return t[e]&&Object.keys(t[e]).length>0}))}},{key:"toJSON",value:function(){return this.data}}]),n}(),Ye={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,n,s,i){var r=this;return e.forEach((function(e){r.processors[e]&&(t=r.processors[e].process(t,n,s,i))})),t}};function Be(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function Ke(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Be(Object(n),!0).forEach((function(t){ye(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Be(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function qe(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,s=Se(e);if(t){var i=Se(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return Ee(this,n)}}var Je={},ze=function(e){ve(n,Ce);var t=qe(n);function n(e){var s,i,r,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return le(this,n),s=t.call(this),Ne&&Ce.call(fe(s)),i=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],r=e,o=fe(s),i.forEach((function(e){r[e]&&(o[e]=r[e])})),s.options=a,void 0===s.options.keySeparator&&(s.options.keySeparator="."),s.logger=Me.create("translator"),s}return de(n,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var n=this.resolve(e,t);return n&&void 0!==n.res}},{key:"extractFromKey",value:function(e,t){var n=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===n&&(n=":");var s=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS||[],r=n&&e.indexOf(n)>-1,o=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,n){t=t||"",n=n||"";var s=ke.filter((function(e){return t.indexOf(e)<0&&n.indexOf(e)<0}));if(0===s.length)return!0;var i=new RegExp("(".concat(s.map((function(e){return"?"===e?"\\?":e})).join("|"),")")),r=!i.test(e);if(!r){var o=e.indexOf(n);o>0&&!i.test(e.substring(0,o))&&(r=!0)}return r}(e,n,s));if(r&&!o){var a=e.match(this.interpolator.nestingRegexp);if(a&&a.length>0)return{key:e,namespaces:i};var u=e.split(n);(n!==s||n===s&&this.options.ns.indexOf(u[0])>-1)&&(i=u.shift()),e=u.join(s)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}},{key:"translate",value:function(e,t,s){var i=this;if("object"!==ce(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),"object"===ce(t)&&(t=Ke({},t)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var r=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,o=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,a=this.extractFromKey(e[e.length-1],t),u=a.key,g=a.namespaces,c=g[g.length-1],l=t.lng||this.language,p=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(p){var h=t.nsSeparator||this.options.nsSeparator;return r?{res:"".concat(c).concat(h).concat(u),usedKey:u,exactUsedKey:u,usedLng:l,usedNS:c}:"".concat(c).concat(h).concat(u)}return r?{res:u,usedKey:u,exactUsedKey:u,usedLng:l,usedNS:c}:u}var d=this.resolve(e,t),f=d&&d.res,m=d&&d.usedKey||u,v=d&&d.exactUsedKey||u,E=Object.prototype.toString.apply(f),S=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,y=!this.i18nFormat||this.i18nFormat.handleAsObject;if(y&&f&&("string"!=typeof f&&"boolean"!=typeof f&&"number"!=typeof f)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(E)<0&&("string"!=typeof S||"[object Array]"!==E)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var T=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,f,Ke(Ke({},t),{},{ns:g})):"key '".concat(u," (").concat(this.language,")' returned an object instead of string.");return r?(d.res=T,d):T}if(o){var I="[object Array]"===E,b=I?[]:{},O=I?v:m;for(var D in f)if(Object.prototype.hasOwnProperty.call(f,D)){var M="".concat(O).concat(o).concat(D);b[D]=this.translate(M,Ke(Ke({},t),{joinArrays:!1,ns:g})),b[D]===M&&(b[D]=f[D])}f=b}}else if(y&&"string"==typeof S&&"[object Array]"===E)(f=f.join(S))&&(f=this.extendTranslation(f,e,t,s));else{var C=!1,_=!1,P=void 0!==t.count&&"string"!=typeof t.count,U=n.hasDefaultValue(t),R=P?this.pluralResolver.getSuffix(l,t.count,t):"",x=t["defaultValue".concat(R)]||t.defaultValue;!this.isValidLookup(f)&&U&&(C=!0,f=x),this.isValidLookup(f)||(_=!0,f=u);var L=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&_?void 0:f,G=U&&x!==f&&this.options.updateMissing;if(_||C||G){if(this.logger.log(G?"updateKey":"missingKey",l,c,u,G?x:f),o){var j=this.resolve(u,Ke(Ke({},t),{},{keySeparator:!1}));j&&j.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 A=[],N=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&N&&N[0])for(var k=0;k<N.length;k++)A.push(N[k]);else"all"===this.options.saveMissingTo?A=this.languageUtils.toResolveHierarchy(t.lng||this.language):A.push(t.lng||this.language);var w=function(e,n,s){var r=U&&s!==f?s:L;i.options.missingKeyHandler?i.options.missingKeyHandler(e,c,n,r,G,t):i.backendConnector&&i.backendConnector.saveMissing&&i.backendConnector.saveMissing(e,c,n,r,G,t),i.emit("missingKey",e,c,n,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&P?A.forEach((function(e){i.pluralResolver.getSuffixes(e,t).forEach((function(n){w([e],u+n,t["defaultValue".concat(n)]||x)}))})):w(A,u,x))}f=this.extendTranslation(f,e,t,d,s),_&&f===u&&this.options.appendNamespaceToMissingKey&&(f="".concat(c,":").concat(u)),(_||C)&&this.options.parseMissingKeyHandler&&(f="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(c,":").concat(u):u,C?f:void 0):this.options.parseMissingKeyHandler(f))}return r?(d.res=f,d):f}},{key:"extendTranslation",value:function(e,t,n,s,i){var r=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,Ke(Ke({},this.options.interpolation.defaultVariables),n),s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!n.skipInterpolation){n.interpolation&&this.interpolator.init(Ke(Ke({},n),{interpolation:Ke(Ke({},this.options.interpolation),n.interpolation)}));var o,a="string"==typeof e&&(n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){var u=e.match(this.interpolator.nestingRegexp);o=u&&u.length}var g=n.replace&&"string"!=typeof n.replace?n.replace:n;if(this.options.interpolation.defaultVariables&&(g=Ke(Ke({},this.options.interpolation.defaultVariables),g)),e=this.interpolator.interpolate(e,g,n.lng||this.language,n),a){var c=e.match(this.interpolator.nestingRegexp);o<(c&&c.length)&&(n.nest=!1)}!n.lng&&"v1"!==this.options.compatibilityAPI&&s&&s.res&&(n.lng=s.usedLng),!1!==n.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,s=new Array(e),o=0;o<e;o++)s[o]=arguments[o];return i&&i[0]===s[0]&&!n.context?(r.logger.warn("It seems you are nesting recursively key: ".concat(s[0]," in key: ").concat(t[0])),null):r.translate.apply(r,s.concat([t]))}),n)),n.interpolation&&this.interpolator.reset()}var l=n.postProcess||this.options.postProcess,p="string"==typeof l?[l]:l;return null!=e&&p&&p.length&&!1!==n.applyPostProcessor&&(e=Ye.handle(p,e,t,this.options&&this.options.postProcessPassResolved?Ke({i18nResolved:s},n):n,this)),e}},{key:"resolve",value:function(e){var t,n,s,i,r,o=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!o.isValidLookup(t)){var u=o.extractFromKey(e,a),g=u.key;n=g;var c=u.namespaces;o.options.fallbackNS&&(c=c.concat(o.options.fallbackNS));var l=void 0!==a.count&&"string"!=typeof a.count,p=l&&!a.ordinal&&0===a.count&&o.pluralResolver.shouldUseIntlApi(),h=void 0!==a.context&&("string"==typeof a.context||"number"==typeof a.context)&&""!==a.context,d=a.lngs?a.lngs:o.languageUtils.toResolveHierarchy(a.lng||o.language,a.fallbackLng);c.forEach((function(e){o.isValidLookup(t)||(r=e,!Je["".concat(d[0],"-").concat(e)]&&o.utils&&o.utils.hasLoadedNamespace&&!o.utils.hasLoadedNamespace(r)&&(Je["".concat(d[0],"-").concat(e)]=!0,o.logger.warn('key "'.concat(n,'" for languages "').concat(d.join(", "),'" won\'t get resolved as namespace "').concat(r,'" 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!!!")),d.forEach((function(n){if(!o.isValidLookup(t)){i=n;var r,u=[g];if(o.i18nFormat&&o.i18nFormat.addLookupKeys)o.i18nFormat.addLookupKeys(u,g,n,e,a);else{var c;l&&(c=o.pluralResolver.getSuffix(n,a.count,a));var d="".concat(o.options.pluralSeparator,"zero");if(l&&(u.push(g+c),p&&u.push(g+d)),h){var f="".concat(g).concat(o.options.contextSeparator).concat(a.context);u.push(f),l&&(u.push(f+c),p&&u.push(f+d))}}for(;r=u.pop();)o.isValidLookup(t)||(s=r,t=o.getResource(n,e,r,a))}})))}))}})),{res:t,usedKey:n,exactUsedKey:s,usedLng:i,usedNS:r}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,n,s):this.resourceStore.getResource(e,t,n,s)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t===n.substring(0,12)&&void 0!==e[n])return!0;return!1}}]),n}();function We(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Xe=function(){function e(t){le(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Me.create("languageUtils")}return de(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?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("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],n=e.split("-");return this.options.lowerCaseLng?n=n.map((function(e){return e.toLowerCase()})):2===n.length?(n[0]=n[0].toLowerCase(),n[1]=n[1].toUpperCase(),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=We(n[1].toLowerCase()))):3===n.length&&(n[0]=n[0].toLowerCase(),2===n[1].length&&(n[1]=n[1].toUpperCase()),"sgn"!==n[0]&&2===n[2].length&&(n[2]=n[2].toUpperCase()),t.indexOf(n[1].toLowerCase())>-1&&(n[1]=We(n[1].toLowerCase())),t.indexOf(n[2].toLowerCase())>-1&&(n[2]=We(n[2].toLowerCase()))),n.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||this.options.nonExplicitSupportedLngs)&&(e=this.getLanguagePartFromCode(e)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(e)>-1}},{key:"getBestMatchFromCodes",value:function(e){var t,n=this;return e?(e.forEach((function(e){if(!t){var s=n.formatLanguageCode(e);n.options.supportedLngs&&!n.isSupportedCode(s)||(t=s)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var s=n.getLanguagePartFromCode(e);if(n.isSupportedCode(s))return t=s;t=n.options.supportedLngs.find((function(e){return e===s?e:e.indexOf("-")<0&&s.indexOf("-")<0?void 0:0===e.indexOf(s)?e:void 0}))}})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))return e;if(!t)return e.default||[];var n=e[t];return n||(n=e[this.getScriptPartFromCode(t)]),n||(n=e[this.formatLanguageCode(t)]),n||(n=e[this.getLanguagePartFromCode(t)]),n||(n=e.default),n||[]}},{key:"toResolveHierarchy",value:function(e,t){var n=this,s=this.getFallbackCodes(t||this.options.fallbackLng||[],e),i=[],r=function(e){e&&(n.isSupportedCode(e)?i.push(e):n.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&r(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&r(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&r(this.getLanguagePartFromCode(e))):"string"==typeof e&&r(this.formatLanguageCode(e)),s.forEach((function(e){i.indexOf(e)<0&&r(n.formatLanguageCode(e))})),i}}]),e}(),Ze=[{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}],Qe={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},et=["v1","v2","v3"],tt={zero:0,one:1,two:2,few:3,many:4,other:5};var nt=function(){function e(t){var n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};le(this,e),this.languageUtils=t,this.options=s,this.logger=Me.create("pluralResolver"),this.options.compatibilityJSON&&"v4"!==this.options.compatibilityJSON||"undefined"!=typeof Intl&&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=(n={},Ze.forEach((function(e){e.lngs.forEach((function(t){n[t]={numbers:e.nr,plurals:Qe[e.fc]}}))})),n)}return de(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,t);return this.shouldUseIntlApi()?n&&n.resolvedOptions().pluralCategories.length>1:n&&n.numbers.length>1}},{key:"getPluralFormsOfKey",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,n).map((function(e){return"".concat(t).concat(e)}))}},{key:"getSuffixes",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s=this.getRule(e,n);return s?this.shouldUseIntlApi()?s.resolvedOptions().pluralCategories.sort((function(e,t){return tt[e]-tt[t]})).map((function(e){return"".concat(t.options.prepend).concat(e)})):s.numbers.map((function(s){return t.getSuffix(e,s,n)})):[]}},{key:"getSuffix",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},s=this.getRule(e,n);return s?this.shouldUseIntlApi()?"".concat(this.options.prepend).concat(s.select(t)):this.getSuffixRetroCompatible(s,t):(this.logger.warn("no plural rule found for: ".concat(e)),"")}},{key:"getSuffixRetroCompatible",value:function(e,t){var n=this,s=e.noAbs?e.plurals(t):e.plurals(Math.abs(t)),i=e.numbers[s];this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]&&(2===i?i="plural":1===i&&(i=""));var r=function(){return n.options.prepend&&i.toString()?n.options.prepend+i.toString():i.toString()};return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?"_plural_".concat(i.toString()):r():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?r():this.options.prepend&&s.toString()?this.options.prepend+s.toString():s.toString()}},{key:"shouldUseIntlApi",value:function(){return!et.includes(this.options.compatibilityJSON)}}]),e}();function st(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function it(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?st(Object(n),!0).forEach((function(t){ye(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):st(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function rt(e,t,n){var s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],r=function(e,t,n){var s=xe(e,n);return void 0!==s?s:xe(t,n)}(e,t,n);return!r&&i&&"string"==typeof n&&void 0===(r=we(e,n,s))&&(r=we(t,n,s)),r}var ot=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};le(this,e),this.logger=Me.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return de(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:Ae,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?Ge(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?Ge(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?Ge(t.nestingPrefix):t.nestingPrefixEscaped||Ge("$t("),this.nestingSuffix=t.nestingSuffix?Ge(t.nestingSuffix):t.nestingSuffixEscaped||Ge(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&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 n="".concat(this.nestingPrefix,"(.+?)").concat(this.nestingSuffix);this.nestingRegexp=new RegExp(n,"g")}},{key:"interpolate",value:function(e,t,n,s){var i,r,o,a=this,u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function g(e){return e.replace(/\$/g,"$$$$")}var c=function(e){if(e.indexOf(a.formatSeparator)<0){var i=rt(t,u,e,a.options.keySeparator,a.options.ignoreJSONStructure);return a.alwaysFormat?a.format(i,void 0,n,it(it(it({},s),t),{},{interpolationkey:e})):i}var r=e.split(a.formatSeparator),o=r.shift().trim(),g=r.join(a.formatSeparator).trim();return a.format(rt(t,u,o,a.options.keySeparator,a.options.ignoreJSONStructure),g,n,it(it(it({},s),t),{},{interpolationkey:o}))};this.resetRegExp();var l=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,p=s&&s.interpolation&&void 0!==s.interpolation.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return g(e)}},{regex:this.regexp,safeValue:function(e){return a.escapeValue?g(a.escape(e)):g(e)}}].forEach((function(t){for(o=0;i=t.regex.exec(e);){var n=i[1].trim();if(void 0===(r=c(n)))if("function"==typeof l){var u=l(e,i,s);r="string"==typeof u?u:""}else if(s&&Object.prototype.hasOwnProperty.call(s,n))r="";else{if(p){r=i[0];continue}a.logger.warn("missed to pass in variable ".concat(n," for interpolating ").concat(e)),r=""}else"string"==typeof r||a.useRawValueToEscape||(r=Pe(r));var g=t.safeValue(r);if(e=e.replace(i[0],g),p?(t.regex.lastIndex+=r.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,++o>=a.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var n,s,i,r=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function a(e,t){var n=this.nestingOptionsSeparator;if(e.indexOf(n)<0)return e;var s=e.split(new RegExp("".concat(n,"[ ]*{"))),r="{".concat(s[1]);e=s[0];var o=(r=this.interpolate(r,i)).match(/'/g),a=r.match(/"/g);(o&&o.length%2==0&&!a||a.length%2!=0)&&(r=r.replace(/'/g,'"'));try{i=JSON.parse(r),t&&(i=it(it({},t),i))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(n).concat(r)}return delete i.defaultValue,e}for(;n=this.nestingRegexp.exec(e);){var u=[];(i=(i=it({},o)).replace&&"string"!=typeof i.replace?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;var g=!1;if(-1!==n[0].indexOf(this.formatSeparator)&&!/{.*}/.test(n[1])){var c=n[1].split(this.formatSeparator).map((function(e){return e.trim()}));n[1]=c.shift(),u=c,g=!0}if((s=t(a.call(this,n[1].trim(),i),i))&&n[0]===e&&"string"!=typeof s)return s;"string"!=typeof s&&(s=Pe(s)),s||(this.logger.warn("missed to resolve ".concat(n[1]," for nesting ").concat(e)),s=""),g&&(s=u.reduce((function(e,t){return r.format(e,t,o.lng,it(it({},o),{},{interpolationkey:n[1].trim()}))}),s.trim())),e=e.replace(n[0],s),this.regexp.lastIndex=0}return e}}]),e}();function at(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function ut(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?at(Object(n),!0).forEach((function(t){ye(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):at(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function gt(e){var t={};return function(n,s,i){var r=s+JSON.stringify(i),o=t[r];return o||(o=e(s,i),t[r]=o),o(n)}}var ct=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};le(this,e),this.logger=Me.create("formatter"),this.options=t,this.formats={number:gt((function(e,t){var n=new Intl.NumberFormat(e,ut({},t));return function(e){return n.format(e)}})),currency:gt((function(e,t){var n=new Intl.NumberFormat(e,ut(ut({},t),{},{style:"currency"}));return function(e){return n.format(e)}})),datetime:gt((function(e,t){var n=new Intl.DateTimeFormat(e,ut({},t));return function(e){return n.format(e)}})),relativetime:gt((function(e,t){var n=new Intl.RelativeTimeFormat(e,ut({},t));return function(e){return n.format(e,t.range||"day")}})),list:gt((function(e,t){var n=new Intl.ListFormat(e,ut({},t));return function(e){return n.format(e)}}))},this.init(t)}return de(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?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()]=gt(t)}},{key:"format",value:function(e,t,n){var s=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return t.split(this.formatSeparator).reduce((function(e,t){var r=function(e){var t=e.toLowerCase().trim(),n={};if(e.indexOf("(")>-1){var s=e.split("(");t=s[0].toLowerCase().trim();var i=s[1].substring(0,s[1].length-1);"currency"===t&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):"relativetime"===t&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach((function(e){if(e){var t=Ie(e.split(":")),s=t[0],i=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");n[s.trim()]||(n[s.trim()]=i),"false"===i&&(n[s.trim()]=!1),"true"===i&&(n[s.trim()]=!0),isNaN(i)||(n[s.trim()]=parseInt(i,10))}}))}return{formatName:t,formatOptions:n}}(t),o=r.formatName,a=r.formatOptions;if(s.formats[o]){var u=e;try{var g=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},c=g.locale||g.lng||i.locale||i.lng||n;u=s.formats[o](e,c,ut(ut(ut({},a),i),g))}catch(e){s.logger.warn(e)}return u}return s.logger.warn("there was no format function for ".concat(o)),e}),e)}}]),e}();function lt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function pt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?lt(Object(n),!0).forEach((function(t){ye(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ht(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,s=Se(e);if(t){var i=Se(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return Ee(this,n)}}var dt=function(e){ve(n,Ce);var t=ht(n);function n(e,s,i){var r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return le(this,n),r=t.call(this),Ne&&Ce.call(fe(r)),r.backend=e,r.store=s,r.services=i,r.languageUtils=i.languageUtils,r.options=o,r.logger=Me.create("backendConnector"),r.waitingReads=[],r.maxParallelReads=o.maxParallelReads||10,r.readingCalls=0,r.maxRetries=o.maxRetries>=0?o.maxRetries:5,r.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,r.state={},r.queue=[],r.backend&&r.backend.init&&r.backend.init(i,o.backend,o),r}return de(n,[{key:"queueLoad",value:function(e,t,n,s){var i=this,r={},o={},a={},u={};return e.forEach((function(e){var s=!0;t.forEach((function(t){var a="".concat(e,"|").concat(t);!n.reload&&i.store.hasResourceBundle(e,t)?i.state[a]=2:i.state[a]<0||(1===i.state[a]?void 0===o[a]&&(o[a]=!0):(i.state[a]=1,s=!1,void 0===o[a]&&(o[a]=!0),void 0===r[a]&&(r[a]=!0),void 0===u[t]&&(u[t]=!0)))})),s||(a[e]=!0)})),(Object.keys(r).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(r),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(u)}}},{key:"loaded",value:function(e,t,n){var s=e.split("|"),i=s[0],r=s[1];t&&this.emit("failedLoading",i,r,t),n&&this.store.addResourceBundle(i,r,n),this.state[e]=t?-1:2;var o={};this.queue.forEach((function(n){var s,a,u,g,c,l;s=n.loaded,a=r,g=Ue(s,[i],Object),c=g.obj,l=g.k,c[l]=c[l]||[],u&&(c[l]=c[l].concat(a)),u||c[l].push(a),function(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}(n,e),t&&n.errors.push(t),0!==n.pendingCount||n.done||(Object.keys(n.loaded).forEach((function(e){o[e]||(o[e]={});var t=n.loaded[e];t.length&&t.forEach((function(t){void 0===o[e][t]&&(o[e][t]=!0)}))})),n.done=!0,n.errors.length?n.callback(n.errors):n.callback())})),this.emit("loaded",o),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,n){var s=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)this.waitingReads.push({lng:e,ns:t,fcName:n,tried:i,wait:r,callback:o});else{this.readingCalls++;var a=function(a,u){if(s.readingCalls--,s.waitingReads.length>0){var g=s.waitingReads.shift();s.read(g.lng,g.ns,g.fcName,g.tried,g.wait,g.callback)}a&&u&&i<s.maxRetries?setTimeout((function(){s.read.call(s,e,t,n,i+1,2*r,o)}),r):o(a,u)},u=this.backend[n].bind(this.backend);if(2!==u.length)return u(e,t,a);try{var g=u(e,t);g&&"function"==typeof g.then?g.then((function(e){return a(null,e)})).catch(a):a(null,g)}catch(e){a(e)}}}},{key:"prepareLoading",value:function(e,t){var n=this,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=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."),i&&i();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var r=this.queueLoad(e,t,s,i);if(!r.toLoad.length)return r.pending.length||i(),null;r.toLoad.forEach((function(e){n.loadOne(e)}))}},{key:"load",value:function(e,t,n){this.prepareLoading(e,t,{},n)}},{key:"reload",value:function(e,t,n){this.prepareLoading(e,t,{reload:!0},n)}},{key:"loadOne",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",s=e.split("|"),i=s[0],r=s[1];this.read(i,r,"read",void 0,void 0,(function(s,o){s&&t.logger.warn("".concat(n,"loading namespace ").concat(r," for language ").concat(i," failed"),s),!s&&o&&t.logger.log("".concat(n,"loaded namespace ").concat(r," for language ").concat(i),o),t.loaded(e,s,o)}))}},{key:"saveMissing",value:function(e,t,n,s,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t))this.logger.warn('did not save key "'.concat(n,'" as the namespace "').concat(t,'" 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(null!=n&&""!==n){if(this.backend&&this.backend.create){var a=pt(pt({},r),{},{isUpdate:i}),u=this.backend.create.bind(this.backend);if(u.length<6)try{var g;(g=5===u.length?u(e,t,n,s,a):u(e,t,n,s))&&"function"==typeof g.then?g.then((function(e){return o(null,e)})).catch(o):o(null,g)}catch(e){o(e)}else u(e,t,n,s,o,a)}e&&e[0]&&this.store.addResource(e[0],t,n,s)}}}]),n}();function ft(){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(e){var t={};if("object"===ce(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===ce(e[2])||"object"===ce(e[3])){var n=e[3]||e[2];Object.keys(n).forEach((function(e){t[e]=n[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,n,s){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function mt(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function vt(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,s)}return n}function Et(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vt(Object(n),!0).forEach((function(t){ye(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function St(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,s=Se(e);if(t){var i=Se(this).constructor;n=Reflect.construct(s,arguments,i)}else n=s.apply(this,arguments);return Ee(this,n)}}function yt(){}var Tt=function(e){ve(n,Ce);var t=St(n);function n(){var e,s,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(le(this,n),e=t.call(this),Ne&&Ce.call(fe(e)),e.options=mt(i),e.services={},e.logger=Me,e.modules={external:[]},s=fe(e),Object.getOwnPropertyNames(Object.getPrototypeOf(s)).forEach((function(e){"function"==typeof s[e]&&(s[e]=s[e].bind(s))})),r&&!e.isInitialized&&!i.isClone){if(!e.options.initImmediate)return e.init(i,r),Ee(e,fe(e));setTimeout((function(){e.init(i,r)}),0)}return e}return de(n,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(n=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var s=ft();function i(e){return e?"function"==typeof e?new e:e:null}if(this.options=Et(Et(Et({},s),this.options),mt(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=Et(Et({},s.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var r;this.modules.logger?Me.init(i(this.modules.logger),this.options):Me.init(null,this.options),this.modules.formatter?r=this.modules.formatter:"undefined"!=typeof Intl&&(r=ct);var o=new Xe(this.options);this.store=new He(this.options.resources,this.options);var a=this.services;a.logger=Me,a.resourceStore=this.store,a.languageUtils=o,a.pluralResolver=new nt(o,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!r||this.options.interpolation.format&&this.options.interpolation.format!==s.interpolation.format||(a.formatter=i(r),a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new ot(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new dt(i(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on("*",(function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];e.emit.apply(e,[t].concat(s))})),this.modules.languageDetector&&(a.languageDetector=i(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=i(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new ze(this.services,this.options),this.translator.on("*",(function(t){for(var n=arguments.length,s=new Array(n>1?n-1:0),i=1;i<n;i++)s[i-1]=arguments[i];e.emit.apply(e,[t].concat(s))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}if(this.format=this.options.interpolation.format,n||(n=yt),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&"dev"!==u[0]&&(this.options.lng=u[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(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((function(t){e[t]=function(){var n;return(n=e.store)[t].apply(n,arguments),e}}));var g=_e(),c=function(){var t=function(t,s){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),g.resolve(s),n(t,s)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?c():setTimeout(c,0),g}},{key:"loadResources",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:yt,s="string"==typeof e?e:this.language;if("function"==typeof e&&(n=e),!this.options.resources||this.options.partialBundledLanguages){if(s&&"cimode"===s.toLowerCase())return n();var i=[],r=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){i.indexOf(e)<0&&i.push(e)}))};if(s)r(s);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return r(e)}));this.options.preload&&this.options.preload.forEach((function(e){return r(e)})),this.services.backendConnector.load(i,this.options.ns,(function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),n(e)}))}else n(null)}},{key:"reloadResources",value:function(e,t,n){var s=_e();return e||(e=this.languages),t||(t=this.options.ns),n||(n=yt),this.services.backendConnector.reload(e,t,(function(e){s.resolve(),n(e)})),s}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&Ye.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var n=this.languages[t];if(!(["cimode","dev"].indexOf(n)>-1)&&this.store.hasLanguageSomeTranslations(n)){this.resolvedLanguage=n;break}}}},{key:"changeLanguage",value:function(e,t){var n=this;this.isLanguageChangingTo=e;var s=_e();this.emit("languageChanging",e);var i=function(e){n.language=e,n.languages=n.services.languageUtils.toResolveHierarchy(e),n.resolvedLanguage=void 0,n.setResolvedLanguage(e)},r=function(r){e||r||!n.services.languageDetector||(r=[]);var o="string"==typeof r?r:n.services.languageUtils.getBestMatchFromCodes(r);o&&(n.language||i(o),n.translator.language||n.translator.changeLanguage(o),n.services.languageDetector&&n.services.languageDetector.cacheUserLanguage&&n.services.languageDetector.cacheUserLanguage(o)),n.loadResources(o,(function(e){!function(e,r){r?(i(r),n.translator.changeLanguage(r),n.isLanguageChangingTo=void 0,n.emit("languageChanged",r),n.logger.log("languageChanged",r)):n.isLanguageChangingTo=void 0,s.resolve((function(){return n.t.apply(n,arguments)})),t&&t(e,(function(){return n.t.apply(n,arguments)}))}(e,o)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e):r(this.services.languageDetector.detect()),s}},{key:"getFixedT",value:function(e,t,n){var s=this,i=function e(t,i){var r;if("object"!==ce(i)){for(var o=arguments.length,a=new Array(o>2?o-2:0),u=2;u<o;u++)a[u-2]=arguments[u];r=s.options.overloadTranslationOptionHandler([t,i].concat(a))}else r=Et({},i);r.lng=r.lng||e.lng,r.lngs=r.lngs||e.lngs,r.ns=r.ns||e.ns,r.keyPrefix=r.keyPrefix||n||e.keyPrefix;var g,c=s.options.keySeparator||".";return g=r.keyPrefix&&Array.isArray(t)?t.map((function(e){return"".concat(r.keyPrefix).concat(c).concat(e)})):r.keyPrefix?"".concat(r.keyPrefix).concat(c).concat(t):t,s.t(g,r)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=n,i}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,n=arguments.length>1&&void 0!==arguments[1]?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 s=n.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,r=this.languages[this.languages.length-1];if("cimode"===s.toLowerCase())return!0;var o=function(e,n){var s=t.services.backendConnector.state["".concat(e,"|").concat(n)];return-1===s||2===s};if(n.precheck){var a=n.precheck(this,o);if(void 0!==a)return a}return!!this.hasResourceBundle(s,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(s,e)||i&&!o(r,e)))}},{key:"loadNamespaces",value:function(e,t){var n=this,s=_e();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){n.options.ns.indexOf(e)<0&&n.options.ns.push(e)})),this.loadResources((function(e){s.resolve(),t&&t(e)})),s):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var n=_e();"string"==typeof e&&(e=[e]);var s=this.options.preload||[],i=e.filter((function(e){return s.indexOf(e)<0}));return i.length?(this.options.preload=s.concat(i),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";var t=this.services&&this.services.languageUtils||new Xe(ft());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(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:yt,i=Et(Et(Et({},this.options),t),{isClone:!0}),r=new n(i);void 0===t.debug&&void 0===t.prefix||(r.logger=r.logger.clone(t));return["store","services","language"].forEach((function(t){r[t]=e[t]})),r.services=Et({},this.services),r.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r.translator=new ze(r.services,r.options),r.translator.on("*",(function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),s=1;s<t;s++)n[s-1]=arguments[s];r.emit.apply(r,[e].concat(n))})),r.init(i,s),r.translator.options=r.options,r.translator.backendConnector.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),n}();ye(Tt,"createInstance",(function(){return new Tt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}));var It=Tt.createInstance();It.createInstance=Tt.createInstance,It.createInstance,It.dir,It.init,It.loadResources,It.reloadResources,It.use,It.changeLanguage,It.getFixedT,It.t,It.exists,It.setDefaultNamespace,It.hasLoadedNamespace,It.loadNamespaces,It.loadLanguages;class bt extends ee{constructor(){super(),this.languages=null}static getInstance(){return bt.instance||(bt.instance=new bt),bt.instance}provideLanguages(e){N||(this.languages=e,console.log("TUITranslateService.provideLanguages ok."))}useI18n(e){N||(this.languages?It.init({compatibilityJSON:"v3",lng:e||"zh",fallbackLng:"zh",detection:{order:["querystring","navigator"],caches:["localStorage","cookie"]},resources:{en:{translation:this.languages.en},zh:{translation:this.languages.zh_cn}}}):console.warn("TUITranslateService.useI18next not have messages."))}changeLanguage(e){return It.changeLanguage(e)}t(e){if(!this.languages){let t=e;return!T(e)&&e.indexOf(".")>-1&&(t=e.split(".").pop()||""),t}return It.t(e)}}class Ot extends ee{constructor(){super(),this.serv="TUIConversationService"}static getInstance(){return Ot.instance||(Ot.instance=new Ot),Ot.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(a.CONV,"conversationList",t),this.updateCurrentConversation()}onTotalUnreadCountUpdated(e){this.getEngine().TUIStore.update(a.CONV,"totalUnreadCount",e)}onMessageReceived(e){const t=this.getEngine(),n=this.getEngine().TUIStore.getData(a.CONV,"conversationList");let s=!1;for(let i=0;i<e.length;i++){if(e[i].type!==t.TYPES.MSG_GRP_SYS_NOTICE)continue;const{operationType:r}=e[i].payload,o=`GROUP${e[i].to}`,a=4===r||5===r||8===r,u=2===r||6===r||7===r;if(a||u)for(let e=0;e<n.length;e++)if(n[e].type!==t.TYPES.CONV_C2C&&n[e].conversationID===o){if(a){n[e].operationType=r,s=!0;break}if(u&&n[e].operationType>0){n[e].operationType=0,s=!0;break}}}s&&this.getEngine().TUIStore.update(a.CONV,"conversationList",n)}getConversationInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getConversationList().then((t=>{const{conversationList:n,isSyncCompleted:s}=t.data;if(console.log(`${this.serv}.init, getConversationList count:${n.length} isSyncCompleted:${s}`),n.length>0){this.onConversationListUpdated(n);const t=e.chat.getTotalUnreadMessageCount();this.onTotalUnreadCountUpdated(t)}}))}switchConversation(e){return i(this,void 0,void 0,(function*(){const t=`${this.serv}.switchConversation`,n=this.getEngine();if(!e)return n.TUIStore.reset(a.CHAT,["messageList","isCompleted","nextReqMessageID"]),n.TUIStore.update(a.CONV,"currentConversationID",""),n.TUIStore.update(a.CONV,"currentConversation",null),console.log(`${t} conversationID is empty, conversationID:${e}`),Promise.resolve({});if(!e.startsWith(n.TYPES.CONV_C2C)&&!e.startsWith(n.TYPES.CONV_GROUP))return console.warn(`${t} conversationID is invalid, conversationID:${e}`),Promise.reject({code:p.INVALID_CONV_ID,message:d.INVALID_CONV_ID});const s=n.TUIStore.getData(a.CONV,"currentConversationID");if(s&&s===e)return this.setMessageRead(s),console.warn(`${t} please check conversationID, conversationID:${e}`),Promise.resolve({code:p.CONV_ID_SAME,message:d.CONV_ID_SAME});const i=yield this.getConversationModel(e);return T(i)?(console.warn(`${t} target conversation is not exist, conversationID:${e}`),Promise.reject({code:p.CONV_NOT_EXIST,message:d.CONV_NOT_EXIST})):(s&&this.setMessageRead(s),e&&this.setMessageRead(e),n.TUIStore.reset(a.CHAT,["messageList","isCompleted","nextReqMessageID"]),n.TUIStore.update(a.CONV,"currentConversationID",e),n.TUIStore.update(a.CONV,"currentConversation",i),Promise.resolve(i))}))}getConversationModel(e){return i(this,void 0,void 0,(function*(){let t=this.findConversation(e);if(T(t))try{const n=yield this.getConversationProfile(e);n.data&&n.data.conversation&&(t=new te(n.data.conversation))}catch(e){t=void 0}return t}))}findConversation(e){let t;const n=this.getEngine().TUIStore.getData(a.CONV,"conversationList");for(let s=0;s<n.length;s++)if(n[s].conversationID===e){t=n[s];break}return t}updateCurrentConversation(){const e=this.getEngine(),t=e.TUIStore.getData(a.CONV,"currentConversationID"),n=this.findConversation(t);n&&e.TUIStore.update(a.CONV,"currentConversation",n)}getConversationList(){return this.getEngine().chat.getConversationList()}getConversationProfile(e){return this.getEngine().chat.getConversationProfile(e)}deleteConversation(e){return this.getEngine().chat.deleteConversation(e).then((t=>{const n=this.getEngine().TUIStore.getData(a.CONV,"currentConversationID");return console.log(`${this.serv}.deleteConversation conversationID:${e} currentConversationID:${n}`),e===n&&(this.getEngine().TUIStore.update(a.CONV,"currentConversationID",""),this.getEngine().TUIStore.update(a.CONV,"currentConversation",null)),t}))}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((e=>(this.getEngine().TUIStore.update(a.CHAT,"messageList",[]),this.getEngine().TUIStore.update(a.CHAT,"nextReqMessageID",""),this.getEngine().TUIStore.update(a.CHAT,"isCompleted",!0),e)))}setMessageRead(e){return this.getEngine().chat.setMessageRead({conversationID:e})}filterSystemConversation(e){return e.filter((e=>e.type!==this.getEngine().TYPES.CONV_SYSTEM))}}class Dt{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))}onProfileUpdated(e){const t=this.getEngine(),n=t.TUIStore.getData(a.USER,"userProfile");e.forEach((e=>{e.userID===n.userID&&t.TUIStore.update(a.USER,"userProfile",e)}))}onBlacklistUpdated(e){const t=this.getEngine();this.getBlacklistProfile(e).then((e=>{t.TUIStore.update(a.USER,"userBlacklist",e)}))}getBlacklistProfile(e){const t=[];let n=0;for(;n<e.length;)t.push(e.slice(n,n+=100));const s=[];t.forEach((e=>{s.push(this.TUIUserService.getUserProfile({userIDList:e}))}));const i=[];return Promise.all(s).then((e=>(e.forEach((e=>{const t=e.data.map((e=>{const{userID:t,nick:n,avatar:s}=e;return{userID:t,nick:n,avatar:s}}));i.push(...t)})),i)))}getUserProfile(e){const t=this.getEngine();return T(e)?t.chat.getMyProfile().then((e=>(t.TUIStore.update(a.USER,"userProfile",e.data),e))).catch((e=>Promise.reject(e))):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 Mt(e,t,n=!0){!function(e,t){w?F.setStorageSync(e,t):Pt()&&localStorage.setItem(e,JSON.stringify(t))}(n?_t(e):e,t)}function Ct(e,t=!0){try{return function(e){if(w)return F.getStorageSync(e);if(Pt()){const t=localStorage.getItem(e);if("undefined"!==t)return JSON.parse(t)}return}(t?_t(e):e)}catch(e){return void console.warn("Storage.getStorageItem error:",e)}}function _t(e){return`chat_engine_${e}`}function Pt(){return navigator&&navigator.cookieEnabled&&localStorage}class Ut{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){const e=this.getEngine(),t=Ct("displayOnlineStatus")||!1;e.TUIStore.update(a.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(a.CONV,{conversationList:()=>{const t=e.TUIStore.getData(a.APP,"enabledOnlineStatus"),n=e.TUIStore.getData(a.USER,"displayOnlineStatus");t&&n&&this.startToSubscribe()}})}onUserStatusUpdated(e){this.getEngine().TUIStore.update(a.USER,"userStatusList",e)}switchUserStatus(e){const t=this.getEngine(),{displayOnlineStatus:n=!1}=e;t.TUIStore.update(a.USER,"displayOnlineStatus",n),Mt("displayOnlineStatus",n);const s=t.TUIStore.getData(a.APP,"enabledOnlineStatus");s?!0===n?this.startToSubscribe():this.unsubscribeUserStatus():console.warn(`UserStatusHandler.switchUserStatus enabledOnlineStatus:${s} displayOnlineStatus:${n}`)}getUserStatus(e){const t=this.getEngine();return t.chat.getUserStatus(e).then((e=>{const{successUserList:n}=e.data;return n.length>0&&t.TUIStore.update(a.USER,"userStatusList",n),e})).catch((e=>Promise.reject(e)))}subscribeUserStatus(e){var t;const n=(null===(t=null==e?void 0:e.userIDList)||void 0===t?void 0:t.length)||0;return 0===n?(console.warn(`UserStatusHandler.subscribeUserStatus userID count:${n}`),Promise.resolve()):this.getEngine().chat.subscribeUserStatus(e)}unsubscribeUserStatus(e){const t=this.getEngine(),{userIDList:n=[]}=e||{};return t.chat.unsubscribeUserStatus({userIDList:n}).then((e=>{const{failureUserList:s}=e.data,i=[];return n.forEach((e=>{s.includes(e)||i.push({userID:e,statusType:u.UNSUB_USER})})),t.TUIStore.update(a.USER,"userStatusList",i),e})).catch((e=>Promise.reject(e)))}startToSubscribe(){const e=this.getEngine(),t=e.TUIStore.getData(a.CONV,"conversationList"),n=e.TUIStore.getData(a.USER,"userStatusList"),s=[];t.forEach((t=>{if(t.type===e.TYPES.CONV_C2C){const i=t.conversationID.replace(e.TYPES.CONV_C2C,"");n.has(i)||s.push(i)}})),0!==s.length&&e.chat.isReady()&&(this.subscribeUserStatus({userIDList:s}),this.getUserStatus({userIDList:s}))}}class Rt extends ee{constructor(){super(),this.userProfileHandler=new Dt(this),this.userStatusHandler=new Ut(this)}static getInstance(){return Rt.instance||(Rt.instance=new Rt),Rt.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(a.USER,"kickedOut",e.type)}onNetStateChange(e){this.getEngine().TUIStore.update(a.USER,"netStateChange",e.state)}initMessageReadReceipt(){const e=Ct("displayMessageReadReceipt")||!0;this.getEngine().TUIStore.update(a.USER,"displayMessageReadReceipt",e)}switchUserStatus(e){return this.userStatusHandler.switchUserStatus(e)}switchMessageReadStatus(e){this.getEngine().TUIStore.update(a.USER,"displayMessageReadReceipt",e),Mt("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 xt{constructor(e){this.TUIChatService=e}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:""};return t.name=e.payload.data.indexOf("@2x")<0?`${e.payload.data}@2x`:e.payload.data,t.url=`${R}${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=`${x}pointx=${t.lon}&pointy=${t.lat}&name=${e.payload.description}`,t.url=`${L}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:D(e.payload.fileSize)}}handleCustomMessage(e){var t;const n=this.handleCreateGroupCustomMessage(e);return{custom:this.handleCallKitSignaling(e)||n||(null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.extension)||`[${this.t("message.custom.自定义消息")}]`,businessID:n?"group_create":""}}handleMergeMessage(e){return Object.assign({},e.payload)}handleGroupTipsMessage(e){var t,n,s,i,r,o;const a=this.getEngine(),u={text:""};let g=(null==e?void 0:e.nick)||(null===(n=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.userIDList)||void 0===n?void 0:n.join(","));switch((null===(i=null===(s=null==e?void 0:e.payload)||void 0===s?void 0:s.memberList)||void 0===i?void 0:i.length)>0&&(g="",null===(o=null===(r=null==e?void 0:e.payload)||void 0===r?void 0:r.memberList)||void 0===o||o.map((e=>{g+=`${(null==e?void 0:e.nick)||(null==e?void 0:e.userID)},`})),g=null==g?void 0:g.slice(0,-1)),e.payload.operationType){case a.TYPES.GRP_TIP_MBR_JOIN:u.text=`${g} ${this.t("message.tip.加入群组")}`;break;case a.TYPES.GRP_TIP_MBR_QUIT:u.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.退出群组")}`;break;case a.TYPES.GRP_TIP_MBR_KICKED_OUT:u.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.被")}${this.t("message.tip.踢出群组")}`;break;case a.TYPES.GRP_TIP_MBR_SET_ADMIN:u.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.成为管理员")}`;break;case a.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:u.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.被撤销管理员")}`;break;case a.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:u.text=this.handleGroupProfileUpdated(e);break;case a.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:for(const t of e.payload.memberList)t.muteTime>0?u.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.被禁言")}`:u.text=`${this.t("message.tip.群成员")}:${g} ${this.t("message.tip.被取消禁言")}`;break;default:u.text=`[${this.t("message.tip.群提示消息")}]`}return u}handleGroupSystemMessage(e){const t=e.payload.groupProfile.name||e.payload.groupProfile.groupID,n={text:""};switch(e.payload.operationType){case 1:n.text=`${e.payload.operatorID} ${this.t("message.tip.申请加入群组")}:${t}`;break;case 2:n.text=`${this.t("message.tip.成功加入群组")}:${t}`;break;case 3:n.text=`${this.t("message.tip.申请加入群组")}:${t} ${this.t("message.tip.被拒绝")}`;break;case 4:n.text=`${this.t("message.tip.你被管理员")}${e.payload.operatorID} ${this.t("message.tip.踢出群组")}:${t}`;break;case 5:n.text=`${this.t("message.tip.群")}:${t} ${this.t("message.tip.被")} ${e.payload.operatorID} ${this.t("message.tip.解散")}`;break;case 6:n.text=`${e.payload.operatorID} ${this.t("message.tip.创建群")}:${t}`;break;case 7:case 12:n.text=`${e.payload.operatorID} ${this.t("message.tip.邀请你加群")}:${t}`;break;case 8:n.text=`${this.t("message.tip.你退出群组")}:${t}`;break;case 9:n.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.设置为群")}:${t} ${this.t("message.tip.的管理员")}`;break;case 10:n.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.撤销群")}:${t} ${this.t("message.tip.的管理员身份")}`;break;case 13:n.text=`${e.payload.operatorID} ${this.t("message.tip.同意加群")}:${t}`;break;case 14:n.text=`${e.payload.operatorID} ${this.t("message.tip.拒接加群")}:${t}`;break;case 255:n.text=`${this.t("message.tip.自定义群系统通知")}: ${e.payload.userDefinedField}`;break;default:n.text="未解析的群系统通知"}return n}handleCallKitSignaling(e){var t,n,s,i,r,o,a,u,g,c;const l=O(e.payload.data);if(1!==(null==l?void 0:l.businessID))return"";const p=O(null==l?void 0:l.data);let h="";null===(t=null==l?void 0:l.inviteeList)||void 0===t||t.forEach((e=>{h+=`${e}、`})),h=h.substring(0,h.lastIndexOf("、"));const d=null==l?void 0:l.inviter;switch(null==l?void 0:l.actionType){case 1:return"audioCall"!==(null===(n=null==p?void 0:p.data)||void 0===n?void 0:n.cmd)&&"videoCall"!==(null===(s=null==p?void 0:p.data)||void 0===s?void 0:s.cmd)||!(null==l?void 0:l.groupID)?"hangup"===(null===(i=null==p?void 0:p.data)||void 0===i?void 0:i.cmd)?(null==l?void 0:l.groupID)?`${this.t("message.custom.结束群聊")}`:`${this.t("message.custom.通话时长")}:${function(e){const t=e;let n,s,i,r="";return t>=3600?(n=parseInt(""+t/3600,10)<10?`0${parseInt(""+t/3600,10)}`:parseInt(""+t/3600,10),s=parseInt(""+t%60/60,10)<10?`0${parseInt(""+t%60/60,10)}`:parseInt(""+t%60/60,10),i=t%3600<10?"0"+t%3600:t%3600,i>60&&(s=parseInt(""+i/60,10)<10?`0${parseInt(""+i/60,10)}`:parseInt(""+i/60,10),i=i%60<10?"0"+i%60:i%60),r=`${n}:${s}:${i}`):t>=60&&t<3600?(s=parseInt(""+t/60,10)<10?`0${parseInt(""+t/60,10)}`:parseInt(""+t/60,10),i=t%60<10?"0"+t%60:t%60,r=`00:${s}:${i}`):t<60&&(i=t<10?`0${t}`:t,r=`00:00:${i}`),r}(null==p?void 0:p.call_end)}`:"switchToAudio"===(null===(r=null==p?void 0:p.data)||void 0===r?void 0:r.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(o=null==p?void 0:p.data)||void 0===o?void 0:o.cmd)?`${this.t("message.custom.切换视频通话")}`:`${this.t("message.custom.发起通话")}`:`${d} ${this.t("message.custom.发起通话")}`;case 2:return(null==l?void 0:l.groupID)?`${d} ${this.t("message.custom.取消通话")}`:this.t("message.custom.取消通话");case 3:return"switchToAudio"===(null===(a=null==p?void 0:p.data)||void 0===a?void 0:a.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(u=null==p?void 0:p.data)||void 0===u?void 0:u.cmd)?`${this.t("message.custom.切换视频通话")}`:(null==l?void 0:l.groupID)?`${h} ${this.t("message.custom.已接听")}`:this.t("message.custom.已接听");case 4:return(null==l?void 0:l.groupID)?`${h} ${this.t("message.custom.拒绝通话")}`:this.t("message.custom.拒绝通话");case 5:return"switchToAudio"===(null===(g=null==p?void 0:p.data)||void 0===g?void 0:g.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(c=null==p?void 0:p.data)||void 0===c?void 0:c.cmd)?`${this.t("message.custom.切换视频通话")}`:(null==l?void 0:l.groupID)?`${h} ${this.t("message.custom.无应答")}`:this.t("message.custom.无应答");default:return""}}handleCreateGroupCustomMessage(e){let t;try{const n=O(e.payload.data);"group_create"===n.businessID&&(t=`${n.opUser} ${n.content}`)}catch(e){}return t}decodeText(e){const t=[];let n=e.text,s=-1,i=-1;for(;""!==n;)switch(s=n.indexOf("["),i=n.indexOf("]"),s){case 0:if(-1===i)t.push({name:"text",text:n}),n="";else{const e=n.slice(0,i+1);G[e]?(t.push({name:"img",src:U+G[e]}),n=n.substring(i+1)):(t.push({name:"text",text:"["}),n=n.slice(1))}break;case-1:t.push({name:"text",text:n}),n="";break;default:t.push({name:"text",text:n.slice(0,s)}),n=n.substring(s)}return t}handleGroupProfileUpdated(e){const{nick:t,payload:n}=e,{newGroupProfile:s,memberList:i,operatorID:r}=n;let o="";const a=t||r,u=Object.keys(s)[0];switch(u){case"muteAllMembers":o=s[u]?`${this.t("message.tip.管理员")} ${a} ${this.t("message.tip.开启全员禁言")}`:`${this.t("message.tip.管理员")} ${a} ${this.t("message.tip.取消全员禁言")}`;break;case"ownerID":o=`${i[0].nick||i[0].userID} ${this.t("message.tip.成为新的群主")}`;break;case"groupName":o=`${a} ${this.t("message.tip.修改群名为")} ${s[u]}`;break;case"notification":o=`${a} ${this.t("message.tip.发布新公告")}`}return o}}class Lt{constructor(e){this.TUIChatService=e,this.typingTo="",this.timer=null}getEngine(){return this.TUIChatService.getEngine()}clearTypingStatus(){this.getEngine().TUIStore.getData(a.CHAT,"typingStatus")&&this.getEngine().TUIStore.update(a.CHAT,"typingStatus",!1),this.timer&&clearTimeout(this.timer),this.timer=null}handleLastMessage(e){const t=this.getEngine(),n=t.TUIStore.getData(a.CHAT,"typingStatus");if(e.type===this.getEngine().TYPES.MSG_CUSTOM&&"in"===e.flow){const s=O(e.payload.data);if(s.businessID===g.BUSINESS_ID){const{typingStatus:e,userAction:i}=s;if(e===g.STATUS_START||i===g.ACTION_START_ID)return n?(this.timer&&clearTimeout(this.timer),this.timer=null):t.TUIStore.update(a.CHAT,"typingStatus",!0),this.timer=setTimeout((()=>{this.clearTypingStatus()}),3e4),t.TUIStore.getData(a.CHAT,"typingStatus");e!==g.STATUS_END&&i!==g.ACTION_END_ID||this.clearTypingStatus()}}}filterTypingMessage(e=[]){if(0===e.length)return[];return this.getEngine().TUIStore.getData(a.APP,"enableTyping")&&this.handleLastMessage(e[e.length-1]),e.filter((e=>{if(e.type===this.getEngine().TYPES.MSG_CUSTOM){return O(e.payload.data).businessID!==g.BUSINESS_ID}return!0}))}createTypingMessage(e=g.STATUS_END,t=""){const{BUSINESS_ID:n,STATUS_START:s,VERSION:i,ACTION_START_ID:r,ACTION_END_ID:o,ACTION_START:a,ACTION_END:u,NEED_TYPING:c}=g;return{to:t,conversationType:this.getEngine().TYPES.CONV_C2C,payload:{data:JSON.stringify({businessID:n,typingStatus:e,version:i,userAction:e===s?r:o,actionParam:e===s?a:u}),description:"",extension:""},cloudCustomData:JSON.stringify({messageFeature:{needTyping:c,version:i}})}}sendTyping(e=!1,t=""){if(e){this.typingTo=t;const e=this.createTypingMessage(g.STATUS_START,t);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}else this.sendTypingEnd()}sendTypingEnd(){if(this.typingTo){const e=this.createTypingMessage(g.STATUS_END,this.typingTo);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}this.typingTo=""}}class Gt{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(),n=t.TUIStore.getData(a.CONV,"currentConversationID"),s=[];e.forEach((e=>{const{messageID:i}=e,r=t.chat.findMessage(i);r&&n===r.conversationID&&s.push(r)})),s.length>0&&t.TUIChat.updateMessageList(s,"edit")}sendMessageReadReceipt(e){const t=[];return e.forEach((e=>{const n=e.getMessage();t.push(n)})),this.getEngine().chat.sendMessageReadReceipt(t)}getGroupMessageReadMemberList(e){const t=e.message.getMessage(),n=Object.assign(Object.assign({},e),{message:t});return this.getEngine().chat.getGroupMessageReadMemberList(n)}getMessageReadReceiptList(e){const t=this.getEngine(),n=t.TUIStore.getData(a.APP,"enabledMessageReadReceipt"),s=t.TUIStore.getData(a.USER,"displayMessageReadReceipt");return!n||!s||0===e.length||e[0].conversationType!==t.TYPES.CONV_GROUP?Promise.resolve(e):t.chat.getMessageReadReceiptList(e).then((e=>e.data.messageList)).catch((()=>Promise.resolve(e)))}}const jt=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let n=t;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return t===n}(e)){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}return!1};class At extends ee{constructor(){super(),this.messageHandler=new xt(this),this.typingHandler=new Lt(this),this.readReceiptHandler=new Gt(this),this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap=new Map}static getInstance(){return At.instance||(At.instance=new At),At.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)),this.onCurrentConversationIDUpdated(),this.onMessageSource(),this.readReceiptHandler.init()}onMessageReceived(e){this.updateMessageList(e,"push"),this.getEngine().TUIStore.update(a.CHAT,"newMessageList",e)}onMessageModified(e){this.updateMessageList(e,"edit")}onMessageRevoked(e){this.updateMessageList(e,"edit")}onCurrentConversationIDUpdated(){const e=this.getEngine();e.TUIStore.watch(a.CONV,{currentConversationID:t=>{this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.clear(),e.TUIStore.reset(a.CHAT),this.typingHandler.clearTypingStatus(),this.typingHandler.sendTypingEnd(),jt(t)||this.getMessageList().finally((e=>{this.isSwitching=!1,this.delayGetHoppingFunction&&this.delayGetHoppingFunction()}))}})}onMessageSource(){const e=this.getEngine();e.TUIStore.watch(a.CHAT,{messageSource:t=>{const n=this.getStoreData(a.CONV,"currentConversationID");if(!n||t&&t.conversationID!==n)return;if(T(t))return this.hoppingConfigMap.clear(),e.TUIStore.update(a.CHAT,"messageList",[]),e.TUIStore.update(a.CHAT,"nextReqMessageID",""),e.TUIStore.update(a.CHAT,"isCompleted",!1),void this.getMessageList();const s=this.getStoreData(a.CHAT,"messageList");s&&s.find((e=>t&&e.ID===t.ID))||(this.isSwitching?this.delayGetHoppingFunction=this.getMessageListHoppingForDown:this.getMessageListHoppingForDown())}})}getMessageListHoppingForDown(){const e=this.getStoreData(a.CHAT,"messageList"),{conversationID:t,sequence:n,time:s,ID:i}=this.getStoreData(a.CHAT,"messageSource");if(e&&e.find((e=>i&&e.ID===i)))return;const r=this.getEngine();r.TUIStore.update(a.CHAT,"messageList",[]),r.TUIStore.update(a.CHAT,"nextReqMessageID",""),r.TUIStore.update(a.CHAT,"isCompleted",!1),this.getMessageListHopping({conversationID:t,sequence:n,time:s,direction:1})}onMessageReadByPeer(e){this.updateMessageList(e,"edit")}getStoreData(e,t){return this.getEngine().TUIStore.getData(e,t)}sendMessage(e,t){this.updateMessageList([e],"send");const n=this.getEngine().chat.sendMessage(e,t);return this.getResponse(n)}getResponse(e,t=!0,n=!0){return e.then((e=>{const n=e.data.messageList?e.data.messageList:[e.data.message];return t&&this.updateMessageList(n,"edit"),e})).catch((e=>{var t;return n&&(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.message)&&this.updateMessageList([e.data.message],"edit"),Promise.reject(e)}))}updateMessageList(e,t=""){if(this.getStoreData(a.CHAT,"messageSource")&&"unshift"!==t&&"edit"!==t)return;const n=this.getStoreData(a.CHAT,"messageList"),s=this.updateTargetMessageList(e,n,t);this.getEngine().TUIStore.update(a.CHAT,"messageList",s)}updateTargetMessageList(e,t,n=""){const s=this.getStoreData(a.CONV,"currentConversationID"),i=e.filter((e=>e.conversationID===s));if(!n||0===i.length)return t;const r=t||[];let o=[];switch(n){case"edit":for(const e of t){const t=i.find((t=>t.ID===e.ID));o.push(t||e)}break;case"resend":o=r.filter((e=>e.ID!==i[0].ID)).concat(i);break;case"send":o=r.concat(this.typingHandler.filterTypingMessage(i));break;case"push":o=r.concat(this.typingHandler.filterTypingMessage(i)),this.getEngine().chat.setMessageRead({conversationID:s});break;case"unshift":o=i.filter((e=>0===r.length||!r.find((t=>t.ID===e.ID)))),o.push(...r)}return o}enterTypingState(){this.getStoreData(a.APP,"enableTyping")&&this.sendTyping(!0)}leaveTypingState(){this.getStoreData(a.APP,"enableTyping")&&this.sendTyping(!1)}sendTyping(e){const t=this.getEngine(),n=this.getStoreData(a.CONV,"currentConversationID");if(!n.startsWith(t.TYPES.CONV_C2C))return;const s=n.replace(t.TYPES.CONV_C2C,"");if(e){const e=this.getStoreData(a.CHAT,"messageList").filter((e=>"in"===e.flow));if(0===e.length)return;const t=1e3*e[e.length-1].time;if((new Date).getTime()-t>3e4)return}this.typingHandler.sendTyping(e,s)}quoteMessage(e){return this.getEngine().TUIStore.update(a.CHAT,"quoteMessage",{message:e,type:"quote"}),e}replyMessage(e){return this.getEngine().TUIStore.update(a.CHAT,"quoteMessage",{message:e,type:"reply"}),e}getCurrentConvInfo(){const{conversationID:e="",type:t}=this.getStoreData(a.CONV,"currentConversation")||{};return{to:e.replace(t,""),conversationType:t}}t(e){return this.getEngine().TUITranslate.t(e)||e}getMessageAbstractAndType(e){var t;const n=this.getEngine(),s={abstract:"",type:0};switch(e.type){case n.TYPES.MSG_TEXT:s.abstract=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.text,s.type=1;break;case n.TYPES.MSG_CUSTOM:s.abstract=this.t("[自定义消息]"),s.type=2;break;case n.TYPES.MSG_IMAGE:s.abstract=this.t("[图片]"),s.type=3;break;case n.TYPES.MSG_AUDIO:s.abstract=this.t("[语音]"),s.type=4;break;case n.TYPES.MSG_VIDEO:s.abstract=this.t("[视频]"),s.type=5;break;case n.TYPES.MSG_FILE:s.abstract=this.t("[文件]"),s.type=6;break;case n.TYPES.MSG_FACE:s.abstract=this.t("[表情]"),s.type=7}return s}genMessageReply(e,t){if("reply"!==t&&"quote"!==t)return{};const{abstract:n,type:s}=this.getMessageAbstractAndType(e),i={messageAbstract:n,messageSender:e.nick||e.from,messageID:e.ID},r=Object.assign(Object.assign({},i),{messageType:s,messageTime:null==e?void 0:e.time,messageSequence:null==e?void 0:e.sequence,version:1});if("reply"===t&&(r.messageRootID=e.ID,e.cloudCustomData)){const t=O(e.cloudCustomData);t.messageReply&&t.messageReply.messageRootID&&(r.messageRootID=t.messageReply.messageRootID)}return{messageReply:r,messageReplyRoot:i}}getMessageInfo(e,t,n){const{messageReply:s,messageReplyRoot:i}=this.genMessageReply(t,n),r=e.cloudCustomData?O(e.cloudCustomData):{};let o;if(r.messageReply?r.messageReply=Object.assign(Object.assign({},s),r.messageReply):r.messageReply=s,"reply"===n){const{messageRootID:e}=s;o=this.getEngine().chat.findMessage(e);const t=o.cloudCustomData?O(o.cloudCustomData):{};t.messageReplies||(t.messageReplies={}),a=t.messageReplies.replies,("function"==typeof Array.isArray?Array.isArray(a):"array"===Object.prototype.toString.call(a).match(/^\[object (.*)\]$/)[1].toLowerCase())||(t.messageReplies.replies=[]),t.messageReplies.replies.push(i),o.cloudCustomData=JSON.stringify(t)}var a;return{cloudCustomData:JSON.stringify(r),rootMessage:o}}sendTextMessage(e,t){const n=this.getEngine(),{message:s,type:i}=this.getStoreData(a.CHAT,"quoteMessage");let r={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};s&&(r=this.getMessageInfo(e,s,i));const o=n.chat.createTextMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:r.cloudCustomData}));return this.sendMessage(o,t).then((e=>(r.rootMessage&&this.modifyMessage(r.rootMessage),n.TUIStore.reset(a.CHAT,["quoteMessage"],!0),e)))}sendTextAtMessage(e,t){const n=this.getEngine(),{message:s,type:i}=this.getStoreData(a.CHAT,"quoteMessage");let r={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};s&&(r=this.getMessageInfo(e,s,i));const o=n.chat.createTextMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:r.cloudCustomData}));return this.sendMessage(o,t).then((e=>(r.rootMessage&&this.modifyMessage(r.rootMessage),n.TUIStore.reset(a.CHAT,["quoteMessage"],!0),e)))}sendImageMessage(e,t){const n=this.getEngine().chat.createImageMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendAudioMessage(e,t){const n=this.getEngine().chat.createAudioMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendVideoMessage(e,t){const n=this.getEngine().chat.createVideoMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendCustomMessage(e,t){const n=this.getEngine().chat.createCustomMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(n,t)}sendFaceMessage(e,t){const n=this.getEngine().chat.createFaceMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(n,t)}sendFileMessage(e,t){const n=this.getEngine().chat.createFileMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(n.ID,e)}}));return this.sendMessage(n,t)}sendLocationMessage(e,t){const n=this.getEngine().chat.createLocationMessage(Object.assign(Object.assign({},this.getCurrentConvInfo()),e));return this.sendMessage(n,t)}onProgress(e,t){const n=this.getEngine().TUIStore.getMessageModel(e);if(n){(t-n.progress>=.1||1===t)&&(n.progress=t,this.updateMessageList([n],"edit"))}}setAbstractList(e){const t=this.getEngine(),n=e.nick||e.from;let s="";switch(e.type){case t.TYPES.MSG_TEXT:return s=e.payload.text||"",s.length>20&&(s=s.slice(0,20)),`${n}: ${s}`;case t.TYPES.MSG_MERGER:return`${n}: ${this.t("[聊天记录]")}`;case t.TYPES.MSG_IMAGE:return`${n}: ${this.t("[图片]")}`;case t.TYPES.MSG_AUDIO:return`${n}: ${this.t("[音频]")}`;case t.TYPES.MSG_VIDEO:return`${n}: ${this.t("[视频]")}`;case t.TYPES.MSG_CUSTOM:return`${n}: ${this.t("[自定义消息]")}`;case t.TYPES.MSG_FILE:return`${n}: ${this.t("[文件]")}`;case t.TYPES.MSG_FACE:return`${n}: ${this.t("[动画表情]")}`}}genMergerForwardPayload(e){const{conversationType:t,nick:n,from:s,to:i}=e[0],r=[];return e.forEach((e=>{r.push(this.setAbstractList(e))})),{messageList:e,title:"GROUP"===t?"群聊的聊天记录":`${n||s} 和 ${i} 的聊天记录`,abstractList:r,compatibleText:"请升级IMSDK到v2.10.1或更高版本查看此消息"}}sendMergerForwardMessage(e){const{conversationList:t,messageList:n,params:s,sendMessageOptions:i}=e,r=[];for(let e=0;e<t.length;e++){const{conversationID:o,type:a}=t[e],u=Object.assign({to:o.replace(`${a}`,""),conversationType:a,payload:this.genMergerForwardPayload(n)},s),g=this.getEngine().chat.createMergerMessage(u);r.push(this.sendMessage(g,i))}return Promise.all(r)}getOriginMessageList(e){return e.map((e=>e instanceof se?e.getMessage():e))}sendForwardMessage(e,t,n){t=this.getOriginMessageList(t);const i=n||{},{needMerge:r=!1,params:o={}}=i,a=s(i,["needMerge","params"]);if(r)return this.sendMergerForwardMessage({conversationList:e,messageList:t,params:o,sendMessageOptions:a});const u=[];for(let n=0;n<e.length;n++){const{conversationID:s,type:i}=e[n],r=Object.assign({to:s.replace(`${i}`,""),conversationType:i},o);for(let e=0;e<t.length;e++){Reflect.set(r,"payload",t[e]);const n=this.getEngine().chat.createForwardMessage(r);u.push(this.sendMessage(n,a))}}return Promise.all(u)}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((e=>{const{code:t=0,data:n={}}=e.code;throw t===l.MSG_MODIFY_CONFLICT?console.warn(`${h.MSG_MODIFY_CONFLICT} data.message: ${null==n?void 0:n.message}`):t===l.MSG_MODIFY_DISABLED_IN_AVCHATROOM?console.warn(h.MSG_MODIFY_DISABLED_IN_AVCHATROOM):t===l.MODIFY_MESSAGE_NOT_EXIST&&console.warn(h.MODIFY_MESSAGE_NOT_EXIST),e}))}getMessageList(e={conversationID:this.getStoreData(a.CONV,"currentConversationID"),nextReqMessageID:this.getStoreData(a.CHAT,"nextReqMessageID")}){const t=this.getEngine();if(!t.chat.isReady())return Promise.reject({code:p.GET_MSG_LIST_ERROR,message:d.GET_MSG_LIST_ERROR});if(this.getStoreData(a.CHAT,"isCompleted"))return Promise.resolve({data:{messageList:[],nextReqMessageID:"",isCompleted:!0}});const n=this.getStoreData(a.CHAT,"messageSource"),s=this.hoppingConfigMap.get("nextMessageSeq"),i=this.hoppingConfigMap.get("nextMessageTime"),r=s||i;if(n&&n.conversationID===e.conversationID&&r)return this.getMessageListHopping();return t.chat.getMessageList(e).then((e=>{const{messageList:n,nextReqMessageID:s,isCompleted:i}=e.data;return this.readReceiptHandler.getMessageReadReceiptList(n).then((n=>(this.updateMessageList(n,"unshift"),t.TUIStore.update(a.CHAT,"nextReqMessageID",s),t.TUIStore.update(a.CHAT,"isCompleted",i),e.data.messageList=n,e)))})).catch((e=>Promise.reject(e)))}getMessageListHopping(e){var t;void 0===e&&(e={conversationID:null===(t=this.getStoreData(a.CHAT,"messageSource"))||void 0===t?void 0:t.conversationID,sequence:this.hoppingConfigMap.get("nextMessageSeq"),time:this.hoppingConfigMap.get("nextMessageTime")});const n=this.getEngine();return n.chat.getMessageListHopping(e).then((t=>{const{messageList:s,nextMessageSeq:i,nextMessageTime:r,isCompleted:o}=t.data,u=1===e.direction?e.sequence:i,g=1===e.direction?e.time:r;return this.updateMessageList(s,"unshift"),this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.set("nextMessageSeq",u),this.hoppingConfigMap.set("nextMessageTime",g),n.TUIStore.update(a.CHAT,"isCompleted",o),t})).catch((e=>Promise.reject(e)))}sendMessageReadReceipt(e){return this.readReceiptHandler.sendMessageReadReceipt(e)}getGroupMessageReadMemberList(e){return this.readReceiptHandler.getGroupMessageReadMemberList(e).then((e=>{const{isCompleted:t,cursor:n,messageID:s,unreadUserIDList:i,readUserIDList:r}=e.data,o={code:0,data:{cursor:n,isCompleted:t,messageID:s,unreadUserInfoList:[],readUserInfoList:[]}},a=[...i,...r];return 0===a.length?o:this.getEngine().TUIUser.getUserProfile({userIDList:a}).then((e=>(i.length>0?e.data.forEach((e=>{const{userID:t,nick:n="",avatar:s=""}=e;o.data.unreadUserInfoList.push({userID:t,nick:n,avatar:s})})):e.data.forEach((e=>{const{userID:t,nick:n="",avatar:s=""}=e;o.data.readUserInfoList.push({userID:t,nick:n,avatar:s})})),o)))}))}downloadMergedMessages(e){return this.getEngine().chat.downloadMergerMessage(e.getMessage())}translateText(e){return this.getEngine().chat.translateText(e)}searchCloudMessages(e){const t=this.getStoreData(a.CONV,"conversationList");return this.getEngine().chat.searchCloudMessages(e).then((e=>{const{searchResultList:n}=e.data;return e.data.searchResultList=n.map((e=>{const{messageList:n,conversationID:i}=e,r=s(e,["messageList","conversationID"]),o=n.map((e=>new se(e))),a=t.find((e=>e.conversationID===i));return Object.assign(Object.assign({},r),{messageList:o.sort(((e,t)=>t.time-e.time)),conversation:a})})),e}))}}class Nt extends ee{constructor(){super(),this.groupMap=new Map}static getInstance(){return Nt.instance||(Nt.instance=new Nt),Nt.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(a.GRP,"groupList",e);const n=t.TUIStore.getData(a.GRP,"currentGroupID");e.forEach((e=>{e.groupID===n&&t.TUIStore.update(a.GRP,"currentGroup",e)}))}onGroupAttributesUpdated(e){const t=this.getEngine(),n=t.TUIStore.getData(a.GRP,"currentGroupID");let s=t.TUIStore.getData(a.GRP,"groupList");const{groupID:i,groupAttributes:r}=e;n===i&&t.TUIStore.update(a.GRP,"currentGroupAttributes",r),s=s.map((e=>(e.groupID===i&&(e.groupAttributes=r),e))),t.TUIStore.update(a.GRP,"groupList",s)}onGroupCounterUpdated(e){const t=this.getEngine(),n=t.TUIStore.getData(a.GRP,"currentGroupID"),s=t.TUIStore.getData(a.GRP,"currentGroupCounters")||{};let i=t.TUIStore.getData(a.GRP,"groupList");const{groupID:r,key:o,value:u}=e;n===r&&(s[o]=u,t.TUIStore.update(a.GRP,"currentGroupCounters",s)),i=i.map((e=>(e.groupID===r&&(e.groupCounters=Object.assign(Object.assign({},e.groupCounters),{[o]:u})),e))),t.TUIStore.update(a.GRP,"groupList",i)}onMessageReceived(e){const t=this.getEngine(),n=[];e.forEach((e=>{if(e.type===t.TYPES.MSG_GRP_TIP){const{payload:n}=e,{operationType:s,userIDList:i}=n,r=t.TUIStore.getData(a.GRP,"currentGroupID");switch(s){case t.TYPES.GRP_TIP_MBR_JOIN:this.addMemberList(i);break;case t.TYPES.GRP_TIP_MBR_QUIT:case t.TYPES.GRP_TIP_MBR_KICKED_OUT:this.removeMemberList(i);break;case t.TYPES.GRP_TIP_MBR_SET_ADMIN:case t.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:this.updateGroupMember(i);break;case t.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:this.getGroupProfile({groupID:r});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(i)}}e.type===t.TYPES.MSG_GRP_SYS_NOTICE&&n.push(e)})),n.length>0&&t.TUIStore.update(a.GRP,"groupSystemNoticeList",n)}getGroupInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getGroupList().then((e=>{const{groupList:t=[]}=e.data;console.log(`TUIGroupService.init, getGroupList count:${t.length}`),t.length>0&&this.onGroupListUpdated(t)}))}updateGroupMember(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine().TUIStore.getData(a.GRP,"currentGroupID");if(t){const n=yield this.getGroupMemberProfile({groupID:t,userIDList:e}),{memberList:s}=n.data;this.updateMemberList(s)}}))}resetCurrentStore(){this.getEngine().TUIStore.reset(a.GRP,["currentGroupID","currentGroup","currentGroupAttributes","currentGroupCounters","currentGroupMemberList"],!0)}switchGroup(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine(),n=t.TUIStore.getData(a.GRP,"currentGroupID");if(!e)return this.resetCurrentStore(),Promise.resolve({});if(n===e){const e=t.TUIStore.getData(a.GRP,"currentGroup");return Promise.resolve(e)}this.resetCurrentStore(),t.TUIStore.update(a.GRP,"currentGroupID",e);try{yield this.getGroupInfo(e)}catch(e){Promise.reject(e)}const s=setTimeout((()=>{this.groupMap.delete(e),clearTimeout(s)}),5e3),i=t.TUIStore.getData(a.GRP,"currentGroup");return Promise.resolve(i)}))}getGroupInfo(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine(),n=this.groupMap.get(e);if(n)return this.updateMemberList((null==n?void 0:n.memberList)||[]),t.TUIStore.update(a.GRP,"currentGroup",n.group),t.TUIStore.update(a.GRP,"currentGroupAttributes",n.groupAttributes||{}),void t.TUIStore.update(a.GRP,"currentGroupCounters",n.counters||{});const s={group:{},memberList:[],groupAttributes:void 0,counters:void 0},{data:{group:i}}=yield this.getGroupProfile({groupID:e});s.group=i;const{data:{memberList:r}}=yield this.getGroupMemberList({groupID:e});s.memberList=r;const o=yield this.getGroupAttributes({groupID:e,keyList:[]}),{groupAttributes:u}=o.data;s.groupAttributes=u,t.TUIStore.update(a.GRP,"currentGroupAttributes",u);try{const n=yield this.getGroupCounters({groupID:e,keyList:[]}),{counters:s}=n.data;t.TUIStore.update(a.GRP,"currentGroupCounters",s)}catch(e){console.warn(e)}this.groupMap.set(e,s)}))}getGroupProfile(e){const t=this.getEngine();return t.chat.getGroupProfile(e).then((n=>i(this,void 0,void 0,(function*(){if(t.TUIStore.getData(a.GRP,"currentGroupID")===e.groupID){const{group:e}=n.data;t.TUIStore.update(a.GRP,"currentGroup",e)}return n}))))}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((e=>{const{group:n}=e.data,s=t.TUIStore.getData(a.GRP,"groupList");return e.data.group.isJoinedGroup=s.some((e=>e.groupID===n.groupID)),e}))}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(),n=[...(t.TUIStore.getData(a.GRP,"currentGroupMemberList")||[]).filter((t=>!e.find((e=>e.userID===t.userID)))),...e];t.TUIStore.update(a.GRP,"currentGroupMemberList",n)}addMemberList(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine().TUIStore.getData(a.GRP,"currentGroupID");if(t)try{const n=yield this.getGroupMemberProfile({groupID:t,userIDList:e}),{memberList:s}=n.data;this.updateMemberList(s)}catch(t){const n=e.map((e=>({userID:e,avatar:"",nick:"",role:"",joinTime:0,nameCard:"",muteUntil:0,memberCustomField:[]})));this.updateMemberList(n)}}))}removeMemberList(e){const t=this.getEngine(),n=t.TUIStore.getData(a.GRP,"currentGroupMemberList").filter((t=>-1===e.indexOf(t.userID)));t.TUIStore.update(a.GRP,"currentGroupMemberList",n)}getGroupMemberList(e){const t=this.getEngine();return t.chat.getGroupMemberList(e).then((n=>{if(t.TUIStore.getData(a.GRP,"currentGroupID")===e.groupID){const{memberList:e}=n.data;this.updateMemberList(e)}return n}))}getGroupMemberProfile(e){return this.getEngine().chat.getGroupMemberProfile(e)}addGroupMember(e){const t=this.getEngine();return t.chat.addGroupMember(e).then((n=>i(this,void 0,void 0,(function*(){if(t.TUIStore.getData(a.GRP,"currentGroupID")===e.groupID){const{successUserIDList:e,group:s}=n.data;t.TUIStore.update(a.GRP,"currentGroup",s),this.addMemberList(e)}return n}))))}deleteGroupMember(e){const t=this.getEngine();return t.chat.deleteGroupMember(e).then((n=>{if(t.TUIStore.getData(a.GRP,"currentGroupID")===e.groupID){const{userIDList:e,group:s}=n.data;this.removeMemberList(e),t.TUIStore.update(a.GRP,"currentGroup",s)}return n}))}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 kt extends ee{constructor(){super()}static getInstance(){return kt.instance||(kt.instance=new kt),kt.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))}onFriendListUpdated(e){this.getEngine().TUIStore.update(a.FRIEND,"friendList",e)}onFriendApplicationListUpdated(e){const{friendApplicationList:t,unreadCount:n=0}=e,s=this.getEngine();s.TUIStore.update(a.FRIEND,"friendApplicationList",t),s.TUIStore.update(a.FRIEND,"friendApplicationUnreadCount",n)}getFriendList(){return this.getEngine().chat.getFriendList()}getFriendRemark(e){const t=this.getEngine().TUIStore.getData(a.FRIEND,"friendList"),n={};return e.forEach((e=>{for(let s=0;s<t.length;s++)t[s].userID!==e||(n[e]=t[s].remark)})),n}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()}}class wt{constructor(){this.cache=[],this.middlewares=[],this.options=null}use(e){if("function"!=typeof e)throw"middleware must be a function";return 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((function(e){return e})),this.options=e,this.next()}}function Vt(e,t,n){const s=Object.create(null);Object.keys(n).forEach((n=>{if(!t[n])return;s[n]=t[n];const i=new wt;t[n]=function(){const r=Array.from(arguments);return i.use((function(t,s){return e.isInited?s():Promise.reject({code:p.NOT_INIT,message:`${n} | ${d.NOT_INIT}`})})).use((function(e,i){return s[n].apply(t,e)})),i.run(r)}}))}console.log("TUIChatEngine.VERSION:2.0.3");const $t=X.getInstance(),Ft=W.getInstance(),Ht=ge.getInstance(),Yt=bt.getInstance(),Bt=Ot.getInstance(),Kt=Rt.getInstance(),qt=At.getInstance(),Jt=Nt.getInstance(),zt=kt.getInstance();$t.mount(o.TUIStore,Ht),$t.mount(o.TUITranslate,Yt),$t.mount(o.TUIConversation,Bt),$t.mount(o.TUIUser,Kt),$t.mount(o.TUIChat,qt),$t.mount(o.TUIGroup,Jt),$t.mount(o.TUIFriend,zt),Vt($t,$t,f),Vt($t,Bt,m),Vt($t,qt,v),Vt($t,Jt,E),Vt($t,Kt,S),Vt($t,zt,y);export{a as StoreName,qt as TUIChatService,Bt as TUIConversationService,zt as TUIFriendService,Ft as TUIGlobal,Jt as TUIGroupService,Ht as TUIStore,Yt as TUITranslateService,Kt as TUIUserService,$t as default};
|
|
1
|
+
import e from"@tencentcloud/chat";import t from"tim-upload-plugin";import s from"tim-profanity-filter-plugin";function n(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(s[n[i]]=e[n[i]])}return s}function i(e,t,s,n){return new(s||(s=Promise))((function(i,r){function o(e){try{u(n.next(e))}catch(e){r(e)}}function a(e){try{u(n.throw(e))}catch(e){r(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}u((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class r{constructor(e){return r.instance||(r.instance=this,this.engine=e,this.events={},this.bindIMEvents()),r.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)}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)}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)}}var o,a,u,c,g,l,h,p,d;!function(e){e.TUIStore="TUIStore",e.TUITranslate="TUITranslate",e.TUIConversation="TUIConversation",e.TUIChat="TUIChat",e.TUIGroup="TUIGroup",e.TUIUser="TUIUser",e.TUIFriend="TUIFriend"}(o||(o={})),function(e){e.APP="application",e.CONV="conversation",e.CHAT="chat",e.GRP="group",e.USER="user",e.FRIEND="friend",e.CUSTOM="custom"}(a||(a={})),function(e){e[e.UNSUB_USER=-1]="UNSUB_USER"}(u||(u={})),function(e){e.BUSINESS_ID="user_typing_status",e[e.STATUS_START=1]="STATUS_START",e[e.STATUS_END=0]="STATUS_END",e[e.VERSION=1]="VERSION",e[e.ACTION_START_ID=14]="ACTION_START_ID",e[e.ACTION_END_ID=0]="ACTION_END_ID",e.ACTION_START="EIMAMSG_InputStatus_Ing",e.ACTION_END="EIMAMSG_InputStatus_End",e[e.NEED_TYPING=1]="NEED_TYPING"}(c||(c={})),function(e){e.ADD="add",e.REMOVE="remove"}(g||(g={})),function(e){e[e.MSG_MODIFY_CONFLICT=2480]="MSG_MODIFY_CONFLICT",e[e.MSG_MODIFY_DISABLED_IN_AVCHATROOM=2481]="MSG_MODIFY_DISABLED_IN_AVCHATROOM",e[e.MODIFY_MESSAGE_NOT_EXIST=20026]="MODIFY_MESSAGE_NOT_EXIST"}(l||(l={})),function(e){e[e.NOT_INIT=-1e5]="NOT_INIT",e[e.INVALID_CONV_ID=-100001]="INVALID_CONV_ID",e[e.CONV_ID_SAME=-100002]="CONV_ID_SAME",e[e.CONV_NOT_EXIST=-100003]="CONV_NOT_EXIST",e[e.GET_MSG_LIST_ERROR=-100004]="GET_MSG_LIST_ERROR",e[e.MISMATCH_TYPE_AND_PAYLOAD=-100005]="MISMATCH_TYPE_AND_PAYLOAD"}(h||(h={})),function(e){e.MSG_MODIFY_CONFLICT="MODIFY_MESSAGE_ERROR,修改消息发生冲突, data.message 是最新的消息",e.MSG_MODIFY_DISABLED_IN_AVCHATROOM="MODIFY_MESSAGE_ERROR,不支持修改直播群消息.",e.MODIFY_MESSAGE_NOT_EXIST="MODIFY_MESSAGE_ERROR,消息不存在."}(p||(p={})),function(e){e.NOT_INIT="TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。",e.INVALID_CONV_ID="会话 ID 无效",e.CONV_ID_SAME="您切换的是同一个会话 ID",e.CONV_NOT_EXIST="会话不存在",e.GET_MSG_LIST_ERROR="Chat SDK is not ready.",e.MISMATCH_TYPE_AND_PAYLOAD="type 与 payload 不匹配."}(d||(d={}));const f={logout:1,destroy:1},m={deleteConversation:1,pinConversation:1,muteConversation:1,switchConversation:1,getConversationProfile:1,clearHistoryMessage:1},E={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,translateText:1,searchCloudMessages:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1},v={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},T={switchUserStatus:1,switchMessageReadStatus:1,getUserProfile:1,updateMyProfile:1,addToBlacklist:1,removeFromBlacklist:1},I={getFriendList:1,addFriend:1,deleteFriend:1,checkFriend:1,getFriendProfile:1,updateFriend:1,acceptFriendApplication:1,refuseFriendApplication:1,deleteFriendApplication:1,setFriendApplicationRead:1},S=function(e){return void 0===e},y=function(e){return e.startsWith("_")},b=function(e){return/^(https?:\/\/(([a-zA-Z0-9]+-?)+[a-zA-Z0-9]+\.)+[a-zA-Z]+)(:\d+)?(\/.*)?(\?.*)?(#.*)?$/.test(e)};const U=function(e){return e&&function(e){if("string"==typeof e)try{return!!JSON.parse(e)}catch(e){return!1}return!1}(e)?JSON.parse(e):e},M=function(e){let t="";return t=e>=1048576?`${(e/1048576).toFixed(2)} Mb`:e>=1024?`${(e/1024).toFixed(2)} Kb`:`${e.toFixed(2)}B`,t},O="https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_21.png",D="https://web.sdk.qcloud.com/im/demo/TUIkit/web/img/constomer.svg",C="https://web.sdk.qcloud.com/component/TUIKit/assets/group_avatar.png",_="https://web.sdk.qcloud.com/im/assets/emoji-plugin/",P="https://web.sdk.qcloud.com/im/assets/face-elem/",R="https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&",j="https://apis.map.qq.com/ws/staticmap/v2/?",L={"[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"},A={"[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]":"[赞]"},G={enabledMessageReadReceipt:Math.pow(2,5),enabledEmojiPlugin:Math.pow(2,48),enabledOnlineStatus:Math.pow(2,7),enabledCustomerServicePlugin:Math.pow(2,40)},N=["messageList","conversationList","newMessageList"],k="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting),x="undefined"!=typeof uni&&"undefined"==typeof window,w=k||x,V="undefined"!=typeof uni,F=("undefined"!=typeof uni||"undefined"!=typeof window)&&!w,$=k?wx:V?uni:window,H=F&&window&&window.navigator&&window.navigator.userAgent||"",Y=/Android/i.test(H),B=/(?:Windows Phone)/.test(H),K=/(?:SymbianOS)/.test(H),q=/iPad/i.test(H)||/iPhone/i.test(H)||/iPod/i.test(H),z=Y||B||K||q,J=F&&!z;class W{constructor(){this.global=$,this.isOfficial=!1}static getInstance(){return W.instance||(W.instance=new W),W.instance}initOfficial(e){this.isOfficial=e}getPlatform(){let e="";return J?e="pc":z?e="h5":k?e="wechat":x&&!k&&(e="app"),e}}class X{constructor(){this.EVENT=e.EVENT,this.TYPES=e.TYPES,this.loginStatusPromise=new Map,this.userID="",this.isInited=!1}static getInstance(){return X.instance||(X.instance=new X),X.instance}mount(e,t){this[e]=t}login(t){const{chat:s,SDKAppID:n,userID:i}=t,o=1400187352===n||1400188366===n;return this.createChat(t),this.userID=i,W.getInstance().initOfficial(o),this.TUIStore.update(a.APP,"isOfficial",o),this.TUIStore.update(a.APP,"SDKVersion",e.VERSION),this.eventCenter=new r(this),this.eventCenter.removeEvents(),this.initStore(),this.initService(),s&&s.isReady()?(console.log("TUIChatEngine.login ok, from TUICore."),this.checkCommercialAbility(),Promise.resolve({})):(this.registerPlugin(t),this.eventCenter.addEvent(this.EVENT.SDK_READY,(()=>{this.onSDKReady()})),this.eventCenter.addEvent(this.EVENT.SDK_NOT_READY,(()=>{this.onSDKNotReady()})),this.loginChat(t))}logout(){return this.userID="",this.isInited=!1,this.chat.logout()}isReady(){var e;return(null===(e=this.chat)||void 0===e?void 0:e.isReady())||!1}setLogLevel(e){if(this.chat)return this.chat.setLogLevel(e);console.warn("TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。")}destroy(){return this.eventCenter.unbindIMEvents(),this.isInited=!1,this.chat.destroy()}getMyUserID(){return this.userID}initStore(){this.TUIStore.reset(a.CHAT),this.TUIStore.reset(a.CONV),this.TUIStore.reset(a.GRP),this.TUIStore.reset(a.USER),console.log("TUIEngine.initStore ok.")}initService(){this.TUIChat.init(),this.TUIConversation.init(),this.TUIGroup.init(),this.TUIUser.init(),this.TUIFriend.init(),this.isInited=!0,console.log("TUIEngine.initService ok.")}createChat(t){const{chat:s}=t,i=n(t,["chat"]);S(s)?this.chat=e.create(Object.assign(Object.assign({},i),{scene:"chat-uikit-engine"})):this.chat=s}loginChat(e){const{userID:t,userSig:s}=e;return new Promise(((e,n)=>{this.chat.login({userID:t,userSig:s}).then((t=>{console.log("TUIChatEngine.loginChat ok."),this.checkCommercialAbility(),t.data.repeatLogin&&this.chat.isReady()&&e(t),this.loginStatusPromise.set("login",{resolve:e,reject:n,imResponse:t})})).catch((e=>{n(e)}))}))}registerPlugin(e){const{useUploadPlugin:n=!1,useProfanityFilterPlugin:i=!1,TIMPush:r,pushConfig:o,TUIOfflinePush:a,offlinePushConfig:u}=e;!0===n&&this.chat.registerPlugin({"tim-upload-plugin":t}),!0===i&&this.chat.registerPlugin({"tim-profanity-filter-plugin":s}),!x||k||S(r)||S(o)||this.chat.registerPlugin({"tim-push":r,pushConfig:o}),!x||k||S(a)||S(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(){if(this.loginStatusPromise.has("login")){this.loginStatusPromise.get("login").reject(new Error("sdk not ready"))}this.loginStatusPromise.delete("login")}checkCommercialAbility(){Object.keys(G).forEach((e=>{const t=G[e];this.chat.callExperimentalAPI("isCommercialAbilityEnabled",t).then((t=>{const{enabled:s=!1}=t.data;this.TUIStore.update(a.APP,e,s)}))}))}}class Z{constructor(){this.defaultStore={enabledMessageReadReceipt:!1,enabledEmojiPlugin:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enableTyping:!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}},this.store={enabledEmojiPlugin:!1,enabledMessageReadReceipt:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enableTyping:!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}}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}}class Q{constructor(){this.defaultStore={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[]},this.store={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[]}}update(e,t){if("userStatusList"===e)this.updateUserStatusList(t);else this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateUserStatusList(e){0!==e.length?e.forEach((e=>{const{userID:t,statusType:s=0,customStatus:n=""}=e;s===u.UNSUB_USER?this.store.userStatusList.delete(t):this.store.userStatusList.set(t,{statusType:s,customStatus:n})})):this.store.userStatusList.clear()}}class ee{getEngine(){return X.getInstance()}}const te=function(e){if(null==e)return!0;if("boolean"==typeof e)return!1;if("number"==typeof e)return 0===e;if("string"==typeof e)return 0===e.length;if("function"==typeof e)return 0===e.length;if(Array.isArray(e))return 0===e.length;if(e instanceof Error)return""===e.message;if(function(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);if(null===t)return!0;let s=t;for(;null!==Object.getPrototypeOf(s);)s=Object.getPrototypeOf(s);return t===s}(e)){for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t))return!1;return!0}return!1};class se extends ee{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=>{y(t)||(this[t]=e[t])}))}updateProperties(e){this._conversation=e,Object.keys(e).forEach((t=>{y(t)||(this[t]=e[t])}))}getConversation(){return this._conversation}deleteConversation(){return this.getEngine().TUIConversation.deleteConversation(this.conversationID)}pinConversation(){return this.getEngine().TUIConversation.pinConversation({conversationID:this.conversationID,isPinned:!this.isPinned})}muteConversation(){const e=this.getEngine(),t={messageRemindType:!0===this.isMuted?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)}getAvatar(){var e,t,s,n,i,r;const o=this.getEngine();let a="";switch(this.type){case o.TYPES.CONV_C2C:a=b(null===(e=this.userProfile)||void 0===e?void 0:e.avatar)?null===(t=this.userProfile)||void 0===t?void 0:t.avatar:O;break;case o.TYPES.CONV_GROUP:a=b(null===(s=this.groupProfile)||void 0===s?void 0:s.avatar)?null===(n=this.groupProfile)||void 0===n?void 0:n.avatar:D;break;case o.TYPES.CONV_SYSTEM:a=b(null===(i=this.groupProfile)||void 0===i?void 0:i.avatar)?null===(r=this.groupProfile)||void 0===r?void 0:r.avatar:C}return a}getShowName(){var e,t,s,n;const i=this.getEngine();let r="";switch(this.type){case i.TYPES.CONV_C2C:r=this.remark||(null===(e=this.userProfile)||void 0===e?void 0:e.nick)||(null===(t=this.userProfile)||void 0===t?void 0:t.userID)||"";break;case i.TYPES.CONV_GROUP:r=(null===(s=this.groupProfile)||void 0===s?void 0:s.name)||(null===(n=this.groupProfile)||void 0===n?void 0:n.groupID)||"";break;case i.TYPES.CONV_SYSTEM:r=i.TUITranslate.t("系统通知")}return r}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 e=0;e<this.groupAtInfoList.length;e++)this.groupAtInfoList[e].atTypeArray[0]&&this.unreadCount>0&&(n=s[this.groupAtInfoList[e].atTypeArray[0]-1]);return n}getLastMessage(e){return"time"===e?this.getLastMessageTime():"text"===e?this.getLastMessageText():(console.warn(`ConversationModel.getLastMessage key:${e} is invalid.`),null)}getLastMessageTime(){var e;const t=this.getEngine();let s="";return(null===(e=this.lastMessage)||void 0===e?void 0:e.lastTime)>0&&(s=function(e,t){const s=6e4,n=36e5,i=24*n,r=(new Date).getTime()-e;let o="";if(r<0)return o;const a=r/s,u=r/n,c=r/i,g=r/6048e5;if(g>=1&&g<=4)o=` ${parseInt(`${g}`,10)} ${t("time.周")}${t("time.前")}`;else if(c>=1&&c<=6)o=` ${parseInt(`${c}`,10)} ${t("time.天")}${t("time.前")}`;else if(u>=1&&u<=23)o=` ${parseInt(`${u}`,10)} ${t("time.小时")}${t("time.前")}`;else if(a>=1&&a<=59)o=` ${parseInt(`${a}`,10)} ${t("time.分钟")}${t("time.前")}`;else if(r>=0&&r<=s)o=`${t("time.刚刚")}`;else{const t=new Date;t.setTime(e),o=`${t.getFullYear()}-${t.getMonth()+1<10?`0${t.getMonth()+1}`:t.getMonth()+1}-${t.getDate()<10?`0${t.getDate()}`:t.getDate()}`}return o}(1e3*this.lastMessage.lastTime,t.TUITranslate.t.bind(t.TUITranslate))),s}getLastMessageText(){var e;const t=this.getEngine(),s=t.TUITranslate.t.bind(t.TUITranslate);if(4===this.operationType)return s("TUIConversation.您已被群管理员移出群聊");if(5===this.operationType)return s("TUIConversation.该群聊已被解散");if(8===this.operationType)return s("TUIConversation.您已退出该群聊");const n=this._conversation,i=this.lastMessage;let r="",o="";const a=n.unreadCount>0&&n.messageRemindType===t.TYPES.MSG_REMIND_ACPT_NOT_NOTE?s(`[${n.unreadCount>99?"99+":n.unreadCount}条]`):"";if(n.type===t.TYPES.CONV_GROUP)if(i.fromAccount===t.getMyUserID())r=s("TUIConversation.我");else{const e=i.fromAccount;r=t.TUIFriend.getFriendRemark([e])[e]||i.nameCard||i.nick||e}if(i.type===t.TYPES.MSG_TEXT)o=this.decodeTextMessage(i.payload.text);else if(i.type===t.TYPES.MSG_CUSTOM){const s=U(null===(e=null==i?void 0:i.payload)||void 0===e?void 0:e.data);if(1===(null==s?void 0:s.businessID))return o=t.TUIChat.messageHandler.handleCallKitSignaling(i),o;o=i.messageForShow}else o=i.messageForShow;return i.isRevoked&&(o=s("TUIChat.撤回了一条消息")),n.type===t.TYPES.CONV_GROUP&&i.type===t.TYPES.MSG_GRP_TIP?o:`${a}${r?`${r}:`:""}${o}`}decodeTextMessage(e){if(te(e))return e;const t=/(\[.+?\])/g;let s=e;return t.test(e)&&(s=e.replace(t,(e=>A[e]||e))),s}}class ne{constructor(){this.defaultStore={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null},this.store={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null}}update(e,t){if("conversationList"===e)this.updateConversationList(t);else this.store[e]=t}getData(e){return this.store[e]}getModel(e){return this.store.conversationList.find((t=>t.conversationID===e))}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateConversationList(e){const t=[];e.forEach((e=>{let s=e;e instanceof se?s.updateProperties(e):s=new se(e),t.push(s)})),this.store.conversationList=t}}class ie extends ee{constructor(e){super(),this.messageHandlers={[this.getEngine().TYPES.MSG_TEXT]:e=>this.getEngine().TUIChat.messageHandler.handleTextMessage(e),[this.getEngine().TYPES.MSG_FACE]:e=>this.getEngine().TUIChat.messageHandler.handleFaceMessage(e),[this.getEngine().TYPES.MSG_LOCATION]:e=>this.getEngine().TUIChat.messageHandler.handleLocationMessage(e),[this.getEngine().TYPES.MSG_IMAGE]:e=>this.getEngine().TUIChat.messageHandler.handleImageMessage(e),[this.getEngine().TYPES.MSG_AUDIO]:e=>this.getEngine().TUIChat.messageHandler.handleAudioMessage(e),[this.getEngine().TYPES.MSG_VIDEO]:e=>this.getEngine().TUIChat.messageHandler.handleVideoMessage(e),[this.getEngine().TYPES.MSG_FILE]:e=>this.getEngine().TUIChat.messageHandler.handleFileMessage(e),[this.getEngine().TYPES.MSG_CUSTOM]:e=>this.getEngine().TUIChat.messageHandler.handleCustomMessage(e),[this.getEngine().TYPES.MSG_MERGER]:e=>this.getEngine().TUIChat.messageHandler.handleMergeMessage(e),[this.getEngine().TYPES.MSG_GRP_TIP]:e=>this.getEngine().TUIChat.messageHandler.handleGroupTipsMessage(e)},this._message=e,this._signalingInfo=void 0,this.progress=0,this.reactionList=[],this.initProperties(e)}initProperties(e){Object.keys(e).forEach((t=>{y(t)||(this[t]=e[t])}))}updateProperties(e){this._message=e,Object.keys(e).forEach((t=>{y(t)||(this[t]=e[t])}))}getMessage(){return this._message}modifyMessage(e){return e.type&&this._message.type!==e.type&&!e.payload?Promise.reject({code:h.MISMATCH_TYPE_AND_PAYLOAD,message:d.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:S(this._signalingInfo)?(this._signalingInfo=this.getEngine().chat.getSignalingInfo(this._message),this._signalingInfo):this._signalingInfo}getMessageContent(){const e=this.messageHandlers[this.type];if(S(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 re{constructor(){this.defaultStore={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0},this.store={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0}}update(e,t){if("messageList"===e)this.updateMessageList(t);else this.store[e]=t}getData(e){return this.store[e]}getModel(e){return this.store.messageList.find((t=>t.ID===e))}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),null==e?void 0:e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateMessageList(e){const t=[];e.forEach((e=>{let s=e;e instanceof ie||(s=this.getModel(e.ID),s?s.updateProperties(e):s=new ie(e)),t.push(s)})),this.store.messageList=t}}class oe extends ee{constructor(e){super(),this.groupAttributes={},this.groupCounters={},this.initProxy(e)}initProxy(e){Object.keys(e).forEach((t=>{y(t)||(this[t]=e[t])})),this._group=e}getGroup(){return this._group}switchGroup(){return this.getEngine().TUIGroup.switchGroup(this.groupID)}getGroupProfile(e){return this.getEngine().TUIGroup.getGroupProfile({groupID:this.groupID,groupCustomFieldFilter:e})}updateGroupProfile(e){return this.getEngine().TUIGroup.updateGroupProfile(Object.assign({groupID:this.groupID},e))}joinGroup(e){return this.getEngine().TUIGroup.joinGroup({groupID:this.groupID,applyMessage:e})}quitGroup(){return this.getEngine().TUIGroup.quitGroup(this.groupID)}dismissGroup(){return this.getEngine().TUIGroup.dismissGroup(this.groupID)}getGroupOnlineMemberCount(){return this.getEngine().TUIGroup.getGroupOnlineMemberCount(this.groupID)}changeGroupOwner(e){return this.getEngine().TUIGroup.changeGroupOwner(Object.assign({groupID:this.groupID},e))}initGroupAttributes(e){return this.getEngine().TUIGroup.initGroupAttributes(Object.assign({groupID:this.groupID},e))}setGroupAttributes(e){return this.getEngine().TUIGroup.setGroupAttributes(Object.assign({groupID:this.groupID},e))}deleteGroupAttributes(e){return this.getEngine().TUIGroup.deleteGroupAttributes(Object.assign({groupID:this.groupID},e))}getGroupAttributes(e){return this.getEngine().TUIGroup.getGroupAttributes(Object.assign({groupID:this.groupID},e))}setGroupCounters(e){return this.getEngine().TUIGroup.setGroupCounters(Object.assign({groupID:this.groupID},e))}increaseGroupCounter(e){return this.getEngine().TUIGroup.increaseGroupCounter(Object.assign({groupID:this.groupID},e))}decreaseGroupCounter(e){return this.getEngine().TUIGroup.decreaseGroupCounter(Object.assign({groupID:this.groupID},e))}getGroupCounters(e){return this.getEngine().TUIGroup.getGroupCounters(Object.assign({groupID:this.groupID},e))}addGroupMember(e){return this.getEngine().TUIGroup.addGroupMember(Object.assign({groupID:this.groupID},e))}getGroupMemberList(e){return this.getEngine().TUIGroup.getGroupMemberList(Object.assign({groupID:this.groupID},e))}getGroupMemberProfile(e){return this.getEngine().TUIGroup.getGroupMemberProfile(Object.assign({groupID:this.groupID},e))}deleteGroupMember(e){return this.getEngine().TUIGroup.deleteGroupMember(Object.assign({groupID:this.groupID},e))}setGroupMemberMuteTime(e){return this.getEngine().TUIGroup.setGroupMemberMuteTime(Object.assign({groupID:this.groupID},e))}setGroupMemberRole(e){return this.getEngine().TUIGroup.setGroupMemberRole(Object.assign({groupID:this.groupID},e))}setGroupMemberNameCard(e){return this.getEngine().TUIGroup.setGroupMemberNameCard(Object.assign({groupID:this.groupID},e))}setGroupMemberCustomField(e){return this.getEngine().TUIGroup.setGroupMemberCustomField(Object.assign({groupID:this.groupID},e))}markGroupMemberList(e){return this.getEngine().TUIGroup.markGroupMemberList(Object.assign({groupID:this.groupID},e))}}class ae{constructor(){this.defaultStore={currentGroupID:"",currentGroup:{},currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[]},this.store={currentGroupID:"",currentGroup:void 0,currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[]}}update(e,t){switch(e){case"groupList":this.updateGroupList(t);break;case"currentGroup":this.store.currentGroup=t instanceof oe?t:new oe(t);break;default:this.store[e]=t}}getData(e){if("groupSystemNoticeList"===e){const e=[...this.store.groupSystemNoticeList];return this.store.groupSystemNoticeList.length=0,e}return this.store[e]}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}updateGroupList(e){this.store.groupList=e.map((e=>e instanceof oe?e:new oe(e)))}}class ue{constructor(){this.store={}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){0===e.length&&(this.store={}),this.store=Object.assign(Object.assign({},this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:void 0})),{}))}}class ce{constructor(){this.defaultStore={friendList:[],friendApplicationList:[],friendApplicationUnreadCount:0},this.store={friendList:[],friendApplicationList:[],friendApplicationUnreadCount:0}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){0===e.length&&(e=Object.keys(this.store)),this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce(((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]})),{}))}}class ge{constructor(){this.storeMap={[a.APP]:new Z,[a.USER]:new Q,[a.CONV]:new ne,[a.CHAT]:new re,[a.GRP]:new ae,[a.FRIEND]:new ce},this.task={}}static getInstance(){return ge.instance||(ge.instance=new ge),ge.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((e=>{s[e].delete(t[e])}))}update(e,t,s){var n;e!==a.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new ue),null===(n=this.storeMap[e])||void 0===n||n.update(t,s),this.notify(e,t)}getData(e,t){var s;return e!==a.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new ue),null===(s=this.storeMap[e])||void 0===s?void 0:s.getData(t)}getConversationModel(e){var t;return null===(t=this.storeMap[a.CONV])||void 0===t?void 0:t.getModel(e)}getMessageModel(e){var t;return null===(t=this.storeMap[a.CHAT])||void 0===t?void 0:t.getModel(e)}reset(e,t=[],s=!1){if(e in this.storeMap){const n=this.storeMap[e];0===t.length&&(t=Object.keys(null==n?void 0:n.store)),n.reset(t),s&&t.forEach((t=>{this.notify(e,t)}))}}notifyOnWatch(e,t,s){const n=this.getData(e,t);N.indexOf(t)>-1&&0===n.length||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[e]of n.entries())e.call(this,i)}}}function le(e){return le="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},le(e)}function he(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pe(e){var t=function(e,t){if("object"!=le(e)||!e)return e;var s=e[Symbol.toPrimitive];if(void 0!==s){var n=s.call(e,t||"default");if("object"!=le(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==le(t)?t:String(t)}function de(e,t){for(var s=0;s<t.length;s++){var n=t[s];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,pe(n.key),n)}}function fe(e,t,s){return t&&de(e.prototype,t),s&&de(e,s),Object.defineProperty(e,"prototype",{writable:!1}),e}function me(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Ee(e,t){return Ee=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},Ee(e,t)}function ve(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Ee(e,t)}function Te(e,t){if(t&&("object"===le(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return me(e)}function Ie(e){return Ie=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},Ie(e)}function Se(e,t,s){return(t=pe(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function ye(e,t){(null==t||t>e.length)&&(t=e.length);for(var s=0,n=new Array(t);s<t;s++)n[s]=e[s];return n}function be(e){return function(e){if(Array.isArray(e))return e}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return ye(e,t);var s=Object.prototype.toString.call(e).slice(8,-1);return"Object"===s&&e.constructor&&(s=e.constructor.name),"Map"===s||"Set"===s?Array.from(e):"Arguments"===s||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?ye(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Ue(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function Me(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?Ue(Object(s),!0).forEach((function(t){Se(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Ue(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}var Oe={type:"logger",log:function(e){this.output("log",e)},warn:function(e){this.output("warn",e)},error:function(e){this.output("error",e)},output:function(e,t){console&&console[e]&&console[e].apply(console,t)}},De=new(function(){function e(t){var s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};he(this,e),this.init(t,s)}return fe(e,[{key:"init",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.prefix=t.prefix||"i18next:",this.logger=e||Oe,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:("string"==typeof e[0]&&(e[0]="".concat(s).concat(this.prefix," ").concat(e[0])),this.logger[t](e))}},{key:"create",value:function(t){return new e(this.logger,Me(Me({},{prefix:"".concat(this.prefix,":").concat(t,":")}),this.options))}},{key:"clone",value:function(t){return(t=t||this.options).prefix=t.prefix||this.prefix,new e(this.logger,t)}}]),e}()),Ce=function(){function e(){he(this,e),this.observers={}}return fe(e,[{key:"on",value:function(e,t){var s=this;return e.split(" ").forEach((function(e){s.observers[e]=s.observers[e]||[],s.observers[e].push(t)})),this}},{key:"off",value:function(e,t){this.observers[e]&&(t?this.observers[e]=this.observers[e].filter((function(e){return e!==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(e){e.apply(void 0,s)}));this.observers["*"]&&[].concat(this.observers["*"]).forEach((function(t){t.apply(t,[e].concat(s))}))}}]),e}();function _e(){var e,t,s=new Promise((function(s,n){e=s,t=n}));return s.resolve=e,s.reject=t,s}function Pe(e){return null==e?"":""+e}function Re(e,t,s){function n(e){return e&&e.indexOf("###")>-1?e.replace(/###/g,"."):e}function i(){return!e||"string"==typeof e}for(var r="string"!=typeof t?[].concat(t):t.split(".");r.length>1;){if(i())return{};var o=n(r.shift());!e[o]&&s&&(e[o]=new s),e=Object.prototype.hasOwnProperty.call(e,o)?e[o]:{}}return i()?{}:{obj:e,k:n(r.shift())}}function je(e,t,s){var n=Re(e,t,Object);n.obj[n.k]=s}function Le(e,t){var s=Re(e,t),n=s.obj,i=s.k;if(n)return n[i]}function Ae(e,t,s){for(var n in t)"__proto__"!==n&&"constructor"!==n&&(n in e?"string"==typeof e[n]||e[n]instanceof String||"string"==typeof t[n]||t[n]instanceof String?s&&(e[n]=t[n]):Ae(e[n],t[n],s):e[n]=t[n]);return e}function Ge(e){return e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&")}var Ne={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function ke(e){return"string"==typeof e?e.replace(/[&<>"'\/]/g,(function(e){return Ne[e]})):e}var xe="undefined"!=typeof window&&window.navigator&&void 0===window.navigator.userAgentData&&window.navigator.userAgent&&window.navigator.userAgent.indexOf("MSIE")>-1,we=[" ",",","?","!",";"];function Ve(e,t){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:".";if(e){if(e[t])return e[t];for(var n=t.split(s),i=e,r=0;r<n.length;++r){if(!i)return;if("string"==typeof i[n[r]]&&r+1<n.length)return;if(void 0===i[n[r]]){for(var o=2,a=n.slice(r,r+o).join(s),u=i[a];void 0===u&&n.length>r+o;)o++,u=i[a=n.slice(r,r+o).join(s)];if(void 0===u)return;if(null===u)return null;if(t.endsWith(a)){if("string"==typeof u)return u;if(a&&"string"==typeof u[a])return u[a]}var c=n.slice(r+o).join(s);return c?Ve(u,c,s):void 0}i=i[n[r]]}return i}}function Fe(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function $e(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?Fe(Object(s),!0).forEach((function(t){Se(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Fe(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function He(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var s,n=Ie(e);if(t){var i=Ie(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return Te(this,s)}}var Ye=function(e){ve(s,Ce);var t=He(s);function s(e){var n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{ns:["translation"],defaultNS:"translation"};return he(this,s),n=t.call(this),xe&&Ce.call(me(n)),n.data=e||{},n.options=i,void 0===n.options.keySeparator&&(n.options.keySeparator="."),void 0===n.options.ignoreJSONStructure&&(n.options.ignoreJSONStructure=!0),n}return fe(s,[{key:"addNamespaces",value:function(e){this.options.ns.indexOf(e)<0&&this.options.ns.push(e)}},{key:"removeNamespaces",value:function(e){var t=this.options.ns.indexOf(e);t>-1&&this.options.ns.splice(t,1)}},{key:"getResource",value:function(e,t,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=void 0!==n.keySeparator?n.keySeparator:this.options.keySeparator,r=void 0!==n.ignoreJSONStructure?n.ignoreJSONStructure:this.options.ignoreJSONStructure,o=[e,t];s&&"string"!=typeof s&&(o=o.concat(s)),s&&"string"==typeof s&&(o=o.concat(i?s.split(i):s)),e.indexOf(".")>-1&&(o=e.split("."));var a=Le(this.data,o);return a||!r||"string"!=typeof s?a:Ve(this.data&&this.data[e]&&this.data[e][t],s,i)}},{key:"addResource",value:function(e,t,s,n){var i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{silent:!1},r=void 0!==i.keySeparator?i.keySeparator:this.options.keySeparator,o=[e,t];s&&(o=o.concat(r?s.split(r):s)),e.indexOf(".")>-1&&(n=t,t=(o=e.split("."))[1]),this.addNamespaces(t),je(this.data,o,n),i.silent||this.emit("added",e,t,s,n)}},{key:"addResources",value:function(e,t,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{silent:!1};for(var i in s)"string"!=typeof s[i]&&"[object Array]"!==Object.prototype.toString.apply(s[i])||this.addResource(e,t,i,s[i],{silent:!0});n.silent||this.emit("added",e,t,s)}},{key:"addResourceBundle",value:function(e,t,s,n,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{silent:!1},o=[e,t];e.indexOf(".")>-1&&(n=s,s=t,t=(o=e.split("."))[1]),this.addNamespaces(t);var a=Le(this.data,o)||{};n?Ae(a,s,i):a=$e($e({},a),s),je(this.data,o,a),r.silent||this.emit("added",e,t,s)}},{key:"removeResourceBundle",value:function(e,t){this.hasResourceBundle(e,t)&&delete this.data[e][t],this.removeNamespaces(t),this.emit("removed",e,t)}},{key:"hasResourceBundle",value:function(e,t){return void 0!==this.getResource(e,t)}},{key:"getResourceBundle",value:function(e,t){return t||(t=this.options.defaultNS),"v1"===this.options.compatibilityAPI?$e($e({},{}),this.getResource(e,t)):this.getResource(e,t)}},{key:"getDataByLanguage",value:function(e){return this.data[e]}},{key:"hasLanguageSomeTranslations",value:function(e){var t=this.getDataByLanguage(e);return!!(t&&Object.keys(t)||[]).find((function(e){return t[e]&&Object.keys(t[e]).length>0}))}},{key:"toJSON",value:function(){return this.data}}]),s}(),Be={processors:{},addPostProcessor:function(e){this.processors[e.name]=e},handle:function(e,t,s,n,i){var r=this;return e.forEach((function(e){r.processors[e]&&(t=r.processors[e].process(t,s,n,i))})),t}};function Ke(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function qe(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?Ke(Object(s),!0).forEach((function(t){Se(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):Ke(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function ze(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var s,n=Ie(e);if(t){var i=Ie(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return Te(this,s)}}var Je={},We=function(e){ve(s,Ce);var t=ze(s);function s(e){var n,i,r,o,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return he(this,s),n=t.call(this),xe&&Ce.call(me(n)),i=["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],r=e,o=me(n),i.forEach((function(e){r[e]&&(o[e]=r[e])})),n.options=a,void 0===n.options.keySeparator&&(n.options.keySeparator="."),n.logger=De.create("translator"),n}return fe(s,[{key:"changeLanguage",value:function(e){e&&(this.language=e)}},{key:"exists",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{interpolation:{}};if(null==e)return!1;var s=this.resolve(e,t);return s&&void 0!==s.res}},{key:"extractFromKey",value:function(e,t){var s=void 0!==t.nsSeparator?t.nsSeparator:this.options.nsSeparator;void 0===s&&(s=":");var n=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,i=t.ns||this.options.defaultNS||[],r=s&&e.indexOf(s)>-1,o=!(this.options.userDefinedKeySeparator||t.keySeparator||this.options.userDefinedNsSeparator||t.nsSeparator||function(e,t,s){t=t||"",s=s||"";var n=we.filter((function(e){return t.indexOf(e)<0&&s.indexOf(e)<0}));if(0===n.length)return!0;var i=new RegExp("(".concat(n.map((function(e){return"?"===e?"\\?":e})).join("|"),")")),r=!i.test(e);if(!r){var o=e.indexOf(s);o>0&&!i.test(e.substring(0,o))&&(r=!0)}return r}(e,s,n));if(r&&!o){var a=e.match(this.interpolator.nestingRegexp);if(a&&a.length>0)return{key:e,namespaces:i};var u=e.split(s);(s!==n||s===n&&this.options.ns.indexOf(u[0])>-1)&&(i=u.shift()),e=u.join(n)}return"string"==typeof i&&(i=[i]),{key:e,namespaces:i}}},{key:"translate",value:function(e,t,n){var i=this;if("object"!==le(t)&&this.options.overloadTranslationOptionHandler&&(t=this.options.overloadTranslationOptionHandler(arguments)),"object"===le(t)&&(t=qe({},t)),t||(t={}),null==e)return"";Array.isArray(e)||(e=[String(e)]);var r=void 0!==t.returnDetails?t.returnDetails:this.options.returnDetails,o=void 0!==t.keySeparator?t.keySeparator:this.options.keySeparator,a=this.extractFromKey(e[e.length-1],t),u=a.key,c=a.namespaces,g=c[c.length-1],l=t.lng||this.language,h=t.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(l&&"cimode"===l.toLowerCase()){if(h){var p=t.nsSeparator||this.options.nsSeparator;return r?{res:"".concat(g).concat(p).concat(u),usedKey:u,exactUsedKey:u,usedLng:l,usedNS:g}:"".concat(g).concat(p).concat(u)}return r?{res:u,usedKey:u,exactUsedKey:u,usedLng:l,usedNS:g}:u}var d=this.resolve(e,t),f=d&&d.res,m=d&&d.usedKey||u,E=d&&d.exactUsedKey||u,v=Object.prototype.toString.apply(f),T=void 0!==t.joinArrays?t.joinArrays:this.options.joinArrays,I=!this.i18nFormat||this.i18nFormat.handleAsObject;if(I&&f&&("string"!=typeof f&&"boolean"!=typeof f&&"number"!=typeof f)&&["[object Number]","[object Function]","[object RegExp]"].indexOf(v)<0&&("string"!=typeof T||"[object Array]"!==v)){if(!t.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");var S=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,f,qe(qe({},t),{},{ns:c})):"key '".concat(u," (").concat(this.language,")' returned an object instead of string.");return r?(d.res=S,d):S}if(o){var y="[object Array]"===v,b=y?[]:{},U=y?E:m;for(var M in f)if(Object.prototype.hasOwnProperty.call(f,M)){var O="".concat(U).concat(o).concat(M);b[M]=this.translate(O,qe(qe({},t),{joinArrays:!1,ns:c})),b[M]===O&&(b[M]=f[M])}f=b}}else if(I&&"string"==typeof T&&"[object Array]"===v)(f=f.join(T))&&(f=this.extendTranslation(f,e,t,n));else{var D=!1,C=!1,_=void 0!==t.count&&"string"!=typeof t.count,P=s.hasDefaultValue(t),R=_?this.pluralResolver.getSuffix(l,t.count,t):"",j=t["defaultValue".concat(R)]||t.defaultValue;!this.isValidLookup(f)&&P&&(D=!0,f=j),this.isValidLookup(f)||(C=!0,f=u);var L=(t.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&C?void 0:f,A=P&&j!==f&&this.options.updateMissing;if(C||D||A){if(this.logger.log(A?"updateKey":"missingKey",l,g,u,A?j:f),o){var G=this.resolve(u,qe(qe({},t),{},{keySeparator:!1}));G&&G.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 N=[],k=this.languageUtils.getFallbackCodes(this.options.fallbackLng,t.lng||this.language);if("fallback"===this.options.saveMissingTo&&k&&k[0])for(var x=0;x<k.length;x++)N.push(k[x]);else"all"===this.options.saveMissingTo?N=this.languageUtils.toResolveHierarchy(t.lng||this.language):N.push(t.lng||this.language);var w=function(e,s,n){var r=P&&n!==f?n:L;i.options.missingKeyHandler?i.options.missingKeyHandler(e,g,s,r,A,t):i.backendConnector&&i.backendConnector.saveMissing&&i.backendConnector.saveMissing(e,g,s,r,A,t),i.emit("missingKey",e,g,s,f)};this.options.saveMissing&&(this.options.saveMissingPlurals&&_?N.forEach((function(e){i.pluralResolver.getSuffixes(e,t).forEach((function(s){w([e],u+s,t["defaultValue".concat(s)]||j)}))})):w(N,u,j))}f=this.extendTranslation(f,e,t,d,n),C&&f===u&&this.options.appendNamespaceToMissingKey&&(f="".concat(g,":").concat(u)),(C||D)&&this.options.parseMissingKeyHandler&&(f="v1"!==this.options.compatibilityAPI?this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?"".concat(g,":").concat(u):u,D?f:void 0):this.options.parseMissingKeyHandler(f))}return r?(d.res=f,d):f}},{key:"extendTranslation",value:function(e,t,s,n,i){var r=this;if(this.i18nFormat&&this.i18nFormat.parse)e=this.i18nFormat.parse(e,qe(qe({},this.options.interpolation.defaultVariables),s),n.usedLng,n.usedNS,n.usedKey,{resolved:n});else if(!s.skipInterpolation){s.interpolation&&this.interpolator.init(qe(qe({},s),{interpolation:qe(qe({},this.options.interpolation),s.interpolation)}));var o,a="string"==typeof e&&(s&&s.interpolation&&void 0!==s.interpolation.skipOnVariables?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);if(a){var u=e.match(this.interpolator.nestingRegexp);o=u&&u.length}var c=s.replace&&"string"!=typeof s.replace?s.replace:s;if(this.options.interpolation.defaultVariables&&(c=qe(qe({},this.options.interpolation.defaultVariables),c)),e=this.interpolator.interpolate(e,c,s.lng||this.language,s),a){var g=e.match(this.interpolator.nestingRegexp);o<(g&&g.length)&&(s.nest=!1)}!s.lng&&"v1"!==this.options.compatibilityAPI&&n&&n.res&&(s.lng=n.usedLng),!1!==s.nest&&(e=this.interpolator.nest(e,(function(){for(var e=arguments.length,n=new Array(e),o=0;o<e;o++)n[o]=arguments[o];return i&&i[0]===n[0]&&!s.context?(r.logger.warn("It seems you are nesting recursively key: ".concat(n[0]," in key: ").concat(t[0])),null):r.translate.apply(r,n.concat([t]))}),s)),s.interpolation&&this.interpolator.reset()}var l=s.postProcess||this.options.postProcess,h="string"==typeof l?[l]:l;return null!=e&&h&&h.length&&!1!==s.applyPostProcessor&&(e=Be.handle(h,e,t,this.options&&this.options.postProcessPassResolved?qe({i18nResolved:n},s):s,this)),e}},{key:"resolve",value:function(e){var t,s,n,i,r,o=this,a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e&&(e=[e]),e.forEach((function(e){if(!o.isValidLookup(t)){var u=o.extractFromKey(e,a),c=u.key;s=c;var g=u.namespaces;o.options.fallbackNS&&(g=g.concat(o.options.fallbackNS));var l=void 0!==a.count&&"string"!=typeof a.count,h=l&&!a.ordinal&&0===a.count&&o.pluralResolver.shouldUseIntlApi(),p=void 0!==a.context&&("string"==typeof a.context||"number"==typeof a.context)&&""!==a.context,d=a.lngs?a.lngs:o.languageUtils.toResolveHierarchy(a.lng||o.language,a.fallbackLng);g.forEach((function(e){o.isValidLookup(t)||(r=e,!Je["".concat(d[0],"-").concat(e)]&&o.utils&&o.utils.hasLoadedNamespace&&!o.utils.hasLoadedNamespace(r)&&(Je["".concat(d[0],"-").concat(e)]=!0,o.logger.warn('key "'.concat(s,'" for languages "').concat(d.join(", "),'" won\'t get resolved as namespace "').concat(r,'" 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!!!")),d.forEach((function(s){if(!o.isValidLookup(t)){i=s;var r,u=[c];if(o.i18nFormat&&o.i18nFormat.addLookupKeys)o.i18nFormat.addLookupKeys(u,c,s,e,a);else{var g;l&&(g=o.pluralResolver.getSuffix(s,a.count,a));var d="".concat(o.options.pluralSeparator,"zero");if(l&&(u.push(c+g),h&&u.push(c+d)),p){var f="".concat(c).concat(o.options.contextSeparator).concat(a.context);u.push(f),l&&(u.push(f+g),h&&u.push(f+d))}}for(;r=u.pop();)o.isValidLookup(t)||(n=r,t=o.getResource(s,e,r,a))}})))}))}})),{res:t,usedKey:s,exactUsedKey:n,usedLng:i,usedNS:r}}},{key:"isValidLookup",value:function(e){return!(void 0===e||!this.options.returnNull&&null===e||!this.options.returnEmptyString&&""===e)}},{key:"getResource",value:function(e,t,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(e,t,s,n):this.resourceStore.getResource(e,t,s,n)}}],[{key:"hasDefaultValue",value:function(e){var t="defaultValue";for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)&&t===s.substring(0,12)&&void 0!==e[s])return!0;return!1}}]),s}();function Xe(e){return e.charAt(0).toUpperCase()+e.slice(1)}var Ze=function(){function e(t){he(this,e),this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=De.create("languageUtils")}return fe(e,[{key:"getScriptPartFromCode",value:function(e){if(!e||e.indexOf("-")<0)return null;var t=e.split("-");return 2===t.length?null:(t.pop(),"x"===t[t.length-1].toLowerCase()?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("string"==typeof e&&e.indexOf("-")>-1){var t=["hans","hant","latn","cyrl","cans","mong","arab"],s=e.split("-");return this.options.lowerCaseLng?s=s.map((function(e){return e.toLowerCase()})):2===s.length?(s[0]=s[0].toLowerCase(),s[1]=s[1].toUpperCase(),t.indexOf(s[1].toLowerCase())>-1&&(s[1]=Xe(s[1].toLowerCase()))):3===s.length&&(s[0]=s[0].toLowerCase(),2===s[1].length&&(s[1]=s[1].toUpperCase()),"sgn"!==s[0]&&2===s[2].length&&(s[2]=s[2].toUpperCase()),t.indexOf(s[1].toLowerCase())>-1&&(s[1]=Xe(s[1].toLowerCase())),t.indexOf(s[2].toLowerCase())>-1&&(s[2]=Xe(s[2].toLowerCase()))),s.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?e.toLowerCase():e}},{key:"isSupportedCode",value:function(e){return("languageOnly"===this.options.load||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(e){if(!t){var n=s.formatLanguageCode(e);s.options.supportedLngs&&!s.isSupportedCode(n)||(t=n)}})),!t&&this.options.supportedLngs&&e.forEach((function(e){if(!t){var n=s.getLanguagePartFromCode(e);if(s.isSupportedCode(n))return t=n;t=s.options.supportedLngs.find((function(e){return e===n?e:e.indexOf("-")<0&&n.indexOf("-")<0?void 0:0===e.indexOf(n)?e:void 0}))}})),t||(t=this.getFallbackCodes(this.options.fallbackLng)[0]),t):null}},{key:"getFallbackCodes",value:function(e,t){if(!e)return[];if("function"==typeof e&&(e=e(t)),"string"==typeof e&&(e=[e]),"[object Array]"===Object.prototype.toString.apply(e))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=[],r=function(e){e&&(s.isSupportedCode(e)?i.push(e):s.logger.warn("rejecting language code not found in supportedLngs: ".concat(e)))};return"string"==typeof e&&e.indexOf("-")>-1?("languageOnly"!==this.options.load&&r(this.formatLanguageCode(e)),"languageOnly"!==this.options.load&&"currentOnly"!==this.options.load&&r(this.getScriptPartFromCode(e)),"currentOnly"!==this.options.load&&r(this.getLanguagePartFromCode(e))):"string"==typeof e&&r(this.formatLanguageCode(e)),n.forEach((function(e){i.indexOf(e)<0&&r(s.formatLanguageCode(e))})),i}}]),e}(),Qe=[{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}],et={1:function(e){return Number(e>1)},2:function(e){return Number(1!=e)},3:function(e){return 0},4:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},5:function(e){return Number(0==e?0:1==e?1:2==e?2:e%100>=3&&e%100<=10?3:e%100>=11?4:5)},6:function(e){return Number(1==e?0:e>=2&&e<=4?1:2)},7:function(e){return Number(1==e?0:e%10>=2&&e%10<=4&&(e%100<10||e%100>=20)?1:2)},8:function(e){return Number(1==e?0:2==e?1:8!=e&&11!=e?2:3)},9:function(e){return Number(e>=2)},10:function(e){return Number(1==e?0:2==e?1:e<7?2:e<11?3:4)},11:function(e){return Number(1==e||11==e?0:2==e||12==e?1:e>2&&e<20?2:3)},12:function(e){return Number(e%10!=1||e%100==11)},13:function(e){return Number(0!==e)},14:function(e){return Number(1==e?0:2==e?1:3==e?2:3)},15:function(e){return Number(e%10==1&&e%100!=11?0:e%10>=2&&(e%100<10||e%100>=20)?1:2)},16:function(e){return Number(e%10==1&&e%100!=11?0:0!==e?1:2)},17:function(e){return Number(1==e||e%10==1&&e%100!=11?0:1)},18:function(e){return Number(0==e?0:1==e?1:2)},19:function(e){return Number(1==e?0:0==e||e%100>1&&e%100<11?1:e%100>10&&e%100<20?2:3)},20:function(e){return Number(1==e?0:0==e||e%100>0&&e%100<20?1:2)},21:function(e){return Number(e%100==1?1:e%100==2?2:e%100==3||e%100==4?3:0)},22:function(e){return Number(1==e?0:2==e?1:(e<0||e>10)&&e%10==0?2:3)}},tt=["v1","v2","v3"],st={zero:0,one:1,two:2,few:3,many:4,other:5};var nt=function(){function e(t){var s,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};he(this,e),this.languageUtils=t,this.options=n,this.logger=De.create("pluralResolver"),this.options.compatibilityJSON&&"v4"!==this.options.compatibilityJSON||"undefined"!=typeof Intl&&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=(s={},Qe.forEach((function(e){e.lngs.forEach((function(t){s[t]={numbers:e.nr,plurals:et[e.fc]}}))})),s)}return fe(e,[{key:"addRule",value:function(e,t){this.rules[e]=t}},{key:"getRule",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this.shouldUseIntlApi())try{return new Intl.PluralRules(e,{type:t.ordinal?"ordinal":"cardinal"})}catch(e){return}return this.rules[e]||this.rules[this.languageUtils.getLanguagePartFromCode(e)]}},{key:"needsPlural",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?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&&void 0!==arguments[2]?arguments[2]:{};return this.getSuffixes(e,s).map((function(e){return"".concat(t).concat(e)}))}},{key:"getSuffixes",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=this.getRule(e,s);return n?this.shouldUseIntlApi()?n.resolvedOptions().pluralCategories.sort((function(e,t){return st[e]-st[t]})).map((function(e){return"".concat(t.options.prepend).concat(e)})):n.numbers.map((function(n){return t.getSuffix(e,n,s)})):[]}},{key:"getSuffix",value:function(e,t){var s=arguments.length>2&&void 0!==arguments[2]?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&&2===e.numbers.length&&1===e.numbers[0]&&(2===i?i="plural":1===i&&(i=""));var r=function(){return s.options.prepend&&i.toString()?s.options.prepend+i.toString():i.toString()};return"v1"===this.options.compatibilityJSON?1===i?"":"number"==typeof i?"_plural_".concat(i.toString()):r():"v2"===this.options.compatibilityJSON||this.options.simplifyPluralSuffix&&2===e.numbers.length&&1===e.numbers[0]?r():this.options.prepend&&n.toString()?this.options.prepend+n.toString():n.toString()}},{key:"shouldUseIntlApi",value:function(){return!tt.includes(this.options.compatibilityJSON)}}]),e}();function it(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function rt(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?it(Object(s),!0).forEach((function(t){Se(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):it(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function ot(e,t,s){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:".",i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4],r=function(e,t,s){var n=Le(e,s);return void 0!==n?n:Le(t,s)}(e,t,s);return!r&&i&&"string"==typeof s&&void 0===(r=Ve(e,s,n))&&(r=Ve(t,s,n)),r}var at=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};he(this,e),this.logger=De.create("interpolator"),this.options=t,this.format=t.interpolation&&t.interpolation.format||function(e){return e},this.init(t)}return fe(e,[{key:"init",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};e.interpolation||(e.interpolation={escapeValue:!0});var t=e.interpolation;this.escape=void 0!==t.escape?t.escape:ke,this.escapeValue=void 0===t.escapeValue||t.escapeValue,this.useRawValueToEscape=void 0!==t.useRawValueToEscape&&t.useRawValueToEscape,this.prefix=t.prefix?Ge(t.prefix):t.prefixEscaped||"{{",this.suffix=t.suffix?Ge(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?Ge(t.nestingPrefix):t.nestingPrefixEscaped||Ge("$t("),this.nestingSuffix=t.nestingSuffix?Ge(t.nestingSuffix):t.nestingSuffixEscaped||Ge(")"),this.nestingOptionsSeparator=t.nestingOptionsSeparator?t.nestingOptionsSeparator:t.nestingOptionsSeparator||",",this.maxReplaces=t.maxReplaces?t.maxReplaces:1e3,this.alwaysFormat=void 0!==t.alwaysFormat&&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,r,o,a=this,u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{};function c(e){return e.replace(/\$/g,"$$$$")}var g=function(e){if(e.indexOf(a.formatSeparator)<0){var i=ot(t,u,e,a.options.keySeparator,a.options.ignoreJSONStructure);return a.alwaysFormat?a.format(i,void 0,s,rt(rt(rt({},n),t),{},{interpolationkey:e})):i}var r=e.split(a.formatSeparator),o=r.shift().trim(),c=r.join(a.formatSeparator).trim();return a.format(ot(t,u,o,a.options.keySeparator,a.options.ignoreJSONStructure),c,s,rt(rt(rt({},n),t),{},{interpolationkey:o}))};this.resetRegExp();var l=n&&n.missingInterpolationHandler||this.options.missingInterpolationHandler,h=n&&n.interpolation&&void 0!==n.interpolation.skipOnVariables?n.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:function(e){return c(e)}},{regex:this.regexp,safeValue:function(e){return a.escapeValue?c(a.escape(e)):c(e)}}].forEach((function(t){for(o=0;i=t.regex.exec(e);){var s=i[1].trim();if(void 0===(r=g(s)))if("function"==typeof l){var u=l(e,i,n);r="string"==typeof u?u:""}else if(n&&Object.prototype.hasOwnProperty.call(n,s))r="";else{if(h){r=i[0];continue}a.logger.warn("missed to pass in variable ".concat(s," for interpolating ").concat(e)),r=""}else"string"==typeof r||a.useRawValueToEscape||(r=Pe(r));var c=t.safeValue(r);if(e=e.replace(i[0],c),h?(t.regex.lastIndex+=r.length,t.regex.lastIndex-=i[0].length):t.regex.lastIndex=0,++o>=a.maxReplaces)break}})),e}},{key:"nest",value:function(e,t){var s,n,i,r=this,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};function a(e,t){var s=this.nestingOptionsSeparator;if(e.indexOf(s)<0)return e;var n=e.split(new RegExp("".concat(s,"[ ]*{"))),r="{".concat(n[1]);e=n[0];var o=(r=this.interpolate(r,i)).match(/'/g),a=r.match(/"/g);(o&&o.length%2==0&&!a||a.length%2!=0)&&(r=r.replace(/'/g,'"'));try{i=JSON.parse(r),t&&(i=rt(rt({},t),i))}catch(t){return this.logger.warn("failed parsing options string in nesting for key ".concat(e),t),"".concat(e).concat(s).concat(r)}return delete i.defaultValue,e}for(;s=this.nestingRegexp.exec(e);){var u=[];(i=(i=rt({},o)).replace&&"string"!=typeof i.replace?i.replace:i).applyPostProcessor=!1,delete i.defaultValue;var c=!1;if(-1!==s[0].indexOf(this.formatSeparator)&&!/{.*}/.test(s[1])){var g=s[1].split(this.formatSeparator).map((function(e){return e.trim()}));s[1]=g.shift(),u=g,c=!0}if((n=t(a.call(this,s[1].trim(),i),i))&&s[0]===e&&"string"!=typeof n)return n;"string"!=typeof n&&(n=Pe(n)),n||(this.logger.warn("missed to resolve ".concat(s[1]," for nesting ").concat(e)),n=""),c&&(n=u.reduce((function(e,t){return r.format(e,t,o.lng,rt(rt({},o),{},{interpolationkey:s[1].trim()}))}),n.trim())),e=e.replace(s[0],n),this.regexp.lastIndex=0}return e}}]),e}();function ut(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function ct(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?ut(Object(s),!0).forEach((function(t){Se(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ut(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function gt(e){var t={};return function(s,n,i){var r=n+JSON.stringify(i),o=t[r];return o||(o=e(n,i),t[r]=o),o(s)}}var lt=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};he(this,e),this.logger=De.create("formatter"),this.options=t,this.formats={number:gt((function(e,t){var s=new Intl.NumberFormat(e,ct({},t));return function(e){return s.format(e)}})),currency:gt((function(e,t){var s=new Intl.NumberFormat(e,ct(ct({},t),{},{style:"currency"}));return function(e){return s.format(e)}})),datetime:gt((function(e,t){var s=new Intl.DateTimeFormat(e,ct({},t));return function(e){return s.format(e)}})),relativetime:gt((function(e,t){var s=new Intl.RelativeTimeFormat(e,ct({},t));return function(e){return s.format(e,t.range||"day")}})),list:gt((function(e,t){var s=new Intl.ListFormat(e,ct({},t));return function(e){return s.format(e)}}))},this.init(t)}return fe(e,[{key:"init",value:function(e){var t=(arguments.length>1&&void 0!==arguments[1]?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()]=gt(t)}},{key:"format",value:function(e,t,s){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return t.split(this.formatSeparator).reduce((function(e,t){var r=function(e){var t=e.toLowerCase().trim(),s={};if(e.indexOf("(")>-1){var n=e.split("(");t=n[0].toLowerCase().trim();var i=n[1].substring(0,n[1].length-1);"currency"===t&&i.indexOf(":")<0?s.currency||(s.currency=i.trim()):"relativetime"===t&&i.indexOf(":")<0?s.range||(s.range=i.trim()):i.split(";").forEach((function(e){if(e){var t=be(e.split(":")),n=t[0],i=t.slice(1).join(":").trim().replace(/^'+|'+$/g,"");s[n.trim()]||(s[n.trim()]=i),"false"===i&&(s[n.trim()]=!1),"true"===i&&(s[n.trim()]=!0),isNaN(i)||(s[n.trim()]=parseInt(i,10))}}))}return{formatName:t,formatOptions:s}}(t),o=r.formatName,a=r.formatOptions;if(n.formats[o]){var u=e;try{var c=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},g=c.locale||c.lng||i.locale||i.lng||s;u=n.formats[o](e,g,ct(ct(ct({},a),i),c))}catch(e){n.logger.warn(e)}return u}return n.logger.warn("there was no format function for ".concat(o)),e}),e)}}]),e}();function ht(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function pt(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?ht(Object(s),!0).forEach((function(t){Se(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ht(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function dt(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var s,n=Ie(e);if(t){var i=Ie(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return Te(this,s)}}var ft=function(e){ve(s,Ce);var t=dt(s);function s(e,n,i){var r,o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return he(this,s),r=t.call(this),xe&&Ce.call(me(r)),r.backend=e,r.store=n,r.services=i,r.languageUtils=i.languageUtils,r.options=o,r.logger=De.create("backendConnector"),r.waitingReads=[],r.maxParallelReads=o.maxParallelReads||10,r.readingCalls=0,r.maxRetries=o.maxRetries>=0?o.maxRetries:5,r.retryTimeout=o.retryTimeout>=1?o.retryTimeout:350,r.state={},r.queue=[],r.backend&&r.backend.init&&r.backend.init(i,o.backend,o),r}return fe(s,[{key:"queueLoad",value:function(e,t,s,n){var i=this,r={},o={},a={},u={};return e.forEach((function(e){var n=!0;t.forEach((function(t){var a="".concat(e,"|").concat(t);!s.reload&&i.store.hasResourceBundle(e,t)?i.state[a]=2:i.state[a]<0||(1===i.state[a]?void 0===o[a]&&(o[a]=!0):(i.state[a]=1,n=!1,void 0===o[a]&&(o[a]=!0),void 0===r[a]&&(r[a]=!0),void 0===u[t]&&(u[t]=!0)))})),n||(a[e]=!0)})),(Object.keys(r).length||Object.keys(o).length)&&this.queue.push({pending:o,pendingCount:Object.keys(o).length,loaded:{},errors:[],callback:n}),{toLoad:Object.keys(r),pending:Object.keys(o),toLoadLanguages:Object.keys(a),toLoadNamespaces:Object.keys(u)}}},{key:"loaded",value:function(e,t,s){var n=e.split("|"),i=n[0],r=n[1];t&&this.emit("failedLoading",i,r,t),s&&this.store.addResourceBundle(i,r,s),this.state[e]=t?-1:2;var o={};this.queue.forEach((function(s){var n,a,u,c,g,l;n=s.loaded,a=r,c=Re(n,[i],Object),g=c.obj,l=c.k,g[l]=g[l]||[],u&&(g[l]=g[l].concat(a)),u||g[l].push(a),function(e,t){void 0!==e.pending[t]&&(delete e.pending[t],e.pendingCount--)}(s,e),t&&s.errors.push(t),0!==s.pendingCount||s.done||(Object.keys(s.loaded).forEach((function(e){o[e]||(o[e]={});var t=s.loaded[e];t.length&&t.forEach((function(t){void 0===o[e][t]&&(o[e][t]=!0)}))})),s.done=!0,s.errors.length?s.callback(s.errors):s.callback())})),this.emit("loaded",o),this.queue=this.queue.filter((function(e){return!e.done}))}},{key:"read",value:function(e,t,s){var n=this,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:this.retryTimeout,o=arguments.length>5?arguments[5]:void 0;if(!e.length)return o(null,{});if(this.readingCalls>=this.maxParallelReads)this.waitingReads.push({lng:e,ns:t,fcName:s,tried:i,wait:r,callback:o});else{this.readingCalls++;var a=function(a,u){if(n.readingCalls--,n.waitingReads.length>0){var c=n.waitingReads.shift();n.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}a&&u&&i<n.maxRetries?setTimeout((function(){n.read.call(n,e,t,s,i+1,2*r,o)}),r):o(a,u)},u=this.backend[s].bind(this.backend);if(2!==u.length)return u(e,t,a);try{var c=u(e,t);c&&"function"==typeof c.then?c.then((function(e){return a(null,e)})).catch(a):a(null,c)}catch(e){a(e)}}}},{key:"prepareLoading",value:function(e,t){var s=this,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=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."),i&&i();"string"==typeof e&&(e=this.languageUtils.toResolveHierarchy(e)),"string"==typeof t&&(t=[t]);var r=this.queueLoad(e,t,n,i);if(!r.toLoad.length)return r.pending.length||i(),null;r.toLoad.forEach((function(e){s.loadOne(e)}))}},{key:"load",value:function(e,t,s){this.prepareLoading(e,t,{},s)}},{key:"reload",value:function(e,t,s){this.prepareLoading(e,t,{reload:!0},s)}},{key:"loadOne",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=e.split("|"),i=n[0],r=n[1];this.read(i,r,"read",void 0,void 0,(function(n,o){n&&t.logger.warn("".concat(s,"loading namespace ").concat(r," for language ").concat(i," failed"),n),!n&&o&&t.logger.log("".concat(s,"loaded namespace ").concat(r," for language ").concat(i),o),t.loaded(e,n,o)}))}},{key:"saveMissing",value:function(e,t,s,n,i){var r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:function(){};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(t))this.logger.warn('did not save key "'.concat(s,'" as the namespace "').concat(t,'" 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(null!=s&&""!==s){if(this.backend&&this.backend.create){var a=pt(pt({},r),{},{isUpdate:i}),u=this.backend.create.bind(this.backend);if(u.length<6)try{var c;(c=5===u.length?u(e,t,s,n,a):u(e,t,s,n))&&"function"==typeof c.then?c.then((function(e){return o(null,e)})).catch(o):o(null,c)}catch(e){o(e)}else u(e,t,s,n,o,a)}e&&e[0]&&this.store.addResource(e[0],t,s,n)}}}]),s}();function mt(){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(e){var t={};if("object"===le(e[1])&&(t=e[1]),"string"==typeof e[1]&&(t.defaultValue=e[1]),"string"==typeof e[2]&&(t.tDescription=e[2]),"object"===le(e[2])||"object"===le(e[3])){var s=e[3]||e[2];Object.keys(s).forEach((function(e){t[e]=s[e]}))}return t},interpolation:{escapeValue:!0,format:function(e,t,s,n){return e},prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}}function Et(e){return"string"==typeof e.ns&&(e.ns=[e.ns]),"string"==typeof e.fallbackLng&&(e.fallbackLng=[e.fallbackLng]),"string"==typeof e.fallbackNS&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e}function vt(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,n)}return s}function Tt(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?vt(Object(s),!0).forEach((function(t){Se(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):vt(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function It(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var s,n=Ie(e);if(t){var i=Ie(this).constructor;s=Reflect.construct(n,arguments,i)}else s=n.apply(this,arguments);return Te(this,s)}}function St(){}var yt=function(e){ve(s,Ce);var t=It(s);function s(){var e,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;if(he(this,s),e=t.call(this),xe&&Ce.call(me(e)),e.options=Et(i),e.services={},e.logger=De,e.modules={external:[]},n=me(e),Object.getOwnPropertyNames(Object.getPrototypeOf(n)).forEach((function(e){"function"==typeof n[e]&&(n[e]=n[e].bind(n))})),r&&!e.isInitialized&&!i.isClone){if(!e.options.initImmediate)return e.init(i,r),Te(e,me(e));setTimeout((function(){e.init(i,r)}),0)}return e}return fe(s,[{key:"init",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0;"function"==typeof t&&(s=t,t={}),!t.defaultNS&&!1!==t.defaultNS&&t.ns&&("string"==typeof t.ns?t.defaultNS=t.ns:t.ns.indexOf("translation")<0&&(t.defaultNS=t.ns[0]));var n=mt();function i(e){return e?"function"==typeof e?new e:e:null}if(this.options=Tt(Tt(Tt({},n),this.options),Et(t)),"v1"!==this.options.compatibilityAPI&&(this.options.interpolation=Tt(Tt({},n.interpolation),this.options.interpolation)),void 0!==t.keySeparator&&(this.options.userDefinedKeySeparator=t.keySeparator),void 0!==t.nsSeparator&&(this.options.userDefinedNsSeparator=t.nsSeparator),!this.options.isClone){var r;this.modules.logger?De.init(i(this.modules.logger),this.options):De.init(null,this.options),this.modules.formatter?r=this.modules.formatter:"undefined"!=typeof Intl&&(r=lt);var o=new Ze(this.options);this.store=new Ye(this.options.resources,this.options);var a=this.services;a.logger=De,a.resourceStore=this.store,a.languageUtils=o,a.pluralResolver=new nt(o,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),!r||this.options.interpolation.format&&this.options.interpolation.format!==n.interpolation.format||(a.formatter=i(r),a.formatter.init(a,this.options),this.options.interpolation.format=a.formatter.format.bind(a.formatter)),a.interpolator=new at(this.options),a.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},a.backendConnector=new ft(i(this.modules.backend),a.resourceStore,a,this.options),a.backendConnector.on("*",(function(t){for(var s=arguments.length,n=new Array(s>1?s-1:0),i=1;i<s;i++)n[i-1]=arguments[i];e.emit.apply(e,[t].concat(n))})),this.modules.languageDetector&&(a.languageDetector=i(this.modules.languageDetector),a.languageDetector.init&&a.languageDetector.init(a,this.options.detection,this.options)),this.modules.i18nFormat&&(a.i18nFormat=i(this.modules.i18nFormat),a.i18nFormat.init&&a.i18nFormat.init(this)),this.translator=new We(this.services,this.options),this.translator.on("*",(function(t){for(var s=arguments.length,n=new Array(s>1?s-1:0),i=1;i<s;i++)n[i-1]=arguments[i];e.emit.apply(e,[t].concat(n))})),this.modules.external.forEach((function(t){t.init&&t.init(e)}))}if(this.format=this.options.interpolation.format,s||(s=St),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){var u=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);u.length>0&&"dev"!==u[0]&&(this.options.lng=u[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(t){e[t]=function(){var s;return(s=e.store)[t].apply(s,arguments)}}));["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach((function(t){e[t]=function(){var s;return(s=e.store)[t].apply(s,arguments),e}}));var c=_e(),g=function(){var t=function(t,n){e.isInitialized&&!e.initializedStoreOnce&&e.logger.warn("init: i18next is already initialized. You should call init just once!"),e.isInitialized=!0,e.options.isClone||e.logger.log("initialized",e.options),e.emit("initialized",e.options),c.resolve(n),s(t,n)};if(e.languages&&"v1"!==e.options.compatibilityAPI&&!e.isInitialized)return t(null,e.t.bind(e));e.changeLanguage(e.options.lng,t)};return this.options.resources||!this.options.initImmediate?g():setTimeout(g,0),c}},{key:"loadResources",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:St,n="string"==typeof e?e:this.language;if("function"==typeof e&&(s=e),!this.options.resources||this.options.partialBundledLanguages){if(n&&"cimode"===n.toLowerCase())return s();var i=[],r=function(e){e&&t.services.languageUtils.toResolveHierarchy(e).forEach((function(e){i.indexOf(e)<0&&i.push(e)}))};if(n)r(n);else this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach((function(e){return r(e)}));this.options.preload&&this.options.preload.forEach((function(e){return r(e)})),this.services.backendConnector.load(i,this.options.ns,(function(e){e||t.resolvedLanguage||!t.language||t.setResolvedLanguage(t.language),s(e)}))}else s(null)}},{key:"reloadResources",value:function(e,t,s){var n=_e();return e||(e=this.languages),t||(t=this.options.ns),s||(s=St),this.services.backendConnector.reload(e,t,(function(e){n.resolve(),s(e)})),n}},{key:"use",value:function(e){if(!e)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!e.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return"backend"===e.type&&(this.modules.backend=e),("logger"===e.type||e.log&&e.warn&&e.error)&&(this.modules.logger=e),"languageDetector"===e.type&&(this.modules.languageDetector=e),"i18nFormat"===e.type&&(this.modules.i18nFormat=e),"postProcessor"===e.type&&Be.addPostProcessor(e),"formatter"===e.type&&(this.modules.formatter=e),"3rdParty"===e.type&&this.modules.external.push(e),this}},{key:"setResolvedLanguage",value:function(e){if(e&&this.languages&&!(["cimode","dev"].indexOf(e)>-1))for(var t=0;t<this.languages.length;t++){var s=this.languages[t];if(!(["cimode","dev"].indexOf(s)>-1)&&this.store.hasLanguageSomeTranslations(s)){this.resolvedLanguage=s;break}}}},{key:"changeLanguage",value:function(e,t){var s=this;this.isLanguageChangingTo=e;var n=_e();this.emit("languageChanging",e);var i=function(e){s.language=e,s.languages=s.services.languageUtils.toResolveHierarchy(e),s.resolvedLanguage=void 0,s.setResolvedLanguage(e)},r=function(r){e||r||!s.services.languageDetector||(r=[]);var o="string"==typeof r?r:s.services.languageUtils.getBestMatchFromCodes(r);o&&(s.language||i(o),s.translator.language||s.translator.changeLanguage(o),s.services.languageDetector&&s.services.languageDetector.cacheUserLanguage&&s.services.languageDetector.cacheUserLanguage(o)),s.loadResources(o,(function(e){!function(e,r){r?(i(r),s.translator.changeLanguage(r),s.isLanguageChangingTo=void 0,s.emit("languageChanged",r),s.logger.log("languageChanged",r)):s.isLanguageChangingTo=void 0,n.resolve((function(){return s.t.apply(s,arguments)})),t&&t(e,(function(){return s.t.apply(s,arguments)}))}(e,o)}))};return e||!this.services.languageDetector||this.services.languageDetector.async?!e&&this.services.languageDetector&&this.services.languageDetector.async?0===this.services.languageDetector.detect.length?this.services.languageDetector.detect().then(r):this.services.languageDetector.detect(r):r(e):r(this.services.languageDetector.detect()),n}},{key:"getFixedT",value:function(e,t,s){var n=this,i=function e(t,i){var r;if("object"!==le(i)){for(var o=arguments.length,a=new Array(o>2?o-2:0),u=2;u<o;u++)a[u-2]=arguments[u];r=n.options.overloadTranslationOptionHandler([t,i].concat(a))}else r=Tt({},i);r.lng=r.lng||e.lng,r.lngs=r.lngs||e.lngs,r.ns=r.ns||e.ns,r.keyPrefix=r.keyPrefix||s||e.keyPrefix;var c,g=n.options.keySeparator||".";return c=r.keyPrefix&&Array.isArray(t)?t.map((function(e){return"".concat(r.keyPrefix).concat(g).concat(e)})):r.keyPrefix?"".concat(r.keyPrefix).concat(g).concat(t):t,n.t(c,r)};return"string"==typeof e?i.lng=e:i.lngs=e,i.ns=t,i.keyPrefix=s,i}},{key:"t",value:function(){var e;return this.translator&&(e=this.translator).translate.apply(e,arguments)}},{key:"exists",value:function(){var e;return this.translator&&(e=this.translator).exists.apply(e,arguments)}},{key:"setDefaultNamespace",value:function(e){this.options.defaultNS=e}},{key:"hasLoadedNamespace",value:function(e){var t=this,s=arguments.length>1&&void 0!==arguments[1]?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 n=s.lng||this.resolvedLanguage||this.languages[0],i=!!this.options&&this.options.fallbackLng,r=this.languages[this.languages.length-1];if("cimode"===n.toLowerCase())return!0;var o=function(e,s){var n=t.services.backendConnector.state["".concat(e,"|").concat(s)];return-1===n||2===n};if(s.precheck){var a=s.precheck(this,o);if(void 0!==a)return a}return!!this.hasResourceBundle(n,e)||(!(this.services.backendConnector.backend&&(!this.options.resources||this.options.partialBundledLanguages))||!(!o(n,e)||i&&!o(r,e)))}},{key:"loadNamespaces",value:function(e,t){var s=this,n=_e();return this.options.ns?("string"==typeof e&&(e=[e]),e.forEach((function(e){s.options.ns.indexOf(e)<0&&s.options.ns.push(e)})),this.loadResources((function(e){n.resolve(),t&&t(e)})),n):(t&&t(),Promise.resolve())}},{key:"loadLanguages",value:function(e,t){var s=_e();"string"==typeof e&&(e=[e]);var n=this.options.preload||[],i=e.filter((function(e){return n.indexOf(e)<0}));return i.length?(this.options.preload=n.concat(i),this.loadResources((function(e){s.resolve(),t&&t(e)})),s):(t&&t(),Promise.resolve())}},{key:"dir",value:function(e){if(e||(e=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!e)return"rtl";var t=this.services&&this.services.languageUtils||new Ze(mt());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(t.getLanguagePartFromCode(e))>-1||e.toLowerCase().indexOf("-arab")>1?"rtl":"ltr"}},{key:"cloneInstance",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:St,i=Tt(Tt(Tt({},this.options),t),{isClone:!0}),r=new s(i);void 0===t.debug&&void 0===t.prefix||(r.logger=r.logger.clone(t));return["store","services","language"].forEach((function(t){r[t]=e[t]})),r.services=Tt({},this.services),r.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r.translator=new We(r.services,r.options),r.translator.on("*",(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];r.emit.apply(r,[e].concat(s))})),r.init(i,n),r.translator.options=r.options,r.translator.backendConnector.services.utils={hasLoadedNamespace:r.hasLoadedNamespace.bind(r)},r}},{key:"toJSON",value:function(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}]),s}();Se(yt,"createInstance",(function(){return new yt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},arguments.length>1?arguments[1]:void 0)}));var bt=yt.createInstance();bt.createInstance=yt.createInstance,bt.createInstance,bt.dir,bt.init,bt.loadResources,bt.reloadResources,bt.use,bt.changeLanguage,bt.getFixedT,bt.t,bt.exists,bt.setDefaultNamespace,bt.hasLoadedNamespace,bt.loadNamespaces,bt.loadLanguages;class Ut extends ee{constructor(){super(),this.languages=null}static getInstance(){return Ut.instance||(Ut.instance=new Ut),Ut.instance}provideLanguages(e){k||(this.languages=e,console.log("TUITranslateService.provideLanguages ok."))}useI18n(e){k||(this.languages?bt.init({compatibilityJSON:"v3",lng:e||"zh",fallbackLng:"zh",detection:{order:["querystring","navigator"],caches:["localStorage","cookie"]},resources:{en:{translation:this.languages.en},zh:{translation:this.languages.zh_cn}}}):console.warn("TUITranslateService.useI18next not have messages."))}changeLanguage(e){return bt.changeLanguage(e)}t(e){if(!this.languages){let t=e;return!S(e)&&e.indexOf(".")>-1&&(t=e.split(".").pop()||""),t}return bt.t(e)}}class Mt extends ee{constructor(){super(),this.serv="TUIConversationService"}static getInstance(){return Mt.instance||(Mt.instance=new Mt),Mt.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(a.CONV,"conversationList",t),this.updateCurrentConversation()}onTotalUnreadCountUpdated(e){this.getEngine().TUIStore.update(a.CONV,"totalUnreadCount",e)}onMessageReceived(e){const t=this.getEngine(),s=this.getEngine().TUIStore.getData(a.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:r}=e[i].payload,o=`GROUP${e[i].to}`,a=4===r||5===r||8===r,u=2===r||6===r||7===r;if(a||u)for(let e=0;e<s.length;e++)if(s[e].type!==t.TYPES.CONV_C2C&&s[e].conversationID===o){if(a){s[e].operationType=r,n=!0;break}if(u&&s[e].operationType>0){s[e].operationType=0,n=!0;break}}}n&&this.getEngine().TUIStore.update(a.CONV,"conversationList",s)}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 t=e.chat.getTotalUnreadMessageCount();this.onTotalUnreadCountUpdated(t)}}))}switchConversation(e){return i(this,void 0,void 0,(function*(){const t=`${this.serv}.switchConversation`,s=this.getEngine();if(!e)return s.TUIStore.reset(a.CHAT,["messageList","isCompleted","nextReqMessageID"]),s.TUIStore.update(a.CONV,"currentConversationID",""),s.TUIStore.update(a.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:h.INVALID_CONV_ID,message:d.INVALID_CONV_ID});const n=s.TUIStore.getData(a.CONV,"currentConversationID");if(n&&n===e)return this.setMessageRead(n),console.warn(`${t} please check conversationID, conversationID:${e}`),Promise.resolve({code:h.CONV_ID_SAME,message:d.CONV_ID_SAME});const i=yield this.getConversationModel(e);return S(i)?(console.warn(`${t} target conversation is not exist, conversationID:${e}`),Promise.reject({code:h.CONV_NOT_EXIST,message:d.CONV_NOT_EXIST})):(n&&this.setMessageRead(n),e&&this.setMessageRead(e),s.TUIStore.reset(a.CHAT,["messageList","isCompleted","nextReqMessageID"]),s.TUIStore.update(a.CONV,"currentConversationID",e),s.TUIStore.update(a.CONV,"currentConversation",i),Promise.resolve(i))}))}getConversationModel(e){return i(this,void 0,void 0,(function*(){let t=this.findConversation(e);if(S(t))try{const s=yield this.getConversationProfile(e);s.data&&s.data.conversation&&(t=new se(s.data.conversation))}catch(e){t=void 0}return t}))}findConversation(e){let t;const s=this.getEngine().TUIStore.getData(a.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(a.CONV,"currentConversationID"),s=this.findConversation(t);s&&e.TUIStore.update(a.CONV,"currentConversation",s)}getConversationList(){return this.getEngine().chat.getConversationList()}getConversationProfile(e){return this.getEngine().chat.getConversationProfile(e)}deleteConversation(e){return this.getEngine().chat.deleteConversation(e).then((t=>{const s=this.getEngine().TUIStore.getData(a.CONV,"currentConversationID");return console.log(`${this.serv}.deleteConversation conversationID:${e} currentConversationID:${s}`),e===s&&(this.getEngine().TUIStore.update(a.CONV,"currentConversationID",""),this.getEngine().TUIStore.update(a.CONV,"currentConversation",null)),t}))}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((e=>(this.getEngine().TUIStore.update(a.CHAT,"messageList",[]),this.getEngine().TUIStore.update(a.CHAT,"nextReqMessageID",""),this.getEngine().TUIStore.update(a.CHAT,"isCompleted",!0),e)))}setMessageRead(e){return this.getEngine().chat.setMessageRead({conversationID:e})}filterSystemConversation(e){return e.filter((e=>e.type!==this.getEngine().TYPES.CONV_SYSTEM))}}class Ot{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))}onProfileUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(a.USER,"userProfile");e.forEach((e=>{e.userID===s.userID&&t.TUIStore.update(a.USER,"userProfile",e)}))}onBlacklistUpdated(e){const t=this.getEngine();this.getBlacklistProfile(e).then((e=>{t.TUIStore.update(a.USER,"userBlacklist",e)}))}getBlacklistProfile(e){const t=[];let s=0;for(;s<e.length;)t.push(e.slice(s,s+=100));const n=[];t.forEach((e=>{n.push(this.TUIUserService.getUserProfile({userIDList:e}))}));const i=[];return Promise.all(n).then((e=>(e.forEach((e=>{const t=e.data.map((e=>{const{userID:t,nick:s,avatar:n}=e;return{userID:t,nick:s,avatar:n}}));i.push(...t)})),i)))}getUserProfile(e){const t=this.getEngine();return S(e)?t.chat.getMyProfile().then((e=>(t.TUIStore.update(a.USER,"userProfile",e.data),e))).catch((e=>Promise.reject(e))):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 Dt(e,t,s=!0){!function(e,t){w?$.setStorageSync(e,t):Pt()&&localStorage.setItem(e,JSON.stringify(t))}(s?_t(e):e,t)}function Ct(e,t=!0){try{return function(e){if(w)return $.getStorageSync(e);if(Pt()){const t=localStorage.getItem(e);if("undefined"!==t)return JSON.parse(t)}return}(t?_t(e):e)}catch(e){return void console.warn("Storage.getStorageItem error:",e)}}function _t(e){return`chat_engine_${e}`}function Pt(){return navigator&&navigator.cookieEnabled&&localStorage}class Rt{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){const e=this.getEngine(),t=Ct("displayOnlineStatus")||!1;e.TUIStore.update(a.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(a.CONV,{conversationList:()=>{const t=e.TUIStore.getData(a.APP,"enabledOnlineStatus"),s=e.TUIStore.getData(a.USER,"displayOnlineStatus");t&&s&&this.startToSubscribe()}})}onUserStatusUpdated(e){this.getEngine().TUIStore.update(a.USER,"userStatusList",e)}switchUserStatus(e){const t=this.getEngine(),{displayOnlineStatus:s=!1}=e;t.TUIStore.update(a.USER,"displayOnlineStatus",s),Dt("displayOnlineStatus",s);const n=t.TUIStore.getData(a.APP,"enabledOnlineStatus");n?!0===s?this.startToSubscribe():this.unsubscribeUserStatus():console.warn(`UserStatusHandler.switchUserStatus enabledOnlineStatus:${n} displayOnlineStatus:${s}`)}getUserStatus(e){const t=this.getEngine();return t.chat.getUserStatus(e).then((e=>{const{successUserList:s}=e.data;return s.length>0&&t.TUIStore.update(a.USER,"userStatusList",s),e})).catch((e=>Promise.reject(e)))}subscribeUserStatus(e){var t;const s=(null===(t=null==e?void 0:e.userIDList)||void 0===t?void 0:t.length)||0;return 0===s?(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((e=>{const{failureUserList:n}=e.data,i=[];return s.forEach((e=>{n.includes(e)||i.push({userID:e,statusType:u.UNSUB_USER})})),t.TUIStore.update(a.USER,"userStatusList",i),e})).catch((e=>Promise.reject(e)))}startToSubscribe(){const e=this.getEngine(),t=e.TUIStore.getData(a.CONV,"conversationList"),s=e.TUIStore.getData(a.USER,"userStatusList"),n=[];t.forEach((t=>{if(t.type===e.TYPES.CONV_C2C){const i=t.conversationID.replace(e.TYPES.CONV_C2C,"");s.has(i)||n.push(i)}})),0!==n.length&&e.chat.isReady()&&(this.subscribeUserStatus({userIDList:n}),this.getUserStatus({userIDList:n}))}}class jt extends ee{constructor(){super(),this.userProfileHandler=new Ot(this),this.userStatusHandler=new Rt(this)}static getInstance(){return jt.instance||(jt.instance=new jt),jt.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(a.USER,"kickedOut",e.type)}onNetStateChange(e){this.getEngine().TUIStore.update(a.USER,"netStateChange",e.state)}initMessageReadReceipt(){const e=Ct("displayMessageReadReceipt")||!0;this.getEngine().TUIStore.update(a.USER,"displayMessageReadReceipt",e)}switchUserStatus(e){return this.userStatusHandler.switchUserStatus(e)}switchMessageReadStatus(e){this.getEngine().TUIStore.update(a.USER,"displayMessageReadReceipt",e),Dt("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 Lt{constructor(e){this.TUIChatService=e}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:""};return t.name=e.payload.data.indexOf("@2x")<0?`${e.payload.data}@2x`:e.payload.data,t.url=`${P}${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=`${R}pointx=${t.lon}&pointy=${t.lat}&name=${e.payload.description}`,t.url=`${j}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:M(e.payload.fileSize)}}handleCustomMessage(e){var t;const s=this.handleCreateGroupCustomMessage(e);return{custom:this.handleCallKitSignaling(e)||s||(null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.extension)||`[${this.t("message.custom.自定义消息")}]`,businessID:s?"group_create":""}}handleMergeMessage(e){return Object.assign({},e.payload)}handleGroupTipsMessage(e){var t,s,n,i,r,o;const a=this.getEngine(),u={text:""};let c=(null==e?void 0:e.nick)||(null===(s=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.userIDList)||void 0===s?void 0:s.join(","));switch((null===(i=null===(n=null==e?void 0:e.payload)||void 0===n?void 0:n.memberList)||void 0===i?void 0:i.length)>0&&(c="",null===(o=null===(r=null==e?void 0:e.payload)||void 0===r?void 0:r.memberList)||void 0===o||o.map((e=>{c+=`${(null==e?void 0:e.nick)||(null==e?void 0:e.userID)},`})),c=null==c?void 0:c.slice(0,-1)),e.payload.operationType){case a.TYPES.GRP_TIP_MBR_JOIN:u.text=`${c} ${this.t("message.tip.加入群组")}`;break;case a.TYPES.GRP_TIP_MBR_QUIT:u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.退出群组")}`;break;case a.TYPES.GRP_TIP_MBR_KICKED_OUT:u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被")}${this.t("message.tip.踢出群组")}`;break;case a.TYPES.GRP_TIP_MBR_SET_ADMIN:u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.成为管理员")}`;break;case a.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被撤销管理员")}`;break;case a.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:u.text=this.handleGroupProfileUpdated(e);break;case a.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:for(const t of e.payload.memberList)t.muteTime>0?u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被禁言")}`:u.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被取消禁言")}`;break;default:u.text=`[${this.t("message.tip.群提示消息")}]`}return u}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,r,o,a,u,c,g;const l=U(e.payload.data);if(1!==(null==l?void 0:l.businessID))return"";const h=U(null==l?void 0:l.data);let p="";null===(t=null==l?void 0:l.inviteeList)||void 0===t||t.forEach((e=>{p+=`${e}、`})),p=p.substring(0,p.lastIndexOf("、"));const d=e.fromAccount||e.from;let f=this.getEngine().TUIFriend.getFriendRemark([d])[d]||e.nameCard||e.nick||d;switch(f=f.length>12?`${f.slice(0,12)}...`:f,null==l?void 0:l.actionType){case 1:return"audioCall"!==(null===(s=null==h?void 0:h.data)||void 0===s?void 0:s.cmd)&&"videoCall"!==(null===(n=null==h?void 0:h.data)||void 0===n?void 0:n.cmd)||!(null==l?void 0:l.groupID)?"hangup"===(null===(i=null==h?void 0:h.data)||void 0===i?void 0:i.cmd)?(null==l?void 0:l.groupID)?`${this.t("message.custom.通话结束")}`:`${this.t("message.custom.通话时长")}:${function(e){const t=e;let s,n,i,r="";return t>=3600?(s=parseInt(""+t/3600,10)<10?`0${parseInt(""+t/3600,10)}`:parseInt(""+t/3600,10),n=parseInt(""+t%60/60,10)<10?`0${parseInt(""+t%60/60,10)}`:parseInt(""+t%60/60,10),i=t%3600<10?"0"+t%3600:t%3600,i>60&&(n=parseInt(""+i/60,10)<10?`0${parseInt(""+i/60,10)}`:parseInt(""+i/60,10),i=i%60<10?"0"+i%60:i%60),r=`${s}:${n}:${i}`):t>=60&&t<3600?(n=parseInt(""+t/60,10)<10?`0${parseInt(""+t/60,10)}`:parseInt(""+t/60,10),i=t%60<10?"0"+t%60:t%60,r=`00:${n}:${i}`):t<60&&(i=t<10?`0${t}`:t,r=`00:00:${i}`),r}(null==h?void 0:h.call_end)}`:"switchToAudio"===(null===(r=null==h?void 0:h.data)||void 0===r?void 0:r.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(o=null==h?void 0:h.data)||void 0===o?void 0:o.cmd)?`${this.t("message.custom.切换视频通话")}`:`${this.t("message.custom.发起通话")}`:`${f} ${this.t("message.custom.发起通话")}`;case 2:return(null==l?void 0:l.groupID)?`${f} ${this.t("message.custom.取消通话")}`:this.t("message.custom.取消通话");case 3:return"switchToAudio"===(null===(a=null==h?void 0:h.data)||void 0===a?void 0:a.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(u=null==h?void 0:h.data)||void 0===u?void 0:u.cmd)?`${this.t("message.custom.切换视频通话")}`:(null==l?void 0:l.groupID)?`${f} ${this.t("message.custom.已接听")}`:this.t("message.custom.已接听");case 4:return(null==l?void 0:l.groupID)?`${f} ${this.t("message.custom.拒绝通话")}`:this.t("message.custom.拒绝通话");case 5:return"switchToAudio"===(null===(c=null==h?void 0:h.data)||void 0===c?void 0:c.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(g=null==h?void 0:h.data)||void 0===g?void 0:g.cmd)?`${this.t("message.custom.切换视频通话")}`:(null==l?void 0:l.groupID)?`${p} ${this.t("message.custom.无应答")}`:this.t("message.custom.无应答");default:return""}}handleCreateGroupCustomMessage(e){let t;const s=U(e.payload.data);return"group_create"===(null==s?void 0:s.businessID)&&(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(-1===i)t.push({name:"text",text:s}),s="";else{const e=s.slice(0,i+1);L[e]?(t.push({name:"img",src:_+L[e]}),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:r}=s;let o="";const a=t||r,u=Object.keys(n)[0];switch(u){case"muteAllMembers":o=n[u]?`${this.t("message.tip.管理员")} ${a} ${this.t("message.tip.开启全员禁言")}`:`${this.t("message.tip.管理员")} ${a} ${this.t("message.tip.取消全员禁言")}`;break;case"ownerID":o=`${i[0].nick||i[0].userID} ${this.t("message.tip.成为新的群主")}`;break;case"groupName":o=`${a} ${this.t("message.tip.修改群名为")} ${n[u]}`;break;case"notification":o=`${a} ${this.t("message.tip.发布新公告")}`}return o}}class At{constructor(e){this.TUIChatService=e,this.typingTo="",this.timer=null}getEngine(){return this.TUIChatService.getEngine()}clearTypingStatus(){this.getEngine().TUIStore.getData(a.CHAT,"typingStatus")&&this.getEngine().TUIStore.update(a.CHAT,"typingStatus",!1),this.timer&&clearTimeout(this.timer),this.timer=null}handleLastMessage(e){const t=this.getEngine(),s=t.TUIStore.getData(a.CHAT,"typingStatus");if(e.type===this.getEngine().TYPES.MSG_CUSTOM&&"in"===e.flow){const n=U(e.payload.data);if(n.businessID===c.BUSINESS_ID){const{typingStatus:e,userAction:i}=n;if(e===c.STATUS_START||i===c.ACTION_START_ID)return s?(this.timer&&clearTimeout(this.timer),this.timer=null):t.TUIStore.update(a.CHAT,"typingStatus",!0),this.timer=setTimeout((()=>{this.clearTypingStatus()}),3e4),t.TUIStore.getData(a.CHAT,"typingStatus");e!==c.STATUS_END&&i!==c.ACTION_END_ID||this.clearTypingStatus()}}}filterTypingMessage(e=[]){if(0===e.length)return[];return this.getEngine().TUIStore.getData(a.APP,"enableTyping")&&this.handleLastMessage(e[e.length-1]),e.filter((e=>{if(e.type===this.getEngine().TYPES.MSG_CUSTOM){return U(e.payload.data).businessID!==c.BUSINESS_ID}return!0}))}createTypingMessage(e=c.STATUS_END,t=""){const{BUSINESS_ID:s,STATUS_START:n,VERSION:i,ACTION_START_ID:r,ACTION_END_ID:o,ACTION_START:a,ACTION_END:u,NEED_TYPING:g}=c;return{to:t,conversationType:this.getEngine().TYPES.CONV_C2C,payload:{data:JSON.stringify({businessID:s,typingStatus:e,version:i,userAction:e===n?r:o,actionParam:e===n?a:u}),description:"",extension:""},cloudCustomData:JSON.stringify({messageFeature:{needTyping:g,version:i}})}}sendTyping(e=!1,t=""){if(e){this.typingTo=t;const e=this.createTypingMessage(c.STATUS_START,t);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}else this.sendTypingEnd()}sendTypingEnd(){if(this.typingTo){const e=this.createTypingMessage(c.STATUS_END,this.typingTo);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}this.typingTo=""}}class Gt{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(a.CONV,"currentConversationID"),n=[];e.forEach((e=>{const{messageID:i}=e,r=t.chat.findMessage(i);r&&s===r.conversationID&&n.push(r)})),n.length>0&&t.TUIChat.updateMessageList(n,"edit")}sendMessageReadReceipt(e){const t=[];return e.forEach((e=>{const s=e.getMessage();t.push(s)})),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(a.APP,"enabledMessageReadReceipt"),n=t.TUIStore.getData(a.USER,"displayMessageReadReceipt");!s||!n||0===e.length||e[0].conversationType!==t.TYPES.CONV_GROUP||t.chat.getMessageReadReceiptList(e).then((e=>{const{messageList:t}=e.data;this.TUIChatService.updateMessageList(t,"edit")})).catch((e=>{console.warn(`ReadReceiptHandler.getMessageReadReceiptList error:${e.message}`)}))}}class Nt extends ee{constructor(){super(),this.messageHandler=new Lt(this),this.typingHandler=new At(this),this.readReceiptHandler=new Gt(this),this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap=new Map}static getInstance(){return Nt.instance||(Nt.instance=new Nt),Nt.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,"push"),this.getEngine().TUIStore.update(a.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(a.CONV,{currentConversationID:t=>{this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.clear(),e.TUIStore.reset(a.CHAT),this.typingHandler.clearTypingStatus(),this.typingHandler.sendTypingEnd(),te(t)||this.getMessageList().finally((e=>{this.isSwitching=!1,this.delayGetHoppingFunction&&this.delayGetHoppingFunction()}))}})}onMessageSource(){const e=this.getEngine();e.TUIStore.watch(a.CHAT,{messageSource:t=>{const s=this.getStoreData(a.CONV,"currentConversationID");if(!s||t&&t.conversationID!==s)return;if(S(t))return this.hoppingConfigMap.clear(),e.TUIStore.update(a.CHAT,"messageList",[]),e.TUIStore.update(a.CHAT,"nextReqMessageID",""),e.TUIStore.update(a.CHAT,"isCompleted",!1),void this.getMessageList();const n=this.getStoreData(a.CHAT,"messageList");n&&n.find((e=>t&&e.ID===t.ID))||(this.isSwitching?this.delayGetHoppingFunction=this.getMessageListHoppingForDown:this.getMessageListHoppingForDown())}})}getMessageListHoppingForDown(){const e=this.getStoreData(a.CHAT,"messageList"),{conversationID:t,sequence:s,time:n,ID:i}=this.getStoreData(a.CHAT,"messageSource");if(e&&e.find((e=>i&&e.ID===i)))return;const r=this.getEngine();r.TUIStore.update(a.CHAT,"messageList",[]),r.TUIStore.update(a.CHAT,"nextReqMessageID",""),r.TUIStore.update(a.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((e=>{const s=e.data.messageList?e.data.messageList:[e.data.message];return t&&this.updateMessageList(s,"edit"),e})).catch((e=>{var t;return s&&(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.message)&&this.updateMessageList([e.data.message],"edit"),Promise.reject(e)}))}updateMessageList(e,t=""){if(this.getStoreData(a.CHAT,"messageSource")&&"unshift"!==t&&"edit"!==t)return;const s=this.getStoreData(a.CHAT,"messageList"),n=this.updateTargetMessageList(e,s,t);this.getEngine().TUIStore.update(a.CHAT,"messageList",n)}updateTargetMessageList(e,t,s=""){const n=this.getStoreData(a.CONV,"currentConversationID"),i=e.filter((e=>e.conversationID===n));if(!s||0===i.length)return t;const r=t||[];let o=[];switch(s){case"edit":for(const e of t){const t=i.find((t=>t.ID===e.ID));o.push(t||e)}break;case"resend":o=r.filter((e=>e.ID!==i[0].ID)).concat(i);break;case"send":o=r.concat(this.typingHandler.filterTypingMessage(i));break;case"push":o=r.concat(this.typingHandler.filterTypingMessage(i)),this.getEngine().chat.setMessageRead({conversationID:n});break;case"unshift":o=i.filter((e=>0===r.length||!r.find((t=>t.ID===e.ID)))),o.push(...r)}return o}enterTypingState(){this.getStoreData(a.APP,"enableTyping")&&this.sendTyping(!0)}leaveTypingState(){this.getStoreData(a.APP,"enableTyping")&&this.sendTyping(!1)}sendTyping(e){const t=this.getEngine(),s=this.getStoreData(a.CONV,"currentConversationID");if(!s.startsWith(t.TYPES.CONV_C2C))return;const n=s.replace(t.TYPES.CONV_C2C,"");if(e){const e=this.getStoreData(a.CHAT,"messageList").filter((e=>"in"===e.flow));if(0===e.length)return;const t=1e3*e[e.length-1].time;if((new Date).getTime()-t>3e4)return}this.typingHandler.sendTyping(e,n)}quoteMessage(e){return this.getEngine().TUIStore.update(a.CHAT,"quoteMessage",{message:e,type:"quote"}),e}replyMessage(e){return this.getEngine().TUIStore.update(a.CHAT,"quoteMessage",{message:e,type:"reply"}),e}getCurrentConvInfo(){const{conversationID:e="",type:t}=this.getStoreData(a.CONV,"currentConversation")||{};return{to:e.replace(t,""),conversationType:t}}t(e){return this.getEngine().TUITranslate.t(e)||e}getMessageAbstractAndType(e){var t;const s=this.getEngine(),n={abstract:"",type:0};switch(e.type){case s.TYPES.MSG_TEXT:n.abstract=null===(t=null==e?void 0:e.payload)||void 0===t?void 0:t.text,n.type=1;break;case s.TYPES.MSG_CUSTOM:n.abstract=this.t("[自定义消息]"),n.type=2;break;case s.TYPES.MSG_IMAGE:n.abstract=this.t("[图片]"),n.type=3;break;case s.TYPES.MSG_AUDIO:n.abstract=this.t("[语音]"),n.type=4;break;case s.TYPES.MSG_VIDEO:n.abstract=this.t("[视频]"),n.type=5;break;case s.TYPES.MSG_FILE:n.abstract=this.t("[文件]"),n.type=6;break;case s.TYPES.MSG_FACE:n.abstract=this.t("[表情]"),n.type=7}return n}genMessageReply(e,t){if("reply"!==t&&"quote"!==t)return{};const{abstract:s,type:n}=this.getMessageAbstractAndType(e),i={messageAbstract:s,messageSender:e.nick||e.from,messageID:e.ID},r=Object.assign(Object.assign({},i),{messageType:n,messageTime:null==e?void 0:e.time,messageSequence:null==e?void 0:e.sequence,version:1});if("reply"===t&&(r.messageRootID=e.ID,e.cloudCustomData)){const t=U(e.cloudCustomData);t.messageReply&&t.messageReply.messageRootID&&(r.messageRootID=t.messageReply.messageRootID)}return{messageReply:r,messageReplyRoot:i}}getMessageInfo(e,t,s){const{messageReply:n,messageReplyRoot:i}=this.genMessageReply(t,s),r=e.cloudCustomData?U(e.cloudCustomData):{};let o;if(r.messageReply?r.messageReply=Object.assign(Object.assign({},n),r.messageReply):r.messageReply=n,"reply"===s){const{messageRootID:e}=n;o=this.getEngine().chat.findMessage(e);const t=o.cloudCustomData?U(o.cloudCustomData):{};t.messageReplies||(t.messageReplies={}),a=t.messageReplies.replies,("function"==typeof Array.isArray?Array.isArray(a):"array"===Object.prototype.toString.call(a).match(/^\[object (.*)\]$/)[1].toLowerCase())||(t.messageReplies.replies=[]),t.messageReplies.replies.push(i),o.cloudCustomData=JSON.stringify(t)}var a;return{cloudCustomData:JSON.stringify(r),rootMessage:o}}sendTextMessage(e,t){const s=this.getEngine(),{message:n,type:i}=this.getStoreData(a.CHAT,"quoteMessage");let r={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};n&&(r=this.getMessageInfo(e,n,i));const o=s.chat.createTextMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:r.cloudCustomData}));return this.sendMessage(o,t).then((e=>(r.rootMessage&&this.modifyMessage(r.rootMessage),s.TUIStore.reset(a.CHAT,["quoteMessage"],!0),e)))}sendTextAtMessage(e,t){const s=this.getEngine(),{message:n,type:i}=this.getStoreData(a.CHAT,"quoteMessage");let r={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};n&&(r=this.getMessageInfo(e,n,i));const o=s.chat.createTextMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:r.cloudCustomData}));return this.sendMessage(o,t).then((e=>(r.rootMessage&&this.modifyMessage(r.rootMessage),s.TUIStore.reset(a.CHAT,["quoteMessage"],!0),e)))}sendImageMessage(e,t){const s=this.getEngine().chat.createImageMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(s.ID,e)}}));return this.sendMessage(s,t)}sendAudioMessage(e,t){const s=this.getEngine().chat.createAudioMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(s.ID,e)}}));return this.sendMessage(s,t)}sendVideoMessage(e,t){const s=this.getEngine().chat.createVideoMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{onProgress:e=>{this.onProgress(s.ID,e)}}));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:e=>{this.onProgress(s.ID,e)}}));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);if(s){(t-s.progress>=.1||1===t)&&(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:return n=e.payload.text||"",n.length>20&&(n=n.slice(0,20)),`${s}: ${n}`;case t.TYPES.MSG_MERGER:return`${s}: ${this.t("[聊天记录]")}`;case t.TYPES.MSG_IMAGE:return`${s}: ${this.t("[图片]")}`;case t.TYPES.MSG_AUDIO:return`${s}: ${this.t("[音频]")}`;case t.TYPES.MSG_VIDEO:return`${s}: ${this.t("[视频]")}`;case t.TYPES.MSG_CUSTOM:return`${s}: ${this.t("[自定义消息]")}`;case t.TYPES.MSG_FILE:return`${s}: ${this.t("[文件]")}`;case t.TYPES.MSG_FACE:return`${s}: ${this.t("[动画表情]")}`}}genMergerForwardPayload(e){const{conversationType:t,nick:s,from:n,to:i}=e[0],r=[];return e.forEach((e=>{r.push(this.setAbstractList(e))})),{messageList:e,title:"GROUP"===t?"群聊的聊天记录":`${s||n} 和 ${i} 的聊天记录`,abstractList:r,compatibleText:"请升级IMSDK到v2.10.1或更高版本查看此消息"}}sendMergerForwardMessage(e){const{conversationList:t,messageList:s,params:n,sendMessageOptions:i}=e,r=[];for(let e=0;e<t.length;e++){const{conversationID:o,type:a}=t[e],u=Object.assign({to:o.replace(`${a}`,""),conversationType:a,payload:this.genMergerForwardPayload(s)},n),c=this.getEngine().chat.createMergerMessage(u);r.push(this.sendMessage(c,i))}return Promise.all(r)}getOriginMessageList(e){return e.map((e=>e instanceof ie?e.getMessage():e))}sendForwardMessage(e,t,s){t=this.getOriginMessageList(t);const i=s||{},{needMerge:r=!1,params:o={}}=i,a=n(i,["needMerge","params"]);if(r)return this.sendMergerForwardMessage({conversationList:e,messageList:t,params:o,sendMessageOptions:a});const u=[];for(let s=0;s<e.length;s++){const{conversationID:n,type:i}=e[s],r=Object.assign({to:n.replace(`${i}`,""),conversationType:i},o);for(let e=0;e<t.length;e++){Reflect.set(r,"payload",t[e]);const s=this.getEngine().chat.createForwardMessage(r);u.push(this.sendMessage(s,a))}}return Promise.all(u)}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((e=>{const{code:t=0,data:s={}}=e.code;throw t===l.MSG_MODIFY_CONFLICT?console.warn(`${p.MSG_MODIFY_CONFLICT} data.message: ${null==s?void 0:s.message}`):t===l.MSG_MODIFY_DISABLED_IN_AVCHATROOM?console.warn(p.MSG_MODIFY_DISABLED_IN_AVCHATROOM):t===l.MODIFY_MESSAGE_NOT_EXIST&&console.warn(p.MODIFY_MESSAGE_NOT_EXIST),e}))}getMessageList(e={conversationID:this.getStoreData(a.CONV,"currentConversationID"),nextReqMessageID:this.getStoreData(a.CHAT,"nextReqMessageID")}){const t=this.getEngine();if(!t.chat.isReady())return Promise.reject({code:h.GET_MSG_LIST_ERROR,message:d.GET_MSG_LIST_ERROR});if(this.getStoreData(a.CHAT,"isCompleted"))return Promise.resolve({data:{messageList:[],nextReqMessageID:"",isCompleted:!0}});const s=this.getStoreData(a.CHAT,"messageSource"),n=this.hoppingConfigMap.get("nextMessageSeq"),i=this.hoppingConfigMap.get("nextMessageTime"),r=n||i;return s&&s.conversationID===e.conversationID&&r?this.getMessageListHopping():t.chat.getMessageList(e).then((e=>{const{messageList:s,nextReqMessageID:n,isCompleted:i}=e.data;return this.updateMessageList(s,"unshift"),t.TUIStore.update(a.CHAT,"nextReqMessageID",n),t.TUIStore.update(a.CHAT,"isCompleted",i),this.getMessageReactions({messageList:s}),this.readReceiptHandler.getMessageReadReceiptList(s),e})).catch((e=>Promise.reject(e)))}getMessageListHopping(e){var t;void 0===e&&(e={conversationID:null===(t=this.getStoreData(a.CHAT,"messageSource"))||void 0===t?void 0:t.conversationID,sequence:this.hoppingConfigMap.get("nextMessageSeq"),time:this.hoppingConfigMap.get("nextMessageTime")});const s=this.getEngine();return s.chat.getMessageListHopping(e).then((t=>{const{messageList:n,nextMessageSeq:i,nextMessageTime:r,isCompleted:o}=t.data,u=1===e.direction?e.sequence:i,c=1===e.direction?e.time:r;return this.updateMessageList(n,"unshift"),this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.set("nextMessageSeq",u),this.hoppingConfigMap.set("nextMessageTime",c),s.TUIStore.update(a.CHAT,"isCompleted",o),t})).catch((e=>Promise.reject(e)))}sendMessageReadReceipt(e){return this.readReceiptHandler.sendMessageReadReceipt(e)}getGroupMessageReadMemberList(e){return this.readReceiptHandler.getGroupMessageReadMemberList(e).then((e=>{const{isCompleted:t,cursor:s,messageID:n,unreadUserIDList:i,readUserIDList:r}=e.data,o={code:0,data:{cursor:s,isCompleted:t,messageID:n,unreadUserInfoList:[],readUserInfoList:[]}},a=[...i,...r];return 0===a.length?o:this.getEngine().TUIUser.getUserProfile({userIDList:a}).then((e=>(i.length>0?e.data.forEach((e=>{const{userID:t,nick:s="",avatar:n=""}=e;o.data.unreadUserInfoList.push({userID:t,nick:s,avatar:n})})):e.data.forEach((e=>{const{userID:t,nick:s="",avatar:n=""}=e;o.data.readUserInfoList.push({userID:t,nick:s,avatar:n})})),o)))}))}downloadMergedMessages(e){return this.getEngine().chat.downloadMergerMessage(e.getMessage())}translateText(e){return this.getEngine().chat.translateText(e)}searchCloudMessages(e){const t=this.getStoreData(a.CONV,"conversationList");return this.getEngine().chat.searchCloudMessages(e).then((e=>{const{searchResultList:s}=e.data;return e.data.searchResultList=s.map((e=>{const{messageList:s,conversationID:i}=e,r=n(e,["messageList","conversationID"]),o=s.map((e=>new ie(e))),a=t.find((e=>e.conversationID===i));return Object.assign(Object.assign({},r),{messageList:o.sort(((e,t)=>t.time-e.time)),conversation:a})})),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(a.APP,"enabledEmojiPlugin");console.log(`TUIChatService.getMessageReactions enabledEmojiPlugin:${s} messageList length:${t.length}`),s&&t.length>0&&this.getEngine().chat.getMessageReactions(e).then((e=>{const t=e.data.resultList||e.data;this.updateMessageReactionList(t)})).catch((e=>{console.warn(`TUIChatService.getMessageReactions error:${e.message}`)}))}getAllUserListOfMessageReaction(e){var t;return this.getEngine().chat.getAllUserListOfMessageReaction(Object.assign(Object.assign({},e),{message:null===(t=null==e?void 0:e.message)||void 0===t?void 0:t.getMessage()}))}updateMessageReactionList(e){const t=[];e.forEach((e=>{const{messageID:s,reactionList:n}=e,i=this.getEngine().TUIStore.getMessageModel(s);if(i){const e=[];for(let t=0;t<n.length;t++){let s=!0;for(let e=0;e<i.reactionList.length;e++)if(n[t].reactionID===i.reactionList[e].reactionID){i.reactionList[e]=n[t],s=!1;break}s&&e.push(n[t])}i.reactionList.push(...e),e.length=0,t.push(i)}})),t.length>0&&this.updateMessageList(t,"edit")}}class kt extends ee{constructor(){super(),this.groupMap=new Map}static getInstance(){return kt.instance||(kt.instance=new kt),kt.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(a.GRP,"groupList",e);const s=t.TUIStore.getData(a.GRP,"currentGroupID");e.forEach((e=>{e.groupID===s&&t.TUIStore.update(a.GRP,"currentGroup",e)}))}onGroupAttributesUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(a.GRP,"currentGroupID");let n=t.TUIStore.getData(a.GRP,"groupList");const{groupID:i,groupAttributes:r}=e;s===i&&t.TUIStore.update(a.GRP,"currentGroupAttributes",r),n=n.map((e=>(e.groupID===i&&(e.groupAttributes=r),e))),t.TUIStore.update(a.GRP,"groupList",n)}onGroupCounterUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(a.GRP,"currentGroupID"),n=t.TUIStore.getData(a.GRP,"currentGroupCounters")||{};let i=t.TUIStore.getData(a.GRP,"groupList");const{groupID:r,key:o,value:u}=e;s===r&&(n[o]=u,t.TUIStore.update(a.GRP,"currentGroupCounters",n)),i=i.map((e=>(e.groupID===r&&(e.groupCounters=Object.assign(Object.assign({},e.groupCounters),{[o]:u})),e))),t.TUIStore.update(a.GRP,"groupList",i)}onMessageReceived(e){const t=this.getEngine(),s=[];e.forEach((e=>{if(e.type===t.TYPES.MSG_GRP_TIP){const{payload:s}=e,{operationType:n,userIDList:i}=s,r=t.TUIStore.getData(a.GRP,"currentGroupID");switch(n){case t.TYPES.GRP_TIP_MBR_JOIN:this.addMemberList(i);break;case t.TYPES.GRP_TIP_MBR_QUIT:case t.TYPES.GRP_TIP_MBR_KICKED_OUT:this.removeMemberList(i);break;case t.TYPES.GRP_TIP_MBR_SET_ADMIN:case t.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:this.updateGroupMember(i);break;case t.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:this.getGroupProfile({groupID:r});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(i)}}e.type===t.TYPES.MSG_GRP_SYS_NOTICE&&s.push(e)})),s.length>0&&t.TUIStore.update(a.GRP,"groupSystemNoticeList",s)}getGroupInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getGroupList().then((e=>{const{groupList:t=[]}=e.data;console.log(`TUIGroupService.init, getGroupList count:${t.length}`),t.length>0&&this.onGroupListUpdated(t)}))}updateGroupMember(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine().TUIStore.getData(a.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(a.GRP,["currentGroupID","currentGroup","currentGroupAttributes","currentGroupCounters","currentGroupMemberList"],!0)}switchGroup(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine(),s=t.TUIStore.getData(a.GRP,"currentGroupID");if(!e)return this.resetCurrentStore(),Promise.resolve({});if(s===e){const e=t.TUIStore.getData(a.GRP,"currentGroup");return Promise.resolve(e)}this.resetCurrentStore(),t.TUIStore.update(a.GRP,"currentGroupID",e);try{yield this.getGroupInfo(e)}catch(e){Promise.reject(e)}const n=setTimeout((()=>{this.groupMap.delete(e),clearTimeout(n)}),5e3),i=t.TUIStore.getData(a.GRP,"currentGroup");return Promise.resolve(i)}))}getGroupInfo(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine(),s=this.groupMap.get(e);if(s)return this.updateMemberList((null==s?void 0:s.memberList)||[]),t.TUIStore.update(a.GRP,"currentGroup",s.group),t.TUIStore.update(a.GRP,"currentGroupAttributes",s.groupAttributes||{}),void t.TUIStore.update(a.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:r}}=yield this.getGroupMemberList({groupID:e});n.memberList=r;const o=yield this.getGroupAttributes({groupID:e,keyList:[]}),{groupAttributes:u}=o.data;n.groupAttributes=u,t.TUIStore.update(a.GRP,"currentGroupAttributes",u);try{const s=yield this.getGroupCounters({groupID:e,keyList:[]}),{counters:n}=s.data;t.TUIStore.update(a.GRP,"currentGroupCounters",n)}catch(e){console.warn(e)}this.groupMap.set(e,n)}))}getGroupProfile(e){const t=this.getEngine();return t.chat.getGroupProfile(e).then((s=>i(this,void 0,void 0,(function*(){if(t.TUIStore.getData(a.GRP,"currentGroupID")===e.groupID){const{group:e}=s.data;t.TUIStore.update(a.GRP,"currentGroup",e)}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((e=>{const{group:s}=e.data,n=t.TUIStore.getData(a.GRP,"groupList");return e.data.group.isJoinedGroup=n.some((e=>e.groupID===s.groupID)),e}))}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(a.GRP,"currentGroupMemberList")||[]).filter((t=>!e.find((e=>e.userID===t.userID)))),...e];t.TUIStore.update(a.GRP,"currentGroupMemberList",s)}addMemberList(e){return i(this,void 0,void 0,(function*(){const t=this.getEngine().TUIStore.getData(a.GRP,"currentGroupID");if(t)try{const s=yield this.getGroupMemberProfile({groupID:t,userIDList:e}),{memberList:n}=s.data;this.updateMemberList(n)}catch(t){const s=e.map((e=>({userID:e,avatar:"",nick:"",role:"",joinTime:0,nameCard:"",muteUntil:0,memberCustomField:[]})));this.updateMemberList(s)}}))}removeMemberList(e){const t=this.getEngine(),s=t.TUIStore.getData(a.GRP,"currentGroupMemberList").filter((t=>-1===e.indexOf(t.userID)));t.TUIStore.update(a.GRP,"currentGroupMemberList",s)}getGroupMemberList(e){const t=this.getEngine();return t.chat.getGroupMemberList(e).then((s=>{if(t.TUIStore.getData(a.GRP,"currentGroupID")===e.groupID){const{memberList:e}=s.data;this.updateMemberList(e)}return s}))}getGroupMemberProfile(e){return this.getEngine().chat.getGroupMemberProfile(e)}addGroupMember(e){const t=this.getEngine();return t.chat.addGroupMember(e).then((s=>i(this,void 0,void 0,(function*(){if(t.TUIStore.getData(a.GRP,"currentGroupID")===e.groupID){const{successUserIDList:e,group:n}=s.data;t.TUIStore.update(a.GRP,"currentGroup",n),this.addMemberList(e)}return s}))))}deleteGroupMember(e){const t=this.getEngine();return t.chat.deleteGroupMember(e).then((s=>{if(t.TUIStore.getData(a.GRP,"currentGroupID")===e.groupID){const{userIDList:e,group:n}=s.data;this.removeMemberList(e),t.TUIStore.update(a.GRP,"currentGroup",n)}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 xt extends ee{constructor(){super()}static getInstance(){return xt.instance||(xt.instance=new xt),xt.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))}onFriendListUpdated(e){this.getEngine().TUIStore.update(a.FRIEND,"friendList",e)}onFriendApplicationListUpdated(e){const{friendApplicationList:t,unreadCount:s=0}=e,n=this.getEngine();n.TUIStore.update(a.FRIEND,"friendApplicationList",t),n.TUIStore.update(a.FRIEND,"friendApplicationUnreadCount",s)}getFriendList(){return this.getEngine().chat.getFriendList()}getFriendRemark(e){const t=this.getEngine().TUIStore.getData(a.FRIEND,"friendList"),s={};return e.forEach((e=>{for(let n=0;n<t.length;n++)t[n].userID!==e||(s[e]=t[n].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()}}class wt{constructor(){this.cache=[],this.middlewares=[],this.options=null}use(e){return"function"!=typeof e&&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((function(e){return e})),this.options=e,this.next()}}function Vt(e,t,s){const n=Object.create(null);Object.keys(s).forEach((s=>{if(!t[s])return;n[s]=t[s];const i=new wt;t[s]=function(){const r=Array.from(arguments);return i.use((function(t,n){return e.isInited?n():Promise.reject({code:h.NOT_INIT,message:`${s} | ${d.NOT_INIT}`})})).use((function(e,i){return n[s].apply(t,e)})),i.run(r)}}))}console.log("TUIChatEngine.VERSION:2.0.5");const Ft=X.getInstance(),$t=W.getInstance(),Ht=ge.getInstance(),Yt=Ut.getInstance(),Bt=Mt.getInstance(),Kt=jt.getInstance(),qt=Nt.getInstance(),zt=kt.getInstance(),Jt=xt.getInstance();Ft.mount(o.TUIStore,Ht),Ft.mount(o.TUITranslate,Yt),Ft.mount(o.TUIConversation,Bt),Ft.mount(o.TUIUser,Kt),Ft.mount(o.TUIChat,qt),Ft.mount(o.TUIGroup,zt),Ft.mount(o.TUIFriend,Jt),Vt(Ft,Ft,f),Vt(Ft,Bt,m),Vt(Ft,qt,E),Vt(Ft,zt,v),Vt(Ft,Kt,T),Vt(Ft,Jt,I);export{a as StoreName,qt as TUIChatService,Bt as TUIConversationService,Jt as TUIFriendService,$t as TUIGlobal,zt as TUIGroupService,Ht as TUIStore,Yt as TUITranslateService,Kt as TUIUserService,Ft as default};
|