@carbon/ai-chat 0.1.1-alpha5 → 0.1.1-react17

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.
Files changed (75) hide show
  1. package/dist/App.js +933 -55468
  2. package/dist/Carousel.js +1 -5705
  3. package/dist/Chat.js +1 -8339
  4. package/dist/GenesysMessengerServiceDesk.js +1 -579
  5. package/dist/HumanAgentServiceImpl.js +1 -1122
  6. package/dist/NiceDFOServiceDesk.js +2 -2097
  7. package/dist/PDFViewerContainer.js +2 -27439
  8. package/dist/SFServiceDesk.js +1 -1012
  9. package/dist/ServiceDeskImpl.js +1 -72
  10. package/dist/ZendeskServiceDesk.js +1 -649
  11. package/dist/_commonjsHelpers.js +1 -33
  12. package/dist/_node-resolve_empty.js +1 -25
  13. package/dist/agentActions.js +1 -187
  14. package/dist/aiChatEntry.js +1 -28
  15. package/dist/aiChatEntry2.js +4 -7022
  16. package/dist/anonymousUserIDStorage.js +2 -250
  17. package/dist/ar-dz.js +1 -55
  18. package/dist/ar-kw.js +1 -55
  19. package/dist/ar-ly.js +1 -55
  20. package/dist/ar-ma.js +1 -55
  21. package/dist/ar-sa.js +1 -55
  22. package/dist/ar-tn.js +1 -55
  23. package/dist/ar.js +1 -55
  24. package/dist/ar2.js +1 -470
  25. package/dist/cs.js +1 -55
  26. package/dist/cs2.js +1 -470
  27. package/dist/de-at.js +1 -55
  28. package/dist/de-ch.js +1 -55
  29. package/dist/de.js +1 -55
  30. package/dist/de2.js +1 -470
  31. package/dist/domUtils.js +2 -820
  32. package/dist/en-au.js +1 -55
  33. package/dist/en-ca.js +1 -55
  34. package/dist/en-gb.js +1 -55
  35. package/dist/en-ie.js +1 -55
  36. package/dist/en-il.js +1 -55
  37. package/dist/en-nz.js +1 -55
  38. package/dist/es-do.js +1 -55
  39. package/dist/es-us.js +1 -55
  40. package/dist/es.js +1 -55
  41. package/dist/es2.js +1 -470
  42. package/dist/export.js +1 -25
  43. package/dist/export.legacy.js +1 -25
  44. package/dist/fontUtils.js +1 -1036
  45. package/dist/fr-ca.js +1 -55
  46. package/dist/fr-ch.js +1 -55
  47. package/dist/fr.js +1 -55
  48. package/dist/fr2.js +1 -470
  49. package/dist/humanAgentUtils.js +1 -1393
  50. package/dist/it-ch.js +1 -55
  51. package/dist/it.js +1 -55
  52. package/dist/it2.js +1 -470
  53. package/dist/ja.js +1 -55
  54. package/dist/ja2.js +1 -470
  55. package/dist/jstz.min.js +1 -41
  56. package/dist/ko.js +1 -55
  57. package/dist/ko2.js +1 -470
  58. package/dist/messageUtils.js +1 -1338
  59. package/dist/mockServiceDesk.js +1 -851
  60. package/dist/moduleFederationPluginUtils.js +2 -5852
  61. package/dist/nl.js +1 -55
  62. package/dist/nl2.js +1 -470
  63. package/dist/pt-br.js +1 -55
  64. package/dist/pt-br2.js +1 -470
  65. package/dist/pt.js +1 -55
  66. package/dist/render.js +1 -88
  67. package/dist/web-components/cds-aichat-container/index.js +3 -3
  68. package/dist/web-components/cds-aichat-container/index.js.map +1 -1
  69. package/dist/web-components/cds-aichat-custom-element/index.js +2 -2
  70. package/dist/web-components/cds-aichat-custom-element/index.js.map +1 -1
  71. package/dist/zh-cn.js +1 -55
  72. package/dist/zh-tw.js +1 -55
  73. package/dist/zh-tw2.js +1 -470
  74. package/dist/zh.js +1 -470
  75. package/package.json +1 -1
