@telia-ace/widget-conversation 1.1.2-rc.1 → 1.1.2-rc.11

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