@telia-ace/knowledge-widget-adapters 1.2.9-rc.0 → 1.2.9

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,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),l=require("@emotion/react"),u=require("@emotion/styled"),n=require("@telia-ace/knowledge-widget-ui"),o=require("@telia-ace/widget-utilities"),d=require("./index-5ef7548a.js");require("react");require("@telia-ace/widget-forms");require("@telia-ace/knowledge-widget-core");const h=u(n.Html)`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),l=require("@emotion/react"),u=require("@emotion/styled"),n=require("@telia-ace/knowledge-widget-ui"),o=require("@telia-ace/widget-utilities"),d=require("./index-192f6c80.js");require("react");require("@telia-ace/widget-forms");require("@telia-ace/knowledge-widget-core");const h=u(n.Html)`
2
2
  ${n.genericHtml}
3
3
 
4
4
  ${e=>{var t;return n.headingElement(e)("h1",l.css`
@@ -3,7 +3,7 @@ import { css as l } from "@emotion/react";
3
3
  import c from "@emotion/styled";
4
4
  import { Html as f, genericHtml as d, headingElement as h } from "@telia-ace/knowledge-widget-ui";
5
5
  import { appendClassNames as r } from "@telia-ace/widget-utilities";
6
- import { F as p } from "./index-738dad5e.mjs";
6
+ import { F as p } from "./index-4ce30bab.mjs";
7
7
  import "react";
8
8
  import "@telia-ace/widget-forms";
9
9
  import "@telia-ace/knowledge-widget-core";
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("@emotion/styled"),n=require("@telia-ace/knowledge-widget-ui"),u=require("@telia-ace/widget-utilities"),o=require("./index-5ef7548a.js");require("@telia-ace/widget-forms");require("react");require("@telia-ace/knowledge-widget-core");require("@emotion/react");const c=({className:s,description:t,body:{freetext:r},htmlParseInstruction:i})=>r?e.jsxs("div",{className:u.appendClassNames(s,"humany-contact-method-free-text"),children:[e.jsx(d,{html:r,htmlParseInstruction:i}),t&&e.jsx(o.Description,{html:t,htmlParseInstruction:i})]}):null,d=l(n.Html)`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("@emotion/styled"),n=require("@telia-ace/knowledge-widget-ui"),u=require("@telia-ace/widget-utilities"),o=require("./index-192f6c80.js");require("@telia-ace/widget-forms");require("react");require("@telia-ace/knowledge-widget-core");require("@emotion/react");const c=({className:s,description:t,body:{freetext:r},htmlParseInstruction:i})=>r?e.jsxs("div",{className:u.appendClassNames(s,"humany-contact-method-free-text"),children:[e.jsx(d,{html:r,htmlParseInstruction:i}),t&&e.jsx(o.Description,{html:t,htmlParseInstruction:i})]}):null,d=l(n.Html)`
2
2
  ${n.genericHtml};
3
3
  `;exports.default=c;
@@ -2,7 +2,7 @@ import { jsxs as p, jsx as r } from "react/jsx-runtime";
2
2
  import i from "@emotion/styled";
3
3
  import { Html as l, genericHtml as s } from "@telia-ace/knowledge-widget-ui";
4
4
  import { appendClassNames as n } from "@telia-ace/widget-utilities";
5
- import { D as a } from "./index-738dad5e.mjs";
5
+ import { D as a } from "./index-4ce30bab.mjs";
6
6
  import "@telia-ace/widget-forms";
7
7
  import "react";
8
8
  import "@telia-ace/knowledge-widget-core";
@@ -0,0 +1,97 @@
1
+ "use strict";var Z=Object.defineProperty;var _=(t,e,n)=>e in t?Z(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var N=(t,e,n)=>(_(t,typeof e!="symbol"?e+"":e,n),n);const C=require("@telia-ace/widget-forms"),I=require("@telia-ace/knowledge-widget-core"),P=require("@telia-ace/widget-utilities"),k=require("react"),u=require("react/jsx-runtime"),w=require("@emotion/react"),f=require("@emotion/styled"),m=require("@telia-ace/knowledge-widget-ui"),S=(t,e,n=!1)=>t.getManyAsync("matchingClient","router").then(i=>{const{formData:o}=new C.FormReader(e.body.form).export(n),{router:c,matchingClient:r}=i,{params:s}=c.getRouteData();return e.guideId=e.body.guideId||s.guideId,r.customRequest(`contactmethods/${e.id}${n?"/validatedwithpayload":""}`,"POST",{body:o,configuration:{guideId:e.body.guideId||s.guideId}})}),A=(t,e,n)=>S(t,e).then(i=>n?n(i):i).then(({ConfirmationText:i})=>i),y=(t,e)=>S(t,e,!0).then(n=>({valid:n.Validation.IsValid,errors:n.Validation.Errors,errorTypes:n.Validation.ErrorTypes})),j=(t,e)=>S(t,e,!0).then(n=>C.FormBuilder.fromLegacyForm(e.id,n.ContactMethod.Form).get()),v=(t,e)=>t.getAsync("matchingClient").then(n=>{n.completeContactMethod(e.id,{guideId:e.guideId})});function D(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"email.form",render:Promise.resolve().then(()=>require("./email-form-component-24f16628.js")),onEvaluate:n=>j(t,n),onValidate:n=>y(t,n),onSubmit:n=>A(t,n),onComplete:n=>v(t,n)})})}const R=(t,e,n)=>{const{url:i,width:o,height:c}=e,r=n||{},s=document.createElement("a");return s.href=i,s.search.replace("?","").split("&").forEach(a=>{const[d,l]=a.split("=");typeof l<"u"&&(r[d]=l)}),s.search=Object.keys(r).map(a=>`${a}=${r[a]}`).join("&"),window.open(s.href,t,`width=${o},height=${c}`),""};function F(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"chat.popup",render:"email.form",handleClick:n=>{const{title:i,body:o}=n,{form:c,guideId:r,confirmationFallback:s,...a}=o;return c?()=>{}:d=>{d.preventDefault(),R(i,a)}},onValidate:n=>y(t,n),onComplete:n=>v(t,n),onSubmit:n=>{const{title:i,body:o}=n,{form:c,guideId:r,confirmationFallback:s,...a}=o,d=new C.FormReader(c).export().values;return R(i,a,d),s}})})}function V(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"custom.freetext",render:Promise.resolve().then(()=>require("./free-text-component-32e19166.js"))})})}function z(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"custom.link",render:Promise.resolve().then(()=>require("./link-component-6fbdc8fb.js"))})})}function H(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"phone.text",render:Promise.resolve().then(()=>require("./phone-component-ebf50e0d.js"))})})}const ee=async(t,e)=>{const n=t.get(e.clientName);let{description:i,disabled:o,onClick:c}=e;if(n){const{handleClick:r,handleDescription:s,handleDisabled:a}=n;typeof r=="function"&&(c=await Promise.resolve(r(e))),typeof s=="function"&&(i=await Promise.resolve(s(e))),typeof a=="function"&&(o=await Promise.resolve(a(e)))}return Promise.resolve({...e,description:i,disabled:o,onClick:c})};class x{constructor(e,n){N(this,"adapters",new Map);N(this,"subs",[]);if(this.container=e,this.componentPlatform=n,n){n.components().ofType("contact-list").select().actions.watch("contact-list.fetched",async(r,s)=>{const{contactMethods:a}=r;if(a){const d=Promise.all(a.map(l=>this.handleAdapters(l)));await Promise.resolve(d).then(l=>{r.contactMethods=l})}return s(r)});const o=n.components().ofType("guide").select();o.actions.watch("guide.fetched",async(r,s)=>{const{contactMethods:a}=r;if(a){const d=Promise.all(a.map(l=>this.handleAdapters(l)));await Promise.resolve(d).then(l=>{r.contactMethods=l})}return s(r)}),o.actions.watch("guide.handover",async(r,s)=>{const{handoverContactMethods:a}=r;if(a){const d=Promise.all(a.map(l=>this.handleAdapters(l)));await Promise.resolve(d).then(l=>{r.handoverContactMethods=l})}return s(r)}),n.components().ofType("contact-method").select().actions.watch("contact-method.fetched",async(r,s)=>{const{contactMethod:a}=r;return a?this.handleAdapters(a).then(d=>s({...r,contactMethod:d})):s(r)})}}static create(e){return I.ComponentPlatform.getInstance(e).then(n=>new x(e,n))}handleAdapters(e){return ee(this.adapters,e)}static getInstance(e,n="contactMethods"){return P.lock(e)(()=>e.getAsync(n).then(i=>{let o=i;return o||I.ComponentPlatform.getInstance(e).then(c=>(o=new x(e,c),e.registerAsync(n,()=>o),o))}))}track(e={},n){const{events:i}=this.container.get("$widget");i.dispatch("tracking:service-client-response",{type:n,data:e})}complete(e){const{id:n,title:i,clientName:o,expanded:c,body:r}=e;this.track({contactMethod:{id:n,title:i,expanded:c,type:o},hasGuide:!!r.guideId},"contact-method-complete");const s=this.adapters.get(o);if(s&&s.onComplete)return s.onComplete(e)}evaluate(e){const{clientName:n}=e,i=this.adapters.get(n);return i&&i.onEvaluate?Promise.resolve(i.onEvaluate(e)):Promise.resolve(e.body.form)}validate(e){const{id:n,title:i,clientName:o}=e,c=this.adapters.get(o);return c&&c.onValidate?Promise.resolve(c.onValidate(e)).then(r=>{this.track({contactMethod:{id:n,title:i,type:o},isValid:r.valid},"contact-method-validate");const{events:s}=this.container.get("$widget");return s.dispatch("form:validated",{isValid:r.valid}),r}):Promise.resolve({valid:!0})}submit(e){const{clientName:n}=e,i=this.adapters.get(n);return i&&i.onSubmit?Promise.resolve(i.onSubmit(e)).then(o=>(this.complete(e),o)):Promise.resolve("")}create(e){const{clientName:n,render:i}=e;return this.adapters.set(n,{onValidate:o=>y(this.container,o),onEvaluate:o=>j(this.container,o),onComplete:o=>v(this.container,o),...e}),this.container.getAsync("componentResolver").then(o=>{typeof i=="string"?this.subs.push(o.registerAlias(n,i)):this.subs.push(o.registerComponent(n,k.lazy(()=>i)))})}dispose(){this.subs.forEach(e=>e())}}f(m.Paragraph)`
2
+ ${t=>{var e;return m.headingElement(t)("h1",w.css`
3
+ font-weight: normal;
4
+ font-size: ${(e=t.theme.fonts)==null?void 0:e.medium};
5
+ `)}}
6
+ `;const O=f(m.Html)`
7
+ ${m.genericHtml}
8
+ font-weight: 300;
9
+ line-height: 1.5em;
10
+ button:focus-visible {
11
+ ${m.borderTabStyle};
12
+ }
13
+
14
+ a:focus-visible {
15
+ ${m.linkTabStyle};
16
+ }
17
+ `,U=t=>{const e=m.useComponent(t.clientName),{params:{contactCategory:n,guideCategory:i,phrase:o}}=m.useRouteData();if(typeof e>"u")return null;if(e===null)return process.env.NODE_ENV!=="production"?u.jsx(ne,{title:`client-name: ${t.clientName}, id: ${t.id}`,className:"humany-non-resolved-contact-method",children:u.jsx(m.Typography,{variant:"h5",children:"Non resolved Contact Method type"})}):null;const c=(r={})=>{const s={...t,...r},{id:a,title:d,clientName:l,symbol:p,inline:$,onClick:b=()=>{},description:g,htmlParseInstruction:T,className:J,disabled:Q,guideId:X,dispatch:E=()=>{},expanded:L}=s,Y=$?{onKeyDown:h=>{h.key&&h.key==="Enter"&&(b(h,s),h.defaultPrevented||!L&&E("expand",a))},onClick:h=>{b(h,s),h.defaultPrevented||!L&&E("expand",a)}}:{onClick:h=>b(h,s),routeName:"contact-method",params:P.createParams({contactCategory:n,guideId:X,guideCategory:i,phrase:o,contactMethod:a,uriName:P.formatUrl(d)})};let M;if(l==="phone.text"){const h=document.createElement("div");h.innerHTML=g,M=h.innerText}return u.jsxs(te,{title:d,"aria-label":l==="phone.text"?`${d} ${M}`:d,className:J,disabled:Q,description:g,"data-client-name":l,...r,...Y,children:[p&&u.jsx(m.SymbolBadge,{symbol:p}),g?u.jsxs("div",{className:"humany-contact-link-rich-content",children:[u.jsx(q,{children:d}),u.jsx(O,{html:g,htmlParseInstruction:T})]}):u.jsx(q,{children:d})]})};return t.expanded?u.jsx(k.Suspense,{fallback:null,children:u.jsx(e,{...t,renderDefault:c})}):c()},W=t=>{var e,n,i,o,c,r,s,a;return w.css`
18
+ display: flex;
19
+ padding: ${(e=t.theme.sizes)==null?void 0:e.large};
20
+ ${t.description?"":"align-items: center;"}
21
+ text-decoration: none;
22
+ span {
23
+ display: inline-block;
24
+ color: ${(n=t.theme.colors)==null?void 0:n.text};
25
+ }
26
+ i {
27
+ font-size: ${(i=t.theme.fonts)==null?void 0:i.large};
28
+ margin: 0 ${(o=t.theme.sizes)==null?void 0:o.large} 0 0;
29
+ min-height: ${(c=t.theme.fonts)==null?void 0:c.large};
30
+ min-width: ${(r=t.theme.fonts)==null?void 0:r.large};
31
+ line-height: ${(s=t.theme.fonts)==null?void 0:s.large};
32
+ display: inline-block;
33
+ vertical-align: bottom;
34
+ color: ${(a=t.theme.colors)==null?void 0:a.text};
35
+ }
36
+ `},q=f(m.StyledText)`
37
+ line-height: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.large}};
38
+ `,te=f(m.Link)`
39
+ ${t=>W(t)}
40
+
41
+ &:focus-visible {
42
+ ${m.borderTabStyle};
43
+ }
44
+ `,ne=f.div`
45
+ text-align: center;
46
+ display: block;
47
+ ${t=>{var e,n;return typeof((e=t.theme.colors)==null?void 0:e.warning)<"u"&&`color: ${(n=t.theme.colors)==null?void 0:n.warning};`}}
48
+ `,B=t=>{var e,n,i;return w.css`
49
+ ${m.itemList(t)}
50
+
51
+ > div {
52
+ padding: ${(e=t.theme.sizes)==null?void 0:e.large};
53
+
54
+ ${m.headingElement(t)("h1",w.css`
55
+ margin: 0;
56
+ `)}
57
+ }
58
+
59
+ > ul {
60
+ &:not(:first-child) {
61
+ border-top: ${t.theme.border};
62
+ }
63
+
64
+ > li {
65
+ margin: 0;
66
+ white-space: normal;
67
+
68
+ > a {
69
+ overflow: hidden;
70
+ }
71
+
72
+ &:first-child > a {
73
+ border-radius: ${`${t.theme.borderRadius} ${t.theme.borderRadius} 0 0`};
74
+ }
75
+
76
+ &:last-child:not(:first-child) > a {
77
+ border-radius: ${`0 0 ${t.theme.borderRadius} ${t.theme.borderRadius}`};
78
+ }
79
+
80
+ &:not(:last-child) {
81
+ border-bottom: ${t.theme.border};
82
+ }
83
+
84
+ > div {
85
+ padding: ${(n=t.theme.sizes)==null?void 0:n.large};
86
+ }
87
+ }
88
+ }
89
+
90
+ @media (hover: hover) {
91
+ a:hover {
92
+ background-color: ${(i=t.theme.colors)==null?void 0:i.accent};
93
+ }
94
+ }
95
+ `},oe=f(m.ItemList)`
96
+ ${t=>B(t)}
97
+ `,ie=({contactMethods:t,children:e,guideId:n,dispatch:i,className:o="",itemRenderer:c,action:r=()=>{},header:s=""})=>{const a=m.useContainer(),{events:d}=a.get("$widget");return t.length?u.jsx(oe,{header:s,className:P.appendClassNames(o,"humany-contact-list"),items:t,renderItem:c?l=>u.jsx("li",{role:t.length===1?"none":void 0,"data-contact-method":l.id,children:c(l,{action:r,dispatch:i,guideId:n})},l.id):l=>u.jsx("li",{role:t.length===1?"none":void 0,"data-contact-method":l.id,onClick:()=>{d.dispatch("tracking:contact-list-item-clicked",l)},children:u.jsx(U,{...l,action:r,dispatch:i,guideId:n})},l.id),children:e}):null},K=(t,e)=>{if(t.actionKey===e)return t;if(!t.properties)return null;const n=Object.keys(t.properties);let i;for(let o=0;o<n.length;o++)if(i=K(t.properties[n[o]],e),i)return i;return!1},re=({className:t,body:{form:e},id:n,action:i,dispatch:o,disabled:c,autoFocus:r})=>{if(e&&!c){const{schema:s,layout:a,data:d,meta:l}=e,p=o||i||(()=>{});return u.jsx(C.FormComponent,{className:t,schema:s,layout:a,data:d,autoFocus:r,onChange:($,b)=>{const g={schema:s,layout:a,data:b,meta:l};$.toString()==="submit"?p("submit",{id:n,form:g}):K(s,$).evaluate?p("evaluate",{id:n,form:g}):p("validate",{id:n,form:g})}})}return null},se=t=>{const[e,n]=k.useState(null),i=m.useContainer();return k.useEffect(()=>{let o;return i.getAsync("componentResolver").then(c=>{o=c.registerResolver(t,r=>n(r))}),()=>{o&&o()}},[t]),e};function G(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"custom.webservice",render:"email.form",onValidate:n=>y(t,n),onComplete:n=>v(t,n),onSubmit:n=>A(t,n,i=>({...i,ConfirmationText:i.ResponseHtml}))})})}const ae=(t,e,n)=>t.getAsync("contactMethods").then(i=>{i.create({clientName:e,render:"email.form",handleClick:()=>(o,c)=>{const{body:{form:r,guideId:s,confirmationFallback:a,...d}}=c;r||(o.preventDefault(),n(d))},onValidate:o=>y(t,o),onComplete:o=>v(t,o),onSubmit:o=>{const{body:{form:c,guideId:r,confirmationFallback:s,...a}}=o,{values:d}=new C.FormReader(c).export();return Promise.resolve(n(a,d)).then(l=>l||s)}})});class ce extends I.Plugin{constructor(e,n){super(e,n),this.widget.implementation.configure(o=>{o.plugin(D).plugin(F).plugin(V).plugin(H).plugin(G).plugin(z)})}}exports.ContactList=ie;exports.ContactMethod=U;exports.ContactMethodPlatform=x;exports.DefaultContactMethodsPlugin=ce;exports.Description=O;exports.Form=re;exports.chatPopupPlugin=F;exports.complete=v;exports.contactItemList=B;exports.contactLink=W;exports.createSubmitAdapter=ae;exports.emailPlugin=D;exports.evaluate=j;exports.freeTextPlugin=V;exports.linkPlugin=z;exports.phonePlugin=H;exports.submit=A;exports.useContactMethod=se;exports.validate=y;exports.webServicePlugin=G;
@@ -1,14 +1,14 @@
1
- var q = Object.defineProperty;
2
- var B = (t, e, n) => e in t ? q(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
- var $ = (t, e, n) => (B(t, typeof e != "symbol" ? e + "" : e, n), n);
4
- import { FormBuilder as K, FormReader as w, FormComponent as G } from "@telia-ace/widget-forms";
5
- import { ComponentPlatform as A, Plugin as U } from "@telia-ace/knowledge-widget-core";
6
- import { lock as W, createParams as J, formatUrl as Q, appendClassNames as X } from "@telia-ace/widget-utilities";
7
- import { lazy as Y, Suspense as Z, useState as _, useEffect as ee } from "react";
8
- import { jsx as m, jsxs as S } from "react/jsx-runtime";
1
+ var B = Object.defineProperty;
2
+ var K = (t, e, n) => e in t ? B(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
3
+ var $ = (t, e, n) => (K(t, typeof e != "symbol" ? e + "" : e, n), n);
4
+ import { FormBuilder as G, FormReader as w, FormComponent as U } from "@telia-ace/widget-forms";
5
+ import { ComponentPlatform as S, Plugin as W } from "@telia-ace/knowledge-widget-core";
6
+ import { lock as J, createParams as Q, formatUrl as X, appendClassNames as Y } from "@telia-ace/widget-utilities";
7
+ import { lazy as Z, Suspense as _, useState as ee, useEffect as te } from "react";
8
+ import { jsx as m, jsxs as E } from "react/jsx-runtime";
9
9
  import { css as C } from "@emotion/react";
10
10
  import f from "@emotion/styled";
11
- import { Paragraph as te, headingElement as D, Html as ne, genericHtml as oe, borderTabStyle as R, linkTabStyle as ie, StyledText as re, Link as se, useComponent as ae, useRouteData as ce, Typography as le, SymbolBadge as de, ItemList as me, itemList as he, useContainer as T } from "@telia-ace/knowledge-widget-ui";
11
+ import { Paragraph as ne, headingElement as D, Html as oe, genericHtml as ie, borderTabStyle as L, linkTabStyle as re, StyledText as se, Link as ae, useComponent as ce, useRouteData as le, Typography as de, SymbolBadge as me, ItemList as he, itemList as ue, useContainer as R } from "@telia-ace/knowledge-widget-ui";
12
12
  const P = (t, e, n = !1) => t.getManyAsync("matchingClient", "router").then((i) => {
13
13
  const { formData: o } = new w(e.body.form).export(
14
14
  n
@@ -23,14 +23,14 @@ const P = (t, e, n = !1) => t.getManyAsync("matchingClient", "router").then((i)
23
23
  }
24
24
  }
25
25
  );
26
- }), L = (t, e, n) => P(t, e).then((i) => n ? n(i) : i).then(({ ConfirmationText: i }) => i), y = (t, e) => P(t, e, !0).then(
26
+ }), M = (t, e, n) => P(t, e).then((i) => n ? n(i) : i).then(({ ConfirmationText: i }) => i), y = (t, e) => P(t, e, !0).then(
27
27
  (n) => ({
28
28
  valid: n.Validation.IsValid,
29
29
  errors: n.Validation.Errors,
30
30
  errorTypes: n.Validation.ErrorTypes
31
31
  })
32
32
  ), F = (t, e) => P(t, e, !0).then(
33
- (n) => K.fromLegacyForm(
33
+ (n) => G.fromLegacyForm(
34
34
  e.id,
35
35
  n.ContactMethod.Form
36
36
  ).get()
@@ -39,26 +39,26 @@ const P = (t, e, n = !1) => t.getManyAsync("matchingClient", "router").then((i)
39
39
  guideId: e.guideId
40
40
  });
41
41
  });
