@telia-ace/widget-conversation 1.0.34-experimental.2 → 1.0.34-experimental.21

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