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

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,588 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),a=require("@emotion/styled"),r=require("@telia-ace/widget-ui"),L=require("@telia-ace/widget-utilities"),y=require("@emotion/react"),g=require("react"),G=require("@telia-ace/widget-forms"),x=require("./index.js");require("@telia-ace/widget-core");require("@telia-ace/widget-services");require("@telia-ace/widget-plugins");const J=({className:e})=>{const[t,o]=g.useState(""),[n,i]=g.useState(!1),[l,h]=g.useState(0),[d,p]=g.useState(0),v=r.useIsTabbing(),m=r.useDispatch(),{inputPlaceholder:c="Type your message",inputHidden:$=!1,inputDisabled:w=!1,sendButtonLabel:C="Send message",inputMultiline:j=!0,secondaryAction:b}=r.useProperties(),[W,f]=r.useScroll(!0);g.useEffect(()=>{if(f.current){const{lineHeight:u,maxHeight:z}=getComputedStyle(f.current);if(u&&u.indexOf("px")>-1){const k=u.split("px"),V=parseInt(k[0],10);h(V);const Y=z.split("px");p(parseInt(Y[0],10))}}},[f.current]);const M=u=>{!u.shiftKey||!j?(u.preventDefault(),t&&t.length>0&&(m("user-submit",{text:t}),o(""),N(""))):t.length<1&&u.preventDefault()},U=u=>{b&&(u.preventDefault(),m("action",{actionKey:b.action,...b}))},_=u=>{if(j&&f.current){const z=f.current.scrollHeight;if(z>l){f.current.style.height="auto";let k=z;u.length<1&&(k=l),f.current.style.height=`${k}px`,k>=d?f.current.style.overflowY="scroll":f.current.style.overflowY="hidden"}}},N=u=>{_(u),o(u),u&&u.length>0&&m("user-typing",{textLength:u.length})};return $?null:s.jsxs(ee,{grow:j,className:L.appendClassNames("humany-conversation-input",e),"data-has-focus":n,scrollableCss:W,isTabbing:v,children:[b&&s.jsx(Z,{disabled:w,onClick:U,title:b.label,"aria-label":b.label,children:s.jsx(r.SymbolBadge,{size:24,symbol:{type:"Svg",content:b.icon||"browse"}})}),j?s.jsx(Q,{value:t,onChange:N,onEnter:M,disabled:w,"aria-label":c,placeholder:c,onFocusChange:i,type:"textarea",rows:1,ref:f}):s.jsx(X,{value:t,onChange:N,onEnter:M,disabled:w,"aria-label":c,placeholder:c,onFocusChange:i}),s.jsx(F,{disabled:w,onClick:M,title:C,"aria-label":C,children:s.jsx(te,{size:22,symbol:{type:"Svg",content:"send"},hasContent:!!t&&!!t.length})})]})},Q=a(r.Input)`
2
- resize: none;
3
- flex: 1;
4
- flex-shrink: 1;
5
- min-height: 1.2em;
6
- max-height: 148px;
7
- line-height: 1.2em;
8
- height: 1.2em;
9
- padding: 0;
10
- margin: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
11
- font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
12
- border: none;
13
- transition: height 200ms linear;
14
- outline: none;
15
- `,X=a(r.Input)`
16
- flex: 1;
17
- border: none;
18
- background-color: transparent;
19
- font-weight: 300;
20
- font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
21
- line-height: 1.2em;
22
- outline: none;
23
- padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
24
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
25
- &::placeholder {
26
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.textLight}};
27
- font-style: italic;
28
- }
29
- `,F=a(r.Button)`
30
- flex: 0 0 50px;
31
- align-self: stretch;
32
- background-color: transparent;
33
- display: flex;
34
- align-items: center;
35
- justify-content: center;
36
- border: none;
37
- color: #a6a6a6;
38
- &:focus-visible {
39
- ${r.borderTabStyle};
40
- }
41
- `,Z=a(F)`
42
- border-right: ${e=>e.theme.border};
43
- margin: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}} 0;
44
- `,ee=a.div`
45
- ${e=>e.grow?y.css`
46
- min-height: 50px;
47
- max-height: 150px;
48
- `:y.css`
49
- height: 50px;
50
- `}
51
- flex: 0 0 auto;
52
- display: flex;
53
- align-items: center;
54
- background-color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.accent}};
55
- border-top: ${e=>e.theme.inputBorder};
56
- ${e=>e["data-has-focus"]&&e.isTabbing&&r.borderTabStyle}
57
- textarea {
58
- ${e=>!!e.scrollableCss&&e.scrollableCss}
59
- }
60
- `,te=a(({hasContent:e,...t})=>s.jsx(r.SymbolBadge,{...t}))`
61
- line,
62
- path {
63
- stroke: ${e=>{var t;return e.hasContent?(t=e.theme.colors)==null?void 0:t.primary:"#a6a6a6"}};
64
- fill: ${e=>{var t;return e.hasContent?(t=e.theme.colors)==null?void 0:t.primary:"#a6a6a6"}};
65
- }
66
- `,se=a.div`
67
- width: ${e=>e.avatarSize||"32px"};
68
- height: ${e=>e.avatarSize||"32px"};
69
- border-radius: 50%;
70
- background-color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.accent}};
71
- border: ${e=>e.theme.border};
72
- grid-area: avatar;
73
- align-self: flex-end;
74
- justify-self: center;
75
- overflow: hidden;
76
- margin-right: 10px;
77
- display: flex;
78
- justify-content: center;
79
- align-items: center;
80
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
81
-
82
- > img {
83
- height: 100%;
84
- width: 100%;
85
- object-fit: cover;
86
- }
87
-
88
- > svg {
89
- width: 90%;
90
- height: 90%;
91
- padding: 10%;
92
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
93
-
94
- line,
95
- path,
96
- circle,
97
- fill {
98
- stroke: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
99
- }
100
- }
101
- `,ne=y.keyframes`
102
- 0% {
103
- opacity: 0;
104
- }
105
- 75% {
106
- opacity: 1;
107
- }
108
- 100% {
109
- opacity: 0;
110
- }
111
- `,re=a.div`
112
- display: flex;
113
- justify-content: center;
114
- > div {
115
- height: 10px;
116
- width: 10px;
117
- border-radius: 50%;
118
- margin: 5px;
119
- background-color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
120
- animation: ${ne} 1s infinite;
121
- }
122
- > div:nth-of-type(2) {
123
- animation-delay: 100ms;
124
- }
125
- > div:nth-of-type(3) {
126
- animation-delay: 200ms;
127
- }
128
- `,R=a.div`
129
- grid-area: content;
130
- max-width: 100%;
131
- overflow: hidden;
132
- `,oe=a(r.Typography)`
133
- font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
134
- font-weight: normal;
135
- margin: 0;
136
- `,A=a.div`
137
- display: flex;
138
- ${e=>e.left&&"justify-content: start;"};
139
- ${e=>e.center&&"justify-content: center;"};
140
- ${e=>e.right&&"justify-content: end;"};
141
- `,O=a.div`
142
- ${e=>{var t;return e.padded&&`padding: ${(t=e.theme.sizes)==null?void 0:t.medium};`}}
143
- ${e=>!e.user&&e.stacked&&ae(e.stacked,e.theme)}
144
- ${e=>e.user&&e.stacked&&ie(e.stacked,e.theme)}
145
-
146
- display: inline-block;
147
- margin-top: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
148
- && > * {
149
- overflow-wrap: break-word;
150
- word-wrap: break-word;
151
- word-break: break-all;
152
- word-break: break-word;
153
- hyphens: auto;
154
- }
155
- max-width: 100%;
156
- ${e=>e.fullWidth&&"width: 100%;"}
157
- `,ae=(e,t)=>{var n,i;const o=y.css`
158
- background-color: ${(n=t.colors)==null?void 0:n.accent};
159
- color: ${(i=t.colors)==null?void 0:i.text};
160
- ${t.border&&`border: ${t.border};`};
161
- `;return t.borderRadius?y.css`
162
- ${o}
163
-
164
- border-top-right-radius: ${t.borderRadius};
165
- border-bottom-right-radius: ${t.borderRadius};
166
-
167
- ${e==="first"&&`
168
- border-top-left-radius: ${t.borderRadius};
169
- `}
170
-
171
- ${e==="last"&&`
172
- border-bottom-left-radius: ${t.borderRadius};
173
- `}
174
- `:o},ie=(e,t)=>{var n,i;const o=y.css`
175
- background-color: ${(n=t.colors)==null?void 0:n.primary};
176
- color: ${(i=t.colors)==null?void 0:i.accent};
177
- `;return t.borderRadius?y.css`
178
- ${o}
179
-
180
- border-top-left-radius: ${t.borderRadius};
181
- border-bottom-left-radius: ${t.borderRadius};
182
-
183
- ${e==="first"&&`
184
- border-top-right-radius: ${t.borderRadius};
185
- `}
186
-
187
- ${e==="last"&&`
188
- border-bottom-right-radius: ${t.borderRadius};
189
- `}
190
- `:o},T=a.div`
191
- margin-bottom: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
192
- &:last-child {
193
- margin-bottom: 0;
194
- }
195
- `,S=e=>{var t,o;return y.css`
196
- margin: ${(t=e.theme.sizes)==null?void 0:t.medium} 0;
197
- padding: 0 ${(o=e.theme.sizes)==null?void 0:o.medium};
198
- `},le=a(G.FormComponent)`
199
- & button.humany-form-component-button {
200
- ${e=>{var t,o,n,i;return((t=e.theme.colors)==null?void 0:t.primary)&&((o=e.theme.colors)==null?void 0:o.accent)&&r.invertedHoverButton({active:!1,primaryColor:(n=e.theme.colors)==null?void 0:n.primary,secondaryColor:(i=e.theme.colors)==null?void 0:i.accent,theme:e.theme})}};
201
- display: block;
202
- width: 100%;
203
- margin-bottom: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
204
- }
205
- & button.humany-form-component-submit {
206
- width: 100%;
207
- margin: 0;
208
- :not(:last-child) {
209
- margin-bottom: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
210
- }
211
- }
212
- `,ce=a(r.Html)`
213
- white-space: pre-wrap;
214
- a {
215
- color: ${e=>e.theme.colors.link};
216
- &:focus {
217
- ${e=>{var t;return((t=e.theme.accessibility)==null?void 0:t.isTabbing)&&r.borderTabStyle}};
218
- }
219
- }
220
- `,de=a(r.List)`
221
- padding: 0;
222
- list-style: none;
223
- margin: 0 -${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
224
- > li {
225
- margin: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
226
- }
227
- `,me=a.button`
228
- ${e=>r.buttonCss(e)};
229
- display: block;
230
- background-color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
231
- width: 100%;
232
- color: #fff;
233
- &:focus-visible {
234
- ${r.borderTabStyle}
235
- background-color: transparent;
236
- }
237
- `,q=g.forwardRef(({boxed:e,className:t,agentData:o},n)=>s.jsx(R,{ref:n,children:s.jsx(A,{left:e,center:!e,children:s.jsx(O,{padded:!!e,stacked:e?"first":void 0,children:s.jsxs(re,{children:[s.jsx("div",{}),s.jsx("div",{}),s.jsx("div",{})]})})})})),ue=a.p`
238
- && {
239
- font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.small}};
240
- font-weight: 300;
241
- }
242
- margin: 0;
243
- line-height: 1.5em;
244
- grid-area: info;
245
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
246
- `,D=e=>new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),I=({className:e,name:t,timestamp:o})=>{if(!t&&!o)return null;let n="";return t?o?n=`${t}: ${D(o)}`:n=t:o&&(n=D(o)),s.jsx(ue,{children:n})},P=({className:e,children:t,sender:o,timestamp:n})=>{const{avatar:i,name:l}=o,{avatarSize:h}=r.useProperties();return s.jsxs(he,{hasAvatar:!!i,className:L.appendClassNames(e,"humany-conversation-agent-message"),children:[i&&s.jsx(se,{avatarSize:h,children:typeof i=="string"?s.jsx("img",{src:i}):s.jsx(r.SymbolBadge,{symbol:i})}),t,s.jsx(I,{name:l,timestamp:n})]})},he=a.div`
247
- display: grid;
248
- margin-right: 10%;
249
- width: 90%;
250
- ${e=>e.hasAvatar?y.css`
251
- grid-template-columns: auto 1fr;
252
- grid-template-rows: 1fr auto;
253
- grid-template-areas:
254
- 'avatar content'
255
- '. info';
256
- `:y.css`
257
- grid-template-columns: 1fr;
258
- grid-template-rows: 1fr auto;
259
- grid-template-areas:
260
- 'content'
261
- 'info';
262
- `};
263
- `,ge=g.forwardRef(({className:e,children:t,timestamp:o,discrete:n,fullWidth:i},l)=>s.jsx(ye,{ref:l,className:L.appendClassNames(e,"humany-conversation-system-message"),fullWidth:i,children:n?s.jsxs(pe,{className:"humany-conversation-discrete-message",children:[t,s.jsx(I,{timestamp:o})]}):s.jsxs(s.Fragment,{children:[t,s.jsx(I,{timestamp:o})]})})),ye=a.div`
264
- ${e=>e.fullWidth&&"width: 100%"};
265
- padding: 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.large}};
266
- overflow: auto;
267
- `,pe=a.div`
268
- text-align: center;
269
- word-wrap: break-word;
270
- font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
271
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
272
- > p {
273
- margin: 0;
274
- }
275
- `,be=({className:e,children:t,timestamp:o})=>{const{userLabel:n=""}=r.useProperties();return s.jsxs(fe,{className:L.appendClassNames(e,"humany-conversation-user-message"),children:[t,s.jsx(I,{name:n,timestamp:o})]})},fe=a.div`
276
- margin-left: 10%;
277
- width: 90%;
278
- display: flex;
279
- flex-direction: column;
280
- align-items: flex-end;
281
- `,K=e=>Array.isArray(e)?e:Object.keys(e).map(t=>({label:e[t],actionKey:t})),xe=({header:e,actions:t,dispatch:o})=>s.jsx($e,{className:"humany-conversation-button-list",header:e,items:K(t),renderItem:n=>{var l;const i=!!((l=n==null?void 0:n.data)!=null&&l.href);return s.jsx("li",{children:i?s.jsxs(ve,{onClick:()=>{o("action",n)},href:n.data.href,target:n.data.target,"aria-label":n.label,title:n.label,children:[s.jsx(r.SymbolBadge,{symbol:n.symbol}),n.label]}):s.jsxs(je,{onClick:()=>{o("action",n)},"aria-label":n.label,title:n.label,children:[s.jsx(r.SymbolBadge,{symbol:n.symbol}),n.label]})},n.actionKey)}}),$e=a(r.ItemList)`
282
- ${r.itemList}
283
- > ul {
284
- display: flex;
285
- flex-wrap: wrap;
286
- gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
287
- > li {
288
- margin: 0;
289
- }
290
- }
291
- ${S}
292
- `,ve=a(r.Link)`
293
- ${r.buttonCss};
294
-
295
- display: block;
296
- padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
297
- background-color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
298
- width: 100%;
299
- color: #ffffff;
300
- overflow: hidden;
301
- text-overflow: ellipsis;
302
- &:focus-visible {
303
- ${r.borderTabStyle}
304
- background-color: transparent;
305
- }
306
-
307
- i,
308
- svg {
309
- margin-right: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}};
310
- }
311
- `,je=a(r.Button)`
312
- ${r.buttonCss};
313
-
314
- display: block;
315
- padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
316
- background-color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
317
- width: 100%;
318
- color: #ffffff;
319
- overflow: hidden;
320
- text-overflow: ellipsis;
321
- &:focus-visible {
322
- ${r.borderTabStyle}
323
- background-color: transparent;
324
- }
325
-
326
- i,
327
- svg {
328
- margin-right: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}};
329
- }
330
- `,Se=({type:e,content:t={}})=>{const o=r.useComponent(e);return!o||!e?null:s.jsx(g.Suspense,{fallback:null,children:s.jsx(o,{...t})})},we=({body:e})=>s.jsx(Ce,{html:e}),Ce=a(r.Html)`
331
- ${r.genericHtml}
332
- color: inherit;
333
- white-space: pre-wrap;
334
- ${S}
335
- a {
336
- color: ${e=>e.theme.colors.link};
337
- &:focus-visible {
338
- ${r.borderTabStyle};
339
- }
340
- }
341
- `,ke=({header:e,actions:t,dispatch:o})=>s.jsx(Le,{className:"humany-conversation-item-list",header:e,items:K(t),renderItem:n=>{var i;return s.jsx("li",{children:s.jsxs(ze,{children:[((i=n.symbol)==null?void 0:i.content)&&s.jsx("div",{className:"item-icon",children:s.jsx(r.SymbolBadge,{size:22,symbol:{type:n.symbol.type,content:n.symbol.content}})}),s.jsxs("div",{className:"item-body",children:[s.jsx(r.Button,{onClick:()=>{o("action",n)},"aria-label":n.label,title:n.label,children:n.label}),n.description&&s.jsx("p",{children:n.description})]})]})},n.actionKey)}}),Le=a(r.ItemList)`
342
- ${r.itemList}
343
-
344
- > .humany-paragraph {
345
- ${S}
346
- margin-bottom: 0;
347
-
348
- h1 {
349
- margin: 0;
350
- }
351
- }
352
-
353
- ${e=>r.headingElement(e)("h1",y.css`
354
- white-space: normal;
355
- `)}
356
-
357
- > ul {
358
- display: flex;
359
- flex-direction: column;
360
- gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
361
- > li {
362
- margin: 0;
363
- }
364
- }
365
-
366
- li {
367
- border-bottom: ${e=>e.theme.border};
368
-
369
- &:last-of-type {
370
- border-bottom: none;
371
- }
372
- }
373
- `,ze=a.div`
374
- display: flex;
375
- gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
376
- ${S}
377
-
378
- .item-icon {
379
- }
380
-
381
- .item-body {
382
- display: flex;
383
- flex-direction: column;
384
- align-items: flex-start;
385
- gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
386
-
387
- p {
388
- margin: 0;
389
- white-space: normal;
390
- }
391
- }
392
-
393
- button {
394
- background: transparent;
395
- border: none;
396
- font-family: inherit;
397
- font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.normal}};
398
- cursor: pointer;
399
- padding: 0;
400
- margin: 0;
401
-
402
- &:focus-visible {
403
- ${r.borderTabStyle}
404
- span {
405
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
406
- text-decoration: underline;
407
- }
408
- }
409
- }
410
- `,Te=({header:e,actions:t,dispatch:o})=>s.jsx(Ie,{className:"humany-conversation-link-list",header:e,items:K(t),renderItem:n=>s.jsx("li",{children:s.jsxs(Me,{help:n.actionKey==="help",onClick:()=>{o("action",n)},"aria-label":n.label,title:n.label,children:[n.label,n.actionKey==="help"&&s.jsx(r.SymbolBadge,{size:14,symbol:{type:"Svg",content:"caret-down"}})]})},n.actionKey)}),Ie=a(r.ItemList)`
411
- ${r.itemList}
412
- ${S}
413
-
414
- ${e=>r.headingElement(e)("h1",y.css`
415
- white-space: normal;
416
- `)}
417
-
418
- > ul {
419
- display: flex;
420
- flex-direction: column;
421
- gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
422
- > li {
423
- margin: 0;
424
- }
425
- }
426
- `,Me=a(r.Button)`
427
- display: block;
428
- text-align: left;
429
- font-weight: 300;
430
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
431
- max-width: 100%;
432
- text-overflow: ellipsis;
433
- overflow: hidden;
434
-
435
- ${e=>{var t,o;return e.help&&y.css`
436
- color: ${(t=e.theme.colors)==null?void 0:t.text};
437
- text-decoration: underline;
438
-
439
- i,
440
- svg {
441
- margin-left: ${(o=e.theme.sizes)==null?void 0:o.small};
442
- }
443
- `}}
444
-
445
- &:focus-visible {
446
- ${r.borderTabStyle}
447
- span {
448
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
449
- text-decoration: underline;
450
- }
451
- }
452
- `,Ne=()=>s.jsx(Be,{className:"humany-conversation-separator"}),Be=a.div`
453
- ${e=>e.theme.border&&`border-bottom: ${e.theme.border};`}
454
- width: 100%;
455
- `,He=({text:e})=>s.jsx(Re,{className:"humany-conversation-text",variant:"span",children:e}),Re=a(r.Typography)`
456
- ${S}
457
- `,Ae=({header:e="Video call",acceptLabel:t="Accept",declineLabel:o="Decline",dispatch:n})=>{const i=g.useMemo(()=>[{label:t,actionKey:"accept-video-call",symbol:{type:"Svg",content:"video"}},{label:o,actionKey:"decline-video-call",symbol:{type:"Svg",content:"close"}}],[t,o]);return s.jsx(Oe,{className:"humany-conversation-video-request",header:e,items:i,renderItem:l=>{const h=l.actionKey==="accept-video-call"?"#70c48e":"#da5c85";return s.jsx("li",{children:s.jsx(Ke,{onClick:()=>{n("action",l)},"aria-label":l.label,title:l.label,bgColor:h,children:s.jsx(r.SymbolBadge,{symbol:l.symbol,size:25})})},l.actionKey)}})},Oe=a(r.ItemList)`
458
- ${e=>r.itemList(e)}
459
- > ul {
460
- display: flex;
461
- flex-wrap: wrap;
462
- gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
463
- > li {
464
- margin: 0;
465
- }
466
- }
467
- ${e=>S(e)}
468
- `,Ke=a(r.Button)`
469
- ${r.buttonCss};
470
-
471
- background-color: ${e=>e.bgColor};
472
- display: flex;
473
- justify-content: center;
474
- align-items: center;
475
- color: #ffffff;
476
- width: 46px;
477
- height: 46px;
478
- border-radius: 100%;
479
-
480
- &:focus-visible {
481
- ${r.borderTabStyle}
482
- background-color: transparent;
483
-
484
- i,
485
- svg {
486
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
487
-
488
- path {
489
- stroke: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.primary}};
490
- }
491
- }
492
- }
493
-
494
- i,
495
- svg {
496
- color: #fff;
497
-
498
- path {
499
- stroke: #fff;
500
- }
501
- }
502
- `,qe=([e,t])=>({type:e,content:t}),De=({items:e,dispatch:t})=>s.jsx(Fe,{className:"humany-message-list",items:e.map(qe),renderLi:!0,renderItem:o=>{switch(o.type){case x.ConversationMessageListItemType.Text:return s.jsx(He,{text:o.content});case x.ConversationMessageListItemType.HTML:return s.jsx(we,{...o.content});case x.ConversationMessageListItemType.Separator:return s.jsx(Ne,{...o.content});case x.ConversationMessageListItemType.ItemList:return s.jsx(ke,{...o.content,dispatch:t});case x.ConversationMessageListItemType.LinkList:return s.jsx(Te,{...o.content,dispatch:t});case x.ConversationMessageListItemType.ButtonList:return s.jsx(xe,{...o.content,dispatch:t});case x.ConversationMessageListItemType.VideoRequest:return s.jsx(Ae,{...o.content,dispatch:t});default:return s.jsx(Se,{type:o.type,content:o.content})}}}),Fe=a(r.List)`
503
- ${r.list}
504
-
505
- > li {
506
- margin: 0;
507
- }
508
- `,Pe=g.forwardRef(({className:e,timestamp:t,sender:o,type:n,content:i},l)=>{const h=g.useCallback(m=>{let c="first";return i.length>1&&(c=m===0?"first":m+1===i.length?"last":"middle"),c},[i]),d=()=>s.jsx(s.Fragment,{children:i.map(m=>{const{key:c,body:$,title:w,form:C,actions:j}=m,b=!!$&&!w&&!C&&!j;return s.jsx(ge,{className:e,discrete:b,ref:l,timestamp:t,fullWidth:!!C||!!j,children:b&&$?s.jsx(r.Html,{html:$}):s.jsx(B,{isSystem:!0,content:m})},c)})}),p=()=>s.jsx(P,{sender:o,timestamp:t,className:e,children:s.jsx(R,{className:"humany-message-content-bundle",children:i.map((m,c)=>s.jsx(A,{className:"humany-message-container",left:!0,ref:l,children:s.jsx(B,{content:m,stacked:h(c)})},m.key))})}),v=()=>s.jsx(be,{timestamp:t,className:e,children:s.jsx(R,{className:"humany-message-content-bundle",children:i.map((m,c)=>s.jsx(A,{className:"humany-message-container",right:!0,ref:l,children:s.jsx(B,{isUser:!0,content:m,stacked:h(c)})},m.key))})});switch(n){case x.ConversationMessageType.System:return d();case x.ConversationMessageType.Agent:return p();case x.ConversationMessageType.User:return v();default:return null}}),B=({content:e,isUser:t,isSystem:o,stacked:n})=>{const i=r.useDispatch(),{title:l,body:h,actions:d,form:p,items:v}=e;return v?s.jsx(O,{className:"humany-message-content",user:!!t,stacked:n,children:s.jsx(De,{items:v,dispatch:i})}):s.jsxs(O,{className:"humany-message-content",padded:!o,user:!!t,stacked:n,fullWidth:!!p||!!d,children:[l&&s.jsx(T,{children:s.jsx(oe,{variant:"h2",children:l})}),h&&s.jsx(T,{children:s.jsx(ce,{html:h})}),p&&s.jsx(T,{children:s.jsx(le,{...p,onChange:(c,$)=>{i("form",{data:$,formKey:p.schema.id,actionKey:c})}})}),d&&s.jsx(T,{children:s.jsx(de,{items:Object.keys(d).map(c=>({label:d[c],actionKey:c})),renderItem:c=>s.jsx("li",{children:s.jsx(me,{onClick:()=>{i("action",c.actionKey)},children:c.label})},c.actionKey)})})]})},E=()=>{const e=g.useCallback(d=>{d&&setTimeout(()=>{d.scrollIntoView({block:"start",behavior:"smooth"})},250)},[]),[t,o]=r.useScroll(!0),{messages:n,loading:i,typingActors:l=[]}=r.useProperties(),h=()=>l&&l.length?l.map((d,p)=>s.jsx(H,{id:`typing_${d.name}`,children:s.jsx(P,{timestamp:Date.now(),sender:d,children:s.jsx(q,{boxed:!0,ref:e})})},`typing_${d.name}`)):null;return s.jsxs(s.Fragment,{children:[s.jsxs(Ee,{tabIndex:0,scrollableCss:t,ref:o,children:[n&&n.length?n.map((d,p)=>{const{type:v,timestamp:m,sender:c,content:$}=d;return s.jsx(H,{className:"humany-conversation-entry",tabIndex:-1,children:s.jsx(Pe,{...d,ref:e})},`${v}_${c==null?void 0:c.name}_${m}_${$[0].key}`)}):null,h(),i&&s.jsx(H,{children:s.jsx(q,{ref:e})})]}),s.jsx(J,{})]})},Ee=a.div`
509
- display: flex;
510
- flex-direction: column;
511
- align-items: stretch;
512
- flex: 0 1 100%;
513
- padding: 0 ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
514
- ${e=>!!e.scrollableCss&&e.scrollableCss};
515
- &:focus-visible {
516
- ${e=>r.borderTabStyle(e)};
517
- }
518
- `,H=a.div`
519
- margin: 0;
520
- margin-bottom: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
521
-
522
- &:first-of-type {
523
- margin-top: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
524
- }
525
-
526
- &:last-of-type {
527
- padding-bottom: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
528
- }
529
-
530
- & span,
531
- p,
532
- a,
533
- div {
534
- font-weight: 300;
535
- }
536
-
537
- & b,
538
- h1 {
539
- font-weight: normal;
540
- }
541
- ${e=>r.headingElement(e)("h1",y.css`
542
- font-weight: normal;
543
- `)}
544
- `,We=({dispatch:e})=>{const t=g.useRef(null);return g.useEffect(()=>{t.current&&t.current.parentNode&&e("overlay-mounted",t.current)},[t]),s.jsx(r.WidgetOverlayOutlet,{portalId:"humany-conversation-overlay-portal",className:"humany-conversation-overlay-outlet",ref:t})},Ue=({dispatch:e,header:t,buttonLabel:o})=>s.jsxs(_e,{portalId:"humany-conversation-portal",className:"humany-conversation-outlet",children:[s.jsxs(Ve,{className:"humany-conversation-outlet-head",children:[s.jsx(Ge,{className:"humany-conversation-outlet-head-button","aria-label":o,title:o,onClick:()=>e("hide-overlay-conversation"),children:s.jsx(r.SymbolBadge,{symbol:{type:"Svg",content:"caret-down"},size:20})}),t&&s.jsx(Ye,{className:"humany-conversation-outlet-header",variant:"h1",children:t})]}),s.jsx(E,{})]}),_e=a(r.WidgetOverlayOutlet)`
545
- z-index: 11;
546
- top: auto;
547
- height: 65%;
548
- background-color: #ffffff;
549
- display: flex;
550
- flex-direction: column;
551
- border-top-right-radius: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.large}};
552
- border-top-left-radius: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.large}};
553
- `,Ve=a.div`
554
- display: flex;
555
- flex-direction: column;
556
- justify-content: center;
557
- align-items: center;
558
- gap: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
559
- padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.normal}};
560
- ${e=>e.theme.border&&`border-bottom: ${e.theme.border};`}
561
- `,Ye=a(r.Typography)`
562
- font-size: ${e=>{var t;return(t=e.theme.fonts)==null?void 0:t.medium}};
563
- color: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
564
- margin: 0;
565
- `,Ge=a(r.Button)`
566
- display: flex;
567
- align-items: center;
568
- justify-content: center;
569
- padding: ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.small}} ${e=>{var t;return(t=e.theme.sizes)==null?void 0:t.medium}};
570
- ${e=>e.theme.borderRadius&&`border-radius: ${e.theme.borderRadius};`}
571
-
572
- &:focus-visible {
573
- ${r.borderTabStyle};
574
- }
575
-
576
- svg line {
577
- stroke: ${e=>{var t;return(t=e.theme.colors)==null?void 0:t.text}};
578
- }
579
- `,Je=({className:e,...t})=>{const{overlay:o,overlayConversationHeader:n,overlayConversationCloseLabel:i,conversationControllerId:l}=r.useProperties(),h=r.useDispatch();return s.jsxs(r.ConversationContext.Provider,{value:l?{id:l}:null,children:[s.jsx(Qe,{...t,className:L.appendClassNames(e,"humany-conversation-component"),children:s.jsx(E,{})}),o&&s.jsxs(s.Fragment,{children:[s.jsx(We,{dispatch:h}),o.conversation&&s.jsx(Ue,{dispatch:h,header:n,buttonLabel:i})]})]})},Qe=a.div`
580
- position: absolute;
581
- right: 0;
582
- left: 0;
583
- bottom: 0;
584
- top: 0;
585
- overflow: hidden;
586
- display: flex;
587
- flex-direction: column;
588
- `;exports.default=Je;