@tencentcloud/chat-uikit-engine-lite 0.0.1
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/README.md +98 -0
- package/index.d.ts +820 -0
- package/index.js +1 -0
- package/package.json +25 -0
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
## 关于 chat-uikit-engine
|
|
2
|
+
|
|
3
|
+
chat-uikit-engine 是腾讯云 Chat TUIKit 的基础库,它同时支持 Web、H5、uni-app、小程序,并且与框架(vuejs, react, react-native, angular等)无关。基于我们精心设计的 Chat TUIKit,您可以快速构建界面优美的、跨平台的、可靠的、可扩展的 Chat 应用。
|
|
4
|
+
|
|
5
|
+
chat-uikit-engine 由 service、model 和 store 三大模块组成,其作用如下:
|
|
6
|
+
|
|
7
|
+
- service 提供了一系列简化的聊天服务接口,包括切换会话、发送消息等。
|
|
8
|
+
|
|
9
|
+
- model 提供了一系列数据模型,如 ConversationModel、MessageModel 等。这些模型类用来管理聊天数据。
|
|
10
|
+
|
|
11
|
+
- store 提供了一系列状态管理模块,如会话状态管理、消息状态管理等,帮助开发者更加方便地管理聊天数据。
|
|
12
|
+
|
|
13
|
+
## 【安装】
|
|
14
|
+
|
|
15
|
+
```shell
|
|
16
|
+
npm install @tencentcloud/chat-uikit-engine
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## 【集成】
|
|
20
|
+
|
|
21
|
+
```javascript
|
|
22
|
+
import TUIChatEngine from '@tencentcloud/chat-uikit-engine';
|
|
23
|
+
|
|
24
|
+
// login to Tencent Cloud Chat
|
|
25
|
+
TUIChatEngine.login({
|
|
26
|
+
SDKAppID: 0, // 将0替换为您的云通信应用的 SDKAppID,类型为 Number
|
|
27
|
+
userID: 'your userID',
|
|
28
|
+
userSig: 'your userSig',
|
|
29
|
+
// 如果您需要发送图片、语音、视频、文件等富媒体消息,请设置为 true
|
|
30
|
+
useUploadPlugin: true,
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 【发送第一条消息】
|
|
35
|
+
|
|
36
|
+
#### 步骤 1:创建并打开会话
|
|
37
|
+
|
|
38
|
+
```javascript
|
|
39
|
+
import { TUIConversationService } from '@tencentcloud/chat-uikit-engine';
|
|
40
|
+
|
|
41
|
+
TUIConversationService.switchConversation("C2Cuser1")
|
|
42
|
+
.then() => {
|
|
43
|
+
console.warn("success");
|
|
44
|
+
})
|
|
45
|
+
.catch((error) => {
|
|
46
|
+
console.log(error);
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
#### 步骤 2:监听 messageList
|
|
51
|
+
|
|
52
|
+
```javascript
|
|
53
|
+
import {
|
|
54
|
+
TUIStore,
|
|
55
|
+
StoreName,
|
|
56
|
+
IMessageModel,
|
|
57
|
+
} from '@tencentcloud/chat-uikit-engine';
|
|
58
|
+
|
|
59
|
+
// 收到新消息、发送消息、删除消息等操作都会导致 messageList 发生变更
|
|
60
|
+
// watch messageList,开发者可及时获取到变更后的最新的 messageList
|
|
61
|
+
TUIStore.watch(StoreName.CHAT, {
|
|
62
|
+
messageList: (list: Array<IMessageModel>) => {
|
|
63
|
+
console.log("messageList", list); // messageList<IMessageModel>
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
#### 步骤 3:发送第一条消息
|
|
69
|
+
|
|
70
|
+
发送第一条消息后,开发者可以通过 **步骤2** 获取更新后的消息列表。
|
|
71
|
+
|
|
72
|
+
```javascript
|
|
73
|
+
import { TUIChatService } from '@tencentcloud/chat-uikit-engine';
|
|
74
|
+
|
|
75
|
+
TUIChatService.sendTextMessage({
|
|
76
|
+
payload: {
|
|
77
|
+
text: "Hello world!",
|
|
78
|
+
},
|
|
79
|
+
}).catch((error) => {
|
|
80
|
+
console.log(error);
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
#### 相关资源
|
|
85
|
+
|
|
86
|
+
- [TUIChatEngine 接口文档](https://web.sdk.qcloud.com/im/doc/chat-engine/index.html)
|
|
87
|
+
|
|
88
|
+
### 常见问题
|
|
89
|
+
|
|
90
|
+
#### 1. 什么是 UserSig?
|
|
91
|
+
|
|
92
|
+
UserSig 是用户登录即时通信 IM 的密钥,其本质是对 UserID 等信息加密后得到的密文。
|
|
93
|
+
|
|
94
|
+
#### 2. 如何生成 UserSig?
|
|
95
|
+
|
|
96
|
+
UserSig 签发方式是将 UserSig 的计算代码集成到您的服务端,并提供面向项目的接口,在需要 UserSig 时由您的项目向业务服务器发起请求获取动态 UserSig。更多详情请参见 [服务端生成 UserSig](https://cloud.tencent.com/document/product/269/32688#GeneratingdynamicUserSig)。
|
|
97
|
+
|
|
98
|
+
本文示例代码采用的获取 UserSig 的方案是在客户端代码中配置 SECRETKEY,该方法中 SECRETKEY 很容易被反编译逆向破解,一旦您的密钥泄露,攻击者就可以盗用您的腾讯云流量,因此**该方法仅适合本地跑通功能调试**。 正确的 UserSig 签发方式请参见上文。
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,820 @@
|
|
|
1
|
+
import TencentCloudChat, { Conversation, Message, Profile, Group, ChatSDK } from '@tencentcloud/lite-chat/basic';
|
|
2
|
+
|
|
3
|
+
interface IConversationModel {
|
|
4
|
+
conversationID: string;
|
|
5
|
+
type: string;
|
|
6
|
+
subType: string;
|
|
7
|
+
unreadCount: number;
|
|
8
|
+
lastMessage?: {
|
|
9
|
+
nick: string;
|
|
10
|
+
nameCard: string;
|
|
11
|
+
lastTime: number | string;
|
|
12
|
+
lastSequence: string;
|
|
13
|
+
fromAccount: string;
|
|
14
|
+
isRevoked: boolean;
|
|
15
|
+
revoker?: string;
|
|
16
|
+
isPeerRead: boolean;
|
|
17
|
+
messageForShow: string;
|
|
18
|
+
type: string;
|
|
19
|
+
payload: any;
|
|
20
|
+
};
|
|
21
|
+
groupProfile?: any;
|
|
22
|
+
userProfile?: any;
|
|
23
|
+
groupAtInfoList?: any[];
|
|
24
|
+
remark: string;
|
|
25
|
+
isPinned: boolean;
|
|
26
|
+
messageRemindType: string;
|
|
27
|
+
markList: string[];
|
|
28
|
+
customData: string;
|
|
29
|
+
conversationGroupList: any[];
|
|
30
|
+
draftText: string;
|
|
31
|
+
isMuted: boolean;
|
|
32
|
+
operationType: number;
|
|
33
|
+
_conversation: any;
|
|
34
|
+
updateProperties(options: Conversation): void;
|
|
35
|
+
updateOperationType(operationType: number): void;
|
|
36
|
+
getConversation(): any;
|
|
37
|
+
deleteConversation(clearHistoryMessage?: boolean): Promise<any>;
|
|
38
|
+
pinConversation(): Promise<any>;
|
|
39
|
+
muteConversation(): Promise<any>;
|
|
40
|
+
setMessageRead(): Promise<any>;
|
|
41
|
+
getAvatar(): string;
|
|
42
|
+
getShowName(): string;
|
|
43
|
+
getGroupAtInfo(): string;
|
|
44
|
+
getLastMessage(key: string): string | null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface IGroupModel {
|
|
48
|
+
groupID: string;
|
|
49
|
+
name: string;
|
|
50
|
+
avatar: string;
|
|
51
|
+
type: TencentCloudChat.TYPES.GRP_WORK | TencentCloudChat.TYPES.GRP_PUBLIC | TencentCloudChat.TYPES.GRP_MEETING | TencentCloudChat.TYPES.GRP_AVCHATROOM | TencentCloudChat.TYPES.GRP_COMMUNITY;
|
|
52
|
+
introduction: string;
|
|
53
|
+
notification: string;
|
|
54
|
+
ownerID: string;
|
|
55
|
+
createTime: number;
|
|
56
|
+
infoSequence?: number;
|
|
57
|
+
lastInfoTime?: number;
|
|
58
|
+
selfInfo?: {
|
|
59
|
+
role?: string;
|
|
60
|
+
messageRemindType?: string;
|
|
61
|
+
joinTime?: number;
|
|
62
|
+
nameCard?: string;
|
|
63
|
+
userID?: string;
|
|
64
|
+
memberCustomField?: any[];
|
|
65
|
+
};
|
|
66
|
+
lastMessage?: any;
|
|
67
|
+
nextMessageSeq: number;
|
|
68
|
+
memberCount: number;
|
|
69
|
+
maxMemberCount: number;
|
|
70
|
+
muteAllMembers: boolean;
|
|
71
|
+
joinOption: string;
|
|
72
|
+
groupCustomField?: any[];
|
|
73
|
+
isSupportTopic: boolean;
|
|
74
|
+
groupAttributes: any;
|
|
75
|
+
groupCounters: any;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
interface IMessageModel {
|
|
79
|
+
ID: string;
|
|
80
|
+
type: TencentCloudChat.TYPES;
|
|
81
|
+
payload: any;
|
|
82
|
+
conversationID: string;
|
|
83
|
+
conversationType: TencentCloudChat.TYPES;
|
|
84
|
+
to: string;
|
|
85
|
+
from: string;
|
|
86
|
+
flow: string;
|
|
87
|
+
time: number;
|
|
88
|
+
status: string;
|
|
89
|
+
isRevoked: boolean;
|
|
90
|
+
priority: TencentCloudChat.TYPES;
|
|
91
|
+
nick: string;
|
|
92
|
+
avatar: string;
|
|
93
|
+
isPeerRead: boolean;
|
|
94
|
+
nameCard: string;
|
|
95
|
+
atUserList: string[];
|
|
96
|
+
cloudCustomData: string;
|
|
97
|
+
isDeleted: boolean;
|
|
98
|
+
isModified: boolean;
|
|
99
|
+
needReadReceipt: boolean;
|
|
100
|
+
readReceiptInfo: any;
|
|
101
|
+
isBroadcastMessage: boolean;
|
|
102
|
+
isSupportExtension: boolean;
|
|
103
|
+
receiverList?: string[];
|
|
104
|
+
revoker: string;
|
|
105
|
+
sequence: number;
|
|
106
|
+
progress: number;
|
|
107
|
+
revokerInfo: {
|
|
108
|
+
userID: string;
|
|
109
|
+
nick: string;
|
|
110
|
+
avatar: string;
|
|
111
|
+
};
|
|
112
|
+
revokeReason: string;
|
|
113
|
+
hasRiskContent: boolean;
|
|
114
|
+
reactionList: ReactionInfo[];
|
|
115
|
+
updateProperties(options: Message): void;
|
|
116
|
+
getMessage(): Message;
|
|
117
|
+
modifyMessage(options: ModifyMessageParams): Promise<any>;
|
|
118
|
+
revokeMessage(): Promise<any>;
|
|
119
|
+
resendMessage(): Promise<any>;
|
|
120
|
+
deleteMessage(): Promise<any>;
|
|
121
|
+
quoteMessage(): Message;
|
|
122
|
+
replyMessage(): Message;
|
|
123
|
+
setMessageExtensions(extensions: object[]): Promise<any>;
|
|
124
|
+
deleteMessageExtensions(keyList?: string[]): Promise<any>;
|
|
125
|
+
getMessageExtensions(): Promise<any>;
|
|
126
|
+
getSignalingInfo(): Record<string, any> | null;
|
|
127
|
+
getMessageContent(): Record<string, any>;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
type func = (...args: any[]) => any;
|
|
131
|
+
type SEARCH_TYPE = 'global' | 'conversation';
|
|
132
|
+
interface LoginParams {
|
|
133
|
+
SDKAppID: number;
|
|
134
|
+
userID: string;
|
|
135
|
+
userSig: string;
|
|
136
|
+
chat?: any;
|
|
137
|
+
unlimitedAVChatRoom?: boolean;
|
|
138
|
+
scene?: string;
|
|
139
|
+
fileUploadProxy?: string;
|
|
140
|
+
fileDownloadProxy?: string;
|
|
141
|
+
proxyServer?: string;
|
|
142
|
+
devMode?: boolean;
|
|
143
|
+
testEnv?: boolean;
|
|
144
|
+
}
|
|
145
|
+
interface UpdateMyProfileParams {
|
|
146
|
+
nick?: string;
|
|
147
|
+
avatar?: string;
|
|
148
|
+
gender?: TencentCloudChat.TYPES;
|
|
149
|
+
selfSignature?: string;
|
|
150
|
+
allowType?: TencentCloudChat.TYPES;
|
|
151
|
+
birthday?: number;
|
|
152
|
+
location?: string;
|
|
153
|
+
language?: number;
|
|
154
|
+
messageSettings?: number;
|
|
155
|
+
adminForbidType?: TencentCloudChat.TYPES;
|
|
156
|
+
level?: number;
|
|
157
|
+
role?: number;
|
|
158
|
+
profileCustomField?: object[];
|
|
159
|
+
}
|
|
160
|
+
interface UserIDListParams {
|
|
161
|
+
userIDList: string[];
|
|
162
|
+
}
|
|
163
|
+
interface SwitchUserStatusParams {
|
|
164
|
+
displayOnlineStatus: boolean;
|
|
165
|
+
}
|
|
166
|
+
interface DeleteConversationParams {
|
|
167
|
+
conversationIDList: string[];
|
|
168
|
+
clearHistoryMessage: boolean;
|
|
169
|
+
}
|
|
170
|
+
interface PinConversationParams {
|
|
171
|
+
conversationID: string;
|
|
172
|
+
isPinned: boolean;
|
|
173
|
+
}
|
|
174
|
+
interface MuteConversationParams {
|
|
175
|
+
groupID?: string;
|
|
176
|
+
userIDList?: string[];
|
|
177
|
+
messageRemindType: TencentCloudChat.TYPES;
|
|
178
|
+
}
|
|
179
|
+
interface MarkConversationParams {
|
|
180
|
+
conversationIDList: string[];
|
|
181
|
+
markType: number;
|
|
182
|
+
enableMark: boolean;
|
|
183
|
+
}
|
|
184
|
+
interface SetConversationDraftParams {
|
|
185
|
+
conversationID: string;
|
|
186
|
+
draftText?: string;
|
|
187
|
+
draftInfo?: {
|
|
188
|
+
html: string;
|
|
189
|
+
abstract: string;
|
|
190
|
+
messageID?: string;
|
|
191
|
+
type?: 'reply' | 'quote';
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
interface SendMessageBasicParams {
|
|
195
|
+
priority?: TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST | TencentCloudChat.TYPES.MSG_PRIORITY_LOW | TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL | TencentCloudChat.TYPES.MSG_PRIORITY_HIGH;
|
|
196
|
+
payload: any;
|
|
197
|
+
cloudCustomData?: string;
|
|
198
|
+
needReadReceipt?: boolean;
|
|
199
|
+
receiverList?: string[];
|
|
200
|
+
}
|
|
201
|
+
interface SendMessageParams extends SendMessageBasicParams {
|
|
202
|
+
to?: string;
|
|
203
|
+
conversationType?: TencentCloudChat.TYPES.CONV_C2C | TencentCloudChat.TYPES.CONV_GROUP;
|
|
204
|
+
}
|
|
205
|
+
interface SendForwardMessageMergeInfo {
|
|
206
|
+
title?: string;
|
|
207
|
+
abstractList?: string[];
|
|
208
|
+
compatibleText?: string;
|
|
209
|
+
}
|
|
210
|
+
interface SendForwardMessageOptions extends SendMessageOptions {
|
|
211
|
+
needMerge?: boolean;
|
|
212
|
+
params?: {
|
|
213
|
+
priority?: TencentCloudChat.TYPES.MSG_PRIORITY_LOWEST | TencentCloudChat.TYPES.MSG_PRIORITY_LOW | TencentCloudChat.TYPES.MSG_PRIORITY_NORMAL | TencentCloudChat.TYPES.MSG_PRIORITY_HIGH;
|
|
214
|
+
cloudCustomData?: string;
|
|
215
|
+
needReadReceipt?: boolean;
|
|
216
|
+
receiverList?: string[];
|
|
217
|
+
};
|
|
218
|
+
mergeInfo?: SendForwardMessageMergeInfo;
|
|
219
|
+
[key: string]: any;
|
|
220
|
+
}
|
|
221
|
+
interface OfflinePushInfo {
|
|
222
|
+
disablePush?: boolean;
|
|
223
|
+
disableVoipPush?: boolean;
|
|
224
|
+
title?: string;
|
|
225
|
+
description?: string;
|
|
226
|
+
extension?: string;
|
|
227
|
+
ignoreIOSBadge?: boolean;
|
|
228
|
+
androidOPPOChannelID?: string;
|
|
229
|
+
}
|
|
230
|
+
interface MessageControlInfo {
|
|
231
|
+
excludedFromUnreadCount?: boolean;
|
|
232
|
+
excludedFromLastMessage?: boolean;
|
|
233
|
+
excludedFromContentModeration?: boolean;
|
|
234
|
+
}
|
|
235
|
+
interface SendMessageOptions {
|
|
236
|
+
onlineUserOnly?: boolean;
|
|
237
|
+
offlinePushInfo?: OfflinePushInfo;
|
|
238
|
+
messageControlInfo?: MessageControlInfo;
|
|
239
|
+
}
|
|
240
|
+
interface TranslateTextParams {
|
|
241
|
+
sourceTextList: string[];
|
|
242
|
+
sourceLanguage?: string;
|
|
243
|
+
}
|
|
244
|
+
interface ConvertVoiceToTextParams {
|
|
245
|
+
message: IMessageModel;
|
|
246
|
+
language?: string;
|
|
247
|
+
}
|
|
248
|
+
declare enum ISearchType {
|
|
249
|
+
MESSAGE = "message",
|
|
250
|
+
CHAT_MESSAGE = "chat_message",
|
|
251
|
+
USER = "user",
|
|
252
|
+
GROUP = "group"
|
|
253
|
+
}
|
|
254
|
+
declare enum MessageType {
|
|
255
|
+
MSG_TEXT = "TIMTextElem",
|
|
256
|
+
MSG_IMAGE = "TIMImageElem",
|
|
257
|
+
MSG_SOUND = "TIMSoundElem",
|
|
258
|
+
MSG_FILE = "TIMFileElem",
|
|
259
|
+
MSG_VIDEO = "TIMVideoFileElem",
|
|
260
|
+
MSG_LOCATION = "TIMLocationElem",
|
|
261
|
+
MSG_CUSTOM = "TIMCustomElem",
|
|
262
|
+
MSG_MERGER = "TIMRelayElem"
|
|
263
|
+
}
|
|
264
|
+
declare enum GroupType {
|
|
265
|
+
GRP_WORK = "Private",
|
|
266
|
+
GRP_PUBLIC = "Public",
|
|
267
|
+
GRP_MEETING = "ChatRoom",
|
|
268
|
+
GRP_COMMUNITY = "Community"
|
|
269
|
+
}
|
|
270
|
+
interface ISearchCloudMessagesResultBase<T extends ISearchType> {
|
|
271
|
+
totalCount: number;
|
|
272
|
+
params: ISearchParamsMap[T];
|
|
273
|
+
}
|
|
274
|
+
interface ISearchCloudMessagesResultItem {
|
|
275
|
+
messageList: IMessageModel[];
|
|
276
|
+
messageCount: number;
|
|
277
|
+
conversation?: IConversationModel;
|
|
278
|
+
}
|
|
279
|
+
interface ISearchCloudUsersResultItem {
|
|
280
|
+
profile: Profile;
|
|
281
|
+
relation: TencentCloudChat.TYPES.SNS_TYPE_NO_RELATION | TencentCloudChat.TYPES.SNS_TYPE_A_WITH_B | TencentCloudChat.TYPES.SNS_TYPE_B_WITH_A | TencentCloudChat.TYPES.SNS_TYPE_BOTH_WAY;
|
|
282
|
+
}
|
|
283
|
+
interface ISearchCloudGroupsResultItem {
|
|
284
|
+
groupInfo: Group;
|
|
285
|
+
conversation?: IConversationModel;
|
|
286
|
+
}
|
|
287
|
+
interface IResultMap {
|
|
288
|
+
[ISearchType.MESSAGE]: ISearchCloudMessagesResultItem[];
|
|
289
|
+
[ISearchType.CHAT_MESSAGE]: ISearchCloudMessagesResultItem[];
|
|
290
|
+
[ISearchType.USER]: ISearchCloudUsersResultItem[];
|
|
291
|
+
[ISearchType.GROUP]: ISearchCloudGroupsResultItem[];
|
|
292
|
+
}
|
|
293
|
+
interface ISearchResult<T extends ISearchType> extends ISearchCloudMessagesResultBase<T> {
|
|
294
|
+
resultList: IResultMap[T] | [];
|
|
295
|
+
hasMore: boolean;
|
|
296
|
+
cursor: string;
|
|
297
|
+
}
|
|
298
|
+
interface ISearchParamsMap {
|
|
299
|
+
[ISearchType.MESSAGE]: SearchCloudMessagesParams;
|
|
300
|
+
[ISearchType.CHAT_MESSAGE]: SearchCloudMessagesParams;
|
|
301
|
+
[ISearchType.USER]: SearchCloudUsersParams;
|
|
302
|
+
[ISearchType.GROUP]: SearchCloudGroupsParams;
|
|
303
|
+
}
|
|
304
|
+
interface BaseSearchCloudParams {
|
|
305
|
+
keyword?: string;
|
|
306
|
+
keywordList?: string[];
|
|
307
|
+
keywordListMatchType?: 'or' | 'and';
|
|
308
|
+
cursor?: string;
|
|
309
|
+
count?: number;
|
|
310
|
+
}
|
|
311
|
+
interface SearchCloudMessagesParams extends BaseSearchCloudParams {
|
|
312
|
+
senderUserIDList?: string[];
|
|
313
|
+
messageTypeList?: any[];
|
|
314
|
+
conversationID?: string;
|
|
315
|
+
timePosition?: number;
|
|
316
|
+
timePeriod?: number;
|
|
317
|
+
}
|
|
318
|
+
interface SearchCloudUsersParams extends BaseSearchCloudParams {
|
|
319
|
+
gender?: string;
|
|
320
|
+
miniBirthday?: number;
|
|
321
|
+
maxBirthday?: number;
|
|
322
|
+
}
|
|
323
|
+
interface SearchCloudGroupsParams extends BaseSearchCloudParams {
|
|
324
|
+
groupTypeList?: any[];
|
|
325
|
+
}
|
|
326
|
+
interface SearchCloudGroupMembersParams extends BaseSearchCloudParams {
|
|
327
|
+
groupTypeList?: string[];
|
|
328
|
+
groupIDList?: string[];
|
|
329
|
+
}
|
|
330
|
+
interface ForwardMessageParams {
|
|
331
|
+
to: string;
|
|
332
|
+
conversationType: TencentCloudChat.TYPES.CONV_C2C | TencentCloudChat.TYPES.CONV_GROUP;
|
|
333
|
+
priority?: TencentCloudChat.TYPES;
|
|
334
|
+
payload: Message;
|
|
335
|
+
}
|
|
336
|
+
interface GetMessageListParams {
|
|
337
|
+
conversationID: string;
|
|
338
|
+
nextReqMessageID: string;
|
|
339
|
+
}
|
|
340
|
+
interface GetMessageListHoppingParams {
|
|
341
|
+
conversationID: string;
|
|
342
|
+
sequence?: number;
|
|
343
|
+
time?: number;
|
|
344
|
+
direction?: number;
|
|
345
|
+
count?: number;
|
|
346
|
+
}
|
|
347
|
+
interface GetGroupMessageReadParams {
|
|
348
|
+
message: IMessageModel;
|
|
349
|
+
filter: number;
|
|
350
|
+
cursor: string;
|
|
351
|
+
count: number;
|
|
352
|
+
}
|
|
353
|
+
interface GetMessageReactionsParams {
|
|
354
|
+
messageList: Message[];
|
|
355
|
+
maxUserCountPerReaction?: number;
|
|
356
|
+
}
|
|
357
|
+
interface ReactionInfo {
|
|
358
|
+
reactionID: string;
|
|
359
|
+
totalUserCount: number;
|
|
360
|
+
partialUserList: ReactionUserInfo[];
|
|
361
|
+
}
|
|
362
|
+
interface ReactionUserInfo {
|
|
363
|
+
userID: string;
|
|
364
|
+
nick: string;
|
|
365
|
+
avatar: string;
|
|
366
|
+
}
|
|
367
|
+
interface GetAllUserListOfMessageReactionParams {
|
|
368
|
+
message: IMessageModel;
|
|
369
|
+
reactionID: string;
|
|
370
|
+
nextSeq: number;
|
|
371
|
+
count?: number;
|
|
372
|
+
}
|
|
373
|
+
interface ModifyMessageParams {
|
|
374
|
+
type?: TencentCloudChat.TYPES;
|
|
375
|
+
payload?: any;
|
|
376
|
+
cloudCustomData?: string;
|
|
377
|
+
}
|
|
378
|
+
interface GroupServiceBasicParams {
|
|
379
|
+
groupID: string;
|
|
380
|
+
}
|
|
381
|
+
interface GetGroupProfileParams extends GroupServiceBasicParams {
|
|
382
|
+
groupCustomFieldFilter?: string[];
|
|
383
|
+
}
|
|
384
|
+
interface UpdateGroupParams extends GroupServiceBasicParams {
|
|
385
|
+
name?: string;
|
|
386
|
+
avatar?: string;
|
|
387
|
+
introduction?: string;
|
|
388
|
+
notification?: string;
|
|
389
|
+
muteAllMembers?: boolean;
|
|
390
|
+
joinOption?: TencentCloudChat.TYPES.JOIN_OPTIONS_FREE_ACCESS | TencentCloudChat.TYPES.JOIN_OPTIONS_NEED_PERMISSION | TencentCloudChat.TYPES.JOIN_OPTIONS_DISABLE_APPLY;
|
|
391
|
+
inviteOption?: TencentCloudChat.TYPES.JOIN_OPTIONS_FREE_ACCESS | TencentCloudChat.TYPES.JOIN_OPTIONS_NEED_PERMISSION | TencentCloudChat.TYPES.JOIN_OPTIONS_DISABLE_APPLY;
|
|
392
|
+
groupCustomField?: Record<string, string>[];
|
|
393
|
+
}
|
|
394
|
+
interface ChangGroupOwnerParams extends GroupServiceBasicParams {
|
|
395
|
+
newOwnerID: string;
|
|
396
|
+
}
|
|
397
|
+
interface GroupAttrParams extends GroupServiceBasicParams {
|
|
398
|
+
groupAttributes: Record<string, string>;
|
|
399
|
+
}
|
|
400
|
+
interface SetCountersParams extends GroupServiceBasicParams {
|
|
401
|
+
counters: Record<string, number>;
|
|
402
|
+
}
|
|
403
|
+
interface CountersParams extends GroupServiceBasicParams {
|
|
404
|
+
key: string;
|
|
405
|
+
value: number;
|
|
406
|
+
}
|
|
407
|
+
interface JoinGroupParams extends GroupServiceBasicParams {
|
|
408
|
+
applyMessage?: string;
|
|
409
|
+
}
|
|
410
|
+
interface KeyListParams extends GroupServiceBasicParams {
|
|
411
|
+
keyList: string[];
|
|
412
|
+
}
|
|
413
|
+
interface CreateGroupParams {
|
|
414
|
+
name: string;
|
|
415
|
+
type: string;
|
|
416
|
+
groupID?: string;
|
|
417
|
+
introduction?: string;
|
|
418
|
+
notification?: string;
|
|
419
|
+
avatar?: string;
|
|
420
|
+
maxMemberNum?: number;
|
|
421
|
+
joinOption: string;
|
|
422
|
+
memberList?: GroupMemberItem[];
|
|
423
|
+
groupCustomField?: any[];
|
|
424
|
+
isSupportTopic?: boolean;
|
|
425
|
+
}
|
|
426
|
+
interface GroupMemberItem {
|
|
427
|
+
userID: string;
|
|
428
|
+
role?: string;
|
|
429
|
+
memberCustomField?: any[];
|
|
430
|
+
}
|
|
431
|
+
interface handleGroupApplicationParams {
|
|
432
|
+
handleAction: 'Agree' | 'Reject';
|
|
433
|
+
handleMessage?: string;
|
|
434
|
+
application: any;
|
|
435
|
+
}
|
|
436
|
+
interface GetMemberListParams extends GroupServiceBasicParams {
|
|
437
|
+
count?: number;
|
|
438
|
+
offset?: number | string;
|
|
439
|
+
filter?: number;
|
|
440
|
+
}
|
|
441
|
+
interface GetMemberProfileParams extends GroupServiceBasicParams {
|
|
442
|
+
userIDList: string[];
|
|
443
|
+
memberCustomFieldFilter?: string[];
|
|
444
|
+
}
|
|
445
|
+
interface AddMemberParams extends GroupServiceBasicParams {
|
|
446
|
+
userIDList: string[];
|
|
447
|
+
}
|
|
448
|
+
interface DeleteMemberParams extends GroupServiceBasicParams {
|
|
449
|
+
userIDList: string[];
|
|
450
|
+
reason?: string;
|
|
451
|
+
duration?: number;
|
|
452
|
+
}
|
|
453
|
+
interface SetMemberMuteParams extends GroupServiceBasicParams {
|
|
454
|
+
userID: string;
|
|
455
|
+
muteTime: number;
|
|
456
|
+
}
|
|
457
|
+
interface SetMemberRoleParams extends GroupServiceBasicParams {
|
|
458
|
+
userID: string;
|
|
459
|
+
role: TencentCloudChat.TYPES;
|
|
460
|
+
}
|
|
461
|
+
interface SetMemberNameCardParams extends GroupServiceBasicParams {
|
|
462
|
+
userID?: string;
|
|
463
|
+
nameCard: string;
|
|
464
|
+
}
|
|
465
|
+
interface SetMemberCustomFiledParams extends GroupServiceBasicParams {
|
|
466
|
+
userID?: string;
|
|
467
|
+
memberCustomField: Record<string, string>[];
|
|
468
|
+
}
|
|
469
|
+
interface MarkMemberParams extends GroupServiceBasicParams {
|
|
470
|
+
userIDList: string[];
|
|
471
|
+
markType: number;
|
|
472
|
+
enableMark: boolean;
|
|
473
|
+
}
|
|
474
|
+
interface Friend {
|
|
475
|
+
userID: string;
|
|
476
|
+
remark: string;
|
|
477
|
+
groupList: any[];
|
|
478
|
+
source: string;
|
|
479
|
+
wording: string;
|
|
480
|
+
profile: any;
|
|
481
|
+
friendCustomFriend: any[];
|
|
482
|
+
}
|
|
483
|
+
interface FriendApplication {
|
|
484
|
+
userID: string;
|
|
485
|
+
avatar: string;
|
|
486
|
+
nick: string;
|
|
487
|
+
time: number;
|
|
488
|
+
source: string;
|
|
489
|
+
wording: string;
|
|
490
|
+
type: string;
|
|
491
|
+
}
|
|
492
|
+
interface AddFriendParams {
|
|
493
|
+
to: string;
|
|
494
|
+
source: string;
|
|
495
|
+
remark?: string;
|
|
496
|
+
groupName?: string;
|
|
497
|
+
wording?: string;
|
|
498
|
+
type?: TencentCloudChat.TYPES;
|
|
499
|
+
}
|
|
500
|
+
interface DeleteFriendParams {
|
|
501
|
+
userIDList: string[];
|
|
502
|
+
type?: TencentCloudChat.TYPES;
|
|
503
|
+
}
|
|
504
|
+
interface CheckFriendParams {
|
|
505
|
+
userIDList: string[];
|
|
506
|
+
type: Partial<TencentCloudChat.TYPES>;
|
|
507
|
+
}
|
|
508
|
+
interface GetFriendProfileParams {
|
|
509
|
+
userIDList: string[];
|
|
510
|
+
}
|
|
511
|
+
interface UpdateFriendParams {
|
|
512
|
+
userID: string;
|
|
513
|
+
remark?: string;
|
|
514
|
+
friendCustomField?: any[];
|
|
515
|
+
}
|
|
516
|
+
interface AcceptFriendApplicationParams {
|
|
517
|
+
userID: string;
|
|
518
|
+
remark?: string;
|
|
519
|
+
type: TencentCloudChat.TYPES;
|
|
520
|
+
}
|
|
521
|
+
interface DeleteFriendApplicationParams {
|
|
522
|
+
userID: string;
|
|
523
|
+
type: TencentCloudChat.TYPES;
|
|
524
|
+
}
|
|
525
|
+
interface FriendGroup {
|
|
526
|
+
name: string;
|
|
527
|
+
friendList: Friend[];
|
|
528
|
+
count: number;
|
|
529
|
+
}
|
|
530
|
+
interface FriendGroupParams {
|
|
531
|
+
name: string;
|
|
532
|
+
userIDList: string[];
|
|
533
|
+
}
|
|
534
|
+
interface RenameFriendGroupParams {
|
|
535
|
+
oldName: string;
|
|
536
|
+
newName: string;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
interface IEventCenter {
|
|
540
|
+
addEvent(event: string, callback: func): void;
|
|
541
|
+
removeEvents(): void;
|
|
542
|
+
unbindIMEvents(): void;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
interface ITUITranslateService {
|
|
546
|
+
setI18next(i18next?: any): void;
|
|
547
|
+
provideLanguages(languages: object): void;
|
|
548
|
+
useI18n(language?: string): void;
|
|
549
|
+
changeLanguage(language: string): Promise<any>;
|
|
550
|
+
t(key: string): string;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
interface ITUIConversationService {
|
|
554
|
+
init(): void;
|
|
555
|
+
switchConversation(conversationID: string): Promise<any>;
|
|
556
|
+
getConversationList(): Promise<any>;
|
|
557
|
+
getConversationProfile(conversationID: string): Promise<any>;
|
|
558
|
+
deleteConversation(options: string | DeleteConversationParams): Promise<any>;
|
|
559
|
+
pinConversation(options: PinConversationParams): Promise<any>;
|
|
560
|
+
muteConversation(options: MuteConversationParams): Promise<any>;
|
|
561
|
+
setMessageRead(conversationID: string): Promise<any>;
|
|
562
|
+
clearHistoryMessage(conversationID: string): Promise<any>;
|
|
563
|
+
setConversationDraft(options: SetConversationDraftParams): Promise<any>;
|
|
564
|
+
markConversation(options: MarkConversationParams): Promise<any>;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
declare enum MountedList {
|
|
568
|
+
TUIStore = "TUIStore",
|
|
569
|
+
TUITranslate = "TUITranslate",
|
|
570
|
+
TUIConversation = "TUIConversation",
|
|
571
|
+
TUIChat = "TUIChat",
|
|
572
|
+
TUIGroup = "TUIGroup",
|
|
573
|
+
TUIUser = "TUIUser",
|
|
574
|
+
TUIFriend = "TUIFriend",
|
|
575
|
+
TUIReport = "TUIReport",
|
|
576
|
+
TUISearch = "TUISearch"
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
declare enum StoreName {
|
|
580
|
+
APP = "application",
|
|
581
|
+
CONV = "conversation",
|
|
582
|
+
CHAT = "chat",
|
|
583
|
+
GRP = "group",
|
|
584
|
+
USER = "user",
|
|
585
|
+
FRIEND = "friend",
|
|
586
|
+
SEARCH = "search",
|
|
587
|
+
CUSTOM = "custom"
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
type Task = Record<StoreName, Record<string, Map<(data?: unknown) => void, 1>>>;
|
|
591
|
+
interface IOptions {
|
|
592
|
+
[key: string]: (newData?: any) => void;
|
|
593
|
+
}
|
|
594
|
+
interface ITUIStore {
|
|
595
|
+
task: Task;
|
|
596
|
+
watch(storeName: StoreName, options: IOptions): void;
|
|
597
|
+
unwatch(storeName: StoreName, options: IOptions): void;
|
|
598
|
+
update(storeName: StoreName, key: string, data: any): void;
|
|
599
|
+
getData(storeName: StoreName, key: string): any;
|
|
600
|
+
getConversationModel(conversationID: string): IConversationModel;
|
|
601
|
+
getMessageModel(messageID: string): IMessageModel;
|
|
602
|
+
reset(storeName: StoreName, keyList?: string[], isNotificationNeeded?: boolean): void;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
declare class ChatEngine implements ITUIChatEngine {
|
|
606
|
+
static instance: ChatEngine;
|
|
607
|
+
isInited: boolean;
|
|
608
|
+
chat: ChatSDK;
|
|
609
|
+
EVENT: any;
|
|
610
|
+
TYPES: any;
|
|
611
|
+
eventCenter: IEventCenter;
|
|
612
|
+
TUIStore: ITUIStore;
|
|
613
|
+
TUITranslate: ITUITranslateService;
|
|
614
|
+
TUIConversation: ITUIConversationService;
|
|
615
|
+
TUIChat: ITUIChatService;
|
|
616
|
+
TUIGroup: ITUIGroupService;
|
|
617
|
+
TUIUser: ITUIUserService;
|
|
618
|
+
TUIFriend: ITUIFriendService;
|
|
619
|
+
TUIReport: ITUIReportService;
|
|
620
|
+
TUISearch: ITUISearchService;
|
|
621
|
+
private loginStatusPromise;
|
|
622
|
+
private userID;
|
|
623
|
+
constructor();
|
|
624
|
+
static getInstance(): ChatEngine;
|
|
625
|
+
mount(name: MountedList, instance: any): void;
|
|
626
|
+
login(options: LoginParams): Promise<unknown>;
|
|
627
|
+
logout(): Promise<void>;
|
|
628
|
+
isReady(): boolean;
|
|
629
|
+
setLogLevel(level: number): void;
|
|
630
|
+
destroy(): Promise<void>;
|
|
631
|
+
getMyUserID(): string;
|
|
632
|
+
private resetStore;
|
|
633
|
+
private initService;
|
|
634
|
+
private initOptionalServices;
|
|
635
|
+
private createChat;
|
|
636
|
+
private loginChat;
|
|
637
|
+
private onSDKReady;
|
|
638
|
+
private onSDKNotReady;
|
|
639
|
+
private checkCommercialAbility;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
declare class TUIBase {
|
|
643
|
+
getEngine(): ChatEngine;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
interface IMessageHandler {
|
|
647
|
+
handleTextMessage(message: Message): object;
|
|
648
|
+
handleFaceMessage(message: Message): object;
|
|
649
|
+
handleLocationMessage(message: Message): object;
|
|
650
|
+
handleImageMessage(message: Message): object;
|
|
651
|
+
handleAudioMessage(message: Message): object;
|
|
652
|
+
handleVideoMessage(message: Message): object;
|
|
653
|
+
handleFileMessage(message: Message): object;
|
|
654
|
+
handleCustomMessage(message: Message): object;
|
|
655
|
+
handleMergeMessage(message: Message): object;
|
|
656
|
+
handleGroupTipsMessage(message: Message): object;
|
|
657
|
+
handleGroupSystemMessage(message: Message): object;
|
|
658
|
+
handleCallKitSignaling(message: any): string | undefined;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
interface ITUIChatService extends TUIBase {
|
|
662
|
+
messageHandler: IMessageHandler;
|
|
663
|
+
init: () => void;
|
|
664
|
+
updateMessageList(messageList: Message[], type: string): void;
|
|
665
|
+
sendTextMessage(options: SendMessageParams, sendMessageOptions?: SendMessageOptions): Promise<any>;
|
|
666
|
+
sendTextAtMessage(options: SendMessageParams, sendMessageOptions?: SendMessageOptions): Promise<any>;
|
|
667
|
+
sendImageMessage(options: SendMessageParams, sendMessageOptions?: SendMessageOptions): Promise<any>;
|
|
668
|
+
sendAudioMessage(options: SendMessageParams, sendMessageOptions?: SendMessageOptions): Promise<any>;
|
|
669
|
+
sendVideoMessage(options: SendMessageParams, sendMessageOptions?: SendMessageOptions): Promise<any>;
|
|
670
|
+
sendFileMessage(options: SendMessageParams, sendMessageOptions?: SendMessageOptions): Promise<any>;
|
|
671
|
+
sendCustomMessage(options: SendMessageParams, sendMessageOptions?: SendMessageOptions): Promise<any>;
|
|
672
|
+
sendFaceMessage(message: SendMessageParams, sendMessageOptions?: SendMessageOptions): Promise<any>;
|
|
673
|
+
sendLocationMessage(options: SendMessageParams, sendMessageOptions?: SendMessageOptions): Promise<any>;
|
|
674
|
+
sendForwardMessage(conversationList: Conversation[] | IConversationModel[], messageList: Message[] | IMessageModel, sendForwardMessageOptions?: SendForwardMessageOptions): Promise<any>;
|
|
675
|
+
revokeMessage(message: Message): Promise<any>;
|
|
676
|
+
resendMessage(message: Message): Promise<any>;
|
|
677
|
+
deleteMessage(messageList: Message[]): Promise<any>;
|
|
678
|
+
setMessageExtensions(message: Message, extensions: object[]): Promise<any>;
|
|
679
|
+
getMessageExtensions(message: Message): Promise<any>;
|
|
680
|
+
deleteMessageExtensions(message: Message, keyList?: string[]): Promise<any>;
|
|
681
|
+
modifyMessage(message: Message): Promise<any>;
|
|
682
|
+
quoteMessage(message: Message): Message;
|
|
683
|
+
replyMessage(message: Message): Message;
|
|
684
|
+
enterTypingState(): void;
|
|
685
|
+
leaveTypingState(): void;
|
|
686
|
+
sendMessageReadReceipt(messageList: IMessageModel[]): Promise<any>;
|
|
687
|
+
getGroupMessageReadMemberList(options: GetGroupMessageReadParams): Promise<any>;
|
|
688
|
+
getMessageList(options?: GetMessageListParams): Promise<any>;
|
|
689
|
+
getMessageListHopping(options?: GetMessageListHoppingParams): Promise<any>;
|
|
690
|
+
downloadMergedMessages(message: any): Promise<any>;
|
|
691
|
+
setTranslationLanguage(language: string): void;
|
|
692
|
+
translateText(options: TranslateTextParams): Promise<any>;
|
|
693
|
+
searchCloudMessages(options: SearchCloudMessagesParams): Promise<any>;
|
|
694
|
+
addMessageReaction(message: IMessageModel, reactionID: string): Promise<any>;
|
|
695
|
+
removeMessageReaction(message: IMessageModel, reactionID: string): Promise<any>;
|
|
696
|
+
getMessageReactions(options: GetMessageReactionsParams): void;
|
|
697
|
+
getAllUserListOfMessageReaction(options: GetAllUserListOfMessageReactionParams): Promise<any>;
|
|
698
|
+
convertVoiceToText(options: ConvertVoiceToTextParams): Promise<any>;
|
|
699
|
+
clearHistoryMessage(conversationID: string): Promise<any>;
|
|
700
|
+
updateMessageInfo(options: Record<string, any>): void;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
interface ITUIGroupService {
|
|
704
|
+
init(): void;
|
|
705
|
+
switchGroup(groupID: string): void;
|
|
706
|
+
getGroupProfile(options: GetGroupProfileParams): Promise<any>;
|
|
707
|
+
updateGroupProfile(options: UpdateGroupParams): Promise<any>;
|
|
708
|
+
createGroup(options: CreateGroupParams): Promise<any>;
|
|
709
|
+
dismissGroup(groupID: string): Promise<any>;
|
|
710
|
+
searchGroupByID(groupID: string): Promise<any>;
|
|
711
|
+
joinGroup(options: JoinGroupParams): Promise<any>;
|
|
712
|
+
quitGroup(groupID: string): Promise<any>;
|
|
713
|
+
getGroupApplicationList(): Promise<any>;
|
|
714
|
+
handleGroupApplication(options: handleGroupApplicationParams): Promise<any>;
|
|
715
|
+
getGroupOnlineMemberCount(groupID: string): Promise<any>;
|
|
716
|
+
changeGroupOwner(options: ChangGroupOwnerParams): Promise<any>;
|
|
717
|
+
initGroupAttributes(groupAttributes: GroupAttrParams): Promise<any>;
|
|
718
|
+
setGroupAttributes(groupAttributes: GroupAttrParams): Promise<any>;
|
|
719
|
+
deleteGroupAttributes(options: KeyListParams): Promise<any>;
|
|
720
|
+
getGroupAttributes(options: KeyListParams): Promise<any>;
|
|
721
|
+
setGroupCounters(counters: SetCountersParams): Promise<any>;
|
|
722
|
+
increaseGroupCounter(options: CountersParams): Promise<any>;
|
|
723
|
+
decreaseGroupCounter(options: CountersParams): Promise<any>;
|
|
724
|
+
getGroupCounters(options: KeyListParams): Promise<any>;
|
|
725
|
+
getGroupMemberList(options: GetMemberListParams): Promise<any>;
|
|
726
|
+
getGroupMemberProfile(options: GetMemberProfileParams): Promise<any>;
|
|
727
|
+
addGroupMember(options: AddMemberParams): Promise<any>;
|
|
728
|
+
deleteGroupMember(options: DeleteMemberParams): Promise<any>;
|
|
729
|
+
setGroupMemberMuteTime(options: SetMemberMuteParams): Promise<any>;
|
|
730
|
+
setGroupMemberRole(options: SetMemberRoleParams): Promise<any>;
|
|
731
|
+
setGroupMemberNameCard(options: SetMemberNameCardParams): Promise<any>;
|
|
732
|
+
setGroupMemberCustomField(options: SetMemberCustomFiledParams): Promise<any>;
|
|
733
|
+
markGroupMemberList(options: MarkMemberParams): Promise<any>;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
interface ITUIUserService extends TUIBase {
|
|
737
|
+
init(): void;
|
|
738
|
+
switchUserStatus(options: SwitchUserStatusParams): void;
|
|
739
|
+
switchMessageReadStatus(displayMessageReadReceipt: boolean): void;
|
|
740
|
+
getUserProfile(options?: UserIDListParams): Promise<any>;
|
|
741
|
+
updateMyProfile(options: UpdateMyProfileParams): Promise<any>;
|
|
742
|
+
addToBlacklist(options: UserIDListParams): Promise<any>;
|
|
743
|
+
removeFromBlacklist(options: UserIDListParams): Promise<any>;
|
|
744
|
+
getUserStatus(options: UserIDListParams): Promise<any>;
|
|
745
|
+
subscribeUserStatus(options: UserIDListParams): Promise<any> | void;
|
|
746
|
+
unsubscribeUserStatus(options?: UserIDListParams): Promise<any>;
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
interface ITUIFriendService {
|
|
750
|
+
init(): void;
|
|
751
|
+
getFriendList(): Promise<any>;
|
|
752
|
+
getFriendRemark(userIDList: string[]): Record<string, any>;
|
|
753
|
+
addFriend(options: AddFriendParams): Promise<any>;
|
|
754
|
+
deleteFriend(options: DeleteFriendParams): Promise<any>;
|
|
755
|
+
checkFriend(options: CheckFriendParams): Promise<any>;
|
|
756
|
+
getFriendProfile(options: GetFriendProfileParams): Promise<any>;
|
|
757
|
+
updateFriend(options: UpdateFriendParams): Promise<any>;
|
|
758
|
+
acceptFriendApplication(options: AcceptFriendApplicationParams): Promise<any>;
|
|
759
|
+
refuseFriendApplication(userID: string): Promise<any>;
|
|
760
|
+
deleteFriendApplication(options: DeleteFriendApplicationParams): Promise<any>;
|
|
761
|
+
setFriendApplicationRead(): Promise<any>;
|
|
762
|
+
createFriendGroup(options: FriendGroupParams): Promise<any>;
|
|
763
|
+
deleteFriendGroup(name: string): Promise<any>;
|
|
764
|
+
addToFriendGroup(options: FriendGroupParams): Promise<any>;
|
|
765
|
+
removeFromFriendGroup(options: FriendGroupParams): Promise<any>;
|
|
766
|
+
renameFriendGroup(options: RenameFriendGroupParams): Promise<any>;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
interface ITUIReportService {
|
|
770
|
+
reportFeature(code: number, feature?: string): void;
|
|
771
|
+
}
|
|
772
|
+
|
|
773
|
+
interface ITUISearchService {
|
|
774
|
+
searchCloudMessages(options: SearchCloudMessagesParams): Promise<any>;
|
|
775
|
+
searchCloudUsers(options: SearchCloudUsersParams): Promise<any>;
|
|
776
|
+
searchCloudGroups(options: SearchCloudGroupsParams): Promise<any>;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
interface ITUIChatEngine {
|
|
780
|
+
isInited: boolean;
|
|
781
|
+
chat: ChatSDK;
|
|
782
|
+
EVENT: any;
|
|
783
|
+
TYPES: any;
|
|
784
|
+
eventCenter: IEventCenter;
|
|
785
|
+
TUIStore: ITUIStore;
|
|
786
|
+
TUITranslate: any;
|
|
787
|
+
TUIConversation: ITUIConversationService;
|
|
788
|
+
TUIChat: ITUIChatService;
|
|
789
|
+
TUIGroup: ITUIGroupService;
|
|
790
|
+
TUIUser: ITUIUserService;
|
|
791
|
+
login(options: LoginParams): Promise<any>;
|
|
792
|
+
logout(): Promise<any>;
|
|
793
|
+
isReady(): boolean;
|
|
794
|
+
destroy(): Promise<any>;
|
|
795
|
+
setLogLevel(level: number): void;
|
|
796
|
+
mount(name: string, instance: any): void;
|
|
797
|
+
getMyUserID(): string;
|
|
798
|
+
}
|
|
799
|
+
|
|
800
|
+
interface ITUIGlobal {
|
|
801
|
+
global: any;
|
|
802
|
+
isOfficial: boolean;
|
|
803
|
+
[key: string]: any;
|
|
804
|
+
initOfficial(isOfficial: boolean): void;
|
|
805
|
+
getPlatform(): string;
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
declare const TUIChatEngine: ITUIChatEngine;
|
|
809
|
+
declare const tuiGlobal: ITUIGlobal;
|
|
810
|
+
declare const tuiStore: ITUIStore;
|
|
811
|
+
declare const tuiTranslate: ITUITranslateService;
|
|
812
|
+
declare const tuiConversation: ITUIConversationService;
|
|
813
|
+
declare const tuiUser: ITUIUserService;
|
|
814
|
+
declare const tuiChat: ITUIChatService;
|
|
815
|
+
declare const tuiGroup: ITUIGroupService;
|
|
816
|
+
declare const tuiFriend: ITUIFriendService;
|
|
817
|
+
declare const tuiReport: ITUIReportService;
|
|
818
|
+
declare const tuiSearch: ITUISearchService;
|
|
819
|
+
|
|
820
|
+
export { AcceptFriendApplicationParams, AddFriendParams, AddMemberParams, ChangGroupOwnerParams, CheckFriendParams, ConvertVoiceToTextParams, CountersParams, CreateGroupParams, DeleteConversationParams, DeleteFriendApplicationParams, DeleteFriendParams, DeleteMemberParams, ForwardMessageParams, Friend, FriendApplication, FriendGroup, FriendGroupParams, GetAllUserListOfMessageReactionParams, GetFriendProfileParams, GetGroupMessageReadParams, GetGroupProfileParams, GetMemberListParams, GetMemberProfileParams, GetMessageListHoppingParams, GetMessageListParams, GetMessageReactionsParams, GroupAttrParams, GroupServiceBasicParams, GroupType, IConversationModel, IGroupModel, IMessageModel, IResultMap, ISearchCloudGroupsResultItem, ISearchCloudMessagesResultItem, ISearchCloudUsersResultItem, ISearchParamsMap, ISearchResult, ISearchType, JoinGroupParams, KeyListParams, LoginParams, MarkConversationParams, MarkMemberParams, MessageControlInfo, MessageType, ModifyMessageParams, MuteConversationParams, OfflinePushInfo, PinConversationParams, ReactionInfo, RenameFriendGroupParams, SEARCH_TYPE, SearchCloudGroupMembersParams, SearchCloudGroupsParams, SearchCloudMessagesParams, SearchCloudUsersParams, SendForwardMessageMergeInfo, SendForwardMessageOptions, SendMessageOptions, SendMessageParams, SetConversationDraftParams, SetCountersParams, SetMemberCustomFiledParams, SetMemberMuteParams, SetMemberNameCardParams, SetMemberRoleParams, StoreName, SwitchUserStatusParams, TUIChatEngine, tuiChat as TUIChatService, tuiConversation as TUIConversationService, tuiFriend as TUIFriendService, tuiGlobal as TUIGlobal, tuiGroup as TUIGroupService, tuiReport as TUIReportService, tuiSearch as TUISearchService, tuiStore as TUIStore, tuiTranslate as TUITranslateService, tuiUser as TUIUserService, TranslateTextParams, UpdateFriendParams, UpdateGroupParams, UpdateMyProfileParams, UserIDListParams, TUIChatEngine as default, func, handleGroupApplicationParams };
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"@tencentcloud/lite-chat/basic";import t from"@tencentcloud/lite-chat/plugins/conversation";import s from"@tencentcloud/lite-chat/plugins/group";import i from"@tencentcloud/lite-chat/plugins/avchatroom";import n from"@tencentcloud/lite-chat/plugins/message-enhancer";import a from"@tencentcloud/lite-chat/plugins/rich-media-message";import r from"@tencentcloud/lite-chat/plugins/cloud-search";import o from"@tencentcloud/lite-chat/plugins/signaling";import g from"@tencentcloud/lite-chat/plugins/friend";function c(e,t){var s={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(s[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(i=Object.getOwnPropertySymbols(e);n<i.length;n++)t.indexOf(i[n])<0&&Object.prototype.propertyIsEnumerable.call(e,i[n])&&(s[i[n]]=e[i[n]])}return s}function h(e,t,s,i){return new(s||(s=Promise))(function(n,a){function r(e){try{g(i.next(e))}catch(e){a(e)}}function o(e){try{g(i.throw(e))}catch(e){a(e)}}function g(e){var t;e.done?n(e.value):(t=e.value,t instanceof s?t:new s(function(e){e(t)})).then(r,o)}g((i=i.apply(e,t||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class u{constructor(e){return u.instance||(u.instance=this,this.engine=e,this.events={},this.bindIMEvents()),u.instance}addEvent(e,t){this.events[e]||(this.events[e]=new Map),this.events[e].set(t,1)}removeEvents(){Object.keys(this.events).forEach(e=>{this.events[e].clear()}),this.events={}}dispatch(e,t){if(this.events[e])for(const s of this.events[e].keys())s.call(this,t)}bindIMEvents(){this.engine.chat.on(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.on(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.on(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.on(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.on(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated,this),this.engine.chat.on(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.on(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.on(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this),this.engine.chat.on(this.engine.EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated,this),this.engine.chat.on(this.engine.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_LIST_UPDATED,this.onGroupListUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,this.onGroupAttributesUpdated,this),this.engine.chat.on(this.engine.EVENT.GROUP_COUNTER_UPDATED,this.onGroupCounterUpdated,this),this.engine.chat.on(this.engine.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated,this),this.engine.chat.on(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated,this),this.engine.chat.on(this.engine.EVENT.FRIEND_GROUP_LIST_UPDATED,this.onFriendGroupListUpdated,this)}unbindIMEvents(){this.engine.chat.off(this.engine.EVENT.SDK_READY,this.onSDKReady,this),this.engine.chat.off(this.engine.EVENT.SDK_NOT_READY,this.onSDKNotReady,this),this.engine.chat.off(this.engine.EVENT.KICKED_OUT,this.onKickedOut,this),this.engine.chat.off(this.engine.EVENT.NET_STATE_CHANGE,this.onNetStateChange,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_RECEIVED,this.onReceiveMessage,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_MODIFIED,this.onMessageModified,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_REVOKED,this.onMessageRevoked,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,this.onMessageReadReceiptReceived,this),this.engine.chat.off(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated,this),this.engine.chat.off(this.engine.EVENT.CONVERSATION_LIST_UPDATED,this.onConversationListUpdated,this),this.engine.chat.off(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,this.onTotalMessageCountUpdated,this),this.engine.chat.off(this.engine.EVENT.PROFILE_UPDATED,this.onProfileUpdated,this),this.engine.chat.off(this.engine.EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated,this),this.engine.chat.off(this.engine.EVENT.USER_STATUS_UPDATED,this.onUserStatusUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_LIST_UPDATED,this.onGroupListUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,this.onGroupAttributesUpdated,this),this.engine.chat.off(this.engine.EVENT.GROUP_COUNTER_UPDATED,this.onGroupCounterUpdated,this),this.engine.chat.off(this.engine.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated,this),this.engine.chat.off(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated,this),this.engine.chat.off(this.engine.EVENT.FRIEND_GROUP_LIST_UPDATED,this.onFriendGroupListUpdated,this),u.instance=null}onSDKReady(e){this.dispatch(this.engine.EVENT.SDK_READY,e.data)}onSDKNotReady(e){this.dispatch(this.engine.EVENT.SDK_NOT_READY,e.data)}onKickedOut(e){this.dispatch(this.engine.EVENT.KICKED_OUT,e.data)}onNetStateChange(e){this.dispatch(this.engine.EVENT.NET_STATE_CHANGE,e.data)}onReceiveMessage(e){this.dispatch(this.engine.EVENT.MESSAGE_RECEIVED,e.data)}onMessageModified(e){this.dispatch(this.engine.EVENT.MESSAGE_MODIFIED,e.data)}onMessageRevoked(e){this.dispatch(this.engine.EVENT.MESSAGE_REVOKED,e.data)}onMessageReadByPeer(e){this.dispatch(this.engine.EVENT.MESSAGE_READ_BY_PEER,e.data)}onMessageReadReceiptReceived(e){this.dispatch(this.engine.EVENT.MESSAGE_READ_RECEIPT_RECEIVED,e.data)}onMessageReactionsUpdated(e){this.dispatch(this.engine.EVENT.MESSAGE_REACTIONS_UPDATED,e.data)}onConversationListUpdated(e){this.dispatch(this.engine.EVENT.CONVERSATION_LIST_UPDATED,e.data)}onTotalMessageCountUpdated(e){this.dispatch(this.engine.EVENT.TOTAL_UNREAD_MESSAGE_COUNT_UPDATED,e.data)}onProfileUpdated(e){this.dispatch(this.engine.EVENT.PROFILE_UPDATED,e.data)}onBlacklistUpdated(e){this.dispatch(this.engine.EVENT.BLACKLIST_UPDATED,e.data)}onUserStatusUpdated(e){this.dispatch(this.engine.EVENT.USER_STATUS_UPDATED,e.data)}onGroupListUpdated(e){this.dispatch(this.engine.EVENT.GROUP_LIST_UPDATED,e.data)}onGroupAttributesUpdated(e){this.dispatch(this.engine.EVENT.GROUP_ATTRIBUTES_UPDATED,e.data)}onGroupCounterUpdated(e){this.dispatch(this.engine.EVENT.GROUP_COUNTER_UPDATED,e.data)}onFriendListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_LIST_UPDATED,e.data)}onFriendApplicationListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_APPLICATION_LIST_UPDATED,e.data)}onFriendGroupListUpdated(e){this.dispatch(this.engine.EVENT.FRIEND_GROUP_LIST_UPDATED,e.data)}}var d,l,p,T,E,I,m,S,U;!function(e){e.TUIStore="TUIStore",e.TUITranslate="TUITranslate",e.TUIConversation="TUIConversation",e.TUIChat="TUIChat",e.TUIGroup="TUIGroup",e.TUIUser="TUIUser",e.TUIFriend="TUIFriend",e.TUIReport="TUIReport",e.TUISearch="TUISearch"}(d||(d={})),function(e){e.APP="application",e.CONV="conversation",e.CHAT="chat",e.GRP="group",e.USER="user",e.FRIEND="friend",e.SEARCH="search",e.CUSTOM="custom"}(l||(l={})),function(e){e[e.UNSUB_USER=-1]="UNSUB_USER"}(p||(p={})),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"}(T||(T={})),function(e){e.ADD="add",e.REMOVE="remove"}(E||(E={})),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"}(I||(I={})),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"}(m||(m={})),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,消息不存在."}(S||(S={})),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 不匹配."}(U||(U={}));const M={logout:1,destroy:1},f={deleteConversation:1,pinConversation:1,muteConversation:1,switchConversation:1,getConversationProfile:1,clearHistoryMessage:1,setMessageRead:1,markConversation:1},_={modifyMessage:1,revokeMessage:1,resendMessage:1,deleteMessage:1,quoteMessage:1,replyMessage:1,setMessageExtensions:1,deleteMessageExtensions:1,getMessageExtensions:1,sendTextMessage:1,sendTextAtMessage:1,sendImageMessage:1,sendAudioMessage:1,sendVideoMessage:1,sendFileMessage:1,sendCustomMessage:1,sendFaceMessage:1,sendLocationMessage:1,sendForwardMessage:1,enterTypingState:1,leaveTypingState:1,sendMessageReadReceipt:1,getGroupMessageReadMemberList:1,getMessageList:1,downloadMergedMessages:1,setTranslationLanguage:1,translateText:1,searchCloudMessages:1,addMessageReaction:1,removeMessageReaction:1,getMessageReactions:1,getAllUserListOfMessageReaction:1},C={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},v={switchUserStatus:1,switchMessageReadStatus:1,getUserProfile:1,updateMyProfile:1,addToBlacklist:1,removeFromBlacklist:1},D={getFriendList:1,addFriend:1,deleteFriend:1,checkFriend:1,getFriendProfile:1,updateFriend:1,acceptFriendApplication:1,refuseFriendApplication:1,deleteFriendApplication:1,setFriendApplicationRead:1},R=function(e){return void 0===e},y=function(e){return e.startsWith("_")},P=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},A=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},G="https://web.sdk.qcloud.com/component/TUIKit/assets/avatar_16.png",b="https://web.sdk.qcloud.com/im/demo/TUIkit/web/img/constomer.png",L="https://web.sdk.qcloud.com/component/TUIKit/assets/group_avatar.png",N="https://web.sdk.qcloud.com/im/assets/emoji-plugin/",j="https://web.sdk.qcloud.com/im/assets/face-elem/",k="https://map.qq.com/?type=marker&isopeninfowin=1&markertype=1&",x="https://apis.map.qq.com/ws/staticmap/v2/?",w={"[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"},$={"[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]":"[赞]"},V={enabledMessageReadReceipt:Math.pow(2,5),enabledEmojiPlugin:Math.pow(2,48),enabledOnlineStatus:Math.pow(2,7),enabledCustomerServicePlugin:Math.pow(2,40),enabledTranslationPlugin:Math.pow(2,38),enabledVoiceToText:Math.pow(2,39)},F=["messageList","conversationList","newMessageList"],H=["translateTextInfo","voiceToTextInfo"],Y="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&("mac"===wx.getSystemInfoSync().platform||"windows"===wx.getSystemInfoSync().platform),B="undefined"!=typeof wx&&"function"==typeof wx.getSystemInfoSync&&Boolean(wx.getSystemInfoSync().fontSizeSetting)||Y,K="undefined"!=typeof qq&&"function"==typeof qq.getSystemInfoSync&&Boolean(qq.getSystemInfoSync().fontSizeSetting),q="undefined"!=typeof tt&&"function"==typeof tt.getSystemInfoSync&&Boolean(tt.getSystemInfoSync().fontSizeSetting),z="undefined"!=typeof swan&&"function"==typeof swan.getSystemInfoSync&&Boolean(swan.getSystemInfoSync().fontSizeSetting),W="undefined"!=typeof my&&"function"==typeof my.getSystemInfoSync&&Boolean(my.getSystemInfoSync().fontSizeSetting),J="undefined"!=typeof jd&&"function"==typeof jd.getSystemInfoSync,X="undefined"!=typeof uni&&"undefined"==typeof window,Z=B||K||q||z||W||J||X,Q=("undefined"!=typeof uni||"undefined"!=typeof window)&&!Z,ee=K?qq:q?tt:z?swan:W?my:B?wx:X?uni:J?jd:Q?window:{},te=Q&&window&&window.navigator&&window.navigator.userAgent||"",se=/Android/i.test(te),ie=/(?:Windows Phone)/.test(te),ne=/(?:SymbianOS)/.test(te),ae=/iPad/i.test(te)||/iPhone/i.test(te)||/iPod/i.test(te),re=se||ie||ne||ae,oe=Q&&!re;class ge{constructor(){this.global=ee,this.isOfficial=!1}static getInstance(){return ge.instance||(ge.instance=new ge),ge.instance}initOfficial(e){this.isOfficial=e}getPlatform(){let e="";return oe?e="pc":re?e="h5":B?e="wechat":X&&!B&&(e="app"),e}}const ce="group-module",he="relationship-module";class ue{constructor(){this.EVENT=e.EVENT,this.TYPES=e.TYPES,this.loginStatusPromise=new Map,this.userID="",this.isInited=!1}static getInstance(){return ue.instance||(ue.instance=new ue),ee.__$RTC_CHAT__=[t,s,i,n,a,r,o,g],ue.instance}mount(e,t){this[e]=t}login(t){const{chat:s,SDKAppID:i,userID:n}=t,a=1400187352===i||1400188366===i;return this.createChat(t),this.userID=n,ge.getInstance().initOfficial(a),this.TUIStore.update(l.APP,"isOfficial",a),this.TUIStore.update(l.APP,"SDKVersion",e.VERSION),this.eventCenter=new u(this),this.eventCenter.removeEvents(),this.resetStore(),this.initService(),s&&s.isReady()?(console.log("TUIChatEngine.login ok, from TUICore."),this.TUIUser.getUserProfile(),this.checkCommercialAbility(),Promise.resolve({})):(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.resetStore(),this.chat.logout()}isReady(){var e;return(null===(e=this.chat)||void 0===e?void 0:e.isReady())||!1}setLogLevel(e){this.chat?this.chat.setLogLevel(e):console.warn("TUIChatEngine 初始化未完成,请确认 TUIChatEngine.login 接口调用是否正常。")}destroy(){return this.eventCenter.unbindIMEvents(),this.isInited=!1,this.resetStore(),this.chat.destroy()}getMyUserID(){return this.userID}resetStore(){this.TUIStore.reset(l.CHAT),this.TUIStore.reset(l.CONV),this.TUIStore.reset(l.GRP),this.TUIStore.reset(l.USER),this.TUIStore.reset(l.SEARCH),this.TUIStore.reset(l.FRIEND),this.TUIStore.reset(l.CUSTOM),console.log("TUIChatEngine.resetStore ok.")}initService(){this.TUIChat.init(),this.TUIConversation.init(),this.TUIUser.init(),this.initOptionalServices(),this.isInited=!0,console.log("TUIChatEngine.initService ok.")}initOptionalServices(){const t=e.VERSION.split(".");t[0]>3||3===t[0]&&t[1]>=3&&t[2]>0?(!0===this.chat.callExperimentalAPI("canIUseModule",[ce])&&this.TUIGroup.init(),!0===this.chat.callExperimentalAPI("canIUseModule",[he])&&this.TUIFriend.init()):(this.TUIGroup.init(),this.TUIFriend.init())}createChat(h){const{chat:u}=h,d=c(h,["chat"]);R(u)?(this.chat=e.create(Object.assign(Object.assign({},d),{scene:"engine-lite"})),this.chat.use([t,s,i,n,a,r,o,g])):this.chat=u}loginChat(e){const{userID:t,userSig:s}=e;return new Promise((e,i)=>{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:i,imResponse:t})}).catch(e=>{i(e)})})}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"),this.resetStore()}checkCommercialAbility(){Object.keys(V).forEach(e=>{const t=V[e];this.chat.callExperimentalAPI("isCommercialAbilityEnabled",t).then(t=>{const{enabled:s=!1}=t.data;this.TUIStore.update(l.APP,e,s)})})}}class de{constructor(){this.defaultStore={enabledMessageReadReceipt:!1,enabledEmojiPlugin:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,enableAutoMessageRead:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}},this.store={enabledEmojiPlugin:!1,enabledMessageReadReceipt:!1,enabledOnlineStatus:!1,enabledCustomerServicePlugin:!1,enabledTranslationPlugin:!1,enabledVoiceToText:!1,enableTyping:!0,enableConversationDraft:!0,enableAutoMessageRead:!0,isOfficial:!1,SDKVersion:"3.0.0",tasks:{sendMessage:!1,revokeMessage:!1,modifyNickName:!1,groupChat:!1,muteGroup:!1,dismissGroup:!1,call:!1,searchCloudMessage:!1,customerService:!1,translateTextMessage:!1}}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]}),{}))}}class le{constructor(){this.defaultStore={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"},this.store={userProfile:{},displayOnlineStatus:!1,displayMessageReadReceipt:!0,userStatusList:new Map,kickedOut:"",netStateChange:"",userBlacklist:[],targetLanguage:"zh"}}update(e,t){if("userStatusList"===e)this.updateUserStatusList(t);else this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((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:i=""}=e;s===p.UNSUB_USER?this.store.userStatusList.delete(t):this.store.userStatusList.set(t,{statusType:s,customStatus:i})}):this.store.userStatusList.clear()}}class pe{getEngine(){return ue.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},Ee={"[Image]":"[图片]","[Voice]":"[语音]","[Video]":"[视频]","[File]":"[文件]","[Location]":"[位置]","[Animated Sticker]":"[动画表情]","[Custom Messages]":"[自定义消息]","[Group Notification]":"[群提示消息]","[Group System Message]":"[群系统消息]","[Chat Record]":"[聊天记录]","[Chat History]":"[聊天记录]"};class Ie extends pe{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){Object.keys(e).forEach(t=>{y(t)||(this[t]=e[t])})}updateOperationType(e){this.operationType=e}getConversation(){return this._conversation}deleteConversation(e=!0){return this.getEngine().TUIConversation.deleteConversation({conversationIDList:[this.conversationID],clearHistoryMessage:e})}pinConversation(){return this.getEngine().TUIConversation.pinConversation({conversationID:this.conversationID,isPinned:!this.isPinned})}muteConversation(){const e=this.getEngine(),t={messageRemindType:!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)}setMessageRead(){return this.getEngine().TUIConversation.setMessageRead(this.conversationID)}getAvatar(){var e,t,s,i,n,a;const r=this.getEngine();let o="";switch(this.type){case r.TYPES.CONV_C2C:o=P(null===(e=this.userProfile)||void 0===e?void 0:e.avatar)?null===(t=this.userProfile)||void 0===t?void 0:t.avatar:G;break;case r.TYPES.CONV_GROUP:o=P(null===(s=this.groupProfile)||void 0===s?void 0:s.avatar)?null===(i=this.groupProfile)||void 0===i?void 0:i.avatar:b;break;case r.TYPES.CONV_SYSTEM:o=P(null===(n=this.groupProfile)||void 0===n?void 0:n.avatar)?null===(a=this.groupProfile)||void 0===a?void 0:a.avatar:L}return o}getShowName(){var e,t,s,i;const n=this.getEngine();let a="";switch(this.type){case n.TYPES.CONV_C2C:a=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 n.TYPES.CONV_GROUP:a=(null===(s=this.groupProfile)||void 0===s?void 0:s.name)||(null===(i=this.groupProfile)||void 0===i?void 0:i.groupID)||"";break;case n.TYPES.CONV_SYSTEM:a=n.TUITranslate.t("系统通知")}return a}getGroupAtInfo(){const e=this.getEngine(),t=e.TUITranslate.t.bind(e.TUITranslate),s=[`[${t("TUIConversation.有人@我")}]`,`[${t("TUIConversation.@所有人")}]`,`[${t("TUIConversation.@所有人")}][${t("TUIConversation.有人@我")}]`];let i="";for(let e=0;e<this.groupAtInfoList.length;e++)this.groupAtInfoList[e].atTypeArray[0]&&this.unreadCount>0&&(i=s[this.groupAtInfoList[e].atTypeArray[0]-1]);return i}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,i=36e5,n=24*i,a=7*n,r=(new Date).getTime()-e;let o="";if(r<0)return o;const g=r/s,c=r/i,h=r/n,u=r/a;if(u>=1&&u<=4)o=` ${parseInt(`${u}`,10)} ${t("time.周")}${t("time.前")}`;else if(h>=1&&h<=6)o=` ${parseInt(`${h}`,10)} ${t("time.天")}${t("time.前")}`;else if(c>=1&&c<=23)o=` ${parseInt(`${c}`,10)} ${t("time.小时")}${t("time.前")}`;else if(g>=1&&g<=59)o=` ${parseInt(`${g}`,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;if(this.draftText){return O(this.draftText).abstract}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 i=this._conversation,{lastMessage:n}=this;let a="",r="";const o=i.unreadCount>0&&i.messageRemindType===t.TYPES.MSG_REMIND_ACPT_NOT_NOTE?`[${i.unreadCount>99?"99+":i.unreadCount}${s("TUIConversation.条")}]`:"";if(i.type===t.TYPES.CONV_GROUP)if(n.fromAccount===t.getMyUserID())a=s("TUIConversation.我");else{const e=n.fromAccount;a=t.TUIFriend.getFriendRemark([e])[e]||n.nameCard||n.nick||e}if(n.type===t.TYPES.MSG_TEXT)r=this.decodeTextMessage(n.payload.text);else if(n.type===t.TYPES.MSG_CUSTOM){const i=O(null===(e=null==n?void 0:n.payload)||void 0===e?void 0:e.data);if(1===(null==i?void 0:i.businessID))return r=t.TUIChat.messageHandler.handleCallKitSignaling(n),r;const a=n.messageForShow;r=Ee[a]?s(`TUIChat.${Ee[a]}`):a}else{const e=n.messageForShow;r=Ee[e]?s(`TUIChat.${Ee[e]}`):e}return n.isRevoked&&(r=s("TUIChat.撤回了一条消息")),i.type===t.TYPES.CONV_GROUP&&n.type===t.TYPES.MSG_GRP_TIP?r:`${o}${a?`${a}:`:""}${r}`}decodeTextMessage(e){if(Te(e))return e;const t=/(\[.+?\])/g;let s=e;if(t.test(e)){const i=this.getEngine(),n=i.TUITranslate.t.bind(i.TUITranslate);s=e.replace(t,e=>{const t=n(`Emoji.${e}`);return B||!t||t.startsWith("Emoji.")?$[e]||e:t})}return s}}class me{constructor(){this.defaultStore={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map},this.store={currentConversationID:"",totalUnreadCount:0,conversationList:[],currentConversation:null,operationTypeMap:new Map}}update(e,t){switch(e){case"conversationList":this.updateConversationList(t);break;case"operationTypeMap":this.updateOperationTypeMap(t);break;default:this.store[e]=t}}getData(e){return this.store[e]}getModel(e){return this.store.conversationList.find(t=>t.conversationID===e)}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]}),{}))}updateConversationList(e){const t=[];e.forEach(e=>{let s=e;e instanceof Ie?s.updateProperties(e):s=new Ie(e);const i=this.getOperationType(e);s.updateOperationType(i),t.push(s)}),this.store.conversationList=t}updateOperationTypeMap(e){const{conversationID:t,operationType:s=0}=e;this.store.operationTypeMap.set(t,s)}getOperationType(e){const{conversationID:t}=e;return this.store.operationTypeMap.get(t)||0}}class Se extends pe{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:m.MISMATCH_TYPE_AND_PAYLOAD,message:U.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:R(this._signalingInfo)?(this._signalingInfo=this.getEngine().chat.getSignalingInfo(this._message),this._signalingInfo):this._signalingInfo}getMessageContent(){const e=this.messageHandlers[this.type];if(R(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 Ue{constructor(){this.defaultStore={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}},this.store={messageList:[],isCompleted:!1,nextReqMessageID:"",quoteMessage:{},newMessageList:[],typingStatus:!1,messageSource:void 0,translateTextInfo:void 0,voiceToTextInfo:void 0,userInfo:{}}}update(e,t){switch(e){case"messageList":this.updateMessageList(t);break;case"translateTextInfo":this.updateTranslateTextInfo(t);break;case"voiceToTextInfo":this.updateVoiceToTextInfo(t);break;default:this.store[e]=t}}getData(e){return this.store[e]}getModel(e){return this.store.messageList.find(t=>t.ID===e)}reset(e=[]){const t=e.filter(e=>!H.includes(e));this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),null==t?void 0:t.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]}),{}))}updateMessageList(e){const t=[];e.forEach(e=>{let s=e;e instanceof Se||(s=this.getModel(e.ID),s?s.updateProperties(e):s=new Se(e)),t.push(s)}),this.store.messageList=t}updateTranslateTextInfo(e){this.updateBykey("translateTextInfo",e)}updateVoiceToTextInfo(e){this.updateBykey("voiceToTextInfo",e)}updateBykey(e,t){const{conversationID:s,messageID:i,visible:n=!1}=t;this.store[e]||(this.store[e]=new Map),this.store[e].has(s)||this.store[e].set(s,[]);const a=this.store[e].get(s)||[];let r=!0;for(let e=0;e<a.length;e++)if(a[e].messageID===i){a[e].visible=n,r=!1;break}r&&a.push({messageID:i,visible:n}),this.store[e].set(s,a)}}class Me{constructor(e){this.groupAttributes={},this.groupCounters={},this.initProxy(e)}initProxy(e){Object.keys(e).forEach(t=>{y(t)||(this[t]=e[t])})}}class fe{constructor(){this.defaultStore={currentGroupID:"",currentGroup:{},currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[],isCompleted:!1,offset:0},this.store={currentGroupID:"",currentGroup:void 0,currentGroupAttributes:{},currentGroupCounters:{},currentGroupMemberList:[],groupList:[],groupSystemNoticeList:[],isCompleted:!1,offset:0}}update(e,t){switch(e){case"groupList":this.updateGroupList(t);break;case"currentGroup":this.store.currentGroup=t instanceof Me?t:new Me(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=[]){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 Me?e:new Me(e))}}class _e{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,friendGroupList:[]},this.store={friendList:[],friendApplicationList:[],friendApplicationUnreadCount:0,friendGroupList:[]}}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),e.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]}),{}))}}class ve{constructor(){this.defaultStore={searchMessagesResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchChatMessagesResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchUserResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchGroupResult:{resultList:[],hasMore:!1,cursor:"",params:void 0,totalCount:0},searchMessageParams:{},searchChatMessageParams:{},searchUserParams:{},searchGroupParams:{},error:null},this.store=this.defaultStore}update(e,t){this.store[e]=t}getData(e){return this.store[e]}reset(e=[]){this.store=Object.assign(Object.assign(Object.assign({},this.defaultStore),this.store),null==e?void 0:e.reduce((e,t)=>Object.assign(Object.assign({},e),{[t]:this.defaultStore[t]}),{}))}}class De{constructor(){this.storeMap={[l.APP]:new de,[l.USER]:new le,[l.CONV]:new me,[l.CHAT]:new Ue,[l.GRP]:new fe,[l.FRIEND]:new Ce,[l.SEARCH]:new ve},this.task={}}static getInstance(){return De.instance||(De.instance=new De),De.instance}watch(e,t){this.task[e]||(this.task[e]={});const s=this.task[e];Object.keys(t).forEach(i=>{const n=t[i];s[i]||(s[i]=new Map),s[i].set(n,1),this.notifyOnWatch(e,i,n)})}unwatch(e,t){if(!this.task[e])return;const s=this.task[e];Object.keys(t).forEach(e=>{var i;null===(i=s[e])||void 0===i||i.delete(t[e])})}update(e,t,s){var i;e!==l.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new _e),null===(i=this.storeMap[e])||void 0===i||i.update(t,s),this.notify(e,t)}getData(e,t){var s;return e!==l.CUSTOM||this.storeMap[e]||(this.storeMap[e]=new _e),null===(s=this.storeMap[e])||void 0===s?void 0:s.getData(t)}getConversationModel(e){var t;return null===(t=this.storeMap[l.CONV])||void 0===t?void 0:t.getModel(e)}getMessageModel(e){var t;return null===(t=this.storeMap[l.CHAT])||void 0===t?void 0:t.getModel(e)}reset(e,t=[],s=!1){if(e in this.storeMap){const i=this.storeMap[e];0===t.length&&(t=Object.keys(null==i?void 0:i.store)),i.reset(t),s&&t.forEach(t=>{this.notify(e,t)})}}notifyOnWatch(e,t,s){const i=this.getData(e,t);F.indexOf(t)>-1&&0===i.length||s&&s.call(this,i)}notify(e,t){if(!this.task[e])return;const s=this.task[e];if(s[t]){const i=s[t],n=this.getData(e,t);for(const[e]of i.entries())e.call(this,n)}}}class Re extends pe{constructor(){super(),this.languages=null,this.keyMap={}}static getInstance(){return Re.instance||(Re.instance=new Re),Re.instance}setI18next(e){this.i18next?console.warn("TUITranslateService.setI18next already have i18next instance."):this.i18next=e}provideLanguages(e){var t;B||(this.languages=e,(null===(t=e["zh-CN"])||void 0===t?void 0:t.Chat)&&this.setKeyMap(e["zh-CN"]),console.log("TUITranslateService.provideLanguages ok."))}useI18n(e){var t;if(B)return;if(!this.languages)return void console.warn("TUITranslateService.useI18next not have messages.");const s={};for(const[e,t]of Object.entries(this.languages)){s["zh_cn"===e?"zh":e]={translation:t}}this.i18next.init({compatibilityJSON:"v3",lng:e||"zh",fallbackLng:"zh",detection:{order:["querystring","navigator"],caches:["localStorage","cookie"]},resources:s});const i=this.normalizeLanguageKey(e||"zh");null===(t=this.getEngine().TUIReport)||void 0===t||t.reportFeature(201,i)}changeLanguage(e){const t=this.normalizeLanguageKey(e);return this.getEngine().TUIReport.reportFeature(201,t),this.i18next.changeLanguage(e)}normalizeLanguageKey(e){return e.includes("en")?"en-us":e.includes("tw")?"zh-tw":e.includes("zh")||e.includes("cn")?"zh-cn":e.includes("ko")||e.includes("kr")?"ko-kr":e.includes("ja")||e.includes("jp")?"ja-jp":`other-${e}`}t(e){if(!this.languages){let t=e;return!R(e)&&e.indexOf(".")>-1&&(t=e.split(".").pop()||""),t}const t=this.keyMap[e];return t?this.i18next.t(t):this.i18next.t(e)}setKeyMap(e,t){for(const s in e)if(Object.prototype.hasOwnProperty.call(e,s)){const i=t?`${t}.${s}`:s;if(e[s]&&"object"==typeof e[s]&&!Array.isArray(e[s])&&null!==e[s])this.setKeyMap(e[s],i);else{let i=t?`${t}.${e[s]}`:e[s];i=this.replaceKey(i),this.keyMap[i]=`${t}.${s}`}}}replaceKey(e){return e.startsWith("Chat")?e.replace("Chat","TUIChat"):e.startsWith("Conversation")?e.replace("Conversation","TUIConversation"):e.startsWith("Message")?e.replace("Message","message.tip"):e.startsWith("Call")?e.replace("Call","message.custom"):e}}class ye extends pe{constructor(){super(),this.serv="TUIConversationService"}static getInstance(){return ye.instance||(ye.instance=new ye),ye.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(l.CONV,"conversationList",t),this.updateCurrentConversation()}onTotalUnreadCountUpdated(e){this.getEngine().TUIStore.update(l.CONV,"totalUnreadCount",e)}onMessageReceived(e){const t=this.getEngine(),s=this.getEngine().TUIStore.getData(l.CONV,"conversationList");let i=!1;for(let n=0;n<e.length;n++){if(e[n].type!==t.TYPES.MSG_GRP_SYS_NOTICE)continue;const{operationType:a}=e[n].payload,r=`GROUP${e[n].to}`,o=4===a||5===a||8===a,g=2===a||6===a||7===a;if(o||g)for(let e=0;e<s.length;e++)if(s[e].type!==t.TYPES.CONV_C2C&&s[e].conversationID===r){if(o){this.getEngine().TUIStore.update(l.CONV,"operationTypeMap",{conversationID:r,operationType:a}),i=!0;break}if(g&&s[e].operationType>0){this.getEngine().TUIStore.update(l.CONV,"operationTypeMap",{conversationID:r,operationType:0}),i=!0;break}}}if(i){this.getEngine().TUIStore.update(l.CONV,"conversationList",s);const e=this.getEngine().TUIStore.getData(l.CONV,"currentConversationID")||"",t=this.findConversation(e);t&&this.getEngine().TUIStore.update(l.CONV,"currentConversation",t)}}getConversationInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getConversationList().then(t=>{const{conversationList:s,isSyncCompleted:i}=t.data;if(console.log(`${this.serv}.init, getConversationList count:${s.length} isSyncCompleted:${i}`),s.length>0){this.onConversationListUpdated(s);const t=e.chat.getTotalUnreadMessageCount();this.onTotalUnreadCountUpdated(t)}})}switchConversation(e){return h(this,void 0,void 0,function*(){const t=`${this.serv}.switchConversation`,s=this.getEngine();if(!e)return s.TUIStore.reset(l.CHAT,["messageList","isCompleted","nextReqMessageID"]),s.TUIStore.update(l.CONV,"currentConversationID",""),s.TUIStore.update(l.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:m.INVALID_CONV_ID,message:U.INVALID_CONV_ID});const i=s.TUIStore.getData(l.APP,"enableAutoMessageRead"),n=s.TUIStore.getData(l.CONV,"currentConversationID");if(n&&n===e)return i&&this.setMessageRead(n),console.warn(`${t} please check conversationID, conversationID:${e}`),Promise.resolve({code:m.CONV_ID_SAME,message:U.CONV_ID_SAME});const a=yield this.getConversationModel(e);return R(a)?(console.warn(`${t} target conversation is not exist, conversationID:${e}`),Promise.reject({code:m.CONV_NOT_EXIST,message:U.CONV_NOT_EXIST})):(i&&(n&&this.setMessageRead(n),e&&this.setMessageRead(e)),s.TUIStore.reset(l.CHAT,["messageList","isCompleted","nextReqMessageID"]),s.TUIStore.update(l.CONV,"currentConversationID",e),s.TUIStore.update(l.CONV,"currentConversation",a),Promise.resolve(a))})}getConversationModel(e){return h(this,void 0,void 0,function*(){let t=this.findConversation(e);if(R(t))try{const s=yield this.getConversationProfile(e);s.data&&s.data.conversation&&(t=new Ie(s.data.conversation))}catch(e){t=void 0}return t})}findConversation(e){let t;const s=this.getEngine().TUIStore.getData(l.CONV,"conversationList");for(let i=0;i<s.length;i++)if(s[i].conversationID===e){t=s[i];break}return t}updateCurrentConversation(){const e=this.getEngine(),t=e.TUIStore.getData(l.CONV,"currentConversationID"),s=this.findConversation(t);s&&e.TUIStore.update(l.CONV,"currentConversation",s)}getConversationList(){return this.getEngine().chat.getConversationList()}getConversationProfile(e){return this.getEngine().chat.getConversationProfile(e)}deleteConversation(e){const t="string"==typeof e?e:e.conversationIDList[0];return this.getEngine().chat.deleteConversation(e).then(e=>{const s=this.getEngine().TUIStore.getData(l.CONV,"currentConversationID");return console.log(`${this.serv}.deleteConversation conversationID:${t} currentConversationID:${s}`),t===s&&(this.getEngine().TUIStore.update(l.CONV,"currentConversationID",""),this.getEngine().TUIStore.update(l.CONV,"currentConversation",null)),e})}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(l.CHAT,"messageList",[]),this.getEngine().TUIStore.update(l.CHAT,"nextReqMessageID",""),this.getEngine().TUIStore.update(l.CHAT,"isCompleted",!0),e))}setMessageRead(e){return this.getEngine().chat.setMessageRead({conversationID:e})}setConversationDraft(e){const{conversationID:t,draftInfo:s,draftText:i=""}=e;return this.getEngine().chat.setConversationDraft({conversationID:t,draftText:i||(s?JSON.stringify(s):"")}).then(e=>{const{conversation:t}=e.data;this.updateConversation(t)})}updateConversation(e){let t=!1;const s=this.getEngine().TUIStore.getData(l.CONV,"conversationList");for(let i=0;i<s.length;i++)if(s[i].conversationID===e.conversationID){s[i]=e,t=!0;break}t&&this.getEngine().TUIStore.update(l.CONV,"conversationList",s)}filterSystemConversation(e){return e.filter(e=>e.type!==this.getEngine().TYPES.CONV_SYSTEM)}markConversation(e){return this.getEngine().chat.markConversation(e)}}class Pe{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.PROFILE_UPDATED,this.onProfileUpdated.bind(this)),this.getEngine().eventCenter.addEvent(this.getEngine().EVENT.BLACKLIST_UPDATED,this.onBlacklistUpdated.bind(this)),this.getUserProfileInitData()}onProfileUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(l.USER,"userProfile");e.forEach(e=>{e.userID===s.userID&&t.TUIStore.update(l.USER,"userProfile",e)})}onBlacklistUpdated(e){const t=this.getEngine();this.getBlacklistProfile(e).then(e=>{t.TUIStore.update(l.USER,"userBlacklist",e)})}getUserProfileInitData(){const e=this.getEngine();e.chat.isReady()&&e.chat.getBlacklist().then(e=>{const t=e.data||[];console.log(`TUIUserProfileHandler.init, getBlacklist count:${t.length}`),t.length>0&&this.onBlacklistUpdated(t)})}getBlacklistProfile(e){const t=[];let s=0;for(;s<e.length;)t.push(e.slice(s,s+=100));const i=[];t.forEach(e=>{i.push(this.TUIUserService.getUserProfile({userIDList:e}))});const n=[];return Promise.all(i).then(e=>(e.forEach(e=>{const t=e.data.map(e=>{const{userID:t,nick:s,avatar:i}=e;return{userID:t,nick:s,avatar:i}});n.push(...t)}),n))}getUserProfile(e){const t=this.getEngine();return R(e)?t.chat.getMyProfile().then(e=>(t.TUIStore.update(l.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 Oe(e,t,s=!0){!function(e,t){Z?ee.setStorageSync(e,t):be()&&localStorage.setItem(e,JSON.stringify(t))}(s?Ge(e):e,t)}function Ae(e,t=!0){try{return function(e){if(Z)return ee.getStorageSync(e);if(be()){const t=localStorage.getItem(e);if("undefined"!==t)return JSON.parse(t)}return}(t?Ge(e):e)}catch(e){return void console.warn("Storage.getStorageItem error:",e)}}function Ge(e){return`chat_engine_${e}`}function be(){return navigator&&navigator.cookieEnabled&&localStorage}class Le{constructor(e){this.TUIUserService=e}getEngine(){return this.TUIUserService.getEngine()}init(){const e=this.getEngine(),t=Ae("displayOnlineStatus")||!1;e.TUIStore.update(l.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(l.CONV,{conversationList:()=>{const t=e.TUIStore.getData(l.APP,"enabledOnlineStatus"),s=e.TUIStore.getData(l.USER,"displayOnlineStatus");t&&s&&this.startToSubscribe()}})}onUserStatusUpdated(e){this.getEngine().TUIStore.update(l.USER,"userStatusList",e)}switchUserStatus(e){const t=this.getEngine(),{displayOnlineStatus:s=!1}=e;t.TUIStore.update(l.USER,"displayOnlineStatus",s),Oe("displayOnlineStatus",s);const i=t.TUIStore.getData(l.APP,"enabledOnlineStatus");i?!0===s?this.startToSubscribe():this.unsubscribeUserStatus():console.warn(`UserStatusHandler.switchUserStatus enabledOnlineStatus:${i} 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(l.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:i}=e.data,n=[];return s.forEach(e=>{i.includes(e)||n.push({userID:e,statusType:p.UNSUB_USER})}),t.TUIStore.update(l.USER,"userStatusList",n),e}).catch(e=>Promise.reject(e))}startToSubscribe(){const e=this.getEngine(),t=e.TUIStore.getData(l.CONV,"conversationList"),s=e.TUIStore.getData(l.USER,"userStatusList"),i=[];t.forEach(t=>{if(t.type===e.TYPES.CONV_C2C){const n=t.conversationID.replace(e.TYPES.CONV_C2C,"");s.has(n)||i.push(n)}}),0!==i.length&&e.chat.isReady()&&(this.subscribeUserStatus({userIDList:i}),this.getUserStatus({userIDList:i}))}}class Ne extends pe{constructor(){super(),this.userProfileHandler=new Pe(this),this.userStatusHandler=new Le(this)}static getInstance(){return Ne.instance||(Ne.instance=new Ne),Ne.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(l.USER,"kickedOut",e.type)}onNetStateChange(e){this.getEngine().TUIStore.update(l.USER,"netStateChange",e.state)}initMessageReadReceipt(){const e=Ae("displayMessageReadReceipt")||!0;this.getEngine().TUIStore.update(l.USER,"displayMessageReadReceipt",e)}switchUserStatus(e){return this.userStatusHandler.switchUserStatus(e)}switchMessageReadStatus(e){this.getEngine().TUIStore.update(l.USER,"displayMessageReadReceipt",e),Oe("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 je{constructor(e){this.TUIChatService=e,this.userShowNameMap=new Map,this.requestedUserMap=new Map}getEngine(){return this.TUIChatService.getEngine()}t(e){return this.getEngine().TUITranslate.t(e)}handleTextMessage(e){return{text:this.decodeText(e.payload)}}handleFaceMessage(e){const t={name:"",url:"",type:""};return e.payload.data.indexOf("@custom")>-1?(t.name=e.payload.data,t.type="custom",t):(t.name=e.payload.data.indexOf("@2x")<0?`${e.payload.data}@2x`:e.payload.data,t.url=`${j}${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=`${k}pointx=${t.lon}&pointy=${t.lat}&name=${e.payload.description}`,t.url=`${x}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:A(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("TUIChat.[自定义消息]")}`,businessID:s?"group_create":""}}handleMergeMessage(e){return Object.assign({},e.payload)}handleGroupTipsMessage(e){var t,s,i,n,a,r;const o=this.getEngine(),g={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===(n=null===(i=null==e?void 0:e.payload)||void 0===i?void 0:i.memberList)||void 0===n?void 0:n.length)>0&&(c="",null===(r=null===(a=null==e?void 0:e.payload)||void 0===a?void 0:a.memberList)||void 0===r||r.map(e=>{const t=(null==e?void 0:e.nick)||(null==e?void 0:e.userID);return c+=`${this.substringByLength(t)},`,e}),c=null==c?void 0:c.slice(0,-1)),e.payload.operationType){case o.TYPES.GRP_TIP_MBR_JOIN:g.text=`${c} ${this.t("message.tip.加入群组")}`;break;case o.TYPES.GRP_TIP_MBR_QUIT:g.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.退出群组")}`;break;case o.TYPES.GRP_TIP_MBR_KICKED_OUT:g.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被")}${this.t("message.tip.踢出群组")}`;break;case o.TYPES.GRP_TIP_MBR_SET_ADMIN:g.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.成为管理员")}`;break;case o.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:g.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被撤销管理员")}`;break;case o.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:g.text=this.handleGroupProfileUpdated(e);break;case o.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:for(const t of e.payload.memberList)t.muteTime>0?g.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被禁言")}`:g.text=`${this.t("message.tip.群成员")}:${c} ${this.t("message.tip.被取消禁言")}`;break;default:g.text=`[${this.t("message.tip.群提示消息")}]`}return g}handleGroupSystemMessage(e){const t=e.payload.groupProfile.name||e.payload.groupProfile.groupID,s={text:""};switch(e.payload.operationType){case 1:s.text=`${e.payload.operatorID} ${this.t("message.tip.申请加入群组")}:${t}`;break;case 2:s.text=`${this.t("message.tip.成功加入群组")}:${t}`;break;case 3:s.text=`${this.t("message.tip.申请加入群组")}:${t} ${this.t("message.tip.被拒绝")}`;break;case 4:s.text=`${this.t("message.tip.你被管理员")}${e.payload.operatorID} ${this.t("message.tip.踢出群组")}:${t}`;break;case 5:s.text=`${this.t("message.tip.群")}:${t} ${this.t("message.tip.被")} ${e.payload.operatorID} ${this.t("message.tip.解散")}`;break;case 6:s.text=`${e.payload.operatorID} ${this.t("message.tip.创建群")}:${t}`;break;case 7:case 12:s.text=`${e.payload.operatorID} ${this.t("message.tip.邀请你加群")}:${t}`;break;case 8:s.text=`${this.t("message.tip.你退出群组")}:${t}`;break;case 9:s.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.设置为群")}:${t} ${this.t("message.tip.的管理员")}`;break;case 10:s.text=`${this.t("message.tip.你被")}${e.payload.operatorID} ${this.t("message.tip.撤销群")}:${t} ${this.t("message.tip.的管理员身份")}`;break;case 13:s.text=`${e.payload.operatorID} ${this.t("message.tip.同意加群")}:${t}`;break;case 14:s.text=`${e.payload.operatorID} ${this.t("message.tip.拒接加群")}:${t}`;break;case 255:s.text=`${this.t("message.tip.自定义群系统通知")}: ${e.payload.userDefinedField}`;break;default:s.text="未解析的群系统通知"}return s}handleCallKitSignaling(e){var t,s,i,n,a,r,o,g,c,h;const u=O(e.payload.data);if(1!==(null==u?void 0:u.businessID))return"";const d=O(null==u?void 0:u.data),l=e.fromAccount||e.from,p=this.getEngine().TUIFriend.getFriendRemark([l]),T=this.getEngine().getMyUserID();let E=p[l]||e.nameCard||e.nick||l;switch(E=this.substringByLength(E),null==u?void 0:u.actionType){case 1:return"audioCall"!==(null===(t=null==d?void 0:d.data)||void 0===t?void 0:t.cmd)&&"videoCall"!==(null===(s=null==d?void 0:d.data)||void 0===s?void 0:s.cmd)||!(null==u?void 0:u.groupID)?"hangup"===(null===(i=null==d?void 0:d.data)||void 0===i?void 0:i.cmd)?(null==u?void 0:u.groupID)?`${this.t("message.custom.通话结束")}`:`${this.t("message.custom.通话时长")}:${function(e){const t=e;let s,i,n,a="";return t>=3600?(s=parseInt(""+t/3600,10)<10?`0${parseInt(""+t/3600,10)}`:parseInt(""+t/3600,10),i=parseInt(""+t%60/60,10)<10?`0${parseInt(""+t%60/60,10)}`:parseInt(""+t%60/60,10),n=t%3600<10?"0"+t%3600:t%3600,n>60&&(i=parseInt(""+n/60,10)<10?`0${parseInt(""+n/60,10)}`:parseInt(""+n/60,10),n=n%60<10?"0"+n%60:n%60),a=`${s}:${i}:${n}`):t>=60&&t<3600?(i=parseInt(""+t/60,10)<10?`0${parseInt(""+t/60,10)}`:parseInt(""+t/60,10),n=t%60<10?"0"+t%60:t%60,a=`00:${i}:${n}`):t<60&&(n=t<10?`0${t}`:t,a=`00:00:${n}`),a}(null==d?void 0:d.call_end)}`:"switchToAudio"===(null===(n=null==d?void 0:d.data)||void 0===n?void 0:n.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(a=null==d?void 0:d.data)||void 0===a?void 0:a.cmd)?`${this.t("message.custom.切换视频通话")}`:`${this.t("message.custom.发起通话")}`:`${E} ${this.t("message.custom.发起通话")}`;case 2:return(null==u?void 0:u.groupID)?`${E} ${this.t("message.custom.取消通话")}`:this.isOldUIKit("message.custom.已取消")?this.t("message.custom.取消通话"):(null==u?void 0:u.inviter)===T?this.t("message.custom.已取消"):this.t("message.custom.对方已取消");case 3:return"switchToAudio"===(null===(r=null==d?void 0:d.data)||void 0===r?void 0:r.cmd)?`${this.t("message.custom.切换语音通话")}`:"switchToVideo"===(null===(o=null==d?void 0:d.data)||void 0===o?void 0:o.cmd)?`${this.t("message.custom.切换视频通话")}`:(null==u?void 0:u.groupID)?`${E} ${this.t("message.custom.已接听")}`:this.t("message.custom.已接听");case 4:return(null==u?void 0:u.groupID)?`${E} ${this.t("message.custom.拒绝通话")}`:this.isOldUIKit("message.custom.已拒绝")?this.t("message.custom.拒绝通话"):"line_busy"===(null==d?void 0:d.line_busy)||"lineBusy"===(null==d?void 0:d.data.message)?(null==u?void 0:u.inviter)===T?this.t("message.custom.对方忙线中"):this.t("message.custom.忙线未接听"):(null==u?void 0:u.inviter)===T?this.t("message.custom.对方已拒绝"):this.t("message.custom.已拒绝");case 5:if("switchToAudio"===(null===(g=null==d?void 0:d.data)||void 0===g?void 0:g.cmd))return`${this.t("message.custom.切换语音通话")}`;if("switchToVideo"===(null===(c=null==d?void 0:d.data)||void 0===c?void 0:c.cmd))return`${this.t("message.custom.切换视频通话")}`;if(null==u?void 0:u.groupID){if(l===(null==u?void 0:u.inviter)){this.handleCallkitTimeoutSignaling(u.inviteeList);let e="";return null===(h=u.inviteeList)||void 0===h||h.forEach(t=>{const s=this.userShowNameMap.get(t)||t;e+=`${this.substringByLength(s)}、`}),e=e.substring(0,e.lastIndexOf("、")),`${e} ${this.t("message.custom.无应答")}`}return`${E} ${this.t("message.custom.无应答")}`}return this.isOldUIKit("message.custom.对方无应答")?this.t("message.custom.无应答"):(null==u?void 0:u.inviter)===T?this.t("message.custom.对方无应答"):this.t("message.custom.超时无应答");default:return""}}handleCreateGroupCustomMessage(e){let t;const s=O(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,i=-1,n=-1;for(;""!==s;)switch(i=s.indexOf("["),n=s.indexOf("]"),i){case 0:if(-1===n)t.push({name:"text",text:s}),s="";else{const e=s.slice(0,n+1);e.indexOf("@custom")>-1?(t.push({name:"img",src:"",type:"custom",emojiKey:e}),s=s.substring(n+1)):w[e]?(t.push({name:"img",src:N+w[e],emojiKey:e}),s=s.substring(n+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,i)}),s=s.substring(i)}return t}handleGroupProfileUpdated(e){const{nick:t,payload:s}=e,{newGroupProfile:i,memberList:n,operatorID:a}=s;let r="";const o=t||a,g=Object.keys(i)[0];switch(g){case"muteAllMembers":r=i[g]?`${this.t("message.tip.管理员")} ${o} ${this.t("message.tip.开启全员禁言")}`:`${this.t("message.tip.管理员")} ${o} ${this.t("message.tip.取消全员禁言")}`;break;case"ownerID":r=`${n[0].nick||n[0].userID} ${this.t("message.tip.成为新的群主")}`;break;case"groupName":r=`${o} ${this.t("message.tip.修改群名为")} ${i[g]}`;break;case"notification":r=this.isOldUIKit("message.tip.把群公告修改为")?`${o} ${this.t("message.tip.发布新公告")}`:`${o} ${this.t("message.tip.把群公告修改为")} "${i[g]}"`}return r}handleCallkitTimeoutSignaling(e=[]){if(0===e.length)return;const t=this.getEngine().TUIFriend.getFriendRemark(e),s=[];e.forEach(e=>{const i=t[e];i?this.userShowNameMap.set(e,i):this.requestedUserMap.has(e)||(s.push(e),this.requestedUserMap.set(e,1))}),s.length>0&&this.getEngine().TUIUser.getUserProfile({userIDList:s}).then(e=>{(e.data||[]).forEach(e=>{const{userID:t,nick:s}=e,i=s||t;this.userShowNameMap.set(t,i)})}).catch(()=>{})}substringByLength(e,t=12){return e.length>t?`${e.slice(0,t)}...`:e}isOldUIKit(e){var t;const s=e.lastIndexOf("."),i=e.slice(0,s+1);return null===(t=this.t(e))||void 0===t?void 0:t.startsWith(i)}}class ke{constructor(e){this.TUIChatService=e,this.typingTo="",this.timer=null}getEngine(){return this.TUIChatService.getEngine()}clearTypingStatus(){this.getEngine().TUIStore.getData(l.CHAT,"typingStatus")&&this.getEngine().TUIStore.update(l.CHAT,"typingStatus",!1),this.timer&&clearTimeout(this.timer),this.timer=null}handleLastMessage(e){const t=this.getEngine(),s=t.TUIStore.getData(l.CHAT,"typingStatus");if(e.type===this.getEngine().TYPES.MSG_CUSTOM&&"in"===e.flow){const i=O(e.payload.data);if(i.businessID===T.BUSINESS_ID){const{typingStatus:e,userAction:n}=i;if(e===T.STATUS_START||n===T.ACTION_START_ID)return s?(this.timer&&clearTimeout(this.timer),this.timer=null):t.TUIStore.update(l.CHAT,"typingStatus",!0),this.timer=setTimeout(()=>{this.clearTypingStatus()},3e4),t.TUIStore.getData(l.CHAT,"typingStatus");e!==T.STATUS_END&&n!==T.ACTION_END_ID||this.clearTypingStatus()}}}filterTypingMessage(e=[]){if(0===e.length)return[];return this.getEngine().TUIStore.getData(l.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!==T.BUSINESS_ID}return!0})}createTypingMessage(e=T.STATUS_END,t=""){const{BUSINESS_ID:s,STATUS_START:i,VERSION:n,ACTION_START_ID:a,ACTION_END_ID:r,ACTION_START:o,ACTION_END:g,NEED_TYPING:c}=T;return{to:t,conversationType:this.getEngine().TYPES.CONV_C2C,payload:{data:JSON.stringify({businessID:s,typingStatus:e,version:n,userAction:e===i?a:r,actionParam:e===i?o:g}),description:"",extension:""},cloudCustomData:JSON.stringify({messageFeature:{needTyping:c,version:n}})}}sendTyping(e=!1,t=""){if(e){this.typingTo=t;const e=this.createTypingMessage(T.STATUS_START,t);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}else this.sendTypingEnd()}sendTypingEnd(){if(this.typingTo){const e=this.createTypingMessage(T.STATUS_END,this.typingTo);this.getEngine().TUIChat.sendCustomMessage(e,{onlineUserOnly:!0})}this.typingTo=""}}class xe{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(l.CONV,"currentConversationID"),i=[];e.forEach(e=>{const{messageID:n}=e,a=t.chat.findMessage(n);a&&s===a.conversationID&&i.push(a)}),i.length>0&&t.TUIChat.updateMessageList(i,"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(l.APP,"enabledMessageReadReceipt"),i=t.TUIStore.getData(l.USER,"displayMessageReadReceipt");!s||!i||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 we extends pe{constructor(){super(),this.serv="TUIChatService",this.messageHandler=new je(this),this.typingHandler=new ke(this),this.readReceiptHandler=new xe(this),this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap=new Map}static getInstance(){return we.instance||(we.instance=new we),we.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.MESSAGE_RECEIVED,this.onMessageReceived.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_MODIFIED,this.onMessageModified.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_REVOKED,this.onMessageRevoked.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_READ_BY_PEER,this.onMessageReadByPeer.bind(this)),e.eventCenter.addEvent(e.EVENT.MESSAGE_REACTIONS_UPDATED,this.onMessageReactionsUpdated.bind(this)),this.onCurrentConversationIDUpdated(),this.onMessageSource(),this.readReceiptHandler.init()}onMessageReceived(e){this.updateMessageList(e,"received"),this.getEngine().TUIStore.update(l.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(l.CONV,{currentConversationID:t=>{this.isSwitching=!0,this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.clear(),e.TUIStore.reset(l.CHAT),this.typingHandler.clearTypingStatus(),this.typingHandler.sendTypingEnd(),Te(t)||this.getMessageList().finally(()=>{this.isSwitching=!1,this.delayGetHoppingFunction&&this.delayGetHoppingFunction()})}})}onMessageSource(){const e=this.getEngine();e.TUIStore.watch(l.CHAT,{messageSource:t=>{const s=this.getStoreData(l.CONV,"currentConversationID");if(!s||t&&t.conversationID!==s)return;if(R(t))return this.hoppingConfigMap.clear(),e.TUIStore.update(l.CHAT,"messageList",[]),e.TUIStore.update(l.CHAT,"nextReqMessageID",""),e.TUIStore.update(l.CHAT,"isCompleted",!1),void this.getMessageList();const i=this.getStoreData(l.CHAT,"messageList");i&&i.find(e=>t&&e.ID===t.ID)||(this.isSwitching?this.delayGetHoppingFunction=this.getMessageListHoppingForDown:this.getMessageListHoppingForDown())}})}getMessageListHoppingForDown(){const e=this.getStoreData(l.CHAT,"messageList"),{conversationID:t,sequence:s,time:i,ID:n}=this.getStoreData(l.CHAT,"messageSource");if(e&&e.find(e=>n&&e.ID===n))return;const a=this.getEngine();a.TUIStore.update(l.CHAT,"messageList",[]),a.TUIStore.update(l.CHAT,"nextReqMessageID",""),a.TUIStore.update(l.CHAT,"isCompleted",!1),this.getMessageListHopping({conversationID:t,sequence:s,time:i,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(l.CHAT,"messageSource")&&"unshift"!==t&&"edit"!==t)return;const s=this.getStoreData(l.CHAT,"messageList"),i=this.updateTargetMessageList(e,s,t);this.getEngine().TUIStore.update(l.CHAT,"messageList",i)}updateTargetMessageList(e,t,s=""){const i=this.getStoreData(l.CONV,"currentConversationID");let n=e.filter(e=>e.conversationID===i);if(n=this.handleC2CCallSignaling(n),!s||0===n.length)return t;const a=t||[];let r=[];if("send"===s||"push"===s||"received"===s){const e=this.getStoreData(l.CHAT,"userInfo");Object.keys(e).length>0&&this.updateLocalMessage(n,e)}const o=this.getStoreData(l.APP,"enableAutoMessageRead");switch(s){case"edit":for(const e of t){const t=n.find(t=>t.ID===e.ID);r.push(t||e)}break;case"resend":r=a.filter(e=>e.ID!==n[0].ID).concat(n);break;case"send":r=a.concat(this.typingHandler.filterTypingMessage(n));break;case"push":r=a.concat(this.typingHandler.filterTypingMessage(n)),this.getEngine().chat.setMessageRead({conversationID:i});break;case"received":r=a.concat(this.typingHandler.filterTypingMessage(n)),r=this.sortMessageList(r),o&&this.getEngine().chat.setMessageRead({conversationID:i});break;case"unshift":r=n.filter(e=>0===a.length||!a.find(t=>t.ID===e.ID)),r.push(...a),r=this.sortMessageList(r)}return r}enterTypingState(){this.getStoreData(l.APP,"enableTyping")&&this.sendTyping(!0)}leaveTypingState(){this.getStoreData(l.APP,"enableTyping")&&this.sendTyping(!1)}sendTyping(e){const t=this.getEngine(),s=this.getStoreData(l.CONV,"currentConversationID");if(!s.startsWith(t.TYPES.CONV_C2C))return;const i=s.replace(t.TYPES.CONV_C2C,"");if(e){const e=this.getStoreData(l.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,i)}quoteMessage(e){var t;return this.getEngine().TUIStore.update(l.CHAT,"quoteMessage",{message:e,type:"quote"}),null===(t=this.getEngine().TUIReport)||void 0===t||t.reportFeature(205),e}replyMessage(e){return this.getEngine().TUIStore.update(l.CHAT,"quoteMessage",{message:e,type:"reply"}),e}getCurrentConvInfo(){const{conversationID:e="",type:t}=this.getStoreData(l.CONV,"currentConversation")||{};return{to:e.replace(t,""),conversationType:t}}t(e){return this.getEngine().TUITranslate.t(e)||e}getMessageAbstractAndType(e){var t,s;const i=this.getEngine(),n={abstract:"",type:0};switch(e.type){case i.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 i.TYPES.MSG_CUSTOM:n.abstract="[自定义消息]",n.type=2;break;case i.TYPES.MSG_IMAGE:n.abstract="[图片]",n.type=3;break;case i.TYPES.MSG_AUDIO:n.abstract="[语音]",n.type=4;break;case i.TYPES.MSG_VIDEO:n.abstract="[视频]",n.type=5;break;case i.TYPES.MSG_FILE:n.abstract="[文件]",n.type=6;break;case i.TYPES.MSG_LOCATION:n.type=7;break;case i.TYPES.MSG_FACE:n.abstract="[表情]",n.type=8;break;case i.TYPES.MSG_GRP_TIP:n.type=9;break;case i.TYPES.MSG_MERGER:n.abstract=null===(s=null==e?void 0:e.payload)||void 0===s?void 0:s.title,n.type=10}return n}genMessageReply(e,t){if("reply"!==t&&"quote"!==t)return{};const{abstract:s,type:i}=this.getMessageAbstractAndType(e),n={messageAbstract:s,messageSender:e.nick||e.from,messageID:e.ID},a=Object.assign(Object.assign({},n),{messageType:i,messageTime:null==e?void 0:e.time,messageSequence:null==e?void 0:e.sequence,version:1});if("reply"===t&&(a.messageRootID=e.ID,e.cloudCustomData)){const t=O(e.cloudCustomData);t.messageReply&&t.messageReply.messageRootID&&(a.messageRootID=t.messageReply.messageRootID)}return{messageReply:a,messageReplyRoot:n}}getMessageInfo(e,t,s){const{messageReply:i,messageReplyRoot:n}=this.genMessageReply(t,s),a=e.cloudCustomData?O(e.cloudCustomData):{};let r;if(a.messageReply?a.messageReply=Object.assign(Object.assign({},i),a.messageReply):a.messageReply=i,"reply"===s){const{messageRootID:e}=i;r=this.getEngine().chat.findMessage(e);const t=(null==r?void 0:r.cloudCustomData)?O(r.cloudCustomData):{};t.messageReplies||(t.messageReplies={}),o=t.messageReplies.replies,("function"==typeof Array.isArray?Array.isArray(o):"array"===Object.prototype.toString.call(o).match(/^\[object (.*)\]$/)[1].toLowerCase())||(t.messageReplies.replies=[]),t.messageReplies.replies.push(n),r.cloudCustomData=JSON.stringify(t)}var o;return{cloudCustomData:JSON.stringify(a),rootMessage:r}}sendTextMessage(e,t){const s=this.getEngine(),{message:i,type:n}=this.getStoreData(l.CHAT,"quoteMessage");let a={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};i&&(a=this.getMessageInfo(e,i,n));const r=s.chat.createTextMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:a.cloudCustomData}));return this.sendMessage(r,t).then(e=>(a.rootMessage&&this.modifyMessage(a.rootMessage),s.TUIStore.reset(l.CHAT,["quoteMessage"],!0),e))}sendTextAtMessage(e,t){const s=this.getEngine(),{message:i,type:n}=this.getStoreData(l.CHAT,"quoteMessage");let a={cloudCustomData:e.cloudCustomData||"",rootMessage:void 0};i&&(a=this.getMessageInfo(e,i,n));const r=s.chat.createTextAtMessage(Object.assign(Object.assign(Object.assign({},this.getCurrentConvInfo()),e),{cloudCustomData:a.cloudCustomData}));return this.sendMessage(r,t).then(e=>(a.rootMessage&&this.modifyMessage(a.rootMessage),s.TUIStore.reset(l.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 i="";switch(e.type){case t.TYPES.MSG_TEXT:i=e.payload.text||"",i.length>20&&(i=i.slice(0,20));break;case t.TYPES.MSG_MERGER:i=`${this.t("TUIChat.[聊天记录]")}`;break;case t.TYPES.MSG_IMAGE:i=`${this.t("TUIChat.[图片]")}`;break;case t.TYPES.MSG_AUDIO:i=`${this.t("TUIChat.[音频]")}`;break;case t.TYPES.MSG_VIDEO:i=`${this.t("TUIChat.[视频]")}`;break;case t.TYPES.MSG_CUSTOM:i=`${this.t("TUIChat.[自定义消息]")}`;break;case t.TYPES.MSG_FILE:i=`${this.t("TUIChat.[文件]")}`;break;case t.TYPES.MSG_FACE:i=`${this.t("TUIChat.[动画表情]")}`}return`${s}: ${i}`}genMergerForwardPayload(e,t){const{abstractList:s=[],compatibleText:i="",title:n}=t;return 0===s.length&&e.forEach(e=>{s.push(this.setAbstractList(e))}),{messageList:e,title:n,abstractList:s,compatibleText:i||this.t("TUIChat.请升级IMSDK到v2.10.1或更高版本查看此消息")}}genSendMergerForwardMessage(e){const{conversationList:t,messageList:s,params:i,mergeInfo:n,sendMessageOptions:a}=e,r=[];for(let e=0;e<t.length;e++){const{conversationID:o,type:g}=t[e],c=Object.assign({to:o.replace(`${g}`,""),conversationType:g,payload:this.genMergerForwardPayload(s,n)},i),h=this.getEngine().chat.createMergerMessage(c);r.push(this.sendMessage(h,a))}return r}genTitle(e,t){const{nick:s,from:i,to:n}=e;return`${s||i} ${this.t("TUIChat.和")} ${t||n} ${this.t("TUIChat.的聊天记录")}`}genMergeInfo(e){var t;return h(this,void 0,void 0,function*(){const{messageList:s,mergeInfo:i}=e;if(i.title)return i;if(s[0].conversationType===this.getEngine().TYPES.CONV_GROUP)return i.title=this.t("TUIChat.群聊的聊天记录"),i;try{const{data:e=[]}=yield this.getEngine().TUIUser.getUserProfile({userIDList:[s[0].to]});i.title=this.genTitle(s[0],null===(t=e[0])||void 0===t?void 0:t.nick)}catch(e){i.title=this.genTitle(s[0])}return i})}sendMergerForwardMessage(e){return h(this,void 0,void 0,function*(){return e.mergeInfo=yield this.genMergeInfo(e),Promise.all(this.genSendMergerForwardMessage(e))})}getOriginMessageList(e){return e.map(e=>e instanceof Se?e.getMessage():e)}sendForwardMessage(e,t,s){t=this.getOriginMessageList(t);const i=s||{},{needMerge:n=!1,params:a={},mergeInfo:r={}}=i,o=c(i,["needMerge","params","mergeInfo"]);if(n)return this.sendMergerForwardMessage({conversationList:e,messageList:t,params:a,mergeInfo:r,sendMessageOptions:o});const g=[];for(let s=0;s<e.length;s++){const{conversationID:i,type:n}=e[s],r=Object.assign({to:i.replace(`${n}`,""),conversationType:n},a),c=o[i]||o;for(let e=0;e<t.length;e++){Reflect.set(r,"payload",t[e]);const s=this.getEngine().chat.createForwardMessage(r);g.push(this.sendMessage(s,c))}}return Promise.all(g)}revokeMessage(e){const t=this.getEngine().chat.revokeMessage(e);return this.getResponse(t,!0,!1)}resendMessage(e){e.status="unSend",this.updateMessageList([e],"resend");const t=this.getEngine().chat.resendMessage(e);return this.getResponse(t,!0,!0)}deleteMessage(e){const t=this.getEngine().chat.deleteMessage(e);return this.getResponse(t,!0,!1)}setMessageExtensions(e,t){return this.getEngine().chat.setMessageExtensions(e,t)}getMessageExtensions(e){return this.getEngine().chat.getMessageExtensions(e)}deleteMessageExtensions(e,t){return this.getEngine().chat.deleteMessageExtensions(e,t)}modifyMessage(e){const t=this.getEngine().chat.modifyMessage(e);return this.getResponse(t,!0,!1).catch(e=>{const{code:t=0,data:s={}}=e.code;throw t===I.MSG_MODIFY_CONFLICT?console.warn(`${S.MSG_MODIFY_CONFLICT} data.message: ${null==s?void 0:s.message}`):t===I.MSG_MODIFY_DISABLED_IN_AVCHATROOM?console.warn(S.MSG_MODIFY_DISABLED_IN_AVCHATROOM):t===I.MODIFY_MESSAGE_NOT_EXIST&&console.warn(S.MODIFY_MESSAGE_NOT_EXIST),e})}getMessageList(e={conversationID:this.getStoreData(l.CONV,"currentConversationID"),nextReqMessageID:this.getStoreData(l.CHAT,"nextReqMessageID")}){const t=this.getEngine();if(!t.chat.isReady())return Promise.reject({code:m.GET_MSG_LIST_ERROR,message:U.GET_MSG_LIST_ERROR});if(this.getStoreData(l.CHAT,"isCompleted"))return Promise.resolve({data:{messageList:[],nextReqMessageID:"",isCompleted:!0}});const s=this.getStoreData(l.CHAT,"messageSource"),i=this.hoppingConfigMap.get("nextMessageSeq"),n=this.hoppingConfigMap.get("nextMessageTime"),a=i||n;return s&&s.conversationID===(null==e?void 0:e.conversationID)&&a?this.getMessageListHopping():t.chat.getMessageList(e).then(e=>{var s;const{messageList:i,nextReqMessageID:n,isCompleted:a}=e.data,r=this.getStoreData(l.CHAT,"userInfo");Object.keys(r).length>0&&this.updateLocalMessage(i,r),this.updateMessageList(i,"unshift"),t.TUIStore.update(l.CHAT,"nextReqMessageID",n),t.TUIStore.update(l.CHAT,"isCompleted",a);const o=null===(s=i[0])||void 0===s?void 0:s.conversationID,{operationType:g=0}=this.getEngine().TUIStore.getConversationModel(o)||{};return 0===g&&(this.getMessageReactions({messageList:i}),this.readReceiptHandler.getMessageReadReceiptList(i)),e}).catch(e=>Promise.reject(e))}getMessageListHopping(e){var t;void 0===e&&(e={conversationID:null===(t=this.getStoreData(l.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:i,nextMessageSeq:n,nextMessageTime:a,isCompleted:r}=t.data,o=1===e.direction?e.sequence:n,g=1===e.direction?e.time:a;return this.updateMessageList(i,"unshift"),this.delayGetHoppingFunction=void 0,this.hoppingConfigMap.set("nextMessageSeq",o),this.hoppingConfigMap.set("nextMessageTime",g),s.TUIStore.update(l.CHAT,"isCompleted",r),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:i,unreadUserIDList:n,readUserIDList:a}=e.data,r={code:0,data:{cursor:s,isCompleted:t,messageID:i,unreadUserInfoList:[],readUserInfoList:[]}},o=[...n,...a];return 0===o.length?r:this.getEngine().TUIUser.getUserProfile({userIDList:o}).then(e=>(n.length>0?e.data.forEach(e=>{const{userID:t,nick:s="",avatar:i=""}=e;r.data.unreadUserInfoList.push({userID:t,nick:s,avatar:i})}):e.data.forEach(e=>{const{userID:t,nick:s="",avatar:i=""}=e;r.data.readUserInfoList.push({userID:t,nick:s,avatar:i})}),r))})}downloadMergedMessages(e){return this.getEngine().chat.downloadMergerMessage(e)}setTranslationLanguage(e){this.getEngine().TUIStore.update(l.USER,"targetLanguage",e)}translateText(e){const t=this.getStoreData(l.USER,"targetLanguage"),s=Object.assign({targetLanguage:t,sourceLanguage:"auto"},e);return this.getEngine().chat.translateText(s)}searchCloudMessages(e){return this.getEngine().TUISearch.searchCloudMessages(e)}addMessageReaction(e,t){return this.getEngine().chat.addMessageReaction(e.getMessage(),t)}removeMessageReaction(e,t){return this.getEngine().chat.removeMessageReaction(e.getMessage(),t)}getMessageReactions(e){const{messageList:t=[]}=e,s=this.getStoreData(l.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(()=>{})}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:i}=e,n=this.getEngine().TUIStore.getMessageModel(s);if(n){const e=[];for(let t=0;t<i.length;t++){let s=!0;for(let e=0;e<n.reactionList.length;e++)if(i[t].reactionID===n.reactionList[e].reactionID){n.reactionList[e]=i[t],s=!1;break}s&&e.push(i[t])}n.reactionList.push(...e),e.length=0,t.push(n)}}),t.length>0&&this.updateMessageList(t,"edit")}convertVoiceToText(e){const{message:t,language:s="zh"}=e,i=t.getMessage();return this.getEngine().chat.convertVoiceToText({message:i,language:s})}clearHistoryMessage(e){const t=this.getEngine();return t.chat.clearHistoryMessage(e).then(e=>(t.TUIStore.update(l.CHAT,"messageList",[]),t.TUIStore.update(l.CHAT,"nextReqMessageID",""),t.TUIStore.update(l.CHAT,"isCompleted",!1),e))}updateMessageInfo(e){const t=this.getStoreData(l.CHAT,"userInfo");this.getEngine().TUIStore.update(l.CHAT,"userInfo",Object.assign(t,e));const s=this.getStoreData(l.CHAT,"messageList");if(s.length>0){this.updateLocalMessage(s,e)&&this.getEngine().TUIStore.update(l.CHAT,"messageList",s)}}updateLocalMessage(e,t){let s=!1;return e.forEach(e=>{if(t[e.from]){const{nick:i,nameCard:n,avatar:a}=t[e.from];i&&(e.nick=i,s=!0),n&&(e.nameCard=n,s=!0),a&&(e.avatar=a,s=!0)}}),s}handleC2CCallSignaling(e){const t=this.getEngine(),s=t.getMyUserID();return e.filter(e=>{var i,n,a,r,o;const{conversationType:g,type:c,payload:h}=e;let u=!0;if(g===t.TYPES.CONV_C2C&&c===t.TYPES.MSG_CUSTOM){if(t.chat.getSignalingInfo(e)){const t=O(h.data);if(1===(null==t?void 0:t.businessID)){const g=O(t.data);if(u=!(e._isExcludedFromUnreadCount&&e._isExcludedFromLastMessage),u&&!0!==(null===(i=null==g?void 0:g.data)||void 0===i?void 0:i.consumed)){let i=null===(n=null==g?void 0:g.data)||void 0===n?void 0:n.inviter;"line_busy"!==(null==g?void 0:g.line_busy)&&"lineBusy"!==(null===(a=null==g?void 0:g.data)||void 0===a?void 0:a.message)||(i=t.inviter);const{from:c,to:h}=e;if(i!==s&&e.from===s){const t=this.getStoreData(l.CONV,"currentConversation");e.from=h,e.to=c,e.flow="in",e.avatar=(null===(r=null==t?void 0:t.userProfile)||void 0===r?void 0:r.avatar)||""}if(i===s&&e.from!==s){const t=this.getStoreData(l.USER,"userProfile");e.from=h,e.to=c,e.flow="out",e.avatar=null==t?void 0:t.avatar}console.log(`${this.serv}.handleC2CCallSignaling myUserID:${s} callSignaling.inviter:${t.inviter} customData.data.inviter:${null===(o=null==g?void 0:g.data)||void 0===o?void 0:o.inviter}`)}}}}return u})}sortMessageList(e){const{conversationType:t}=e[0];if(t===this.getEngine().TYPES.CONV_C2C)return e.sort((e,t)=>e.time-t.time);const s=e.filter(e=>"success"===e.status).sort((e,t)=>e.sequence-t.sequence);for(let t=0;t<e.length;t++)"success"!==e[t].status&&s.splice(t,0,e[t]);return s}}class $e extends pe{constructor(){super(),this.groupMap=new Map}static getInstance(){return $e.instance||($e.instance=new $e),$e.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(l.GRP,"groupList",e);const s=t.TUIStore.getData(l.GRP,"currentGroupID");e.forEach(e=>{e.groupID===s&&t.TUIStore.update(l.GRP,"currentGroup",e)})}onGroupAttributesUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(l.GRP,"currentGroupID");let i=t.TUIStore.getData(l.GRP,"groupList");const{groupID:n,groupAttributes:a}=e;s===n&&t.TUIStore.update(l.GRP,"currentGroupAttributes",a),i=i.map(e=>(e.groupID===n&&(e.groupAttributes=a),e)),t.TUIStore.update(l.GRP,"groupList",i)}onGroupCounterUpdated(e){const t=this.getEngine(),s=t.TUIStore.getData(l.GRP,"currentGroupID"),i=t.TUIStore.getData(l.GRP,"currentGroupCounters")||{};let n=t.TUIStore.getData(l.GRP,"groupList");const{groupID:a,key:r,value:o}=e;s===a&&(i[r]=o,t.TUIStore.update(l.GRP,"currentGroupCounters",i)),n=n.map(e=>(e.groupID===a&&(e.groupCounters=Object.assign(Object.assign({},e.groupCounters),{[r]:o})),e)),t.TUIStore.update(l.GRP,"groupList",n)}onMessageReceived(e){const t=this.getEngine(),s=[];e.forEach(e=>{if(e.type===t.TYPES.MSG_GRP_TIP){const{payload:s}=e,{operationType:i,userIDList:n}=s;switch(i){case t.TYPES.GRP_TIP_MBR_JOIN:this.addMemberList(n);break;case t.TYPES.GRP_TIP_MBR_QUIT:case t.TYPES.GRP_TIP_MBR_KICKED_OUT:this.removeMemberList(n);break;case t.TYPES.GRP_TIP_MBR_SET_ADMIN:case t.TYPES.GRP_TIP_MBR_CANCELED_ADMIN:this.updateGroupMember(n);break;case t.TYPES.GRP_TIP_GRP_PROFILE_UPDATED:break;case t.TYPES.GRP_TIP_MBR_PROFILE_UPDATED:case t.TYPES.GRP_TIP_BAN_AVCHATROOM_MEMBER:case t.TYPES.GRP_TIP_UNBAN_AVCHATROOM_MEMBER:this.updateGroupMember(n)}}e.type===t.TYPES.MSG_GRP_SYS_NOTICE&&s.push(e)}),s.length>0&&t.TUIStore.update(l.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 h(this,void 0,void 0,function*(){const t=this.getEngine().TUIStore.getData(l.GRP,"currentGroupID");if(t){const s=yield this.getGroupMemberProfile({groupID:t,userIDList:e}),{memberList:i}=s.data;this.updateMemberList(i)}})}resetCurrentStore(){this.getEngine().TUIStore.reset(l.GRP,["currentGroupID","currentGroup","currentGroupAttributes","currentGroupCounters","currentGroupMemberList"],!0)}switchGroup(e){return h(this,void 0,void 0,function*(){const t=this.getEngine();t.TUIStore.update(l.GRP,"offset",0),t.TUIStore.update(l.GRP,"isCompleted",!1);const s=t.TUIStore.getConversationModel(`GROUP${e}`);if((null==s?void 0:s.operationType)>0){const e=t.TUIStore.getData(l.GRP,"currentGroup");return Promise.resolve(e)}const i=t.TUIStore.getData(l.GRP,"currentGroupID");if(!e)return this.resetCurrentStore(),Promise.resolve({});if(i===e){const e=t.TUIStore.getData(l.GRP,"currentGroup");return Promise.resolve(e)}this.resetCurrentStore(),t.TUIStore.update(l.GRP,"currentGroupID",e);try{yield this.getGroupInfo(e)}catch(e){Promise.reject(e)}const n=setTimeout(()=>{this.groupMap.delete(e),clearTimeout(n)},5e3),a=t.TUIStore.getData(l.GRP,"currentGroup");return Promise.resolve(a)})}getGroupInfo(e){return h(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(l.GRP,"currentGroup",s.group),t.TUIStore.update(l.GRP,"currentGroupAttributes",s.groupAttributes||{}),void t.TUIStore.update(l.GRP,"currentGroupCounters",s.counters||{});const i={group:{},memberList:[],groupAttributes:void 0,counters:void 0},{data:{group:n}}=yield this.getGroupProfile({groupID:e});i.group=n;const{data:{memberList:a}}=yield this.getGroupMemberList({groupID:e});i.memberList=a;const r=yield this.getGroupAttributes({groupID:e,keyList:[]}),{groupAttributes:o}=r.data;i.groupAttributes=o,t.TUIStore.update(l.GRP,"currentGroupAttributes",o);try{const s=yield this.getGroupCounters({groupID:e,keyList:[]}),{counters:n}=s.data;i.counters=n,t.TUIStore.update(l.GRP,"currentGroupCounters",n)}catch(e){console.warn(null==e?void 0:e.message)}this.groupMap.set(e,i)})}getGroupProfile(e){const t=this.getEngine();return t.chat.getGroupProfile(e).then(s=>h(this,void 0,void 0,function*(){if(t.TUIStore.getData(l.GRP,"currentGroupID")===e.groupID){const{group:e}=s.data;t.TUIStore.update(l.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,i=t.TUIStore.getData(l.GRP,"groupList");return e.data.group.isJoinedGroup=i.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(l.GRP,"currentGroupMemberList")||[]).filter(t=>!e.find(e=>e.userID===t.userID)),...e];t.TUIStore.update(l.GRP,"currentGroupMemberList",s)}addMemberList(e){return h(this,void 0,void 0,function*(){const t=this.getEngine().TUIStore.getData(l.GRP,"currentGroupID");if(t)try{const s=yield this.getGroupMemberProfile({groupID:t,userIDList:e}),{memberList:i}=s.data;this.updateMemberList(i)}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(l.GRP,"currentGroupMemberList").filter(t=>-1===e.indexOf(t.userID));t.TUIStore.update(l.GRP,"currentGroupMemberList",s)}getGroupMemberList(e){const t=this.getEngine();if(R(e.offset)){const s=t.TUIStore.getData(l.GRP,"offset");e.offset=s}return t.chat.getGroupMemberList(e).then(s=>{if(t.TUIStore.getData(l.GRP,"currentGroupID")===e.groupID){const{memberList:e,offset:i=0}=s.data;this.updateMemberList(e),t.TUIStore.update(l.GRP,"offset",i),0===i&&t.TUIStore.update(l.GRP,"isCompleted",!0)}return s})}getGroupMemberProfile(e){return this.getEngine().chat.getGroupMemberProfile(e)}addGroupMember(e){const t=this.getEngine();return t.chat.addGroupMember(e).then(s=>h(this,void 0,void 0,function*(){if(t.TUIStore.getData(l.GRP,"currentGroupID")===e.groupID){const{successUserIDList:e,group:i}=s.data;t.TUIStore.update(l.GRP,"currentGroup",i),this.addMemberList(e)}return s}))}deleteGroupMember(e){const t=this.getEngine();return t.chat.deleteGroupMember(e).then(s=>{if(t.TUIStore.getData(l.GRP,"currentGroupID")===e.groupID){const{userIDList:e,group:i}=s.data;this.removeMemberList(e),t.TUIStore.update(l.GRP,"currentGroup",i)}return s})}setGroupMemberMuteTime(e){return this.getEngine().chat.setGroupMemberMuteTime(e)}setGroupMemberRole(e){return this.getEngine().chat.setGroupMemberRole(e)}setGroupMemberNameCard(e){return this.getEngine().chat.setGroupMemberNameCard(e)}setGroupMemberCustomField(e){return this.getEngine().chat.setGroupMemberCustomField(e)}markGroupMemberList(e){return this.getEngine().chat.markGroupMemberList(e)}}class Ve extends pe{constructor(){super(),this.tobeUpdatedFriendGroupList=void 0}static getInstance(){return Ve.instance||(Ve.instance=new Ve),Ve.instance}init(){const e=this.getEngine();e.eventCenter.addEvent(e.EVENT.FRIEND_LIST_UPDATED,this.onFriendListUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.FRIEND_APPLICATION_LIST_UPDATED,this.onFriendApplicationListUpdated.bind(this)),e.eventCenter.addEvent(e.EVENT.FRIEND_GROUP_LIST_UPDATED,this.onFriendGroupListUpdated.bind(this)),this.getFriendInitData()}onFriendListUpdated(e){this.getEngine().TUIStore.update(l.FRIEND,"friendList",e),this.updatedFriendGroupList(e,this.tobeUpdatedFriendGroupList)}onFriendApplicationListUpdated(e){const{friendApplicationList:t,unreadCount:s=0}=e,i=this.getEngine();i.TUIStore.update(l.FRIEND,"friendApplicationList",t),i.TUIStore.update(l.FRIEND,"friendApplicationUnreadCount",s)}onFriendGroupListUpdated(e){const t=this.getEngine().TUIStore.getData(l.FRIEND,"friendList");t.length>0?this.updatedFriendGroupList(t,e):this.tobeUpdatedFriendGroupList=e}updatedFriendGroupList(e,t){const s=this.getEngine();if(t&&t.length>0){const i=t.map(t=>{const{userIDList:s}=t,i=c(t,["userIDList"]),n=s.map(t=>e.find(e=>e.userID===t));return Object.assign(Object.assign({},i),{friendList:n})});s.TUIStore.update(l.FRIEND,"friendGroupList",i),this.tobeUpdatedFriendGroupList=void 0}}getFriendInitData(){const e=this.getEngine();e.chat.isReady()&&(e.chat.getFriendList().then(e=>{const t=e.data||[];console.log(`TUIFriendService.init, getFriendList count:${t.length}`),t.length>0&&this.onFriendListUpdated(t)}),e.chat.getFriendGroupList().then(e=>{const t=e.data||[];console.log(`TUIFriendService.init, getFriendGroupList count:${t.length}`),t.length>0&&this.onFriendGroupListUpdated(t)}),e.chat.getFriendApplicationList().then(e=>{this.onFriendApplicationListUpdated(e.data)}))}getFriendList(){return this.getEngine().chat.getFriendList()}getFriendRemark(e){const t=this.getEngine().TUIStore.getData(l.FRIEND,"friendList"),s={};return e.forEach(e=>{for(let i=0;i<t.length;i++)t[i].userID!==e||(s[e]=t[i].remark)}),s}addFriend(e){return this.getEngine().chat.addFriend(e)}deleteFriend(e){return this.getEngine().chat.deleteFriend(e)}checkFriend(e){return this.getEngine().chat.checkFriend(e)}getFriendProfile(e){return this.getEngine().chat.getFriendProfile(e)}updateFriend(e){return this.getEngine().chat.updateFriend(e)}acceptFriendApplication(e){return this.getEngine().chat.acceptFriendApplication(e)}refuseFriendApplication(e){return this.getEngine().chat.refuseFriendApplication({userID:e})}deleteFriendApplication(e){return this.getEngine().chat.deleteFriendApplication(e)}setFriendApplicationRead(){return this.getEngine().chat.setFriendApplicationRead()}createFriendGroup(e){return this.getEngine().chat.createFriendGroup(e)}deleteFriendGroup(e){return this.getEngine().chat.deleteFriendGroup({name:e})}addToFriendGroup(e){return this.getEngine().chat.addToFriendGroup(e)}removeFromFriendGroup(e){return this.getEngine().chat.removeFromFriendGroup(e)}renameFriendGroup(e){return this.getEngine().chat.renameFriendGroup(e)}}class Fe extends pe{static getInstance(){return Fe.instance||(Fe.instance=new Fe),Fe.instance}reportFeature(e,t){var s;return null===(s=this.getEngine().chat)||void 0===s?void 0:s.callExperimentalAPI("statTUIKeyFeatures",{code:e,msg:t?`${e}-${t}`:""})}}var He,Ye,Be;!function(e){e.MESSAGE="message",e.CHAT_MESSAGE="chat_message",e.USER="user",e.GROUP="group"}(He||(He={})),function(e){e.MSG_TEXT="TIMTextElem",e.MSG_IMAGE="TIMImageElem",e.MSG_SOUND="TIMSoundElem",e.MSG_FILE="TIMFileElem",e.MSG_VIDEO="TIMVideoFileElem",e.MSG_LOCATION="TIMLocationElem",e.MSG_CUSTOM="TIMCustomElem",e.MSG_MERGER="TIMRelayElem"}(Ye||(Ye={})),function(e){e.GRP_WORK="Private",e.GRP_PUBLIC="Public",e.GRP_MEETING="ChatRoom",e.GRP_COMMUNITY="Community"}(Be||(Be={}));class Ke extends pe{constructor(){super(),this.resultKeyMap={[He.MESSAGE]:"searchMessagesResult",[He.CHAT_MESSAGE]:"searchChatMessagesResult",[He.USER]:"searchUserResult",[He.GROUP]:"searchGroupResult"},this.paramsKeyMap={[He.MESSAGE]:"searchMessageParams",[He.CHAT_MESSAGE]:"searchChatMessageParams",[He.USER]:"searchUserParams",[He.GROUP]:"searchGroupParams"}}static getInstance(){return Ke.instance||(Ke.instance=new Ke),Ke.instance}getStoreData(e,t){return this.getEngine().TUIStore.getData(e,t)}handleSearchResult(e,t){const{resultList:s}=this.getStoreData(l.SEARCH,this.resultKeyMap[e]),{cursor:i,searchResultList:n,params:a,totalCount:r}=t,o=[];if(e===He.CHAT_MESSAGE){const{conversation:e}=s[0]||{},{conversation:t}=n[0]||{};(null==e?void 0:e.conversationID)===(null==t?void 0:t.conversationID)&&1===s.length&&(n[0].messageList=[...s[0].messageList,...n[0].messageList]),o.push(...n)}else o.push(...s,...n);this.getEngine().TUIStore.update(l.SEARCH,this.resultKeyMap[e],{resultList:o,params:a,hasMore:!!i,cursor:i,totalCount:r})}searchParamsValidate(e,t){const s=this.getStoreData(l.SEARCH,this.paramsKeyMap[e]),{cursor:i}=s,n=c(s,["cursor"]),{cursor:a}=t,r=c(t,["cursor"]),o=JSON.stringify(n)===JSON.stringify(r),g=!!a,h=a===i;return o?o&&!g?(this.getEngine().TUIStore.reset(l.SEARCH,[this.resultKeyMap[e]]),this.getEngine().TUIStore.update(l.SEARCH,this.paramsKeyMap[e],t),!0):!(!o||!g||h):(this.getEngine().TUIStore.reset(l.SEARCH,[this.resultKeyMap[e]]),this.getEngine().TUIStore.update(l.SEARCH,this.paramsKeyMap[e],t),!0)}searchCloudMessages(e){const{keyword:t,keywordList:s,conversationID:i}=e,n=c(e,["keyword","keywordList","conversationID"]);let a=!0;if(a=i?this.searchParamsValidate(He.CHAT_MESSAGE,e):this.searchParamsValidate(He.MESSAGE,e),!a)return Promise.resolve();const r=this.getStoreData(l.CONV,"conversationList");return this.getEngine().chat.searchCloudMessages(Object.assign({keywordList:t?[t]:s||void 0,keywordListMatchType:"or",conversationID:i},n)).then(t=>h(this,void 0,void 0,function*(){const{searchResultList:s}=t.data;if((null==s?void 0:s.length)>0){const e=[];if(t.data.searchResultList=s.map(t=>{const{messageList:s,conversationID:i}=t,n=c(t,["messageList","conversationID"]),a=s.map(e=>new Se(e)),o=r.find(e=>e.conversationID===i);return R(o)&&e.push(ye.getInstance().getConversationProfile(i)),Object.assign(Object.assign({},n),{messageList:a.sort((e,t)=>t.time-e.time),conversation:o})}),e.length>0)try{const i=yield Promise.all(e);t.data.searchResultList=s.map(e=>{const{messageList:t,conversationID:s}=e,n=c(e,["messageList","conversationID"]),a=t.map(e=>new Se(e)),{data:{conversation:r}}=i.find(e=>e.data.conversation.conversationID===s),o=new Ie(r);return Object.assign(Object.assign({},n),{messageList:a.sort((e,t)=>t.time-e.time),conversation:o})})}catch(e){console.log("fetch conversation error",e)}}return t.data.params=e,i?this.handleSearchResult(He.CHAT_MESSAGE,t.data):this.handleSearchResult(He.MESSAGE,t.data),t})).catch(e=>(this.getEngine().TUIStore.update(l.SEARCH,"error",e),Promise.reject(e)))}searchCloudUsers(t){const{keyword:s,keywordList:i}=t,n=c(t,["keyword","keywordList"]),a=this.getStoreData(l.FRIEND,"friendList");return this.searchParamsValidate(He.USER,t)?this.getEngine().chat.searchCloudUsers(Object.assign({keywordList:s?[s]:i||void 0,keywordListMatchType:"or"},n)).then(s=>{const{searchResultList:i}=s.data;if(i.length>0){const t=new Map(i.map(t=>[t.userID,{profile:t,relation:e.TYPES.SNS_TYPE_NO_RELATION}]));a.forEach(s=>{const{userID:i}=s,n=t.get(i);n&&(n.relation=e.TYPES.SNS_TYPE_BOTH_WAY)}),s.data.searchResultList=Array.from(t.values())}return s.data.params=t,this.handleSearchResult(He.USER,s.data),s}).catch(e=>(this.getEngine().TUIStore.update(l.SEARCH,"error",e),Promise.reject(e))):Promise.resolve()}searchCloudGroups(e){const{keyword:t,keywordList:s}=e,i=c(e,["keyword","keywordList"]),n=this.getStoreData(l.CONV,"conversationList"),a=this.getStoreData(l.GRP,"groupList");return this.searchParamsValidate(He.GROUP,e)?this.getEngine().chat.searchCloudGroups(Object.assign({keywordList:t?[t]:s||void 0,keywordListMatchType:"or"},i)).then(t=>{const{searchResultList:s}=t.data;return s.length>0&&(t.data.searchResultList=s.map(e=>{const t=a.find(t=>t.groupID===e.groupID),s=n.find(t=>t.conversationID===`GROUP${e.groupID}`);return{groupInfo:t||e,conversation:s}})),t.data.params=e,this.handleSearchResult(He.GROUP,t.data),t}).catch(e=>(this.getEngine().TUIStore.update(l.SEARCH,"error",e),Promise.reject(e))):Promise.resolve()}}class qe{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(e=>e),this.options=e,this.next()}}function ze(e,t,s){const i=Object.create(null);Object.keys(s).forEach(s=>{if(!t[s])return;i[s]=t[s];const n=new qe;t[s]=function(){const a=Array.from(arguments);return n.use((t,i)=>e.isInited?i():Promise.reject({code:m.NOT_INIT,message:`${s} | ${U.NOT_INIT}`})).use(e=>i[s].apply(t,e)),n.run(a)}})}console.log("TUIChatEngine-Lite.VERSION:0.0.1");const We=ue.getInstance(),Je=ge.getInstance(),Xe=De.getInstance(),Ze=Re.getInstance(),Qe=ye.getInstance(),et=Ne.getInstance(),st=we.getInstance(),it=$e.getInstance(),nt=Ve.getInstance(),at=Fe.getInstance(),rt=Ke.getInstance();We.mount(d.TUIStore,Xe),We.mount(d.TUITranslate,Ze),We.mount(d.TUIConversation,Qe),We.mount(d.TUIUser,et),We.mount(d.TUIChat,st),We.mount(d.TUIGroup,it),We.mount(d.TUIFriend,nt),We.mount(d.TUIReport,at),We.mount(d.TUISearch,rt),ze(We,We,M),ze(We,Qe,f),ze(We,st,_),ze(We,it,C),ze(We,et,v),ze(We,nt,D),ze(We,at,M),ze(We,rt,M);export{Be as GroupType,He as ISearchType,Ye as MessageType,l as StoreName,We as TUIChatEngine,st as TUIChatService,Qe as TUIConversationService,nt as TUIFriendService,Je as TUIGlobal,it as TUIGroupService,at as TUIReportService,rt as TUISearchService,Xe as TUIStore,Ze as TUITranslateService,et as TUIUserService,We as default};
|
package/package.json
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tencentcloud/chat-uikit-engine-lite",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Tencent Cloud TUIChatEngine SDK for Chat TUIKit",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"chat",
|
|
9
|
+
"real-time chat",
|
|
10
|
+
"messaging",
|
|
11
|
+
"Instant Messaging",
|
|
12
|
+
"IM",
|
|
13
|
+
"Tencent Cloud",
|
|
14
|
+
"Tencent"
|
|
15
|
+
],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": ""
|
|
19
|
+
},
|
|
20
|
+
"author": "Tencent Cloud Terminal R&D Center",
|
|
21
|
+
"license": "ISC",
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@tencentcloud/lite-chat": "^1.4.1"
|
|
24
|
+
}
|
|
25
|
+
}
|