@sendbird/ai-agent-messenger-react 1.3.2 → 1.4.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.
Files changed (45) hide show
  1. package/dist/cjs/BHzdI_Qt.cjs +1 -0
  2. package/dist/cjs/BJrc6-lv.cjs +1 -0
  3. package/dist/cjs/Bb0Nr21w.cjs +1 -0
  4. package/dist/cjs/{CuE-R-Ab.cjs → C5K5hHy4.cjs} +1 -1
  5. package/dist/cjs/C6S9YvOe.cjs +1 -0
  6. package/dist/cjs/CzB3EwDs.cjs +1 -0
  7. package/dist/cjs/{udFozCQd.cjs → D1cSvUyI.cjs} +1 -1
  8. package/dist/cjs/D6zoiaPq.cjs +1 -0
  9. package/dist/cjs/{D0K6vsP-.cjs → DCYbEbRy.cjs} +1 -1
  10. package/dist/cjs/{D7p9IHLh.cjs → DdDHgZcy.cjs} +1 -1
  11. package/dist/cjs/Df_7d5l_.cjs +1 -0
  12. package/dist/cjs/KtTuzALW.cjs +1 -0
  13. package/dist/cjs/QbzBXqp7.cjs +1 -0
  14. package/dist/cjs/erHZgq1d.cjs +309 -0
  15. package/dist/cjs/{Qn-Vab7D.cjs → kjUExkVf.cjs} +1 -1
  16. package/dist/es/{DYR8UT_l.js → B-Bit2rH.js} +21 -5
  17. package/dist/es/{BKSUGIyL.js → B7zUx3wi.js} +21 -5
  18. package/dist/es/{D0QwWNMF.js → BDu5g5oT.js} +21 -5
  19. package/dist/es/BFu7kfm0.js +4787 -0
  20. package/dist/es/{jtdZ66dz.js → BMpxfxq9.js} +1 -1
  21. package/dist/es/{B1s75De5.js → BOQBJafG.js} +21 -5
  22. package/dist/es/{CA1gVgSD.js → BgVN3jH0.js} +21 -5
  23. package/dist/es/{EylKxx4d.js → CGGa6Wi6.js} +21 -5
  24. package/dist/es/{D5uRw0Em.js → DAj-QM_C.js} +1 -1
  25. package/dist/es/{DcqbdvlW.js → DGEcXOnE.js} +21 -5
  26. package/dist/es/{kE3eGJ-O.js → DU-buYVt.js} +1 -1
  27. package/dist/es/{DhUBPQ6o.js → DxAEO4J0.js} +1 -1
  28. package/dist/es/{CVCUjr3Q.js → dnxo1nL1.js} +1 -1
  29. package/dist/es/{Dxrtj2R8.js → fgcpgo5V.js} +21 -5
  30. package/dist/es/{BAebVbLs.js → qC-GIbc4.js} +20 -4
  31. package/dist/index.cjs +1 -1
  32. package/dist/index.d.ts +173 -9
  33. package/dist/index.js +1 -1
  34. package/package.json +7 -7
  35. package/dist/cjs/6xTfJrmg.cjs +0 -1
  36. package/dist/cjs/B4mujFdj.cjs +0 -1
  37. package/dist/cjs/BIDOBNC3.cjs +0 -1
  38. package/dist/cjs/BlshmoPb.cjs +0 -207
  39. package/dist/cjs/BzMiZszH.cjs +0 -1
  40. package/dist/cjs/D5dT1ruo.cjs +0 -1
  41. package/dist/cjs/DdQV23MS.cjs +0 -1
  42. package/dist/cjs/VJMogId3.cjs +0 -1
  43. package/dist/cjs/eFpF2Osy.cjs +0 -1
  44. package/dist/cjs/kTWMrzTz.cjs +0 -1
  45. package/dist/es/DcGmTG3A.js +0 -4104
