@telia-ace/widget-conversation 1.0.24 → 1.0.27

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