@@ -1,1338 +1 @@
1
- /*
2
-
3
-
4
- (C) Copyright IBM Corp. 2017, 2024. All Rights Reserved.
5
-
6
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7
- in compliance with the License. You may obtain a copy of the License at
8
-
9
- http://www.apache.org/licenses/LICENSE-2.0
10
-
11
- Unless required by applicable law or agreed to in writing, software distributed under the License
12
- is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13
- or implied. See the License for the specific language governing permissions and limitations under
14
- the License.
15
-
16
- @carbon/ai-chat 0.1.1-alpha5
17
-
18
- Built: Oct 24 2024 10:59 am -04:00
19
-
20
-
21
-
22
- */
23
- import { a3 as MessageInputType, p as MessageResponseTypes, k as deepFreeze, u as uuid, U as UUIDType, l as cloneDeep, m as merge, Q as FileStatusValue } from './aiChatEntry2.js';
24
-
25
- /**
26
- *
27
- * IBM Confidential
28
- *
29
- * (C) Copyright IBM Corp. 2024
30
- *
31
- * The source code for this program is not published or otherwise
32
- * divested of its trade secrets, irrespective of what has been
33
- * deposited with the U. S. Copyright Office
34
- *
35
- * US Government Users Restricted Rights - Use, duplication or
36
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
37
- *
38
- */
39
- /**
40
- * This file contains the generic types for the API between a general chat widget and a chat back-end. It is
41
- * intended to provide base types for a standalone widget and should not contain any imports of other types. This file
42
- * is the same as wa-types-chat.ts except that contains extensions beyond the watsonx Assistant store API.
43
- */
44
- const EVENT_NAME_UPDATE_HISTORY = 'update_history';
45
-
46
- /**
47
- *
48
- * IBM Confidential
49
- *
50
- * (C) Copyright IBM Corp. 2024
51
- *
52
- * The source code for this program is not published or otherwise
53
- * divested of its trade secrets, irrespective of what has been
54
- * deposited with the U. S. Copyright Office
55
- *
56
- * US Government Users Restricted Rights - Use, duplication or
57
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
58
- *
59
- */
60
- var ButtonItemKind;
61
- (function (ButtonItemKind) {
62
- ButtonItemKind["DEFAULT"] = "default";
63
- ButtonItemKind["SECONDARY"] = "secondary";
64
- ButtonItemKind["TERTIARY"] = "tertiary";
65
- ButtonItemKind["DANGER"] = "danger";
66
- ButtonItemKind["LINK"] = "link";
67
- })(ButtonItemKind || (ButtonItemKind = {}));
68
- var ButtonItemType;
69
- (function (ButtonItemType) {
70
- ButtonItemType["POST_BACK"] = "post_back";
71
- ButtonItemType["CUSTOM_EVENT"] = "custom_event";
72
- ButtonItemType["SHOW_PANEL"] = "show_panel";
73
- ButtonItemType["URL"] = "url";
74
- })(ButtonItemType || (ButtonItemType = {}));
75
-
76
- /**
77
- *
78
- * IBM Confidential
79
- *
80
- * (C) Copyright IBM Corp. 2024
81
- *
82
- * The source code for this program is not published or otherwise
83
- * divested of its trade secrets, irrespective of what has been
84
- * deposited with the U. S. Copyright Office
85
- *
86
- * US Government Users Restricted Rights - Use, duplication or
87
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
88
- *
89
- */
90
- /**
91
- * Represents the different states for the availability of a human agent from a service desk.
92
- */
93
- var AgentsOnlineStatus;
94
- (function (AgentsOnlineStatus) {
95
- /**
96
- * Indicates that agents are online.
97
- */
98
- AgentsOnlineStatus["ONLINE"] = "online";
99
- /**
100
- * Indicates that no agents are online.
101
- */
102
- AgentsOnlineStatus["OFFLINE"] = "offline";
103
- /**
104
- * Indicates that it is unknown whether any agents are available. This may be because the service desk being used
105
- * doesn't support the ability to determine this information.
106
- */
107
- AgentsOnlineStatus["UNKNOWN"] = "unknown";
108
- })(AgentsOnlineStatus || (AgentsOnlineStatus = {}));
109
- /**
110
- * The possible state changes for a screen sharing request.
111
- */
112
- var ScreenShareState;
113
- (function (ScreenShareState) {
114
- /**
115
- * Indicates the screen sharing was accepted by the user.
116
- */
117
- ScreenShareState["ACCEPTED"] = "accepted";
118
- /**
119
- * Indicates the screen sharing was declined by the user.
120
- */
121
- ScreenShareState["DECLINED"] = "declined";
122
- /**
123
- * Indicates the screen sharing request was cancelled.
124
- */
125
- ScreenShareState["CANCELLED"] = "cancelled";
126
- /**
127
- * Indicates that screen sharing has ended.
128
- */
129
- ScreenShareState["ENDED"] = "ended";
130
- })(ScreenShareState || (ScreenShareState = {}));
131
- /**
132
- * The possible events that may have some form of error status.
133
- */
134
- var ErrorType;
135
- (function (ErrorType) {
136
- /**
137
- * This error is meant to be displayed while the user is attempting to connect to a service desk and before an
138
- * agent has joined. If this error is generated by the service desk, it is expected that the service desk will
139
- * treat the chat as having ended (or never started).
140
- */
141
- ErrorType[ErrorType["CONNECTING"] = 1] = "CONNECTING";
142
- /**
143
- * This is used to indicate the state of errors that can happen any time during a chat where the service desk
144
- * implementation has lost a connection to the back-end. If this error occurs while the user is waiting for an
145
- * agent to join, it will be treated as a {@link CONNECTING} error instead.
146
- */
147
- ErrorType[ErrorType["DISCONNECTED"] = 2] = "DISCONNECTED";
148
- /**
149
- * This error is used to report when there was an error sending a message to the agent.
150
- */
151
- ErrorType[ErrorType["USER_MESSAGE"] = 3] = "USER_MESSAGE";
152
- })(ErrorType || (ErrorType = {}));
153
- /**
154
- * These are the human agent specific message types.
155
- */
156
- var AgentMessageType;
157
- (function (AgentMessageType) {
158
- AgentMessageType["INLINE_ERROR"] = "inline_error";
159
- AgentMessageType["FROM_AGENT"] = "from_agent";
160
- AgentMessageType["FROM_USER"] = "from_user";
161
- AgentMessageType["AGENT_LEFT_CHAT"] = "agent_left_chat";
162
- AgentMessageType["AGENT_ENDED_CHAT"] = "agent_ended_chat";
163
- AgentMessageType["AGENT_JOINED"] = "agent_joined";
164
- AgentMessageType["RELOAD_WARNING"] = "user_connected_warning";
165
- AgentMessageType["TRANSFER_TO_AGENT"] = "transfer_to_agent";
166
- AgentMessageType["USER_ENDED_CHAT"] = "user_ended_chat";
167
- AgentMessageType["CHAT_WAS_ENDED"] = "chat_was_ended";
168
- AgentMessageType["DISCONNECTED"] = "disconnected";
169
- AgentMessageType["RECONNECTED"] = "reconnected";
170
- AgentMessageType["SHARING_REQUESTED"] = "sharing_requested";
171
- AgentMessageType["SHARING_ACCEPTED"] = "sharing_accepted";
172
- AgentMessageType["SHARING_DECLINED"] = "sharing_declined";
173
- AgentMessageType["SHARING_CANCELLED"] = "sharing_cancelled";
174
- AgentMessageType["SHARING_ENDED"] = "sharing_ended";
175
- AgentMessageType["SYSTEM"] = "system";
176
- })(AgentMessageType || (AgentMessageType = {}));
177
-
178
- /**
179
- *
180
- * IBM Confidential
181
- *
182
- * (C) Copyright IBM Corp. 2019, 2024
183
- *
184
- * The source code for this program is not published or otherwise
185
- * divested of its trade secrets, irrespective of what has been
186
- * deposited with the U. S. Copyright Office
187
- *
188
- * US Government Users Restricted Rights - Use, duplication or
189
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
190
- *
191
- */
192
- /**
193
- * This file documents the interfaces used by the API for communicating with watsonx Assistant. The published
194
- * documentation for the API can be found here: https://cloud.ibm.com/apidocs/assistant-v2#message.
195
- *
196
- * Note that these interfaces are incomplete and only contain the properties that we're actually making use of. There
197
- * are additional properties available when sending requests as well as in getting responses from the assistant.
198
- *
199
- * There are a few properties noted below that are not included in the documentation above because they are added by
200
- * the integration service after it has received a message from an assistant.
201
- */
202
- /**
203
- * These are custom message types that are not part of the v2 API but are generated by the widget for internal use.
204
- * Note: INLINE_ERROR can be used by custom service desks and is part of the public API.
205
- */
206
- var InternalMessageResponseType;
207
- (function (InternalMessageResponseType) {
208
- InternalMessageResponseType["STREAM_LOADING"] = "stream_loading";
209
- InternalMessageResponseType["SESSION_EXPIRED"] = "session_expired";
210
- InternalMessageResponseType["CHANNEL_TRANSFER_FAILED"] = "channel_transfer_failed";
211
- // TODO: Add to wa-fd-types when ready.
212
- InternalMessageResponseType["CARD"] = "card";
213
- // TODO: Add to wa-fd-types when ready.
214
- InternalMessageResponseType["CAROUSEL"] = "carousel";
215
- // TODO: Add to wa-fd-types when ready.
216
- InternalMessageResponseType["BUTTON"] = "button";
217
- // TODO: Add to wa-fd-types when ready.
218
- InternalMessageResponseType["GRID"] = "grid";
219
- // TODO: Add to wa-fd-types when ready.
220
- InternalMessageResponseType["PANEL"] = "panel";
221
- InternalMessageResponseType["WATSON_ORCHESTRATE_FORM"] = "user_defined_ibm_wo_form";
222
- })(InternalMessageResponseType || (InternalMessageResponseType = {}));
223
- /**
224
- * These are custom message types that are not part of the v2 API but are generated by the widget for internal use.
225
- */
226
- var InternalMessageRequestType;
227
- (function (InternalMessageRequestType) {
228
- InternalMessageRequestType["FILE"] = "file";
229
- })(InternalMessageRequestType || (InternalMessageRequestType = {}));
230
- /**
231
- * The names of channels that support channel transfer.
232
- */
233
- var CHANNEL_NAME;
234
- (function (CHANNEL_NAME) {
235
- CHANNEL_NAME["CHAT"] = "chat";
236
- CHANNEL_NAME["WHATSAPP"] = "whatsapp";
237
- CHANNEL_NAME["FACEBOOK"] = "facebook";
238
- CHANNEL_NAME["SLACK"] = "slack";
239
- })(CHANNEL_NAME || (CHANNEL_NAME = {}));
240
- /**
241
- * The different places a custom menu may be configured.
242
- *
243
- * @deprecated
244
- */
245
- var CustomMenuType;
246
- (function (CustomMenuType) {
247
- /**
248
- * The overflow menu on the bot view.
249
- */
250
- CustomMenuType["BOT"] = "bot";
251
- /**
252
- * The overflow menu on the human agent view.
253
- */
254
- CustomMenuType["AGENT"] = "agent";
255
- })(CustomMenuType || (CustomMenuType = {}));
256
-
257
- /**
258
- *
259
- * IBM Confidential
260
- *
261
- * (C) Copyright IBM Corp. 2020, 2024
262
- *
263
- * The source code for this program is not published or otherwise
264
- * divested of its trade secrets, irrespective of what has been
265
- * deposited with the U. S. Copyright Office
266
- *
267
- * US Government Users Restricted Rights - Use, duplication or
268
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
269
- *
270
- */
271
- const EVENT_NAME_ALTERNATE_SUGGESTIONS_OPENED = 'alternate_suggestions_opened';
272
- const EVENT_NAME_ALTERNATE_SUGGESTIONS_CLOSED = 'alternate_suggestions_closed';
273
- const EVENT_NAME_CHANNEL_TRANSFER = 'channel_transfer';
274
- /**
275
- * The different types of triggers for a meaningful conversation.
276
- */
277
- var MeaningfulConversationType;
278
- (function (MeaningfulConversationType) {
279
- /**
280
- * Indicates the user clicked on the "request agent" button from a connect-to-agent card.
281
- */
282
- MeaningfulConversationType["CONNECT_TO_AGENT"] = "connect_to_agent";
283
- /**
284
- * Indicates the user clicked on some link in the web chat (which could include any random link from a custom
285
- * response or an html/markdown response).
286
- */
287
- MeaningfulConversationType["LINK"] = "link";
288
- /**
289
- * Indicates the user clicked on a search result.
290
- */
291
- MeaningfulConversationType["SEARCH"] = "search_result";
292
- })(MeaningfulConversationType || (MeaningfulConversationType = {}));
293
-
294
- /**
295
- *
296
- * IBM Confidential
297
- *
298
- * (C) Copyright IBM Corp. 2019, 2024
299
- *
300
- * The source code for this program is not published or otherwise
301
- * divested of its trade secrets, irrespective of what has been
302
- * deposited with the U. S. Copyright Office
303
- *
304
- * US Government Users Restricted Rights - Use, duplication or
305
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
306
- *
307
- */
308
- /**
309
- * This file documents the interfaces used by the API for communicating with IBM watsonx Assistant. The published
310
- * documentation for the API can be found here: https://cloud.ibm.com/apidocs/assistant-v2#send-user-input-to-assistant.
311
- */
312
- /**
313
- * This is the name of the main dialog skill. A recent change did allow for skills with other names to be created so
314
- * this is mainly used for legacy or default purposes. This is used when looking up dialog specific data from the
315
- * context.
316
- */
317
- const MAIN_SKILL = 'main skill';
318
- /**
319
- * ID of the start of the dialog as it appears in the dialog state. This is used when identifying dialog responses
320
- * that are part of a multi-turn response.
321
- */
322
- const DIALOG_ROOT = 'root';
323
- /**
324
- * Enum values added by module augmentation do not have values set.
325
- * This seems to not be an issue for web chat when using webpack but node.js as done by haa-integrations needs to have these values assigned separately.
326
- */
327
- Object.assign(MessageInputType, {
328
- REQUEST_CONNECT_TO_AGENT: 'request_connect_to_agent',
329
- SEARCH: 'search'
330
- });
331
- Object.assign(MessageResponseTypes, {
332
- SUGGESTION: 'suggestion',
333
- CONVERSATIONAL_SEARCH: 'conversational_search',
334
- SEARCH: 'search',
335
- CHANNEL_TRANSFER: 'channel_transfer',
336
- TEXT_TO_SPEECH: 'text_to_speech',
337
- SPEECH_TO_TEXT: 'speech_to_text',
338
- START_ACTIVITIES: 'start_activities',
339
- STOP_ACTIVITIES: 'stop_activities',
340
- DTMF: 'dtmf',
341
- END_SESSION: 'end_session',
342
- RECORD: 'record',
343
- });
344
- /**
345
- * A suggestion can be an indication of a single turn (FAQ) or multi-turn. Typically, the type of suggestion will be
346
- * used when offering a suggestion to an agent. If it is a single turn, the agent can just copy/paste it to the
347
- * user. If it is a multi-turn the agent might hand it off back to Watson.
348
- */
349
- var SuggestionTypes;
350
- (function (SuggestionTypes) {
351
- /**
352
- * Single turn.
353
- */
354
- SuggestionTypes["ANSWER"] = "answer";
355
- /**
356
- * Multi turn.
357
- */
358
- SuggestionTypes["FLOW"] = "flow";
359
- })(SuggestionTypes || (SuggestionTypes = {}));
360
-
361
- var safeIsNaN = Number.isNaN ||
362
- function ponyfill(value) {
363
- return typeof value === 'number' && value !== value;
364
- };
365
- function isEqual(first, second) {
366
- if (first === second) {
367
- return true;
368
- }
369
- if (safeIsNaN(first) && safeIsNaN(second)) {
370
- return true;
371
- }
372
- return false;
373
- }
374
- function areInputsEqual(newInputs, lastInputs) {
375
- if (newInputs.length !== lastInputs.length) {
376
- return false;
377
- }
378
- for (var i = 0; i < newInputs.length; i++) {
379
- if (!isEqual(newInputs[i], lastInputs[i])) {
380
- return false;
381
- }
382
- }
383
- return true;
384
- }
385
-
386
- function memoizeOne(resultFn, isEqual) {
387
- if (isEqual === void 0) { isEqual = areInputsEqual; }
388
- var cache = null;
389
- function memoized() {
390
- var newArgs = [];
391
- for (var _i = 0; _i < arguments.length; _i++) {
392
- newArgs[_i] = arguments[_i];
393
- }
394
- if (cache && cache.lastThis === this && isEqual(newArgs, cache.lastArgs)) {
395
- return cache.lastResult;
396
- }
397
- var lastResult = resultFn.apply(this, newArgs);
398
- cache = {
399
- lastResult: lastResult,
400
- lastArgs: newArgs,
401
- lastThis: this,
402
- };
403
- return lastResult;
404
- }
405
- memoized.clear = function clear() {
406
- cache = null;
407
- };
408
- return memoized;
409
- }
410
-
411
- /**
412
- *
413
- * IBM Confidential
414
- *
415
- * (C) Copyright IBM Corp. 2020
416
- *
417
- * The source code for this program is not published or otherwise
418
- * divested of its trade secrets, irrespective of what has been
419
- * deposited with the U. S. Copyright Office
420
- *
421
- * US Government Users Restricted Rights - Use, duplication or
422
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
423
- *
424
- */
425
- var SkillType;
426
- (function (SkillType) {
427
- SkillType["SEARCH"] = "search";
428
- SkillType["DIALOG"] = "dialog";
429
- SkillType["ACTIONS"] = "actions";
430
- })(SkillType || (SkillType = {}));
431
-
432
- /**
433
- *
434
- * IBM Confidential
435
- *
436
- * (C) Copyright IBM Corp. 2020, 2024
437
- *
438
- * The source code for this program is not published or otherwise
439
- * divested of its trade secrets, irrespective of what has been
440
- * deposited with the U. S. Copyright Office
441
- *
442
- * US Government Users Restricted Rights - Use, duplication or
443
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
444
- *
445
- */
446
- /**
447
- * Indicates the different states a thread can be in for a given message.
448
- */
449
- var ThreadStatus;
450
- (function (ThreadStatus) {
451
- /**
452
- * Indicates that the response is starting a new thread.
453
- */
454
- ThreadStatus[ThreadStatus["STARTED"] = 1] = "STARTED";
455
- /**
456
- * Indicates that the request and response are in the same thread and the thread is continuing.
457
- */
458
- ThreadStatus[ThreadStatus["CONTINUING"] = 2] = "CONTINUING";
459
- /**
460
- * Indicates that the request and response are in the same thread but the response has indicated that thread has
461
- * ended.
462
- * This is currently determined by examining the dialog state. If the
463
- * dialog stack first item is the root then it means this response is a leaf in the dialog tree.
464
- */
465
- ThreadStatus[ThreadStatus["ENDED"] = 3] = "ENDED";
466
- })(ThreadStatus || (ThreadStatus = {}));
467
- /**
468
- * The thread id of the main thread for every channel. It is used in both MessageRequest and Message Response.
469
- * This ID is specifically for communicating with the bot and is distinct from the id of a sub-thread or the threads
470
- * with any human agent.
471
- */
472
- const THREAD_ID_MAIN = 'main';
473
- /**
474
- * The reason for the escalation.
475
- */
476
- var ConnectToAgentReason;
477
- (function (ConnectToAgentReason) {
478
- /**
479
- * An intentional escalation designed in the dialog.
480
- */
481
- ConnectToAgentReason["ASSISTANT_REQUESTED"] = "assistant_requested";
482
- /**
483
- * An escalation which occurred due to the user requesting an agent.
484
- */
485
- ConnectToAgentReason["USER_REQUESTED"] = "user_requested";
486
- /**
487
- * An escalation which occurred due to an error in the service.
488
- */
489
- ConnectToAgentReason["GENERAL_ERROR"] = "general_error";
490
- /**
491
- * An escalation which occurred due to a failure to transfer a conversation to Watson. This may happen only in
492
- * backdoor integrations (Intercom), in which an agent has approved a suggestion but the virtual agent failed to
493
- * continue with the conversation.
494
- */
495
- ConnectToAgentReason["TRANSFER_FAILURE"] = "transfer_failure";
496
- })(ConnectToAgentReason || (ConnectToAgentReason = {}));
497
- // ************ END OF EXPERIMENTAL ******************* //
498
- // ************* User Profile ***************** //
499
- /**
500
- * The set of possible conversation companions.
501
- */
502
- var UserTypes;
503
- (function (UserTypes) {
504
- UserTypes["HUMAN_AGENT"] = "human_agent";
505
- UserTypes["USER"] = "user";
506
- /**
507
- * The bot which replies to the user.
508
- */
509
- UserTypes["WATSON"] = "watson";
510
- /**
511
- * Used to denote that an event was processed/logged by the service
512
- */
513
- UserTypes["SERVICE"] = "service";
514
- })(UserTypes || (UserTypes = {}));
515
- /**
516
- * Gender used in user info provided to Watson by client, typically within a JWT.
517
- */
518
- var UserGender;
519
- (function (UserGender) {
520
- UserGender["MALE"] = "male";
521
- UserGender["FEMALE"] = "female";
522
- UserGender["OTHER"] = "other";
523
- })(UserGender || (UserGender = {}));
524
-
525
- /**
526
- *
527
- * IBM Confidential
528
- *
529
- * (C) Copyright IBM Corp. 2019, 2023
530
- *
531
- * The source code for this program is not published or otherwise
532
- * divested of its trade secrets, irrespective of what has been
533
- * deposited with the U. S. Copyright Office
534
- *
535
- * US Government Users Restricted Rights - Use, duplication or
536
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
537
- *
538
- */
539
- /**
540
- * Coerces the given value into an array. If the value is already an array, it is returned as-is. Otherwise it is
541
- * returned as a new array that contains the value as a single entry.
542
- *
543
- * @param value The value that's either an array or should be put into an array.
544
- */
545
- function asArray(value) {
546
- return Array.isArray(value) ? value : [value];
547
- }
548
- /**
549
- * Executes an asynchronous "forEach" over the given array with the given callback function. The values are executed
550
- * in series (as opposed to in parallel). The array may not be modified during the loop.
551
- *
552
- * @param array The array to execute the loop over.
553
- * @param callbackFunction The function to call for each value in the array. The return value from the function will
554
- * be awaited which means if the value is a Promise, the loop will block until the Promise is resolved. The function
555
- * does not have to return a Promise in which case no waiting will occur.
556
- */
557
- async function asyncForEach(array, callbackFunction) {
558
- for (let index = 0; index < array.length; index++) {
559
- const value = array[index];
560
- // eslint-disable-next-line no-await-in-loop
561
- await callbackFunction(value, index, array);
562
- }
563
- }
564
- /**
565
- * Finds the last value in the given array that matches according to the provided predicate. The search will
566
- * begin from the end of the array and continue backwards until a match is found.
567
- *
568
- * @param array The array to search through.
569
- * @param predicate The function used to determine if each value matches.
570
- * @param startAt The index to start at in the array. Defaults to length -1.
571
- * @returns Returns the array value that was found to match or undefined if no match was found.
572
- */
573
- function findLast(array, predicate, startAt) {
574
- const lastIndex = findLastIndex(array, predicate);
575
- return lastIndex === -1 ? undefined : array[lastIndex];
576
- }
577
- /**
578
- * Finds the last value in the given array that matches according to the provided predicate. The search will
579
- * begin from the end of the array and continue backwards until a match is found.
580
- *
581
- * @param array The array to search through.
582
- * @param predicate The function used to determine if each value matches.
583
- * @param startAt The index to start at in the array. Defaults to length -1.
584
- * @returns Returns the array index that was found to match or -1 if no match was found.
585
- */
586
- function findLastIndex(array, predicate, startAt) {
587
- if (array) {
588
- const startingIndex = array.length - 1 ;
589
- for (let index = startingIndex; index >= 0; index--) {
590
- const value = array[index];
591
- if (predicate(value, index, array)) {
592
- return index;
593
- }
594
- }
595
- }
596
- return -1;
597
- }
598
- /**
599
- * Finds the last value in the given array whose matching object from the given map matches according to the
600
- * provided predicate. The search will begin from the end of the array and continue backwards until a match is
601
- * found. This functionality basically works the same as {@link findLast} except that it will retrieve the object
602
- * from the map for the given id and use the predicate on that object.
603
- *
604
- * @param keys The array to search through.
605
- * @param map The map that contains the objects to look for. The object will be looked up using the key from the
606
- * provided array.
607
- * @param predicate The function used to determine if each value matches.
608
- * @returns Returns the array value that was found to match or undefined if no match was found.
609
- */
610
- function findLastWithMap(keys, map, predicate) {
611
- for (let index = keys.length - 1; index >= 0; index--) {
612
- const key = keys[index];
613
- const value = map[key];
614
- if (predicate(value, index, keys)) {
615
- return value;
616
- }
617
- }
618
- return undefined;
619
- }
620
- /**
621
- * Pushes all the elements from the source array to the end of the target array.
622
- */
623
- function pushAll(targetArray, sourceArray) {
624
- // Resize the target array.
625
- const originalSize = targetArray.length;
626
- targetArray.length = originalSize + sourceArray.length;
627
- // Assign all the values.
628
- for (let offset = 0; offset < sourceArray.length; offset++) {
629
- targetArray[originalSize + offset] = sourceArray[offset];
630
- }
631
- return targetArray;
632
- }
633
- /**
634
- * Returns the last value of the given array.
635
- */
636
- function arrayLastValue(array) {
637
- return array && array.length ? array[array.length - 1] : null;
638
- }
639
-
640
- /**
641
- *
642
- * IBM Confidential
643
- *
644
- * (C) Copyright IBM Corp. 2020, 2024
645
- *
646
- * The source code for this program is not published or otherwise
647
- * divested of its trade secrets, irrespective of what has been
648
- * deposited with the U. S. Copyright Office
649
- *
650
- * US Government Users Restricted Rights - Use, duplication or
651
- * disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
652
- *
653
- */
654
- /**
655
- * The regular expression for identifying the anything else node. It's basically looking for the word
656
- * "anything_else" as a separate word in the string surrounding by any non-alphanumeric characters and underscore.
657
- */
658
- const ANYTHING_ELSE_REGEXP = /([^#a-zA-Z0-9_]|^)anything_else([^a-zA-Z0-9_]|$)/;
659
- const EMPTY_CONTEXT = memoizeOne((assistant) => {
660
- const context = {};
661
- if (assistant?.skills) {
662
- assistant.skills.forEach(skill => {
663
- if (skill.type === SkillType.DIALOG || skill.type === SkillType.ACTIONS) {
664
- merge(context, {
665
- global: {
666
- system: {},
667
- },
668
- skills: {
669
- [skill.skill_reference]: {
670
- system: {},
671
- user_defined: {},
672
- },
673
- },
674
- });
675
- }
676
- });
677
- }
678
- return context;
679
- });
680
- /**
681
- * A default request for fetching the welcome node. The ID will need to be filled in when the request is made.
682
- */
683
- const WELCOME_MESSAGE_REQUEST = {
684
- id: null,
685
- input: {
686
- text: '',
687
- },
688
- history: {
689
- silent: true,
690
- is_welcome_request: true,
691
- },
692
- thread_id: THREAD_ID_MAIN,
693
- };
694
- deepFreeze(WELCOME_MESSAGE_REQUEST);
695
- /**
696
- * This function determines if the given message is an output message (i.e. a message output from the assistant) and
697
- * is a {@link MessageResponse}. This function acts as a type guard which will narrow the type to
698
- * {@link MessageResponse} if it returns true.
699
- */
700
- function isResponse(message) {
701
- return message && message.output !== undefined;
702
- }
703
- /**
704
- * Determines if the message is a response from actions.
705
- *
706
- * Note: Actions has 'history' under output.user_defined.debug. This will be changed in the near future with history
707
- * being renamed to turn_events and moved to output.debug. Checks for both are in place in case actions updates.
708
- */
709
- function isActionsResponse(message) {
710
- return (isResponse(message) &&
711
- (message.output.user_defined?.debug?.history !== undefined ||
712
- message.output.debug?.turn_events !== undefined));
713
- }
714
- // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
715
- function isDateResponseType(localMessage) {
716
- return localMessage?.item.response_type === MessageResponseTypes.DATE;
717
- }
718
- /**
719
- * Adds default values to the given MessageResponse.
720
- */
721
- function addDefaultsToMessage(fullMessage) {
722
- if (!fullMessage.id) {
723
- fullMessage.id = uuid(UUIDType.MESSAGE);
724
- }
725
- if (!fullMessage.thread_id) {
726
- fullMessage.thread_id = THREAD_ID_MAIN;
727
- }
728
- if (!fullMessage.history) {
729
- fullMessage.history = {};
730
- }
731
- if (!fullMessage.history.timestamp) {
732
- fullMessage.history.timestamp = Date.now();
733
- }
734
- if (fullMessage.history.from_history === undefined) {
735
- fullMessage.history.from_history = false;
736
- }
737
- return fullMessage;
738
- }
739
- /**
740
- * Indicates if the given local message is either an option or a suggestion response.
741
- */
742
- function isOptionOrSuggestion(localMessage) {
743
- switch (localMessage?.item.response_type) {
744
- case MessageResponseTypes.OPTION:
745
- case MessageResponseTypes.SUGGESTION:
746
- case InternalMessageResponseType.BUTTON:
747
- return true;
748
- default:
749
- return false;
750
- }
751
- }
752
- /**
753
- * This function determines if the given message is a message input to the assistant and is a {@link MessageRequest}.
754
- * This function will return false if the MessageRequest is an internal event. This function acts as a type guard which
755
- * will narrow the type to {@link MessageRequest} if it returns true.
756
- */
757
- function isRequest(message) {
758
- return message?.input !== undefined;
759
- }
760
- /**
761
- * Indicates if this message was part of a conversation with a live agent.
762
- */
763
- function isLiveAgentMessage(message) {
764
- return Boolean(message.item.agent_message_type);
765
- }
766
- /**
767
- * Indicates if this message contains a message that was part of a conversation with a live agent.
768
- */
769
- function hasLiveAgentMessage(message) {
770
- return ((isResponse(message) && Boolean(message.output.generic?.find(item => item?.agent_message_type))) ||
771
- (isRequest(message) && Boolean(message.input.agent_message_type)));
772
- }
773
- /**
774
- * This function determines if the given message is an internal event message that was input (i.e. a message we sent to
775
- * the backend that is a {@link MessageRequest} with {@link EventInput} in it). This function acts as a type guard
776
- * which will narrow the type to 'MessageRequest<EventInput>' if it returns true.
777
- */
778
- function isEventRequest(message) {
779
- return message?.input?.message_type === MessageInputType.EVENT;
780
- }
781
- /**
782
- * This function determines if the given message is an internal event message that was input in order to update the
783
- * message history (i.e. a message we sent to the backend that is a {@link MessageEvent} with {@link EventInput} in it
784
- * which contains {@link UpdateHistoryEvent} data). This function acts as a type guard which will narrow the type to
785
- * 'MessageRequest<EventInput<UpdateHistoryEvent>>' if it returns true.
786
- */
787
- function isUpdateHistoryRequest(message) {
788
- return (isEventRequest(message) &&
789
- message?.input?.event?.name === EVENT_NAME_UPDATE_HISTORY);
790
- }
791
- function isTyping(message) {
792
- // eslint-disable-next-line eqeqeq
793
- return message.response_type === MessageResponseTypes.PAUSE && message.typing == true;
794
- }
795
- function isPause(message) {
796
- return message.response_type === MessageResponseTypes.PAUSE;
797
- }
798
- /**
799
- * This is a type guard that determines if the given item is an {@link OptionItem} item.
800
- */
801
- function isOptionItem(item) {
802
- return item?.response_type === MessageResponseTypes.OPTION && item.options !== undefined;
803
- }
804
- function isChannelTransfer(response) {
805
- return response?.response_type === MessageResponseTypes.CHANNEL_TRANSFER;
806
- }
807
- /**
808
- * Determines if the message is a transfer to agent response.
809
- */
810
- function isChannelTransferToAgent(message) {
811
- const { generic } = message.output;
812
- return generic.some(isChannelTransfer) && generic.some(isConnectToAgent);
813
- }
814
- /**
815
- * Determines if the message contains a panel response type.
816
- */
817
- function hasMessageResponsePanel(message) {
818
- return message.output.generic.some(item => {
819
- let messageItem = item;
820
- // TODO: This check is temporary until there is backend support for the panel response type.
821
- if (betaUserDefinedResponses[item.user_defined?.user_defined_type]) {
822
- messageItem = item.user_defined;
823
- }
824
- return isPanelResponseType(messageItem);
825
- });
826
- }
827
- /**
828
- * Determines if the given item contains 'chat' as a channel in order to determine if it should be rendered by web chat.
829
- * If the item does not contain the 'channel' property, then we can return 'true' because this means all channels can
830
- * render the item.
831
- */
832
- function isForChatChannel(item) {
833
- if (item.channels) {
834
- return item.channels.some(channel => channel.channel === 'chat');
835
- }
836
- return true;
837
- }
838
- /**
839
- * Determines if the message response is from a main thread.
840
- */
841
- function isFromAMainThread(message, request) {
842
- // We know we're in a multi-turn if it has a thread id. It's a little harder to tell if it's the first message though.
843
- // We can check the request to see if the request thinks it was already in a thread.
844
- return message.thread_id === THREAD_ID_MAIN || request?.thread_id === THREAD_ID_MAIN;
845
- }
846
- /**
847
- * Determines if the message response is a fallback.
848
- */
849
- function isFallbackResponse(message) {
850
- return message.output.debug?.branch_exited_reason === 'fallback';
851
- }
852
- /**
853
- * Determines if the current message is a repeat response of the previous.
854
- *
855
- * @param currentResponse The last response the user sees.
856
- * @param previousResponse The previous response from the last one.
857
- */
858
- function isRepeatResponse(currentResponse, previousResponse) {
859
- // We can't determine a repeat response if either responses are not provided.
860
- if (!currentResponse || !previousResponse) {
861
- return false;
862
- }
863
- const currentLastDialogNode = arrayLastValue(currentResponse.output.debug?.nodes_visited)?.dialog_node;
864
- const previousLastDialogNode = arrayLastValue(previousResponse.output.debug?.nodes_visited)?.dialog_node;
865
- // The current response is a duplicate of the previous if their last dialog nodes are the same.
866
- return currentLastDialogNode && currentLastDialogNode === previousLastDialogNode;
867
- }
868
- /**
869
- * Indicates if the dialog state indicates that dialog is now at the root.
870
- */
871
- function isAtStackRoot(state) {
872
- // In the case of disambiguation, the stack may be empty in which case, we'll still count it as the root.
873
- return Boolean(!state.dialog_stack?.[0] || state.dialog_stack[0].dialog_node === DIALOG_ROOT);
874
- }
875
- /**
876
- * Converts any line breaks to spaces.
877
- */
878
- function replaceLineBreak(text) {
879
- return text.replace(/(\r\n|\n|\r)/gm, ' ');
880
- }
881
- /**
882
- * Generates a {@link MessageRequest} for the given {@link Option} that the user has selected. This is used for
883
- * generating the request to the server once the user has selected a choice from an option or suggestion list.
884
- *
885
- * @param choice The selected value.
886
- * @param relatedResponseID If this choice was made as the result of the choice choosing a value from a previous
887
- * {@link MessageResponse}, this should be the ID of that message.
888
- */
889
- function createMessageRequestForChoice(choice, relatedResponseID) {
890
- // The "value" of the choice contains the data that is to be sent to the server when this choice is selected.
891
- // We'll clone it and add in the history value which stores the user-visible label in the history store.
892
- const messageRequest = {
893
- id: uuid(UUIDType.MESSAGE),
894
- thread_id: THREAD_ID_MAIN,
895
- ...cloneDeep(choice.value),
896
- };
897
- messageRequest.history = {
898
- label: choice.label,
899
- relatedMessageID: relatedResponseID,
900
- };
901
- return messageRequest;
902
- }
903
- /**
904
- * Generates a {@link MessageRequest} for the given {@link Option} that the user has selected. This is used for
905
- * generating the request to the server once the user has selected a choice from an option or suggestion list.
906
- *
907
- * @param buttonItem The button item.
908
- * @param relatedResponseID The id of the {@link MessageResponse} the button item came from.
909
- * {@link MessageResponse}, this should be the ID of that message.
910
- */
911
- function createMessageRequestForButtonItemOption(buttonItem, relatedResponseID) {
912
- // The "value" of the choice contains the data that is to be sent to the server when this choice is selected.
913
- const messageRequest = {
914
- id: uuid(UUIDType.MESSAGE),
915
- thread_id: THREAD_ID_MAIN,
916
- input: null,
917
- };
918
- if (buttonItem.value?.input?.text) {
919
- messageRequest.input = cloneDeep(buttonItem.value.input);
920
- }
921
- else {
922
- messageRequest.input = { text: buttonItem.label };
923
- }
924
- messageRequest.history = { relatedMessageID: relatedResponseID };
925
- return messageRequest;
926
- }
927
- /**
928
- * Generates a {@link MessageRequest} to request the welcome node.
929
- */
930
- function createWelcomeRequest() {
931
- return addDefaultsToMessage({
932
- id: uuid(UUIDType.MESSAGE),
933
- input: {
934
- text: '',
935
- },
936
- history: {
937
- silent: true,
938
- is_welcome_request: true,
939
- },
940
- thread_id: THREAD_ID_MAIN,
941
- });
942
- }
943
- /**
944
- * Generates a {@link MessageRequest} for the given text message sent by the user. This is used for generating the
945
- * request to send to the server when the user has typed something into the input field.
946
- */
947
- function createMessageRequestForText(text) {
948
- // The "value" of the choice contains the data that is to be sent to the server when this choice is selected.
949
- // We'll clone it and add in the history value which stores the user-visible label in the history store.
950
- return addDefaultsToMessage({
951
- input: {
952
- // The assistant will choke if we send it text with line breaks in it, so we have to remove them first.
953
- text: replaceLineBreak(text),
954
- message_type: MessageInputType.TEXT,
955
- },
956
- });
957
- }
958
- /**
959
- * Generates a {@link MessageRequest} to represent a file upload.
960
- */
961
- function createMessageRequestForFileUpload(upload) {
962
- return addDefaultsToMessage({
963
- id: upload.id,
964
- input: {
965
- text: upload.file.name,
966
- message_type: InternalMessageRequestType.FILE,
967
- agent_message_type: AgentMessageType.FROM_USER,
968
- },
969
- history: {
970
- file_upload_status: FileStatusValue.UPLOADING,
971
- },
972
- });
973
- }
974
- function createMessageRequestForDate(inputString, userString, relatedResponseID) {
975
- const messageRequest = createMessageRequestForText(inputString);
976
- messageRequest.history = {
977
- label: userString,
978
- relatedMessageID: relatedResponseID,
979
- };
980
- return messageRequest;
981
- }
982
- /**
983
- * Generates a {@link MessageResponse} for the given text message sent to the user.
984
- */
985
- function createMessageResponseForText(text, threadID = THREAD_ID_MAIN, responseType = MessageResponseTypes.TEXT, context) {
986
- const textItem = {
987
- response_type: responseType,
988
- text,
989
- };
990
- const messageResponse = {
991
- id: uuid(UUIDType.MESSAGE),
992
- thread_id: threadID,
993
- output: {
994
- generic: [textItem],
995
- },
996
- };
997
- return messageResponse;
998
- }
999
- /**
1000
- * Generates a {@link MessageResponse} for the given item sent to the user.
1001
- */
1002
- function createMessageResponseForItem(item, context) {
1003
- const messageResponse = {
1004
- output: {
1005
- generic: [item],
1006
- },
1007
- };
1008
- return addDefaultsToMessage(messageResponse);
1009
- }
1010
- /**
1011
- * Generates a {@link MessageRequest<EventInput} for the given eventData. This is used to properly format the event
1012
- * before sending it to the backend with the messageService.
1013
- */
1014
- function createEventMessageRequest(eventData) {
1015
- // Build the full eventMessage now that we have the eventData to send.
1016
- const eventMessage = {
1017
- input: {
1018
- message_type: MessageInputType.EVENT,
1019
- event: eventData,
1020
- },
1021
- };
1022
- return addDefaultsToMessage(eventMessage);
1023
- }
1024
- /**
1025
- * Indicates if the dialog response is a "connect_to_agent" message.
1026
- */
1027
- function isConnectToAgent(response) {
1028
- return response?.response_type === MessageResponseTypes.CONNECT_TO_AGENT;
1029
- }
1030
- function isCardResponseType(response) {
1031
- // TODO: Add Card to wa-fd-types MessageResponseTypes enum.
1032
- return response?.response_type === InternalMessageResponseType.CARD;
1033
- }
1034
- function isCarouselResponseType(response) {
1035
- // TODO: Add Carousel to MessageResponseTypes enum.
1036
- return response?.response_type === InternalMessageResponseType.CAROUSEL;
1037
- }
1038
- function isButtonResponseType(response) {
1039
- // TODO: Add Button to MessageResponseTypes enum.
1040
- return response?.response_type === InternalMessageResponseType.BUTTON;
1041
- }
1042
- function isShowPanelButtonType(response) {
1043
- return isButtonResponseType(response) && response.button_type === ButtonItemType.SHOW_PANEL;
1044
- }
1045
- /**
1046
- * Determines if the provided message item is a response type that supports nesting response types.
1047
- */
1048
- function isResponseWithNestedItems(item) {
1049
- if (isButtonResponseType(item)) {
1050
- return hasBodyOrFooter(item.panel);
1051
- }
1052
- if (isCardResponseType(item) || isPanelResponseType(item)) {
1053
- return hasBodyOrFooter(item);
1054
- }
1055
- if (isCarouselResponseType(item)) {
1056
- return item.items !== undefined;
1057
- }
1058
- return isGridResponseType(item);
1059
- }
1060
- function hasBodyOrFooter(item) {
1061
- return item?.body !== undefined || item?.footer !== undefined;
1062
- }
1063
- /**
1064
- * Object containing mapping `LocalMessage.message.user_defined.user_defined_type` values to the function to transform
1065
- * the user_defined response to a real response inside web chat.
1066
- */
1067
- const betaUserDefinedResponses = {
1068
- /**
1069
- * Transform the temporary user_defined response type for a wXo form to the temporary internal response type.
1070
- */
1071
- user_defined_ibm_wo_form(localMessage) {
1072
- const localMessageCopy = cloneDeep(localMessage);
1073
- localMessageCopy.item.response_type =
1074
- InternalMessageResponseType.WATSON_ORCHESTRATE_FORM;
1075
- return localMessageCopy;
1076
- },
1077
- /*
1078
- Example:
1079
- {
1080
- response_type: "user_defined",
1081
- user_defined: {
1082
- user_defined_type: "IBM_BETA_TRANSFORM_RESPONSE",
1083
- response_type: "card",
1084
- body: [{ "response_type": "text", "text: "Hello, world!" }]
1085
- }
1086
- }
1087
-
1088
- to
1089
-
1090
- {
1091
- response_type: "card",
1092
- body: [{ "response_type": "text", "text: "Hello, world!" }]
1093
- }
1094
-
1095
- */
1096
- IBM_BETA_TRANSFORM_RESPONSE(localMessage) {
1097
- const localMessageCopy = cloneDeep(localMessage);
1098
- const userDefinedCopy = cloneDeep(localMessage.item.user_defined);
1099
- localMessageCopy.item = userDefinedCopy;
1100
- delete localMessageCopy.item.user_defined_type;
1101
- return localMessageCopy;
1102
- },
1103
- };
1104
- /**
1105
- * Returns if the given local message has a user_defined response type with user_defined.user_defined_type that matches
1106
- * one of the responses in our beta list.
1107
- *
1108
- * @param localMessage A message we are checking to see if it needs to be transformed.
1109
- */
1110
- function isBetaUserDefinedResponse(localMessage) {
1111
- return (localMessage.item.response_type === MessageResponseTypes.USER_DEFINED &&
1112
- betaUserDefinedResponses[localMessage.item.user_defined?.user_defined_type] !== undefined);
1113
- }
1114
- /**
1115
- * Transforms a given user_defined response with a user_defined.user_defined_type that matches
1116
- * one of the responses in our beta list to a new format using a InternalMessageResponseType.
1117
- *
1118
- * @param localMessage A message that needs to be transformed.
1119
- */
1120
- function transformBetaUserDefinedResponse(localMessage) {
1121
- const betaUserDefinedResponseFunction = betaUserDefinedResponses[localMessage.item.user_defined?.user_defined_type];
1122
- return betaUserDefinedResponseFunction(localMessage);
1123
- }
1124
- /**
1125
- * Determines if the given message should be rendered as custom message.
1126
- */
1127
- function renderAsUserDefinedMessage(messageItem) {
1128
- const responseType = messageItem.response_type;
1129
- switch (responseType) {
1130
- case MessageResponseTypes.TEXT:
1131
- case MessageResponseTypes.IMAGE:
1132
- case MessageResponseTypes.OPTION:
1133
- case MessageResponseTypes.SUGGESTION:
1134
- case MessageResponseTypes.SEARCH:
1135
- case MessageResponseTypes.CONNECT_TO_AGENT:
1136
- case MessageResponseTypes.CHANNEL_TRANSFER:
1137
- case MessageResponseTypes.IFRAME:
1138
- case MessageResponseTypes.VIDEO:
1139
- case MessageResponseTypes.AUDIO:
1140
- case MessageResponseTypes.DATE:
1141
- case MessageResponseTypes.CONVERSATIONAL_SEARCH:
1142
- case MessageResponseTypes.TABLE:
1143
- case MessageResponseTypes.INLINE_ERROR:
1144
- case InternalMessageResponseType.STREAM_LOADING:
1145
- case InternalMessageResponseType.SESSION_EXPIRED:
1146
- case InternalMessageResponseType.CHANNEL_TRANSFER_FAILED:
1147
- case InternalMessageResponseType.CARD:
1148
- case InternalMessageResponseType.CAROUSEL:
1149
- case InternalMessageResponseType.BUTTON:
1150
- case InternalMessageResponseType.GRID:
1151
- case InternalMessageResponseType.PANEL:
1152
- case InternalMessageResponseType.WATSON_ORCHESTRATE_FORM:
1153
- return false;
1154
- default:
1155
- // If the custom response is for the tour feature then don't render as a custom message since it will be rendered
1156
- // as a tour instead.
1157
- return !renderAsTour(messageItem);
1158
- }
1159
- }
1160
- /**
1161
- * Determines if the LocalMessage should be rendered as a tour.
1162
- */
1163
- function renderAsTour(messageItem) {
1164
- return hasTourUserDefinedType(messageItem);
1165
- }
1166
- /**
1167
- * Determines if the Generic item's user_defined_type matched the type for the tour beta.
1168
- */
1169
- function hasTourUserDefinedType(message) {
1170
- // For now the tour response will be a custom message with a specific user_defined_type.
1171
- return message?.user_defined?.user_defined_type === 'IBM_BETA_JOURNEYS_TOUR';
1172
- }
1173
- /**
1174
- * Indicates if the given remote config indicates that a service desk is configured.
1175
- */
1176
- function hasServiceDesk(config) {
1177
- return Boolean(config.public.serviceDeskFactory || hasSupportedServiceDesk(config));
1178
- }
1179
- /**
1180
- * Indicates if the given config indicates that a supported service desk is configured. This may either be a
1181
- * server-side configuration service desk or a client-only service desk.
1182
- */
1183
- function hasSupportedServiceDesk(config) {
1184
- return Boolean(config.remote.initConfig.service_desk?.is_on || config.public.serviceDesk?.integrationType);
1185
- }
1186
- /**
1187
- * Determines if in the given array of messages there is at least one response to a request from the user.
1188
- */
1189
- function hasResponseToRequest(messageIDs, allMessageItemsByID, allMessagesByID) {
1190
- let foundRequest = false;
1191
- for (let index = 0; index < messageIDs.length; index++) {
1192
- const message = allMessageItemsByID[messageIDs[index]];
1193
- const originalMessage = allMessagesByID[message?.fullMessageID];
1194
- if (foundRequest && isResponse(originalMessage)) {
1195
- return true;
1196
- }
1197
- if (isRequest(originalMessage) && !originalMessage?.history?.silent) {
1198
- foundRequest = true;
1199
- }
1200
- }
1201
- return false;
1202
- }
1203
- /**
1204
- * Indicates if the given message came from the "anything else" node.
1205
- */
1206
- function isAnythingElse(message) {
1207
- // We have to go look at the debug info to find the anything_else condition.
1208
- // Note: Probably need to limit this to a root AE Node, but I don't know how.
1209
- const nodes = message?.output.debug?.nodes_visited;
1210
- return Boolean(nodes?.find(node => ANYTHING_ELSE_REGEXP.test(node.conditions)));
1211
- }
1212
- /**
1213
- * Creates a new {@link TextItem}.
1214
- */
1215
- function createTextItem(text) {
1216
- return {
1217
- response_type: MessageResponseTypes.TEXT,
1218
- text,
1219
- };
1220
- }
1221
- /**
1222
- * Determines if the given search result item is empty (has no results in it).
1223
- */
1224
- function isSearchResultItem(item) {
1225
- return item?.response_type === MessageResponseTypes.SEARCH;
1226
- }
1227
- /**
1228
- * Determines if the given search result item is a conversational search item.
1229
- */
1230
- function isConversationalSearchItem(item) {
1231
- return item?.response_type === MessageResponseTypes.CONVERSATIONAL_SEARCH;
1232
- }
1233
- /**
1234
- * Determines if the given search result item is empty (has no results in it).
1235
- */
1236
- function isEmptySearchResultItem(item) {
1237
- return !item?.primary_results?.length && !item?.results?.length;
1238
- }
1239
- /**
1240
- * Determines if the provided local message has a chat status response type message.
1241
- */
1242
- function isChatStatusResponseType(message) {
1243
- const responseType = message?.item.response_type;
1244
- switch (responseType) {
1245
- case InternalMessageResponseType.SESSION_EXPIRED:
1246
- case InternalMessageResponseType.CHANNEL_TRANSFER_FAILED:
1247
- return true;
1248
- default:
1249
- return false;
1250
- }
1251
- }
1252
- /**
1253
- * Determines if the provided message item can be rendered in a response body item.
1254
- */
1255
- function isItemSupportedInResponseBody(item) {
1256
- switch (item.response_type) {
1257
- case MessageResponseTypes.IMAGE:
1258
- case MessageResponseTypes.IFRAME:
1259
- case MessageResponseTypes.VIDEO:
1260
- case MessageResponseTypes.AUDIO:
1261
- case MessageResponseTypes.TEXT:
1262
- case MessageResponseTypes.USER_DEFINED:
1263
- case InternalMessageResponseType.CARD:
1264
- case InternalMessageResponseType.GRID:
1265
- return true;
1266
- default:
1267
- return false;
1268
- }
1269
- }
1270
- /**
1271
- * Determines if the message item is a carousel response type with a single item.
1272
- */
1273
- function isSingleItemCarousel(messageItem) {
1274
- return isCarouselResponseType(messageItem) && messageItem.items.length === 1;
1275
- }
1276
- function isGridResponseType(item) {
1277
- return item?.response_type === InternalMessageResponseType.GRID;
1278
- }
1279
- function isPanelResponseType(item) {
1280
- return item?.response_type === InternalMessageResponseType.PANEL;
1281
- }
1282
- function getOptionType(preference, totalOptions) {
1283
- let type = 'button';
1284
- if (preference && preference === 'button') {
1285
- type = 'button';
1286
- }
1287
- else if (preference && preference === 'dropdown') {
1288
- type = 'dropdown';
1289
- }
1290
- else if (totalOptions > 4) {
1291
- type = 'dropdown';
1292
- }
1293
- return type;
1294
- }
1295
- /**
1296
- * Indicates if the given stream chunk is a partial item.
1297
- */
1298
- function isStreamPartialItem(chunk) {
1299
- return Boolean(chunk.partial_item);
1300
- }
1301
- /**
1302
- * Indicates if the given stream chunk is a complete item.
1303
- */
1304
- function isStreamCompleteItem(chunk) {
1305
- return Boolean(chunk.complete_item);
1306
- }
1307
- /**
1308
- * Indicates if the given stream chunk is a partial item.
1309
- */
1310
- function isStreamFinalResponse(chunk) {
1311
- return Boolean(chunk.final_response);
1312
- }
1313
- /**
1314
- * Returns the ID of a streaming item that is part of a message response. If the item does not have a streaming ID,
1315
- * this will return null;
1316
- */
1317
- function streamItemID(messageID, item) {
1318
- const itemID = item?.streaming_metadata?.id;
1319
- if (!itemID) {
1320
- return null;
1321
- }
1322
- return `${messageID}-${itemID}`;
1323
- }
1324
- /**
1325
- * Returns the dimensions info for the given media item.
1326
- */
1327
- function getMediaDimensions(item) {
1328
- return item.dimensions || item.channel_options?.chat?.dimensions;
1329
- }
1330
- /**
1331
- * Returns the last response message from the bot (excludes agent messages) that has a context object on it.
1332
- */
1333
- function getLastBotResponseWithContext(state) {
1334
- const messageIDs = state.botMessageState.messageIDs || [];
1335
- return findLastWithMap(messageIDs, state.allMessagesByID, message => isResponse(message) && !hasLiveAgentMessage(message) && Boolean(message.context));
1336
- }
1337
-
1338
- export { ConnectToAgentReason as $, AgentsOnlineStatus as A, EVENT_NAME_UPDATE_HISTORY as B, asArray as C, findLastIndex as D, EVENT_NAME_CHANNEL_TRANSFER as E, isEventRequest as F, findLast as G, isOptionOrSuggestion as H, isDateResponseType as I, hasMessageResponsePanel as J, isUpdateHistoryRequest as K, InternalMessageResponseType as L, isSearchResultItem as M, isEmptySearchResultItem as N, EMPTY_CONTEXT as O, isAtStackRoot as P, hasResponseToRequest as Q, isFromAMainThread as R, isFallbackResponse as S, THREAD_ID_MAIN as T, EVENT_NAME_ALTERNATE_SUGGESTIONS_OPENED as U, hasLiveAgentMessage as V, EVENT_NAME_ALTERNATE_SUGGESTIONS_CLOSED as W, AgentMessageType as X, CustomMenuType as Y, hasSupportedServiceDesk as Z, getMediaDimensions as _, createEventMessageRequest as a, ButtonItemKind as a0, createMessageRequestForButtonItemOption as a1, ButtonItemType as a2, createMessageRequestForDate as a3, getOptionType as a4, isActionsResponse as a5, renderAsTour as a6, InternalMessageRequestType as a7, isChatStatusResponseType as a8, isOptionItem as a9, isSingleItemCarousel as aa, memoizeOne as ab, createTextItem as ac, ScreenShareState as ad, SkillType as ae, MAIN_SKILL as af, DIALOG_ROOT as ag, isConversationalSearchItem as ah, isAnythingElse as ai, isRepeatResponse as aj, ErrorType as ak, createMessageRequestForFileUpload as al, isBetaUserDefinedResponse as am, transformBetaUserDefinedResponse as an, createMessageResponseForItem as ao, isGridResponseType as ap, isCarouselResponseType as aq, isShowPanelButtonType as ar, isItemSupportedInResponseBody as as, isCardResponseType as at, isButtonResponseType as au, pushAll as av, createWelcomeRequest as b, createMessageRequestForChoice as c, arrayLastValue as d, isRequest as e, createMessageRequestForText as f, addDefaultsToMessage as g, isResponse as h, isLiveAgentMessage as i, createMessageResponseForText as j, isStreamCompleteItem as k, isStreamPartialItem as l, isStreamFinalResponse as m, isResponseWithNestedItems as n, asyncForEach as o, isForChatChannel as p, isPause as q, renderAsUserDefinedMessage as r, streamItemID as s, isConnectToAgent as t, hasTourUserDefinedType as u, hasServiceDesk as v, isChannelTransferToAgent as w, isTyping as x, isPanelResponseType as y, getLastBotResponseWithContext as z };
1
+ import{a3 as e,p as n,k as t,u as s,U as r,l as a,m as o,Q as i}from"./aiChatEntry2.js";const u="update_history";var c,_,E,f,l,d,N,A,T,p;!function(e){e.DEFAULT="default",e.SECONDARY="secondary",e.TERTIARY="tertiary",e.DANGER="danger",e.LINK="link"}(c||(c={})),function(e){e.POST_BACK="post_back",e.CUSTOM_EVENT="custom_event",e.SHOW_PANEL="show_panel",e.URL="url"}(_||(_={})),function(e){e.ONLINE="online",e.OFFLINE="offline",e.UNKNOWN="unknown"}(E||(E={})),function(e){e.ACCEPTED="accepted",e.DECLINED="declined",e.CANCELLED="cancelled",e.ENDED="ended"}(f||(f={})),function(e){e[e.CONNECTING=1]="CONNECTING",e[e.DISCONNECTED=2]="DISCONNECTED",e[e.USER_MESSAGE=3]="USER_MESSAGE"}(l||(l={})),function(e){e.INLINE_ERROR="inline_error",e.FROM_AGENT="from_agent",e.FROM_USER="from_user",e.AGENT_LEFT_CHAT="agent_left_chat",e.AGENT_ENDED_CHAT="agent_ended_chat",e.AGENT_JOINED="agent_joined",e.RELOAD_WARNING="user_connected_warning",e.TRANSFER_TO_AGENT="transfer_to_agent",e.USER_ENDED_CHAT="user_ended_chat",e.CHAT_WAS_ENDED="chat_was_ended",e.DISCONNECTED="disconnected",e.RECONNECTED="reconnected",e.SHARING_REQUESTED="sharing_requested",e.SHARING_ACCEPTED="sharing_accepted",e.SHARING_DECLINED="sharing_declined",e.SHARING_CANCELLED="sharing_cancelled",e.SHARING_ENDED="sharing_ended",e.SYSTEM="system"}(d||(d={})),function(e){e.STREAM_LOADING="stream_loading",e.SESSION_EXPIRED="session_expired",e.CHANNEL_TRANSFER_FAILED="channel_transfer_failed",e.CARD="card",e.CAROUSEL="carousel",e.BUTTON="button",e.GRID="grid",e.PANEL="panel",e.WATSON_ORCHESTRATE_FORM="user_defined_ibm_wo_form"}(N||(N={})),function(e){e.FILE="file"}(A||(A={})),function(e){e.CHAT="chat",e.WHATSAPP="whatsapp",e.FACEBOOK="facebook",e.SLACK="slack"}(T||(T={})),function(e){e.BOT="bot",e.AGENT="agent"}(p||(p={}));const S="alternate_suggestions_opened",R="alternate_suggestions_closed",O="channel_transfer";var g;!function(e){e.CONNECT_TO_AGENT="connect_to_agent",e.LINK="link",e.SEARCH="search_result"}(g||(g={}));const h="main skill",I="root";var C;Object.assign(e,{REQUEST_CONNECT_TO_AGENT:"request_connect_to_agent",SEARCH:"search"}),Object.assign(n,{SUGGESTION:"suggestion",CONVERSATIONAL_SEARCH:"conversational_search",SEARCH:"search",CHANNEL_TRANSFER:"channel_transfer",TEXT_TO_SPEECH:"text_to_speech",SPEECH_TO_TEXT:"speech_to_text",START_ACTIVITIES:"start_activities",STOP_ACTIVITIES:"stop_activities",DTMF:"dtmf",END_SESSION:"end_session",RECORD:"record"}),function(e){e.ANSWER="answer",e.FLOW="flow"}(C||(C={}));var D,y,m=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function L(e,n){if(e.length!==n.length)return!1;for(var t=0;t<e.length;t++)if(s=e[t],r=n[t],!(s===r||m(s)&&m(r)))return!1;var s,r;return!0}function G(e,n){void 0===n&&(n=L);var t=null;function s(){for(var s=[],r=0;r<arguments.length;r++)s[r]=arguments[r];if(t&&t.lastThis===this&&n(s,t.lastArgs))return t.lastResult;var a=e.apply(this,s);return t={lastResult:a,lastArgs:s,lastThis:this},a}return s.clear=function(){t=null},s}!function(e){e.SEARCH="search",e.DIALOG="dialog",e.ACTIONS="actions"}(D||(D={})),function(e){e[e.STARTED=1]="STARTED",e[e.CONTINUING=2]="CONTINUING",e[e.ENDED=3]="ENDED"}(y||(y={}));const v="main";var U,H,F;function M(e){return Array.isArray(e)?e:[e]}async function b(e,n){for(let t=0;t<e.length;t++){const s=e[t];await n(s,t,e)}}function B(e,n,t){const s=P(e,n);return-1===s?void 0:e[s]}function P(e,n,t){if(e){for(let t=e.length-1;t>=0;t--){if(n(e[t],t,e))return t}}return-1}function w(e,n){const t=e.length;e.length=t+n.length;for(let s=0;s<n.length;s++)e[t+s]=n[s];return e}function k(e){return e&&e.length?e[e.length-1]:null}!function(e){e.ASSISTANT_REQUESTED="assistant_requested",e.USER_REQUESTED="user_requested",e.GENERAL_ERROR="general_error",e.TRANSFER_FAILURE="transfer_failure"}(U||(U={})),function(e){e.HUMAN_AGENT="human_agent",e.USER="user",e.WATSON="watson",e.SERVICE="service"}(H||(H={})),function(e){e.MALE="male",e.FEMALE="female",e.OTHER="other"}(F||(F={}));const x=/([^#a-zA-Z0-9_]|^)anything_else([^a-zA-Z0-9_]|$)/,W=G((e=>{const n={};return e?.skills&&e.skills.forEach((e=>{e.type!==D.DIALOG&&e.type!==D.ACTIONS||o(n,{global:{system:{}},skills:{[e.skill_reference]:{system:{},user_defined:{}}}})})),n}));function V(e){return e&&void 0!==e.output}function X(e){return V(e)&&(void 0!==e.output.user_defined?.debug?.history||void 0!==e.output.debug?.turn_events)}function q(e){return e?.item.response_type===n.DATE}function K(e){return e.id||(e.id=s(r.MESSAGE)),e.thread_id||(e.thread_id=v),e.history||(e.history={}),e.history.timestamp||(e.history.timestamp=Date.now()),void 0===e.history.from_history&&(e.history.from_history=!1),e}function j(e){switch(e?.item.response_type){case n.OPTION:case n.SUGGESTION:case N.BUTTON:return!0;default:return!1}}function Q(e){return void 0!==e?.input}function Y(e){return Boolean(e.item.agent_message_type)}function $(e){return V(e)&&Boolean(e.output.generic?.find((e=>e?.agent_message_type)))||Q(e)&&Boolean(e.input.agent_message_type)}function z(n){return n?.input?.message_type===e.EVENT}function J(e){return z(e)&&e?.input?.event?.name===u}function Z(e){return e.response_type===n.PAUSE&&1==e.typing}function ee(e){return e.response_type===n.PAUSE}function ne(e){return e?.response_type===n.OPTION&&void 0!==e.options}function te(e){return e?.response_type===n.CHANNEL_TRANSFER}function se(e){const{generic:n}=e.output;return n.some(te)&&n.some(Re)}function re(e){return e.output.generic.some((e=>{let n=e;return ye[e.user_defined?.user_defined_type]&&(n=e.user_defined),qe(n)}))}function ae(e){return!e.channels||e.channels.some((e=>"chat"===e.channel))}function oe(e,n){return e.thread_id===v||n?.thread_id===v}function ie(e){return"fallback"===e.output.debug?.branch_exited_reason}function ue(e,n){if(!e||!n)return!1;const t=k(e.output.debug?.nodes_visited)?.dialog_node,s=k(n.output.debug?.nodes_visited)?.dialog_node;return t&&t===s}function ce(e){return Boolean(!e.dialog_stack?.[0]||e.dialog_stack[0].dialog_node===I)}function _e(e){return e.replace(/(\r\n|\n|\r)/gm," ")}function Ee(e,n){const t={id:s(r.MESSAGE),thread_id:v,...a(e.value)};return t.history={label:e.label,relatedMessageID:n},t}function fe(e,n){const t={id:s(r.MESSAGE),thread_id:v,input:null};return e.value?.input?.text?t.input=a(e.value.input):t.input={text:e.label},t.history={relatedMessageID:n},t}function le(){return K({id:s(r.MESSAGE),input:{text:""},history:{silent:!0,is_welcome_request:!0},thread_id:v})}function de(n){return K({input:{text:_e(n),message_type:e.TEXT}})}function Ne(e){return K({id:e.id,input:{text:e.file.name,message_type:A.FILE,agent_message_type:d.FROM_USER},history:{file_upload_status:i.UPLOADING}})}function Ae(e,n,t){const s=de(e);return s.history={label:n,relatedMessageID:t},s}function Te(e,t=v,a=n.TEXT,o){const i={response_type:a,text:e};return{id:s(r.MESSAGE),thread_id:t,output:{generic:[i]}}}function pe(e,n){return K({output:{generic:[e]}})}function Se(n){return K({input:{message_type:e.EVENT,event:n}})}function Re(e){return e?.response_type===n.CONNECT_TO_AGENT}function Oe(e){return e?.response_type===N.CARD}function ge(e){return e?.response_type===N.CAROUSEL}function he(e){return e?.response_type===N.BUTTON}function Ie(e){return he(e)&&e.button_type===_.SHOW_PANEL}function Ce(e){return he(e)?De(e.panel):Oe(e)||qe(e)?De(e):ge(e)?void 0!==e.items:Xe(e)}function De(e){return void 0!==e?.body||void 0!==e?.footer}t({id:null,input:{text:""},history:{silent:!0,is_welcome_request:!0},thread_id:v});const ye={user_defined_ibm_wo_form(e){const n=a(e);return n.item.response_type=N.WATSON_ORCHESTRATE_FORM,n},IBM_BETA_TRANSFORM_RESPONSE(e){const n=a(e),t=a(e.item.user_defined);return n.item=t,delete n.item.user_defined_type,n}};function me(e){return e.item.response_type===n.USER_DEFINED&&void 0!==ye[e.item.user_defined?.user_defined_type]}function Le(e){return(0,ye[e.item.user_defined?.user_defined_type])(e)}function Ge(e){switch(e.response_type){case n.TEXT:case n.IMAGE:case n.OPTION:case n.SUGGESTION:case n.SEARCH:case n.CONNECT_TO_AGENT:case n.CHANNEL_TRANSFER:case n.IFRAME:case n.VIDEO:case n.AUDIO:case n.DATE:case n.CONVERSATIONAL_SEARCH:case n.TABLE:case n.INLINE_ERROR:case N.STREAM_LOADING:case N.SESSION_EXPIRED:case N.CHANNEL_TRANSFER_FAILED:case N.CARD:case N.CAROUSEL:case N.BUTTON:case N.GRID:case N.PANEL:case N.WATSON_ORCHESTRATE_FORM:return!1;default:return!ve(e)}}function ve(e){return Ue(e)}function Ue(e){return"IBM_BETA_JOURNEYS_TOUR"===e?.user_defined?.user_defined_type}function He(e){return Boolean(e.public.serviceDeskFactory||Fe(e))}function Fe(e){return Boolean(e.remote.initConfig.service_desk?.is_on||e.public.serviceDesk?.integrationType)}function Me(e,n,t){let s=!1;for(let r=0;r<e.length;r++){const a=n[e[r]],o=t[a?.fullMessageID];if(s&&V(o))return!0;Q(o)&&!o?.history?.silent&&(s=!0)}return!1}function be(e){const n=e?.output.debug?.nodes_visited;return Boolean(n?.find((e=>x.test(e.conditions))))}function Be(e){return{response_type:n.TEXT,text:e}}function Pe(e){return e?.response_type===n.SEARCH}function we(e){return e?.response_type===n.CONVERSATIONAL_SEARCH}function ke(e){return!e?.primary_results?.length&&!e?.results?.length}function xe(e){const n=e?.item.response_type;switch(n){case N.SESSION_EXPIRED:case N.CHANNEL_TRANSFER_FAILED:return!0;default:return!1}}function We(e){switch(e.response_type){case n.IMAGE:case n.IFRAME:case n.VIDEO:case n.AUDIO:case n.TEXT:case n.USER_DEFINED:case N.CARD:case N.GRID:return!0;default:return!1}}function Ve(e){return ge(e)&&1===e.items.length}function Xe(e){return e?.response_type===N.GRID}function qe(e){return e?.response_type===N.PANEL}function Ke(e,n){let t="button";return e&&"button"===e?t="button":(e&&"dropdown"===e||n>4)&&(t="dropdown"),t}function je(e){return Boolean(e.partial_item)}function Qe(e){return Boolean(e.complete_item)}function Ye(e){return Boolean(e.final_response)}function $e(e,n){const t=n?.streaming_metadata?.id;return t?`${e}-${t}`:null}function ze(e){return e.dimensions||e.channel_options?.chat?.dimensions}function Je(e){return function(e,n,t){for(let s=e.length-1;s>=0;s--){const r=n[e[s]];if(t(r,s,e))return r}}(e.botMessageState.messageIDs||[],e.allMessagesByID,(e=>V(e)&&!$(e)&&Boolean(e.context)))}export{U as $,E as A,u as B,M as C,P as D,O as E,z as F,B as G,j as H,q as I,re as J,J as K,N as L,Pe as M,ke as N,W as O,ce as P,Me as Q,oe as R,ie as S,v as T,S as U,$ as V,R as W,d as X,p as Y,Fe as Z,ze as _,Se as a,c as a0,fe as a1,_ as a2,Ae as a3,Ke as a4,X as a5,ve as a6,A as a7,xe as a8,ne as a9,Ve as aa,G as ab,Be as ac,f as ad,D as ae,h as af,I as ag,we as ah,be as ai,ue as aj,l as ak,Ne as al,me as am,Le as an,pe as ao,Xe as ap,ge as aq,Ie as ar,We as as,Oe as at,he as au,w as av,le as b,Ee as c,k as d,Q as e,de as f,K as g,V as h,Y as i,Te as j,Qe as k,je as l,Ye as m,Ce as n,b as o,ae as p,ee as q,Ge as r,$e as s,Re as t,Ue as u,He as v,se as w,Z as x,qe as y,Je as z};