@telia-ace/widget-conversation 1.0.29-next.0 → 1.0.29-next.10

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.
@@ -0,0 +1,1164 @@
1
+ var ve = Object.defineProperty, Ee = Object.defineProperties;
2
+ var xe = Object.getOwnPropertyDescriptors;
3
+ var A = Object.getOwnPropertySymbols;
4
+ var ee = Object.prototype.hasOwnProperty, te = Object.prototype.propertyIsEnumerable;
5
+ var Z = (e, t, n) => t in e ? ve(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, g = (e, t) => {
6
+ for (var n in t || (t = {}))
7
+ ee.call(t, n) && Z(e, n, t[n]);
8
+ if (A)
9
+ for (var n of A(t))
10
+ te.call(t, n) && Z(e, n, t[n]);
11
+ return e;
12
+ }, x = (e, t) => Ee(e, xe(t));
13
+ var j = (e, t) => {
14
+ var n = {};
15
+ for (var o in e)
16
+ ee.call(e, o) && t.indexOf(o) < 0 && (n[o] = e[o]);
17
+ if (e != null && A)
18
+ for (var o of A(e))
19
+ t.indexOf(o) < 0 && te.call(e, o) && (n[o] = e[o]);
20
+ return n;
21
+ };
22
+ import a from "@emotion/styled";
23
+ import { Input as oe, Button as L, borderTabStyle as b, SymbolBadge as w, useIsTabbing as we, useDispatch as V, useProperties as M, useScroll as ae, Typography as q, invertedHoverButton as ke, Html as Y, List as le, buttonCss as G, ItemList as J, itemList as Q, useComponent as Ce, genericHtml as Se, headingElement as se, list as ze, WidgetOverlayOutlet as ie, ConversationContext as Le } from "@telia-ace/widget-ui";
24
+ import { appendClassNames as H } from "@telia-ace/widget-utilities";
25
+ import r, { useState as R, useEffect as ce, forwardRef as X, Suspense as Me, useMemo as He, useCallback as me, useRef as Te } from "react";
26
+ import { css as f, keyframes as Ie } from "@emotion/react";
27
+ import { FormComponent as Ae } from "@telia-ace/widget-forms";
28
+ import { ConversationMessageListItemType as C, ConversationMessageType as D } from "./index.js";
29
+ import "@telia-ace/widget-core";
30
+ import "@telia-ace/widget-services";
31
+ import "@telia-ace/widget-plugins";
32
+ const Re = ({ className: e }) => {
33
+ const [t, n] = R(""), [o, l] = R(!1), [s, u] = R(0), [c, h] = R(0), v = we(), m = V(), {
34
+ inputPlaceholder: i = "Type your message",
35
+ inputHidden: $ = !1,
36
+ inputDisabled: k = !1,
37
+ sendButtonLabel: S = "Send message",
38
+ inputMultiline: E = !0,
39
+ secondaryAction: p
40
+ } = M(), [fe, y] = ae(!0);
41
+ ce(() => {
42
+ if (y.current) {
43
+ const { lineHeight: d, maxHeight: I } = getComputedStyle(y.current);
44
+ if (d && d.indexOf("px") > -1) {
45
+ const z = d.split("px"), be = parseInt(z[0], 10);
46
+ u(be);
47
+ const $e = I.split("px");
48
+ h(parseInt($e[0], 10));
49
+ }
50
+ }
51
+ }, [y.current]);
52
+ const N = (d) => {
53
+ !d.shiftKey || !E ? (d.preventDefault(), t && t.length > 0 && (m("user-submit", { text: t }), n(""), O(""))) : t.length < 1 && d.preventDefault();
54
+ }, pe = (d) => {
55
+ !p || (d.preventDefault(), m("action", g({
56
+ actionKey: p.action
57
+ }, p)));
58
+ }, ye = (d) => {
59
+ if (E && y.current) {
60
+ const I = y.current.scrollHeight;
61
+ if (I > s) {
62
+ y.current.style.height = "auto";
63
+ let z = I;
64
+ d.length < 1 && (z = s), y.current.style.height = `${z}px`, z >= c ? y.current.style.overflowY = "scroll" : y.current.style.overflowY = "hidden";
65
+ }
66
+ }
67
+ }, O = (d) => {
68
+ ye(d), n(d), d && d.length > 0 && m("user-typing", { textLength: d.length });
69
+ };
70
+ return $ ? null : /* @__PURE__ */ r.createElement(Oe, {
71
+ grow: E,
72
+ className: H("humany-conversation-input", e),
73
+ "data-has-focus": o,
74
+ scrollableCss: fe,
75
+ isTabbing: v
76
+ }, p && /* @__PURE__ */ r.createElement(Ne, {
77
+ disabled: k,
78
+ onClick: pe,
79
+ title: p.label,
80
+ "aria-label": p.label
81
+ }, /* @__PURE__ */ r.createElement(w, {
82
+ size: 24,
83
+ symbol: { type: "Svg", content: p.icon || "browse" }
84
+ })), E ? /* @__PURE__ */ r.createElement(Be, {
85
+ value: t,
86
+ onChange: O,
87
+ onEnter: N,
88
+ disabled: k,
89
+ "aria-label": i,
90
+ placeholder: i,
91
+ onFocusChange: l,
92
+ type: "textarea",
93
+ rows: 1,
94
+ ref: y
95
+ }) : /* @__PURE__ */ r.createElement(Ke, {
96
+ value: t,
97
+ onChange: O,
98
+ onEnter: N,
99
+ disabled: k,
100
+ "aria-label": i,
101
+ placeholder: i,
102
+ onFocusChange: l
103
+ }), /* @__PURE__ */ r.createElement(de, {
104
+ disabled: k,
105
+ onClick: N,
106
+ title: S,
107
+ "aria-label": S
108
+ }, /* @__PURE__ */ r.createElement(je, {
109
+ size: 22,
110
+ symbol: { type: "Svg", content: "send" },
111
+ hasContent: !!t && !!t.length
112
+ })));
113
+ }, Be = a(oe)`
114
+ resize: none;
115
+ flex: 1;
116
+ flex-shrink: 1;
117
+ min-height: 1.2em;
118
+ max-height: 148px;
119
+ line-height: 1.2em;
120
+ height: 1.2em;
121
+ padding: 0;
122
+ margin: ${(e) => {
123
+ var t;
124
+ return (t = e.theme.sizes) == null ? void 0 : t.medium;
125
+ }};
126
+ font-size: ${(e) => {
127
+ var t;
128
+ return (t = e.theme.fonts) == null ? void 0 : t.normal;
129
+ }};
130
+ border: none;
131
+ transition: height 200ms linear;
132
+ outline: none;
133
+ `, Ke = a(oe)`
134
+ flex: 1;
135
+ border: none;
136
+ background-color: transparent;
137
+ font-weight: 300;
138
+ font-size: ${(e) => {
139
+ var t;
140
+ return (t = e.theme.fonts) == null ? void 0 : t.normal;
141
+ }};
142
+ line-height: 1.2em;
143
+ outline: none;
144
+ padding: ${(e) => {
145
+ var t;
146
+ return (t = e.theme.sizes) == null ? void 0 : t.medium;
147
+ }};
148
+ color: ${(e) => {
149
+ var t;
150
+ return (t = e.theme.colors) == null ? void 0 : t.text;
151
+ }};
152
+ &::placeholder {
153
+ color: ${(e) => {
154
+ var t;
155
+ return (t = e.theme.colors) == null ? void 0 : t.textLight;
156
+ }};
157
+ font-style: italic;
158
+ }
159
+ `, de = a(L)`
160
+ flex: 0 0 50px;
161
+ align-self: stretch;
162
+ background-color: transparent;
163
+ display: flex;
164
+ align-items: center;
165
+ justify-content: center;
166
+ border: none;
167
+ color: #a6a6a6;
168
+ &:focus-visible {
169
+ ${b};
170
+ }
171
+ `, Ne = a(de)`
172
+ border-right: ${(e) => e.theme.border};
173
+ margin: ${(e) => {
174
+ var t;
175
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
176
+ }} 0;
177
+ `, Oe = a.div`
178
+ ${(e) => e.grow ? f`
179
+ min-height: 50px;
180
+ max-height: 150px;
181
+ ` : f`
182
+ height: 50px;
183
+ `}
184
+ flex: 0 0 auto;
185
+ display: flex;
186
+ align-items: center;
187
+ background-color: ${(e) => {
188
+ var t;
189
+ return (t = e.theme.colors) == null ? void 0 : t.accent;
190
+ }};
191
+ border-top: ${(e) => e.theme.inputBorder};
192
+ ${(e) => e["data-has-focus"] && e.isTabbing && b}
193
+ textarea {
194
+ ${(e) => !!e.scrollableCss && e.scrollableCss}
195
+ }
196
+ `, je = a(
197
+ (n) => {
198
+ var o = n, {
199
+ hasContent: e
200
+ } = o, t = j(o, [
201
+ "hasContent"
202
+ ]);
203
+ return /* @__PURE__ */ r.createElement(w, g({}, t));
204
+ }
205
+ )`
206
+ line,
207
+ path {
208
+ stroke: ${(e) => {
209
+ var t;
210
+ return e.hasContent ? (t = e.theme.colors) == null ? void 0 : t.primary : "#a6a6a6";
211
+ }};
212
+ fill: ${(e) => {
213
+ var t;
214
+ return e.hasContent ? (t = e.theme.colors) == null ? void 0 : t.primary : "#a6a6a6";
215
+ }};
216
+ }
217
+ `, De = a.div`
218
+ width: ${(e) => e.avatarSize || "32px"};
219
+ height: ${(e) => e.avatarSize || "32px"};
220
+ border-radius: 50%;
221
+ background-color: ${(e) => {
222
+ var t;
223
+ return (t = e.theme.colors) == null ? void 0 : t.accent;
224
+ }};
225
+ border: ${(e) => e.theme.border};
226
+ grid-area: avatar;
227
+ align-self: flex-end;
228
+ justify-self: center;
229
+ overflow: hidden;
230
+ margin-right: 10px;
231
+ display: flex;
232
+ justify-content: center;
233
+ align-items: center;
234
+ color: ${(e) => {
235
+ var t;
236
+ return (t = e.theme.colors) == null ? void 0 : t.text;
237
+ }};
238
+
239
+ > img {
240
+ height: 100%;
241
+ width: 100%;
242
+ object-fit: cover;
243
+ }
244
+
245
+ > svg {
246
+ width: 90%;
247
+ height: 90%;
248
+ padding: 10%;
249
+ color: ${(e) => {
250
+ var t;
251
+ return (t = e.theme.colors) == null ? void 0 : t.text;
252
+ }};
253
+
254
+ line,
255
+ path,
256
+ circle,
257
+ fill {
258
+ stroke: ${(e) => {
259
+ var t;
260
+ return (t = e.theme.colors) == null ? void 0 : t.text;
261
+ }};
262
+ }
263
+ }
264
+ `, Fe = Ie`
265
+ 0% {
266
+ opacity: 0;
267
+ }
268
+ 75% {
269
+ opacity: 1;
270
+ }
271
+ 100% {
272
+ opacity: 0;
273
+ }
274
+ `, We = a.div`
275
+ display: flex;
276
+ justify-content: center;
277
+ > div {
278
+ height: 10px;
279
+ width: 10px;
280
+ border-radius: 50%;
281
+ margin: 5px;
282
+ background-color: ${(e) => {
283
+ var t;
284
+ return (t = e.theme.colors) == null ? void 0 : t.text;
285
+ }};
286
+ animation: ${Fe} 1s infinite;
287
+ }
288
+ > div:nth-child(2) {
289
+ animation-delay: 100ms;
290
+ }
291
+ > div:nth-child(3) {
292
+ animation-delay: 200ms;
293
+ }
294
+ `, P = a.div`
295
+ grid-area: content;
296
+ max-width: 100%;
297
+ overflow: hidden;
298
+ `, Pe = a(q)`
299
+ font-size: ${(e) => {
300
+ var t;
301
+ return (t = e.theme.fonts) == null ? void 0 : t.normal;
302
+ }};
303
+ font-weight: normal;
304
+ margin: 0;
305
+ `, U = a.div`
306
+ display: flex;
307
+ ${(e) => e.left && "justify-content: start;"};
308
+ ${(e) => e.center && "justify-content: center;"};
309
+ ${(e) => e.right && "justify-content: end;"};
310
+ `, _ = a.div`
311
+ ${(e) => {
312
+ var t;
313
+ return e.padded && `padding: ${(t = e.theme.sizes) == null ? void 0 : t.medium};`;
314
+ }}
315
+ ${(e) => !e.user && e.stacked && Ue(e.stacked, e.theme)}
316
+ ${(e) => e.user && e.stacked && _e(e.stacked, e.theme)}
317
+
318
+ display: inline-block;
319
+ margin-top: ${(e) => {
320
+ var t;
321
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
322
+ }};
323
+ && > * {
324
+ overflow-wrap: break-word;
325
+ word-wrap: break-word;
326
+ word-break: break-all;
327
+ word-break: break-word;
328
+ hyphens: auto;
329
+ }
330
+ max-width: 100%;
331
+ ${(e) => e.fullWidth && "width: 100%;"}
332
+ `, Ue = (e, t) => {
333
+ var o, l;
334
+ const n = f`
335
+ background-color: ${(o = t.colors) == null ? void 0 : o.accent};
336
+ color: ${(l = t.colors) == null ? void 0 : l.text};
337
+ ${t.border && `border: ${t.border};`};
338
+ `;
339
+ return t.borderRadius ? f`
340
+ ${n}
341
+
342
+ border-top-right-radius: ${t.borderRadius};
343
+ border-bottom-right-radius: ${t.borderRadius};
344
+
345
+ ${e === "first" && `
346
+ border-top-left-radius: ${t.borderRadius};
347
+ `}
348
+
349
+ ${e === "last" && `
350
+ border-bottom-left-radius: ${t.borderRadius};
351
+ `}
352
+ ` : n;
353
+ }, _e = (e, t) => {
354
+ var o, l;
355
+ const n = f`
356
+ background-color: ${(o = t.colors) == null ? void 0 : o.primary};
357
+ color: ${(l = t.colors) == null ? void 0 : l.accent};
358
+ `;
359
+ return t.borderRadius ? f`
360
+ ${n}
361
+
362
+ border-top-left-radius: ${t.borderRadius};
363
+ border-bottom-left-radius: ${t.borderRadius};
364
+
365
+ ${e === "first" && `
366
+ border-top-right-radius: ${t.borderRadius};
367
+ `}
368
+
369
+ ${e === "last" && `
370
+ border-bottom-right-radius: ${t.borderRadius};
371
+ `}
372
+ ` : n;
373
+ }, B = a.div`
374
+ margin-bottom: ${(e) => {
375
+ var t;
376
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
377
+ }};
378
+ &:last-child {
379
+ margin-bottom: 0;
380
+ }
381
+ `, T = (e) => {
382
+ var t, n;
383
+ return f`
384
+ margin: ${(t = e.theme.sizes) == null ? void 0 : t.medium} 0;
385
+ padding: 0 ${(n = e.theme.sizes) == null ? void 0 : n.medium};
386
+ `;
387
+ }, Ve = a(Ae)`
388
+ & button.humany-form-component-button {
389
+ ${(e) => {
390
+ var t, n, o, l;
391
+ return ((t = e.theme.colors) == null ? void 0 : t.primary) && ((n = e.theme.colors) == null ? void 0 : n.accent) && ke({
392
+ active: !1,
393
+ primaryColor: (o = e.theme.colors) == null ? void 0 : o.primary,
394
+ secondaryColor: (l = e.theme.colors) == null ? void 0 : l.accent,
395
+ theme: e.theme
396
+ });
397
+ }};
398
+ display: block;
399
+ width: 100%;
400
+ margin-bottom: ${(e) => {
401
+ var t;
402
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
403
+ }};
404
+ }
405
+ & button.humany-form-component-submit {
406
+ width: 100%;
407
+ margin: 0;
408
+ :not(:last-child) {
409
+ margin-bottom: ${(e) => {
410
+ var t;
411
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
412
+ }};
413
+ }
414
+ }
415
+ `, qe = a(Y)`
416
+ white-space: pre-wrap;
417
+ a {
418
+ color: ${(e) => e.theme.colors.link};
419
+ &:focus {
420
+ ${(e) => {
421
+ var t;
422
+ return ((t = e.theme.accessibility) == null ? void 0 : t.isTabbing) && b;
423
+ }};
424
+ }
425
+ }
426
+ `, Ye = a(le)`
427
+ padding: 0;
428
+ list-style: none;
429
+ margin: 0 -${(e) => {
430
+ var t;
431
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
432
+ }};
433
+ > li {
434
+ margin: ${(e) => {
435
+ var t;
436
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
437
+ }};
438
+ }
439
+ `, Ge = a.button`
440
+ ${(e) => G(e)};
441
+ display: block;
442
+ background-color: ${(e) => {
443
+ var t;
444
+ return (t = e.theme.colors) == null ? void 0 : t.primary;
445
+ }};
446
+ width: 100%;
447
+ color: #fff;
448
+ &:focus-visible {
449
+ ${b}
450
+ background-color: transparent;
451
+ }
452
+ `, re = X(
453
+ ({ boxed: e, className: t, agentData: n }, o) => /* @__PURE__ */ r.createElement(P, {
454
+ ref: o
455
+ }, /* @__PURE__ */ r.createElement(U, {
456
+ left: e,
457
+ center: !e
458
+ }, /* @__PURE__ */ r.createElement(_, {
459
+ padded: !!e,
460
+ stacked: e ? "first" : void 0
461
+ }, /* @__PURE__ */ r.createElement(We, null, /* @__PURE__ */ r.createElement("div", null), /* @__PURE__ */ r.createElement("div", null), /* @__PURE__ */ r.createElement("div", null)))))
462
+ ), Je = a.p`
463
+ && {
464
+ font-size: ${(e) => {
465
+ var t;
466
+ return (t = e.theme.fonts) == null ? void 0 : t.small;
467
+ }};
468
+ font-weight: 300;
469
+ }
470
+ margin: 0;
471
+ line-height: 1.5em;
472
+ grid-area: info;
473
+ color: ${(e) => {
474
+ var t;
475
+ return (t = e.theme.colors) == null ? void 0 : t.text;
476
+ }};
477
+ `, ne = (e) => new Date(e).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), K = ({ className: e, name: t, timestamp: n }) => {
478
+ if (!t && !n)
479
+ return null;
480
+ let o = "";
481
+ return t ? n ? o = `${t}: ${ne(n)}` : o = t : n && (o = ne(n)), /* @__PURE__ */ r.createElement(Je, null, o);
482
+ }, ue = ({ className: e, children: t, sender: n, timestamp: o }) => {
483
+ const { avatar: l, name: s } = n, { avatarSize: u } = M();
484
+ return /* @__PURE__ */ r.createElement(Qe, {
485
+ hasAvatar: !!l,
486
+ className: H(e, "humany-conversation-agent-message")
487
+ }, l && /* @__PURE__ */ r.createElement(De, {
488
+ avatarSize: u
489
+ }, typeof l == "string" ? /* @__PURE__ */ r.createElement("img", {
490
+ src: l
491
+ }) : /* @__PURE__ */ r.createElement(w, {
492
+ symbol: l
493
+ })), t, /* @__PURE__ */ r.createElement(K, {
494
+ name: s,
495
+ timestamp: o
496
+ }));
497
+ }, Qe = a.div`
498
+ display: grid;
499
+ margin-right: 10%;
500
+ width: 90%;
501
+ ${(e) => e.hasAvatar ? f`
502
+ grid-template-columns: auto 1fr;
503
+ grid-template-rows: 1fr auto;
504
+ grid-template-areas:
505
+ 'avatar content'
506
+ '. info';
507
+ ` : f`
508
+ grid-template-columns: 1fr;
509
+ grid-template-rows: 1fr auto;
510
+ grid-template-areas:
511
+ 'content'
512
+ 'info';
513
+ `};
514
+ `, Xe = X(
515
+ ({ className: e, children: t, timestamp: n, discrete: o, fullWidth: l }, s) => /* @__PURE__ */ r.createElement(Ze, {
516
+ ref: s,
517
+ className: H(e, "humany-conversation-system-message"),
518
+ fullWidth: l
519
+ }, o ? /* @__PURE__ */ r.createElement(et, {
520
+ className: "humany-conversation-discrete-message"
521
+ }, t, /* @__PURE__ */ r.createElement(K, {
522
+ timestamp: n
523
+ })) : /* @__PURE__ */ r.createElement(r.Fragment, null, t, /* @__PURE__ */ r.createElement(K, {
524
+ timestamp: n
525
+ })))
526
+ ), Ze = a.div`
527
+ ${(e) => e.fullWidth && "width: 100%"};
528
+ padding: 0 ${(e) => {
529
+ var t;
530
+ return (t = e.theme.sizes) == null ? void 0 : t.large;
531
+ }};
532
+ overflow: auto;
533
+ `, et = a.div`
534
+ text-align: center;
535
+ word-wrap: break-word;
536
+ font-size: ${(e) => {
537
+ var t;
538
+ return (t = e.theme.fonts) == null ? void 0 : t.normal;
539
+ }};
540
+ color: ${(e) => {
541
+ var t;
542
+ return (t = e.theme.colors) == null ? void 0 : t.text;
543
+ }};
544
+ > p {
545
+ margin: 0;
546
+ }
547
+ `, tt = ({ className: e, children: t, timestamp: n }) => {
548
+ const { userLabel: o = "" } = M();
549
+ return /* @__PURE__ */ r.createElement(rt, {
550
+ className: H(e, "humany-conversation-user-message")
551
+ }, t, /* @__PURE__ */ r.createElement(K, {
552
+ name: o,
553
+ timestamp: n
554
+ }));
555
+ }, rt = a.div`
556
+ margin-left: 10%;
557
+ width: 90%;
558
+ display: flex;
559
+ flex-direction: column;
560
+ align-items: flex-end;
561
+ `, he = (e) => Array.isArray(e) ? e : Object.keys(e).map((t) => ({
562
+ label: e[t],
563
+ actionKey: t
564
+ })), nt = ({ header: e, actions: t, dispatch: n }) => /* @__PURE__ */ r.createElement(ot, {
565
+ header: e,
566
+ items: he(t),
567
+ renderItem: (o) => /* @__PURE__ */ r.createElement("li", {
568
+ key: o.actionKey
569
+ }, /* @__PURE__ */ r.createElement(at, {
570
+ onClick: () => {
571
+ n("action", o);
572
+ },
573
+ "aria-label": o.label,
574
+ title: o.label
575
+ }, /* @__PURE__ */ r.createElement(w, {
576
+ symbol: o.symbol
577
+ }), o.label))
578
+ }), ot = a(J)`
579
+ ${Q}
580
+ > ul {
581
+ display: flex;
582
+ flex-wrap: wrap;
583
+ gap: ${(e) => {
584
+ var t;
585
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
586
+ }};
587
+ > li {
588
+ margin: 0;
589
+ }
590
+ }
591
+ ${T}
592
+ `, at = a(L)`
593
+ ${G};
594
+
595
+ display: block;
596
+ padding: ${(e) => {
597
+ var t;
598
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
599
+ }};
600
+ background-color: ${(e) => {
601
+ var t;
602
+ return (t = e.theme.colors) == null ? void 0 : t.primary;
603
+ }};
604
+ width: 100%;
605
+ color: #ffffff;
606
+ overflow: hidden;
607
+ text-overflow: ellipsis;
608
+ &:focus-visible {
609
+ ${b}
610
+ background-color: transparent;
611
+ }
612
+
613
+ i,
614
+ svg {
615
+ margin-right: ${(e) => {
616
+ var t;
617
+ return (t = e.theme.sizes) == null ? void 0 : t.small;
618
+ }};
619
+ }
620
+ `, lt = ({ type: e, content: t = {} }) => {
621
+ const n = Ce(e);
622
+ return !n || !e ? null : /* @__PURE__ */ r.createElement(Me, {
623
+ fallback: null
624
+ }, /* @__PURE__ */ r.createElement(n, g({}, t)));
625
+ }, st = ({ body: e }) => /* @__PURE__ */ r.createElement(it, {
626
+ html: e
627
+ }), it = a(Y)`
628
+ ${Se}
629
+ color: inherit;
630
+ white-space: pre-wrap;
631
+ ${T}
632
+ a {
633
+ color: ${(e) => e.theme.colors.link};
634
+ &:focus-visible {
635
+ ${b};
636
+ }
637
+ }
638
+ `, ct = ({ header: e, actions: t, dispatch: n }) => /* @__PURE__ */ r.createElement(mt, {
639
+ header: e,
640
+ items: he(t),
641
+ renderItem: (o) => /* @__PURE__ */ r.createElement("li", {
642
+ key: o.actionKey
643
+ }, /* @__PURE__ */ r.createElement(dt, {
644
+ help: o.actionKey === "help",
645
+ onClick: () => {
646
+ n("action", o);
647
+ },
648
+ "aria-label": o.label,
649
+ title: o.label
650
+ }, o.label, o.actionKey === "help" && /* @__PURE__ */ r.createElement(w, {
651
+ size: 14,
652
+ symbol: {
653
+ type: "Svg",
654
+ content: "caret-down"
655
+ }
656
+ })))
657
+ }), mt = a(J)`
658
+ ${Q}
659
+ ${T}
660
+
661
+ ${(e) => se(e)(
662
+ "h1",
663
+ f`
664
+ white-space: normal;
665
+ `
666
+ )}
667
+
668
+ > ul {
669
+ display: flex;
670
+ flex-direction: column;
671
+ gap: ${(e) => {
672
+ var t;
673
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
674
+ }};
675
+ > li {
676
+ margin: 0;
677
+ }
678
+ }
679
+ `, dt = a(L)`
680
+ display: block;
681
+ text-align: left;
682
+ font-weight: 300;
683
+ color: ${(e) => {
684
+ var t;
685
+ return (t = e.theme.colors) == null ? void 0 : t.primary;
686
+ }};
687
+ max-width: 100%;
688
+ text-overflow: ellipsis;
689
+ overflow: hidden;
690
+
691
+ ${(e) => {
692
+ var t, n;
693
+ return e.help && f`
694
+ color: ${(t = e.theme.colors) == null ? void 0 : t.text};
695
+ text-decoration: underline;
696
+
697
+ i,
698
+ svg {
699
+ margin-left: ${(n = e.theme.sizes) == null ? void 0 : n.small};
700
+ }
701
+ `;
702
+ }}
703
+
704
+ &:focus-visible {
705
+ ${b}
706
+ span {
707
+ color: ${(e) => {
708
+ var t;
709
+ return (t = e.theme.colors) == null ? void 0 : t.primary;
710
+ }};
711
+ text-decoration: underline;
712
+ }
713
+ }
714
+ `, ut = () => /* @__PURE__ */ r.createElement(ht, null), ht = a.div`
715
+ ${(e) => e.theme.border && `border-bottom: ${e.theme.border};`}
716
+ width: 100%;
717
+ `, gt = ({ text: e }) => /* @__PURE__ */ r.createElement(ft, {
718
+ variant: "span"
719
+ }, e), ft = a(q)`
720
+ ${T}
721
+ `, pt = ({
722
+ header: e = "Video call",
723
+ acceptLabel: t = "Accept",
724
+ declineLabel: n = "Decline",
725
+ dispatch: o
726
+ }) => {
727
+ const l = He(() => [
728
+ {
729
+ label: t,
730
+ actionKey: "accept-video-call",
731
+ symbol: {
732
+ type: "Svg",
733
+ content: "video"
734
+ }
735
+ },
736
+ {
737
+ label: n,
738
+ actionKey: "decline-video-call",
739
+ symbol: {
740
+ type: "Svg",
741
+ content: "close"
742
+ }
743
+ }
744
+ ], [t, n]);
745
+ return /* @__PURE__ */ r.createElement(yt, {
746
+ header: e,
747
+ items: l,
748
+ renderItem: (s) => {
749
+ const u = s.actionKey === "accept-video-call" ? "#70c48e" : "#da5c85";
750
+ return /* @__PURE__ */ r.createElement("li", {
751
+ key: s.actionKey
752
+ }, /* @__PURE__ */ r.createElement(bt, {
753
+ onClick: () => {
754
+ o("action", s);
755
+ },
756
+ "aria-label": s.label,
757
+ title: s.label,
758
+ bgColor: u
759
+ }, /* @__PURE__ */ r.createElement(w, {
760
+ symbol: s.symbol,
761
+ size: 25
762
+ })));
763
+ }
764
+ });
765
+ }, yt = a(J)`
766
+ ${(e) => Q(e)}
767
+ > ul {
768
+ display: flex;
769
+ flex-wrap: wrap;
770
+ gap: ${(e) => {
771
+ var t;
772
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
773
+ }};
774
+ > li {
775
+ margin: 0;
776
+ }
777
+ }
778
+ ${(e) => T(e)}
779
+ `, bt = a(L)`
780
+ ${G};
781
+
782
+ background-color: ${(e) => e.bgColor};
783
+ display: flex;
784
+ justify-content: center;
785
+ align-items: center;
786
+ color: #ffffff;
787
+ width: 46px;
788
+ height: 46px;
789
+ border-radius: 100%;
790
+
791
+ &:focus-visible {
792
+ ${b}
793
+ background-color: transparent;
794
+
795
+ i,
796
+ svg {
797
+ color: ${(e) => {
798
+ var t;
799
+ return (t = e.theme.colors) == null ? void 0 : t.primary;
800
+ }};
801
+
802
+ path {
803
+ stroke: ${(e) => {
804
+ var t;
805
+ return (t = e.theme.colors) == null ? void 0 : t.primary;
806
+ }};
807
+ }
808
+ }
809
+ }
810
+
811
+ i,
812
+ svg {
813
+ color: #fff;
814
+
815
+ path {
816
+ stroke: #fff;
817
+ }
818
+ }
819
+ `, $t = ([e, t]) => ({ type: e, content: t }), vt = ({ items: e, dispatch: t }) => /* @__PURE__ */ r.createElement(Et, {
820
+ items: e.map($t),
821
+ renderLi: !0,
822
+ renderItem: (n) => {
823
+ switch (n.type) {
824
+ case C.Text:
825
+ return /* @__PURE__ */ r.createElement(gt, {
826
+ text: n.content
827
+ });
828
+ case C.HTML:
829
+ return /* @__PURE__ */ r.createElement(st, g({}, n.content));
830
+ case C.Separator:
831
+ return /* @__PURE__ */ r.createElement(ut, g({}, n.content));
832
+ case C.LinkList:
833
+ return /* @__PURE__ */ r.createElement(ct, x(g({}, n.content), {
834
+ dispatch: t
835
+ }));
836
+ case C.ButtonList:
837
+ return /* @__PURE__ */ r.createElement(nt, x(g({}, n.content), {
838
+ dispatch: t
839
+ }));
840
+ case C.VideoRequest:
841
+ return /* @__PURE__ */ r.createElement(pt, x(g({}, n.content), {
842
+ dispatch: t
843
+ }));
844
+ default:
845
+ return /* @__PURE__ */ r.createElement(lt, {
846
+ type: n.type,
847
+ content: n.content
848
+ });
849
+ }
850
+ }
851
+ }), Et = a(le)`
852
+ ${ze}
853
+
854
+ > li {
855
+ margin: 0;
856
+ }
857
+ `, xt = X(
858
+ ({ className: e, timestamp: t, sender: n, type: o, content: l }, s) => {
859
+ const u = me(
860
+ (m) => {
861
+ let i = "first";
862
+ return l.length > 1 && (i = m === 0 ? "first" : m + 1 === l.length ? "last" : "middle"), i;
863
+ },
864
+ [l]
865
+ ), c = () => /* @__PURE__ */ r.createElement(r.Fragment, null, l.map((m) => {
866
+ const { key: i, body: $, title: k, form: S, actions: E } = m, p = !!$ && !k && !S && !E;
867
+ return /* @__PURE__ */ r.createElement(Xe, {
868
+ className: e,
869
+ key: i,
870
+ discrete: p,
871
+ ref: s,
872
+ timestamp: t,
873
+ fullWidth: !!S || !!E
874
+ }, p && $ ? /* @__PURE__ */ r.createElement(Y, {
875
+ html: $
876
+ }) : /* @__PURE__ */ r.createElement(F, {
877
+ isSystem: !0,
878
+ content: m
879
+ }));
880
+ })), h = () => /* @__PURE__ */ r.createElement(ue, {
881
+ sender: n,
882
+ timestamp: t,
883
+ className: e
884
+ }, /* @__PURE__ */ r.createElement(P, null, l.map((m, i) => /* @__PURE__ */ r.createElement(U, {
885
+ left: !0,
886
+ key: m.key,
887
+ ref: s
888
+ }, /* @__PURE__ */ r.createElement(F, {
889
+ content: m,
890
+ stacked: u(i)
891
+ }))))), v = () => /* @__PURE__ */ r.createElement(tt, {
892
+ timestamp: t,
893
+ className: e
894
+ }, /* @__PURE__ */ r.createElement(P, null, l.map((m, i) => /* @__PURE__ */ r.createElement(U, {
895
+ right: !0,
896
+ key: m.key,
897
+ ref: s
898
+ }, /* @__PURE__ */ r.createElement(F, {
899
+ isUser: !0,
900
+ content: m,
901
+ stacked: u(i)
902
+ })))));
903
+ switch (o) {
904
+ case D.System:
905
+ return c();
906
+ case D.Agent:
907
+ return h();
908
+ case D.User:
909
+ return v();
910
+ default:
911
+ return null;
912
+ }
913
+ }
914
+ ), F = ({ content: e, isUser: t, isSystem: n, stacked: o }) => {
915
+ const l = V(), { title: s, body: u, actions: c, form: h, items: v } = e;
916
+ return v ? /* @__PURE__ */ r.createElement(_, {
917
+ user: !!t,
918
+ stacked: o
919
+ }, /* @__PURE__ */ r.createElement(vt, {
920
+ items: v,
921
+ dispatch: l
922
+ })) : /* @__PURE__ */ r.createElement(_, {
923
+ padded: !n,
924
+ user: !!t,
925
+ stacked: o,
926
+ fullWidth: !!h || !!c
927
+ }, s && /* @__PURE__ */ r.createElement(B, null, /* @__PURE__ */ r.createElement(Pe, {
928
+ variant: "h2"
929
+ }, s)), u && /* @__PURE__ */ r.createElement(B, null, /* @__PURE__ */ r.createElement(qe, {
930
+ html: u
931
+ })), h && /* @__PURE__ */ r.createElement(B, null, /* @__PURE__ */ r.createElement(Ve, x(g({}, h), {
932
+ onChange: (i, $) => {
933
+ l("form", {
934
+ data: $,
935
+ formKey: h.schema.id,
936
+ actionKey: i
937
+ });
938
+ }
939
+ }))), c && /* @__PURE__ */ r.createElement(B, null, /* @__PURE__ */ r.createElement(Ye, {
940
+ items: Object.keys(c).map((i) => ({ label: c[i], actionKey: i })),
941
+ renderItem: (i) => /* @__PURE__ */ r.createElement("li", {
942
+ key: i.actionKey
943
+ }, /* @__PURE__ */ r.createElement(Ge, {
944
+ onClick: () => {
945
+ l("action", i.actionKey);
946
+ }
947
+ }, i.label))
948
+ })));
949
+ }, ge = () => {
950
+ const e = me((c) => {
951
+ c && setTimeout(() => {
952
+ c.scrollIntoView({
953
+ block: "start",
954
+ behavior: "smooth"
955
+ });
956
+ }, 250);
957
+ }, []), [t, n] = ae(!0), {
958
+ messages: o,
959
+ loading: l,
960
+ typingActors: s = []
961
+ } = M(), u = () => s && s.length ? s.map((c, h) => /* @__PURE__ */ r.createElement(W, {
962
+ id: `typing_${c.name}`,
963
+ key: `typing_${c.name}`
964
+ }, /* @__PURE__ */ r.createElement(ue, {
965
+ timestamp: Date.now(),
966
+ sender: c
967
+ }, /* @__PURE__ */ r.createElement(re, {
968
+ boxed: !0,
969
+ ref: e
970
+ })))) : null;
971
+ return /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(wt, {
972
+ tabIndex: 0,
973
+ scrollableCss: t,
974
+ ref: n
975
+ }, o && o.length ? o.map((c, h) => {
976
+ const { type: v, timestamp: m, sender: i, content: $ } = c;
977
+ return /* @__PURE__ */ r.createElement(W, {
978
+ className: "humany-conversation-entry",
979
+ tabIndex: -1,
980
+ key: `${v}_${i == null ? void 0 : i.name}_${m}_${$[0].key}`
981
+ }, /* @__PURE__ */ r.createElement(xt, x(g({}, c), {
982
+ ref: e
983
+ })));
984
+ }) : null, u(), l && /* @__PURE__ */ r.createElement(W, null, /* @__PURE__ */ r.createElement(re, {
985
+ ref: e
986
+ }))), /* @__PURE__ */ r.createElement(Re, null));
987
+ }, wt = a.div`
988
+ display: flex;
989
+ flex-direction: column;
990
+ align-items: stretch;
991
+ flex: 0 1 100%;
992
+ padding: 0 ${(e) => {
993
+ var t;
994
+ return (t = e.theme.sizes) == null ? void 0 : t.medium;
995
+ }};
996
+ ${(e) => !!e.scrollableCss && e.scrollableCss};
997
+ &:focus-visible {
998
+ ${(e) => b(e)};
999
+ }
1000
+ `, W = a.div`
1001
+ margin: 0;
1002
+ margin-bottom: ${(e) => {
1003
+ var t;
1004
+ return (t = e.theme.sizes) == null ? void 0 : t.medium;
1005
+ }};
1006
+
1007
+ &:first-of-type {
1008
+ margin-top: ${(e) => {
1009
+ var t;
1010
+ return (t = e.theme.sizes) == null ? void 0 : t.medium;
1011
+ }};
1012
+ }
1013
+
1014
+ &:last-of-type {
1015
+ padding-bottom: ${(e) => {
1016
+ var t;
1017
+ return (t = e.theme.sizes) == null ? void 0 : t.medium;
1018
+ }};
1019
+ }
1020
+
1021
+ & span,
1022
+ p,
1023
+ a,
1024
+ div {
1025
+ font-weight: 300;
1026
+ }
1027
+
1028
+ & b,
1029
+ h1 {
1030
+ font-weight: normal;
1031
+ }
1032
+ ${(e) => se(e)(
1033
+ "h1",
1034
+ f`
1035
+ font-weight: normal;
1036
+ `
1037
+ )}
1038
+ `, kt = ({ dispatch: e }) => {
1039
+ const t = Te(null);
1040
+ return ce(() => {
1041
+ t.current && t.current.parentNode && e("overlay-mounted", t.current);
1042
+ }, [t]), /* @__PURE__ */ r.createElement(ie, {
1043
+ portalId: "humany-conversation-overlay-portal",
1044
+ className: "humany-conversation-overlay-outlet",
1045
+ ref: t
1046
+ });
1047
+ }, Ct = ({
1048
+ dispatch: e,
1049
+ header: t,
1050
+ buttonLabel: n
1051
+ }) => /* @__PURE__ */ r.createElement(St, {
1052
+ portalId: "humany-conversation-portal",
1053
+ className: "humany-conversation-outlet"
1054
+ }, /* @__PURE__ */ r.createElement(zt, {
1055
+ className: "humany-conversation-outlet-head"
1056
+ }, /* @__PURE__ */ r.createElement(Mt, {
1057
+ className: "humany-conversation-outlet-head-button",
1058
+ "aria-label": n,
1059
+ title: n,
1060
+ onClick: () => e("hide-overlay-conversation")
1061
+ }, /* @__PURE__ */ r.createElement(w, {
1062
+ symbol: {
1063
+ type: "Svg",
1064
+ content: "caret-down"
1065
+ },
1066
+ size: 20
1067
+ })), t && /* @__PURE__ */ r.createElement(Lt, {
1068
+ className: "humany-conversation-outlet-header",
1069
+ variant: "h1"
1070
+ }, t)), /* @__PURE__ */ r.createElement(ge, null)), St = a(ie)`
1071
+ z-index: 11;
1072
+ top: auto;
1073
+ height: 65%;
1074
+ background-color: #ffffff;
1075
+ display: flex;
1076
+ flex-direction: column;
1077
+ border-top-right-radius: ${(e) => {
1078
+ var t;
1079
+ return (t = e.theme.sizes) == null ? void 0 : t.large;
1080
+ }};
1081
+ border-top-left-radius: ${(e) => {
1082
+ var t;
1083
+ return (t = e.theme.sizes) == null ? void 0 : t.large;
1084
+ }};
1085
+ `, zt = a.div`
1086
+ display: flex;
1087
+ flex-direction: column;
1088
+ justify-content: center;
1089
+ align-items: center;
1090
+ gap: ${(e) => {
1091
+ var t;
1092
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
1093
+ }};
1094
+ padding: ${(e) => {
1095
+ var t;
1096
+ return (t = e.theme.sizes) == null ? void 0 : t.normal;
1097
+ }};
1098
+ ${(e) => e.theme.border && `border-bottom: ${e.theme.border};`}
1099
+ `, Lt = a(q)`
1100
+ font-size: ${(e) => {
1101
+ var t;
1102
+ return (t = e.theme.fonts) == null ? void 0 : t.medium;
1103
+ }};
1104
+ color: ${(e) => {
1105
+ var t;
1106
+ return (t = e.theme.colors) == null ? void 0 : t.text;
1107
+ }};
1108
+ margin: 0;
1109
+ `, Mt = a(L)`
1110
+ display: flex;
1111
+ align-items: center;
1112
+ justify-content: center;
1113
+ padding: ${(e) => {
1114
+ var t;
1115
+ return (t = e.theme.sizes) == null ? void 0 : t.small;
1116
+ }} ${(e) => {
1117
+ var t;
1118
+ return (t = e.theme.sizes) == null ? void 0 : t.medium;
1119
+ }};
1120
+ ${(e) => e.theme.borderRadius && `border-radius: ${e.theme.borderRadius};`}
1121
+
1122
+ &:focus-visible {
1123
+ ${b};
1124
+ }
1125
+
1126
+ svg line {
1127
+ stroke: ${(e) => {
1128
+ var t;
1129
+ return (t = e.theme.colors) == null ? void 0 : t.text;
1130
+ }};
1131
+ }
1132
+ `, Wt = (n) => {
1133
+ var o = n, { className: e } = o, t = j(o, ["className"]);
1134
+ const {
1135
+ overlay: l,
1136
+ overlayConversationHeader: s,
1137
+ overlayConversationCloseLabel: u,
1138
+ conversationControllerId: c
1139
+ } = M(), h = V();
1140
+ return /* @__PURE__ */ r.createElement(Le.Provider, {
1141
+ value: c ? { id: c } : null
1142
+ }, /* @__PURE__ */ r.createElement(Ht, x(g({}, t), {
1143
+ className: H(e, "humany-conversation-component")
1144
+ }), /* @__PURE__ */ r.createElement(ge, null)), l && /* @__PURE__ */ r.createElement(r.Fragment, null, /* @__PURE__ */ r.createElement(kt, {
1145
+ dispatch: h
1146
+ }), l.conversation && /* @__PURE__ */ r.createElement(Ct, {
1147
+ dispatch: h,
1148
+ header: s,
1149
+ buttonLabel: u
1150
+ })));
1151
+ }, Ht = a.div`
1152
+ position: absolute;
1153
+ right: 0;
1154
+ left: 0;
1155
+ bottom: 0;
1156
+ top: 0;
1157
+ overflow: hidden;
1158
+ display: flex;
1159
+ flex-direction: column;
1160
+ `;
1161
+ export {
1162
+ Wt as default
1163
+ };
1164
+ //# sourceMappingURL=conversation.fe5da693.js.map