@telia-ace/widget-conversation 1.1.2-rc.1 → 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,1411 +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(V, { padded: !!e, stacked: e ? "first" : void 0, children: /* @__PURE__ */ m(Re, { children: [
459
- /* @__PURE__ */ n("div", {}),
460
- /* @__PURE__ */ n("div", {}),
461
- /* @__PURE__ */ n("div", {})
462
- ] }) }) }) })
463
- ), Pe = s.p`
464
- && {
465
- font-size: ${(e) => {
466
- var t;
467
- return (t = e.theme.fonts) == null ? void 0 : t.small;
468
- }};
469
- font-weight: 300;
470
- }
471
- margin: 0;
472
- line-height: 1.5em;
473
- grid-area: info;
474
- color: ${(e) => {
475
- var t;
476
- return (t = e.theme.colors) == null ? void 0 : t.text;
477
- }};
478
- `, ee = (e) => new Date(e).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }), B = ({ className: e, name: t, timestamp: o }) => {
479
- if (!t && !o)
480
- return null;
481
- let r = "";
482
- return t ? o ? r = `${t}: ${ee(o)}` : r = t : o && (r = ee(o)), /* @__PURE__ */ n(Pe, { children: r });
483
- }, le = ({
484
- className: e,
485
- children: t,
486
- sender: o,
487
- timestamp: r
488
- }) => {
489
- const { avatar: a, name: i } = o, { avatarSize: u } = I();
490
- return /* @__PURE__ */ m(
491
- Ue,
492
- {
493
- hasAvatar: !!a,
494
- className: M(
495
- e,
496
- "humany-conversation-agent-message"
497
- ),
498
- children: [
499
- a && /* @__PURE__ */ n(Ae, { avatarSize: u, children: typeof a == "string" ? (
500
- // eslint-disable-next-line jsx-a11y/alt-text
501
- /* @__PURE__ */ n("img", { src: a })
502
- ) : /* @__PURE__ */ n(v, { symbol: a }) }),
503
- t,
504
- /* @__PURE__ */ n(B, { name: i, timestamp: r })
505
- ]
506
- }
507
- );
508
- }, Ue = s.div`
509
- display: grid;
510
- margin-right: 10%;
511
- width: 90%;
512
- ${(e) => e.hasAvatar ? g`
513
- grid-template-columns: auto 1fr;
514
- grid-template-rows: 1fr auto;
515
- grid-template-areas:
516
- 'avatar content'
517
- '. info';
518
- ` : g`
519
- grid-template-columns: 1fr;
520
- grid-template-rows: 1fr auto;
521
- grid-template-areas:
522
- 'content'
523
- 'info';
524
- `};
525
- `, _e = Q(
526
- ({ className: e, children: t, timestamp: o, discrete: r, fullWidth: a }, i) => /* @__PURE__ */ n(
527
- Ve,
528
- {
529
- ref: i,
530
- className: M(e, "humany-conversation-system-message"),
531
- fullWidth: a,
532
- children: r ? /* @__PURE__ */ m(qe, { className: "humany-conversation-discrete-message", children: [
533
- t,
534
- /* @__PURE__ */ n(B, { timestamp: o })
535
- ] }) : /* @__PURE__ */ m(R, { children: [
536
- t,
537
- /* @__PURE__ */ n(B, { timestamp: o })
538
- ] })
539
- }
540
- )
541
- ), Ve = s.div`
542
- ${(e) => e.fullWidth && "width: 100%"};
543
- padding: 0 ${(e) => {
544
- var t;
545
- return (t = e.theme.sizes) == null ? void 0 : t.large;
546
- }};
547
- overflow: auto;
548
- `, qe = s.div`
549
- text-align: center;
550
- word-wrap: break-word;
551
- font-size: ${(e) => {
552
- var t;
553
- return (t = e.theme.fonts) == null ? void 0 : t.normal;
554
- }};
555
- color: ${(e) => {
556
- var t;
557
- return (t = e.theme.colors) == null ? void 0 : t.text;
558
- }};
559
- > p {
560
- margin: 0;
561
- }
562
- `, Ye = ({ className: e, children: t, timestamp: o }) => {
563
- const { userLabel: r = "" } = I();
564
- return /* @__PURE__ */ m(
565
- Ge,
566
- {
567
- className: M(e, "humany-conversation-user-message"),
568
- children: [
569
- t,
570
- /* @__PURE__ */ n(B, { name: r, timestamp: o })
571
- ]
572
- }
573
- );
574
- }, Ge = s.div`
575
- margin-left: 10%;
576
- width: 90%;
577
- display: flex;
578
- flex-direction: column;
579
- align-items: flex-end;
580
- `, X = (e) => Array.isArray(e) ? e : Object.keys(e).map((t) => ({
581
- label: e[t],
582
- actionKey: t
583
- })), Je = ({ header: e, actions: t, dispatch: o }) => /* @__PURE__ */ n(
584
- Qe,
585
- {
586
- className: "humany-conversation-button-list",
587
- header: e,
588
- items: X(t),
589
- renderItem: (r) => {
590
- var i;
591
- const a = !!((i = r == null ? void 0 : r.data) != null && i.href);
592
- return /* @__PURE__ */ n("li", { children: a ? /* @__PURE__ */ m(
593
- Xe,
594
- {
595
- onClick: () => {
596
- o("action", r);
597
- },
598
- href: r.data.href,
599
- target: r.data.target,
600
- "aria-label": r.label,
601
- title: r.label,
602
- children: [
603
- /* @__PURE__ */ n(v, { symbol: r.symbol }),
604
- r.label
605
- ]
606
- }
607
- ) : /* @__PURE__ */ m(
608
- Ze,
609
- {
610
- onClick: () => {
611
- o("action", r);
612
- },
613
- "aria-label": r.label,
614
- title: r.label,
615
- children: [
616
- /* @__PURE__ */ n(v, { symbol: r.symbol }),
617
- r.label
618
- ]
619
- }
620
- ) }, r.actionKey);
621
- }
622
- }
623
- ), Qe = s(j)`
624
- ${O}
625
- > ul {
626
- display: flex;
627
- flex-wrap: wrap;
628
- gap: ${(e) => {
629
- var t;
630
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
631
- }};
632
- > li {
633
- margin: 0;
634
- }
635
- }
636
- ${C}
637
- `, Xe = s(ye)`
638
- ${K};
639
-
640
- display: block;
641
- padding: ${(e) => {
642
- var t;
643
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
644
- }};
645
- background-color: ${(e) => {
646
- var t;
647
- return (t = e.theme.colors) == null ? void 0 : t.primary;
648
- }};
649
- width: 100%;
650
- color: #ffffff;
651
- overflow: hidden;
652
- text-overflow: ellipsis;
653
- &:focus-visible {
654
- ${f}
655
- background-color: transparent;
656
- }
657
-
658
- i,
659
- svg {
660
- margin-right: ${(e) => {
661
- var t;
662
- return (t = e.theme.sizes) == null ? void 0 : t.small;
663
- }};
664
- }
665
- `, Ze = s(z)`
666
- ${K};
667
-
668
- display: block;
669
- padding: ${(e) => {
670
- var t;
671
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
672
- }};
673
- background-color: ${(e) => {
674
- var t;
675
- return (t = e.theme.colors) == null ? void 0 : t.primary;
676
- }};
677
- width: 100%;
678
- color: #ffffff;
679
- overflow: hidden;
680
- text-overflow: ellipsis;
681
- &:focus-visible {
682
- ${f}
683
- background-color: transparent;
684
- }
685
-
686
- i,
687
- svg {
688
- margin-right: ${(e) => {
689
- var t;
690
- return (t = e.theme.sizes) == null ? void 0 : t.small;
691
- }};
692
- }
693
- `, et = ({ type: e, content: t = {} }) => {
694
- const o = be(e);
695
- return !o || !e ? null : /* @__PURE__ */ n(ke, { fallback: null, children: /* @__PURE__ */ n(o, { ...t }) });
696
- }, tt = ({ body: e }) => /* @__PURE__ */ n(nt, { html: e }), nt = s(G)`
697
- ${$e}
698
- color: inherit;
699
- white-space: pre-wrap;
700
- ${C}
701
- a {
702
- color: ${(e) => e.theme.colors.link};
703
- &:focus-visible {
704
- ${f};
705
- }
706
- }
707
- `, rt = ({ header: e, actions: t, dispatch: o }) => /* @__PURE__ */ n(
708
- ot,
709
- {
710
- className: "humany-conversation-item-list",
711
- header: e,
712
- items: X(t),
713
- renderItem: (r) => {
714
- var a;
715
- return /* @__PURE__ */ n("li", { children: /* @__PURE__ */ m(st, { children: [
716
- ((a = r.symbol) == null ? void 0 : a.content) && /* @__PURE__ */ n("div", { className: "item-icon", children: /* @__PURE__ */ n(
717
- v,
718
- {
719
- size: 22,
720
- symbol: {
721
- type: r.symbol.type,
722
- content: r.symbol.content
723
- }
724
- }
725
- ) }),
726
- /* @__PURE__ */ m("div", { className: "item-body", children: [
727
- /* @__PURE__ */ n(
728
- z,
729
- {
730
- onClick: () => {
731
- o("action", r);
732
- },
733
- "aria-label": r.label,
734
- title: r.label,
735
- children: r.label
736
- }
737
- ),
738
- r.description && /* @__PURE__ */ n("p", { children: r.description })
739
- ] })
740
- ] }) }, r.actionKey);
741
- }
742
- }
743
- ), ot = s(j)`
744
- ${O}
745
-
746
- > .humany-paragraph {
747
- ${C}
748
- margin-bottom: 0;
749
-
750
- h1 {
751
- margin: 0;
752
- }
753
- }
754
-
755
- ${(e) => J(e)(
756
- "h1",
757
- g`
758
- white-space: normal;
759
- `
760
- )}
761
-
762
- > ul {
763
- display: flex;
764
- flex-direction: column;
765
- gap: ${(e) => {
766
- var t;
767
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
768
- }};
769
- > li {
770
- margin: 0;
771
- }
772
- }
773
-
774
- li {
775
- border-bottom: ${(e) => e.theme.border};
776
-
777
- &:last-of-type {
778
- border-bottom: none;
779
- }
780
- }
781
- `, st = s.div`
782
- display: flex;
783
- gap: ${(e) => {
784
- var t;
785
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
786
- }};
787
- ${C}
788
-
789
- .item-icon {
790
- }
791
-
792
- .item-body {
793
- display: flex;
794
- flex-direction: column;
795
- align-items: flex-start;
796
- gap: ${(e) => {
797
- var t;
798
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
799
- }};
800
-
801
- p {
802
- margin: 0;
803
- white-space: normal;
804
- }
805
- }
806
-
807
- button {
808
- background: transparent;
809
- border: none;
810
- font-family: inherit;
811
- font-size: ${(e) => {
812
- var t;
813
- return (t = e.theme.fonts) == null ? void 0 : t.normal;
814
- }};
815
- cursor: pointer;
816
- padding: 0;
817
- margin: 0;
818
-
819
- &:focus-visible {
820
- ${f}
821
- span {
822
- color: ${(e) => {
823
- var t;
824
- return (t = e.theme.colors) == null ? void 0 : t.primary;
825
- }};
826
- text-decoration: underline;
827
- }
828
- }
829
- }
830
- `, at = ({ header: e, actions: t, dispatch: o }) => /* @__PURE__ */ n(
831
- it,
832
- {
833
- className: "humany-conversation-link-list",
834
- header: e,
835
- items: X(t),
836
- renderItem: (r) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ m(
837
- lt,
838
- {
839
- help: r.actionKey === "help",
840
- onClick: () => {
841
- o("action", r);
842
- },
843
- "aria-label": r.label,
844
- title: r.label,
845
- children: [
846
- r.label,
847
- r.actionKey === "help" && /* @__PURE__ */ n(
848
- v,
849
- {
850
- size: 14,
851
- symbol: {
852
- type: "Svg",
853
- content: "caret-down"
854
- }
855
- }
856
- )
857
- ]
858
- }
859
- ) }, r.actionKey)
860
- }
861
- ), it = s(j)`
862
- ${O}
863
- ${C}
864
-
865
- ${(e) => J(e)(
866
- "h1",
867
- g`
868
- white-space: normal;
869
- `
870
- )}
871
-
872
- > ul {
873
- display: flex;
874
- flex-direction: column;
875
- gap: ${(e) => {
876
- var t;
877
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
878
- }};
879
- > li {
880
- margin: 0;
881
- }
882
- }
883
- `, lt = s(z)`
884
- display: block;
885
- text-align: left;
886
- font-weight: 300;
887
- color: ${(e) => {
888
- var t;
889
- return (t = e.theme.colors) == null ? void 0 : t.primary;
890
- }};
891
- max-width: 100%;
892
- text-overflow: ellipsis;
893
- overflow: hidden;
894
-
895
- ${(e) => {
896
- var t, o;
897
- return e.help && g`
898
- color: ${(t = e.theme.colors) == null ? void 0 : t.text};
899
- text-decoration: underline;
900
-
901
- i,
902
- svg {
903
- margin-left: ${(o = e.theme.sizes) == null ? void 0 : o.small};
904
- }
905
- `;
906
- }}
907
-
908
- &:focus-visible {
909
- ${f}
910
- span {
911
- color: ${(e) => {
912
- var t;
913
- return (t = e.theme.colors) == null ? void 0 : t.primary;
914
- }};
915
- text-decoration: underline;
916
- }
917
- }
918
- `, ct = () => /* @__PURE__ */ n(dt, { className: "humany-conversation-separator" }), dt = s.div`
919
- ${(e) => e.theme.border && `border-bottom: ${e.theme.border};`}
920
- width: 100%;
921
- `, mt = ({ text: e }) => /* @__PURE__ */ n(ht, { className: "humany-conversation-text", variant: "span", children: e }), ht = s(Y)`
922
- ${C}
923
- `, ut = ({
924
- header: e = "Video call",
925
- acceptLabel: t = "Accept",
926
- declineLabel: o = "Decline",
927
- dispatch: r
928
- }) => {
929
- const a = Ce(() => [
930
- {
931
- label: t,
932
- actionKey: "accept-video-call",
933
- symbol: {
934
- type: "Svg",
935
- content: "video"
936
- }
937
- },
938
- {
939
- label: o,
940
- actionKey: "decline-video-call",
941
- symbol: {
942
- type: "Svg",
943
- content: "close"
944
- }
945
- }
946
- ], [t, o]);
947
- return /* @__PURE__ */ n(
948
- gt,
949
- {
950
- className: "humany-conversation-video-request",
951
- header: e,
952
- items: a,
953
- renderItem: (i) => {
954
- const u = i.actionKey === "accept-video-call" ? "#70c48e" : "#da5c85";
955
- return /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(
956
- ft,
957
- {
958
- onClick: () => {
959
- r("action", i);
960
- },
961
- "aria-label": i.label,
962
- title: i.label,
963
- bgColor: u,
964
- children: /* @__PURE__ */ n(v, { symbol: i.symbol, size: 25 })
965
- }
966
- ) }, i.actionKey);
967
- }
968
- }
969
- );
970
- }, gt = s(j)`
971
- ${(e) => O(e)}
972
- > ul {
973
- display: flex;
974
- flex-wrap: wrap;
975
- gap: ${(e) => {
976
- var t;
977
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
978
- }};
979
- > li {
980
- margin: 0;
981
- }
982
- }
983
- ${(e) => C(e)}
984
- `, ft = s(z)`
985
- ${K};
986
-
987
- background-color: ${(e) => e.bgColor};
988
- display: flex;
989
- justify-content: center;
990
- align-items: center;
991
- color: #ffffff;
992
- width: 46px;
993
- height: 46px;
994
- border-radius: 100%;
995
-
996
- &:focus-visible {
997
- ${f}
998
- background-color: transparent;
999
-
1000
- i,
1001
- svg {
1002
- color: ${(e) => {
1003
- var t;
1004
- return (t = e.theme.colors) == null ? void 0 : t.primary;
1005
- }};
1006
-
1007
- path {
1008
- stroke: ${(e) => {
1009
- var t;
1010
- return (t = e.theme.colors) == null ? void 0 : t.primary;
1011
- }};
1012
- }
1013
- }
1014
- }
1015
-
1016
- i,
1017
- svg {
1018
- color: #fff;
1019
-
1020
- path {
1021
- stroke: #fff;
1022
- }
1023
- }
1024
- `, pt = ([e, t]) => ({ type: e, content: t }), yt = ({ items: e, dispatch: t }) => /* @__PURE__ */ n(
1025
- bt,
1026
- {
1027
- className: "humany-message-list",
1028
- items: e.map(pt),
1029
- renderLi: !0,
1030
- renderItem: (o) => {
1031
- switch (o.type) {
1032
- case k.Text:
1033
- return /* @__PURE__ */ n(mt, { text: o.content });
1034
- case k.HTML:
1035
- return /* @__PURE__ */ n(tt, { ...o.content });
1036
- case k.Separator:
1037
- return /* @__PURE__ */ n(ct, { ...o.content });
1038
- case k.ItemList:
1039
- return /* @__PURE__ */ n(rt, { ...o.content, dispatch: t });
1040
- case k.LinkList:
1041
- return /* @__PURE__ */ n(at, { ...o.content, dispatch: t });
1042
- case k.ButtonList:
1043
- return /* @__PURE__ */ n(Je, { ...o.content, dispatch: t });
1044
- case k.VideoRequest:
1045
- return /* @__PURE__ */ n(ut, { ...o.content, dispatch: t });
1046
- default:
1047
- return /* @__PURE__ */ n(et, { type: o.type, content: o.content });
1048
- }
1049
- }
1050
- }
1051
- ), bt = s(re)`
1052
- ${ve}
1053
-
1054
- > li {
1055
- margin: 0;
1056
- }
1057
- `, $t = Q(
1058
- ({ className: e, timestamp: t, sender: o, type: r, content: a }, i) => {
1059
- const u = ae(
1060
- (d) => {
1061
- let l = "first";
1062
- return a.length > 1 && (l = d === 0 ? "first" : d + 1 === a.length ? "last" : "middle"), l;
1063
- },
1064
- [a]
1065
- ), c = () => /* @__PURE__ */ n(R, { children: a.map((d) => {
1066
- const { key: l, body: $, title: S, form: L, actions: w } = d, y = !!$ && !S && !L && !w;
1067
- return /* @__PURE__ */ n(
1068
- _e,
1069
- {
1070
- className: e,
1071
- discrete: y,
1072
- ref: i,
1073
- timestamp: t,
1074
- fullWidth: !!L || !!w,
1075
- children: y && $ ? /* @__PURE__ */ n(G, { html: $ }) : /* @__PURE__ */ n(F, { isSystem: !0, content: d })
1076
- },
1077
- l
1078
- );
1079
- }) }), p = () => /* @__PURE__ */ n(le, { sender: o, timestamp: t, className: e, children: /* @__PURE__ */ n(U, { className: "humany-message-content-bundle", children: a.map((d, l) => /* @__PURE__ */ n(
1080
- _,
1081
- {
1082
- className: "humany-message-container",
1083
- left: !0,
1084
- ref: i,
1085
- children: /* @__PURE__ */ n(
1086
- F,
1087
- {
1088
- content: d,
1089
- stacked: u(l)
1090
- }
1091
- )
1092
- },
1093
- d.key
1094
- )) }) }), x = () => /* @__PURE__ */ n(Ye, { timestamp: t, className: e, children: /* @__PURE__ */ n(U, { className: "humany-message-content-bundle", children: a.map((d, l) => /* @__PURE__ */ n(
1095
- _,
1096
- {
1097
- className: "humany-message-container",
1098
- right: !0,
1099
- ref: i,
1100
- children: /* @__PURE__ */ n(
1101
- F,
1102
- {
1103
- isUser: !0,
1104
- content: d,
1105
- stacked: u(l)
1106
- }
1107
- )
1108
- },
1109
- d.key
1110
- )) }) });
1111
- switch (r) {
1112
- case E.System:
1113
- return c();
1114
- case E.Agent:
1115
- return p();
1116
- case E.User:
1117
- return x();
1118
- default:
1119
- return null;
1120
- }
1121
- }
1122
- ), F = ({ content: e, isUser: t, isSystem: o, stacked: r }) => {
1123
- const a = q(), { title: i, body: u, actions: c, form: p, items: x } = e;
1124
- return x ? /* @__PURE__ */ n(V, { className: "humany-message-content", user: !!t, stacked: r, children: /* @__PURE__ */ n(yt, { items: x, dispatch: a }) }) : /* @__PURE__ */ m(
1125
- V,
1126
- {
1127
- className: "humany-message-content",
1128
- padded: !o,
1129
- user: !!t,
1130
- stacked: r,
1131
- fullWidth: !!p || !!c,
1132
- children: [
1133
- i && /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(Ke, { variant: "h2", children: i }) }),
1134
- u && /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(We, { html: u }) }),
1135
- p && /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(
1136
- De,
1137
- {
1138
- ...p,
1139
- onChange: (l, $) => {
1140
- a("form", {
1141
- data: $,
1142
- formKey: p.schema.id,
1143
- actionKey: l
1144
- });
1145
- }
1146
- }
1147
- ) }),
1148
- c && /* @__PURE__ */ n(A, { children: /* @__PURE__ */ n(
1149
- Ee,
1150
- {
1151
- items: Object.keys(c).map((l) => ({ label: c[l], actionKey: l })),
1152
- renderItem: (l) => /* @__PURE__ */ n("li", { children: /* @__PURE__ */ n(
1153
- Fe,
1154
- {
1155
- onClick: () => {
1156
- a("action", l.actionKey);
1157
- },
1158
- children: l.label
1159
- }
1160
- ) }, l.actionKey)
1161
- }
1162
- ) })
1163
- ]
1164
- }
1165
- );
1166
- }, ce = () => {
1167
- const e = ae((c) => {
1168
- c && setTimeout(() => {
1169
- c.scrollIntoView({
1170
- block: "start",
1171
- behavior: "smooth"
1172
- });
1173
- }, 250);
1174
- }, []), [t, o] = ne(!0), {
1175
- messages: r,
1176
- loading: a,
1177
- typingActors: i = []
1178
- } = I(), u = () => i && i.length ? i.map((c, p) => /* @__PURE__ */ n(P, { id: `typing_${c.name}`, children: /* @__PURE__ */ n(le, { timestamp: Date.now(), sender: c, children: /* @__PURE__ */ n(Z, { boxed: !0, ref: e }) }) }, `typing_${c.name}`)) : null;
1179
- return /* @__PURE__ */ m(R, { children: [
1180
- /* @__PURE__ */ m(vt, { tabIndex: 0, scrollableCss: t, ref: o, children: [
1181
- r && r.length ? r.map((c, p) => {
1182
- const { type: x, timestamp: d, sender: l, content: $ } = c;
1183
- return /* @__PURE__ */ n(
1184
- P,
1185
- {
1186
- className: "humany-conversation-entry",
1187
- tabIndex: -1,
1188
- children: /* @__PURE__ */ n($t, { ...c, ref: e })
1189
- },
1190
- `${x}_${l == null ? void 0 : l.name}_${d}_${$[0].key}`
1191
- );
1192
- }) : null,
1193
- u(),
1194
- a && /* @__PURE__ */ n(P, { children: /* @__PURE__ */ n(Z, { ref: e }) })
1195
- ] }),
1196
- /* @__PURE__ */ n(Le, {})
1197
- ] });
1198
- }, vt = s.div`
1199
- display: flex;
1200
- flex-direction: column;
1201
- align-items: stretch;
1202
- flex: 0 1 100%;
1203
- padding: 0 ${(e) => {
1204
- var t;
1205
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
1206
- }};
1207
- ${(e) => !!e.scrollableCss && e.scrollableCss};
1208
- &:focus-visible {
1209
- ${(e) => f(e)};
1210
- }
1211
- `, P = s.div`
1212
- margin: 0;
1213
- margin-bottom: ${(e) => {
1214
- var t;
1215
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
1216
- }};
1217
-
1218
- &:first-of-type {
1219
- margin-top: ${(e) => {
1220
- var t;
1221
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
1222
- }};
1223
- }
1224
-
1225
- &:last-of-type {
1226
- padding-bottom: ${(e) => {
1227
- var t;
1228
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
1229
- }};
1230
- }
1231
-
1232
- & span,
1233
- p,
1234
- a,
1235
- div {
1236
- font-weight: 300;
1237
- }
1238
-
1239
- & b,
1240
- h1 {
1241
- font-weight: normal;
1242
- }
1243
- ${(e) => J(e)(
1244
- "h1",
1245
- g`
1246
- font-weight: normal;
1247
- `
1248
- )}
1249
- `, xt = ({ dispatch: e }) => {
1250
- const t = Se(null);
1251
- return se(() => {
1252
- t.current && t.current.parentNode && e("overlay-mounted", t.current);
1253
- }, [t]), /* @__PURE__ */ n(
1254
- oe,
1255
- {
1256
- portalId: "humany-conversation-overlay-portal",
1257
- className: "humany-conversation-overlay-outlet",
1258
- ref: t
1259
- }
1260
- );
1261
- }, wt = ({
1262
- dispatch: e,
1263
- header: t,
1264
- buttonLabel: o
1265
- }) => /* @__PURE__ */ m(
1266
- kt,
1267
- {
1268
- portalId: "humany-conversation-portal",
1269
- className: "humany-conversation-outlet",
1270
- children: [
1271
- /* @__PURE__ */ m(Ct, { className: "humany-conversation-outlet-head", children: [
1272
- /* @__PURE__ */ n(
1273
- zt,
1274
- {
1275
- className: "humany-conversation-outlet-head-button",
1276
- "aria-label": o,
1277
- title: o,
1278
- onClick: () => e("hide-overlay-conversation"),
1279
- children: /* @__PURE__ */ n(
1280
- v,
1281
- {
1282
- symbol: {
1283
- type: "Svg",
1284
- content: "caret-down"
1285
- },
1286
- size: 20
1287
- }
1288
- )
1289
- }
1290
- ),
1291
- t && /* @__PURE__ */ n(
1292
- St,
1293
- {
1294
- className: "humany-conversation-outlet-header",
1295
- variant: "h1",
1296
- children: t
1297
- }
1298
- )
1299
- ] }),
1300
- /* @__PURE__ */ n(ce, {})
1301
- ]
1302
- }
1303
- ), kt = s(oe)`
1304
- z-index: 11;
1305
- top: auto;
1306
- height: 65%;
1307
- background-color: #ffffff;
1308
- display: flex;
1309
- flex-direction: column;
1310
- border-top-right-radius: ${(e) => {
1311
- var t;
1312
- return (t = e.theme.sizes) == null ? void 0 : t.large;
1313
- }};
1314
- border-top-left-radius: ${(e) => {
1315
- var t;
1316
- return (t = e.theme.sizes) == null ? void 0 : t.large;
1317
- }};
1318
- `, Ct = s.div`
1319
- display: flex;
1320
- flex-direction: column;
1321
- justify-content: center;
1322
- align-items: center;
1323
- gap: ${(e) => {
1324
- var t;
1325
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
1326
- }};
1327
- padding: ${(e) => {
1328
- var t;
1329
- return (t = e.theme.sizes) == null ? void 0 : t.normal;
1330
- }};
1331
- ${(e) => e.theme.border && `border-bottom: ${e.theme.border};`}
1332
- `, St = s(Y)`
1333
- font-size: ${(e) => {
1334
- var t;
1335
- return (t = e.theme.fonts) == null ? void 0 : t.medium;
1336
- }};
1337
- color: ${(e) => {
1338
- var t;
1339
- return (t = e.theme.colors) == null ? void 0 : t.text;
1340
- }};
1341
- margin: 0;
1342
- `, zt = s(z)`
1343
- display: flex;
1344
- align-items: center;
1345
- justify-content: center;
1346
- padding: ${(e) => {
1347
- var t;
1348
- return (t = e.theme.sizes) == null ? void 0 : t.small;
1349
- }} ${(e) => {
1350
- var t;
1351
- return (t = e.theme.sizes) == null ? void 0 : t.medium;
1352
- }};
1353
- ${(e) => e.theme.borderRadius && `border-radius: ${e.theme.borderRadius};`}
1354
-
1355
- &:focus-visible {
1356
- ${f};
1357
- }
1358
-
1359
- svg line {
1360
- stroke: ${(e) => {
1361
- var t;
1362
- return (t = e.theme.colors) == null ? void 0 : t.text;
1363
- }};
1364
- }
1365
- `, Dt = ({ className: e, ...t }) => {
1366
- const {
1367
- overlay: o,
1368
- overlayConversationHeader: r,
1369
- overlayConversationCloseLabel: a,
1370
- conversationControllerId: i
1371
- } = I(), u = q();
1372
- return /* @__PURE__ */ m(
1373
- xe.Provider,
1374
- {
1375
- value: i ? { id: i } : null,
1376
- children: [
1377
- /* @__PURE__ */ n(
1378
- Lt,
1379
- {
1380
- ...t,
1381
- className: M(e, "humany-conversation-component"),
1382
- children: /* @__PURE__ */ n(ce, {})
1383
- }
1384
- ),
1385
- o && /* @__PURE__ */ m(R, { children: [
1386
- /* @__PURE__ */ n(xt, { dispatch: u }),
1387
- o.conversation && /* @__PURE__ */ n(
1388
- wt,
1389
- {
1390
- dispatch: u,
1391
- header: r,
1392
- buttonLabel: a
1393
- }
1394
- )
1395
- ] })
1396
- ]
1397
- }
1398
- );
1399
- }, Lt = s.div`
1400
- position: absolute;
1401
- right: 0;
1402
- left: 0;
1403
- bottom: 0;
1404
- top: 0;
1405
- overflow: hidden;
1406
- display: flex;
1407
- flex-direction: column;
1408
- `;
1409
- export {
1410
- Dt as default
1411
- };