@servicetitan/titan-chat-ui-common 7.1.2 → 8.0.0
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/CHANGELOG.md +13 -0
- package/dist/hooks/use-customization-chat.js +2 -1
- package/dist/hooks/use-customization-chat.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/models/__mocks__/support-chat.mock.js +13 -12
- package/dist/models/__mocks__/support-chat.mock.js.map +1 -1
- package/dist/models/chat-customizations.js +2 -1
- package/dist/models/chat-customizations.js.map +1 -1
- package/dist/models/file-descriptor.js +2 -1
- package/dist/models/file-descriptor.js.map +1 -1
- package/dist/models/index.d.ts +2 -2
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +1 -2
- package/dist/models/index.js.map +1 -1
- package/dist/models/support-chat.js +37 -41
- package/dist/models/support-chat.js.map +1 -1
- package/dist/stores/__tests__/chat-ui.store.test.js +117 -106
- package/dist/stores/__tests__/chat-ui.store.test.js.map +1 -1
- package/dist/stores/chat-ui-backend-echo.store.js +86 -87
- package/dist/stores/chat-ui-backend-echo.store.js.map +1 -1
- package/dist/stores/chat-ui-backend.store.js +1 -0
- package/dist/stores/chat-ui-backend.store.js.map +1 -1
- package/dist/stores/chat-ui.store.d.ts +2 -2
- package/dist/stores/chat-ui.store.d.ts.map +1 -1
- package/dist/stores/chat-ui.store.js +307 -329
- package/dist/stores/chat-ui.store.js.map +1 -1
- package/dist/stores/index.d.ts +4 -2
- package/dist/stores/index.d.ts.map +1 -1
- package/dist/stores/index.js +2 -1
- package/dist/stores/index.js.map +1 -1
- package/dist/utils/__tests__/text-utils.test.js +33 -14
- package/dist/utils/__tests__/text-utils.test.js.map +1 -1
- package/dist/utils/test-utils.js +5 -5
- package/dist/utils/test-utils.js.map +1 -1
- package/dist/utils/text-utils.js +12 -12
- package/dist/utils/text-utils.js.map +1 -1
- package/package.json +2 -2
- package/src/models/index.ts +2 -2
- package/src/stores/chat-ui.store.ts +1 -3
- package/src/stores/index.ts +3 -3
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,21 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
function _define_property(obj, key, value) {
|
|
2
|
+
if (key in obj) {
|
|
3
|
+
Object.defineProperty(obj, key, {
|
|
4
|
+
value: value,
|
|
5
|
+
enumerable: true,
|
|
6
|
+
configurable: true,
|
|
7
|
+
writable: true
|
|
8
|
+
});
|
|
9
|
+
} else {
|
|
10
|
+
obj[key] = value;
|
|
11
|
+
}
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
function _ts_decorate(decorators, target, key, desc) {
|
|
2
15
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
16
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for
|
|
17
|
+
else for(var i = decorators.length - 1; i >= 0; i--)if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
18
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
}
|
|
7
|
-
|
|
19
|
+
}
|
|
20
|
+
function _ts_metadata(k, v) {
|
|
8
21
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
-
}
|
|
22
|
+
}
|
|
10
23
|
import { EventEmitter } from 'events';
|
|
11
24
|
import { injectable, symbolToken } from '@servicetitan/react-ioc';
|
|
12
25
|
import { action, computed, makeObservable, observable, runInAction } from 'mobx';
|
|
13
26
|
import { nanoid } from 'nanoid';
|
|
14
|
-
import { ChatEndReason, ChatError, ChatMessageState, ChatParticipantIcon, ChatRunState, } from '../models';
|
|
27
|
+
import { ChatConfiguration, ChatEndReason, ChatError, ChatErrorOptions, ChatMessageModelBase, ChatMessageModelFile, ChatMessageState, ChatParticipantIcon, ChatRunState, ChatTimer } from '../models';
|
|
28
|
+
import { FileDescriptor } from '../models/file-descriptor';
|
|
15
29
|
export const symbolAgent = Symbol('SupportChatAgent');
|
|
16
30
|
export const symbolUser = Symbol('SupportChatUser');
|
|
17
|
-
export var ChatUiEvent
|
|
18
|
-
(function (ChatUiEvent) {
|
|
31
|
+
export var ChatUiEvent = /*#__PURE__*/ function(ChatUiEvent) {
|
|
19
32
|
ChatUiEvent["eventRun"] = "eventRun";
|
|
20
33
|
ChatUiEvent["eventDestroy"] = "eventDestroy";
|
|
21
34
|
ChatUiEvent["eventRestart"] = "eventRestart";
|
|
@@ -28,9 +41,10 @@ export var ChatUiEvent;
|
|
|
28
41
|
ChatUiEvent["eventMessageSendRetry"] = "eventMessageSendRetry";
|
|
29
42
|
ChatUiEvent["eventMessageSendFile"] = "eventMessageSendFile";
|
|
30
43
|
ChatUiEvent["eventMessageSendFileRetry"] = "eventMessageSendFileRetry";
|
|
31
|
-
|
|
44
|
+
return ChatUiEvent;
|
|
45
|
+
}({});
|
|
32
46
|
export const CHAT_UI_STORE_TOKEN = symbolToken('CHAT_UI_STORE_TOKEN');
|
|
33
|
-
|
|
47
|
+
export class ChatUiStore {
|
|
34
48
|
get agent() {
|
|
35
49
|
return this.participants[symbolAgent];
|
|
36
50
|
}
|
|
@@ -52,126 +66,6 @@ let ChatUiStore = class ChatUiStore {
|
|
|
52
66
|
get customizations() {
|
|
53
67
|
return this.customizationContext;
|
|
54
68
|
}
|
|
55
|
-
constructor() {
|
|
56
|
-
Object.defineProperty(this, "isAgentTyping", {
|
|
57
|
-
enumerable: true,
|
|
58
|
-
configurable: true,
|
|
59
|
-
writable: true,
|
|
60
|
-
value: false
|
|
61
|
-
});
|
|
62
|
-
Object.defineProperty(this, "status", {
|
|
63
|
-
enumerable: true,
|
|
64
|
-
configurable: true,
|
|
65
|
-
writable: true,
|
|
66
|
-
value: ChatRunState.Offline
|
|
67
|
-
});
|
|
68
|
-
Object.defineProperty(this, "isFilePickerEnabled", {
|
|
69
|
-
enumerable: true,
|
|
70
|
-
configurable: true,
|
|
71
|
-
writable: true,
|
|
72
|
-
value: false
|
|
73
|
-
});
|
|
74
|
-
Object.defineProperty(this, "file", {
|
|
75
|
-
enumerable: true,
|
|
76
|
-
configurable: true,
|
|
77
|
-
writable: true,
|
|
78
|
-
value: void 0
|
|
79
|
-
});
|
|
80
|
-
Object.defineProperty(this, "error", {
|
|
81
|
-
enumerable: true,
|
|
82
|
-
configurable: true,
|
|
83
|
-
writable: true,
|
|
84
|
-
value: void 0
|
|
85
|
-
});
|
|
86
|
-
Object.defineProperty(this, "endReason", {
|
|
87
|
-
enumerable: true,
|
|
88
|
-
configurable: true,
|
|
89
|
-
writable: true,
|
|
90
|
-
value: void 0
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperty(this, "messages", {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
configurable: true,
|
|
95
|
-
writable: true,
|
|
96
|
-
value: []
|
|
97
|
-
});
|
|
98
|
-
Object.defineProperty(this, "currentFileMessage", {
|
|
99
|
-
enumerable: true,
|
|
100
|
-
configurable: true,
|
|
101
|
-
writable: true,
|
|
102
|
-
value: void 0
|
|
103
|
-
});
|
|
104
|
-
Object.defineProperty(this, "scrollCounter", {
|
|
105
|
-
enumerable: true,
|
|
106
|
-
configurable: true,
|
|
107
|
-
writable: true,
|
|
108
|
-
value: 1
|
|
109
|
-
});
|
|
110
|
-
Object.defineProperty(this, "timer", {
|
|
111
|
-
enumerable: true,
|
|
112
|
-
configurable: true,
|
|
113
|
-
writable: true,
|
|
114
|
-
value: void 0
|
|
115
|
-
});
|
|
116
|
-
Object.defineProperty(this, "participants", {
|
|
117
|
-
enumerable: true,
|
|
118
|
-
configurable: true,
|
|
119
|
-
writable: true,
|
|
120
|
-
value: {
|
|
121
|
-
[symbolAgent]: {
|
|
122
|
-
isAgent: true,
|
|
123
|
-
name: 'Agent',
|
|
124
|
-
icon: ChatParticipantIcon.Initials,
|
|
125
|
-
},
|
|
126
|
-
[symbolUser]: {
|
|
127
|
-
isAgent: false,
|
|
128
|
-
name: 'User',
|
|
129
|
-
icon: ChatParticipantIcon.Initials,
|
|
130
|
-
},
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
Object.defineProperty(this, "customizationContext", {
|
|
134
|
-
enumerable: true,
|
|
135
|
-
configurable: true,
|
|
136
|
-
writable: true,
|
|
137
|
-
value: {}
|
|
138
|
-
});
|
|
139
|
-
Object.defineProperty(this, "eventEmitter", {
|
|
140
|
-
enumerable: true,
|
|
141
|
-
configurable: true,
|
|
142
|
-
writable: true,
|
|
143
|
-
value: new EventEmitter()
|
|
144
|
-
});
|
|
145
|
-
Object.defineProperty(this, "incomingMessageSound", {
|
|
146
|
-
enumerable: true,
|
|
147
|
-
configurable: true,
|
|
148
|
-
writable: true,
|
|
149
|
-
value: void 0
|
|
150
|
-
});
|
|
151
|
-
Object.defineProperty(this, "incomingMessageSoundPromise", {
|
|
152
|
-
enumerable: true,
|
|
153
|
-
configurable: true,
|
|
154
|
-
writable: true,
|
|
155
|
-
value: void 0
|
|
156
|
-
});
|
|
157
|
-
Object.defineProperty(this, "on", {
|
|
158
|
-
enumerable: true,
|
|
159
|
-
configurable: true,
|
|
160
|
-
writable: true,
|
|
161
|
-
value: (event, listener) => {
|
|
162
|
-
this.eventEmitter.on(event, listener);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
Object.defineProperty(this, "off", {
|
|
166
|
-
enumerable: true,
|
|
167
|
-
configurable: true,
|
|
168
|
-
writable: true,
|
|
169
|
-
value: (event, listener) => {
|
|
170
|
-
this.eventEmitter.off(event, listener);
|
|
171
|
-
}
|
|
172
|
-
});
|
|
173
|
-
makeObservable(this);
|
|
174
|
-
}
|
|
175
69
|
setCustomizationContext(customizationContext) {
|
|
176
70
|
this.customizationContext = customizationContext !== null && customizationContext !== void 0 ? customizationContext : {};
|
|
177
71
|
this.triggerScroll();
|
|
@@ -247,35 +141,35 @@ let ChatUiStore = class ChatUiStore {
|
|
|
247
141
|
}
|
|
248
142
|
async run(configuration, data) {
|
|
249
143
|
this.configure(configuration);
|
|
250
|
-
if (!this.eventEmitter.listeners(
|
|
144
|
+
if (!this.eventEmitter.listeners("eventRun").length) {
|
|
251
145
|
throw new Error("No listeners for ChatUiEvent.eventRun ('eventRun')");
|
|
252
146
|
}
|
|
253
|
-
await this.emitAsync(
|
|
147
|
+
await this.emitAsync("eventRun", data);
|
|
254
148
|
}
|
|
255
149
|
async recover() {
|
|
256
|
-
await this.emitAsync(
|
|
150
|
+
await this.emitAsync("eventRecover", this.error);
|
|
257
151
|
}
|
|
258
152
|
async destroy() {
|
|
259
153
|
this.reset();
|
|
260
|
-
await this.emitAsync(
|
|
154
|
+
await this.emitAsync("eventDestroy");
|
|
261
155
|
}
|
|
262
156
|
async restart() {
|
|
263
157
|
this.reset();
|
|
264
|
-
await this.emitAsync(
|
|
158
|
+
await this.emitAsync("eventRestart");
|
|
265
159
|
}
|
|
266
160
|
async cancelChat() {
|
|
267
|
-
await this.emitAsync(
|
|
161
|
+
await this.emitAsync("eventCancel");
|
|
268
162
|
}
|
|
269
163
|
async endChat(endReason) {
|
|
270
|
-
await this.emitAsync(
|
|
164
|
+
await this.emitAsync("eventEndChat", endReason);
|
|
271
165
|
}
|
|
272
166
|
async chasitorTyping(isTyping) {
|
|
273
|
-
await this.emitAsync(
|
|
167
|
+
await this.emitAsync("eventChasitorTyping", isTyping);
|
|
274
168
|
}
|
|
275
169
|
async sendMessageText(message) {
|
|
276
170
|
if (this.isFilePickerEnabled && this.file) {
|
|
277
171
|
// Send text message with file
|
|
278
|
-
runInAction(()
|
|
172
|
+
runInAction(()=>{
|
|
279
173
|
this.isFilePickerEnabled = false;
|
|
280
174
|
this.currentFileMessage = this.addMessageFile(this.file);
|
|
281
175
|
});
|
|
@@ -283,11 +177,10 @@ let ChatUiStore = class ChatUiStore {
|
|
|
283
177
|
if (message.trim() !== '') {
|
|
284
178
|
messageModel = this.addMessage(false, message);
|
|
285
179
|
}
|
|
286
|
-
await this.emitAsync(
|
|
180
|
+
await this.emitAsync("eventMessageSendFile", this.currentFileMessage, this.file, messageModel);
|
|
287
181
|
this.setFilePickerEnabled(false);
|
|
288
182
|
this.setFile(undefined);
|
|
289
|
-
}
|
|
290
|
-
else {
|
|
183
|
+
} else {
|
|
291
184
|
// Send plain text message
|
|
292
185
|
await this.sendMessageTextInternal(message);
|
|
293
186
|
}
|
|
@@ -295,17 +188,19 @@ let ChatUiStore = class ChatUiStore {
|
|
|
295
188
|
async sendMessageRetry(messageModel) {
|
|
296
189
|
this.resetError(ChatRunState.Started);
|
|
297
190
|
this.setMessageState(messageModel, ChatMessageState.Delivering);
|
|
298
|
-
await this.emitAsync(
|
|
191
|
+
await this.emitAsync("eventMessageSendRetry", messageModel);
|
|
299
192
|
await this.restartTimers();
|
|
300
193
|
}
|
|
301
194
|
async sendMessageFileRetry(messageModel) {
|
|
302
195
|
this.resetError(ChatRunState.Started);
|
|
303
196
|
this.setMessageState(messageModel, ChatMessageState.Delivering);
|
|
304
|
-
await this.emitAsync(
|
|
197
|
+
await this.emitAsync("eventMessageSendFileRetry", messageModel);
|
|
305
198
|
}
|
|
306
199
|
getParticipant(participantKey) {
|
|
307
200
|
const participant = this.participants[participantKey];
|
|
308
|
-
return {
|
|
201
|
+
return {
|
|
202
|
+
...participant
|
|
203
|
+
};
|
|
309
204
|
}
|
|
310
205
|
addMessage(isAgent, message, data) {
|
|
311
206
|
return this.addMessageInternal({
|
|
@@ -313,18 +208,18 @@ let ChatUiStore = class ChatUiStore {
|
|
|
313
208
|
state: ChatMessageState.Delivering,
|
|
314
209
|
participant: this.getParticipant(isAgent ? symbolAgent : symbolUser),
|
|
315
210
|
data,
|
|
316
|
-
message
|
|
211
|
+
message
|
|
317
212
|
});
|
|
318
213
|
}
|
|
319
214
|
addMessageTimeout() {
|
|
320
|
-
const isNewChat = this.messages.length === 0 || this.messages.every(m
|
|
215
|
+
const isNewChat = this.messages.length === 0 || this.messages.every((m)=>m.type === 'welcome');
|
|
321
216
|
if (isNewChat) {
|
|
322
217
|
return;
|
|
323
218
|
}
|
|
324
219
|
return this.addMessageInternal({
|
|
325
220
|
type: 'timeout',
|
|
326
221
|
participant: this.agent,
|
|
327
|
-
state: ChatMessageState.Delivered
|
|
222
|
+
state: ChatMessageState.Delivered
|
|
328
223
|
});
|
|
329
224
|
}
|
|
330
225
|
addMessageWelcome(message) {
|
|
@@ -332,24 +227,24 @@ let ChatUiStore = class ChatUiStore {
|
|
|
332
227
|
type: 'welcome',
|
|
333
228
|
state: ChatMessageState.Delivered,
|
|
334
229
|
participant: this.getParticipant(symbolAgent),
|
|
335
|
-
message
|
|
230
|
+
message
|
|
336
231
|
});
|
|
337
232
|
}
|
|
338
233
|
addMessageFile(file) {
|
|
339
|
-
var
|
|
234
|
+
var _file_displayName;
|
|
340
235
|
return this.addMessageInternal({
|
|
341
|
-
fileName: (
|
|
236
|
+
fileName: (_file_displayName = file.displayName) !== null && _file_displayName !== void 0 ? _file_displayName : 'attachment',
|
|
342
237
|
type: 'file',
|
|
343
238
|
state: ChatMessageState.Delivering,
|
|
344
|
-
participant: this.user
|
|
239
|
+
participant: this.user
|
|
345
240
|
});
|
|
346
241
|
}
|
|
347
242
|
async restartTimers() {
|
|
348
243
|
this.removeMessageByType('timeout');
|
|
349
|
-
await this.emitAsync(
|
|
244
|
+
await this.emitAsync("eventTimerRestart");
|
|
350
245
|
}
|
|
351
246
|
setMessageState(message, state, data) {
|
|
352
|
-
const foundMessage = this.messages.find(m
|
|
247
|
+
const foundMessage = this.messages.find((m)=>m.id === message.id);
|
|
353
248
|
if (foundMessage) {
|
|
354
249
|
foundMessage.state = state;
|
|
355
250
|
if (data) {
|
|
@@ -375,7 +270,7 @@ let ChatUiStore = class ChatUiStore {
|
|
|
375
270
|
}
|
|
376
271
|
getLastFailedMessages() {
|
|
377
272
|
const result = [];
|
|
378
|
-
for
|
|
273
|
+
for(let i = this.messages.length - 1; i >= 0; i--){
|
|
379
274
|
const message = this.messages[i];
|
|
380
275
|
if (message.type === 'message' && !message.participant.isAgent) {
|
|
381
276
|
if (message.state !== ChatMessageState.Failed) {
|
|
@@ -387,8 +282,8 @@ let ChatUiStore = class ChatUiStore {
|
|
|
387
282
|
return result;
|
|
388
283
|
}
|
|
389
284
|
triggerScroll() {
|
|
390
|
-
setTimeout(()
|
|
391
|
-
runInAction(()
|
|
285
|
+
setTimeout(()=>{
|
|
286
|
+
runInAction(()=>{
|
|
392
287
|
this.scrollCounter++;
|
|
393
288
|
});
|
|
394
289
|
}, 0);
|
|
@@ -397,26 +292,28 @@ let ChatUiStore = class ChatUiStore {
|
|
|
397
292
|
if (!this.eventEmitter.listenerCount(event)) {
|
|
398
293
|
return Promise.resolve(undefined);
|
|
399
294
|
}
|
|
400
|
-
return new Promise((resolve, reject)
|
|
295
|
+
return new Promise((resolve, reject)=>{
|
|
401
296
|
this.eventEmitter.emit(event, resolve, reject, ...args);
|
|
402
297
|
});
|
|
403
298
|
}
|
|
404
299
|
addMessageInternal(message) {
|
|
405
300
|
if (message.type === 'timeout') {
|
|
406
301
|
this.removeMessageByType('timeout'); // Remove previous timeout messages
|
|
302
|
+
} else {
|
|
303
|
+
this.restartTimers().then(()=>{});
|
|
407
304
|
}
|
|
408
|
-
|
|
409
|
-
this.
|
|
410
|
-
|
|
411
|
-
|
|
305
|
+
this.setMessages([
|
|
306
|
+
...this.messages,
|
|
307
|
+
this.createMessage(message)
|
|
308
|
+
]);
|
|
412
309
|
if (message.participant.isAgent) {
|
|
413
|
-
this.beepIncoming().catch(()
|
|
310
|
+
this.beepIncoming().catch(()=>{});
|
|
414
311
|
}
|
|
415
312
|
return this.messages.at(-1);
|
|
416
313
|
}
|
|
417
314
|
removeMessageByType(type) {
|
|
418
|
-
if (this.messages.some(m
|
|
419
|
-
this.setMessages(this.messages.filter(m
|
|
315
|
+
if (this.messages.some((m)=>m.type === type)) {
|
|
316
|
+
this.setMessages(this.messages.filter((m)=>m.type !== type));
|
|
420
317
|
}
|
|
421
318
|
}
|
|
422
319
|
async sendMessageTextInternal(message) {
|
|
@@ -424,13 +321,13 @@ let ChatUiStore = class ChatUiStore {
|
|
|
424
321
|
return;
|
|
425
322
|
}
|
|
426
323
|
const messageModel = this.addMessage(false, message);
|
|
427
|
-
await this.emitAsync(
|
|
324
|
+
await this.emitAsync("eventMessageSend", messageModel);
|
|
428
325
|
}
|
|
429
326
|
createMessage(rest) {
|
|
430
327
|
return {
|
|
431
328
|
id: nanoid(),
|
|
432
329
|
timestamp: new Date(),
|
|
433
|
-
...rest
|
|
330
|
+
...rest
|
|
434
331
|
};
|
|
435
332
|
}
|
|
436
333
|
async beepIncoming() {
|
|
@@ -438,258 +335,339 @@ let ChatUiStore = class ChatUiStore {
|
|
|
438
335
|
return;
|
|
439
336
|
}
|
|
440
337
|
try {
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
}
|
|
338
|
+
var _this_incomingMessageSoundPromise;
|
|
339
|
+
(_this_incomingMessageSoundPromise = this.incomingMessageSoundPromise) !== null && _this_incomingMessageSoundPromise !== void 0 ? _this_incomingMessageSoundPromise : this.incomingMessageSoundPromise = this.incomingMessageSound.play();
|
|
444
340
|
await this.incomingMessageSoundPromise;
|
|
445
|
-
}
|
|
446
|
-
finally {
|
|
341
|
+
} finally{
|
|
447
342
|
this.incomingMessageSoundPromise = undefined;
|
|
448
343
|
}
|
|
449
344
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
345
|
+
constructor(){
|
|
346
|
+
_define_property(this, "isAgentTyping", false);
|
|
347
|
+
_define_property(this, "status", ChatRunState.Offline);
|
|
348
|
+
_define_property(this, "isFilePickerEnabled", false);
|
|
349
|
+
_define_property(this, "file", void 0);
|
|
350
|
+
_define_property(this, "error", void 0);
|
|
351
|
+
_define_property(this, "endReason", void 0);
|
|
352
|
+
_define_property(this, "messages", []);
|
|
353
|
+
_define_property(this, "currentFileMessage", void 0);
|
|
354
|
+
_define_property(this, "scrollCounter", 1);
|
|
355
|
+
_define_property(this, "timer", void 0);
|
|
356
|
+
_define_property(this, "participants", {
|
|
357
|
+
[symbolAgent]: {
|
|
358
|
+
isAgent: true,
|
|
359
|
+
name: 'Agent',
|
|
360
|
+
icon: ChatParticipantIcon.Initials
|
|
361
|
+
},
|
|
362
|
+
[symbolUser]: {
|
|
363
|
+
isAgent: false,
|
|
364
|
+
name: 'User',
|
|
365
|
+
icon: ChatParticipantIcon.Initials
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
_define_property(this, "customizationContext", {});
|
|
369
|
+
_define_property(this, "eventEmitter", new EventEmitter());
|
|
370
|
+
_define_property(this, "incomingMessageSound", void 0);
|
|
371
|
+
_define_property(this, "incomingMessageSoundPromise", void 0);
|
|
372
|
+
_define_property(this, "on", (event, listener)=>{
|
|
373
|
+
this.eventEmitter.on(event, listener);
|
|
374
|
+
});
|
|
375
|
+
_define_property(this, "off", (event, listener)=>{
|
|
376
|
+
this.eventEmitter.off(event, listener);
|
|
377
|
+
});
|
|
378
|
+
makeObservable(this);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
_ts_decorate([
|
|
382
|
+
observable
|
|
454
383
|
], ChatUiStore.prototype, "isAgentTyping", void 0);
|
|
455
|
-
|
|
456
|
-
observable
|
|
457
|
-
__metadata("design:type", Object)
|
|
384
|
+
_ts_decorate([
|
|
385
|
+
observable
|
|
458
386
|
], ChatUiStore.prototype, "status", void 0);
|
|
459
|
-
|
|
460
|
-
observable
|
|
461
|
-
__metadata("design:type", Object)
|
|
387
|
+
_ts_decorate([
|
|
388
|
+
observable
|
|
462
389
|
], ChatUiStore.prototype, "isFilePickerEnabled", void 0);
|
|
463
|
-
|
|
390
|
+
_ts_decorate([
|
|
464
391
|
observable,
|
|
465
|
-
|
|
392
|
+
_ts_metadata("design:type", typeof FileDescriptor === "undefined" ? Object : FileDescriptor)
|
|
466
393
|
], ChatUiStore.prototype, "file", void 0);
|
|
467
|
-
|
|
394
|
+
_ts_decorate([
|
|
468
395
|
observable.ref,
|
|
469
|
-
|
|
396
|
+
_ts_metadata("design:type", typeof ChatError === "undefined" ? Object : ChatError)
|
|
470
397
|
], ChatUiStore.prototype, "error", void 0);
|
|
471
|
-
|
|
398
|
+
_ts_decorate([
|
|
472
399
|
observable,
|
|
473
|
-
|
|
400
|
+
_ts_metadata("design:type", typeof ChatEndReason === "undefined" ? Object : ChatEndReason)
|
|
474
401
|
], ChatUiStore.prototype, "endReason", void 0);
|
|
475
|
-
|
|
402
|
+
_ts_decorate([
|
|
476
403
|
observable,
|
|
477
|
-
|
|
404
|
+
_ts_metadata("design:type", Array)
|
|
478
405
|
], ChatUiStore.prototype, "messages", void 0);
|
|
479
|
-
|
|
406
|
+
_ts_decorate([
|
|
480
407
|
observable,
|
|
481
|
-
|
|
408
|
+
_ts_metadata("design:type", typeof ChatMessageModelFile === "undefined" ? Object : ChatMessageModelFile)
|
|
482
409
|
], ChatUiStore.prototype, "currentFileMessage", void 0);
|
|
483
|
-
|
|
484
|
-
observable
|
|
485
|
-
__metadata("design:type", Object)
|
|
410
|
+
_ts_decorate([
|
|
411
|
+
observable
|
|
486
412
|
], ChatUiStore.prototype, "scrollCounter", void 0);
|
|
487
|
-
|
|
413
|
+
_ts_decorate([
|
|
488
414
|
observable,
|
|
489
|
-
|
|
415
|
+
_ts_metadata("design:type", typeof ChatTimer === "undefined" ? Object : ChatTimer)
|
|
490
416
|
], ChatUiStore.prototype, "timer", void 0);
|
|
491
|
-
|
|
417
|
+
_ts_decorate([
|
|
492
418
|
observable,
|
|
493
|
-
|
|
419
|
+
_ts_metadata("design:type", Object)
|
|
494
420
|
], ChatUiStore.prototype, "participants", void 0);
|
|
495
|
-
|
|
421
|
+
_ts_decorate([
|
|
496
422
|
computed,
|
|
497
|
-
|
|
498
|
-
|
|
423
|
+
_ts_metadata("design:type", void 0),
|
|
424
|
+
_ts_metadata("design:paramtypes", [])
|
|
499
425
|
], ChatUiStore.prototype, "agent", null);
|
|
500
|
-
|
|
426
|
+
_ts_decorate([
|
|
501
427
|
computed,
|
|
502
|
-
|
|
503
|
-
|
|
428
|
+
_ts_metadata("design:type", void 0),
|
|
429
|
+
_ts_metadata("design:paramtypes", [])
|
|
504
430
|
], ChatUiStore.prototype, "user", null);
|
|
505
|
-
|
|
431
|
+
_ts_decorate([
|
|
506
432
|
computed,
|
|
507
|
-
|
|
508
|
-
|
|
433
|
+
_ts_metadata("design:type", void 0),
|
|
434
|
+
_ts_metadata("design:paramtypes", [])
|
|
509
435
|
], ChatUiStore.prototype, "isStarted", null);
|
|
510
|
-
|
|
436
|
+
_ts_decorate([
|
|
511
437
|
computed,
|
|
512
|
-
|
|
513
|
-
|
|
438
|
+
_ts_metadata("design:type", void 0),
|
|
439
|
+
_ts_metadata("design:paramtypes", [])
|
|
514
440
|
], ChatUiStore.prototype, "isError", null);
|
|
515
|
-
|
|
441
|
+
_ts_decorate([
|
|
516
442
|
computed,
|
|
517
|
-
|
|
518
|
-
|
|
443
|
+
_ts_metadata("design:type", void 0),
|
|
444
|
+
_ts_metadata("design:paramtypes", [])
|
|
519
445
|
], ChatUiStore.prototype, "isEnded", null);
|
|
520
|
-
|
|
446
|
+
_ts_decorate([
|
|
521
447
|
computed,
|
|
522
|
-
|
|
523
|
-
|
|
448
|
+
_ts_metadata("design:type", void 0),
|
|
449
|
+
_ts_metadata("design:paramtypes", [])
|
|
524
450
|
], ChatUiStore.prototype, "isStarting", null);
|
|
525
|
-
|
|
451
|
+
_ts_decorate([
|
|
526
452
|
computed,
|
|
527
|
-
|
|
528
|
-
|
|
453
|
+
_ts_metadata("design:type", void 0),
|
|
454
|
+
_ts_metadata("design:paramtypes", [])
|
|
529
455
|
], ChatUiStore.prototype, "customizations", null);
|
|
530
|
-
|
|
456
|
+
_ts_decorate([
|
|
531
457
|
observable,
|
|
532
|
-
|
|
458
|
+
_ts_metadata("design:type", typeof T === "undefined" ? Object : T)
|
|
533
459
|
], ChatUiStore.prototype, "customizationContext", void 0);
|
|
534
|
-
|
|
460
|
+
_ts_decorate([
|
|
535
461
|
action,
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
462
|
+
_ts_metadata("design:type", Function),
|
|
463
|
+
_ts_metadata("design:paramtypes", [
|
|
464
|
+
typeof T === "undefined" ? Object : T
|
|
465
|
+
]),
|
|
466
|
+
_ts_metadata("design:returntype", void 0)
|
|
539
467
|
], ChatUiStore.prototype, "setCustomizationContext", null);
|
|
540
|
-
|
|
468
|
+
_ts_decorate([
|
|
541
469
|
action,
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
470
|
+
_ts_metadata("design:type", Function),
|
|
471
|
+
_ts_metadata("design:paramtypes", [
|
|
472
|
+
typeof FileDescriptor === "undefined" ? Object : FileDescriptor
|
|
473
|
+
]),
|
|
474
|
+
_ts_metadata("design:returntype", void 0)
|
|
545
475
|
], ChatUiStore.prototype, "setFile", null);
|
|
546
|
-
|
|
476
|
+
_ts_decorate([
|
|
547
477
|
action,
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
478
|
+
_ts_metadata("design:type", Function),
|
|
479
|
+
_ts_metadata("design:paramtypes", [
|
|
480
|
+
Boolean
|
|
481
|
+
]),
|
|
482
|
+
_ts_metadata("design:returntype", void 0)
|
|
551
483
|
], ChatUiStore.prototype, "setFilePickerEnabled", null);
|
|
552
|
-
|
|
484
|
+
_ts_decorate([
|
|
553
485
|
action,
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
486
|
+
_ts_metadata("design:type", Function),
|
|
487
|
+
_ts_metadata("design:paramtypes", [
|
|
488
|
+
typeof ChatTimer === "undefined" ? Object : ChatTimer
|
|
489
|
+
]),
|
|
490
|
+
_ts_metadata("design:returntype", void 0)
|
|
557
491
|
], ChatUiStore.prototype, "setTimer", null);
|
|
558
|
-
|
|
492
|
+
_ts_decorate([
|
|
559
493
|
action,
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
494
|
+
_ts_metadata("design:type", Function),
|
|
495
|
+
_ts_metadata("design:paramtypes", [
|
|
496
|
+
typeof ChatRunState === "undefined" ? Object : ChatRunState
|
|
497
|
+
]),
|
|
498
|
+
_ts_metadata("design:returntype", void 0)
|
|
563
499
|
], ChatUiStore.prototype, "resetError", null);
|
|
564
|
-
|
|
500
|
+
_ts_decorate([
|
|
565
501
|
action,
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
502
|
+
_ts_metadata("design:type", Function),
|
|
503
|
+
_ts_metadata("design:paramtypes", [
|
|
504
|
+
typeof ChatError === "undefined" ? Object : ChatError
|
|
505
|
+
]),
|
|
506
|
+
_ts_metadata("design:returntype", void 0)
|
|
569
507
|
], ChatUiStore.prototype, "setChatError", null);
|
|
570
|
-
|
|
508
|
+
_ts_decorate([
|
|
571
509
|
action,
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
510
|
+
_ts_metadata("design:type", Function),
|
|
511
|
+
_ts_metadata("design:paramtypes", [
|
|
512
|
+
String,
|
|
513
|
+
typeof ChatErrorOptions === "undefined" ? Object : ChatErrorOptions
|
|
514
|
+
]),
|
|
515
|
+
_ts_metadata("design:returntype", void 0)
|
|
575
516
|
], ChatUiStore.prototype, "setError", null);
|
|
576
|
-
|
|
517
|
+
_ts_decorate([
|
|
577
518
|
action,
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
519
|
+
_ts_metadata("design:type", Function),
|
|
520
|
+
_ts_metadata("design:paramtypes", [
|
|
521
|
+
typeof ChatRunState === "undefined" ? Object : ChatRunState
|
|
522
|
+
]),
|
|
523
|
+
_ts_metadata("design:returntype", void 0)
|
|
581
524
|
], ChatUiStore.prototype, "setStatus", null);
|
|
582
|
-
|
|
525
|
+
_ts_decorate([
|
|
583
526
|
action,
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
527
|
+
_ts_metadata("design:type", Function),
|
|
528
|
+
_ts_metadata("design:paramtypes", [
|
|
529
|
+
Array
|
|
530
|
+
]),
|
|
531
|
+
_ts_metadata("design:returntype", void 0)
|
|
587
532
|
], ChatUiStore.prototype, "setMessages", null);
|
|
588
|
-
|
|
533
|
+
_ts_decorate([
|
|
589
534
|
action,
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
535
|
+
_ts_metadata("design:type", Function),
|
|
536
|
+
_ts_metadata("design:paramtypes", [
|
|
537
|
+
String
|
|
538
|
+
]),
|
|
539
|
+
_ts_metadata("design:returntype", void 0)
|
|
593
540
|
], ChatUiStore.prototype, "setAgentName", null);
|
|
594
|
-
|
|
541
|
+
_ts_decorate([
|
|
595
542
|
action,
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
543
|
+
_ts_metadata("design:type", Function),
|
|
544
|
+
_ts_metadata("design:paramtypes", [
|
|
545
|
+
typeof ChatParticipantIcon === "undefined" ? Object : ChatParticipantIcon
|
|
546
|
+
]),
|
|
547
|
+
_ts_metadata("design:returntype", void 0)
|
|
599
548
|
], ChatUiStore.prototype, "setAgentIcon", null);
|
|
600
|
-
|
|
549
|
+
_ts_decorate([
|
|
601
550
|
action,
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
551
|
+
_ts_metadata("design:type", Function),
|
|
552
|
+
_ts_metadata("design:paramtypes", [
|
|
553
|
+
Boolean
|
|
554
|
+
]),
|
|
555
|
+
_ts_metadata("design:returntype", void 0)
|
|
605
556
|
], ChatUiStore.prototype, "setAgentTyping", null);
|
|
606
|
-
|
|
557
|
+
_ts_decorate([
|
|
607
558
|
action,
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
559
|
+
_ts_metadata("design:type", Function),
|
|
560
|
+
_ts_metadata("design:paramtypes", [
|
|
561
|
+
typeof ChatEndReason === "undefined" ? Object : ChatEndReason
|
|
562
|
+
]),
|
|
563
|
+
_ts_metadata("design:returntype", void 0)
|
|
611
564
|
], ChatUiStore.prototype, "setEndReason", null);
|
|
612
|
-
|
|
565
|
+
_ts_decorate([
|
|
613
566
|
action,
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
567
|
+
_ts_metadata("design:type", Function),
|
|
568
|
+
_ts_metadata("design:paramtypes", [
|
|
569
|
+
typeof ChatEndReason === "undefined" ? Object : ChatEndReason
|
|
570
|
+
]),
|
|
571
|
+
_ts_metadata("design:returntype", void 0)
|
|
617
572
|
], ChatUiStore.prototype, "setEndedChatState", null);
|
|
618
|
-
|
|
573
|
+
_ts_decorate([
|
|
619
574
|
action,
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
575
|
+
_ts_metadata("design:type", Function),
|
|
576
|
+
_ts_metadata("design:paramtypes", [
|
|
577
|
+
typeof ChatConfiguration === "undefined" ? Object : ChatConfiguration
|
|
578
|
+
]),
|
|
579
|
+
_ts_metadata("design:returntype", void 0)
|
|
623
580
|
], ChatUiStore.prototype, "configure", null);
|
|
624
|
-
|
|
581
|
+
_ts_decorate([
|
|
625
582
|
action,
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
583
|
+
_ts_metadata("design:type", Function),
|
|
584
|
+
_ts_metadata("design:paramtypes", [
|
|
585
|
+
String
|
|
586
|
+
]),
|
|
587
|
+
_ts_metadata("design:returntype", Promise)
|
|
629
588
|
], ChatUiStore.prototype, "sendMessageText", null);
|
|
630
|
-
|
|
589
|
+
_ts_decorate([
|
|
631
590
|
action,
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
591
|
+
_ts_metadata("design:type", Function),
|
|
592
|
+
_ts_metadata("design:paramtypes", [
|
|
593
|
+
typeof ChatMessageModelBase === "undefined" ? Object : ChatMessageModelBase
|
|
594
|
+
]),
|
|
595
|
+
_ts_metadata("design:returntype", Promise)
|
|
635
596
|
], ChatUiStore.prototype, "sendMessageRetry", null);
|
|
636
|
-
|
|
597
|
+
_ts_decorate([
|
|
637
598
|
action,
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
599
|
+
_ts_metadata("design:type", Function),
|
|
600
|
+
_ts_metadata("design:paramtypes", [
|
|
601
|
+
typeof ChatMessageModelFile === "undefined" ? Object : ChatMessageModelFile
|
|
602
|
+
]),
|
|
603
|
+
_ts_metadata("design:returntype", Promise)
|
|
641
604
|
], ChatUiStore.prototype, "sendMessageFileRetry", null);
|
|
642
|
-
|
|
605
|
+
_ts_decorate([
|
|
643
606
|
action,
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
607
|
+
_ts_metadata("design:type", Function),
|
|
608
|
+
_ts_metadata("design:paramtypes", [
|
|
609
|
+
Boolean,
|
|
610
|
+
String,
|
|
611
|
+
Object
|
|
612
|
+
]),
|
|
613
|
+
_ts_metadata("design:returntype", void 0)
|
|
647
614
|
], ChatUiStore.prototype, "addMessage", null);
|
|
648
|
-
|
|
615
|
+
_ts_decorate([
|
|
649
616
|
action,
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
617
|
+
_ts_metadata("design:type", Function),
|
|
618
|
+
_ts_metadata("design:paramtypes", []),
|
|
619
|
+
_ts_metadata("design:returntype", void 0)
|
|
653
620
|
], ChatUiStore.prototype, "addMessageTimeout", null);
|
|
654
|
-
|
|
621
|
+
_ts_decorate([
|
|
655
622
|
action,
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
623
|
+
_ts_metadata("design:type", Function),
|
|
624
|
+
_ts_metadata("design:paramtypes", [
|
|
625
|
+
String
|
|
626
|
+
]),
|
|
627
|
+
_ts_metadata("design:returntype", void 0)
|
|
659
628
|
], ChatUiStore.prototype, "addMessageWelcome", null);
|
|
660
|
-
|
|
629
|
+
_ts_decorate([
|
|
661
630
|
action,
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
631
|
+
_ts_metadata("design:type", Function),
|
|
632
|
+
_ts_metadata("design:paramtypes", [
|
|
633
|
+
typeof FileDescriptor === "undefined" ? Object : FileDescriptor
|
|
634
|
+
]),
|
|
635
|
+
_ts_metadata("design:returntype", void 0)
|
|
665
636
|
], ChatUiStore.prototype, "addMessageFile", null);
|
|
666
|
-
|
|
637
|
+
_ts_decorate([
|
|
667
638
|
action,
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
639
|
+
_ts_metadata("design:type", Function),
|
|
640
|
+
_ts_metadata("design:paramtypes", []),
|
|
641
|
+
_ts_metadata("design:returntype", Promise)
|
|
671
642
|
], ChatUiStore.prototype, "restartTimers", null);
|
|
672
|
-
|
|
643
|
+
_ts_decorate([
|
|
673
644
|
action,
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
645
|
+
_ts_metadata("design:type", Function),
|
|
646
|
+
_ts_metadata("design:paramtypes", [
|
|
647
|
+
typeof ChatMessageModelBase === "undefined" ? Object : ChatMessageModelBase,
|
|
648
|
+
typeof ChatMessageState === "undefined" ? Object : ChatMessageState,
|
|
649
|
+
Object
|
|
650
|
+
]),
|
|
651
|
+
_ts_metadata("design:returntype", void 0)
|
|
677
652
|
], ChatUiStore.prototype, "setMessageState", null);
|
|
678
|
-
|
|
653
|
+
_ts_decorate([
|
|
679
654
|
action,
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
655
|
+
_ts_metadata("design:type", Function),
|
|
656
|
+
_ts_metadata("design:paramtypes", []),
|
|
657
|
+
_ts_metadata("design:returntype", void 0)
|
|
683
658
|
], ChatUiStore.prototype, "resetFile", null);
|
|
684
|
-
|
|
659
|
+
_ts_decorate([
|
|
685
660
|
action,
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
661
|
+
_ts_metadata("design:type", Function),
|
|
662
|
+
_ts_metadata("design:paramtypes", [
|
|
663
|
+
void 0
|
|
664
|
+
]),
|
|
665
|
+
_ts_metadata("design:returntype", void 0)
|
|
689
666
|
], ChatUiStore.prototype, "reset", null);
|
|
690
|
-
ChatUiStore =
|
|
667
|
+
ChatUiStore = _ts_decorate([
|
|
691
668
|
injectable(),
|
|
692
|
-
|
|
669
|
+
_ts_metadata("design:type", Function),
|
|
670
|
+
_ts_metadata("design:paramtypes", [])
|
|
693
671
|
], ChatUiStore);
|
|
694
|
-
|
|
672
|
+
|
|
695
673
|
//# sourceMappingURL=chat-ui.store.js.map
|