@@ -1,4104 +0,0 @@
1
- import * as r from "react";
2
- import { createContext as ve, useContext as Q, useEffect as L, useState as _, useId as bn, useRef as N, useCallback as R, useMemo as ae, forwardRef as ye, useImperativeHandle as Er, useLayoutEffect as le, lazy as T, Suspense as ke, Component as xr, Fragment as Ut, useReducer as Cr, Children as vr } from "react";
3
- import yr, { SendbirdChatOptions as _r, SendbirdProduct as Sr, DeviceOsPlatform as Ht, SendbirdPlatform as Tr, ConnectionHandler as Je, SendbirdError as wr, SessionHandler as Ar, LogLevel as En, ConnectionState as kr } from "@sendbird/chat";
4
- import u, { css as I, ThemeProvider as Ir, useTheme as xt, createGlobalStyle as $r, StyleSheetManager as Mr, keyframes as xn } from "styled-components";
5
- import { format as Cn, isSameMinute as zt, isSameDay as Or } from "date-fns";
6
- import { enUS as Lr } from "date-fns/locale/en-US";
7
- import { AIAgentModule as Rr, ConversationStatus as W, ConversationType as Dr } from "@sendbird/chat/aiAgent";
8
- import { useGroupChannelMessages as Nr, useGroupChannelHandler as Xe, useForceUpdate as Pr } from "@sendbird/uikit-tools";
9
- import { GroupChannelModule as Br, GroupChannelListOrder as vn, GroupChannelHandler as Fr } from "@sendbird/chat/groupChannel";
10
- import { renderer as Ur, parser as Hr, MessageProvider as zr } from "@sendbird/react-uikit-message-template-view";
11
- import { createMessageTemplate as Vr } from "@sendbird/uikit-message-template";
12
- import yn from "dompurify";
13
- import { SendingStatus as dt, MessageMetaArray as Wr } from "@sendbird/chat/message";
14
- import { isSameDay as Gr } from "date-fns/isSameDay";
15
- import { createPortal as jr } from "react-dom";
16
- import Kr from "@emotion/is-prop-valid";
17
- const G = (e, t) => {
18
- const n = ve(null), o = ({ children: a, value: l }) => /* @__PURE__ */ r.createElement(n.Provider, { value: l }, typeof a == "function" ? a(l) : a), s = ({ children: a }) => /* @__PURE__ */ r.createElement(n.Consumer, null, (l) => l ? typeof a == "function" ? a(l) : a : null), i = () => {
19
- const a = Q(n);
20
- if (!a)
21
- throw new Error(`use${e}Context must be used within a ${e}Provider`);
22
- return a;
23
- };
24
- return n.displayName = `${e}Context`, o.displayName = `${e}Provider`, s.displayName = `${e}Consumer`, i.displayName = `use${e}Context`, { Context: n, Provider: o, Consumer: s, useContext: i };
25
- };
26
- function _e(e) {
27
- const t = ve({
28
- Template: e.template,
29
- updateTemplate: () => {
30
- },
31
- components: e.components,
32
- updateComponent: () => {
33
- }
34
- });
35
- function n({ children: i }) {
36
- const [a, l] = _(() => e.template), [c, d] = _(e.components), h = {
37
- Template: a,
38
- updateTemplate: (m) => l(() => m),
39
- components: c,
40
- updateComponent: (m, f) => d((x) => ({ ...x, [m]: f }))
41
- };
42
- return /* @__PURE__ */ r.createElement(t.Provider, { value: h }, i);
43
- }
44
- function o({ template: i, children: a }) {
45
- const { updateTemplate: l } = Q(t);
46
- return L(() => {
47
- i && l(i);
48
- }, [i]), /* @__PURE__ */ r.createElement(r.Fragment, null, a);
49
- }
50
- function s({ children: i }) {
51
- return /* @__PURE__ */ r.createElement(n, null, i);
52
- }
53
- return s.defaults = e, s.useContext = () => Q(t), s.Context = t, s.Template = o, Object.keys(e.components).forEach((i) => {
54
- s[i] = function({
55
- component: l
56
- }) {
57
- const { updateComponent: c } = Q(t);
58
- return L(() => {
59
- l && c(i, l);
60
- }, [l]), null;
61
- };
62
- }), s;
63
- }
64
- function Zr(...e) {
65
- return function({ children: n }) {
66
- return e.reduce((o, s) => /* @__PURE__ */ r.createElement(s, null, o), n);
67
- };
68
- }
69
- function ut() {
70
- }
71
- function Yr() {
72
- const e = /iPad|iPhone|iPod/.test(navigator.userAgent), t = /Android/.test(navigator.userAgent);
73
- return e || t;
74
- }
75
- function qr(e) {
76
- let t = 0;
77
- for (let n = 0; n < e.length; n++)
78
- t = (t << 5) - t + e.charCodeAt(n), t |= 0;
79
- return t.toString(16);
80
- }
81
- const Vt = (e) => {
82
- try {
83
- return JSON.parse(e === "" ? "{}" : e);
84
- } catch {
85
- return {};
86
- }
87
- }, Se = {
88
- isStreaming(e) {
89
- const t = Vt(e.data);
90
- return typeof t == "object" && !!t.stream;
91
- },
92
- isWelcomeMessage(e, t) {
93
- var n;
94
- if (((n = e.extendedMessagePayload) == null ? void 0 : n.bot_message_type) === "welcome")
95
- return !0;
96
- if ((e.isUserMessage() || e.isFileMessage()) && e.sender.userId === t) {
97
- const o = Vt(e.data);
98
- return !(o != null && o.respond_mesg_id) && !(o != null && o.stream);
99
- }
100
- return !1;
101
- },
102
- isGeneratedMessage(e) {
103
- var t;
104
- return ((t = e.extendedMessagePayload) == null ? void 0 : t.bot_message_type) === "generated";
105
- },
106
- checkExtendedFieldPresence(e) {
107
- const t = e.extendedMessagePayload || {}, n = (a) => a.some((l) => typeof t[l] < "u"), o = n(ot.ui), s = n(ot.trail), i = n(ot.marking);
108
- return { ui: o, trail: s, marking: i };
109
- },
110
- shouldScrollToBottom(e, t, n = !1) {
111
- if ((e.isUserMessage() || e.isFileMessage() || e.isMultipleFilesMessage()) && e.sender.userId === t) {
112
- if (this.isGeneratedMessage(e) && this.isStreaming(e))
113
- return !0;
114
- const { ui: i, trail: a, marking: l } = this.checkExtendedFieldPresence(e);
115
- return i ? !(!n && l) : !!(n && (a || l));
116
- }
117
- return !0;
118
- }
119
- }, ot = {
120
- ui: ["suggested_replies", "cta_button", "message_template", "csat"],
121
- trail: ["groundedness", "manual", "function_calls"],
122
- marking: ["is_hallucination", "is_moderated", "flagged_types"]
123
- }, Jr = "1.3.2", Ee = "sb-agent", Xr = Jr, st = `@${Ee}`, Wt = ({ appId: e, aiAgentId: t, storage: n }) => {
124
- const o = {
125
- templateBase: `${st}-template`,
126
- template: (s) => `${o.templateBase}/templates/${s}`,
127
- templateToken: () => `${o.templateBase}-template/message-template/tokens`,
128
- messengerSession: (s) => {
129
- const i = qr(`${e}/${t}/${s}`);
130
- return `${st}-udata/${i}`;
131
- },
132
- anonUserSession: () => `${st}-session/${e}/${t}`
133
- };
134
- return {
135
- template: {
136
- set: (s, i) => n.set(o.template(s), i),
137
- get: (s) => n.get(o.template(s)),
138
- setCachedToken: (s) => n.set(o.templateToken(), s),
139
- getCachedToken: () => n.get(o.templateToken()),
140
- clear: () => {
141
- n.getKeys(o.templateBase).forEach(n.delete);
142
- }
143
- },
144
- messenger: {
145
- getSettings: (s) => {
146
- try {
147
- const i = n.get(o.messengerSession(s));
148
- return i ? JSON.parse(i) : null;
149
- } catch {
150
- return null;
151
- }
152
- },
153
- setSettings: (s, i) => {
154
- try {
155
- const a = JSON.stringify(i);
156
- n.set(o.messengerSession(s), a);
157
- } catch {
158
- return;
159
- }
160
- },
161
- getAnonUser: () => {
162
- try {
163
- const s = n.get(o.anonUserSession());
164
- return s ? JSON.parse(s) : null;
165
- } catch {
166
- return null;
167
- }
168
- },
169
- setAnonUser: (s) => {
170
- try {
171
- const i = JSON.stringify(s);
172
- n.set(o.anonUserSession(), i);
173
- } catch {
174
- return;
175
- }
176
- },
177
- clear: (s) => {
178
- try {
179
- n.delete(o.messengerSession(s)), n.delete(o.anonUserSession());
180
- } catch {
181
- return;
182
- }
183
- }
184
- }
185
- };
186
- };
187
- class _n {
188
- constructor(t) {
189
- this.logger = t, this.subscribers = {};
190
- }
191
- async send(t) {
192
- const n = Qr(), o = this.subscribers[t.type];
193
- if (o) {
194
- this.logger.debug(`messenger.dispatcher: dispatching command: ${t.type}`, t.payload);
195
- const s = o.map((i) => i(t.payload));
196
- await Promise.all(s).catch((i) => {
197
- this.logger.error(`messenger.dispatcher: error in callback for command: ${t.type}`, i);
198
- });
199
- }
200
- return n.resolve(), n.promise;
201
- }
202
- subscribe(t, n) {
203
- this.subscribers[t] || (this.subscribers[t] = []), this.subscribers[t].push(n);
204
- }
205
- unsubscribe(t, n) {
206
- this.subscribers[t] && (this.subscribers[t] = this.subscribers[t].filter((o) => o !== n));
207
- }
208
- }
209
- const Qr = () => {
210
- let e = ut, t = ut;
211
- return { promise: new Promise((o, s) => {
212
- e = o, t = s;
213
- }), resolve: e, reject: t };
214
- };
215
- var Sn = /* @__PURE__ */ ((e) => (e[e.VERBOSE = 0] = "VERBOSE", e[e.DEBUG = 1] = "DEBUG", e[e.INFO = 2] = "INFO", e[e.WARN = 3] = "WARN", e[e.ERROR = 4] = "ERROR", e[e.NONE = 5] = "NONE", e))(Sn || {});
216
- class Tn {
217
- constructor(t) {
218
- this.level = t;
219
- }
220
- verbose(...t) {
221
- this.level <= 0 && console.log(`[${Ee}/verbose]`, ...t);
222
- }
223
- debug(...t) {
224
- this.level <= 1 && console.log(`[${Ee}/debug]`, ...t);
225
- }
226
- info(...t) {
227
- this.level <= 2 && console.log(`[${Ee}/info]`, ...t);
228
- }
229
- warn(...t) {
230
- this.level <= 3 && console.warn(`[${Ee}/warn]`, ...t);
231
- }
232
- error(...t) {
233
- this.level <= 4 && console.error(`[${Ee}/error]`, ...t);
234
- }
235
- }
236
- function Gt(e, t, n) {
237
- const o = yr.init({
238
- appId: e,
239
- modules: [new Br(), new Rr()],
240
- localCacheEnabled: !0,
241
- options: new _r({ typingIndicatorInvalidateTime: 3e4 }),
242
- ...n
243
- });
244
- return o.addSendbirdExtensions(
245
- [{ version: Xr, product: Sr.AI_AGENT, platform: t.platform }],
246
- { platform: t.deviceOSPlatform, version: t.deviceOSVersion },
247
- t.customData
248
- ) || console.warn("Invalid Sendbird Extensions", t), o;
249
- }
250
- const {
251
- Provider: eo,
252
- useContext: ue
253
- } = G("AIAgent");
254
- function to({
255
- appId: e,
256
- aiAgentId: t,
257
- keyValueStorage: n,
258
- language: o,
259
- countryCode: s,
260
- context: i,
261
- queryParams: a,
262
- chatSDK: l,
263
- chatParams: c,
264
- children: d,
265
- logger: h,
266
- dispatcher: m,
267
- extensions: f = {
268
- platform: Tr.JS,
269
- deviceOSPlatform: Yr() ? Ht.MOBILE_WEB : Ht.WEB
270
- }
271
- }) {
272
- const [x, E] = _(() => {
273
- const b = h ?? new Tn(Sn.WARN), g = m ?? new _n(b);
274
- return {
275
- appId: e,
276
- aiAgentId: t,
277
- language: o,
278
- countryCode: s,
279
- context: i,
280
- queryParams: a,
281
- keyValueStorage: n,
282
- logger: b,
283
- dispatcher: g,
284
- chatSDK: l ?? Gt(e, f, c),
285
- cache: Wt({ appId: e, aiAgentId: t, storage: n })
286
- };
287
- });
288
- return L(() => {
289
- E((b) => {
290
- let g = b.logger, C = b.dispatcher, v = b.chatSDK;
291
- return h && h !== b.logger && (g = h), m && m !== b.dispatcher && (C = m), l && l !== b.chatSDK ? v = l : !l && b.chatSDK.appId !== e && (v = Gt(e, f, { newInstance: !0, ...c })), {
292
- ...b,
293
- appId: e,
294
- aiAgentId: t,
295
- keyValueStorage: n,
296
- language: o,
297
- countryCode: s,
298
- context: i,
299
- queryParams: a,
300
- logger: g,
301
- dispatcher: C,
302
- chatSDK: v,
303
- cache: Wt({ appId: e, aiAgentId: t, storage: n })
304
- };
305
- });
306
- }, [e, t, o, s, i, h, m, l]), L(() => () => {
307
- x.chatSDK.disconnectWebSocket();
308
- }, [x.chatSDK]), /* @__PURE__ */ r.createElement(eo, { value: x }, d);
309
- }
310
- const no = (e, t, n) => Nr(e, t, { ...n, strictStreamingOrder: !0 });
311
- var mt = /* @__PURE__ */ ((e) => (e.ConversationClose = "conv.close", e))(mt || {});
312
- class ro {
313
- constructor(t = {}) {
314
- this.payload = t;
315
- }
316
- toJSON() {
317
- return JSON.stringify({ type: this.type, payload: this.payload });
318
- }
319
- }
320
- const oo = {
321
- CloseConversation: (e) => new so(e)
322
- };
323
- class so extends ro {
324
- constructor() {
325
- super(...arguments), this.type = "conv.close";
326
- }
327
- }
328
- const {
329
- Provider: io
330
- } = G("AIAgentConversation");
331
- function ao({
332
- children: e,
333
- channelUrl: t,
334
- onChannelDeleted: n,
335
- onMessagesReceived: o,
336
- onMessagesUpdated: s,
337
- onConversationClosedViaDispatcher: i,
338
- onBeforeSendMessage: a,
339
- onAfterSendMessage: l = ut
340
- }) {
341
- var g;
342
- const { chatSDK: c, logger: d, dispatcher: h } = ue(), { channel: m, channelFetchError: f, fetchChannel: x } = lo(t), E = no(c, m, {
343
- shouldCountNewMessages: () => !1,
344
- onChannelDeleted: n,
345
- onMessagesReceived: (C) => o == null ? void 0 : o(C),
346
- onMessagesUpdated: (C) => s == null ? void 0 : s(C),
347
- logger: d
348
- });
349
- L(() => {
350
- const C = async (v) => {
351
- const S = typeof (v == null ? void 0 : v.channelUrl) == "string";
352
- m && S && v.channelUrl !== m.url || (d.debug("conversation.dispatcher: try to close conversation", m), m != null && m.conversation && m.conversation.status === W.OPEN && (await m.closeConversation(), i == null || i()));
353
- };
354
- return h.subscribe(mt.ConversationClose, C), () => {
355
- h.unsubscribe(mt.ConversationClose, C);
356
- };
357
- }, [h, (g = m == null ? void 0 : m.conversation) == null ? void 0 : g.status, i]);
358
- const b = {
359
- conversation: (m == null ? void 0 : m.conversation) ?? void 0,
360
- channelSource: {
361
- channel: m,
362
- error: f,
363
- refetch: () => x()
364
- },
365
- messageSource: {
366
- messages: E.messages,
367
- initialized: E.initialized,
368
- loadPrevious: () => E.loadPrevious(),
369
- loadNext: () => E.loadNext(),
370
- sendUserMessage: async (C) => {
371
- var S;
372
- if (((S = m == null ? void 0 : m.conversation) == null ? void 0 : S.status) === W.CLOSED)
373
- throw new Error("Conversation is closed");
374
- a && (C = await a(C));
375
- const v = await E.sendUserMessage(C, l);
376
- return l == null || l(v), v;
377
- },
378
- sendFileMessage: async (C) => {
379
- var S;
380
- if (((S = m == null ? void 0 : m.conversation) == null ? void 0 : S.status) === W.CLOSED)
381
- throw new Error("Conversation is closed");
382
- a && (C = await a(C));
383
- const v = await E.sendFileMessage(C, l);
384
- return l == null || l(v), v;
385
- }
386
- }
387
- };
388
- return /* @__PURE__ */ r.createElement(io, { value: b }, e);
389
- }
390
- function lo(e) {
391
- const { chatSDK: t, logger: n } = ue(), [o, s] = _(void 0), [i, a] = _(void 0);
392
- async function l() {
393
- if (n.debug("conversation.fetchChannel: start"), s(void 0), a(void 0), e)
394
- try {
395
- n.debug("conversation.fetchChannel: get channel", e);
396
- const c = await t.groupChannel.getChannel(e);
397
- s(c);
398
- const d = new Je({ onReconnectSucceeded: () => c.refresh() });
399
- t.addConnectionHandler(`sba-refresh-${e}`, d), n.debug("conversation.fetchChannel: fetched channel", c);
400
- } catch (c) {
401
- c instanceof wr && a(c), n.error("conversation.fetchChannel: error", c);
402
- }
403
- }
404
- return L(() => {
405
- l();
406
- }, [e, t]), {
407
- channel: o,
408
- channelFetchError: i,
409
- fetchChannel: l
410
- };
411
- }
412
- class co {
413
- /**
414
- * Creates a new ConversationListCollection instance.
415
- * @param sdk - The Sendbird Chat SDK instance
416
- * @param params - Configuration parameters for the collection
417
- */
418
- constructor(t, { filter: n, limit: o = 20 }) {
419
- var s, i, a, l, c;
420
- this._isDisposed = !1, this._handlerId = `handler-id-${Date.now()}`, this._order = vn.LATEST_LAST_MESSAGE, this.filter = n, this._sdk = t, this._pinnedChannels = [], this._channels = [], this._limit = o, this._query = this._sdk.aiAgent.createMyGroupChannelListQuery({
421
- aiAgentChannelFilter: (s = this.filter) == null ? void 0 : s.aiAgentChannelFilter,
422
- aiAgentConversationStatusFilter: (i = this.filter) == null ? void 0 : i.aiAgentConversationStatusFilter,
423
- aiAgentIds: (a = this.filter) == null ? void 0 : a.aiAgentIds,
424
- deskChannelFilter: (l = this.filter) == null ? void 0 : l.deskChannelFilter,
425
- pinnedChannelUrls: (c = this.filter) == null ? void 0 : c.pinnedChannelUrls,
426
- limit: this._limit
427
- }), this._token = "", this._timestamp = Number.MAX_SAFE_INTEGER, this._isSyncing = !1, this._channelHandler = new Fr({
428
- onChannelChanged: (d) => {
429
- d.isGroupChannel() && (this._query.belongsTo(d) ? this._addChannelsToView([d], !1) : this._removeChannelsFromView([d.url]));
430
- },
431
- onChannelDeleted: (d) => {
432
- this._removeChannelsFromView([d]);
433
- }
434
- }), this._connectionHandler = new Je({
435
- onReconnectSucceeded: () => {
436
- this._isDefaultChangelogSyncTimestampUpdated && this._syncChannelChangelogs();
437
- }
438
- }), this._sdk.addConnectionHandler(this._handlerId, this._connectionHandler), this._sdk.groupChannel.addGroupChannelHandler(this._handlerId, this._channelHandler);
439
- }
440
- /**
441
- * Checks if the default changelog sync timestamp has been updated.
442
- */
443
- get _isDefaultChangelogSyncTimestampUpdated() {
444
- return this._timestamp !== Number.MAX_SAFE_INTEGER;
445
- }
446
- /**
447
- * Sets the default changelog sync timestamp based on the first non-pinned channel.
448
- * @param channels - Array of channels to analyze
449
- */
450
- _setDefaultChangelogsSyncTimestamp(t) {
451
- var i, a;
452
- const n = new Set(((i = this.filter) == null ? void 0 : i.pinnedChannelUrls) ?? []), o = t.find((l) => !n.has(l.url));
453
- let s;
454
- o ? s = ((a = o.lastMessage) == null ? void 0 : a.createdAt) ?? o.createdAt : s = this._query.lastResponseAt, this._timestamp > s && (this._timestamp = s);
455
- }
456
- /**
457
- * Synchronizes channel changelogs to keep the collection up-to-date.
458
- * @returns Promise that resolves to an empty array
459
- */
460
- async _syncChannelChangelogs() {
461
- if (this._isDisposed) return [];
462
- if (this._isSyncing) return [];
463
- try {
464
- this._isSyncing = !0;
465
- let t;
466
- for (this._token ? t = await this._sdk.aiAgent.getMyGroupChannelChangeLogsByToken(this._token, this.filter) : t = await this._sdk.aiAgent.getMyGroupChannelChangeLogsByTimestamp(this._timestamp, this.filter), this._token = t.token, this._addChannelsToView(t.updatedChannels), this._removeChannelsFromView(t.deletedChannelUrls); t.hasMore && t.token; )
467
- t = await this._sdk.aiAgent.getMyGroupChannelChangeLogsByToken(this._token, this.filter), this._token = t.token, this._addChannelsToView(t.updatedChannels), this._removeChannelsFromView(t.deletedChannelUrls);
468
- } catch {
469
- } finally {
470
- this._isSyncing = !1;
471
- }
472
- return [];
473
- }
474
- /**
475
- * Upserts pinned channels maintaining the order specified in pinnedChannelUrls.
476
- * @param channels - Pinned channels to upsert
477
- * @returns Object containing added, updated channels and unmatched URLs
478
- */
479
- _upsertPinnedChannelsToArray(t) {
480
- var l;
481
- const n = ((l = this.filter) == null ? void 0 : l.pinnedChannelUrls) ?? [], o = new Map(n.map((c, d) => [c, d])), s = [], i = [], a = [];
482
- for (const c of t) {
483
- if (!this._query.belongsTo(c)) {
484
- a.push(c.url);
485
- continue;
486
- }
487
- const d = o.get(c.url);
488
- if (d === void 0) continue;
489
- const h = gt(this._pinnedChannels, c);
490
- h >= 0 ? (this._pinnedChannels.splice(h, 1), i.push(c)) : s.push(c);
491
- const f = this._pinnedChannels.findIndex((E) => (o.get(E.url) ?? 1 / 0) > d), x = f === -1 ? this._pinnedChannels.length : f;
492
- this._pinnedChannels.splice(x, 0, c);
493
- }
494
- return { addedChannels: s, updatedChannels: i, unmatchedChannelUrls: a };
495
- }
496
- /**
497
- * Upserts regular (non-pinned) channels with time-based sorting.
498
- * @param channels - Regular channels to upsert
499
- * @param forceAppend - Whether to force append channels at the end regardless of hasMore status
500
- * @returns Object containing added, updated channels and unmatched URLs
501
- */
502
- _upsertRegularChannelsToArray(t, n = !1) {
503
- const o = [], s = [], i = [];
504
- for (const a of t) {
505
- if (!this._query.belongsTo(a)) {
506
- o.push(a.url);
507
- continue;
508
- }
509
- const l = gt(this._channels, a), c = l < 0;
510
- !c && this._channels.splice(l, 1);
511
- const h = uo(this._channels, a, this._order).place, m = h === this._channels.length;
512
- c ? m ? (n || !this.hasMore) && (this._channels.push(a), s.push(a)) : (this._channels.splice(h, 0, a), s.push(a)) : (this._channels.splice(h, 0, a), i.push(a));
513
- }
514
- return { addedChannels: s, updatedChannels: i, unmatchedChannelUrls: o };
515
- }
516
- /**
517
- * Adds or updates channels in the collection, separating pinned and non-pinned channels.
518
- * @param channels - Channels to add or update
519
- * @param forceAppend - Whether to force append channels at the end
520
- */
521
- _addChannelsToView(t, n = !1) {
522
- var m, f, x, E, b;
523
- const o = new Set(((m = this.filter) == null ? void 0 : m.pinnedChannelUrls) ?? []), s = [], i = [];
524
- for (const g of t)
525
- o.has(g.url) ? s.push(g) : i.push(g);
526
- const a = this._upsertPinnedChannelsToArray(s), l = this._upsertRegularChannelsToArray(i, n), c = a.addedChannels.concat(l.addedChannels), d = a.updatedChannels.concat(l.updatedChannels), h = a.unmatchedChannelUrls.concat(l.unmatchedChannelUrls);
527
- c.length > 0 && ((x = (f = this._collectionEventHandler) == null ? void 0 : f.onChannelsAdded) == null || x.call(f, {}, c)), d.length > 0 && ((b = (E = this._collectionEventHandler) == null ? void 0 : E.onChannelsUpdated) == null || b.call(E, {}, d)), h.length > 0 && this._removeChannelsFromView(h);
528
- }
529
- /**
530
- * Removes channels from the collection by their URLs.
531
- * @param channelUrls - Array of channel URLs to remove
532
- */
533
- _removeChannelsFromView(t) {
534
- var s, i, a;
535
- const n = new Set(((s = this.filter) == null ? void 0 : s.pinnedChannelUrls) ?? []), o = [];
536
- for (const l of t)
537
- if (n.has(l)) {
538
- const c = this._pinnedChannels.findIndex((d) => d.url === l);
539
- c >= 0 && (o.push(l), this._pinnedChannels.splice(c, 1));
540
- } else {
541
- const c = this._channels.findIndex((d) => d.url === l);
542
- c >= 0 && (o.push(l), this._channels.splice(c, 1));
543
- }
544
- o.length > 0 && ((a = (i = this._collectionEventHandler) == null ? void 0 : i.onChannelsDeleted) == null || a.call(i, {}, o));
545
- }
546
- /**
547
- * Gets all channels in the collection.
548
- * Pinned channels are always returned first, followed by non-pinned channels.
549
- * @returns Array of GroupChannel objects
550
- */
551
- get channels() {
552
- return this._isDisposed ? [] : [...this._pinnedChannels, ...this._channels];
553
- }
554
- /**
555
- * Indicates whether the collection has more channels to load.
556
- * @returns True if more channels can be loaded, false otherwise
557
- */
558
- get hasMore() {
559
- return this._isDisposed ? !1 : this._query.hasNext;
560
- }
561
- /**
562
- * Loads the next batch of channels from the server.
563
- * @returns Promise that resolves to an array of newly loaded channels
564
- */
565
- async loadMore() {
566
- if (this._isDisposed) return [];
567
- if (this.hasMore) {
568
- const t = await this._query.next();
569
- return this._setDefaultChangelogsSyncTimestamp(t), this._addChannelsToView(t, !0), t;
570
- }
571
- return [];
572
- }
573
- /**
574
- * Sets the event handler for collection updates.
575
- * @param handler - Event handler for channel collection changes
576
- */
577
- setConversationListCollectionHandler(t) {
578
- this._collectionEventHandler = t;
579
- }
580
- /**
581
- * Disposes the collection and cleans up all resources.
582
- * Stops all event handlers and clears all channels.
583
- */
584
- dispose() {
585
- this._isDisposed || (this._isDisposed = !0, this._collectionEventHandler = void 0, this._sdk.removeConnectionHandler(this._handlerId), this._sdk.groupChannel.removeGroupChannelHandler(this._handlerId), this._pinnedChannels.length = 0, this._channels.length = 0);
586
- }
587
- }
588
- const gt = (e, t) => e.findIndex((n) => n.isIdentical(t)), uo = (e, t, n) => {
589
- if (e.length > 0) {
590
- const o = gt(e, t);
591
- let s = 0, i = e.length - 1, a = Math.floor((s + i) / 2);
592
- for (; s < i; ) {
593
- const c = jt(e[a], t, n);
594
- if (c > 0)
595
- i = a, a = Math.floor((s + i) / 2);
596
- else if (c < 0)
597
- s = a + 1, a = Math.floor((s + i) / 2);
598
- else
599
- return { place: a, oldPosition: o };
600
- }
601
- return { place: jt(e[a], t, n) >= 0 ? a : a + 1, oldPosition: o };
602
- }
603
- return { place: e.length, oldPosition: -1 };
604
- }, jt = (e, t, n) => {
605
- switch (n) {
606
- case vn.LATEST_LAST_MESSAGE:
607
- if (e.lastMessage && t.lastMessage) {
608
- const o = t.lastMessage.createdAt - e.lastMessage.createdAt;
609
- return o === 0 ? t.createdAt - e.createdAt : o;
610
- } else return e.lastMessage ? -1 : t.lastMessage ? 1 : t.createdAt - e.createdAt;
611
- default:
612
- return 0;
613
- }
614
- };
615
- function mo(e, t) {
616
- var E, b, g, C, v, S, k, F;
617
- const n = bn(), [o, s] = _(!1), [i, a] = _(null), [l, c] = _([]), [d, h] = _(null), m = N(!1), f = R(async () => {
618
- if (!m.current && e.currentUser) {
619
- m.current = !0, s(!1), a(null), c([]);
620
- try {
621
- d == null || d.dispose();
622
- const $ = new co(e, t);
623
- $.setConversationListCollectionHandler({
624
- onChannelsAdded: () => {
625
- c($.channels);
626
- },
627
- onChannelsUpdated: () => {
628
- c($.channels);
629
- },
630
- onChannelsDeleted: () => {
631
- c($.channels);
632
- }
633
- }), await $.loadMore(), h($), a(null);
634
- } catch ($) {
635
- h(null), a($);
636
- } finally {
637
- s(!0), m.current = !1;
638
- }
639
- }
640
- }, [
641
- e,
642
- (E = t.filter) == null ? void 0 : E.aiAgentChannelFilter,
643
- (g = (b = t.filter) == null ? void 0 : b.aiAgentConversationStatusFilter) == null ? void 0 : g.join(),
644
- (v = (C = t.filter) == null ? void 0 : C.aiAgentIds) == null ? void 0 : v.join(),
645
- (S = t.filter) == null ? void 0 : S.deskChannelFilter,
646
- (F = (k = t.filter) == null ? void 0 : k.pinnedChannelUrls) == null ? void 0 : F.join(),
647
- t.limit
648
- ]), x = R(async () => {
649
- if (d)
650
- try {
651
- await d.loadMore();
652
- } catch ($) {
653
- a($);
654
- }
655
- }, [d]);
656
- return L(() => (e.addConnectionHandler(n, new Je({ onConnected: () => f() })), () => e.removeConnectionHandler(n)), [e, n, f]), L(() => {
657
- f();
658
- }, [f]), L(() => () => {
659
- m.current = !1, d == null || d.dispose();
660
- }, [d]), {
661
- initialized: o,
662
- error: i,
663
- channels: l,
664
- loadMore: x
665
- };
666
- }
667
- const {
668
- Provider: go
669
- } = G("AIAgentConversationList");
670
- function ho({
671
- conversationListLimit: e,
672
- conversationListFilter: t,
673
- children: n
674
- }) {
675
- var m, f;
676
- const { chatSDK: o, aiAgentId: s, queryParams: i } = ue(), a = { aiAgentIds: [s], aiAgentConversationStatusFilter: [W.CLOSED] }, l = e ?? ((m = i == null ? void 0 : i.conversationListParams) == null ? void 0 : m.limit), c = {
677
- ...a,
678
- ...(f = i == null ? void 0 : i.conversationListParams) == null ? void 0 : f.filter,
679
- ...t
680
- }, d = mo(o, { limit: l, filter: c }), h = {
681
- listSource: {
682
- initialized: d.initialized,
683
- error: d.error ?? void 0,
684
- channels: d.channels,
685
- loadMore: () => d.loadMore()
686
- }
687
- };
688
- return /* @__PURE__ */ r.createElement(go, { value: h }, n);
689
- }
690
- const ht = {
691
- DEFAULT_BOT_MSG_BG: "#eeeeee",
692
- WHITE: "#ffffff",
693
- BLACK: "#000000"
694
- };
695
- function wn(e) {
696
- return e.length === 4 ? `#${[...e.slice(1)].map((t) => t + t).join("")}` : e;
697
- }
698
- function po(e) {
699
- const t = wn(e);
700
- return [
701
- parseInt(t.slice(1, 3), 16),
702
- // r
703
- parseInt(t.slice(3, 5), 16),
704
- // g
705
- parseInt(t.slice(5, 7), 16)
706
- // b
707
- ];
708
- }
709
- function fo(e) {
710
- return `#${e.map((t) => t.toString(16).padStart(2, "0")).join("")}`;
711
- }
712
- function bo(e, t, n) {
713
- e /= 255, t /= 255, n /= 255;
714
- const o = Math.max(e, t, n), s = Math.min(e, t, n), i = o - s;
715
- let a = 0, l = 0;
716
- const c = (o + s) / 2;
717
- return o !== s && (l = c > 0.5 ? i / (2 - o - s) : i / (o + s)), o === e ? a = (t - n) / i + (t < n ? 6 : 0) : o === t ? a = (n - e) / i + 2 : o === n && (a = (e - t) / i + 4), a /= 6, [a, l, c];
718
- }
719
- function Eo(e, t, n) {
720
- let o, s, i;
721
- if (t === 0)
722
- o = s = i = n;
723
- else {
724
- const a = function(h, m, f) {
725
- return f < 0 && (f += 1), f > 1 && (f -= 1), f < 0.16666666666666666 ? h + (m - h) * 6 * f : f < 0.5 ? m : f < 0.6666666666666666 ? h + (m - h) * (0.6666666666666666 - f) * 6 : h;
726
- }, l = n < 0.5 ? n * (1 + t) : n + t - n * t, c = 2 * n - l;
727
- o = a(c, l, e + 1 / 3), s = a(c, l, e), i = a(c, l, e - 1 / 3);
728
- }
729
- return [Math.round(o * 255), Math.round(s * 255), Math.round(i * 255)];
730
- }
731
- function Be(e, t, n) {
732
- const [o, s, i] = po(e), [a, l, c] = bo(o, s, i), d = Math.max(0, Math.min(1, c * t)), h = Math.max(0, Math.min(1, l * n)), [m, f, x] = Eo(a, h, d);
733
- return fo([Math.round(m), Math.round(f), Math.round(x)]);
734
- }
735
- function xo(e, t = "light") {
736
- return {
737
- extraDark: Be(e, 0.6, 1.2),
738
- dark: Be(e, 0.85, 1.1),
739
- main: e,
740
- light: Be(e, t === "dark" ? 1.1 : 1.5, t === "dark" ? 0.95 : 0.9),
741
- extraLight: Be(e, t === "dark" ? 1.2 : 1.75, t === "dark" ? 0.9 : 0.8)
742
- };
743
- }
744
- function pt(e) {
745
- const t = wn(e), n = 149, o = +`0x${t[1]}${t[2]}`, s = +`0x${t[3]}${t[4]}`, i = +`0x${t[5]}${t[6]}`;
746
- return o * 0.299 + s * 0.587 + i * 0.114 > n ? ht.BLACK : ht.WHITE;
747
- }
748
- function Co(e, t, n, o, s) {
749
- return {
750
- base: {
751
- primary: t,
752
- primaryContrastContent: n,
753
- background: e.background50,
754
- headerBackground: e.background50,
755
- modalContentBackground: e.background50
756
- },
757
- metadata: {
758
- errorContent: e.ondark.textHighEmphasis,
759
- placeholderText: e.onlight.textLowEmphasis
760
- },
761
- messageInput: {
762
- background: e.background100
763
- },
764
- messageIncoming: {
765
- text: s,
766
- background: o
767
- },
768
- messageOutgoing: {
769
- text: n,
770
- background: t
771
- },
772
- csat: {
773
- background: e.background100
774
- }
775
- };
776
- }
777
- const vo = (e, t, n, o, s) => ({
778
- base: {
779
- primary: t,
780
- primaryContrastContent: n,
781
- background: e.background600,
782
- headerBackground: e.background500,
783
- modalContentBackground: e.background500
784
- },
785
- metadata: {
786
- errorContent: e.ondark.textHighEmphasis,
787
- placeholderText: e.ondark.textLowEmphasis
788
- },
789
- messageInput: {
790
- background: e.background400
791
- },
792
- messageIncoming: {
793
- text: s,
794
- background: o
795
- },
796
- messageOutgoing: {
797
- text: n,
798
- background: t
799
- },
800
- csat: {
801
- background: e.background400
802
- }
803
- }), Fe = {
804
- primary: {
805
- extraDark: "#491389",
806
- dark: "#6211c8",
807
- main: "#742ddd",
808
- light: "#c2a9fa",
809
- extraLight: "#dbd1ff"
810
- },
811
- secondary: {
812
- extraDark: "#066858",
813
- dark: "#027d69",
814
- main: "#259c72",
815
- light: "#69c085",
816
- extraLight: "#a8e2ab"
817
- },
818
- error: {
819
- extraDark: "#9d091e",
820
- dark: "#bf0711",
821
- main: "#de360b",
822
- light: "#f66161",
823
- extraLight: "#fdaaaa"
824
- },
825
- information: {
826
- extraDark: "#241389",
827
- dark: "#362ca9",
828
- main: "#4a48cd",
829
- light: "#a9bbfa",
830
- extraLight: "#d1dbff"
831
- },
832
- background700: "#000000",
833
- background600: "#161616",
834
- background500: "#2c2c2c",
835
- background400: "#393939",
836
- background300: "#bdbdbd",
837
- background200: "#e0e0e0",
838
- background100: "#eeeeee",
839
- background50: "#ffffff",
840
- onlight: {
841
- textHighEmphasis: "rgba(0, 0, 0, 0.88)",
842
- textMidEmphasis: "rgba(0, 0, 0, 0.5)",
843
- textLowEmphasis: "rgba(0, 0, 0, 0.38)",
844
- textDisabled: "rgba(0, 0, 0, 0.12)"
845
- },
846
- ondark: {
847
- textHighEmphasis: "rgba(255, 255, 255, 0.88)",
848
- textMidEmphasis: "rgba(255, 255, 255, 0.5)",
849
- textLowEmphasis: "rgba(255, 255, 255, 0.38)",
850
- textDisabled: "rgba(255, 255, 255, 0.12)"
851
- },
852
- overlay: {
853
- dark: "rgba(0, 0, 0, 0.55)",
854
- light: "rgba(22, 22, 22, 0.32)"
855
- }
856
- }, it = {
857
- h1: { fontSize: 18, fontWeight: 700 },
858
- h2: { fontSize: 16, fontWeight: 700 },
859
- subtitle1: { fontSize: 16, fontWeight: 500 },
860
- subtitle2: { fontSize: 16, fontWeight: 400 },
861
- body1: { fontSize: 16, fontWeight: 400 },
862
- body2: { fontSize: 14, fontWeight: 500 },
863
- body3: { fontSize: 14, fontWeight: 400 },
864
- button: { fontSize: 14, fontWeight: 700 },
865
- caption1: { fontSize: 12, fontWeight: 700 },
866
- caption2: { fontSize: 12, fontWeight: 400 },
867
- caption3: { fontSize: 11, fontWeight: 700 },
868
- caption4: { fontSize: 11, fontWeight: 400 }
869
- };
870
- function Kt(e) {
871
- const t = yo(e), { colors: n, aiAgentColorVariables: o } = _o(e, t), s = To(e);
872
- return {
873
- selectedTheme: e.selectedTheme,
874
- palette: t,
875
- colors: n,
876
- aiAgentColorVariables: o,
877
- typography: s
878
- };
879
- }
880
- function yo({ selectedTheme: e, palette: t, primary: n }) {
881
- const o = t != null && t.primary ? t.primary : n ? n === Fe.primary.main ? Fe.primary : xo(n, e) : Fe.primary;
882
- return {
883
- ...Fe,
884
- primary: o,
885
- ...t
886
- };
887
- }
888
- function _o({ selectedTheme: e, primaryContrast: t, botMessageBackground: n, botMessageBackgroundContrast: o }, s) {
889
- const i = s.primary.main, a = t ?? pt(i), l = n ?? ht.DEFAULT_BOT_MSG_BG, c = o ?? pt(l);
890
- return {
891
- colors: (e === "light" ? Co : vo)(
892
- s,
893
- i,
894
- a,
895
- l,
896
- c
897
- ),
898
- aiAgentColorVariables: {
899
- primary_color: i,
900
- bot_message_bg_color: l,
901
- primary_contrast_color: a,
902
- bot_message_bg_contrast_color: c
903
- }
904
- };
905
- }
906
- function So(e, t, n) {
907
- const o = { ...e };
908
- return n.forEach((s) => {
909
- const i = t[s];
910
- i != null && (o[s] = i);
911
- }), o;
912
- }
913
- function To({ typography: e }) {
914
- if (!e)
915
- return it;
916
- const t = { ...it };
917
- return Object.keys(e).forEach((n) => {
918
- const o = e[n];
919
- if (o && typeof o == "object") {
920
- const s = it[n], i = ["fontSize", "fontWeight", "fontFamily", "lineHeight"];
921
- t[n] = So(s, o, i);
922
- }
923
- }), t;
924
- }
925
- const {
926
- Provider: wo,
927
- useContext: Ct
928
- } = G("AIAgentTheme");
929
- function Ao({ logger: e, palette: t, typography: n, appearance: o, children: s }) {
930
- const [i, a] = _(
931
- () => Kt({
932
- selectedTheme: (o == null ? void 0 : o.theme) ?? "light",
933
- palette: t,
934
- typography: n,
935
- primary: o == null ? void 0 : o.primaryColor,
936
- botMessageBackground: o == null ? void 0 : o.botMessageBackgroundColor
937
- })
938
- ), l = R(
939
- (c, d) => {
940
- const h = (o == null ? void 0 : o.theme) ?? c, m = d == null ? void 0 : d(h), f = {
941
- primary: o == null ? void 0 : o.primaryColor,
942
- primaryContrast: void 0,
943
- botMessageBackground: o == null ? void 0 : o.botMessageBackgroundColor,
944
- botMessageBackgroundContrast: void 0
945
- };
946
- !f.primary && (m != null && m.primaryColor) && (f.primary = m.primaryColor, f.primaryContrast = m.primaryContrastColor), !f.botMessageBackground && (m != null && m.botMessageBackgroundColor) && (f.botMessageBackground = m.botMessageBackgroundColor, f.botMessageBackgroundContrast = m.botMessageBackgroundContrastColor);
947
- const x = Kt({ selectedTheme: h, palette: t, typography: n, ...f });
948
- a(x), e == null || e.info("theme.update:", h);
949
- },
950
- [o == null ? void 0 : o.theme, o == null ? void 0 : o.primaryColor, o == null ? void 0 : o.botMessageBackgroundColor, t, n, e]
951
- );
952
- return L(() => {
953
- (o != null && o.theme || o != null && o.primaryColor || o != null && o.botMessageBackgroundColor) && l(i.selectedTheme);
954
- }, [o == null ? void 0 : o.theme, o == null ? void 0 : o.primaryColor, o == null ? void 0 : o.botMessageBackgroundColor]), /* @__PURE__ */ r.createElement(wo, { value: { theme: i, updateTheme: l } }, s);
955
- }
956
- function ko() {
957
- const { chatSDK: e, logger: t } = ue(), n = R(
958
- async (s, i, a) => {
959
- if (t.debug("useChatConnection.connect: start, session", s.userId), i) {
960
- const l = new Ar({
961
- ...i,
962
- onSessionTokenRequired: Io(i.onSessionTokenRequired, a)
963
- });
964
- e.setSessionHandler(l);
965
- }
966
- await e.connect(s.userId, s.authToken), t.debug("useChatConnection.connect: end, currentUser", e.currentUser);
967
- },
968
- [e, t]
969
- ), o = R(async () => {
970
- t.debug("useChatConnection.disconnect: start"), await e.disconnect(), t.debug("useChatConnection.disconnect: end");
971
- }, [e, t]);
972
- return { connect: n, disconnect: o };
973
- }
974
- function Io(e, t) {
975
- if (e)
976
- return async (n, o) => {
977
- new Promise((s, i) => e == null ? void 0 : e(s, i)).then((s) => {
978
- s && (t == null || t(s)), n(s);
979
- }).catch((s) => {
980
- o(s);
981
- });
982
- };
983
- }
984
- class $o {
985
- constructor({ userId: t, authToken: n, sessionHandler: o }) {
986
- this.userId = t, this.authToken = n, this.sessionHandler = o;
987
- }
988
- }
989
- class Zt {
990
- }
991
- const Mo = 24 * 60 * 60 * 1e3, Oo = (e) => {
992
- const { logger: t, cache: n } = ue(), o = () => {
993
- const i = n.messenger.getAnonUser();
994
- return i ? i.expireAt - Mo <= Date.now() ? (t.debug("useUserSessionCandidate.getAnonymousSessionInfo: auto session expired, clear cache"), n.messenger.clear(i.userId), null) : (t.debug("useUserSessionCandidate.getAnonymousSessionInfo: auto session info detected"), i) : null;
995
- }, s = () => {
996
- if (!e || e instanceof Zt)
997
- throw new Error("userSessionInfo must be an instance of ManualSessionInfo");
998
- const i = ["authToken", "sessionHandler"].filter((a) => !(a in e));
999
- return i.length > 0 && t.error(
1000
- `useUserSessionCandidate.getManualSessionInfo: missing required keys in userSessionInfo: ${i.join(", ")}`
1001
- ), t.debug("useUserSessionCandidate.getManualSessionInfo: manual session info detected"), e;
1002
- };
1003
- return ae(() => e instanceof $o ? s() : e instanceof Zt ? o() : e && typeof e == "object" ? (t.warn("Please use ManualSessionInfo instead of the old userSessionInfo format."), s()) : e === void 0 ? (t.warn("Please use AnonymousSessionInfo instead of undefined userSessionInfo."), o()) : null, [
1004
- t,
1005
- e == null ? void 0 : e.userId,
1006
- e == null ? void 0 : e.authToken,
1007
- e == null ? void 0 : e.sessionHandler,
1008
- n.messenger.getAnonUser,
1009
- n.messenger.clear
1010
- ]);
1011
- };
1012
- function Lo({
1013
- userSessionInfo: e,
1014
- onPreAuth: t,
1015
- onPostAuth: n,
1016
- onErrorAuth: o,
1017
- onAuthTokenRefreshed: s,
1018
- onPostDeauth: i,
1019
- forceCreateChannel: a
1020
- }) {
1021
- const { aiAgentId: l, chatSDK: c, language: d, context: h, countryCode: m, logger: f, cache: x } = ue(), { connect: E, disconnect: b } = ko(), g = Oo(e), C = R(async () => {
1022
- var $;
1023
- f.debug("useAuthentication.authenticate: start");
1024
- const S = (g == null ? void 0 : g.userId) && (($ = x.messenger.getSettings(g.userId)) == null ? void 0 : $.knownActiveChannelUrl), k = await c.aiAgent.requestMessengerSettings({
1025
- aiAgentId: l,
1026
- userId: g == null ? void 0 : g.userId,
1027
- language: d,
1028
- country: m,
1029
- context: h,
1030
- forceCreateChannel: a,
1031
- knownActiveChannelUrl: S
1032
- });
1033
- f.debug("useAuthentication.authenticate: messenger settings response", k);
1034
- let F = null;
1035
- if (k.auto_created_user) {
1036
- const { user_id: V, session_token: re, expire_at: y } = k.auto_created_user;
1037
- x.messenger.setAnonUser({ userId: V, authToken: re, expireAt: y }), F = { userId: V, authToken: re };
1038
- } else
1039
- F = {
1040
- userId: (g == null ? void 0 : g.userId) ?? "",
1041
- authToken: (g == null ? void 0 : g.authToken) ?? ""
1042
- };
1043
- x.messenger.setSettings(F.userId, {
1044
- knownActiveChannelUrl: k.active_channel.channel_url
1045
- });
1046
- try {
1047
- await t(k, F), await E(F, g == null ? void 0 : g.sessionHandler, s), await n(k, F);
1048
- } catch (V) {
1049
- V instanceof Error && (o(V), f.error("useAuthentication.authenticate: failed to connect", V));
1050
- }
1051
- return k;
1052
- }, [
1053
- c,
1054
- E,
1055
- g == null ? void 0 : g.userId,
1056
- g == null ? void 0 : g.sessionHandler,
1057
- g == null ? void 0 : g.authToken,
1058
- x.messenger.setAnonUser,
1059
- x.messenger.getSettings,
1060
- x.messenger.setSettings,
1061
- t,
1062
- n,
1063
- o,
1064
- s
1065
- ]), v = R(async () => {
1066
- f.debug("useAuthentication.deauthenticate: start"), await b(), i(), f.debug("useAuthentication.deauthenticate: completed");
1067
- }, [b, f, i]);
1068
- return {
1069
- authenticate: C,
1070
- deauthenticate: v,
1071
- userSessionCandidate: g
1072
- };
1073
- }
1074
- const An = (e) => {
1075
- try {
1076
- const t = JSON.parse(e);
1077
- return typeof t == "string" ? JSON.stringify(t).slice(1, -1) : e.trim();
1078
- } catch {
1079
- return JSON.stringify(e).slice(1, -1);
1080
- }
1081
- }, $e = (e) => JSON.parse(e), Qe = (e) => JSON.parse(e);
1082
- function Ro(e, t) {
1083
- const [n, o] = t.split(",").map((s) => s.trim());
1084
- return e === "dark" && o || n;
1085
- }
1086
- function Do(e) {
1087
- const t = {};
1088
- function n(o, s = "") {
1089
- for (const [i, a] of Object.entries(o)) {
1090
- const l = s ? `${s}.${i}` : i;
1091
- a && typeof a == "object" && !Array.isArray(a) ? n(a, l) : t[l] = a;
1092
- }
1093
- }
1094
- return n(e), t;
1095
- }
1096
- function vt({
1097
- template: e,
1098
- variables: t,
1099
- variableKeyPattern: n,
1100
- variableValueTransformer: o
1101
- }) {
1102
- return Object.entries(t).reduce((s, [i, a]) => {
1103
- if (!o && !["number", "boolean", "string"].includes(typeof a))
1104
- throw new Error(`If transformer is not provided, value(${i}:${a}) must be a {string, number, or boolean}`);
1105
- const l = o ? o(a) : String(a), c = n(i);
1106
- return s.replace(c, An(l));
1107
- }, e);
1108
- }
1109
- async function No({
1110
- template: e,
1111
- variables: t,
1112
- variableKeyPattern: n,
1113
- variableValueTransformer: o
1114
- }) {
1115
- return (await Promise.all(
1116
- Object.entries(t).map(async ([i, a]) => {
1117
- const l = await o(a);
1118
- return { regex: n(i), transformedValue: l };
1119
- })
1120
- )).reduce((i, { regex: a, transformedValue: l }) => i.replace(a, An(l)), e);
1121
- }
1122
- const Po = () => {
1123
- const { chatSDK: e, logger: t, cache: n } = ue(), o = R(() => {
1124
- var l, c;
1125
- const i = (c = (l = e.appInfo) == null ? void 0 : l.aiAgentInfo) == null ? void 0 : c.templateListToken;
1126
- if (!i) return !1;
1127
- const a = n.template.getCachedToken();
1128
- return a ? i !== a : !0;
1129
- }, [e, n.template.getCachedToken]), s = R(async () => {
1130
- try {
1131
- const { templates: i, token: a } = await e.aiAgent.getMessageTemplates({ limit: 20 });
1132
- for (const { template: l } of i) {
1133
- const { key: c } = $e(l);
1134
- n.template.set(c, l);
1135
- }
1136
- n.template.setCachedToken(a);
1137
- } catch (i) {
1138
- t == null || t.error("messageTemplateContext.syncCachedTemplates: error:", i);
1139
- }
1140
- }, [e, t, n.template.set, n.template.setCachedToken]);
1141
- return {
1142
- shouldSyncCachedTemplate: o,
1143
- syncCachedTemplates: s
1144
- };
1145
- };
1146
- var je = /* @__PURE__ */ ((e) => (e.OFF = "off", e.ALWAYS = "always", e.HANDED_OFF_ONLY = "handed_off_only", e))(je || {});
1147
- const Bo = {
1148
- off: "off",
1149
- always: "always",
1150
- handed_off_only: "handed_off_only"
1151
- /* HANDED_OFF_ONLY */
1152
- }, {
1153
- Provider: Fo
1154
- } = G("AIAgentMessengerSession"), Uo = ye(
1155
- function({ userSessionInfo: e, forceCreateChannel: t, children: n }, o) {
1156
- const { appId: s, aiAgentId: i, chatSDK: a, language: l, countryCode: c, context: d, cache: h, logger: m } = ue(), { updateTheme: f } = Ct(), [x, E] = _(void 0), [b, g] = _(
1157
- void 0
1158
- ), [C, v] = _(null), [S, k] = _(null), [F, $] = _(null), [V, re] = _(
1159
- "handed_off_only"
1160
- /* HANDED_OFF_ONLY */
1161
- ), { shouldSyncCachedTemplate: y, syncCachedTemplates: H } = Po(), { authenticate: oe, deauthenticate: Y } = Lo({
1162
- userSessionInfo: e,
1163
- forceCreateChannel: t,
1164
- onPreAuth: R((A, D) => {
1165
- const K = A.appearance.selected_theme;
1166
- f(K, (q) => {
1167
- const be = A.appearance.themes[q];
1168
- return {
1169
- primaryColor: be.primary_color,
1170
- botMessageBackgroundColor: be.bot_message_bg_color,
1171
- primaryContrastColor: be.primary_contrast_color,
1172
- botMessageBackgroundContrastColor: be.bot_message_bg_contrast_color
1173
- };
1174
- }), E(void 0), v(D), k({
1175
- userId: A.bot.bot_userid,
1176
- profileUrl: A.bot.bot_profile_url,
1177
- nickname: A.bot.bot_nickname,
1178
- replyToFile: A.bot.reply_to_file,
1179
- specialNotice: A.bot.special_notice,
1180
- specialNoticeEnabled: A.bot.is_special_notice_enabled,
1181
- showHandoffButton: A.bot.show_handoff_button ?? !0
1182
- }), $({
1183
- type: A.launcher.image_type || "default_icon",
1184
- imageUrl: A.launcher.image_url
1185
- }), re(
1186
- Bo[A.active_channel.attachment_mode] ?? "handed_off_only"
1187
- /* HANDED_OFF_ONLY */
1188
- );
1189
- }, []),
1190
- onPostAuth: R(
1191
- async (A) => {
1192
- y() && await H(), g({ url: A.active_channel.channel_url, status: W.OPEN });
1193
- },
1194
- [y, H]
1195
- ),
1196
- onErrorAuth: R((A) => {
1197
- E(A);
1198
- }, []),
1199
- onAuthTokenRefreshed: R((A) => {
1200
- v((D) => D ? { ...D, authToken: A } : null);
1201
- }, []),
1202
- onPostDeauth: R(() => {
1203
- h.template.clear(), C != null && C.userId && h.messenger.clear(C.userId), g(void 0), v(null), k(null), $(null);
1204
- }, [h.template.clear, C])
1205
- }), nt = R(async () => {
1206
- var A;
1207
- if (C) {
1208
- m.debug("agentMessengerSession.refreshActiveChannel: try to refresh active channel"), g(void 0);
1209
- const D = await a.aiAgent.requestMessengerSettings({
1210
- aiAgentId: i,
1211
- userId: C.userId,
1212
- language: l,
1213
- country: c,
1214
- context: d,
1215
- forceCreateChannel: t,
1216
- knownActiveChannelUrl: (A = h.messenger.getSettings(C.userId)) == null ? void 0 : A.knownActiveChannelUrl
1217
- });
1218
- return h.messenger.setSettings(C.userId, {
1219
- knownActiveChannelUrl: D.active_channel.channel_url
1220
- }), g({ url: D.active_channel.channel_url, status: W.OPEN }), m.info(
1221
- "agentMessengerSession.refreshActiveChannel: refreshed active channel",
1222
- D.active_channel.channel_url
1223
- ), D.active_channel.channel_url;
1224
- } else
1225
- throw m.error("agentMessengerSession.refreshActiveChannel: userSession is not ready"), new Error("userSession is not ready");
1226
- }, [
1227
- a,
1228
- s,
1229
- i,
1230
- C == null ? void 0 : C.userId,
1231
- l,
1232
- c,
1233
- d,
1234
- t,
1235
- h.messenger.getSettings,
1236
- h.messenger.setSettings
1237
- ]), rt = R(
1238
- async (A) => {
1239
- if (!(C != null && C.userId))
1240
- throw new Error("Current user is not authenticated. Please authenticate first.");
1241
- const K = (await a.aiAgent.requestMessengerSettings({
1242
- ...A,
1243
- userId: C.userId,
1244
- knownActiveChannelUrl: void 0
1245
- })).active_channel.channel_url;
1246
- return h.messenger.setSettings(C.userId, { knownActiveChannelUrl: K }), K;
1247
- },
1248
- [C == null ? void 0 : C.userId]
1249
- );
1250
- return Xe(a, {
1251
- onChannelChanged: (A) => {
1252
- var D;
1253
- A.isGroupChannel() && A.url === (b == null ? void 0 : b.url) && (m.info("agentMessengerSession.channelChanged: channel.conversation", A.conversation), g({ url: A.url, status: ((D = A.conversation) == null ? void 0 : D.status) ?? W.OPEN }));
1254
- }
1255
- }), Er(o, () => {
1256
- const A = async () => {
1257
- if (!b) throw new Error("No active conversation. Please start a conversation first.");
1258
- return await a.groupChannel.getChannel(b.url);
1259
- };
1260
- return {
1261
- activeChannel: b,
1262
- chatSDK: a,
1263
- authenticate: oe,
1264
- deauthenticate: Y,
1265
- updateContext: async (D) => {
1266
- const q = await (await A()).updateContext(i, D);
1267
- return { ...q, context: q.context ?? {} };
1268
- },
1269
- patchContext: async (D) => {
1270
- const q = await (await A()).patchContext(i, D);
1271
- return { ...q, context: q.context ?? {} };
1272
- },
1273
- getContextObject: async () => {
1274
- const K = await (await A()).getContextObject(i);
1275
- return { ...K, context: K.context ?? {} };
1276
- }
1277
- };
1278
- }, [oe, Y, b, a, i, m]), /* @__PURE__ */ r.createElement(
1279
- Fo,
1280
- {
1281
- value: {
1282
- userSessionInfo: e,
1283
- userSession: C,
1284
- activeChannel: b,
1285
- setActiveChannel: g,
1286
- refreshActiveChannel: nt,
1287
- createConversation: rt,
1288
- connectionError: x,
1289
- aiAgentInfo: S,
1290
- launcherInfo: F,
1291
- authenticate: oe,
1292
- deauthenticate: Y,
1293
- attachmentMode: V
1294
- }
1295
- },
1296
- n
1297
- );
1298
- }
1299
- );
1300
- function Ho(e) {
1301
- let t = "pending", n = e.then((o) => {
1302
- t = "resolved", n = o;
1303
- }).catch((o) => {
1304
- t = "rejected", n = o;
1305
- });
1306
- return {
1307
- get value() {
1308
- if (t === "resolved")
1309
- return n;
1310
- throw n;
1311
- }
1312
- };
1313
- }
1314
- const {
1315
- Provider: zo,
1316
- useContext: kn
1317
- } = G("MessageTemplateFetching");
1318
- function Vo({ children: e, internalVariables: t }) {
1319
- const n = N({}), o = N({}), [s, i] = _({}), a = R((d, h) => {
1320
- i((m) => ({
1321
- ...m,
1322
- [d]: { fetching: !1, error: !1, ...m[d], ...h }
1323
- }));
1324
- }, []), l = R(
1325
- async ({
1326
- onRequestTemplate: d,
1327
- onGetCachedTemplate: h,
1328
- templateKey: m,
1329
- suspense: f = !1
1330
- }) => {
1331
- const x = h(m);
1332
- if (x) return x;
1333
- const E = o.current[m];
1334
- if (E) return E;
1335
- f || a(m, { fetching: !0 });
1336
- const b = d(m).catch((g) => {
1337
- throw f || a(m, { error: !0 }), g;
1338
- }).finally(() => {
1339
- f || a(m, { fetching: !1 }), delete o.current[m];
1340
- });
1341
- return o.current[m] = b, b;
1342
- },
1343
- [a]
1344
- ), c = {
1345
- internalVariables: t,
1346
- fetchTemplate: l,
1347
- suspend: (d, h) => {
1348
- if (n.current[d])
1349
- return n.current[d];
1350
- const m = Ho(h());
1351
- return n.current[d] = m, m;
1352
- },
1353
- getIsFetching: (d) => {
1354
- var h;
1355
- return ((h = s[d]) == null ? void 0 : h.fetching) ?? !1;
1356
- },
1357
- getHasError: (d) => {
1358
- var h;
1359
- return ((h = s[d]) == null ? void 0 : h.error) ?? !1;
1360
- }
1361
- };
1362
- return /* @__PURE__ */ r.createElement(zo, { value: c }, e);
1363
- }
1364
- const et = {
1365
- VARIABLE: (e) => new RegExp(`\\{${e}\\}`, "g"),
1366
- VIEW_VARIABLE: (e) => new RegExp(`"{@${e}}"`, "g")
1367
- };
1368
- function ce({ uiTemplateString: e, variables: t = {} }) {
1369
- const n = Do(t);
1370
- return vt({
1371
- template: e,
1372
- variables: n,
1373
- variableKeyPattern: (o) => et.VARIABLE(o)
1374
- });
1375
- }
1376
- function de({
1377
- theme: e,
1378
- uiTemplateString: t,
1379
- colorVariables: n = {}
1380
- }) {
1381
- return vt({
1382
- template: t,
1383
- variables: n,
1384
- variableKeyPattern: (o) => et.VARIABLE(o),
1385
- variableValueTransformer: (o) => Ro(e, o)
1386
- });
1387
- }
1388
- function Wo({
1389
- theme: e,
1390
- uiTemplateString: t,
1391
- viewVariables: n = {},
1392
- aiAgentColorVariables: o,
1393
- internalVariables: s,
1394
- onRequestTemplate: i
1395
- }) {
1396
- const l = Object.values(n).flat().map((d) => d.key);
1397
- return [...new Set(l)].some((d) => !i(d)) ? null : vt({
1398
- template: t,
1399
- variables: n,
1400
- variableKeyPattern: (d) => et.VIEW_VARIABLE(d),
1401
- variableValueTransformer: (d) => {
1402
- const h = d.map(({ key: m, variables: f }) => {
1403
- const x = i(m), { ui_template: E, color_variables: b } = $e(x);
1404
- let g = JSON.stringify(E);
1405
- return g = ce({
1406
- uiTemplateString: g,
1407
- variables: s
1408
- }), g = de({
1409
- theme: e,
1410
- uiTemplateString: g,
1411
- colorVariables: b
1412
- }), g = de({
1413
- theme: e,
1414
- uiTemplateString: g,
1415
- colorVariables: o
1416
- }), g = ce({
1417
- uiTemplateString: g,
1418
- variables: f
1419
- }), Qe(g);
1420
- });
1421
- return JSON.stringify(h);
1422
- }
1423
- });
1424
- }
1425
- async function Go({
1426
- theme: e,
1427
- uiTemplateString: t,
1428
- viewVariables: n = {},
1429
- aiAgentColorVariables: o,
1430
- internalVariables: s,
1431
- onRequestTemplate: i
1432
- }) {
1433
- return No({
1434
- template: t,
1435
- variables: n,
1436
- variableKeyPattern: (a) => et.VIEW_VARIABLE(a),
1437
- variableValueTransformer: async (a) => {
1438
- const l = a.map(async ({ key: d, variables: h }) => {
1439
- const m = await i(d), { ui_template: f, color_variables: x } = $e(m);
1440
- let E = JSON.stringify(f);
1441
- return E = ce({
1442
- uiTemplateString: E,
1443
- variables: s
1444
- }), E = de({
1445
- theme: e,
1446
- uiTemplateString: E,
1447
- colorVariables: x
1448
- }), E = de({
1449
- theme: e,
1450
- uiTemplateString: E,
1451
- colorVariables: o
1452
- }), E = ce({
1453
- uiTemplateString: E,
1454
- variables: h
1455
- }), Qe(E);
1456
- }), c = await Promise.all(l);
1457
- return JSON.stringify(c);
1458
- }
1459
- });
1460
- }
1461
- const jo = ({
1462
- rawTemplate: e,
1463
- aiAgentColorVariables: t,
1464
- internalVariables: n,
1465
- ...o
1466
- }) => {
1467
- const { ui_template: s, color_variables: i } = $e(e);
1468
- let a = JSON.stringify(s);
1469
- if (Object.keys(o.viewVariables ?? {}).length > 0) {
1470
- const c = Wo({
1471
- ...o,
1472
- uiTemplateString: a,
1473
- aiAgentColorVariables: t,
1474
- internalVariables: n
1475
- });
1476
- if (c === null) return null;
1477
- a = c;
1478
- }
1479
- return a = ce({ ...o, uiTemplateString: a, variables: n }), a = de({ ...o, uiTemplateString: a, colorVariables: i }), a = de({ ...o, uiTemplateString: a, colorVariables: t }), a = ce({ ...o, uiTemplateString: a }), Qe(a);
1480
- }, Ko = async ({
1481
- rawTemplate: e,
1482
- aiAgentColorVariables: t,
1483
- internalVariables: n,
1484
- ...o
1485
- }) => {
1486
- const { ui_template: s, color_variables: i } = $e(e);
1487
- let a = JSON.stringify(s);
1488
- return Object.keys(o.viewVariables ?? {}).length > 0 && (a = await Go({
1489
- ...o,
1490
- uiTemplateString: a,
1491
- aiAgentColorVariables: t,
1492
- internalVariables: n
1493
- })), a = ce({ ...o, uiTemplateString: a, variables: n }), a = de({ ...o, uiTemplateString: a, colorVariables: i }), a = de({ ...o, uiTemplateString: a, colorVariables: t }), a = ce({ ...o, uiTemplateString: a }), Qe(a);
1494
- }, Zo = (e) => {
1495
- const { aiAgentColorVariables: t = {} } = e, { internalVariables: n } = kn();
1496
- return _(() => {
1497
- const o = e.onGetCachedTemplate(e.templateKey);
1498
- return o ? jo({
1499
- ...e,
1500
- rawTemplate: o,
1501
- aiAgentColorVariables: t,
1502
- internalVariables: n,
1503
- onRequestTemplate: e.onGetCachedTemplate
1504
- }) : null;
1505
- });
1506
- }, Yo = (e) => {
1507
- const [t] = Zo(e);
1508
- if (t) return t;
1509
- const { aiAgentColorVariables: n = {} } = e, { internalVariables: o, fetchTemplate: s, suspend: i } = kn();
1510
- return i(e.templateKey, async () => {
1511
- const l = await s({ ...e, suspense: !0 });
1512
- return await Ko({
1513
- ...e,
1514
- rawTemplate: l,
1515
- aiAgentColorVariables: n,
1516
- internalVariables: o
1517
- });
1518
- }).value;
1519
- }, qo = '@import"https://fonts.googleapis.com/css?family=Roboto:400,500,600,700&display=swap";.sb-message-template__border{position:relative}.sb-message-template__border:after{content:"";position:absolute;top:0;bottom:0;left:0;right:0;z-index:1;box-shadow:inset 0 0 0 var(--border-width) var(--border-color);border-radius:var(--border-radius);pointer-events:none}.sb-message-template__action{cursor:pointer}.sb-message-template__parent{font-family:Roboto,serif}.sb-message-template__text{font-family:inherit;font-size:14px;font-weight:400;font-stretch:normal;font-style:normal;letter-spacing:normal;text-align:left}.sb-message-template__text-button{font-family:inherit;background-color:#e0e0e0;text-align:center;padding:10px;border-radius:6px;font-size:14px;font-weight:600;font-stretch:normal;font-style:normal;letter-spacing:normal}.sendbird-theme--light .sb-message-template__text-button{color:#742ddd}.sendbird-theme--dark .sb-message-template__text-button{color:#c2a9fa}.sb-message-template__text-button:hover{opacity:1;box-shadow:#0000001a 0 1px 3px,#0000000f 0 1px 2px}.sb-message-template__text-button,.sb-message-template__image-button{cursor:pointer;border-style:none}.sb-message-template__parent{border-radius:unset;background-color:transparent;overflow:hidden}.sb-message-template__parent *{box-sizing:border-box;line-height:1.3}.sb-message-template__carousel{display:flex;width:100%;box-sizing:border-box;touch-action:pan-y}', Me = "en", Jo = /* @__PURE__ */ new Set([
1520
- Me,
1521
- "ko",
1522
- "es",
1523
- "pt",
1524
- "fr",
1525
- "hi",
1526
- "it",
1527
- "de",
1528
- "tr",
1529
- "ja"
1530
- ]), Xo = (e, t, n) => {
1531
- const o = e[t];
1532
- return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((s, i) => {
1533
- (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
1534
- i.bind(
1535
- null,
1536
- new Error(
1537
- "Unknown variable dynamic import: " + t + (t.split("/").length !== n ? ". Note that variables only represent file names one level deep." : "")
1538
- )
1539
- )
1540
- );
1541
- });
1542
- }, Qo = Lr, es = {
1543
- // Channel - Common
1544
- CHANNEL_FROZEN: "Channel frozen",
1545
- PLACE_HOLDER__WRONG: "Something went wrong",
1546
- PLACE_HOLDER__NO_MESSAGES: "No messages",
1547
- UNKNOWN__UNKNOWN_MESSAGE_TYPE: "(Unknown message type)",
1548
- // Channel - Header
1549
- HEADER_BUTTON__AGENT_HANDOFF: "Connect with an agent",
1550
- // Message Input
1551
- MESSAGE_INPUT__PLACE_HOLDER: "Ask a question",
1552
- MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE: "Waiting for the agent’s reply…",
1553
- MESSAGE_INPUT__PLACE_HOLDER__DISABLED: "Chat is unavailable in this channel",
1554
- // Common UI
1555
- BUTTON__CANCEL: "Cancel",
1556
- BUTTON__SAVE: "Save",
1557
- BUTTON__OK: "OK",
1558
- NO_NAME: "(No name)",
1559
- RETRY: "Retry",
1560
- // Date format
1561
- DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR: "MMMM dd, yyyy",
1562
- DATE_FORMAT__MESSAGE_TIMESTAMP: "p",
1563
- // File Upload
1564
- FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT: "You can't upload more than one image",
1565
- FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT: "The maximum size per file is %d MB.",
1566
- // File Viewer
1567
- FILE_VIEWER__UNSUPPORT: "Unsupported message",
1568
- // CSAT
1569
- CSAT_TITLE_UNSUBMITTED: "Your feedback matters to us",
1570
- CSAT_TITLE_SUBMITTED: "Successfully submitted!",
1571
- CSAT_CRE_TITLE: "Was your issue resolved?",
1572
- CSAT_CRE_SOLVED: "Yes, thank you! 👍",
1573
- CSAT_CRE_NOT_SOLVED: "No, that didn’t help.",
1574
- CSAT_REASON_PLACEHOLDER: "Share your feedback",
1575
- CSAT_RATING_TITLE: "How would you rate your experience?",
1576
- CSAT5_RATING_SCORE_1: "Terrible",
1577
- CSAT5_RATING_SCORE_2: "Bad",
1578
- CSAT5_RATING_SCORE_3: "Okay",
1579
- CSAT5_RATING_SCORE_4: "Good",
1580
- CSAT5_RATING_SCORE_5: "Great",
1581
- CSAT_SUBMIT_LABEL: "Submit",
1582
- CSAT_SUBMISSION_EXPIRED: "We’re sorry, the survey period has ended.",
1583
- POWERED_BY: "Powered by",
1584
- // Conversation list
1585
- CONVERSATION_CLOSED_FOOTER_LABEL: "Your conversation has ended",
1586
- START_NEW_CONVERSATION: "💬 Start a new conversation",
1587
- RETURN_TO_CONVERSATION: "💬 Return to conversation",
1588
- CONVERSATION_LIST__HEADER_TITLE: "Conversation history",
1589
- CONVERSATION_LIST__TOPICS_FALLBACK: "No category",
1590
- CONVERSATION_LIST__NO_CONVERSATIONS: "No conversations yet",
1591
- DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE: "MM/dd/yyyy",
1592
- DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION: "h:mma",
1593
- // Citation
1594
- CITATION_SOURCE_TITLE: "Source"
1595
- }, yt = { language: "en", dateLocale: Qo, stringSet: es }, ts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1596
- __proto__: null,
1597
- default: yt
1598
- }, Symbol.toStringTag, { value: "Module" })), Ke = /* @__PURE__ */ new Map([[Me, yt]]);
1599
- async function ns(e) {
1600
- if (Ke.has(e))
1601
- return Ke.get(e);
1602
- const t = Jo.has(e) ? e : Me;
1603
- try {
1604
- const { default: n } = await Xo(/* @__PURE__ */ Object.assign({ "./languages/de.ts": () => import("./BAebVbLs.js"), "./languages/en.ts": () => Promise.resolve().then(() => ts), "./languages/es.ts": () => import("./BKSUGIyL.js"), "./languages/fr.ts": () => import("./B1s75De5.js"), "./languages/hi.ts": () => import("./D0QwWNMF.js"), "./languages/it.ts": () => import("./CA1gVgSD.js"), "./languages/ja.ts": () => import("./DcqbdvlW.js"), "./languages/ko.ts": () => import("./Dxrtj2R8.js"), "./languages/pt.ts": () => import("./EylKxx4d.js"), "./languages/tr.ts": () => import("./DYR8UT_l.js") }), `./languages/${t}.ts`, 3);
1605
- return Ke.set(e, n), n;
1606
- } catch {
1607
- return yt;
1608
- }
1609
- }
1610
- const {
1611
- Provider: rs,
1612
- useContext: O
1613
- } = G("Localization");
1614
- function os(e) {
1615
- var t;
1616
- return ((t = e.split("-")) == null ? void 0 : t[0]) ?? Me;
1617
- }
1618
- function ss({
1619
- language: e = navigator.language,
1620
- logger: t,
1621
- stringSet: n,
1622
- children: o
1623
- }) {
1624
- const [s, i] = _(Ke.get(Me));
1625
- return L(() => {
1626
- const a = os(e);
1627
- s.language !== a && (t == null || t.debug("localization.useEffect: update language", `${s.language} -> ${a}`), ns(a).then(i));
1628
- }, [e]), /* @__PURE__ */ r.createElement(
1629
- rs,
1630
- {
1631
- value: {
1632
- language: s.language,
1633
- stringSet: { ...s.stringSet, ...n },
1634
- dateLocale: s.dateLocale,
1635
- format: (a, l, c) => Cn(a, l, { locale: s.dateLocale, ...c })
1636
- }
1637
- },
1638
- o
1639
- );
1640
- }
1641
- const Ze = "data-sb-agent-theme", Yt = (e) => (t, ...n) => {
1642
- let o = "";
1643
- return t.forEach((s, i) => {
1644
- o += s + (n[i] ?? "");
1645
- }), `[${Ze}='${e}'] & { ${o} }`;
1646
- }, P = {
1647
- light: Yt("light"),
1648
- dark: Yt("dark")
1649
- }, is = I(({ theme: e }) => {
1650
- const { palette: t } = e;
1651
- return `
1652
- :root,
1653
- :host {
1654
- --sendbird-primary-extra-dark: ${t.primary.extraDark};
1655
- --sendbird-primary-dark: ${t.primary.dark};
1656
- --sendbird-primary-main: ${t.primary.main};
1657
- --sendbird-primary-light: ${t.primary.light};
1658
- --sendbird-primary-extra-light: ${t.primary.extraLight};
1659
-
1660
- --sendbird-secondary-extra-dark: ${t.secondary.extraDark};
1661
- --sendbird-secondary-dark: ${t.secondary.dark};
1662
- --sendbird-secondary-main: ${t.secondary.main};
1663
- --sendbird-secondary-light: ${t.secondary.light};
1664
- --sendbird-secondary-extra-light: ${t.secondary.extraLight};
1665
-
1666
- --sendbird-information-extra-dark: ${t.information.extraDark};
1667
- --sendbird-information-dark: ${t.information.dark};
1668
- --sendbird-information-main: ${t.information.main};
1669
- --sendbird-information-light: ${t.information.light};
1670
- --sendbird-information-extra-light: ${t.information.extraLight};
1671
-
1672
- --sendbird-error-extra-dark: ${t.error.extraDark};
1673
- --sendbird-error-dark: ${t.error.dark};
1674
- --sendbird-error-main: ${t.error.main};
1675
- --sendbird-error-light: ${t.error.light};
1676
- --sendbird-error-extra-light: ${t.error.extraLight};
1677
-
1678
- --sendbird-background-700: ${t.background700};
1679
- --sendbird-background-600: ${t.background600};
1680
- --sendbird-background-500: ${t.background500};
1681
- --sendbird-background-400: ${t.background400};
1682
- --sendbird-background-300: ${t.background300};
1683
- --sendbird-background-200: ${t.background200};
1684
- --sendbird-background-100: ${t.background100};
1685
- --sendbird-background-50: ${t.background50};
1686
-
1687
- --sendbird-onlight-text-high-emphasis: ${t.onlight.textHighEmphasis};
1688
- --sendbird-onlight-text-mid-emphasis: ${t.onlight.textMidEmphasis};
1689
- --sendbird-onlight-text-low-emphasis: ${t.onlight.textLowEmphasis};
1690
- --sendbird-onlight-text-disabled: ${t.onlight.textDisabled};
1691
-
1692
- --sendbird-ondark-text-high-emphasis: ${t.ondark.textHighEmphasis};
1693
- --sendbird-ondark-text-mid-emphasis: ${t.ondark.textMidEmphasis};
1694
- --sendbird-ondark-text-low-emphasis: ${t.ondark.textLowEmphasis};
1695
- --sendbird-ondark-text-disabled: ${t.ondark.textDisabled};
1696
-
1697
- --sendbird-overlay-dark: ${t.overlay.dark};
1698
- --sendbird-overlay-light: ${t.overlay.light};
1699
- }
1700
- `;
1701
- }), as = I`[${Ze}='light'] &{--sb-text-high-emphasis:var(--sendbird-onlight-text-high-emphasis);--sb-text-mid-emphasis:var(--sendbird-onlight-text-mid-emphasis);--sb-text-low-emphasis:var(--sendbird-onlight-text-low-emphasis);--sb-text-disabled:var(--sendbird-onlight-text-disabled);--sb-text-high-emphasis-inverse:var(--sendbird-ondark-text-high-emphasis);--sb-text-mid-emphasis-inverse:var(--sendbird-ondark-text-mid-emphasis);--sb-text-low-emphasis-inverse:var(--sendbird-ondark-text-low-emphasis);--sb-text-disabled-inverse:var(--sendbird-ondark-text-disabled);--sb-bg-50-600:var(--sendbird-background-50);--sb-bg-100-500:var(--sendbird-background-100);--sb-bg-200-400:var(--sendbird-background-200);--sb-primary:var(--sendbird-primary-main);--sb-secondary:var(--sendbird-secondary-main);--sb-error:var(--sendbird-error-main);--sb-information:var(--sendbird-information-light);}[${Ze}='dark'] &{--sb-text-high-emphasis:var(--sendbird-ondark-text-high-emphasis);--sb-text-mid-emphasis:var(--sendbird-ondark-text-mid-emphasis);--sb-text-low-emphasis:var(--sendbird-ondark-text-low-emphasis);--sb-text-disabled:var(--sendbird-ondark-text-disabled);--sb-text-high-emphasis-inverse:var(--sendbird-onlight-text-high-emphasis);--sb-text-mid-emphasis-inverse:var(--sendbird-onlight-text-mid-emphasis);--sb-text-low-emphasis-inverse:var(--sendbird-onlight-text-low-emphasis);--sb-text-disabled-inverse:var(--sendbird-onlight-text-disabled);--sb-bg-50-600:var(--sendbird-background-600);--sb-bg-100-500:var(--sendbird-background-500);--sb-bg-200-400:var(--sendbird-background-400);--sb-primary:var(--sendbird-primary-light);--sb-secondary:var(--sendbird-secondary-light);--sb-error:var(--sendbird-error-light);--sb-information:var(--sendbird-information-light);}`, p = {
1702
- color: {
1703
- primary: {
1704
- dark: "var(--sendbird-primary-dark)",
1705
- main: "var(--sendbird-primary-main)"
1706
- },
1707
- error: {
1708
- extraDark: "var(--sendbird-error-extra-dark)",
1709
- dark: "var(--sendbird-error-dark)"
1710
- },
1711
- information: {
1712
- main: "var(--sendbird-information-main)",
1713
- light: "var(--sendbird-information-light)"
1714
- },
1715
- background700: "var(--sendbird-background-700)",
1716
- background500: "var(--sendbird-background-500)",
1717
- background400: "var(--sendbird-background-400)",
1718
- background200: "var(--sendbird-background-200)",
1719
- background100: "var(--sendbird-background-100)",
1720
- background50: "var(--sendbird-background-50)",
1721
- ondark: {
1722
- textMidEmphasis: "var(--sendbird-ondark-text-mid-emphasis)",
1723
- textLowEmphasis: "var(--sendbird-ondark-text-low-emphasis)",
1724
- textDisabled: "var(--sendbird-ondark-text-disabled)"
1725
- },
1726
- overlay: {
1727
- dark: "var(--sendbird-overlay-dark)"
1728
- }
1729
- },
1730
- themedColor: {
1731
- textHighEmphasis: "var(--sb-text-high-emphasis)",
1732
- textMidEmphasis: "var(--sb-text-mid-emphasis)",
1733
- textLowEmphasis: "var(--sb-text-low-emphasis)",
1734
- textDisabled: "var(--sb-text-disabled)",
1735
- textHighEmphasisInverse: "var(--sb-text-high-emphasis-inverse)",
1736
- bg_50_600: "var(--sb-bg-50-600)",
1737
- bg_100_500: "var(--sb-bg-100-500)",
1738
- bg_200_400: "var(--sb-bg-200-400)",
1739
- error: "var(--sb-error)"
1740
- }
1741
- }, {
1742
- Provider: ls,
1743
- useContext: cs
1744
- } = G("MessengerTheme");
1745
- function ds(e) {
1746
- const { theme: t, appearance: n, logger: o } = e;
1747
- return /* @__PURE__ */ r.createElement(
1748
- Ao,
1749
- {
1750
- appearance: n,
1751
- palette: t == null ? void 0 : t.palette,
1752
- typography: t == null ? void 0 : t.typography,
1753
- logger: o
1754
- },
1755
- /* @__PURE__ */ r.createElement(us, { ...e })
1756
- );
1757
- }
1758
- function us({ rootElement: e = document.body, children: t }) {
1759
- const { theme: n, updateTheme: o } = Ct();
1760
- return le(() => {
1761
- e.setAttribute(Ze, n.selectedTheme);
1762
- }, [e, n.selectedTheme]), /* @__PURE__ */ r.createElement(Ir, { theme: n }, /* @__PURE__ */ r.createElement(ls, { value: { theme: n, updateTheme: o } }, t));
1763
- }
1764
- function pe(e, t) {
1765
- const n = e.getRootNode({ composed: t });
1766
- return n instanceof ShadowRoot || n instanceof Document ? n : document;
1767
- }
1768
- const ms = (e, t) => {
1769
- L(() => {
1770
- const n = pe(t) instanceof ShadowRoot, o = pe(t, !0);
1771
- if (!(n ? t : o).querySelector(`link[href*='${e}']`)) {
1772
- const i = o.createElement("link");
1773
- i.rel = "stylesheet", i.href = e, (n ? t : o.head).appendChild(i);
1774
- }
1775
- }, [e, t]);
1776
- }, gs = (e, t = document.body) => {
1777
- L(() => {
1778
- const n = pe(t), s = n instanceof ShadowRoot ? t : n.head;
1779
- if (!s) return;
1780
- const i = `sba-${btoa(e).slice(0, 10)}`;
1781
- let a = s.querySelector(`style#${i}`);
1782
- a ? a.textContent !== e && (a.textContent = e) : (a = s.ownerDocument.createElement("style"), a.id = i, a.textContent = e, s.appendChild(a));
1783
- }, [e, t]);
1784
- }, _t = /iPad|iPhone|iPod/.test(navigator.userAgent), hs = /Android/.test(navigator.userAgent), Oe = (e) => _t || hs, {
1785
- Provider: ps,
1786
- Consumer: In,
1787
- useContext: B
1788
- } = G("Messenger");
1789
- function fs({
1790
- children: e,
1791
- state: t,
1792
- enableCloseConversationButton: n = !1,
1793
- enableExpandButton: o = !0,
1794
- enableAutoDisconnectInLauncher: s = !0,
1795
- ...i
1796
- }) {
1797
- const [a, l] = _(!1), [c, d] = _(!1), h = {
1798
- opened: (t == null ? void 0 : t.opened) ?? a,
1799
- setOpened: (t == null ? void 0 : t.setOpened) ?? l,
1800
- expanded: (t == null ? void 0 : t.expanded) ?? c,
1801
- setExpanded: (t == null ? void 0 : t.setExpanded) ?? d
1802
- };
1803
- return /* @__PURE__ */ r.createElement(to, { ...i }, (m) => /* @__PURE__ */ r.createElement(
1804
- ps,
1805
- {
1806
- value: {
1807
- ...i,
1808
- ...m,
1809
- state: h,
1810
- enableCloseConversationButton: n,
1811
- enableExpandButton: o,
1812
- enableAutoDisconnectInLauncher: s
1813
- }
1814
- },
1815
- e
1816
- ));
1817
- }
1818
- const {
1819
- Provider: bs,
1820
- useContext: U
1821
- } = G("MessengerSession"), Es = ye(function({ children: e, ...t }, n) {
1822
- return /* @__PURE__ */ r.createElement(Uo, { ref: n, ...t }, (o) => /* @__PURE__ */ r.createElement(xs, { ...o }, e));
1823
- }), xs = ({ children: e, ...t }) => {
1824
- const { chatSDK: n, logger: o, appId: s, aiAgentId: i, agentPreviewConfigs: a, state: l } = B(), { userSessionInfo: c, authenticate: d, setActiveChannel: h, userSession: m, aiAgentInfo: f, launcherInfo: x } = t;
1825
- return Xe(n, {
1826
- async onUserJoined(E, b) {
1827
- var C, v;
1828
- if (E.conversation && E.conversation.type === Dr.PROACTIVE && b.userId === ((C = n.currentUser) == null ? void 0 : C.userId)) {
1829
- o.info("messengerSession.onUserJoined: proactive channel joined", E.url);
1830
- const S = ((v = E.conversation) == null ? void 0 : v.status) ?? W.OPEN;
1831
- h({ url: E.url, status: S }), l.setOpened(!0), Cs({ sound: document.hidden || !l.opened });
1832
- }
1833
- }
1834
- }), L(() => {
1835
- d().then(({ launcher: E }) => {
1836
- E.auto_open && !Oe() && setTimeout(() => l.setOpened(!0), 500);
1837
- }).catch((E) => {
1838
- o.error("messengerSession: failed to initialize", E);
1839
- });
1840
- }, [n, s, i, c == null ? void 0 : c.userId, c == null ? void 0 : c.authToken]), !m || !f || !x ? null : /* @__PURE__ */ r.createElement(
1841
- bs,
1842
- {
1843
- value: {
1844
- ...t,
1845
- userSession: m,
1846
- aiAgentInfo: { ...f, ...a == null ? void 0 : a.bot },
1847
- launcherInfo: { ...x, ...a == null ? void 0 : a.launcher }
1848
- }
1849
- },
1850
- e
1851
- );
1852
- };
1853
- function Cs({ sound: e }) {
1854
- const t = "🔔You have received a new message", n = document.title, o = setInterval(() => {
1855
- document.title = document.title === t ? n : t;
1856
- }, 750);
1857
- setTimeout(() => clearInterval(o), 5e3), e && import("./DP0MwObA.js").then((s) => {
1858
- new Audio(s.default).play();
1859
- });
1860
- }
1861
- const j = (e) => {
1862
- const t = e;
1863
- return typeof t == "number" ? `${t}px` : t;
1864
- }, w = ({
1865
- as: e,
1866
- variant: t = "body1",
1867
- color: n,
1868
- className: o,
1869
- ...s
1870
- }) => /* @__PURE__ */ r.createElement(ys, { as: e, $variant: t, className: o, $color: n, ...s }), qt = /* @__PURE__ */ new WeakMap(), vs = (e, t) => {
1871
- let n = qt.get(t);
1872
- n || (n = /* @__PURE__ */ new Map(), qt.set(t, n));
1873
- const o = n.get(e);
1874
- if (o) return o;
1875
- const s = t[e] ?? t.body1, i = I`font-size:${j(s.fontSize)};font-weight:${s.fontWeight};${s.fontFamily ? `font-family: ${s.fontFamily};` : ""}
1876
- ${s.lineHeight ? `line-height: ${s.lineHeight};` : "line-height: 100%;"}
1877
- `;
1878
- return n.set(e, i), i;
1879
- }, ys = u.span`font-stretch:normal;font-style:normal;letter-spacing:normal;${({ $variant: e, theme: t }) => vs(e, t.typography)}color:${({ $color: e }) => e};`, J = "sb-agent", ee = {
1880
- ENTRY: `${J}-entry`,
1881
- MODAL_ROOT: `${J}-modal-root`,
1882
- WINDOW: `${J}-window`,
1883
- LAUNCHER: `${J}-launcher`
1884
- }, Ue = 2147483647, fe = {
1885
- MODAL: Ue - 1,
1886
- // FIXME: need to cover the case where the tooltip is on the top of the modal
1887
- TOOLTIP: Ue - 2,
1888
- WINDOW: Ue - 3,
1889
- LAUNCHER: Ue - 4
1890
- }, $n = {
1891
- DEFAULT_PRIMARY: "#742ddd",
1892
- WHITE: "#ffffff"
1893
- }, Mn = 36, _s = 100, Ss = 25 * 1024 * 1024, On = ["application/pdf", "image/jpeg", "image/jpg", "image/png"], St = "noopener noreferrer nofollow", Le = 244, Ln = 640, Ye = 26, Rn = 4, te = 12, Te = 2, Ts = 16, ne = `${J}-incoming-msg`, ws = `${J}-marked-text`;
1894
- function Tt(e) {
1895
- switch (e) {
1896
- case "top":
1897
- case "middle":
1898
- return Te;
1899
- default:
1900
- return Ts;
1901
- }
1902
- }
1903
- function wt(e, t) {
1904
- if (t) {
1905
- const [, n] = t.split("/");
1906
- if (n)
1907
- return n.toUpperCase();
1908
- }
1909
- if (e && !e.startsWith(".")) {
1910
- const n = e.split(".").pop();
1911
- if (n && n !== e)
1912
- return n.toUpperCase();
1913
- }
1914
- return "FILE";
1915
- }
1916
- function Dn(e) {
1917
- return e.messageType === "file" ? e.message.length > 0 && e.file.name !== e.message : e.message.length > 0;
1918
- }
1919
- const As = /* @__PURE__ */ new Set(["send", "chat", "message", "chevron-right"]), ks = {
1920
- spinner: T(() => import("./BcUGcaq2.js")),
1921
- chat: T(() => import("./DcFCGVBm.js")),
1922
- message: T(() => import("./DsGXnanX.js")),
1923
- error: T(() => import("./B6fvrWGq.js")),
1924
- info: T(() => import("./CAIYsKDy.js")),
1925
- refresh: T(() => import("./B6xd54zt.js")),
1926
- "chevron-down": T(() => import("./BsimU71m.js")),
1927
- "chevron-right": T(() => import("./NmJl7zv3.js")),
1928
- done: T(() => import("./D_q6g3Dd.js")),
1929
- user: T(() => import("./CvqfQEhO.js")),
1930
- "file-document": T(() => import("./BAr50pfO.js")),
1931
- download: T(() => import("./B2CtcWp3.js")),
1932
- attach: T(() => import("./DY2ULcTX.js")),
1933
- delete: T(() => import("./DMruRpOm.js")),
1934
- close: T(() => import("./CuaBI7kd.js")),
1935
- "close-filled": T(() => import("./CxQFWLnW.js")),
1936
- send: T(() => import("./DZJyDpNp.js")),
1937
- menu: T(() => import("./BUYabNz7.js")),
1938
- expand: T(() => import("./wBtIAuNm.js")),
1939
- collapse: T(() => import("./C0RFfifL.js")),
1940
- agent: T(() => import("./Cc7XmLN1.js")),
1941
- question: T(() => import("./dqwvRBog.js")),
1942
- actionbook: T(() => import("./CrjNuryZ.js")),
1943
- function: T(() => import("./CvdSjw1c.js")),
1944
- "radio-on": T(() => import("./nmdo2Fbj.js")),
1945
- "radio-off": T(() => import("./BnZcRFmS.js")),
1946
- confluence: T(() => import("./BOnlh2zd.js")),
1947
- zendesk: T(() => import("./BAJ6LEKc.js")),
1948
- salesforce: T(() => import("./CT2kv4lr.js")),
1949
- sprinklr: T(() => import("./m2INcyV2.js")),
1950
- website: T(() => import("./BgGVGNdg.js")),
1951
- snippet: T(() => import("./BFcXPuf5.js")),
1952
- template: T(() => import("./awO7aBCv.js")),
1953
- source: T(() => import("./_EVMCh6Y.js"))
1954
- }, M = ({ type: e, size: t = 24, className: n, color: o }) => {
1955
- const s = ks[e];
1956
- return /* @__PURE__ */ r.createElement(
1957
- $s,
1958
- {
1959
- className: n,
1960
- $rtlFlip: As.has(e),
1961
- $size: t,
1962
- $color: o ?? p.color.primary.main
1963
- },
1964
- /* @__PURE__ */ r.createElement(ke, { fallback: null }, /* @__PURE__ */ r.createElement(s, null))
1965
- );
1966
- }, Is = I`[dir='rtl'] &{transform:scaleX(-1);}`, $s = u.div`width:${({ $size: e }) => j(e)};height:${({ $size: e }) => j(e)};display:inline-block;&:focus{outline:none;}svg{display:block;}[class*='fill']{fill:${({ $color: e }) => e};}[class*='stroke']{stroke:${({ $color: e }) => e};stroke-width:2px;stroke-linejoin:round;}${({ $rtlFlip: e }) => e && Is};`;
1967
- function At({
1968
- name: e,
1969
- type: t = "FILE",
1970
- iconColor: n,
1971
- iconBackgroundColor: o,
1972
- onClick: s
1973
- }) {
1974
- const { colors: i } = xt();
1975
- return /* @__PURE__ */ r.createElement(Ms, { onClick: s, $clickable: !!s }, /* @__PURE__ */ r.createElement(Ls, { $bgColor: o ?? i.base.primary }, /* @__PURE__ */ r.createElement(M, { type: "file-document", size: 24, color: n ?? i.base.primaryContrastContent })), /* @__PURE__ */ r.createElement(Rs, null, /* @__PURE__ */ r.createElement(Ds, { variant: "button", color: p.themedColor.textHighEmphasis }, e), /* @__PURE__ */ r.createElement(w, { color: p.themedColor.textMidEmphasis, variant: "caption3" }, t)));
1976
- }
1977
- const Ms = u.div`border-radius:12px;gap:8px;width:${Le}px;height:64px;display:flex;align-items:center;padding:12px;box-sizing:border-box;border:1px solid ${p.themedColor.textDisabled};background-color:${p.themedColor.bg_50_600};${({ $clickable: e }) => e && Os}`, Os = I`cursor:pointer;&:hover{background-color:${p.themedColor.bg_100_500};}`, Ls = u.div`border-radius:8px;width:40px;height:40px;display:flex;align-items:center;justify-content:center;background-color:${({ $bgColor: e }) => e};`, Rs = u.div`display:flex;flex:1;flex-direction:column;gap:4px;min-width:0;`, Ds = u(w)`text-overflow:ellipsis;white-space:nowrap;overflow:hidden;`;
1978
- function Ns({ file: e, children: t, onClickFile: n }) {
1979
- return /* @__PURE__ */ r.createElement(Ps, null, /* @__PURE__ */ r.createElement(
1980
- At,
1981
- {
1982
- name: e.name,
1983
- type: wt(e.name, e.type),
1984
- onClick: n && (() => n == null ? void 0 : n(e))
1985
- }
1986
- ), t);
1987
- }
1988
- const Ps = u.div`display:flex;flex-direction:column;align-items:flex-start;gap:${Te}px;`;
1989
- function Bs({ file: e, onClickMedia: t, children: n }) {
1990
- const o = () => e.type.startsWith("image") ? /* @__PURE__ */ r.createElement(Hs, { src: e.url, alt: "image-message" }) : e.type.startsWith("video") ? /* @__PURE__ */ r.createElement(zs, { controls: !0 }, /* @__PURE__ */ r.createElement("source", { src: e.url }), /* @__PURE__ */ r.createElement("track", { kind: "captions" })) : null;
1991
- if (o) {
1992
- const s = {
1993
- id: `${ne}-media-body`,
1994
- onClick: () => t == null ? void 0 : t(e)
1995
- };
1996
- return /* @__PURE__ */ r.createElement(Fs, null, /* @__PURE__ */ r.createElement(Us, { ...s }, o()), n);
1997
- }
1998
- return null;
1999
- }
2000
- const Fs = u.div`display:flex;flex-direction:column;align-items:flex-start;gap:${Te}px;`, Us = u.div`width:${Le}px;height:160px;border-radius:12px;overflow:hidden;cursor:pointer;${P.light`
2001
- background-color: ${p.color.background100};
2002
- `}
2003
- ${P.dark`
2004
- background-color: ${p.color.background400};
2005
- `}
2006
- `, Hs = u.img`width:100%;height:100%;object-fit:cover;`, zs = u.video`width:100%;height:100%;object-fit:cover;`, Vs = "✱";
2007
- function Nn(e) {
2008
- const t = new RegExp(`${Vs}+`, "g");
2009
- return e.replace(t, (n) => `<span id=${ws} aria-label="masked-text">${n}</span>`);
2010
- }
2011
- function Ws(e) {
2012
- return e.replace(/\*\*(.*?)\*\*/g, "<b>$1</b>");
2013
- }
2014
- function Gs(e) {
2015
- const t = /```(\w+)?\n([\s\S]*?)```/g, n = [];
2016
- let o = 0;
2017
- return e.replace(t, (s, ...i) => {
2018
- const [a, l, c] = i;
2019
- return o < c && n.push({
2020
- type: "text",
2021
- value: e.slice(o, c).trim()
2022
- }), n.push({
2023
- type: "code",
2024
- value: l.trim(),
2025
- language: a ? a.trim() : "plaintext"
2026
- }), o = c + s.length, s;
2027
- }), o < e.length && n.push({
2028
- type: "text",
2029
- value: e.slice(o).trim()
2030
- }), n.map((s) => s.type !== "text" ? s : { ...s, value: Nn(s.value) });
2031
- }
2032
- const js = T(async () => ({ default: (await import("./D5uRw0Em.js")).MarkdownText })), Ks = T(async () => ({ default: (await import("./Ch_6OPTz.js")).CodeBlock }));
2033
- function Jt(e) {
2034
- var s, i;
2035
- const t = e.maxBodyWidth ?? Le, n = ae(() => Gs(e.message), [e.message]), o = {
2036
- id: `${ne}-text-body`,
2037
- $maxWidth: t,
2038
- $color: (s = e.customStyle) == null ? void 0 : s.bubbleContentColor,
2039
- $bgColor: (i = e.customStyle) == null ? void 0 : i.bubbleBackgroundColor
2040
- };
2041
- return n.length === 0 ? e.children ? /* @__PURE__ */ r.createElement(Xt, { ...o }, e.children) : null : /* @__PURE__ */ r.createElement(Xt, { ...o }, n.map((a, l) => a.type === "text" ? /* @__PURE__ */ r.createElement(Qt, { key: l, variant: "body3" }, /* @__PURE__ */ r.createElement(ke, { fallback: a.value }, /* @__PURE__ */ r.createElement(js, { onClickImage: (c) => {
2042
- var d;
2043
- return (d = e.onClickMedia) == null ? void 0 : d.call(e, { url: c, type: "image/*" });
2044
- } }, a.value))) : a.type === "code" ? /* @__PURE__ */ r.createElement(ke, { key: l, fallback: /* @__PURE__ */ r.createElement(Qt, { variant: "body3" }, a.value) }, /* @__PURE__ */ r.createElement(Ks, { code: a.value, language: a.language })) : null), e.children);
2045
- }
2046
- const Xt = u.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({ $maxWidth: e }) => e}px;${({ theme: e, $color: t, $bgColor: n }) => I`
2047
- color: ${t || e.colors.messageIncoming.text};
2048
- background-color: ${n || e.colors.messageIncoming.background};
2049
- `}
2050
- padding: 12px 0;
2051
- transition: max-width 0.3s;
2052
- overflow-wrap: break-word;
2053
- `, Qt = u(w)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;
2054
- function Zs(e) {
2055
- const { stringSet: t } = O(), n = Dn(e) ? /* @__PURE__ */ r.createElement(Jt, { ...e }) : null;
2056
- if (e.messageType === "user")
2057
- return n;
2058
- if (e.messageType === "file") {
2059
- const o = e.file;
2060
- return o.type.startsWith("image") || o.type.startsWith("video") ? /* @__PURE__ */ r.createElement(Bs, { ...e }, n) : /* @__PURE__ */ r.createElement(Ns, { ...e }, n);
2061
- }
2062
- return /* @__PURE__ */ r.createElement(Jt, { ...e, message: t.UNKNOWN__UNKNOWN_MESSAGE_TYPE });
2063
- }
2064
- const kt = (e) => /* @__PURE__ */ r.createElement("svg", { width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M12.0008 0.973633C10.6172 0.973633 9.49558 2.09527 9.49558 3.47888C9.49558 4.50705 10.115 5.39055 11.0009 5.77664V7.47887H13.0009V5.77653C13.8868 5.3904 14.5061 4.50696 14.5061 3.47888C14.5061 2.09527 13.3844 0.973633 12.0008 0.973633ZM0.250977 16.5788L0.250977 10.5789H2.25098L2.25098 16.5788H0.250977ZM21.7511 10.5789V16.5788H23.7511V10.5789H21.7511ZM18.251 7.47888H3.25097V18.9789C3.25097 20.3596 4.37026 21.4789 5.75097 21.4789H18.251C19.6317 21.4789 20.751 20.3596 20.751 18.9789V9.97887C20.751 8.59816 19.6317 7.47888 18.251 7.47888ZM9.78434 11.9539V15.2038C9.78434 15.7561 9.33663 16.2038 8.78434 16.2038C8.23206 16.2038 7.78434 15.7561 7.78434 15.2038V11.9539C7.78434 11.4016 8.23206 10.9539 8.78434 10.9539C9.33663 10.9539 9.78434 11.4016 9.78434 11.9539ZM16.2677 11.9539V15.2038C16.2677 15.7561 15.82 16.2038 15.2677 16.2038C14.7154 16.2038 14.2677 15.7561 14.2677 15.2038V11.9539C14.2677 11.4016 14.7154 10.9539 15.2677 10.9539C15.82 10.9539 16.2677 11.4016 16.2677 11.9539Z", fill: "#0D0D0D" }));
2065
- function It({ id: e, src: t, size: n = 56, onClick: o, style: s }) {
2066
- return /* @__PURE__ */ r.createElement(Ys, { id: e, tabIndex: 0, onClick: o, $size: j(n), style: s }, t ? /* @__PURE__ */ r.createElement(qs, { src: t }) : /* @__PURE__ */ r.createElement(M, { type: "user", size: n }));
2067
- }
2068
- const Ys = u.div`border-radius:50%;display:inline-block;overflow:hidden;position:relative;flex-shrink:0;height:${(e) => e.$size};width:${(e) => e.$size};background-color:${p.themedColor.bg_100_500};&:focus{outline:none;}`, qs = u.img`object-fit:cover;width:100%;height:100%;position:absolute;`;
2069
- function Js({ sender: e, isBotMessage: t }) {
2070
- const n = `${ne}-sender-avatar`;
2071
- return !e.profileUrl && t ? /* @__PURE__ */ r.createElement(Xs, { id: n }, /* @__PURE__ */ r.createElement(kt, null)) : /* @__PURE__ */ r.createElement(It, { id: n, size: Ye, src: e.profileUrl });
2072
- }
2073
- const Xs = u.div`flex-shrink:0;width:${Ye}px;height:${Ye}px;box-sizing:border-box;padding:6px;border-radius:50%;display:flex;justify-content:center;align-items:center;background-color:${({ theme: e }) => e.colors.base.primary};path{fill:${({ theme: e }) => e.colors.base.primaryContrastContent};}}`;
2074
- function Qs({ sender: e }) {
2075
- return /* @__PURE__ */ r.createElement(ei, { id: `${ne}-sender-name`, variant: "caption1", color: p.themedColor.textMidEmphasis }, e.nickname);
2076
- }
2077
- const ei = u(w)`text-align:start;width:100%;box-sizing:border-box;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-block:5px;padding-inline:0 7px;`;
2078
- function ti({ createdAt: e }) {
2079
- const { stringSet: t, format: n } = O();
2080
- return e ? /* @__PURE__ */ r.createElement(w, { id: `${ne}-sent-time`, variant: "caption4", color: p.themedColor.textLowEmphasis }, n(e, t.DATE_FORMAT__MESSAGE_TIMESTAMP)) : null;
2081
- }
2082
- function ni({ customStyle: e }) {
2083
- return /* @__PURE__ */ r.createElement(ri, { $bgColor: e == null ? void 0 : e.bubbleBackgroundColor }, [0, 1, 2].map((t) => /* @__PURE__ */ r.createElement(oi, { key: t, $color: e == null ? void 0 : e.bubbleContentColor })));
2084
- }
2085
- const ri = u.div`align-items:center;border-radius:12px;display:flex;gap:6px;justify-content:center;padding:16px 12px;background-color:${({ theme: e, $bgColor: t }) => t || e.colors.messageIncoming.background};`, oi = u.span`animation:blink 1.4s infinite;animation-fill-mode:both;border-radius:50%;height:8px;width:8px;background:${({ theme: e, $color: t }) => t || e.colors.messageIncoming.text};@keyframes blink{0%{opacity:0.12;transform:scale(1);}21.43%{opacity:0.38;transform:scale(1.2);}42.86%{opacity:0.12;transform:scale(1);}100%{opacity:0.12;transform:scale(1);}}&:nth-child(1){animation-delay:0.4s;}&:nth-child(2){animation-delay:0.6s;}&:nth-child(3){animation-delay:0.8s;}`;
2086
- function Ie() {
2087
- }
2088
- async function $t(e) {
2089
- let t = e;
2090
- t && (!t.startsWith("http://") && !t.startsWith("https://") && (t = "https://" + t), window.open(t, "_blank", "noopener,noreferrer"));
2091
- }
2092
- function Pn(e) {
2093
- return !e || !e.conversation ? !1 : e.conversation.status === W.CLOSED;
2094
- }
2095
- function Bn(e) {
2096
- return !e || !e.conversation ? !1 : e.conversation.status === W.OPEN;
2097
- }
2098
- function Fn(e) {
2099
- var n;
2100
- const t = (n = e == null ? void 0 : e.conversation) == null ? void 0 : n.handoff;
2101
- return !!(t != null && t.timestamp);
2102
- }
2103
- function si(e) {
2104
- return Bn(e) && !Fn(e);
2105
- }
2106
- function ii({
2107
- extendedMessagePayload: e,
2108
- onClickCTA: t = ({ url: n }) => $t(n)
2109
- }) {
2110
- const n = e == null ? void 0 : e.cta_button;
2111
- return n ? /* @__PURE__ */ r.createElement(ai, { id: `${ne}-ext-cta-button`, role: "button", onClick: () => t(n) }, /* @__PURE__ */ r.createElement(li, { variant: "button" }, n.label)) : null;
2112
- }
2113
- const ai = u.div`display:flex;align-items:center;justify-content:center;cursor:pointer;border-radius:6px;padding:8px;color:${p.themedColor.textHighEmphasis};background-color:${p.color.background50};${P.dark`
2114
- background-color: ${p.color.ondark.textDisabled};
2115
- `}
2116
- `, li = u(w)`overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`;
2117
- function ci({
2118
- extendedMessagePayload: e,
2119
- onClickCitation: t = (n) => $t(n.link)
2120
- }) {
2121
- const { stringSet: n } = O(), { theme: o } = Ct(), s = e == null ? void 0 : e.citations;
2122
- return !s || s.length === 0 ? null : /* @__PURE__ */ r.createElement(di, { id: `${ne}-ext-citation` }, /* @__PURE__ */ r.createElement(ui, { variant: "caption1", color: o.colors.messageIncoming.text }, n.CITATION_SOURCE_TITLE), /* @__PURE__ */ r.createElement(mi, null, s.map((i, a) => /* @__PURE__ */ r.createElement(
2123
- hi,
2124
- {
2125
- key: `${i.embedding_id}-${a}`,
2126
- role: "button",
2127
- onClick: () => t(i)
2128
- },
2129
- /* @__PURE__ */ r.createElement(M, { type: "source", size: 16, color: o.colors.messageIncoming.text }),
2130
- /* @__PURE__ */ r.createElement(gi, { variant: "body3", color: o.colors.messageIncoming.text }, i.title)
2131
- ))));
2132
- }
2133
- const di = u.div`display:flex;flex-direction:column;gap:8px;border-radius:8px;padding:8px 12px 6px;`, ui = u(w)`opacity:0.5;`, mi = u.div`display:flex;flex-direction:column;gap:8px;`, gi = u(w)`text-decoration:underline;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`, hi = u.div`display:flex;align-items:center;gap:4px;cursor:pointer;&:hover{opacity:0.5;}`;
2134
- function pi(e) {
2135
- return /* @__PURE__ */ r.createElement(r.Fragment, null);
2136
- }
2137
- class fi extends xr {
2138
- constructor(t) {
2139
- super(t), this.state = {
2140
- hasError: !1
2141
- };
2142
- }
2143
- static getDerivedStateFromError() {
2144
- return { hasError: !0 };
2145
- }
2146
- render() {
2147
- return this.state.hasError ? this.props.errorFallback : /* @__PURE__ */ r.createElement(ke, { fallback: this.props.loadingFallback }, this.props.children);
2148
- }
2149
- }
2150
- const bi = /* @__PURE__ */ new Set(["default"]), { MessageTemplate: Ei } = Vr({
2151
- parser: Hr,
2152
- renderer: Ur,
2153
- Container: (e) => /* @__PURE__ */ r.createElement("div", { ...e })
2154
- });
2155
- function xi(e) {
2156
- return /* @__PURE__ */ r.createElement(
2157
- fi,
2158
- {
2159
- errorFallback: e.messageTemplateErrorFallback,
2160
- loadingFallback: e.messageTemplateLoadingFallback
2161
- },
2162
- /* @__PURE__ */ r.createElement(Ci, { ...e })
2163
- );
2164
- }
2165
- const Ci = ({
2166
- extendedMessagePayload: e,
2167
- onGetCachedMessageTemplate: t = () => null,
2168
- onRequestMessageTemplate: n,
2169
- onHandleTemplateInternalAction: o = Ie
2170
- }) => {
2171
- const s = e == null ? void 0 : e.message_template;
2172
- if (!bi.has((s == null ? void 0 : s.type) ?? "default")) throw new Error("Unsupported template type");
2173
- if (!n) throw new Error("onRequestMessageTemplate is required");
2174
- const { theme: a } = cs(), l = Yo({
2175
- onRequestTemplate: n,
2176
- onGetCachedTemplate: t,
2177
- theme: a.selectedTheme,
2178
- templateKey: (s == null ? void 0 : s.key) ?? "invalid",
2179
- variables: s == null ? void 0 : s.variables,
2180
- viewVariables: s == null ? void 0 : s.view_variables,
2181
- aiAgentColorVariables: a.aiAgentColorVariables
2182
- });
2183
- return /* @__PURE__ */ r.createElement(vi, { id: `${ne}-ext-message-template` }, /* @__PURE__ */ r.createElement(
2184
- zr,
2185
- {
2186
- handleInternalAction: (c, d) => {
2187
- c.stopPropagation(), o == null || o(d);
2188
- }
2189
- },
2190
- /* @__PURE__ */ r.createElement(Ei, { templateItems: l.body.items, templateVersion: l.version })
2191
- ));
2192
- }, vi = u.div`box-sizing:border-box;overflow:hidden;width:100%;`;
2193
- function yi({
2194
- extendedMessagePayload: e,
2195
- onClickSuggestedReply: t,
2196
- suggestedRepliesDirection: n = "vertical"
2197
- }) {
2198
- const [o, s] = _(!1), i = (e == null ? void 0 : e.suggested_replies) ?? [];
2199
- return i.length === 0 || o ? null : /* @__PURE__ */ r.createElement(_i, { id: `${ne}-ext-suggested-replies`, $type: n }, i.map((a, l) => /* @__PURE__ */ r.createElement(
2200
- Si,
2201
- {
2202
- key: l,
2203
- $type: n,
2204
- variant: "body3",
2205
- onClick: () => {
2206
- t && (t == null || t({ reply: a }), s(!0));
2207
- }
2208
- },
2209
- a
2210
- )));
2211
- }
2212
- const _i = u.div`margin:16px 0;padding:0 ${te}px;position:relative;display:flex;gap:8px;${({ $type: e }) => e === "vertical" ? Ti : wi};`, Si = u(w)`box-sizing:border-box;padding:8px 12px;display:flex;align-items:center;border-radius:20px / clamp(20px,5%,100px);cursor:pointer;word-break:break-word;color:${p.color.primary.main};border:1px solid ${p.color.primary.main};background-color:${p.themedColor.bg_50_600};&:hover{background-color:${p.themedColor.bg_100_500};}${({ $type: e, theme: t }) => I`
2213
- ${e === "vertical" ? Ai : ki};
2214
- &:active {
2215
- background-color: ${t.colors.base.primary};
2216
- color: ${t.colors.base.primaryContrastContent};
2217
- }
2218
- `}
2219
- `, Ti = I`flex-direction:column;align-items:flex-end;`, wi = I`flex-direction:row;overflow-x:scroll;-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none;}`, Ai = I`max-width:calc(100% - 70px);white-space:pre-wrap;`, ki = I`white-space:nowrap;`;
2220
- function Mt(e) {
2221
- return e();
2222
- }
2223
- const xe = _e({
2224
- template: Ii,
2225
- components: {
2226
- SenderName: Qs,
2227
- SenderAvatar: Js,
2228
- SentTime: ti,
2229
- MessageBody: Zs,
2230
- TypingIndicator: ni,
2231
- SuggestedReplies: yi,
2232
- MessageTemplate: xi,
2233
- CTAButton: ii,
2234
- Citation: ci,
2235
- MessageLogs: pi
2236
- }
2237
- });
2238
- function Ii(e) {
2239
- return /* @__PURE__ */ r.createElement(Un, { ...e, testerMode: !1 });
2240
- }
2241
- function Un(e) {
2242
- var f, x, E, b, g;
2243
- const { components: t } = xe.useContext(), n = !!e.isTyping, o = e.testerMode, s = !!((f = e.extendedMessagePayload) != null && f.message_template), i = !!((x = e.extendedMessagePayload) != null && x.cta_button), a = !!((E = e.extendedMessagePayload) != null && E.citations) && e.extendedMessagePayload.citations.length > 0, l = !!e.createdAt, c = Mt(() => e.messageType === "user" ? e.message.length > 0 : !0), d = e.groupType === "top" || e.groupType === "single", h = e.groupType === "bottom" || e.groupType === "single", m = o ? 0 : Ye;
2244
- return /* @__PURE__ */ r.createElement($i, { $marginBottom: n ? 0 : Tt(e.groupType) }, d && /* @__PURE__ */ r.createElement(Mi, null, !o && /* @__PURE__ */ r.createElement(t.SenderAvatar, { ...e }), /* @__PURE__ */ r.createElement(t.SenderName, { ...e })), /* @__PURE__ */ r.createElement(Ut, null, /* @__PURE__ */ r.createElement(at, { $extraStartPadding: m }, n && /* @__PURE__ */ r.createElement(t.TypingIndicator, { ...e }), /* @__PURE__ */ r.createElement(t.MessageBody, { ...e }, i && /* @__PURE__ */ r.createElement("div", { style: { marginTop: 12, marginInline: 12 } }, /* @__PURE__ */ r.createElement(t.CTAButton, { ...e })), a && /* @__PURE__ */ r.createElement(t.Citation, { ...e }))), s && /* @__PURE__ */ r.createElement(en, { $startPadding: 0, $endPadding: 0, style: { marginTop: c ? Te : 0 } }, /* @__PURE__ */ r.createElement(
2245
- t.MessageTemplate,
2246
- {
2247
- ...e,
2248
- messageTemplateErrorFallback: e.messageTemplateErrorFallback ?? /* @__PURE__ */ r.createElement(at, { $extraStartPadding: m }, /* @__PURE__ */ r.createElement(
2249
- t.MessageBody,
2250
- {
2251
- ...e,
2252
- messageType: "user",
2253
- message: ((g = (b = e.extendedMessagePayload) == null ? void 0 : b.message_template) == null ? void 0 : g.fallback_message) ?? "Cannot read this template."
2254
- }
2255
- )),
2256
- messageTemplateLoadingFallback: e.messageTemplateLoadingFallback ?? /* @__PURE__ */ r.createElement(at, { $extraStartPadding: m }, /* @__PURE__ */ r.createElement(t.TypingIndicator, { ...e }))
2257
- }
2258
- ))), h && l && /* @__PURE__ */ r.createElement(Oi, { $extraStartPadding: m + 8 }, /* @__PURE__ */ r.createElement(t.SentTime, { ...e })), /* @__PURE__ */ r.createElement(Ut, null, e.suggestedRepliesVisible && /* @__PURE__ */ r.createElement(en, null, /* @__PURE__ */ r.createElement(t.SuggestedReplies, { ...e })), /* @__PURE__ */ r.createElement(t.MessageLogs, { ...e })));
2259
- }
2260
- const $i = u.div`display:flex;flex-direction:column;align-items:flex-start;margin-bottom:${({ $marginBottom: e }) => `${e}px`};
2261
- `, tt = u.div`display:flex;align-self:stretch;justify-content:flex-start;${({ $startPadding: e = te, $endPadding: t = te, $extraStartPadding: n = 0 }) => `
2262
- padding-inline: ${e + n}px ${t}px;
2263
- `}
2264
- `, Mi = u(tt)`display:flex;flex-direction:row;align-items:center;gap:8px;`, at = u(tt)`display:flex;`, Oi = u(tt)`margin-top:${Rn}px;display:flex;align-items:flex-start;justify-content:flex-start;`, en = u(tt)`display:flex;flex-direction:column;${({ $startPadding: e = te, $endPadding: t = te, $extraStartPadding: n = 0 }) => `
2265
- padding-inline: ${e + n}px ${t}px;
2266
- `}
2267
- `;
2268
- function Li({ file: e, children: t, onClickFile: n }) {
2269
- return /* @__PURE__ */ r.createElement(Ri, null, /* @__PURE__ */ r.createElement(
2270
- At,
2271
- {
2272
- name: e.name,
2273
- type: wt(e.name, e.type),
2274
- onClick: n && (() => n == null ? void 0 : n(e))
2275
- }
2276
- ), t);
2277
- }
2278
- const Ri = u.div`display:flex;flex-direction:column;align-items:flex-end;gap:${Te}px;`, Hn = ({ className: e, children: t, size: n = 26 }) => /* @__PURE__ */ r.createElement(Di, { className: e, $size: n }, t ?? /* @__PURE__ */ r.createElement(M, { type: "spinner", size: n })), Di = u.div`display:flex;align-items:center;justify-content:center;width:${({ $size: e }) => j(e)};height:${({ $size: e }) => j(e)};animation:1s infinite linear;animation-name:rotate;@keyframes rotate{from{transform:rotate(0);}to{transform:rotate(360deg);}}`;
2279
- function Ni({ file: e, metadata: t, onClickMedia: n, children: o }) {
2280
- const { aspectRatio: s, localFile: i } = t, [a] = _(() => i instanceof File ? URL.createObjectURL(i) : e.url), [l, c] = _(!1), d = {
2281
- onClick: () => n == null ? void 0 : n(e),
2282
- $ratio: s
2283
- };
2284
- return /* @__PURE__ */ r.createElement(Pi, null, /* @__PURE__ */ r.createElement(Bi, { ...d }, !l && /* @__PURE__ */ r.createElement(Hn, { size: 26 }, /* @__PURE__ */ r.createElement(M, { type: "spinner", color: "textLowEmphasis", size: 26 })), /* @__PURE__ */ r.createElement(Fi, { $loaded: l, src: a, alt: "image-message", onLoad: () => c(!0) })), o);
2285
- }
2286
- const Pi = u.div`display:flex;flex-direction:column;align-items:flex-end;gap:${Te}px;`, Bi = u.div`width:${Le}px;border-radius:12px;overflow:hidden;cursor:pointer;height:auto;aspect-ratio:${(e) => e.$ratio};position:relative;display:flex;align-items:center;justify-content:center;${P.light`
2287
- background-color: ${p.color.background100};
2288
- `}
2289
- ${P.dark`
2290
- background-color: ${p.color.background400};
2291
- `}
2292
- `, Fi = u.img`position:absolute;width:100%;height:100%;inset-block-start:0;inset-inline-start:0;object-fit:cover;opacity:${(e) => e.$loaded ? 1 : 0};transition:opacity 0.5s ease;`;
2293
- function tn(e) {
2294
- var n, o;
2295
- const t = ae(() => {
2296
- const s = Ws(Nn(e.message));
2297
- return yn.sanitize(s);
2298
- }, [e.message]);
2299
- return /* @__PURE__ */ r.createElement(
2300
- Ui,
2301
- {
2302
- $maxWidth: e.maxBodyWidth ?? Le,
2303
- $color: (n = e.customStyle) == null ? void 0 : n.bubbleContentColor,
2304
- $bgColor: (o = e.customStyle) == null ? void 0 : o.bubbleBackgroundColor
2305
- },
2306
- /* @__PURE__ */ r.createElement(Hi, { variant: "body3", dangerouslySetInnerHTML: { __html: t } })
2307
- );
2308
- }
2309
- const Ui = u.div`display:flex;flex-direction:column;border-radius:12px;overflow:hidden;max-width:${({ $maxWidth: e }) => e}px;${({ theme: e, $color: t, $bgColor: n }) => I`
2310
- color: ${t || e.colors.messageOutgoing.text};
2311
- background-color: ${n || e.colors.messageOutgoing.background};
2312
- `}
2313
- padding: 12px 0;
2314
- transition: max-width 0.3s;
2315
- overflow-wrap: break-word;
2316
- `, Hi = u(w)`align-items:flex-start;line-height:140%;white-space:pre-wrap;padding:0 12px;`;
2317
- function zi(e) {
2318
- const { stringSet: t } = O(), n = Dn(e) ? /* @__PURE__ */ r.createElement(tn, { ...e }) : null;
2319
- return e.messageType === "user" ? n : e.messageType === "file" ? e.file.type.startsWith("image") ? /* @__PURE__ */ r.createElement(Ni, { ...e }, n) : /* @__PURE__ */ r.createElement(Li, { ...e }, n) : /* @__PURE__ */ r.createElement(tn, { ...e, message: t.UNKNOWN__UNKNOWN_MESSAGE_TYPE });
2320
- }
2321
- function Vi({ sendingStatus: e }) {
2322
- const t = xt();
2323
- switch (e) {
2324
- case "pending":
2325
- return /* @__PURE__ */ r.createElement(Wi, { size: 16 }, /* @__PURE__ */ r.createElement(M, { type: "spinner", color: t.colors.messageOutgoing.background, size: 16 }));
2326
- case "failed":
2327
- return /* @__PURE__ */ r.createElement("div", { style: { marginBottom: 2 } }, /* @__PURE__ */ r.createElement(M, { type: "error", color: p.themedColor.error, size: 16 }));
2328
- case "scheduled":
2329
- case "canceled":
2330
- return null;
2331
- default:
2332
- return /* @__PURE__ */ r.createElement("div", null, /* @__PURE__ */ r.createElement(M, { type: "chevron-down" }));
2333
- }
2334
- }
2335
- const Wi = u(Hn)`margin-bottom:2px;width:16px;height:16px;`;
2336
- function Gi({ createdAt: e }) {
2337
- const { stringSet: t, format: n } = O();
2338
- return e ? /* @__PURE__ */ r.createElement(w, { variant: "caption4", color: p.themedColor.textLowEmphasis }, n(e, t.DATE_FORMAT__MESSAGE_TIMESTAMP)) : null;
2339
- }
2340
- const Ot = _e({
2341
- template: ji,
2342
- components: {
2343
- SendingStatus: Vi,
2344
- SentTime: Gi,
2345
- MessageBody: zi
2346
- }
2347
- });
2348
- function ji(e) {
2349
- const { components: t } = Ot.useContext(), n = e.sendingStatus === "succeeded", o = e.groupType === "bottom" || e.groupType === "single";
2350
- return /* @__PURE__ */ r.createElement(Ki, { $marginBottom: Tt(e.groupType) }, /* @__PURE__ */ r.createElement(Zi, null, /* @__PURE__ */ r.createElement(t.MessageBody, { ...e })), o && /* @__PURE__ */ r.createElement(Yi, { $extraEndPadding: 8 }, n ? /* @__PURE__ */ r.createElement(t.SentTime, { ...e }) : /* @__PURE__ */ r.createElement(t.SendingStatus, { ...e })));
2351
- }
2352
- const Ki = u.div`display:flex;flex:1;flex-direction:column;align-items:flex-end;margin-bottom:${({ $marginBottom: e }) => `${e}px`};
2353
- `, zn = u.div`display:flex;align-self:stretch;justify-content:flex-end;${({ $startPadding: e = te, $endPadding: t = te, $extraEndPadding: n = 0 }) => `padding-inline: ${e}px ${t + n}px;`};
2354
- `, Zi = u(zn)``, Yi = u(zn)`margin-top:${Rn}px;`;
2355
- function qi(e) {
2356
- return e.messageType !== "admin" ? null : /* @__PURE__ */ r.createElement(Ji, null, /* @__PURE__ */ r.createElement(w, { variant: "caption2", color: p.themedColor.textMidEmphasis }, Xi(yn.sanitize(e.message))));
2357
- }
2358
- const Ji = u.div`text-align:center;text-wrap:pretty;a{text-decoration:none;color:inherit;}`, Xi = (e) => {
2359
- const t = /\[([^\]]+)\]\((https?:\/\/[^\s]+)\)/g, n = [];
2360
- let o = 0;
2361
- return e.replace(t, (s, i, a, l) => (n.push(e.slice(o, l)), n.push(
2362
- /* @__PURE__ */ r.createElement("a", { key: a, href: a, target: "_blank", rel: St }, i)
2363
- ), o = l + s.length, s)), n.push(e.slice(o)), n;
2364
- }, Qi = ({ submitted: e, defaultValue: t, value: n, onChange: o }) => {
2365
- const { stringSet: s } = O();
2366
- return L(() => {
2367
- typeof n > "u" && typeof t == "boolean" && (o == null || o(t));
2368
- }, [n, t]), /* @__PURE__ */ r.createElement(ea, null, /* @__PURE__ */ r.createElement(w, { variant: "caption2", color: p.themedColor.textMidEmphasis }, s.CSAT_CRE_TITLE), /* @__PURE__ */ r.createElement("div", null, /* @__PURE__ */ r.createElement(
2369
- nn,
2370
- {
2371
- checked: n === !0,
2372
- label: s.CSAT_CRE_SOLVED,
2373
- disabled: e,
2374
- onClick: () => o == null ? void 0 : o(!0)
2375
- }
2376
- ), /* @__PURE__ */ r.createElement(
2377
- nn,
2378
- {
2379
- checked: n === !1,
2380
- label: s.CSAT_CRE_NOT_SOLVED,
2381
- disabled: e,
2382
- onClick: () => o == null ? void 0 : o(!1)
2383
- }
2384
- )));
2385
- }, nn = ({ onClick: e, checked: t, label: n, disabled: o }) => {
2386
- const s = t ? p.color.primary.main : o ? p.themedColor.textDisabled : p.themedColor.textLowEmphasis, i = t ? p.themedColor.textHighEmphasis : o ? p.themedColor.textLowEmphasis : p.themedColor.textHighEmphasis;
2387
- return /* @__PURE__ */ r.createElement(ta, { onClick: e, disabled: o }, /* @__PURE__ */ r.createElement(M, { size: 24, type: t ? "radio-on" : "radio-off", color: s }), /* @__PURE__ */ r.createElement(w, { variant: "caption2", color: i }, n));
2388
- }, ea = u.div`display:flex;flex-direction:column;gap:8px;`, ta = u.button`all:unset;display:flex;align-items:center;justify-content:flex-start;gap:2px;span{line-height:initial;}&:enabled{cursor:pointer;}`, na = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", id: "csat1", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.08301 20C2.08301 10.1049 10.1046 2.08334 19.9997 2.08334C29.8948 2.08334 37.9163 10.1049 37.9163 20C37.9163 29.8952 29.8948 37.9167 19.9997 37.9167C10.1046 37.9167 2.08301 29.8952 2.08301 20Z", fill: "#E0E0E0" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M12.5824 29.3328C13.1344 29.7473 13.918 29.636 14.3326 29.084C15.6269 27.3607 17.6835 26.25 19.9997 26.25C22.316 26.25 24.3727 27.3607 25.6668 29.084C26.0815 29.636 26.865 29.7473 27.4172 29.3328C27.9692 28.9182 28.0805 28.1347 27.6658 27.5825C25.9198 25.2577 23.1357 23.75 19.9997 23.75C16.8638 23.75 14.0797 25.2577 12.3336 27.5825C11.919 28.1347 12.0304 28.9182 12.5824 29.3328Z", fill: "black", fillOpacity: 0.12 }), /* @__PURE__ */ r.createElement("path", { d: "M28.4449 13.7707C29.1324 13.8328 29.64 14.4406 29.578 15.1281C29.516 15.8153 28.909 16.3221 28.2219 16.2608C28.2219 16.2608 28.0282 16.2502 27.9267 16.2487C27.7224 16.2457 27.4382 16.2509 27.1224 16.2833C26.7864 16.3177 26.4644 16.3782 26.1799 16.4662L26.304 16.86C26.7792 18.3675 25.5094 19.5813 24.2057 19.5813C23.504 19.5813 22.8319 19.2617 22.4295 18.6857C22.0025 18.0745 21.9417 17.241 22.4075 16.5344C22.7505 16.0143 23.2444 15.3831 23.8959 14.8657C24.8355 14.1195 26.0435 13.8809 26.867 13.7963C27.3024 13.7517 28.0149 13.7319 28.4449 13.7707Z", fill: "black", fillOpacity: 0.12 }), /* @__PURE__ */ r.createElement("path", { d: "M11.5553 13.7707C10.8677 13.8328 10.3601 14.4406 10.4221 15.1281C10.4842 15.8153 11.0912 16.3221 11.7782 16.2608C11.7782 16.2608 11.972 16.2502 12.0734 16.2487C12.2778 16.2457 12.562 16.2509 12.8778 16.2833C13.2137 16.3177 13.5357 16.3782 13.8203 16.4662L13.6962 16.86C13.2209 18.3675 14.4907 19.5813 15.7944 19.5813C16.4962 19.5813 17.1683 19.2617 17.5707 18.6857C17.9975 18.0745 18.0585 17.241 17.5925 16.5344C17.2497 16.0143 16.7557 15.3831 16.1043 14.8657C15.1646 14.1195 13.9566 13.8809 13.1331 13.7963C12.6978 13.7517 11.9853 13.7319 11.5553 13.7707Z", fill: "black", fillOpacity: 0.12 })), ra = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.08337 19.9999C2.08337 10.1048 10.1049 2.08325 20 2.08325C29.8952 2.08325 37.9167 10.1048 37.9167 19.9999C37.9167 29.8951 29.8952 37.9166 20 37.9166C10.1049 37.9166 2.08337 29.8951 2.08337 19.9999Z", fill: "url(#paint0_linear_159_173206)" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M12.5828 29.3328C13.1348 29.7473 13.9184 29.636 14.3329 29.084C15.6272 27.3607 17.6839 26.25 20 26.25C22.3164 26.25 24.373 27.3607 25.6672 29.084C26.0819 29.636 26.8654 29.7473 27.4175 29.3328C27.9695 28.9182 28.0809 28.1347 27.6662 27.5825C25.9202 25.2577 23.136 23.75 20 23.75C16.8642 23.75 14.0801 25.2577 12.334 27.5825C11.9194 28.1347 12.0308 28.9182 12.5828 29.3328Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { d: "M28.4454 13.7707C29.1329 13.8328 29.6405 14.4406 29.5785 15.1281C29.5165 15.8153 28.9095 16.3221 28.2224 16.2608C28.2224 16.2608 28.0287 16.2502 27.9272 16.2487C27.7229 16.2457 27.4387 16.2509 27.1229 16.2833C26.7869 16.3177 26.4649 16.3782 26.1804 16.4662L26.3045 16.86C26.7797 18.3675 25.5099 19.5813 24.2062 19.5813C23.5045 19.5813 22.8324 19.2617 22.43 18.6857C22.003 18.0745 21.9422 17.241 22.408 16.5344C22.751 16.0143 23.2449 15.3831 23.8964 14.8657C24.836 14.1195 26.044 13.8809 26.8675 13.7963C27.3029 13.7517 28.0154 13.7319 28.4454 13.7707Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { d: "M11.5549 13.7707C10.8674 13.8328 10.3597 14.4406 10.4218 15.1281C10.4838 15.8153 11.0908 16.3221 11.7779 16.2608C11.7779 16.2608 11.9716 16.2502 12.073 16.2487C12.2774 16.2457 12.5616 16.2509 12.8774 16.2833C13.2134 16.3177 13.5353 16.3782 13.8199 16.4662L13.6958 16.86C13.2205 18.3675 14.4904 19.5813 15.794 19.5813C16.4958 19.5813 17.168 19.2617 17.5703 18.6857C17.9971 18.0745 18.0581 17.241 17.5921 16.5344C17.2493 16.0143 16.7553 15.3831 16.1039 14.8657C15.1643 14.1195 13.9562 13.8809 13.1327 13.7963C12.6974 13.7517 11.9849 13.7319 11.5549 13.7707Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("defs", null, /* @__PURE__ */ r.createElement("linearGradient", { id: "paint0_linear_159_173206", x1: 20, y1: 2.08325, x2: 20, y2: 37.9166, gradientUnits: "userSpaceOnUse" }, /* @__PURE__ */ r.createElement("stop", { stopColor: "#FF2D1D" }), /* @__PURE__ */ r.createElement("stop", { offset: 1, stopColor: "#FFA540" })))), oa = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z", fill: "#E0E0E0" }), /* @__PURE__ */ r.createElement("path", { d: "M15 28.333C16.3927 27.2867 18.124 26.6667 20 26.6667C21.876 26.6667 23.6073 27.2867 25 28.333", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ r.createElement("path", { d: "M11.667 13.3511C11.667 13.3511 14.0161 13.139 15.3268 14.18M15.3268 14.18L14.8882 15.5711C14.7153 16.1199 15.1675 16.6667 15.7943 16.6667C16.4531 16.6667 16.8882 16.0723 16.549 15.5579C16.2483 15.102 15.8388 14.5866 15.3268 14.18ZM23.3337 13.3511C23.3337 13.3511 25.6827 13.139 26.9935 14.18M26.9935 14.18L26.555 15.5711C26.382 16.1199 26.8342 16.6667 27.461 16.6667C28.1198 16.6667 28.5548 16.0723 28.2157 15.5579C27.915 15.102 27.5055 14.5866 26.9935 14.18Z", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" })), sa = (e) => /* @__PURE__ */ r.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z", fill: "#FFD46E" }), /* @__PURE__ */ r.createElement("path", { d: "M14.249 27.334C15.851 26.13 17.844 25.417 20 25.417c2.156 0 4.149.714 5.751 1.917.553.415.664 1.199.25 1.751-.415.552-1.199.664-1.751.25-1.183-.889-2.652-1.416-4.25-1.416s-3.067.527-4.25 1.416c-.553.414-1.336.302-1.751-.25-.415-.552-.303-1.336.249-1.751Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { d: "M23.445 14.596c-.687.062-1.294-.445-1.356-1.132-.062-.687.445-1.295 1.132-1.357.082-.005.342-.02.482-.022.277-.004.662.002 1.097.047.823.085 2.031.323 2.97 1.07.652.518 1.146 1.15 1.489 1.67.466.706.405 1.54-.022 2.15-.402.576-1.074.896-1.775.896-1.304 0-2.573-1.214-2.098-2.722l.125-.394c-.285-.088-.607-.148-.942-.182-.316-.033-.6-.038-.804-.035-.101.002-.242.01-.294.013Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { d: "M11.779 14.596c-.687.062-1.294-.445-1.356-1.132-.062-.687.445-1.295 1.132-1.357.082-.005.342-.02.482-.022.277-.004.662.002 1.097.047.823.085 2.031.323 2.97 1.07.652.518 1.146 1.15 1.489 1.67.466.706.405 1.54-.022 2.15-.402.576-1.074.896-1.775.896-1.304 0-2.573-1.214-2.098-2.722l.124-.394c-.284-.088-.606-.148-.941-.182-.316-.033-.6-.038-.804-.035-.101.002-.243.01-.294.013Z", fill: "#141B34" })), ia = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z", fill: "#E0E0E0" }), /* @__PURE__ */ r.createElement("path", { d: "M13.348 15H13.333M26.6663 15H26.6513", stroke: "black", strokeOpacity: 0.12, strokeWidth: 3.33333, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ r.createElement("path", { d: "M15 26.6667H25", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" })), aa = (e) => /* @__PURE__ */ r.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z", fill: "#FFD46E" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M11.25 15c0-1.151.933-2.083 2.083-2.083h.015c1.151 0 2.084.933 2.084 2.083 0 1.151-.933 2.083-2.084 2.083h-.015c-1.15 0-2.083-.933-2.083-2.083ZM24.568 15c0-1.151.933-2.083 2.084-2.083h.015c1.151 0 2.083.933 2.083 2.083 0 1.151-.932 2.083-2.083 2.083h-.015c-1.151 0-2.084-.933-2.084-2.083Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M13.75 26.667c0-.691.56-1.25 1.25-1.25h10c.69 0 1.25.559 1.25 1.25 0 .691-.56 1.25-1.25 1.25h-10c-.69 0-1.25-.559-1.25-1.25Z", fill: "#141B34" })), la = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M19.9997 36.6667C29.2044 36.6667 36.6663 29.2048 36.6663 20C36.6663 10.7953 29.2044 3.33334 19.9997 3.33334C10.7949 3.33334 3.33301 10.7953 3.33301 20C3.33301 29.2048 10.7949 36.6667 19.9997 36.6667Z", fill: "#E0E0E0" }), /* @__PURE__ */ r.createElement("path", { d: "M13.333 25C14.8532 27.024 17.2735 28.3333 19.9997 28.3333C22.7258 28.3333 25.1462 27.024 26.6663 25", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ r.createElement("path", { d: "M13.348 15H13.333M26.6663 15H26.6513", stroke: "black", strokeOpacity: 0.12, strokeWidth: 3.33333, strokeLinecap: "round", strokeLinejoin: "round" })), ca = (e) => /* @__PURE__ */ r.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z", fill: "#FFD46E" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M12.583 24.001c.552-.414 1.335-.302 1.75.25 1.294 1.723 3.35 2.834 5.667 2.834s4.373-1.11 5.667-2.834c.415-.552 1.199-.664 1.751-.25.552.415.664 1.199.25 1.751C25.92 28.076 23.136 29.584 20 29.584s-5.92-1.508-7.666-3.832c-.415-.552-.303-1.336.249-1.751Z", fill: "#141B34" }), /* @__PURE__ */ r.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M11.25 15c0-1.151.933-2.083 2.083-2.083h.015c1.151 0 2.084.933 2.084 2.083 0 1.151-.933 2.083-2.084 2.083h-.015c-1.15 0-2.083-.933-2.083-2.083ZM24.568 15c0-1.151.933-2.083 2.084-2.083h.015c1.151 0 2.083.933 2.083 2.083 0 1.151-.932 2.083-2.083 2.083h-.015c-1.151 0-2.084-.933-2.084-2.083Z", fill: "#141B34" })), da = (e) => /* @__PURE__ */ r.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M19.9997 36.6663C29.2044 36.6663 36.6663 29.2044 36.6663 19.9997C36.6663 10.7949 29.2044 3.33301 19.9997 3.33301C10.7949 3.33301 3.33301 10.7949 3.33301 19.9997C3.33301 29.2044 10.7949 36.6663 19.9997 36.6663Z", fill: "#E0E0E0" }), /* @__PURE__ */ r.createElement("path", { d: "M19.9997 30C23.16 30 25.8145 27.867 26.56 24.9832C26.9068 23.6413 26.4033 23.3333 25.0765 23.3333H14.9228C13.5959 23.3333 13.0925 23.6413 13.4393 24.9832C14.1848 27.867 16.8393 30 19.9997 30Z", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ r.createElement("path", { d: "M11.667 15.8333C11.667 14.4526 12.7863 13.3333 14.167 13.3333C15.5477 13.3333 16.667 14.4526 16.667 15.8333M23.3337 15.8333C23.3337 14.4526 24.453 13.3333 25.8337 13.3333C27.2143 13.3333 28.3337 14.4526 28.3337 15.8333", stroke: "black", strokeOpacity: 0.12, strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round" })), ua = (e) => /* @__PURE__ */ r.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 40, height: 40, viewBox: "0 0 40 40", fill: "none", ...e }, /* @__PURE__ */ r.createElement("path", { d: "M2.083 20C2.083 10.105 10.105 2.083 20 2.083c9.895 0 17.917 8.021 17.917 17.917 0 9.895-8.022 17.917-17.917 17.917C10.105 37.917 2.083 29.895 2.083 20Z", fill: "#FFD46E" }), /* @__PURE__ */ r.createElement("g", { clipPath: "url(#clip0_159_173224)" }, /* @__PURE__ */ r.createElement("g", { clipPath: "url(#clip1_159_173224)" }, /* @__PURE__ */ r.createElement("path", { d: "M20 30.624c3.752 0 6.904-2.532 7.789-5.956.412-1.593-.185-1.959-1.76-1.959H13.973c-1.575 0-2.173.366-1.761 1.959.885 3.424 4.037 5.956 7.788 5.956Z", fill: "#141B34" })), /* @__PURE__ */ r.createElement("mask", { id: "mask0_159_173224", style: {
2389
- maskType: "alpha"
2390
- }, maskUnits: "userSpaceOnUse", x: 12, y: 22, width: 16, height: 9 }, /* @__PURE__ */ r.createElement("path", { d: "M20 30.624c3.752 0 6.904-2.532 7.789-5.956.412-1.593-.185-1.959-1.76-1.959H13.973c-1.575 0-2.173.366-1.761 1.959.885 3.424 4.037 5.956 7.788 5.956Z", fill: "#141B34" })), /* @__PURE__ */ r.createElement("g", { mask: "url(#mask0_159_173224)" }, /* @__PURE__ */ r.createElement("path", { d: "M20 32.998c3.278 0 5.936-1.594 5.936-3.561 0-1.968-2.658-3.562-5.936-3.562-3.278 0-5.936 1.594-5.936 3.562 0 1.967 2.658 3.561 5.936 3.561Z", fill: "#FF493B" }))), /* @__PURE__ */ r.createElement("path", { d: "M11.667 15.833c0-1.381 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5M23.333 15.833c0-1.381 1.12-2.5 2.5-2.5s2.5 1.12 2.5 2.5", stroke: "#141B34", strokeWidth: 2.5, strokeLinecap: "round", strokeLinejoin: "round" }), /* @__PURE__ */ r.createElement("defs", null, /* @__PURE__ */ r.createElement("clipPath", { id: "clip0_159_173224" }, /* @__PURE__ */ r.createElement("rect", { width: 15.83, height: 7.915, fill: "white", transform: "translate(12.085 22.709)" })), /* @__PURE__ */ r.createElement("clipPath", { id: "clip1_159_173224" }, /* @__PURE__ */ r.createElement("rect", { width: 15.83, height: 7.915, fill: "white", transform: "translate(12.085 22.709)" })))), ma = [
2391
- {
2392
- value: 1,
2393
- Icon: {
2394
- Active: ra,
2395
- Inactive: na
2396
- },
2397
- isActive: (e) => e <= 1,
2398
- getTooltip: (e) => e.CSAT5_RATING_SCORE_1
2399
- },
2400
- {
2401
- value: 2,
2402
- Icon: {
2403
- Active: sa,
2404
- Inactive: oa
2405
- },
2406
- isActive: (e) => e === 2,
2407
- getTooltip: (e) => e.CSAT5_RATING_SCORE_2
2408
- },
2409
- {
2410
- value: 3,
2411
- Icon: {
2412
- Active: aa,
2413
- Inactive: ia
2414
- },
2415
- isActive: (e) => e === 3,
2416
- getTooltip: (e) => e.CSAT5_RATING_SCORE_3
2417
- },
2418
- {
2419
- value: 4,
2420
- Icon: {
2421
- Active: ca,
2422
- Inactive: la
2423
- },
2424
- isActive: (e) => e === 4,
2425
- getTooltip: (e) => e.CSAT5_RATING_SCORE_4
2426
- },
2427
- {
2428
- value: 5,
2429
- Icon: {
2430
- Active: ua,
2431
- Inactive: da
2432
- },
2433
- isActive: (e) => 5 <= e,
2434
- getTooltip: (e) => e.CSAT5_RATING_SCORE_5
2435
- }
2436
- ], ga = () => ma, Vn = ({ label: e, children: t, position: n = "top", disabled: o }) => o ? t : /* @__PURE__ */ r.createElement(ft, null, t, /* @__PURE__ */ r.createElement(fa, { $position: n }, /* @__PURE__ */ r.createElement(ba, { variant: "caption1" }, e), /* @__PURE__ */ r.createElement(ha, { $position: n }))), ha = ({ $position: e }) => /* @__PURE__ */ r.createElement(
2437
- "svg",
2438
- {
2439
- style: { transform: e === "top" ? "rotate(0)" : "rotate(180deg)" },
2440
- xmlns: "http://www.w3.org/2000/svg",
2441
- width: "12",
2442
- height: "6",
2443
- viewBox: "0 0 12 6",
2444
- fill: "none"
2445
- },
2446
- /* @__PURE__ */ r.createElement("path", { d: "M6 6L0 0h12L6 6Z", fill: p.themedColor.textHighEmphasis })
2447
- ), pa = {
2448
- top: I`flex-direction:column;top:0;transform:translate(-50%,-100%);`,
2449
- bottom: I`flex-direction:column-reverse;bottom:0;transform:translate(-50%,100%);`
2450
- }, ft = u.div`position:relative;`, fa = u.div`display:flex;align-items:center;position:absolute;left:50%;z-index:${fe.TOOLTIP};${({ $position: e }) => pa[e]}opacity:0;transition:opacity 0.2s ease-in-out;pointer-events:none;${ft}:hover &,${ft}:focus-within &{opacity:1;}`, ba = u(w)`padding:6px 8px;background:${p.themedColor.textHighEmphasis};color:${p.themedColor.textHighEmphasisInverse};border-radius:4px;font-size:12px;white-space:nowrap;`, Ea = ({ submitted: e, value: t, onChange: n }) => {
2451
- const { stringSet: o } = O(), s = ga(), i = typeof t == "number";
2452
- return /* @__PURE__ */ r.createElement(xa, null, /* @__PURE__ */ r.createElement(w, { variant: "caption2", color: p.themedColor.textMidEmphasis }, o.CSAT_RATING_TITLE), /* @__PURE__ */ r.createElement(Ca, null, s.map((a) => /* @__PURE__ */ r.createElement(Vn, { disabled: e, key: a.value, label: a.getTooltip(o) }, /* @__PURE__ */ r.createElement(
2453
- va,
2454
- {
2455
- disabled: e,
2456
- onClick: () => n(a.value),
2457
- $inactive: i && !a.isActive(t)
2458
- },
2459
- i ? a.isActive(t) ? /* @__PURE__ */ r.createElement(a.Icon.Active, null) : /* @__PURE__ */ r.createElement(a.Icon.Inactive, null) : /* @__PURE__ */ r.createElement(a.Icon.Active, null)
2460
- )))));
2461
- }, xa = u.div`display:flex;flex-direction:column;gap:8px;`, Ca = u.div`display:flex;justify-content:space-between;width:100%;max-width:320px;`, va = u.button`background-color:transparent;border:none;border-radius:4px;padding:0;display:flex;align-items:center;justify-content:center;box-sizing:border-box;&:enabled:hover{cursor:pointer;background-color:${p.color.background200};${P.dark`
2462
- background-color: ${p.color.background500};
2463
- `}
2464
- }
2465
-
2466
- ${({ $inactive: e, theme: t }) => e && t.selectedTheme === "dark" && ya};
2467
- `, ya = I`[fill]{fill:white;fill-opacity:0.12;}[stroke]{stroke:white;stroke-opacity:0.12;}`, _a = ({ submitted: e, value: t = "", onChange: n }) => {
2468
- const { stringSet: o } = O();
2469
- return e && !t ? null : /* @__PURE__ */ r.createElement(
2470
- Sa,
2471
- {
2472
- disabled: e,
2473
- maxLength: 255,
2474
- value: t,
2475
- onChange: (s) => n(s.target.value),
2476
- placeholder: o.CSAT_REASON_PLACEHOLDER
2477
- }
2478
- );
2479
- }, Sa = u.input`box-sizing:border-box;width:100%;border-radius:4px;padding:10px 16px;font-size:14px;font-weight:400;font-style:normal;border:unset;&:focus{outline:none;}color:${p.themedColor.textHighEmphasis};&::placeholder{color:${p.themedColor.textLowEmphasis};}background-color:${p.color.background50};${P.dark`
2480
- background-color: ${p.themedColor.textDisabled};
2481
- `}
2482
-
2483
- &:disabled {
2484
- cursor: not-allowed;
2485
- color: ${p.themedColor.textLowEmphasis};
2486
- background-color: ${p.color.background200};
2487
- ${P.dark`
2488
- color: ${p.color.ondark.textDisabled};
2489
- background-color: ${p.themedColor.textDisabled};
2490
- `}
2491
- }
2492
- `, Ta = ({ submitted: e }) => {
2493
- const { stringSet: t } = O();
2494
- return e ? /* @__PURE__ */ r.createElement(w, { variant: "h2", color: p.themedColor.textHighEmphasis }, t.CSAT_TITLE_SUBMITTED) : /* @__PURE__ */ r.createElement(w, { variant: "h2", color: p.themedColor.textHighEmphasis }, t.CSAT_TITLE_UNSUBMITTED);
2495
- };
2496
- var X = /* @__PURE__ */ ((e) => (e.AI_AGENT_CSAT_5 = "AI_AGENT_CSAT_5", e.AI_AGENT_CSAT_5_WITH_CRE = "AI_AGENT_CSAT_5_WITH_CRE", e.HELPDESK_CSAT_5 = "HELPDESK_CSAT_5", e))(X || {});
2497
- const wa = (e) => Cr((t, n) => ({ ...t, ...n }), e), lt = ({
2498
- type: e,
2499
- renderSubmitButton: t,
2500
- initialCsat: n,
2501
- initialCsatReason: o,
2502
- initialIsResolved: s
2503
- }) => {
2504
- const [i, a] = wa({
2505
- csatType: e,
2506
- csat: n,
2507
- csatReason: o,
2508
- isResolved: s
2509
- }), l = typeof n == "number" ? "submitted" : (e === X.AI_AGENT_CSAT_5 || e === X.HELPDESK_CSAT_5) && typeof i.csat == "number" || e === X.AI_AGENT_CSAT_5_WITH_CRE && typeof i.csat == "number" && typeof i.isResolved == "boolean" ? "submittable" : "unsubmittable", c = { state: l, submitted: l === "submitted" };
2510
- return /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(Aa, null, /* @__PURE__ */ r.createElement(Ta, { ...c }), e === X.AI_AGENT_CSAT_5_WITH_CRE && /* @__PURE__ */ r.createElement(
2511
- Qi,
2512
- {
2513
- ...c,
2514
- defaultValue: s,
2515
- value: i.isResolved,
2516
- onChange: (d) => a({ isResolved: d })
2517
- }
2518
- ), /* @__PURE__ */ r.createElement(Ea, { ...c, value: i.csat, onChange: (d) => a({ csat: d }) }), i.csat && /* @__PURE__ */ r.createElement(
2519
- _a,
2520
- {
2521
- ...c,
2522
- value: i.csatReason,
2523
- onChange: (d) => a({ csatReason: d })
2524
- }
2525
- )), l !== "submitted" && t({ state: l, params: i }));
2526
- }, Aa = u.div`display:flex;flex-direction:column;gap:12px;`, ka = () => {
2527
- const { stringSet: e } = O();
2528
- return /* @__PURE__ */ r.createElement(w, { variant: "body2", color: p.themedColor.textMidEmphasis, style: { textAlign: "center" } }, e.CSAT_SUBMISSION_EXPIRED);
2529
- }, Ia = (e) => {
2530
- if (e.messageType !== "admin.csat")
2531
- throw new Error("Invalid message type");
2532
- const t = Pr(), { stringSet: n } = O(), { extendedMessagePayload: o, csat: s, csatReason: i, csatExpireAt: a, isResolvedWhenDeterminedByUser: l, onSubmitCSAT: c } = e, { visibility: d, type: h } = (o == null ? void 0 : o.csat) ?? {};
2533
- if (!d || !h || !X[h]) return null;
2534
- const m = h === X.AI_AGENT_CSAT_5 || h === X.AI_AGENT_CSAT_5_WITH_CRE || h === X.HELPDESK_CSAT_5 ? lt : () => null, f = (x) => {
2535
- x.csat && !rn(a) ? c({
2536
- csatType: x.csatType,
2537
- csat: x.csat,
2538
- csatReason: x.csatReason,
2539
- isResolved: x.isResolved
2540
- }) : t();
2541
- };
2542
- return /* @__PURE__ */ r.createElement($a, null, !s && rn(a) ? /* @__PURE__ */ r.createElement(ka, null) : /* @__PURE__ */ r.createElement(
2543
- m,
2544
- {
2545
- type: h,
2546
- initialCsat: s,
2547
- initialCsatReason: i,
2548
- initialIsResolved: l,
2549
- renderSubmitButton: ({ state: x, params: E }) => /* @__PURE__ */ r.createElement(Ma, { disabled: x !== "submittable", onClick: () => f(E) }, /* @__PURE__ */ r.createElement(w, { variant: "button" }, n.CSAT_SUBMIT_LABEL))
2550
- }
2551
- ));
2552
- }, $a = u.div`display:flex;flex-direction:column;background-color:${({ theme: e }) => e.colors.csat.background};border-radius:16px;gap:16px;padding:24px;`, Ma = u.button`all:unset;background-color:${({ theme: e }) => e.colors.base.primary};color:${({ theme: e }) => e.colors.base.primaryContrastContent};border-radius:6px;padding:10px 20px;display:flex;align-items:center;justify-content:center;cursor:pointer;&:hover{background-color:${p.color.primary.dark};}&:disabled{color:${p.color.ondark.textLowEmphasis};background-color:${p.themedColor.textDisabled};cursor:not-allowed;}`;
2553
- function rn(e) {
2554
- return !!e && e < Date.now();
2555
- }
2556
- const Lt = _e({
2557
- template: Oa,
2558
- components: {
2559
- AdminMessage: qi,
2560
- CSATMessage: Ia
2561
- }
2562
- });
2563
- function Oa(e) {
2564
- const { components: t } = Lt.useContext(), n = Mt(() => e.messageType === "admin" ? /* @__PURE__ */ r.createElement(t.AdminMessage, { ...e }) : e.messageType === "admin.csat" ? /* @__PURE__ */ r.createElement(t.CSATMessage, { ...e }) : null);
2565
- return /* @__PURE__ */ r.createElement(La, { $marginBottom: Tt(e.groupType) }, n);
2566
- }
2567
- const La = u.div`padding-inline:${te}px;margin-bottom:${({ $marginBottom: e }) => e}px;`, on = {
2568
- file: "attach",
2569
- snippet: "snippet",
2570
- site: "website",
2571
- sb_sprinklr: "sprinklr",
2572
- sb_salesforce: "salesforce",
2573
- sb_confluence: "confluence",
2574
- sb_zendesk: "zendesk",
2575
- sb_desk: "snippet"
2576
- // TODO: request icon
2577
- }, Ra = ({
2578
- actionbook: e,
2579
- functionCalls: t,
2580
- groundedness: n,
2581
- agentMessageTemplates: o,
2582
- onClickActionbook: s,
2583
- onClickFunctionCall: i,
2584
- onClickFunctionCallDetail: a,
2585
- onClickGroundedness: l,
2586
- onClickAgentMessageTemplate: c,
2587
- bottomContent: d,
2588
- renderCustomGroundednessIcon: h = (f) => f.default,
2589
- style: m = {}
2590
- }) => {
2591
- const {
2592
- // Note: This component is used with the dashboard, so cssVars should not be used.
2593
- iconColor: f = "#000000",
2594
- textColor: x = "#000000",
2595
- highlightColor: E = $n.DEFAULT_PRIMARY
2596
- } = m;
2597
- return /* @__PURE__ */ r.createElement(sn, null, e && /* @__PURE__ */ r.createElement(sn, null, /* @__PURE__ */ r.createElement(qe, null, /* @__PURE__ */ r.createElement(ze, null, /* @__PURE__ */ r.createElement(M, { size: 16, type: "actionbook", color: f })), /* @__PURE__ */ r.createElement(
2598
- He,
2599
- {
2600
- $clickable: !!s,
2601
- $highlightColor: E,
2602
- variant: "body2",
2603
- color: x,
2604
- onClick: () => s == null ? void 0 : s(e)
2605
- },
2606
- e.name
2607
- ))), t == null ? void 0 : t.map((b) => /* @__PURE__ */ r.createElement(ct, { key: b.key }, /* @__PURE__ */ r.createElement(ze, null, /* @__PURE__ */ r.createElement(M, { size: 16, type: "function", color: f })), /* @__PURE__ */ r.createElement(qe, null, /* @__PURE__ */ r.createElement(
2608
- He,
2609
- {
2610
- $clickable: !!i,
2611
- $highlightColor: E,
2612
- variant: "body2",
2613
- color: x,
2614
- onClick: () => i == null ? void 0 : i(b)
2615
- },
2616
- b.name
2617
- ), a && /* @__PURE__ */ r.createElement(Na, { role: "button", onClick: () => a == null ? void 0 : a(b) }, /* @__PURE__ */ r.createElement(w, { variant: "body2", color: E }, "View details"), /* @__PURE__ */ r.createElement(M, { type: "chevron-right", size: 16, color: E }))))), n == null ? void 0 : n.map((b) => /* @__PURE__ */ r.createElement(ct, { key: b.id }, /* @__PURE__ */ r.createElement(ze, null, h({
2618
- default: /* @__PURE__ */ r.createElement(M, { size: 16, type: on[b.source_type] ?? on.snippet, color: f }),
2619
- sourceType: b.source_type
2620
- })), /* @__PURE__ */ r.createElement(
2621
- He,
2622
- {
2623
- $clickable: !!l,
2624
- $highlightColor: E,
2625
- variant: "body2",
2626
- color: x,
2627
- onClick: () => l == null ? void 0 : l(b)
2628
- },
2629
- b.preview_title
2630
- ))), o == null ? void 0 : o.map((b) => /* @__PURE__ */ r.createElement(ct, { key: b.key }, /* @__PURE__ */ r.createElement(ze, null, /* @__PURE__ */ r.createElement(M, { size: 16, type: "template", color: f })), /* @__PURE__ */ r.createElement(
2631
- He,
2632
- {
2633
- $clickable: !!c,
2634
- $highlightColor: E,
2635
- variant: "body2",
2636
- color: x,
2637
- onClick: () => c == null ? void 0 : c(b)
2638
- },
2639
- b.name
2640
- ))), d);
2641
- }, Da = u(w)`font-weight:400;`, He = u(Da)`${({ $clickable: e, $highlightColor: t }) => e && I`
2642
- cursor: pointer;
2643
- text-decoration: underline;
2644
- &:hover {
2645
- color: ${t};
2646
- }
2647
- `}
2648
- `, ze = u.div`display:flex;align-items:center;justify-content:center;flex-shrink:0;`, qe = u.div`display:flex;gap:8px;align-items:center;`, Na = u(qe)`cursor:pointer;gap:4px;`, ct = u(qe)`flex-direction:row;align-items:center;`, sn = u.div`display:flex;gap:4px;flex-direction:column;align-items:flex-start;`, Wn = ve(null);
2649
- function Pa({ testerType: e, children: t }) {
2650
- return /* @__PURE__ */ r.createElement(
2651
- Wn.Provider,
2652
- {
2653
- value: { testerType: e, isActionbookTester: e === "actionbook" }
2654
- },
2655
- e && /* @__PURE__ */ r.createElement(Ba, null),
2656
- t
2657
- );
2658
- }
2659
- const Re = () => {
2660
- const e = Q(Wn);
2661
- if (!e) throw new Error("_UNSAFE_INTERNAL_DashboardTesterProvider not found");
2662
- return e;
2663
- }, Ba = () => {
2664
- const { isActionbookTester: e } = Re();
2665
- return /* @__PURE__ */ r.createElement(xe.Template, { template: e ? Fa : void 0 }, /* @__PURE__ */ r.createElement(xe.MessageLogs, { component: Ua }));
2666
- }, Fa = (e) => /* @__PURE__ */ r.createElement(Un, { ...e, testerMode: !0, maxBodyWidth: Ln }), Ua = ({ extendedMessagePayload: e = {} }) => {
2667
- const { handlers: t } = B(), { manual: n, groundedness: o, function_calls: s, agent_message_templates: i, is_thinking: a } = e;
2668
- return a || !n && !(o != null && o.length) && !(s != null && s.length) && !(i != null && i.length) ? /* @__PURE__ */ r.createElement(r.Fragment, null) : /* @__PURE__ */ r.createElement(Ha, null, /* @__PURE__ */ r.createElement(za, { width: 4 }), /* @__PURE__ */ r.createElement(
2669
- Ra,
2670
- {
2671
- actionbook: n,
2672
- functionCalls: s,
2673
- groundedness: o,
2674
- agentMessageTemplates: i,
2675
- onClickFunctionCallDetail: t == null ? void 0 : t.onFunctionCallDetailClick,
2676
- style: {
2677
- iconColor: p.themedColor.textHighEmphasis,
2678
- textColor: p.themedColor.textHighEmphasis,
2679
- barColor: p.themedColor.textDisabled
2680
- },
2681
- bottomContent: /* @__PURE__ */ r.createElement(Va, { variant: "caption2", color: p.themedColor.textLowEmphasis }, "Only visible in the tester")
2682
- }
2683
- ));
2684
- }, Ha = u.div`display:flex;gap:16px;margin:16px ${te}px 0;align-self:stretch;`, za = u.div`width:${({ width: e }) => e}px;background-color:${p.themedColor.textDisabled};border-radius:100px;flex-shrink:0;`, Va = u(w)`margin-top:5px;`;
2685
- function Wa(e) {
2686
- return "sendingStatus" in e ? e.sendingStatus === "succeeded" ? String(e.messageId) : e.reqId : String(e.messageId);
2687
- }
2688
- const Ga = (e, t, n, o = !0) => {
2689
- if (!o || !e.isUserMessage() && !e.isFileMessage())
2690
- return "single";
2691
- const s = () => {
2692
- if (!t || !t.isUserMessage() && !t.isFileMessage()) return !1;
2693
- const c = t.sender.userId === e.sender.userId, d = zt(t.createdAt, e.createdAt);
2694
- return c && d;
2695
- }, i = () => {
2696
- if (!n || !n.isUserMessage() && !n.isFileMessage()) return !1;
2697
- const c = n.sender.userId === e.sender.userId, d = zt(n.createdAt, e.createdAt);
2698
- return c && d;
2699
- }, a = s(), l = i();
2700
- return a && l ? "middle" : a ? "bottom" : l ? "top" : "single";
2701
- };
2702
- function ja(e, t) {
2703
- return e.filter((n) => Se.isWelcomeMessage(n, t));
2704
- }
2705
- function Gn(e, t) {
2706
- return Ka(e) === t;
2707
- }
2708
- function Ka(e) {
2709
- var t;
2710
- if (e)
2711
- return e.isUserMessage() || e.isFileMessage() || e.isMultipleFilesMessage() ? e.sender.userId : ((t = e == null ? void 0 : e.sender) == null ? void 0 : t.userId) ?? void 0;
2712
- }
2713
- function Za(e) {
2714
- return e.isAdminMessage() ? e.message === "The channel's custom_type was updated." : !1;
2715
- }
2716
- const bt = (e) => !!e && "sender" in e, jn = (e) => e.startsWith("image/"), Kn = (e) => e.startsWith("video/"), an = (e) => jn(e) || Kn(e), Ve = {
2717
- isAdmin: (e) => e.isAdminMessage(),
2718
- isCSAT: (e) => {
2719
- var t;
2720
- return e.isAdminMessage() && !!((t = e.extendedMessagePayload) != null && t.csat);
2721
- },
2722
- isIncoming: (e, t) => bt(e) && e.sender.userId !== t,
2723
- isOutgoing: (e, t) => bt(e) && (e.sender.userId === t || e.sendingStatus === dt.PENDING)
2724
- }, Ya = (e) => {
2725
- const { chatSDK: t, handlers: n } = B(), { aiAgentInfo: o } = U(), s = N(/* @__PURE__ */ new Set()), i = (a, l) => {
2726
- var c;
2727
- a.url === e && bt(l) && l.sender.userId === o.userId && !Se.isStreaming(l) && !s.current.has(l.messageId) && ((c = n == null ? void 0 : n.onCustomEvent) == null || c.call(n, { type: "bot-message-received", data: { message: l } }), s.current.add(l.messageId));
2728
- };
2729
- Xe(t, {
2730
- onMessageUpdated: i,
2731
- onMessageReceived: i
2732
- });
2733
- }, qa = ({ publishSynchronous: e = !1 }) => {
2734
- const t = /* @__PURE__ */ new Set();
2735
- return {
2736
- publish: (n) => {
2737
- t.forEach((o) => {
2738
- e ? o(n) : setTimeout(() => o(n), 0);
2739
- });
2740
- },
2741
- subscribe: (n) => (t.add(n), () => t.delete(n))
2742
- };
2743
- };
2744
- function Ja(e, t = []) {
2745
- const n = N(null), o = N(0), s = N(0), [i] = _(() => qa({ publishSynchronous: !0 })), [a, l] = _(!0);
2746
- return le(() => {
2747
- o.current = 0, s.current = 0, l(!0), n.current && (n.current.scrollTop = n.current.scrollHeight);
2748
- }, t), le(() => i.subscribe(({ type: c, data: d }) => {
2749
- const { resolve: h, animated: m } = d ?? {};
2750
- if (!n.current) return h == null ? void 0 : h();
2751
- if (c === "scrollToBottom" && (n.current.scroll ? n.current.scroll({
2752
- top: n.current.scrollHeight,
2753
- behavior: ln(e, m)
2754
- }) : n.current.scrollTop = n.current.scrollHeight, s.current = 0, l(!0), h == null || h()), c === "scroll") {
2755
- const f = d == null ? void 0 : d.top, { scrollTop: x, scrollHeight: E, clientHeight: b } = n.current;
2756
- n.current.scroll ? n.current.scroll({ top: f, behavior: ln(e, m) }) : typeof f == "number" && (n.current.scrollTop = f), s.current = Math.max(0, E - x - b), l(s.current === 0), h == null || h();
2757
- }
2758
- }), [e]), {
2759
- scrollRef: n,
2760
- scrollPubSub: i,
2761
- isScrollBottomReached: a,
2762
- setIsScrollBottomReached: l,
2763
- scrollDistanceFromBottomRef: s,
2764
- scrollPositionRef: o
2765
- };
2766
- }
2767
- function ln(e, t) {
2768
- return typeof t == "boolean" ? t ? "smooth" : "auto" : e;
2769
- }
2770
- function Xa(e) {
2771
- return new Promise((t) => {
2772
- const n = new Image();
2773
- n.onload = function() {
2774
- const o = String(n.width), s = String(n.height);
2775
- URL.revokeObjectURL(n.src), t({ width: o, height: s });
2776
- }, n.src = URL.createObjectURL(e);
2777
- });
2778
- }
2779
- async function Qa(e) {
2780
- if ("file" in e && e.file instanceof File && e.file.type.startsWith("image/")) {
2781
- const { width: t, height: n } = await Xa(e.file);
2782
- return new Wr({
2783
- key: Zn,
2784
- value: [t, n]
2785
- });
2786
- }
2787
- }
2788
- const Zn = "KEY_IMG_ASPECT_RATIO", el = ({ onScrollAfterSendMessage: e }) => {
2789
- const { agentPreviewConfigs: t, handlers: n } = B(), o = N(t == null ? void 0 : t.agentAttributes);
2790
- return o.current = t == null ? void 0 : t.agentAttributes, {
2791
- onBeforeSendMessage: async (s) => {
2792
- const i = await Qa(s), a = {
2793
- ...s,
2794
- metaArrays: i ? [i] : void 0
2795
- }, l = tl(o.current);
2796
- return l ? { ...a, data: JSON.stringify(l) } : a;
2797
- },
2798
- onAfterSendMessage: (s) => {
2799
- var i, a, l;
2800
- e(), (i = n == null ? void 0 : n.onMessageSend) == null || i.call(n, s.message), s.sendingStatus === dt.SUCCEEDED ? (a = n == null ? void 0 : n.onCustomEvent) == null || a.call(n, { type: "message-sent-succeeded", data: { message: s } }) : s.sendingStatus === dt.PENDING && ((l = n == null ? void 0 : n.onCustomEvent) == null || l.call(n, { type: "message-sent-pending", data: { message: s } }));
2801
- }
2802
- };
2803
- }, tl = (e) => {
2804
- if (!e) return null;
2805
- const t = {};
2806
- return e.ai && Object.keys(e.ai).length > 0 && (t.ai_attrs = e.ai), e.safeguard && Object.keys(e.safeguard).length > 0 && (t.safeguard_attrs = e.safeguard), typeof e.use_prompt_cache == "boolean" && (t.use_prompt_cache = e.use_prompt_cache), Object.keys(t).length > 0 ? t : null;
2807
- }, {
2808
- Provider: nl,
2809
- Context: su,
2810
- useContext: Z
2811
- } = G("Conversation"), rl = ({
2812
- closedChannelUrl: e,
2813
- onClearClosedChannelUrl: t,
2814
- onNavigateToConversationList: n,
2815
- children: o
2816
- }) => {
2817
- const { aiAgentInfo: s, activeChannel: i, refreshActiveChannel: a } = U(), { testerType: l } = Re(), c = Ja("smooth"), { onBeforeSendMessage: d, onAfterSendMessage: h } = el({
2818
- onScrollAfterSendMessage: () => {
2819
- c.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !1 } });
2820
- }
2821
- }), m = e || (i == null ? void 0 : i.url);
2822
- Ya(m);
2823
- const f = (E) => {
2824
- const b = E[E.length - 1];
2825
- b && Se.shouldScrollToBottom(b, s.userId, !!l) && setTimeout(() => c.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !0 } }), 100);
2826
- }, x = R(async () => {
2827
- await a(), e && (t == null || t());
2828
- }, [a, e, t]);
2829
- return /* @__PURE__ */ r.createElement(
2830
- ao,
2831
- {
2832
- channelUrl: m,
2833
- onBeforeSendMessage: d,
2834
- onAfterSendMessage: h,
2835
- onMessagesUpdated: f,
2836
- onMessagesReceived: f,
2837
- onChannelDeleted: x,
2838
- onConversationClosedViaDispatcher: x
2839
- },
2840
- (E) => /* @__PURE__ */ r.createElement(
2841
- nl,
2842
- {
2843
- value: { ...E, scrollSource: c, goToActiveConversation: x, onNavigateToConversationList: n }
2844
- },
2845
- o
2846
- )
2847
- );
2848
- }, Rt = ve({
2849
- onDrop: Ie,
2850
- subscribe: () => Ie
2851
- }), Et = ({ children: e }) => {
2852
- const t = N(/* @__PURE__ */ new Set());
2853
- return /* @__PURE__ */ r.createElement(
2854
- Rt.Provider,
2855
- {
2856
- value: {
2857
- onDrop: (n) => {
2858
- var o;
2859
- if (n.preventDefault(), (o = n.dataTransfer) != null && o.files) {
2860
- const s = Array.from(n.dataTransfer.files);
2861
- s.length > 0 && t.current.forEach((i) => i(s));
2862
- }
2863
- },
2864
- subscribe: (n) => (t.current.add(n), () => t.current.delete(n))
2865
- }
2866
- },
2867
- e
2868
- );
2869
- }, ol = ({ onDropFiles: e }) => {
2870
- const { subscribe: t } = Q(Rt);
2871
- L(() => t(e), [e]);
2872
- };
2873
- Et.Consumer = ({ children: e }) => {
2874
- const { onDrop: t } = Q(Rt);
2875
- return e({ onDrop: t, onDragOver: (s) => s.preventDefault() });
2876
- };
2877
- const iu = ({ iconSize: e = 64, icon: t, className: n, label: o, children: s }) => /* @__PURE__ */ r.createElement(il, { className: n }, /* @__PURE__ */ r.createElement(M, { type: t, size: e, color: p.themedColor.textLowEmphasis }), /* @__PURE__ */ r.createElement(w, { variant: "body1", color: p.themedColor.textMidEmphasis }, o), s), sl = u.div`position:relative;display:flex;justify-content:center;align-items:center;width:100%;height:100%;`, il = u.div`display:flex;flex-direction:column;min-height:104px;align-items:center;gap:20px;text-align:center;`, al = {
2878
- loading: T(() => import("./DhUBPQ6o.js")),
2879
- error: T(() => import("./CVCUjr3Q.js")),
2880
- noChannels: T(() => import("./kE3eGJ-O.js")),
2881
- noMessages: T(() => import("./jtdZ66dz.js"))
2882
- }, Ce = ({ className: e, type: t = "loading", ...n }) => {
2883
- const o = al[t];
2884
- return /* @__PURE__ */ r.createElement(sl, { className: e }, /* @__PURE__ */ r.createElement(ke, { fallback: null }, /* @__PURE__ */ r.createElement(o, { ...n })));
2885
- }, Yn = ({ rootElementId: e, visible: t, onClose: n, children: o }) => {
2886
- if (!t) return null;
2887
- const { rootElement: s } = B(), i = pe(s), a = pe(s, !0);
2888
- return jr(
2889
- /* @__PURE__ */ r.createElement(ll, { onClick: n }, /* @__PURE__ */ r.createElement(cl, { onClick: (l) => l.stopPropagation() }, o)),
2890
- i.getElementById(e) ?? i.getElementById(ee.MODAL_ROOT) ?? a.body
2891
- );
2892
- }, ll = u.div`position:fixed;top:0;left:0;width:100%;height:100%;background:${p.color.overlay.dark};display:flex;justify-content:center;align-items:center;z-index:${fe.MODAL};`, cl = u.div`border-radius:4px;overflow:hidden;box-shadow:0 16px 24px 2px rgba(13,13,13,0.12),0 6px 30px 5px rgba(13,13,13,0.08),0 6px 10px -5px rgba(13,13,13,0.04);z-index:${fe.MODAL};`, dl = u.div`flex-shrink:0;width:${({ $size: e }) => j(e)};height:${({ $size: e }) => j(e)};background-color:${({ theme: e }) => e.colors.base.primary};box-sizing:border-box;padding:6px;border-radius:50%;display:flex;justify-content:center;align-items:center;}`, ul = u(kt)`path{fill:${({ theme: e }) => e.colors.base.primaryContrastContent};}`;
2893
- function qn({ size: e }) {
2894
- const { aiAgentInfo: t } = U();
2895
- return t.profileUrl ? /* @__PURE__ */ r.createElement(It, { size: e, src: t.profileUrl }) : /* @__PURE__ */ r.createElement(dl, { $size: e }, /* @__PURE__ */ r.createElement(ul, null));
2896
- }
2897
- const ml = u.div`width:100%;height:100%;position:fixed;top:0;left:0;outline:none;`, gl = u.div`height:64px;min-height:64px;box-sizing:border-box;display:flex;justify-content:space-between;border-bottom:1px solid ${p.themedColor.textDisabled};background-color:${p.themedColor.bg_50_600};@media screen and (max-width:768px){position:relative;}`, hl = u.div`box-sizing:border-box;display:flex;flex-direction:row;align-items:center;height:64px;padding:16px 20px;width:calc(100% - 128px);`, pl = u.div`margin-inline-end:8px;`, fl = u.div`max-width:500px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;display:inline-block;@media screen and (max-width:768px){position:absolute;inset-inline-start:64px;top:10px;display:block;max-width:calc(100vw - 240px);}`, bl = u.div`display:inline-block;margin-inline-start:8px;padding-top:5px;@media screen and (max-width:768px){position:absolute;inset-inline-start:56px;top:24px;}`, El = u.div`display:flex;width:160px;justify-content:flex-end;`, xl = u.div`inset-inline-end:0;display:flex;flex-direction:row;`, Jn = u.div`width:64px;padding:21px;box-sizing:border-box;cursor:${(e) => e.disabled ? "not-allowed" : "pointer"};`, Cl = u(Jn)`border-inline-start:1px solid ${p.themedColor.textDisabled};`, vl = u.div`width:100%;height:100%;display:flex;align-items:center;justify-content:center;`, yl = u.video`max-width:100%;max-height:100%;user-select:none;-webkit-user-drag:none;`, _l = u.img`max-width:calc(90% - 60px);max-height:calc(90% - 60px);user-select:none;-webkit-user-drag:none;`, Sl = u.div`max-width:100%;max-height:100%;display:flex;justify-content:center;align-items:center;`, Tl = ({ file: e, sender: t = {}, onClose: n, onDownloadClick: o }) => {
2898
- const { type: s, url: i, name: a = "" } = e, { profileUrl: l, nickname: c, userId: d } = t, { aiAgentInfo: h } = U();
2899
- return /* @__PURE__ */ r.createElement(
2900
- Al,
2901
- {
2902
- profileUrl: l ?? "",
2903
- nickname: c ?? "",
2904
- type: s,
2905
- url: i,
2906
- name: a,
2907
- onClose: n,
2908
- isBotMessage: d === h.userId,
2909
- onDownloadClick: o
2910
- }
2911
- );
2912
- }, wl = ({ profileUrl: e, isBotMessage: t }) => !e && t ? /* @__PURE__ */ r.createElement(qn, { size: 32 }) : /* @__PURE__ */ r.createElement(It, { size: 32, src: e }), Al = ({
2913
- profileUrl: e,
2914
- isBotMessage: t,
2915
- nickname: n,
2916
- name: o,
2917
- type: s,
2918
- url: i,
2919
- onClose: a,
2920
- onDownloadClick: l
2921
- }) => {
2922
- const { stringSet: c } = O();
2923
- return /* @__PURE__ */ r.createElement(Yn, { onClose: a, visible: !0, rootElementId: ee.MODAL_ROOT }, /* @__PURE__ */ r.createElement(ml, null, /* @__PURE__ */ r.createElement(gl, null, /* @__PURE__ */ r.createElement(hl, null, /* @__PURE__ */ r.createElement(pl, null, /* @__PURE__ */ r.createElement(wl, { profileUrl: e, isBotMessage: t })), /* @__PURE__ */ r.createElement(fl, null, /* @__PURE__ */ r.createElement(w, { variant: "h2", color: p.themedColor.textHighEmphasis }, o)), /* @__PURE__ */ r.createElement(bl, null, /* @__PURE__ */ r.createElement(w, { variant: "body1", color: p.color.ondark.textMidEmphasis }, n))), /* @__PURE__ */ r.createElement(El, null, an(s) && /* @__PURE__ */ r.createElement(xl, null, /* @__PURE__ */ r.createElement(Jn, { as: "a", href: i, target: "_blank", rel: St, onClick: l }, /* @__PURE__ */ r.createElement(M, { type: "download", color: p.themedColor.textHighEmphasis, size: 24 }))), /* @__PURE__ */ r.createElement(Cl, { onClick: a }, /* @__PURE__ */ r.createElement(M, { type: "close", color: p.themedColor.textHighEmphasis, size: 24 })))), /* @__PURE__ */ r.createElement(vl, { onClick: (d) => d.currentTarget === d.target && a() }, Kn(s) && /* @__PURE__ */ r.createElement(yl, { controls: !0 }, /* @__PURE__ */ r.createElement("source", { src: i, type: s })), jn(s) && /* @__PURE__ */ r.createElement(_l, { src: i, alt: o }), !an(s) && /* @__PURE__ */ r.createElement(Sl, null, /* @__PURE__ */ r.createElement(w, { variant: "h1", color: p.themedColor.textHighEmphasis }, c.FILE_VIEWER__UNSUPPORT)))));
2924
- }, Xn = ({
2925
- className: e,
2926
- locale: t,
2927
- date: n = Date.now(),
2928
- formatString: o = "MMMM dd, yyyy",
2929
- style: s
2930
- }) => /* @__PURE__ */ r.createElement(kl, { id: `${J}-date-separator`, style: s, className: e }, /* @__PURE__ */ r.createElement(w, { variant: "caption4", color: p.themedColor.textMidEmphasis }, Cn(n, o, { locale: t }))), kl = u.div`display:flex;justify-content:center;align-items:center;`, Il = ye(function(t, n) {
2931
- const {
2932
- messages: o,
2933
- renderMessage: s,
2934
- messageTopArea: i,
2935
- messageBottomArea: a,
2936
- overlayArea: l,
2937
- onLoadPrev: c,
2938
- onLoadNext: d,
2939
- loadThreshold: h = 0.05,
2940
- onScrollPosition: m = Ie,
2941
- depsForResetScrollPositionToBottom: f,
2942
- scrollPositionRef: x,
2943
- scrollDistanceFromBottomRef: E,
2944
- stackDirection: b = "top"
2945
- } = t, g = n && "current" in n ? n : { current: null }, C = N(!1), v = N(void 0), S = N(0), k = N(0), F = N(0), $ = x ?? k, V = E ?? F;
2946
- le(() => {
2947
- g.current && (g.current.scrollTop = g.current.scrollHeight);
2948
- }, f), le(() => {
2949
- g.current && (v.current === "top" && (g.current.scrollTop = g.current.scrollHeight - $.current), v.current === "bottom" && (g.current.scrollTop = S.current), v.current = void 0);
2950
- }, [g.current, o.length]);
2951
- const re = async () => {
2952
- if (!g.current) return;
2953
- const y = g.current;
2954
- if (m($l(y)), $.current = y.scrollHeight - y.scrollTop, V.current = $.current - y.clientHeight, S.current = y.scrollTop, C.current) return;
2955
- const H = y.clientHeight * Math.min(Math.max(0, h), 1);
2956
- y.scrollTop <= H ? (C.current = !0, v.current = "top", await c(), C.current = !1) : y.scrollHeight - y.scrollTop - y.clientHeight <= H ? (C.current = !0, v.current = "bottom", await d(), C.current = !1) : v.current = void 0;
2957
- };
2958
- return /* @__PURE__ */ r.createElement(Ml, { id: "infinite-list-container" }, /* @__PURE__ */ r.createElement(Ol, { id: "infinite-list-inner", ref: g, onScroll: re }, b === "bottom" && /* @__PURE__ */ r.createElement("div", { style: { flexGrow: 1 } }), i, o.map((y, H) => s({ message: y, index: H })), a), /* @__PURE__ */ r.createElement(Ll, { id: "infinite-list-overlay-container" }, /* @__PURE__ */ r.createElement(Rl, { id: "infinite-list-overlay" }, l)));
2959
- }), cn = 50;
2960
- function $l(e) {
2961
- return e.scrollTop <= cn ? "top" : e.scrollHeight - (e.scrollTop + e.clientHeight) <= cn ? "bottom" : "middle";
2962
- }
2963
- const Ml = u.div`display:flex;position:relative;flex:1;overflow:hidden;`, Ol = u.div`display:flex;flex:1;flex-direction:column;overflow-y:auto;scrollbar-color:${p.themedColor.textLowEmphasis}transparent;&::-webkit-scrollbar-thumb:hover{background-color:transparent;}`, Ll = u.div`position:absolute;top:0;bottom:0;left:0;right:0;pointer-events:none;`, Rl = u.div`pointer-events:auto;`, Dl = ({ className: e, onClick: t }) => /* @__PURE__ */ r.createElement(Nl, { className: e, onClick: t, tabIndex: 0 }, /* @__PURE__ */ r.createElement(M, { size: 24, type: "chevron-down", color: p.color.primary.main })), Nl = u.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:40px;height:40px;border-radius:24px;box-shadow:0 2px 8px 0 rgba(0,0,0,0.08),0 4px 6px 0 rgba(0,0,0,0.12);${P.light`
2964
- background-color: ${p.color.background50};
2965
- &:hover {
2966
- background-color: ${p.color.background100};
2967
- }
2968
- &:active {
2969
- background-color: ${p.color.background200};
2970
- }
2971
- `}
2972
- ${P.dark`
2973
- background-color: ${p.color.background400};
2974
- &:hover {
2975
- background-color: ${p.color.background500};
2976
- }
2977
- &:active {
2978
- background-color: ${p.color.background700};
2979
- }
2980
- `}
2981
-
2982
- &:focus {
2983
- outline: none;
2984
- }
2985
- `, Qn = () => {
2986
- const { chatSDK: e } = B(), { channelSource: t } = Z(), [n, o] = _([]);
2987
- return Xe(e, {
2988
- onTypingStatusUpdated(s) {
2989
- var i;
2990
- if (s.url === ((i = t.channel) == null ? void 0 : i.url)) {
2991
- const a = s.getTypingUsers();
2992
- o(a);
2993
- }
2994
- }
2995
- }), n;
2996
- }, Pl = () => {
2997
- const { agentPreviewConfigs: e = {}, aiAgentId: t } = B(), { aiAgentInfo: n } = U(), { stringSet: o, dateLocale: s } = O(), { messageSource: i } = Z(), { Template: a } = xe.useContext(), l = e.welcomeMessages ?? [], c = i.messages, d = ja(c, t), h = c[d.length + 1], m = d[0] ?? h;
2998
- return {
2999
- /**
3000
- * Returns a list of messages filtered according to business requirements.
3001
- */
3002
- filteredMessages: c.filter((f) => Za(f) ? !1 : l.length > 0 ? !Se.isWelcomeMessage(f, t) : !0),
3003
- /**
3004
- * Determines whether to display the DateSeparator in the data list by comparing it with the welcome messages from Bot Studio.
3005
- */
3006
- shouldShowOriginalDate: (f) => f > 0 || l.length === 0 ? !0 : h && !Or(h.createdAt, (m == null ? void 0 : m.createdAt) ?? 0),
3007
- /**
3008
- * Renders the list of welcome messages from Bot Studio.
3009
- */
3010
- renderAgentPreviewWelcomeMessages: () => l.length === 0 ? null : /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(
3011
- Xn,
3012
- {
3013
- style: { margin: "16px 0" },
3014
- date: m == null ? void 0 : m.createdAt,
3015
- locale: s,
3016
- formatString: o.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR
3017
- }
3018
- ), l.map((f, x) => {
3019
- const E = x === l.length - 1, b = d.length !== c.length, g = l.length === 1 ? "single" : x === 0 ? "top" : E || b ? "bottom" : "middle";
3020
- return /* @__PURE__ */ r.createElement(
3021
- a,
3022
- {
3023
- messageType: "user",
3024
- message: f.message,
3025
- sender: n,
3026
- groupType: g,
3027
- createdAt: (m == null ? void 0 : m.createdAt) ?? Date.now(),
3028
- extendedMessagePayload: { suggested_replies: f.suggestedReplies },
3029
- suggestedRepliesDirection: e.suggestedRepliesDirection,
3030
- suggestedRepliesVisible: E && !b,
3031
- isBotMessage: !0,
3032
- onClickSuggestedReply: async ({ reply: C }) => {
3033
- i.sendUserMessage({ message: C });
3034
- }
3035
- }
3036
- );
3037
- }))
3038
- };
3039
- }, Bl = (e) => u(e).withConfig({ shouldForwardProp: Kr });
3040
- function Fl(e) {
3041
- var o;
3042
- const t = "remove_powered_by", n = (o = e == null ? void 0 : e.appInfo) == null ? void 0 : o.applicationAttributes;
3043
- return Array.isArray(n) && n.includes(t);
3044
- }
3045
- const Ul = ({ style: e }) => {
3046
- const { stringSet: t } = O(), { chatSDK: n } = B(), { isActionbookTester: o } = Re();
3047
- return Fl(n) || o ? null : /* @__PURE__ */ r.createElement(Hl, { variant: "caption2", style: e }, t.POWERED_BY + " ", /* @__PURE__ */ r.createElement(
3048
- zl,
3049
- {
3050
- variant: "caption2",
3051
- as: "a",
3052
- href: "https://sendbird.com?utm_medium=product&utm_source=aiagent&utm_campaign=fy26-glbl-ai-agent-poweredby",
3053
- "aria-label": "Learn more about Sendbird",
3054
- rel: St,
3055
- target: "_blank"
3056
- },
3057
- "Sendbird"
3058
- ));
3059
- }, Hl = u(w)`color:${p.themedColor.textLowEmphasis};text-align:center;`, zl = Bl(w)`
3060
- color: ${p.themedColor.textLowEmphasis};
3061
- cursor: pointer;
3062
- text-decoration: none;
3063
- `, Vl = () => {
3064
- var c;
3065
- const { stringSet: e } = O(), { activeChannel: t } = U(), { channelSource: n, goToActiveConversation: o, scrollSource: s } = Z(), i = Pn(n.channel), l = t && ((c = n.channel) == null ? void 0 : c.url) === (t == null ? void 0 : t.url) && i;
3066
- return le(() => {
3067
- l && s.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !0 } });
3068
- }, [l]), l ? /* @__PURE__ */ r.createElement(Wl, null, /* @__PURE__ */ r.createElement(
3069
- Gl,
3070
- {
3071
- variant: "button",
3072
- role: "button",
3073
- color: p.themedColor.textHighEmphasis,
3074
- onClick: () => o()
3075
- },
3076
- e.START_NEW_CONVERSATION
3077
- )) : null;
3078
- }, Wl = u.div`display:flex;justify-content:center;margin:16px 0;`, Gl = u(w)`border-radius:6px;box-sizing:border-box;padding:10px 20px;border:1px solid ${p.themedColor.textDisabled};cursor:pointer;user-select:none;`, jl = !0, Kl = () => {
3079
- const { Template: e } = Ot.useContext(), { Template: t } = xe.useContext(), { Template: n } = Lt.useContext(), [o, s] = _(null), { userSession: i, aiAgentInfo: a } = U(), { cache: l, agentPreviewConfigs: c, chatSDK: d, state: h } = B(), { stringSet: m, dateLocale: f } = O(), { conversation: x, channelSource: E, messageSource: b, scrollSource: g } = Z(), { isActionbookTester: C } = Re(), { filteredMessages: v, shouldShowOriginalDate: S, renderAgentPreviewWelcomeMessages: k } = Pl(), F = Qn(), $ = Mt(() => {
3080
- const y = F[0];
3081
- if (!y) return null;
3082
- const H = y.userId === a.userId;
3083
- return { user: H ? a : y, isBot: H };
3084
- });
3085
- L(() => {
3086
- $ && g.scrollPubSub.publish({ type: "scrollToBottom", data: { animated: !0 } });
3087
- }, [!!$, g.scrollPubSub.publish]);
3088
- const V = (y, H = !1) => {
3089
- var oe;
3090
- return H ? a : ((oe = E.channel) == null ? void 0 : oe.members.find((Y) => Y.userId === y.sender.userId)) ?? y.sender;
3091
- }, re = () => {
3092
- if (!b.initialized)
3093
- return /* @__PURE__ */ r.createElement(Ce, { type: "loading" });
3094
- if (b.messages.length === 0) {
3095
- const y = k();
3096
- return y ? /* @__PURE__ */ r.createElement("div", { style: { width: "100%" } }, y) : /* @__PURE__ */ r.createElement(Ce, { type: "noMessages", label: m.PLACE_HOLDER__NO_MESSAGES });
3097
- }
3098
- return /* @__PURE__ */ r.createElement(
3099
- Il,
3100
- {
3101
- ref: g.scrollRef,
3102
- scrollPositionRef: g.scrollPositionRef,
3103
- scrollDistanceFromBottomRef: g.scrollDistanceFromBottomRef,
3104
- onScrollPosition: (y) => g.setIsScrollBottomReached(y === "bottom"),
3105
- stackDirection: c == null ? void 0 : c.messageStackDirection,
3106
- messages: v,
3107
- onLoadPrev: b.loadPrevious,
3108
- onLoadNext: b.loadNext,
3109
- depsForResetScrollPositionToBottom: [b.initialized, b.messages.length !== 0],
3110
- messageTopArea: /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(Ul, { style: { marginTop: 16 } }), k()),
3111
- messageBottomArea: /* @__PURE__ */ r.createElement(r.Fragment, null, $ && /* @__PURE__ */ r.createElement(
3112
- t,
3113
- {
3114
- isTyping: !0,
3115
- isBotMessage: $.isBot,
3116
- sender: $.user,
3117
- messageType: "user",
3118
- groupType: "single",
3119
- message: ""
3120
- }
3121
- ), /* @__PURE__ */ r.createElement(Vl, null)),
3122
- overlayArea: /* @__PURE__ */ r.createElement(r.Fragment, null, !g.isScrollBottomReached && /* @__PURE__ */ r.createElement(Yl, { onClick: () => g.scrollPubSub.publish({ type: "scrollToBottom" }) })),
3123
- renderMessage: ({ message: y, index: H }) => {
3124
- const oe = Wa(y), Y = v[H - 1], nt = v[H + 1], rt = v[v.length - 1], A = y === rt, D = Ga(y, Y, nt, jl), K = !Gr((Y == null ? void 0 : Y.createdAt) ?? 0, y.createdAt) && S(H) && !C, q = (Pe) => {
3125
- (y.isFileMessage() || y.isUserMessage()) && s({ file: Pe, sender: V(y, y.sender.userId === a.userId) });
3126
- }, be = () => {
3127
- y.isFileMessage() && $t(y.url);
3128
- }, fr = K ? /* @__PURE__ */ r.createElement(
3129
- Xn,
3130
- {
3131
- style: { margin: "16px 0" },
3132
- date: y.createdAt,
3133
- locale: f,
3134
- formatString: m.DATE_FORMAT__MESSAGE_LIST__DATE_SEPARATOR
3135
- }
3136
- ) : null, Ne = {
3137
- maxBodyWidth: h.expanded ? Ln : void 0,
3138
- extendedMessagePayload: y.extendedMessagePayload,
3139
- createdAt: y.createdAt,
3140
- groupType: D,
3141
- onClickMedia: q,
3142
- onClickFile: be
3143
- }, br = (() => {
3144
- var Pe, Ft;
3145
- if (Ve.isAdmin(y))
3146
- return Ve.isCSAT(y) ? x ? /* @__PURE__ */ r.createElement(
3147
- n,
3148
- {
3149
- ...Ne,
3150
- ...x,
3151
- isResolvedWhenDeterminedByUser: ql(x),
3152
- messageType: "admin.csat",
3153
- onSubmitCSAT: ({ csat: se, csatType: me, csatReason: z, isResolved: ie }) => {
3154
- var ge;
3155
- se && ((ge = E.channel) == null || ge.submitCSAT({ csat: se, csatType: me, csatReason: z, isResolved: ie }));
3156
- }
3157
- }
3158
- ) : null : /* @__PURE__ */ r.createElement(n, { ...Ne, messageType: "admin", message: y.message });
3159
- if (Ve.isOutgoing(y, i.userId)) {
3160
- const se = {
3161
- ...Ne,
3162
- message: y.message,
3163
- sender: V(y),
3164
- sendingStatus: y.sendingStatus
3165
- };
3166
- if (y.isUserMessage())
3167
- return /* @__PURE__ */ r.createElement(e, { messageType: "user", ...se });
3168
- if (y.isFileMessage()) {
3169
- const [me, z] = ((Pe = y.metaArrays.find((ie) => ie.key === Zn)) == null ? void 0 : Pe.value) ?? [];
3170
- return /* @__PURE__ */ r.createElement(
3171
- e,
3172
- {
3173
- messageType: "file",
3174
- file: y,
3175
- metadata: {
3176
- aspectRatio: me && z ? `${me}/${z}` : "1/1",
3177
- localFile: (Ft = y.messageParams) == null ? void 0 : Ft.file
3178
- },
3179
- ...se
3180
- }
3181
- );
3182
- }
3183
- }
3184
- if (Ve.isIncoming(y, i.userId)) {
3185
- const se = y.sender.userId === a.userId, me = {
3186
- ...Ne,
3187
- sender: V(y, se),
3188
- message: y.message,
3189
- suggestedRepliesVisible: A,
3190
- suggestedRepliesDirection: c == null ? void 0 : c.suggestedRepliesDirection,
3191
- isBotMessage: se,
3192
- isStreaming: Se.isStreaming(y),
3193
- onClickSuggestedReply: async ({ reply: z }) => {
3194
- b.sendUserMessage({ message: z });
3195
- },
3196
- onRequestMessageTemplate: async (z) => {
3197
- const { template: ie } = await d.aiAgent.getMessageTemplate(z);
3198
- return l.template.set(z, ie), ie;
3199
- },
3200
- onGetCachedMessageTemplate: (z) => l.template.get(z),
3201
- onHandleTemplateInternalAction: (z) => {
3202
- if (z.type === "internal" && z.internalData) {
3203
- const { method: ie, payload: ge } = z.internalData;
3204
- ie === "message.send" && (ge != null && ge.message) && b.sendUserMessage({ message: ge.message });
3205
- }
3206
- }
3207
- };
3208
- if (y.isUserMessage())
3209
- return /* @__PURE__ */ r.createElement(t, { messageType: "user", ...me });
3210
- if (y.isFileMessage())
3211
- return /* @__PURE__ */ r.createElement(t, { messageType: "file", file: y, ...me });
3212
- }
3213
- })();
3214
- return /* @__PURE__ */ r.createElement("div", { key: oe, id: `${J}-message-item` }, fr, br);
3215
- }
3216
- }
3217
- );
3218
- };
3219
- return /* @__PURE__ */ r.createElement(Zl, { id: `${J}-message-list` }, re(), o && /* @__PURE__ */ r.createElement(Tl, { onClose: () => s(null), sender: o.sender, file: o.file }));
3220
- }, Zl = u.div`overflow-y:hidden;display:flex;flex:1;position:relative;`, Yl = u(Dl)`position:absolute;bottom:20px;inset-inline-end:20px;`;
3221
- function ql(e) {
3222
- var t;
3223
- if (((t = e == null ? void 0 : e.resolution) == null ? void 0 : t.determinedBy) === "user")
3224
- return e.resolution.isResolved;
3225
- }
3226
- const Jl = () => {
3227
- const { stringSet: e } = O(), { connectionError: t } = U(), { channelSource: n } = Z(), o = t || n.error;
3228
- if (o) {
3229
- const s = t ? void 0 : { label: e.RETRY, onClick: () => n.refetch() };
3230
- return /* @__PURE__ */ r.createElement(Ce, { type: "error", label: o.message, action: s });
3231
- }
3232
- return n.channel ? /* @__PURE__ */ r.createElement(Kl, null) : /* @__PURE__ */ r.createElement(Ce, { type: "loading" });
3233
- }, er = () => {
3234
- const { stringSet: e } = O(), { activeChannel: t } = U(), [n] = _(() => (t == null ? void 0 : t.status) === W.OPEN);
3235
- return n ? e.RETURN_TO_CONVERSATION : e.START_NEW_CONVERSATION;
3236
- }, Xl = () => {
3237
- const { stringSet: e } = O(), { goToActiveConversation: t } = Z(), n = er();
3238
- return /* @__PURE__ */ r.createElement(Ql, null, /* @__PURE__ */ r.createElement(w, { variant: "body1", color: p.themedColor.textMidEmphasis }, e.CONVERSATION_CLOSED_FOOTER_LABEL), /* @__PURE__ */ r.createElement(ec, { onClick: t }, /* @__PURE__ */ r.createElement(w, { variant: "button", color: p.themedColor.textHighEmphasis }, n)));
3239
- }, Ql = u.div`display:flex;flex-direction:column;align-items:center;justify-content:center;padding:32px 0;gap:14px;${P.light`
3240
- background-color: ${p.color.background100};
3241
- `}
3242
- ${P.dark`
3243
- background-color: ${p.color.background500};
3244
- `}
3245
- `, ec = u.button`all:unset;padding:10px 20px;border-radius:6px;border:1px solid ${p.themedColor.textDisabled};cursor:pointer;${P.light`
3246
- background-color: ${p.color.background50};
3247
- `}
3248
- ${P.dark`
3249
- background-color: ${p.color.background700};
3250
- `}
3251
- `, tr = ve(void 0), tc = ({ children: e }) => {
3252
- const { stringSet: t } = O(), { attachmentMode: n } = U(), { channelSource: o } = Z(), [s, i] = _([]), [a, l] = _({
3253
- visible: !1,
3254
- title: "",
3255
- buttonText: t.BUTTON__OK
3256
- }), c = Fn(o.channel), d = ae(() => {
3257
- switch (n) {
3258
- case je.OFF:
3259
- return !1;
3260
- case je.ALWAYS:
3261
- return !0;
3262
- case je.HANDED_OFF_ONLY:
3263
- return c;
3264
- default:
3265
- return c;
3266
- }
3267
- }, [n, c]), h = (x) => {
3268
- if (!d) return;
3269
- const E = x.filter((b) => On.includes(b.type));
3270
- if (E.length !== 0) {
3271
- if (E.some((b) => b.size > Ss)) {
3272
- l((b) => ({
3273
- ...b,
3274
- visible: !0,
3275
- title: t.FILE_UPLOAD_NOTIFICATION__SIZE_LIMIT.replace("%d", "25")
3276
- }));
3277
- return;
3278
- }
3279
- if (E.length > 1 || E.length > 0 && s.length > 0) {
3280
- l((b) => ({
3281
- ...b,
3282
- visible: !0,
3283
- title: t.FILE_UPLOAD_NOTIFICATION__COUNT_LIMIT
3284
- }));
3285
- return;
3286
- }
3287
- i((b) => [
3288
- ...b,
3289
- ...E.map((g) => ({
3290
- file: g,
3291
- preview: { url: URL.createObjectURL(g), type: g.type, name: g.name }
3292
- }))
3293
- ]);
3294
- }
3295
- }, m = (x) => {
3296
- i((E) => {
3297
- var g;
3298
- const b = (g = E[x]) == null ? void 0 : g.preview;
3299
- return b && URL.revokeObjectURL(b.url), E.filter((C, v) => v !== x);
3300
- });
3301
- }, f = () => {
3302
- i((x) => (x.forEach((E) => URL.revokeObjectURL(E.preview.url)), []));
3303
- };
3304
- return /* @__PURE__ */ r.createElement(
3305
- tr.Provider,
3306
- {
3307
- value: {
3308
- files: s,
3309
- addFiles: h,
3310
- removeFile: m,
3311
- clearFiles: f,
3312
- isFileUploadEnabled: d
3313
- }
3314
- },
3315
- e,
3316
- /* @__PURE__ */ r.createElement(nc, { ...a, onClose: () => l((x) => ({ ...x, visible: !1, title: "" })) })
3317
- );
3318
- }, Dt = () => {
3319
- const e = Q(tr);
3320
- if (!e)
3321
- throw new Error("useFileUpload must be used within FileUploadProvider");
3322
- return e;
3323
- }, nc = ({
3324
- title: e,
3325
- buttonText: t,
3326
- visible: n,
3327
- onClose: o
3328
- }) => /* @__PURE__ */ r.createElement(Yn, { rootElementId: ee.WINDOW, visible: n, onClose: o }, /* @__PURE__ */ r.createElement(rc, null, /* @__PURE__ */ r.createElement(sc, null, /* @__PURE__ */ r.createElement(w, { variant: "h1", color: p.themedColor.textHighEmphasis }, e)), /* @__PURE__ */ r.createElement(oc, null, /* @__PURE__ */ r.createElement(ic, { onClick: o }, /* @__PURE__ */ r.createElement(w, { variant: "button", color: p.themedColor.textHighEmphasisInverse }, t))))), rc = u.div`width:100%;height:auto;padding-block:18px 24px;padding-inline:24px;margin:0 auto;border-radius:4px;box-sizing:border-box;background-color:${({ theme: e }) => e.colors.base.modalContentBackground};`, oc = u.div`display:flex;flex-direction:row;justify-content:flex-end;`, sc = u.div`margin-bottom:16px;`, ic = u.button`display:flex;justify-content:center;align-items:center;border-radius:4px;cursor:pointer;background-color:${p.themedColor.error};border:1px solid ${p.themedColor.error};padding:10px 16px;&:hover{background-color:${p.color.error.dark};border-color:${p.color.error.dark};}&:active{background-color:${p.color.error.extraDark};}`;
3329
- function ac({ blurred: e, elementRef: t, document: n = window.document }) {
3330
- const o = N(!1);
3331
- e && t.current && n.activeElement === t.current && (o.current = !0), le(() => {
3332
- var s;
3333
- !e && o.current && ((s = t.current) == null || s.focus(), o.current = !1);
3334
- }, [e]);
3335
- }
3336
- const lc = (e, t) => {
3337
- L(() => {
3338
- t ? e == null || e.startTyping() : e == null || e.endTyping();
3339
- }, [e, t]);
3340
- }, cc = u.div`&::-webkit-scrollbar{display:none;}overflow-x:auto;display:flex;flex-direction:row;gap:10px;padding:8px 16px;background-color:transparent;`, dc = u.div`display:flex;flex-shrink:0;position:relative;margin-block-start:8px;border-radius:12px;height:64px;img{border-radius:12px;object-fit:cover;width:64px;-webkit-user-drag:none;}`, uc = u.div`display:flex;align-items:center;justify-content:center;position:absolute;inset-inline-end:-8px;inset-block-start:-8px;cursor:pointer;border-radius:50%;${P.light`
3341
- background-color: ${p.color.background50};
3342
- `}
3343
- ${P.dark`
3344
- background-color: ${p.color.background500};
3345
- `}
3346
- path {
3347
- fill: ${p.themedColor.textMidEmphasis};
3348
- }
3349
-
3350
- &:hover {
3351
- path {
3352
- fill: ${p.themedColor.textHighEmphasis};
3353
- }
3354
- }
3355
-
3356
- circle {
3357
- stroke: ${p.themedColor.bg_50_600};
3358
- }
3359
- `, mc = () => {
3360
- const e = Oe(), [t, n] = _(), { files: o, removeFile: s, isFileUploadEnabled: i } = Dt();
3361
- return !i || o.length === 0 ? null : /* @__PURE__ */ r.createElement(cc, null, o.map(({ preview: { type: a, name: l, url: c } }, d) => /* @__PURE__ */ r.createElement(dc, { key: c, onMouseOver: () => n(d), onMouseLeave: () => n(void 0) }, (e || t === d) && /* @__PURE__ */ r.createElement(uc, { title: "Remove file", onClick: () => s(d) }, /* @__PURE__ */ r.createElement(M, { type: "close-filled", color: p.themedColor.textMidEmphasis })), a.startsWith("image/") ? /* @__PURE__ */ r.createElement("img", { alt: "file-image", src: c }) : /* @__PURE__ */ r.createElement(At, { name: l, type: wt(l, a) }))));
3362
- }, gc = ({ channel: e, messages: t }) => {
3363
- const { stringSet: n } = O(), { aiAgentInfo: o } = U(), s = hc(), i = pc({
3364
- lastMessage: t[t.length - 1],
3365
- aiAgentUserId: o.userId
3366
- });
3367
- return !e || !s || Pn(e) ? [!0, n.MESSAGE_INPUT__PLACE_HOLDER__DISABLED] : i ? [!0, n.MESSAGE_INPUT__PLACE_HOLDER__WAIT_AI_AGENT_RESPONSE] : [!1, n.MESSAGE_INPUT__PLACE_HOLDER];
3368
- }, hc = () => {
3369
- const e = bn(), { chatSDK: t } = B(), [n, o] = _(!0);
3370
- return L(() => {
3371
- const s = new Je({
3372
- onDisconnected: () => o(!1),
3373
- onConnected: () => o(!0),
3374
- onReconnectSucceeded: () => o(!0)
3375
- });
3376
- return t.addConnectionHandler(e, s), () => {
3377
- t.removeConnectionHandler(e);
3378
- };
3379
- }, [t]), n;
3380
- }, pc = ({
3381
- lastMessage: e,
3382
- aiAgentUserId: t
3383
- }) => {
3384
- const [n, o] = _(!1), s = Qn();
3385
- return L(() => {
3386
- if (!e) return;
3387
- const i = s.some((l) => l.userId === t), a = Gn(e, t) && Se.isStreaming(e);
3388
- o(!!(a || i));
3389
- }, [s, e, t]), n;
3390
- }, nr = {
3391
- textArea: I`min-height:40px;height:40px;font-size:16px;line-height:24px;`,
3392
- attachIcon: I`margin-bottom:4px;`
3393
- }, rr = u.button`all:unset;cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;`, fc = u(rr)`flex-shrink:0;margin-inline-end:12px;margin-bottom:2px;&:disabled{cursor:not-allowed;}&:not(:disabled){&:hover{path{fill:${p.themedColor.textHighEmphasis};}}&:active{border-radius:4px;background-color:${p.themedColor.bg_200_400};}}${_t && nr.attachIcon};`, bc = u.input`display:none;`, dn = u.div`width:100%;position:relative;background-color:${p.themedColor.bg_100_500};border-radius:20px;`, un = u.div`display:flex;flex-direction:row;align-items:flex-end;position:relative;`, mn = u.textarea`all:unset;display:block;flex:1;min-width:0;padding-top:8px;padding-bottom:8px;padding-inline-start:16px;padding-inline-end:12px;box-sizing:border-box;font-size:14px;line-height:20px;color:${p.themedColor.textHighEmphasis};resize:none;width:100%;height:${Mn}px;overflow-wrap:break-word;white-space:pre-wrap;overflow-x:hidden;${_t && nr.textArea};&::placeholder{color:${p.themedColor.textLowEmphasis};}&:disabled{cursor:not-allowed;&::placeholder{color:${p.themedColor.textDisabled};}}`, gn = u.div`padding:12px 16px;position:relative;display:flex;align-items:center;`, hn = ({ disabled: e }) => {
3394
- const t = N(null), { addFiles: n, clearFiles: o, files: s, isFileUploadEnabled: i } = Dt();
3395
- return !i || s.length > 0 ? null : /* @__PURE__ */ r.createElement(
3396
- fc,
3397
- {
3398
- disabled: e,
3399
- onClick: () => {
3400
- var a;
3401
- o(), (a = t.current) == null || a.click();
3402
- }
3403
- },
3404
- /* @__PURE__ */ r.createElement(
3405
- M,
3406
- {
3407
- type: "attach",
3408
- color: e ? p.themedColor.textDisabled : p.themedColor.textMidEmphasis,
3409
- size: 16
3410
- }
3411
- ),
3412
- /* @__PURE__ */ r.createElement(
3413
- bc,
3414
- {
3415
- type: "file",
3416
- ref: t,
3417
- onChange: (a) => {
3418
- const l = a.currentTarget.files;
3419
- l && n(Array.from(l)), a.target.value = "";
3420
- },
3421
- accept: On.join(",")
3422
- }
3423
- )
3424
- );
3425
- }, Ec = () => {
3426
- const e = N(null), [t, n] = _(""), { rootElement: o } = B(), { channelSource: s, messageSource: i } = Z(), [a, l] = gc({
3427
- channel: s.channel,
3428
- messages: i.messages
3429
- }), { files: c, addFiles: d, clearFiles: h } = Dt();
3430
- ol({ onDropFiles: d }), ac({ blurred: a, elementRef: e, document: pe(o) }), lc(s.channel, t);
3431
- const m = t.trim().length > 0, f = c.length > 0, x = !a && (m || f), E = () => {
3432
- e.current && (e.current.value = "", e.current.style.height = ""), h(), n("");
3433
- }, b = async () => {
3434
- const S = t.trim(), k = { message: S };
3435
- if (!(!S && !c.length)) {
3436
- if (c.length > 0) {
3437
- const F = c[0].file, $ = { ...k, file: F };
3438
- i.sendFileMessage($), E();
3439
- return;
3440
- }
3441
- i.sendUserMessage(k), E();
3442
- }
3443
- }, g = (S) => {
3444
- const k = Array.from(S.clipboardData.files);
3445
- k.length > 0 && (S.preventDefault(), d(k));
3446
- }, C = (S) => {
3447
- S.key !== "Enter" || S.nativeEvent.isComposing || S.shiftKey || (S.preventDefault(), b());
3448
- }, v = (S) => {
3449
- if (e.current) {
3450
- e.current.style.height = "";
3451
- const k = Math.min(_s, e.current.scrollHeight);
3452
- Mn < k && (e.current.style.height = `${k}px`);
3453
- }
3454
- n(S.target.value);
3455
- };
3456
- return a ? /* @__PURE__ */ r.createElement(gn, null, /* @__PURE__ */ r.createElement(dn, null, /* @__PURE__ */ r.createElement(un, null, /* @__PURE__ */ r.createElement(mn, { disabled: !0, placeholder: l }), /* @__PURE__ */ r.createElement(hn, { disabled: !0 })))) : /* @__PURE__ */ r.createElement(gn, null, /* @__PURE__ */ r.createElement(dn, null, /* @__PURE__ */ r.createElement(mc, null), /* @__PURE__ */ r.createElement(un, null, /* @__PURE__ */ r.createElement(
3457
- mn,
3458
- {
3459
- ref: e,
3460
- role: "textbox",
3461
- "aria-label": "Text Input",
3462
- placeholder: l,
3463
- maxLength: 5e3,
3464
- onKeyDown: C,
3465
- onChange: v,
3466
- onPaste: g
3467
- }
3468
- ), /* @__PURE__ */ r.createElement(hn, null))), x && /* @__PURE__ */ r.createElement(rr, { onClick: () => b() }, /* @__PURE__ */ r.createElement(M, { type: "send", color: p.color.primary.main, size: 20 })));
3469
- }, xc = u.div`padding:8px 16px;text-align:center;word-break:break-word;white-space:pre-wrap;line-height:1.43;letter-spacing:-0.2px;font-size:14px;font-weight:400;color:${p.themedColor.textLowEmphasis};&& a{font-weight:700;text-decoration:none;${P.light`
3470
- color: ${p.color.information.light};
3471
- `};
3472
- ${P.dark`
3473
- color: ${p.color.information.main};
3474
- `};
3475
- }
3476
- `, Cc = T(() => import("./D5uRw0Em.js").then((e) => ({ default: e.MarkdownText }))), vc = () => {
3477
- const { aiAgentInfo: e } = U(), { messageSource: t } = Z(), { userSession: n } = U();
3478
- return !e.specialNoticeEnabled || !e.specialNotice || !(t.initialized && !t.messages.some((s) => Gn(s, n.userId))) ? null : /* @__PURE__ */ r.createElement(xc, null, /* @__PURE__ */ r.createElement(Cc, null, e.specialNotice));
3479
- }, yc = () => /* @__PURE__ */ r.createElement(_c, null, /* @__PURE__ */ r.createElement(vc, null), /* @__PURE__ */ r.createElement(tc, null, /* @__PURE__ */ r.createElement(Ec, null))), _c = u.div`z-index:0;border:none;width:100%;`, Sc = () => {
3480
- var i, a, l;
3481
- const { activeChannel: e } = U(), { channelSource: t } = Z(), n = ((a = (i = t.channel) == null ? void 0 : i.conversation) == null ? void 0 : a.status) === W.CLOSED;
3482
- return !(((l = t.channel) == null ? void 0 : l.url) === (e == null ? void 0 : e.url)) && n ? /* @__PURE__ */ r.createElement(Xl, null) : /* @__PURE__ */ r.createElement(yc, null);
3483
- }, Tc = () => {
3484
- var v;
3485
- const { state: e, logger: t, enableCloseConversationButton: n, enableExpandButton: o, dispatcher: s } = B(), { stringSet: i } = O(), { aiAgentInfo: a, activeChannel: l } = U(), { channelSource: c, onNavigateToConversationList: d } = Z(), h = c.channel, f = Oe() ? 24 : 16, x = () => {
3486
- e.setOpened(!1);
3487
- }, E = async () => {
3488
- try {
3489
- const S = await (h == null ? void 0 : h.markConversationAsHandoff());
3490
- t.info("conversation.handleAgentHandoff: success", S);
3491
- } catch (S) {
3492
- t.error("conversation.handleAgentHandoff: error", S);
3493
- }
3494
- }, b = async () => {
3495
- h && await s.send(oo.CloseConversation({ channelUrl: h.url }));
3496
- }, g = l && (h == null ? void 0 : h.url) === l.url, C = a.showHandoffButton && !!((v = h == null ? void 0 : h.conversation) != null && v.handoff) && g;
3497
- return /* @__PURE__ */ r.createElement($c, null, /* @__PURE__ */ r.createElement(Mc, null, d && /* @__PURE__ */ r.createElement(De, { onClick: () => d() }, /* @__PURE__ */ r.createElement(M, { type: "menu", size: 24, color: p.themedColor.textHighEmphasis })), g && /* @__PURE__ */ r.createElement(qn, { size: 34 }), /* @__PURE__ */ r.createElement(Lc, { variant: "h2", color: p.themedColor.textHighEmphasis }, a.nickname || (h == null ? void 0 : h.name))), /* @__PURE__ */ r.createElement(Oc, null, C && /* @__PURE__ */ r.createElement(
3498
- Ic,
3499
- {
3500
- tooltipLabel: i.HEADER_BUTTON__AGENT_HANDOFF,
3501
- disabled: !si(h),
3502
- size: f,
3503
- onClick: E
3504
- }
3505
- ), n && /* @__PURE__ */ r.createElement(
3506
- kc,
3507
- {
3508
- disabled: !Bn(h),
3509
- size: f,
3510
- onClick: b
3511
- }
3512
- ), o && /* @__PURE__ */ r.createElement(wc, { size: f }), /* @__PURE__ */ r.createElement(Ac, { size: f, onClick: x })));
3513
- }, wc = ({ size: e, disabled: t }) => {
3514
- const { state: n } = B();
3515
- return /* @__PURE__ */ r.createElement(De, { "aria-label": "expand", onClick: () => n.setExpanded(!n.expanded), disabled: t }, /* @__PURE__ */ r.createElement(M, { type: n.expanded ? "collapse" : "expand", size: e, color: p.themedColor.textHighEmphasis }));
3516
- }, Ac = ({ size: e, disabled: t, onClick: n }) => /* @__PURE__ */ r.createElement(De, { "aria-label": "close messenger", onClick: n, disabled: t }, /* @__PURE__ */ r.createElement(M, { type: "close", size: e, color: p.themedColor.textHighEmphasis })), kc = ({ size: e, disabled: t, onClick: n }) => /* @__PURE__ */ r.createElement(De, { "aria-label": "close conversation", onClick: n, disabled: t }, /* @__PURE__ */ r.createElement(
3517
- M,
3518
- {
3519
- type: "refresh",
3520
- size: e,
3521
- color: t ? p.themedColor.textDisabled : p.themedColor.textHighEmphasis
3522
- }
3523
- )), Ic = ({ size: e, onClick: t, disabled: n, tooltipLabel: o }) => /* @__PURE__ */ r.createElement(Vn, { label: o, position: "bottom", disabled: n }, /* @__PURE__ */ r.createElement(De, { "aria-label": "agent", onClick: t, disabled: n }, /* @__PURE__ */ r.createElement(
3524
- M,
3525
- {
3526
- type: "agent",
3527
- size: e,
3528
- color: n ? p.themedColor.textDisabled : p.themedColor.textHighEmphasis
3529
- }
3530
- ))), $c = u.div`height:56px;box-sizing:border-box;display:flex;align-items:center;padding:11px 12px;border-bottom:1px solid ${p.themedColor.textDisabled};background-color:${({ theme: e }) => e.colors.base.headerBackground};`, Mc = u.div`display:flex;flex:1;flex-direction:row;align-items:center;gap:6px;overflow:hidden;`, Oc = u.div`display:flex;gap:10px;align-items:center;justify-content:center;`, Lc = u(w)`text-overflow:ellipsis;overflow:hidden;white-space:nowrap;padding:2px 0;`, De = u.button`all:unset;padding:4px;cursor:pointer;display:flex;align-items:center;justify-content:center;&:disabled{cursor:not-allowed;}`, Rc = () => {
3531
- const { isActionbookTester: e } = Re();
3532
- return e ? null : /* @__PURE__ */ r.createElement(Tc, null);
3533
- }, pn = ({
3534
- children: e,
3535
- onNavigateToConversationList: t,
3536
- closedChannelUrl: n,
3537
- onClearClosedChannelUrl: o
3538
- }) => {
3539
- const { Template: s } = Nt.useContext();
3540
- return /* @__PURE__ */ r.createElement(
3541
- rl,
3542
- {
3543
- onNavigateToConversationList: t,
3544
- closedChannelUrl: n,
3545
- onClearClosedChannelUrl: o
3546
- },
3547
- /* @__PURE__ */ r.createElement(Et, null, /* @__PURE__ */ r.createElement(Et.Consumer, null, (i) => /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(Nc, { ...i }, /* @__PURE__ */ r.createElement(s, null)), e)))
3548
- );
3549
- }, Nt = _e({
3550
- template: Dc,
3551
- components: {
3552
- Header: Rc,
3553
- Body: Jl,
3554
- Footer: Sc
3555
- }
3556
- });
3557
- function Dc() {
3558
- const { components: e } = Nt.useContext();
3559
- return /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(e.Header, null), /* @__PURE__ */ r.createElement(e.Body, null), /* @__PURE__ */ r.createElement(e.Footer, null));
3560
- }
3561
- const Nc = u.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({ theme: e }) => e.colors.base.background};`, {
3562
- Provider: Pc,
3563
- Context: au,
3564
- useContext: or
3565
- } = G("ConversationList");
3566
- function Bc({
3567
- conversationListLimit: e,
3568
- conversationListFilter: t,
3569
- onOpenConversationView: n = Ie,
3570
- children: o
3571
- }) {
3572
- return /* @__PURE__ */ r.createElement(
3573
- ho,
3574
- {
3575
- conversationListLimit: e,
3576
- conversationListFilter: t
3577
- },
3578
- (s) => /* @__PURE__ */ r.createElement(Pc, { value: { ...s, onOpenConversationView: n } }, o)
3579
- );
3580
- }
3581
- const sr = _e({
3582
- template: Fc,
3583
- // Note: 리스트 변경되면 디자인 변경 가능성이 있어서 일단 컴포넌트는 비워둠
3584
- components: {}
3585
- });
3586
- function Fc({
3587
- title: e = "",
3588
- lastMessageTimestamp: t = Date.now(),
3589
- onClick: n
3590
- }) {
3591
- const { stringSet: o, format: s } = O();
3592
- return /* @__PURE__ */ r.createElement(Uc, { role: "button", onClick: () => n == null ? void 0 : n() }, /* @__PURE__ */ r.createElement(zc, null, /* @__PURE__ */ r.createElement(Vc, null, /* @__PURE__ */ r.createElement(w, { variant: "subtitle1", color: p.themedColor.textHighEmphasis }, s(t, o.DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE)), /* @__PURE__ */ r.createElement(w, { variant: "caption2", color: p.themedColor.textLowEmphasis }, s(t, o.DATE_FORMAT__CONVERSATION_LIST__LIST_ITEM_TITLE_CAPTION))), /* @__PURE__ */ r.createElement(w, { variant: "body3", color: p.themedColor.textMidEmphasis }, e || o.CONVERSATION_LIST__TOPICS_FALLBACK)), /* @__PURE__ */ r.createElement(M, { type: "chevron-right", size: 16, color: p.themedColor.textHighEmphasis }), /* @__PURE__ */ r.createElement(Hc, null));
3593
- }
3594
- const Uc = u.div`display:flex;flex-direction:row;align-items:center;position:relative;width:100%;padding:14px 16px;box-sizing:border-box;gap:4px;cursor:pointer;`, Hc = u.div`position:absolute;bottom:0;height:1px;width:calc(100% - 32px);background-color:${p.themedColor.textDisabled};`, zc = u.div`gap:4px;display:flex;flex-direction:column;flex:1;`, Vc = u.div`display:flex;justify-content:flex-start;align-items:center;gap:6px;`, Wc = ({ items: e, renderItem: t, onEndReached: n }) => {
3595
- const o = (s) => {
3596
- const i = s.target;
3597
- i.scrollHeight - i.scrollTop === i.clientHeight && (n == null || n());
3598
- };
3599
- return /* @__PURE__ */ r.createElement(Gc, { onScroll: (s) => o(s) }, e.map((s, i) => t(s, i)));
3600
- }, Gc = u.div`width:100%;height:100%;display:flex;flex-direction:column;flex:1;overflow:auto;`, jc = () => {
3601
- const { stringSet: e } = O(), { listSource: t, onOpenConversationView: n } = or(), { Template: o } = sr.useContext();
3602
- return t.initialized ? t.channels.length === 0 ? /* @__PURE__ */ r.createElement(Ce, { type: "noChannels", label: e.CONVERSATION_LIST__NO_CONVERSATIONS }) : /* @__PURE__ */ r.createElement(
3603
- Wc,
3604
- {
3605
- items: t.channels,
3606
- renderItem: (s) => {
3607
- var i, a, l;
3608
- return /* @__PURE__ */ r.createElement(
3609
- o,
3610
- {
3611
- key: s.url,
3612
- channelUrl: s.url,
3613
- title: (a = (i = s.conversation) == null ? void 0 : i.topics) == null ? void 0 : a.join(", "),
3614
- lastMessageTimestamp: (l = s.lastMessage) == null ? void 0 : l.createdAt,
3615
- onClick: () => n(s.url, W.CLOSED),
3616
- channel: s
3617
- }
3618
- );
3619
- },
3620
- onEndReached: () => {
3621
- t.loadMore();
3622
- }
3623
- }
3624
- ) : /* @__PURE__ */ r.createElement(Ce, { type: "loading" });
3625
- }, Kc = () => {
3626
- const { refreshActiveChannel: e } = U(), { onOpenConversationView: t } = or(), n = er();
3627
- return /* @__PURE__ */ r.createElement(
3628
- Zc,
3629
- {
3630
- role: "button",
3631
- onClick: async () => {
3632
- const o = await e();
3633
- t(o, W.OPEN);
3634
- }
3635
- },
3636
- /* @__PURE__ */ r.createElement(Yc, { variant: "h1" }, n)
3637
- );
3638
- }, Zc = u.div`background-color:${({ theme: e }) => e.colors.base.primary};display:flex;align-items:center;justify-content:center;padding:16px;cursor:pointer;`, Yc = u(w)`color:${({ theme: e }) => e.colors.base.primaryContrastContent};overflow:hidden;text-overflow:ellipsis;white-space:nowrap;`, qc = () => {
3639
- const { stringSet: e } = O();
3640
- return /* @__PURE__ */ r.createElement(Jc, null, /* @__PURE__ */ r.createElement(Xc, { variant: "h2", color: p.themedColor.textHighEmphasis }, e.CONVERSATION_LIST__HEADER_TITLE), /* @__PURE__ */ r.createElement(Qc, null));
3641
- }, Jc = u.div`display:flex;flex-direction:column;align-items:flex-start;justify-content:center;width:100%;flex-shrink:0;height:56px;position:relative;background-color:${({ theme: e }) => e.colors.base.headerBackground};`, Xc = u(w)`padding:0 12px;width:100%;box-sizing:border-box;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;`, Qc = u.div`position:absolute;bottom:0;width:100%;height:1px;background-color:${p.themedColor.textDisabled};`, ed = ({
3642
- conversationListLimit: e,
3643
- conversationListFilter: t,
3644
- children: n,
3645
- onOpenConversationView: o
3646
- }) => {
3647
- const { Template: s } = Pt.useContext();
3648
- return /* @__PURE__ */ r.createElement(
3649
- Bc,
3650
- {
3651
- conversationListLimit: e,
3652
- conversationListFilter: t,
3653
- onOpenConversationView: o
3654
- },
3655
- /* @__PURE__ */ r.createElement(nd, null, /* @__PURE__ */ r.createElement(s, null)),
3656
- n
3657
- );
3658
- }, Pt = _e({
3659
- template: td,
3660
- components: {
3661
- Header: qc,
3662
- Body: jc,
3663
- Footer: Kc
3664
- }
3665
- });
3666
- function td() {
3667
- const { components: e } = Pt.useContext();
3668
- return /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(e.Header, null), /* @__PURE__ */ r.createElement(e.Body, null), /* @__PURE__ */ r.createElement(e.Footer, null));
3669
- }
3670
- const nd = u.div`height:100%;width:100%;display:flex;flex-direction:column;flex:1;background-color:${({ theme: e }) => e.colors.base.background};`, rd = I`:where(#${ee.ENTRY}) :not(code *){font-family:'Roboto',sans-serif;box-sizing:border-box;}`, od = [rd, is, as], sd = (e, ...t) => $r(e, ...od, ...t), id = sd``, ad = Zr(
3671
- Nt,
3672
- xe,
3673
- Ot,
3674
- Lt,
3675
- Pt,
3676
- sr
3677
- );
3678
- function ld({
3679
- appearance: e,
3680
- rootElement: t,
3681
- logger: n,
3682
- language: o,
3683
- stringSet: s,
3684
- children: i,
3685
- messageTemplate: a,
3686
- theme: l
3687
- }) {
3688
- return gs(qo, t), /* @__PURE__ */ r.createElement(Mr, { target: t }, /* @__PURE__ */ r.createElement(ds, { rootElement: t, logger: n, appearance: e, theme: l }, /* @__PURE__ */ r.createElement(Vo, { internalVariables: a == null ? void 0 : a.__internalVariables }, /* @__PURE__ */ r.createElement(ss, { stringSet: s, logger: n, language: o }, /* @__PURE__ */ r.createElement(ad, null, i, /* @__PURE__ */ r.createElement(id, null))))));
3689
- }
3690
- const We = {}, Ge = {
3691
- getItem: (e) => {
3692
- try {
3693
- return localStorage.getItem(e);
3694
- } catch {
3695
- return We[e] ?? null;
3696
- }
3697
- },
3698
- setItem: (e, t) => {
3699
- try {
3700
- localStorage.setItem(e, t);
3701
- } catch {
3702
- We[e] = t;
3703
- }
3704
- },
3705
- deleteItem: (e) => {
3706
- try {
3707
- localStorage.removeItem(e);
3708
- } catch {
3709
- delete We[e];
3710
- }
3711
- },
3712
- getKeys: (e) => {
3713
- try {
3714
- const t = [];
3715
- for (let n = 0; n < localStorage.length; n++) {
3716
- const o = localStorage.key(n);
3717
- o && o.startsWith(e) && t.push(o);
3718
- }
3719
- return t;
3720
- } catch {
3721
- return Object.keys(We).filter((t) => t.startsWith(e));
3722
- }
3723
- }
3724
- }, ir = ye(function({
3725
- rootElement: t = document.body,
3726
- logLevel: n = En.WARN,
3727
- language: o = navigator.language,
3728
- userSessionInfo: s,
3729
- children: i,
3730
- ...a
3731
- }, l) {
3732
- var c, d;
3733
- return we.level !== n && (we.level = n), ms("https://fonts.googleapis.com/css2?family=Roboto&display=swap", t), /* @__PURE__ */ r.createElement("div", { id: ee.ENTRY, style: { width: "fit-content", height: "fit-content", ...a.entryStyle } }, /* @__PURE__ */ r.createElement(
3734
- ld,
3735
- {
3736
- logger: we,
3737
- rootElement: t,
3738
- appearance: (c = a.agentPreviewConfigs) == null ? void 0 : c.appearance,
3739
- stringSet: a.stringSet,
3740
- language: o,
3741
- messageTemplate: a.messageTemplate,
3742
- theme: a.theme
3743
- },
3744
- /* @__PURE__ */ r.createElement(
3745
- fs,
3746
- {
3747
- rootElement: t,
3748
- keyValueStorage: {
3749
- get: Ge.getItem,
3750
- set: Ge.setItem,
3751
- delete: Ge.deleteItem,
3752
- getKeys: Ge.getKeys
3753
- },
3754
- language: o,
3755
- logger: we,
3756
- dispatcher: cd,
3757
- chatParams: { customApiHost: a.customApiHost, customWebSocketHost: a.customWebSocketHost },
3758
- ...a
3759
- },
3760
- /* @__PURE__ */ r.createElement(
3761
- Es,
3762
- {
3763
- ref: l,
3764
- userSessionInfo: s,
3765
- forceCreateChannel: (d = a.agentPreviewConfigs) == null ? void 0 : d.forceCreateChannel
3766
- },
3767
- /* @__PURE__ */ r.createElement(Pa, { ...a._UNSAFE_INTERNAL_dashboardTester }, i, /* @__PURE__ */ r.createElement("div", { id: ee.MODAL_ROOT }))
3768
- )
3769
- )
3770
- ));
3771
- }), we = new Tn(En.WARN), cd = new _n(we), ar = ({ children: e, isOpened: t }) => {
3772
- const { dir: n, rootElement: o } = B(), s = pe(o, !0);
3773
- return L(() => {
3774
- const i = "sb-agent-block-scroll";
3775
- return t ? s.body.classList.add(i) : s.body.classList.remove(i), () => {
3776
- s.body.classList.remove(i);
3777
- };
3778
- }, [s, t]), /* @__PURE__ */ r.createElement(dd, { dir: n, $visible: t }, e);
3779
- }, dd = u.div`width:100%;height:100%;position:fixed;top:0;left:0;z-index:${fe.WINDOW};visibility:${({ $visible: e }) => e ? "visible" : "hidden"};`, ud = 48, md = 2 / 3;
3780
- function gd({
3781
- className: e,
3782
- isOpened: t,
3783
- onClick: n,
3784
- type: o,
3785
- imageUrl: s,
3786
- dir: i,
3787
- animated: a = !0,
3788
- backgroundColor: l,
3789
- size: c = ud
3790
- }) {
3791
- const d = pt(l), h = Math.round(c * md);
3792
- return /* @__PURE__ */ r.createElement(
3793
- fd,
3794
- {
3795
- dir: i,
3796
- id: ee.LAUNCHER,
3797
- className: e,
3798
- "aria-label": "Sendbird AIAgent Launcher",
3799
- onClick: n,
3800
- $animated: a,
3801
- $backgroundColor: l,
3802
- $size: c
3803
- },
3804
- /* @__PURE__ */ r.createElement(bd, { $isOpened: t, $animated: a, $fillColor: d, $iconSize: h }, /* @__PURE__ */ r.createElement(fn.Open, { url: s, isDefaultIcon: o === "default_icon" })),
3805
- /* @__PURE__ */ r.createElement(Ed, { $isOpened: t, $animated: a, $fillColor: d, $iconSize: h }, /* @__PURE__ */ r.createElement(fn.Close, { size: h }))
3806
- );
3807
- }
3808
- const hd = I`&:hover{transition:transform 250ms cubic-bezier(0.33,0,0,1);transform:scale(1.1);}&:active{transform:scale(0.8);}`, pd = I`img{width:100%;height:100%;object-fit:cover;user-select:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-user-drag:none;&[data-default-icon='true']{width:${({ $iconSize: e }) => e}px;height:${({ $iconSize: e }) => e}px;filter:${({ $fillColor: e }) => e === $n.WHITE ? "grayscale(100%) brightness(2000%)" : "grayscale(100%) invert(100%) saturate(0%) brightness(0%) contrast(1000%)"};}}`, lr = I`svg{width:${({ $iconSize: e }) => e}px;height:${({ $iconSize: e }) => e}px;${({ $fillColor: e }) => I`
3809
- path {
3810
- fill: ${e};
3811
- }
3812
- [class*='fill'] {
3813
- fill: ${e};
3814
- }
3815
- `}
3816
- }
3817
- `, fd = u.button`position:relative;padding:0;width:${({ $size: e }) => e}px;height:${({ $size: e }) => e}px;background:${({ $backgroundColor: e }) => e};border-radius:50%;transition:all 0.3s cubic-bezier(0.31,-0.105,0.43,1.4);border:none;display:flex;justify-content:center;align-items:center;box-shadow:0 16px 24px 2px rgba(33,33,33,0.12),0 6px 30px 5px rgba(33,33,33,0.08),0 6px 10px -5px rgba(33,33,33,0.04);${({ $animated: e }) => e && hd}`, cr = u.span`position:absolute;width:100%;height:100%;border-radius:50%;overflow:hidden;transition:transform 0.16s linear,opacity 0.08s linear,scale 0.16s linear;user-select:none;display:flex;justify-content:center;align-items:center;`, bd = u(cr)`opacity:${({ $isOpened: e }) => e ? 0 : 1};transform:${({ $animated: e, $isOpened: t }) => e && (t ? "rotate(-90deg) scale(0)" : "rotate(0deg)")};${pd}${lr}`, Ed = u(cr)`scale:${({ $isOpened: e }) => e ? 1 : 0};transform:${({ $animated: e, $isOpened: t }) => e && (t ? "rotate(0deg)" : "rotate(-90deg)")};${lr}`, fn = {
3818
- Open: (e) => e.url ? /* @__PURE__ */ r.createElement("img", { src: e.url, alt: "launcher-img", "data-default-icon": e.isDefaultIcon }) : /* @__PURE__ */ r.createElement(kt, null),
3819
- Close: ({ size: e }) => /* @__PURE__ */ r.createElement(M, { size: e, type: "chevron-down" })
3820
- };
3821
- function dr({ className: e, size: t }) {
3822
- const { colors: n } = xt(), { dir: o, state: s } = B(), { launcherInfo: i } = U();
3823
- return Cd(), /* @__PURE__ */ r.createElement(
3824
- gd,
3825
- {
3826
- dir: o,
3827
- className: e,
3828
- isOpened: s.opened,
3829
- onClick: () => s.setOpened(!s.opened),
3830
- type: i.type,
3831
- imageUrl: i.imageUrl,
3832
- backgroundColor: n.base.primary,
3833
- size: t
3834
- }
3835
- );
3836
- }
3837
- const xd = 1e3 * 60;
3838
- function Cd() {
3839
- const { chatSDK: e, state: t, logger: n, enableAutoDisconnectInLauncher: o } = B(), s = N(null);
3840
- L(() => {
3841
- if (!o) return;
3842
- function i() {
3843
- s.current && (clearTimeout(s.current), s.current = null);
3844
- }
3845
- function a() {
3846
- e.connectionState === kr.CLOSED && (e.reconnect(), n.debug("useSDKInactivityTimeout: reconnected")), i(), n.debug("useSDKInactivityTimeout: clear disconnect schedule");
3847
- }
3848
- function l() {
3849
- i(), s.current = setTimeout(async () => {
3850
- await e.disconnectWebSocket(), n.debug("useSDKInactivityTimeout: disconnected");
3851
- }, xd);
3852
- }
3853
- t.opened ? a() : (l(), n.debug("useSDKInactivityTimeout: schedule disconnect"));
3854
- }, [o, e, t.opened]);
3855
- }
3856
- const ur = ve(null);
3857
- function vd() {
3858
- const e = Q(ur);
3859
- if (!e)
3860
- throw new Error("useNavigator() must be used within <Navigator />");
3861
- return e;
3862
- }
3863
- function mr({ children: e }) {
3864
- const t = vd();
3865
- return typeof e == "function" ? e(t) : /* @__PURE__ */ r.createElement(r.Fragment, null, e);
3866
- }
3867
- const yd = xn`0%{transform:translateY(40px);opacity:0;}100%{transform:translateY(0px);opacity:1;}`, _d = xn`0%{transform:translateY(0px);opacity:1;}100%{transform:translateY(40px);opacity:0;}`, Sd = I`animation-name:${yd};animation-duration:0.3s;animation-fill-mode:forwards;`, Td = I``, wd = I`animation-name:${_d};animation-duration:0.3s;animation-fill-mode:forwards;`, Ad = I`visibility:hidden;`, kd = u.div`position:absolute;top:0;left:0;width:100%;height:100%;${({ $transitionState: e }) => {
3868
- switch (e) {
3869
- case "entering":
3870
- return Sd;
3871
- case "entered":
3872
- return Td;
3873
- case "exiting":
3874
- return wd;
3875
- case "exited":
3876
- return Ad;
3877
- default:
3878
- return "";
3879
- }
3880
- }}${({ $active: e }) => e ? I`
3881
- z-index: 999;
3882
- ` : I`z-index:1;pointer-events:none;`}
3883
- `;
3884
- function Ae({ initialId: e, children: t }) {
3885
- const n = R((g, C) => {
3886
- c((v) => [...v, g]), h((v) => ({ ...v, [g]: !0 })), C != null && C.reset && E((v) => ({
3887
- ...v,
3888
- [g]: (v[g] || 0) + 1
3889
- })), f((v) => ({
3890
- ...v,
3891
- [g]: "entering"
3892
- })), setTimeout(() => {
3893
- f((v) => ({
3894
- ...v,
3895
- [g]: "entered"
3896
- }));
3897
- }, 300);
3898
- }, []), o = R(() => {
3899
- c((g) => {
3900
- if (g.length <= 1) return g;
3901
- const C = g[g.length - 1];
3902
- return f((v) => ({
3903
- ...v,
3904
- [C]: "exiting"
3905
- })), setTimeout(() => {
3906
- f((v) => ({
3907
- ...v,
3908
- [C]: "exited"
3909
- })), c((v) => v.slice(0, -1));
3910
- }, 300), g;
3911
- });
3912
- }, []), s = ae(() => ({
3913
- navigation: {
3914
- navigate: n,
3915
- pop: o
3916
- }
3917
- }), [n, o]), i = ae(() => vr.toArray(t).filter(
3918
- (g) => g.type === mr
3919
- ), [t]), a = ae(() => {
3920
- const g = {};
3921
- return i.forEach((C) => {
3922
- const { id: v, lazy: S, children: k } = C.props;
3923
- g[v] = { lazy: S, element: typeof k == "function" ? k(s) : k };
3924
- }), g;
3925
- }, [i]), [l, c] = _([e]), [d, h] = _(() => {
3926
- const g = {};
3927
- return Object.entries(a).forEach(([C, { lazy: v }]) => {
3928
- v === !1 && (g[C] = !0);
3929
- }), g[e] = !0, g;
3930
- }), [m, f] = _(() => {
3931
- const g = {};
3932
- return Object.keys(a).forEach((C) => {
3933
- C === e ? g[C] = "entered" : g[C] = "exited";
3934
- }), g;
3935
- }), [x, E] = _({}), b = l[l.length - 1];
3936
- return /* @__PURE__ */ r.createElement(ur.Provider, { value: s }, /* @__PURE__ */ r.createElement(Id, null, Object.keys(a).map((g) => {
3937
- var k;
3938
- if (!d[g]) return null;
3939
- const C = m[g] || "exited", v = g === b, S = `${g}-${x[g] || 0}`;
3940
- return /* @__PURE__ */ r.createElement(kd, { key: S, $transitionState: C, $active: v }, (k = a[g]) == null ? void 0 : k.element);
3941
- })));
3942
- }
3943
- const Id = u.div`position:relative;width:100%;height:100%;`;
3944
- Ae.Screen = mr;
3945
- const he = {
3946
- activeConv: "active-conv",
3947
- closedConv: "closed-conv",
3948
- convList: "conv-list"
3949
- }, gr = ({ setClosedChannelUrl: e, closedChannelUrl: t }) => /* @__PURE__ */ r.createElement(Ae, { initialId: he.activeConv }, /* @__PURE__ */ r.createElement(Ae.Screen, { id: he.activeConv }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(pn, { onNavigateToConversationList: () => n.navigate(he.convList, { reset: !0 }) })), /* @__PURE__ */ r.createElement(Ae.Screen, { id: he.closedConv }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(
3950
- pn,
3951
- {
3952
- onNavigateToConversationList: () => n.pop(),
3953
- closedChannelUrl: t,
3954
- onClearClosedChannelUrl: () => e(void 0)
3955
- }
3956
- )), /* @__PURE__ */ r.createElement(Ae.Screen, { id: he.convList, lazy: !0 }, ({ navigation: n }) => /* @__PURE__ */ r.createElement(
3957
- ed,
3958
- {
3959
- onOpenConversationView: (o, s) => {
3960
- s === "closed" ? (e(o), n.navigate(he.closedConv, { reset: !0 })) : n.navigate(he.activeConv);
3961
- }
3962
- }
3963
- )));
3964
- function $d({ isExpanded: e, isOpened: t, children: n, launcher: o }) {
3965
- const { dir: s } = B();
3966
- return /* @__PURE__ */ r.createElement(Md, null, /* @__PURE__ */ r.createElement(Od, { dir: s, id: ee.WINDOW, $isExpanded: e, $isOpened: t }, n), o);
3967
- }
3968
- const Md = u.div`display:flex;flex-direction:column;gap:8px;align-items:flex-end;`, Od = u.div`background:${({ theme: e }) => e.colors.base.background};display:flex;overscroll-behavior:none;-webkit-overflow-scrolling:auto;height:640px;min-height:80px;width:400px;max-width:80vw;max-height:80vh;box-shadow:0px 16px 24px 2px rgba(33,33,33,0.12),0px 6px 30px 5px rgba(33,33,33,0.08),0px 6px 10px -5px rgba(33,33,33,0.04);border-radius:16px;overflow:hidden;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 150ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;transform:scale(0.15);opacity:0;transform-origin:right bottom;[dir='rtl'] &:not([dir='ltr']),&[dir='rtl']{transform-origin:left bottom;}${({ $isOpened: e }) => e && Rd};${({ $isExpanded: e }) => e && Ld};`, Ld = I`width:743px;height:723px;`, Rd = I`z-index:${fe.WINDOW};pointer-events:all;transform:scale(1);opacity:1;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 300ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;`, lu = ye(function({ children: e, ...t }, n) {
3969
- const o = Oe(), [s, i] = _(), a = o ? ar : $d;
3970
- return /* @__PURE__ */ r.createElement(ir, { enableExpandButton: !o, ref: n, ...t }, /* @__PURE__ */ r.createElement(In, null, ({ state: l }) => /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(a, { isExpanded: l.expanded, isOpened: l.opened, launcher: /* @__PURE__ */ r.createElement(dr, null) }, /* @__PURE__ */ r.createElement(
3971
- gr,
3972
- {
3973
- closedChannelUrl: s,
3974
- setClosedChannelUrl: i
3975
- }
3976
- )), e)));
3977
- }), {
3978
- Provider: Dd,
3979
- useContext: Bt
3980
- } = G("FixedMessengerStyle");
3981
- function hr(e, t, n, o = 0) {
3982
- const { top: s, bottom: i, start: a, end: l } = n;
3983
- let c = "", d = "";
3984
- switch (e) {
3985
- case "start":
3986
- d = `inset-inline-start: ${j(a)}`;
3987
- break;
3988
- case "end":
3989
- d = `inset-inline-end: ${j(l)}`;
3990
- break;
3991
- }
3992
- switch (t) {
3993
- case "top":
3994
- c = `top: calc(${j(s)} + ${o}px)`;
3995
- break;
3996
- case "bottom":
3997
- c = `bottom: calc(${j(i)} + ${o}px)`;
3998
- break;
3999
- }
4000
- return I`${c};${d};`;
4001
- }
4002
- function Nd(e) {
4003
- const { horizontal: t, vertical: n, margin: o, launcherSize: s } = Bt();
4004
- return /* @__PURE__ */ r.createElement(Pd, { ...e, size: s, $horizontal: t, $vertical: n, $margin: o });
4005
- }
4006
- const Pd = u(dr)`position:fixed;z-index:${fe.LAUNCHER};${({ $horizontal: e, $vertical: t, $margin: n }) => hr(e, t, n)};`;
4007
- function Bd({ isExpanded: e, isOpened: t, children: n }) {
4008
- const { dir: o } = B(), { horizontal: s, vertical: i, margin: a, launcherSize: l } = Bt();
4009
- return /* @__PURE__ */ r.createElement(
4010
- Fd,
4011
- {
4012
- dir: o,
4013
- id: ee.WINDOW,
4014
- $isExpanded: e,
4015
- $isOpened: t,
4016
- $horizontal: s,
4017
- $vertical: i,
4018
- $margin: a,
4019
- $launcherSize: l
4020
- },
4021
- n
4022
- );
4023
- }
4024
- const Fd = u.div`background:${({ theme: e }) => e.colors.base.background};display:flex;overscroll-behavior:none;-webkit-overflow-scrolling:auto;position:fixed;${({ $horizontal: e, $vertical: t, $margin: n, $launcherSize: o }) => hr(e, t, n, o + 12)};height:640px;min-height:80px;width:400px;max-width:80vw;max-height:80vh;box-shadow:0px 16px 24px 2px rgba(33,33,33,0.12),0px 6px 30px 5px rgba(33,33,33,0.08),0px 6px 10px -5px rgba(33,33,33,0.04);border-radius:16px;overflow:hidden;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 150ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;transform:scale(0.15);opacity:0;transform-origin:${({ $horizontal: e, $vertical: t }) => `${e === "start" ? "left" : "right"} ${t}`};
4025
- [dir='rtl'] &:not([dir='ltr']),
4026
- &[dir='rtl'] {
4027
- transform-origin: ${({ $horizontal: e, $vertical: t }) => `${e === "start" ? "right" : "left"} ${t}`};
4028
- }
4029
-
4030
- ${({ $isOpened: e }) => e && Hd};
4031
- ${({ $isExpanded: e }) => e && Ud};
4032
- `, Ud = I`width:743px;height:723px;`, Hd = I`z-index:${fe.WINDOW};pointer-events:all;transform:scale(1);opacity:1;transition:width 200ms ease 0s,height 200ms ease 0s,max-height 200ms ease 0s,transform 300ms cubic-bezier(0,1.2,1,1) 0s,opacity 83ms ease-out 0s;`, pr = { top: 24, bottom: 24, start: 24, end: 24 }, zd = ye(function({ children: e, ...t }, n) {
4033
- const [o, s] = _(), [i, a] = _("end-bottom"), [l, c] = _(pr), [d, h] = _(48), m = Oe(), f = m ? ar : Bd, { horizontal: x, vertical: E } = ae(() => {
4034
- const [b, g] = i.split("-");
4035
- return { horizontal: b === "start" ? "start" : "end", vertical: g === "top" ? "top" : "bottom" };
4036
- }, [i]);
4037
- return /* @__PURE__ */ r.createElement(ir, { enableExpandButton: !m, ref: n, ...t }, /* @__PURE__ */ r.createElement(In, null, ({ state: b }) => /* @__PURE__ */ r.createElement(
4038
- Dd,
4039
- {
4040
- value: { horizontal: x, vertical: E, margin: l, launcherSize: d, setPosition: a, setMargin: c, setLauncherSize: h }
4041
- },
4042
- /* @__PURE__ */ r.createElement(f, { isExpanded: b.expanded, isOpened: b.opened }, /* @__PURE__ */ r.createElement(
4043
- gr,
4044
- {
4045
- closedChannelUrl: o,
4046
- setClosedChannelUrl: s
4047
- }
4048
- )),
4049
- /* @__PURE__ */ r.createElement(Nd, null),
4050
- e
4051
- )));
4052
- }), Vd = (e) => {
4053
- var s, i, a, l;
4054
- const { setPosition: t, setMargin: n, setLauncherSize: o } = Bt();
4055
- return le(() => {
4056
- e.position && t(e.position), e.margin && n({ ...pr, ...e.margin }), e.launcherSize && o(e.launcherSize);
4057
- }, [
4058
- e.position,
4059
- (s = e.margin) == null ? void 0 : s.top,
4060
- (i = e.margin) == null ? void 0 : i.bottom,
4061
- (a = e.margin) == null ? void 0 : a.start,
4062
- (l = e.margin) == null ? void 0 : l.end,
4063
- e.launcherSize
4064
- ]), null;
4065
- }, cu = Object.assign(zd, {
4066
- Style: Vd
4067
- });
4068
- export {
4069
- St as A,
4070
- oo as C,
4071
- lu as D,
4072
- cu as F,
4073
- M as I,
4074
- Hn as L,
4075
- Ra as M,
4076
- Ot as O,
4077
- iu as P,
4078
- Lt as S,
4079
- w as a,
4080
- ir as b,
4081
- p as c,
4082
- ld as d,
4083
- U as e,
4084
- O as f,
4085
- gd as g,
4086
- xe as h,
4087
- X as i,
4088
- sr as j,
4089
- pn as k,
4090
- Nt as l,
4091
- cd as m,
4092
- su as n,
4093
- rl as o,
4094
- Z as p,
4095
- ed as q,
4096
- Pt as r,
4097
- au as s,
4098
- Bc as t,
4099
- B as u,
4100
- or as v,
4101
- Sn as w,
4102
- $o as x,
4103
- Zt as y
4104
- };