@telia-ace/widget-conversation 1.1.2-rc.2 → 1.1.2-rc.3

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