42
- function ue(t) {
42
+ function pe(t) {
43
43
  t.getAsync("contactMethods").then((e) => {
44
44
  e.create({
45
45
  clientName: "email.form",
46
- render: import("./email-form-component-c4f2dd9c.mjs"),
46
+ render: import("./email-form-component-f4b252a3.mjs"),
47
47
  onEvaluate: (n) => F(t, n),
48
48
  onValidate: (n) => y(t, n),
49
- onSubmit: (n) => L(t, n),
49
+ onSubmit: (n) => M(t, n),
50
50
  onComplete: (n) => b(t, n)
51
51
  });
52
52
  });
53
53
  }
54
- const E = (t, e, n) => {
54
+ const T = (t, e, n) => {
55
55
  const { url: i, width: o, height: c } = e, r = n || {}, s = document.createElement("a");
56
56
  return s.href = i, s.search.replace("?", "").split("&").forEach((a) => {
57
57
  const [d, l] = a.split("=");
58
58
  typeof l < "u" && (r[d] = l);
59
59
  }), s.search = Object.keys(r).map((a) => `${a}=${r[a]}`).join("&"), window.open(s.href, t, `width=${o},height=${c}`), "";
60
60
  };
61
- function pe(t) {
61
+ function fe(t) {
62
62
  t.getAsync("contactMethods").then((e) => {
63
63
  e.create({
64
64
  clientName: "chat.popup",
@@ -67,27 +67,27 @@ function pe(t) {
67
67
  const { title: i, body: o } = n, { form: c, guideId: r, confirmationFallback: s, ...a } = o;
68
68
  return c ? () => {
69
69
  } : (d) => {
70
- d.preventDefault(), E(i, a);
70
+ d.preventDefault(), T(i, a);
71
71
  };
72
72
  },
73
73
  onValidate: (n) => y(t, n),
74
74
  onComplete: (n) => b(t, n),
75
75
  onSubmit: (n) => {
76
76
  const { title: i, body: o } = n, { form: c, guideId: r, confirmationFallback: s, ...a } = o, d = new w(c).export().values;
77
- return E(i, a, d), s;
77
+ return T(i, a, d), s;
78
78
  }
79
79
  });
80
80
  });
81
81
  }
82
- function fe(t) {
82
+ function ge(t) {
83
83
  t.getAsync("contactMethods").then((e) => {
84
84
  e.create({
85
85
  clientName: "custom.freetext",
86
- render: import("./free-text-component-d819debd.mjs")
86
+ render: import("./free-text-component-652bb1ce.mjs")
87
87
  });
88
88
  });
89
89
  }
90
- function ge(t) {
90
+ function ye(t) {
91
91
  t.getAsync("contactMethods").then((e) => {
92
92
  e.create({
93
93
  clientName: "custom.link",
@@ -95,7 +95,7 @@ function ge(t) {
95
95
  });
96
96
  });
97
97
  }
98
- function ye(t) {
98
+ function be(t) {
99
99
  t.getAsync("contactMethods").then((e) => {
100
100
  e.create({
101
101
  clientName: "phone.text",
@@ -103,7 +103,7 @@ function ye(t) {
103
103
  });
104
104
  });
105
105
  }
106
- const be = async (t, e) => {
106
+ const ve = async (t, e) => {
107
107
  const n = t.get(e.clientName);
108
108
  let { description: i, disabled: o, onClick: c } = e;
109
109
  if (n) {
@@ -176,15 +176,15 @@ class k {
176
176
  }
177
177
  }
178
178
  static create(e) {
179
- return A.getInstance(e).then((n) => new k(e, n));
179
+ return S.getInstance(e).then((n) => new k(e, n));
180
180
  }
181
181
  handleAdapters(e) {
182
- return be(this.adapters, e);
182
+ return ve(this.adapters, e);
183
183
  }
184
184
  static getInstance(e, n = "contactMethods") {
185
- return W(e)(() => e.getAsync(n).then((i) => {
185
+ return J(e)(() => e.getAsync(n).then((i) => {
186
186
  let o = i;
187
- return o || A.getInstance(e).then((c) => (o = new k(
187
+ return o || S.getInstance(e).then((c) => (o = new k(
188
188
  e,
189
189
  c
190
190
  ), e.registerAsync(n, () => o), o));
@@ -247,7 +247,7 @@ class k {
247
247
  typeof i == "string" ? this.subs.push(o.registerAlias(n, i)) : this.subs.push(
248
248
  o.registerComponent(
249
249
  n,
250
- Y(() => i)
250
+ Z(() => i)
251
251
  )
252
252
  );
253
253
  });
@@ -256,7 +256,7 @@ class k {
256
256
  this.subs.forEach((e) => e());
257
257
  }
258
258
  }
259
- f(te)`
259
+ f(ne)`
260
260
  ${(t) => {
261
261
  var e;
262
262
  return D(t)(
@@ -268,30 +268,30 @@ f(te)`
268
268
  );
269
269
  }}
270
270
  `;
271
- const ve = f(ne)`
272
- ${oe}
271
+ const Ce = f(oe)`
272
+ ${ie}
273
273
  font-weight: 300;
274
274
  line-height: 1.5em;
275
275
  button:focus-visible {
276
- ${R};
276
+ ${L};
277
277
  }
278
278
 
279
279
  a:focus-visible {
280
- ${ie};
280
+ ${re};
281
281
  }
282
- `, Ce = (t) => {
283
- const e = ae(t.clientName), {
282
+ `, $e = (t) => {
283
+ const e = ce(t.clientName), {
284
284
  params: { contactCategory: n, guideCategory: i, phrase: o }
285
- } = ce();
285
+ } = le();
286
286
  if (typeof e > "u")
287
287
  return null;
288
288
  if (e === null)
289
289
  return process.env.NODE_ENV !== "production" ? /* @__PURE__ */ m(
290
- we,
290
+ Pe,
291
291
  {
292
292
  title: `client-name: ${t.clientName}, id: ${t.id}`,
293
293
  className: "humany-non-resolved-contact-method",
294
- children: /* @__PURE__ */ m(le, { variant: "h5", children: "Non resolved Contact Method type" })
294
+ children: /* @__PURE__ */ m(de, { variant: "h5", children: "Non resolved Contact Method type" })
295
295
  }
296
296
  ) : null;
297
297
  const c = (r = {}) => {
@@ -305,48 +305,53 @@ const ve = f(ne)`
305
305
  },
306
306
  description: u,
307
307
  htmlParseInstruction: N,
308
- className: z,
309
- disabled: j,
308
+ className: j,
309
+ disabled: H,
310
310
  guideId: O,
311
- dispatch: I = () => {
311
+ dispatch: x = () => {
312
312
  },
313
- expanded: x
314
- } = s, H = v ? {
313
+ expanded: I
314
+ } = s, q = v ? {
315
315
  onKeyDown: (h) => {
316
- h.key && h.key === "Enter" && (g(h, s), h.defaultPrevented || !x && I("expand", a));
316
+ h.key && h.key === "Enter" && (g(h, s), h.defaultPrevented || !I && x("expand", a));
317
317
  },
318
318
  onClick: (h) => {
319
- g(h, s), h.defaultPrevented || !x && I("expand", a);
319
+ g(h, s), h.defaultPrevented || !I && x("expand", a);
320
320
  }
321
321
  } : {
322
322
  onClick: (h) => g(h, s),
323
323
  routeName: "contact-method",
324
- params: J({
324
+ params: Q({
325
325
  contactCategory: n,
326
326
  guideId: O,
327
327
  guideCategory: i,
328
328
  phrase: o,
329
329
  contactMethod: a,
330
- uriName: Q(d)
330
+ uriName: X(d)
331
331
  })
332
332
  };
333
- return /* @__PURE__ */ S(
334
- ke,
333
+ let A;
334
+ if (l === "phone.text") {
335
+ const h = document.createElement("div");
336
+ h.innerHTML = u, A = h.innerText;
337
+ }
338
+ return /* @__PURE__ */ E(
339
+ we,
335
340
  {
336
341
  title: d,
337
- "aria-label": d,
338
- className: z,
339
- disabled: j,
342
+ "aria-label": l === "phone.text" ? `${d} ${A}` : d,
343
+ className: j,
344
+ disabled: H,
340
345
  description: u,
341
346
  "data-client-name": l,
342
347
  ...r,
343
- ...H,
348
+ ...q,
344
349
  children: [
345
- p && /* @__PURE__ */ m(de, { symbol: p }),
346
- u ? /* @__PURE__ */ S("div", { className: "humany-contact-link-rich-content", children: [
350
+ p && /* @__PURE__ */ m(me, { symbol: p }),
351
+ u ? /* @__PURE__ */ E("div", { className: "humany-contact-link-rich-content", children: [
347
352
  /* @__PURE__ */ m(V, { children: d }),
348
353
  /* @__PURE__ */ m(
349
- ve,
354
+ Ce,
350
355
  {
351
356
  html: u,
352
357
  htmlParseInstruction: N
@@ -357,8 +362,8 @@ const ve = f(ne)`
357
362
  }
358
363
  );
359
364
  };
360
- return t.expanded ? /* @__PURE__ */ m(Z, { fallback: null, children: /* @__PURE__ */ m(e, { ...t, renderDefault: c }) }) : c();
361
- }, $e = (t) => {
365
+ return t.expanded ? /* @__PURE__ */ m(_, { fallback: null, children: /* @__PURE__ */ m(e, { ...t, renderDefault: c }) }) : c();
366
+ }, ke = (t) => {
362
367
  var e, n, i, o, c, r, s, a;
363
368
  return C`
364
369
  display: flex;
@@ -380,28 +385,28 @@ const ve = f(ne)`
380
385
  color: ${(a = t.theme.colors) == null ? void 0 : a.text};
381
386
  }
382
387
  `;
383
- }, V = f(re)`
388
+ }, V = f(se)`
384
389
  line-height: ${(t) => {
385
390
  var e;
386
391
  return (e = t.theme.fonts) == null ? void 0 : e.large;
387
392
  }};
388
- `, ke = f(se)`
389
- ${(t) => $e(t)}
393
+ `, we = f(ae)`
394
+ ${(t) => ke(t)}
390
395
 
391
396
  &:focus-visible {
392
- ${R};
397
+ ${L};
393
398
  }
394
- `, we = f.div`
399
+ `, Pe = f.div`
395
400
  text-align: center;
396
401
  display: block;
397
402
  ${(t) => {
398
403
  var e, n;
399
404
  return typeof ((e = t.theme.colors) == null ? void 0 : e.warning) < "u" && `color: ${(n = t.theme.colors) == null ? void 0 : n.warning};`;
400
405
  }}
401
- `, Pe = (t) => {
406
+ `, Ne = (t) => {
402
407
  var e, n, i;
403
408
  return C`
404
- ${he(t)}
409
+ ${ue(t)}
405
410
 
406
411
  > div {
407
412
  padding: ${(e = t.theme.sizes) == null ? void 0 : e.large};
@@ -451,8 +456,8 @@ const ve = f(ne)`
451
456
  }
452
457
  }
453
458
  `;
454
- }, Ne = f(me)`
455
- ${(t) => Pe(t)}
459
+ }, xe = f(he)`
460
+ ${(t) => Ne(t)}
456
461
  `, Fe = ({
457
462
  contactMethods: t,
458
463
  children: e,
@@ -464,12 +469,12 @@ const ve = f(ne)`
464
469
  },
465
470
  header: s = ""
466
471
  }) => {
467
- const a = T(), { events: d } = a.get("$widget");
472
+ const a = R(), { events: d } = a.get("$widget");
468
473
  return t.length ? /* @__PURE__ */ m(
469
- Ne,
474
+ xe,
470
475
  {
471
476
  header: s,
472
- className: X(o, "humany-contact-list"),
477
+ className: Y(o, "humany-contact-list"),
473
478
  items: t,
474
479
  renderItem: c ? (l) => /* @__PURE__ */ m(
475
480
  "li",
@@ -488,7 +493,7 @@ const ve = f(ne)`
488
493
  d.dispatch("tracking:contact-list-item-clicked", l);
489
494
  },
490
495
  children: /* @__PURE__ */ m(
491
- Ce,
496
+ $e,
492
497
  {
493
498
  ...l,
494
499
  action: r,
@@ -502,7 +507,7 @@ const ve = f(ne)`
502
507
  children: e
503
508
  }
504
509
  ) : null;
505
- }, M = (t, e) => {
510
+ }, z = (t, e) => {
506
511
  if (t.actionKey === e)
507
512
  return t;
508
513
  if (!t.properties)
@@ -510,10 +515,10 @@ const ve = f(ne)`
510
515
  const n = Object.keys(t.properties);
511
516
  let i;
512
517
  for (let o = 0; o < n.length; o++)
513
- if (i = M(t.properties[n[o]], e), i)
518
+ if (i = z(t.properties[n[o]], e), i)
514
519
  return i;
515
520
  return !1;
516
- }, Me = ({
521
+ }, ze = ({
517
522
  className: t,
518
523
  body: { form: e },
519
524
  id: n,
@@ -526,7 +531,7 @@ const ve = f(ne)`
526
531
  const { schema: s, layout: a, data: d, meta: l } = e, p = o || i || (() => {
527
532
  });
528
533
  return /* @__PURE__ */ m(
529
- G,
534
+ U,
530
535
  {
531
536
  className: t,
532
537
  schema: s,
@@ -535,15 +540,15 @@ const ve = f(ne)`
535
540
  autoFocus: r,
536
541
  onChange: (v, g) => {
537
542
  const u = { schema: s, layout: a, data: g, meta: l };
538
- v.toString() === "submit" ? p("submit", { id: n, form: u }) : M(s, v).evaluate ? p("evaluate", { id: n, form: u }) : p("validate", { id: n, form: u });
543
+ v.toString() === "submit" ? p("submit", { id: n, form: u }) : z(s, v).evaluate ? p("evaluate", { id: n, form: u }) : p("validate", { id: n, form: u });
539
544
  }
540
545
  }
541
546
  );
542
547
  }
543
548
  return null;
544
- }, ze = (t) => {
545
- const [e, n] = _(null), i = T();
546
- return ee(() => {
549
+ }, je = (t) => {
550
+ const [e, n] = ee(null), i = R();
551
+ return te(() => {
547
552
  let o;
548
553
  return i.getAsync("componentResolver").then((c) => {
549
554
  o = c.registerResolver(
@@ -562,14 +567,14 @@ function Ie(t) {
562
567
  render: "email.form",
563
568
  onValidate: (n) => y(t, n),
564
569
  onComplete: (n) => b(t, n),
565
- onSubmit: (n) => L(t, n, (i) => ({
570
+ onSubmit: (n) => M(t, n, (i) => ({
566
571
  ...i,
567
572
  ConfirmationText: i.ResponseHtml
568
573
  }))
569
574
  });
570
575
  });
571
576
  }
572
- const je = (t, e, n) => t.getAsync("contactMethods").then((i) => {
577
+ const He = (t, e, n) => t.getAsync("contactMethods").then((i) => {
573
578
  i.create({
574
579
  clientName: e,
575
580
  render: "email.form",
@@ -589,32 +594,32 @@ const je = (t, e, n) => t.getAsync("contactMethods").then((i) => {
589
594
  }
590
595
  });
591
596
  });
592
- class Oe extends U {
597
+ class Oe extends W {
593
598
  constructor(e, n) {
594
599
  super(e, n), this.widget.implementation.configure((o) => {
595
- o.plugin(ue).plugin(pe).plugin(fe).plugin(ye).plugin(Ie).plugin(ge);
600
+ o.plugin(pe).plugin(fe).plugin(ge).plugin(be).plugin(Ie).plugin(ye);
596
601
  });
597
602
  }
598
603
  }
599
604
  export {
600
605
  Fe as C,
601
- ve as D,
602
- Me as F,
603
- Pe as a,
604
- $e as b,
605
- pe as c,
606
- Ce as d,
606
+ Ce as D,
607
+ ze as F,
608
+ Ne as a,
609
+ ke as b,
610
+ fe as c,
611
+ $e as d,
607
612
  k as e,
608
613
  b as f,
609
614
  F as g,
610
- ue as h,
611
- fe as i,
612
- je as j,
615
+ pe as h,
616
+ ge as i,
617
+ He as j,
613
618
  Oe as k,
614
- ge as l,
615
- ye as p,
616
- L as s,
617
- ze as u,
619
+ ye as l,
620
+ be as p,
621
+ M as s,
622
+ je as u,
618
623
  y as v,
619
624
  Ie as w
620
625
  };
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-5ef7548a.js");require("@telia-ace/widget-forms");require("@telia-ace/knowledge-widget-core");require("@telia-ace/widget-utilities");require("react");require("react/jsx-runtime");require("@emotion/react");require("@emotion/styled");require("@telia-ace/knowledge-widget-ui");exports.ChatPopupPlugin=t.chatPopupPlugin;exports.ContactList=t.ContactList;exports.ContactMethod=t.ContactMethod;exports.ContactMethodPlatform=t.ContactMethodPlatform;exports.DefaultContactMethodsPlugin=t.DefaultContactMethodsPlugin;exports.DefaultForm=t.Form;exports.EmailFormPlugin=t.emailPlugin;exports.FreeTextPlugin=t.freeTextPlugin;exports.LinkPlugin=t.linkPlugin;exports.PhonePlugin=t.phonePlugin;exports.WebServicePlugin=t.webServicePlugin;exports.contactItemList=t.contactItemList;exports.contactLink=t.contactLink;exports.createSubmitAdapter=t.createSubmitAdapter;exports.defaultComplete=t.complete;exports.defaultEvaluate=t.evaluate;exports.defaultSubmit=t.submit;exports.defaultValidate=t.validate;exports.useContactMethod=t.useContactMethod;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-192f6c80.js");require("@telia-ace/widget-forms");require("@telia-ace/knowledge-widget-core");require("@telia-ace/widget-utilities");require("react");require("react/jsx-runtime");require("@emotion/react");require("@emotion/styled");require("@telia-ace/knowledge-widget-ui");exports.ChatPopupPlugin=t.chatPopupPlugin;exports.ContactList=t.ContactList;exports.ContactMethod=t.ContactMethod;exports.ContactMethodPlatform=t.ContactMethodPlatform;exports.DefaultContactMethodsPlugin=t.DefaultContactMethodsPlugin;exports.DefaultForm=t.Form;exports.EmailFormPlugin=t.emailPlugin;exports.FreeTextPlugin=t.freeTextPlugin;exports.LinkPlugin=t.linkPlugin;exports.PhonePlugin=t.phonePlugin;exports.WebServicePlugin=t.webServicePlugin;exports.contactItemList=t.contactItemList;exports.contactLink=t.contactLink;exports.createSubmitAdapter=t.createSubmitAdapter;exports.defaultComplete=t.complete;exports.defaultEvaluate=t.evaluate;exports.defaultSubmit=t.submit;exports.defaultValidate=t.validate;exports.useContactMethod=t.useContactMethod;
package/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as r, C as p, d as c, e as d, k as P, F as f, h as g, i as C, l as h, p as b, w as F, a as L, b as M, j as k, f as v, g as S, s as x, v as D, u as E } from "./index-738dad5e.mjs";
1
+ import { c as r, C as p, d as c, e as d, k as P, F as f, h as g, i as C, l as h, p as b, w as F, a as L, b as M, j as k, f as v, g as S, s as x, v as D, u as E } from "./index-4ce30bab.mjs";
2
2
  import "@telia-ace/widget-forms";
3
3
  import "@telia-ace/knowledge-widget-core";
4
4
  import "@telia-ace/widget-utilities";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-adapters",
3
- "version": "1.2.9-rc.0",
3
+ "version": "1.2.9",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
@@ -11,11 +11,11 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@telia-ace/knowledge-serviceclient": "^1.0.31",
14
- "@telia-ace/knowledge-widget-core": "^1.2.9-rc.0",
15
- "@telia-ace/knowledge-widget-ui": "^1.2.9-rc.0",
16
- "@telia-ace/widget-forms": "^1.2.9-rc.0",
17
- "@telia-ace/widget-routing": "^1.2.9-rc.0",
18
- "@telia-ace/widget-utilities": "^1.2.9-rc.0",
14
+ "@telia-ace/knowledge-widget-core": "*",
15
+ "@telia-ace/knowledge-widget-ui": "*",
16
+ "@telia-ace/widget-forms": "*",
17
+ "@telia-ace/widget-routing": "*",
18
+ "@telia-ace/widget-utilities": "*",
19
19
  "@webprovisions/platform": "^1.1.4"
20
20
  },
21
21
  "peerDependencies": {
package/index-5ef7548a.js DELETED
@@ -1,97 +0,0 @@
1
- "use strict";var Y=Object.defineProperty;var Z=(t,e,n)=>e in t?Y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var N=(t,e,n)=>(Z(t,typeof e!="symbol"?e+"":e,n),n);const C=require("@telia-ace/widget-forms"),I=require("@telia-ace/knowledge-widget-core"),$=require("@telia-ace/widget-utilities"),k=require("react"),u=require("react/jsx-runtime"),w=require("@emotion/react"),p=require("@emotion/styled"),m=require("@telia-ace/knowledge-widget-ui"),S=(t,e,n=!1)=>t.getManyAsync("matchingClient","router").then(i=>{const{formData:o}=new C.FormReader(e.body.form).export(n),{router:c,matchingClient:r}=i,{params:s}=c.getRouteData();return e.guideId=e.body.guideId||s.guideId,r.customRequest(`contactmethods/${e.id}${n?"/validatedwithpayload":""}`,"POST",{body:o,configuration:{guideId:e.body.guideId||s.guideId}})}),A=(t,e,n)=>S(t,e).then(i=>n?n(i):i).then(({ConfirmationText:i})=>i),y=(t,e)=>S(t,e,!0).then(n=>({valid:n.Validation.IsValid,errors:n.Validation.Errors,errorTypes:n.Validation.ErrorTypes})),j=(t,e)=>S(t,e,!0).then(n=>C.FormBuilder.fromLegacyForm(e.id,n.ContactMethod.Form).get()),b=(t,e)=>t.getAsync("matchingClient").then(n=>{n.completeContactMethod(e.id,{guideId:e.guideId})});function q(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"email.form",render:Promise.resolve().then(()=>require("./email-form-component-bb0863b7.js")),onEvaluate:n=>j(t,n),onValidate:n=>y(t,n),onSubmit:n=>A(t,n),onComplete:n=>b(t,n)})})}const M=(t,e,n)=>{const{url:i,width:o,height:c}=e,r=n||{},s=document.createElement("a");return s.href=i,s.search.replace("?","").split("&").forEach(a=>{const[d,l]=a.split("=");typeof l<"u"&&(r[d]=l)}),s.search=Object.keys(r).map(a=>`${a}=${r[a]}`).join("&"),window.open(s.href,t,`width=${o},height=${c}`),""};function D(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"chat.popup",render:"email.form",handleClick:n=>{const{title:i,body:o}=n,{form:c,guideId:r,confirmationFallback:s,...a}=o;return c?()=>{}:d=>{d.preventDefault(),M(i,a)}},onValidate:n=>y(t,n),onComplete:n=>b(t,n),onSubmit:n=>{const{title:i,body:o}=n,{form:c,guideId:r,confirmationFallback:s,...a}=o,d=new C.FormReader(c).export().values;return M(i,a,d),s}})})}function F(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"custom.freetext",render:Promise.resolve().then(()=>require("./free-text-component-c14c86de.js"))})})}function V(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"custom.link",render:Promise.resolve().then(()=>require("./link-component-6fbdc8fb.js"))})})}function z(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"phone.text",render:Promise.resolve().then(()=>require("./phone-component-ebf50e0d.js"))})})}const _=async(t,e)=>{const n=t.get(e.clientName);let{description:i,disabled:o,onClick:c}=e;if(n){const{handleClick:r,handleDescription:s,handleDisabled:a}=n;typeof r=="function"&&(c=await Promise.resolve(r(e))),typeof s=="function"&&(i=await Promise.resolve(s(e))),typeof a=="function"&&(o=await Promise.resolve(a(e)))}return Promise.resolve({...e,description:i,disabled:o,onClick:c})};class x{constructor(e,n){N(this,"adapters",new Map);N(this,"subs",[]);if(this.container=e,this.componentPlatform=n,n){n.components().ofType("contact-list").select().actions.watch("contact-list.fetched",async(r,s)=>{const{contactMethods:a}=r;if(a){const d=Promise.all(a.map(l=>this.handleAdapters(l)));await Promise.resolve(d).then(l=>{r.contactMethods=l})}return s(r)});const o=n.components().ofType("guide").select();o.actions.watch("guide.fetched",async(r,s)=>{const{contactMethods:a}=r;if(a){const d=Promise.all(a.map(l=>this.handleAdapters(l)));await Promise.resolve(d).then(l=>{r.contactMethods=l})}return s(r)}),o.actions.watch("guide.handover",async(r,s)=>{const{handoverContactMethods:a}=r;if(a){const d=Promise.all(a.map(l=>this.handleAdapters(l)));await Promise.resolve(d).then(l=>{r.handoverContactMethods=l})}return s(r)}),n.components().ofType("contact-method").select().actions.watch("contact-method.fetched",async(r,s)=>{const{contactMethod:a}=r;return a?this.handleAdapters(a).then(d=>s({...r,contactMethod:d})):s(r)})}}static create(e){return I.ComponentPlatform.getInstance(e).then(n=>new x(e,n))}handleAdapters(e){return _(this.adapters,e)}static getInstance(e,n="contactMethods"){return $.lock(e)(()=>e.getAsync(n).then(i=>{let o=i;return o||I.ComponentPlatform.getInstance(e).then(c=>(o=new x(e,c),e.registerAsync(n,()=>o),o))}))}track(e={},n){const{events:i}=this.container.get("$widget");i.dispatch("tracking:service-client-response",{type:n,data:e})}complete(e){const{id:n,title:i,clientName:o,expanded:c,body:r}=e;this.track({contactMethod:{id:n,title:i,expanded:c,type:o},hasGuide:!!r.guideId},"contact-method-complete");const s=this.adapters.get(o);if(s&&s.onComplete)return s.onComplete(e)}evaluate(e){const{clientName:n}=e,i=this.adapters.get(n);return i&&i.onEvaluate?Promise.resolve(i.onEvaluate(e)):Promise.resolve(e.body.form)}validate(e){const{id:n,title:i,clientName:o}=e,c=this.adapters.get(o);return c&&c.onValidate?Promise.resolve(c.onValidate(e)).then(r=>{this.track({contactMethod:{id:n,title:i,type:o},isValid:r.valid},"contact-method-validate");const{events:s}=this.container.get("$widget");return s.dispatch("form:validated",{isValid:r.valid}),r}):Promise.resolve({valid:!0})}submit(e){const{clientName:n}=e,i=this.adapters.get(n);return i&&i.onSubmit?Promise.resolve(i.onSubmit(e)).then(o=>(this.complete(e),o)):Promise.resolve("")}create(e){const{clientName:n,render:i}=e;return this.adapters.set(n,{onValidate:o=>y(this.container,o),onEvaluate:o=>j(this.container,o),onComplete:o=>b(this.container,o),...e}),this.container.getAsync("componentResolver").then(o=>{typeof i=="string"?this.subs.push(o.registerAlias(n,i)):this.subs.push(o.registerComponent(n,k.lazy(()=>i)))})}dispose(){this.subs.forEach(e=>e())}}p(m.Paragraph)`
2
- ${t=>{var e;return m.headingElement(t)("h1",w.css`
3
- font-weight: normal;
4
- font-size: ${(e=t.theme.fonts)==null?void 0:e.medium};
5
- `)}}
6
- `;const O=p(m.Html)`
7
- ${m.genericHtml}
8
- font-weight: 300;
9
- line-height: 1.5em;
10
- button:focus-visible {
11
- ${m.borderTabStyle};
12
- }
13
-
14
- a:focus-visible {
15
- ${m.linkTabStyle};
16
- }
17
- `,H=t=>{const e=m.useComponent(t.clientName),{params:{contactCategory:n,guideCategory:i,phrase:o}}=m.useRouteData();if(typeof e>"u")return null;if(e===null)return process.env.NODE_ENV!=="production"?u.jsx(te,{title:`client-name: ${t.clientName}, id: ${t.id}`,className:"humany-non-resolved-contact-method",children:u.jsx(m.Typography,{variant:"h5",children:"Non resolved Contact Method type"})}):null;const c=(r={})=>{const s={...t,...r},{id:a,title:d,clientName:l,symbol:f,inline:P,onClick:v=()=>{},description:g,htmlParseInstruction:R,className:G,disabled:J,guideId:Q,dispatch:E=()=>{},expanded:L}=s,X=P?{onKeyDown:h=>{h.key&&h.key==="Enter"&&(v(h,s),h.defaultPrevented||!L&&E("expand",a))},onClick:h=>{v(h,s),h.defaultPrevented||!L&&E("expand",a)}}:{onClick:h=>v(h,s),routeName:"contact-method",params:$.createParams({contactCategory:n,guideId:Q,guideCategory:i,phrase:o,contactMethod:a,uriName:$.formatUrl(d)})};return u.jsxs(ee,{title:d,"aria-label":d,className:G,disabled:J,description:g,"data-client-name":l,...r,...X,children:[f&&u.jsx(m.SymbolBadge,{symbol:f}),g?u.jsxs("div",{className:"humany-contact-link-rich-content",children:[u.jsx(T,{children:d}),u.jsx(O,{html:g,htmlParseInstruction:R})]}):u.jsx(T,{children:d})]})};return t.expanded?u.jsx(k.Suspense,{fallback:null,children:u.jsx(e,{...t,renderDefault:c})}):c()},U=t=>{var e,n,i,o,c,r,s,a;return w.css`
18
- display: flex;
19
- padding: ${(e=t.theme.sizes)==null?void 0:e.large};
20
- ${t.description?"":"align-items: center;"}
21
- text-decoration: none;
22
- span {
23
- display: inline-block;
24
- color: ${(n=t.theme.colors)==null?void 0:n.text};
25
- }
26
- i {
27
- font-size: ${(i=t.theme.fonts)==null?void 0:i.large};
28
- margin: 0 ${(o=t.theme.sizes)==null?void 0:o.large} 0 0;
29
- min-height: ${(c=t.theme.fonts)==null?void 0:c.large};
30
- min-width: ${(r=t.theme.fonts)==null?void 0:r.large};
31
- line-height: ${(s=t.theme.fonts)==null?void 0:s.large};
32
- display: inline-block;
33
- vertical-align: bottom;
34
- color: ${(a=t.theme.colors)==null?void 0:a.text};
35
- }
36
- `},T=p(m.StyledText)`
37
- line-height: ${t=>{var e;return(e=t.theme.fonts)==null?void 0:e.large}};
38
- `,ee=p(m.Link)`
39
- ${t=>U(t)}
40
-
41
- &:focus-visible {
42
- ${m.borderTabStyle};
43
- }
44
- `,te=p.div`
45
- text-align: center;
46
- display: block;
47
- ${t=>{var e,n;return typeof((e=t.theme.colors)==null?void 0:e.warning)<"u"&&`color: ${(n=t.theme.colors)==null?void 0:n.warning};`}}
48
- `,W=t=>{var e,n,i;return w.css`
49
- ${m.itemList(t)}
50
-
51
- > div {
52
- padding: ${(e=t.theme.sizes)==null?void 0:e.large};
53
-
54
- ${m.headingElement(t)("h1",w.css`
55
- margin: 0;
56
- `)}
57
- }
58
-
59
- > ul {
60
- &:not(:first-child) {
61
- border-top: ${t.theme.border};
62
- }
63
-
64
- > li {
65
- margin: 0;
66
- white-space: normal;
67
-
68
- > a {
69
- overflow: hidden;
70
- }
71
-
72
- &:first-child > a {
73
- border-radius: ${`${t.theme.borderRadius} ${t.theme.borderRadius} 0 0`};
74
- }
75
-
76
- &:last-child:not(:first-child) > a {
77
- border-radius: ${`0 0 ${t.theme.borderRadius} ${t.theme.borderRadius}`};
78
- }
79
-
80
- &:not(:last-child) {
81
- border-bottom: ${t.theme.border};
82
- }
83
-
84
- > div {
85
- padding: ${(n=t.theme.sizes)==null?void 0:n.large};
86
- }
87
- }
88
- }
89
-
90
- @media (hover: hover) {
91
- a:hover {
92
- background-color: ${(i=t.theme.colors)==null?void 0:i.accent};
93
- }
94
- }
95
- `},ne=p(m.ItemList)`
96
- ${t=>W(t)}
97
- `,oe=({contactMethods:t,children:e,guideId:n,dispatch:i,className:o="",itemRenderer:c,action:r=()=>{},header:s=""})=>{const a=m.useContainer(),{events:d}=a.get("$widget");return t.length?u.jsx(ne,{header:s,className:$.appendClassNames(o,"humany-contact-list"),items:t,renderItem:c?l=>u.jsx("li",{role:t.length===1?"none":void 0,"data-contact-method":l.id,children:c(l,{action:r,dispatch:i,guideId:n})},l.id):l=>u.jsx("li",{role:t.length===1?"none":void 0,"data-contact-method":l.id,onClick:()=>{d.dispatch("tracking:contact-list-item-clicked",l)},children:u.jsx(H,{...l,action:r,dispatch:i,guideId:n})},l.id),children:e}):null},B=(t,e)=>{if(t.actionKey===e)return t;if(!t.properties)return null;const n=Object.keys(t.properties);let i;for(let o=0;o<n.length;o++)if(i=B(t.properties[n[o]],e),i)return i;return!1},ie=({className:t,body:{form:e},id:n,action:i,dispatch:o,disabled:c,autoFocus:r})=>{if(e&&!c){const{schema:s,layout:a,data:d,meta:l}=e,f=o||i||(()=>{});return u.jsx(C.FormComponent,{className:t,schema:s,layout:a,data:d,autoFocus:r,onChange:(P,v)=>{const g={schema:s,layout:a,data:v,meta:l};P.toString()==="submit"?f("submit",{id:n,form:g}):B(s,P).evaluate?f("evaluate",{id:n,form:g}):f("validate",{id:n,form:g})}})}return null},re=t=>{const[e,n]=k.useState(null),i=m.useContainer();return k.useEffect(()=>{let o;return i.getAsync("componentResolver").then(c=>{o=c.registerResolver(t,r=>n(r))}),()=>{o&&o()}},[t]),e};function K(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"custom.webservice",render:"email.form",onValidate:n=>y(t,n),onComplete:n=>b(t,n),onSubmit:n=>A(t,n,i=>({...i,ConfirmationText:i.ResponseHtml}))})})}const se=(t,e,n)=>t.getAsync("contactMethods").then(i=>{i.create({clientName:e,render:"email.form",handleClick:()=>(o,c)=>{const{body:{form:r,guideId:s,confirmationFallback:a,...d}}=c;r||(o.preventDefault(),n(d))},onValidate:o=>y(t,o),onComplete:o=>b(t,o),onSubmit:o=>{const{body:{form:c,guideId:r,confirmationFallback:s,...a}}=o,{values:d}=new C.FormReader(c).export();return Promise.resolve(n(a,d)).then(l=>l||s)}})});class ae extends I.Plugin{constructor(e,n){super(e,n),this.widget.implementation.configure(o=>{o.plugin(q).plugin(D).plugin(F).plugin(z).plugin(K).plugin(V)})}}exports.ContactList=oe;exports.ContactMethod=H;exports.ContactMethodPlatform=x;exports.DefaultContactMethodsPlugin=ae;exports.Description=O;exports.Form=ie;exports.chatPopupPlugin=D;exports.complete=b;exports.contactItemList=W;exports.contactLink=U;exports.createSubmitAdapter=se;exports.emailPlugin=q;exports.evaluate=j;exports.freeTextPlugin=F;exports.linkPlugin=V;exports.phonePlugin=z;exports.submit=A;exports.useContactMethod=re;exports.validate=y;exports.webServicePlugin=K;