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

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.
@@ -3,7 +3,7 @@ import { css as l } from "@emotion/react";
3
3
  import c from "@emotion/styled";
4
4
  import { genericHtml as f, headingElement as d, Html as h } from "@telia-ace/knowledge-widget-ui";
5
5
  import { appendClassNames as r } from "@telia-ace/widget-utilities";
6
- import { F as u } from "./index-C0zDP2YF.mjs";
6
+ import { F as u } from "./index-D4XSiXsg.mjs";
7
7
  import "react";
8
8
  const p = c(h)`
9
9
  ${f}
@@ -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-Bj6NPYaU.js");require("react");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-BFS2vrQq.js");require("react");const h=u(n.Html)`
2
2
  ${n.genericHtml}
3
3
 
4
4
  ${e=>{var t;return n.headingElement(e)("h1",l.css`
@@ -2,7 +2,7 @@ import { jsxs as l, jsx as r } from "react/jsx-runtime";
2
2
  import p from "@emotion/styled";
3
3
  import { genericHtml as s, Html as i } from "@telia-ace/knowledge-widget-ui";
4
4
  import { appendClassNames as n } from "@telia-ace/widget-utilities";
5
- import { D as a } from "./index-C0zDP2YF.mjs";
5
+ import { D as a } from "./index-D4XSiXsg.mjs";
6
6
  import "@telia-ace/widget-forms";
7
7
  import "react";
8
8
  const j = ({
@@ -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"),o=require("@telia-ace/widget-utilities"),u=require("./index-Bj6NPYaU.js");require("@telia-ace/widget-forms");require("react");const c=({className:s,description:t,body:{freetext:r},htmlParseInstruction:i})=>r?e.jsxs("div",{className:o.appendClassNames(s,"humany-contact-method-free-text"),children:[e.jsx(d,{html:r,htmlParseInstruction:i}),t&&e.jsx(u.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"),o=require("@telia-ace/widget-utilities"),u=require("./index-BFS2vrQq.js");require("@telia-ace/widget-forms");require("react");const c=({className:s,description:t,body:{freetext:r},htmlParseInstruction:i})=>r?e.jsxs("div",{className:o.appendClassNames(s,"humany-contact-method-free-text"),children:[e.jsx(d,{html:r,htmlParseInstruction:i}),t&&e.jsx(u.Description,{html:t,htmlParseInstruction:i})]}):null,d=l(n.Html)`
2
2
  ${n.genericHtml};
3
3
  `;exports.default=c;
@@ -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);const C=require("@telia-ace/widget-forms"),S=require("@telia-ace/knowledge-widget-core"),k=require("@telia-ace/widget-utilities"),P=require("react"),u=require("react/jsx-runtime"),w=require("@emotion/react"),f=require("@emotion/styled"),m=require("@telia-ace/knowledge-widget-ui"),I=(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();e.guideId=e.body.guideId||s.guideId;const a=JSON.parse(o.get("components"))??{};return a.site??(a.site=r.getConfiguration().site),o.set("components",JSON.stringify(a)),r.customRequest(`contactmethods/${e.id}${n?"/validatedwithpayload":""}`,"POST",{body:o,configuration:{guideId:e.body.guideId||s.guideId}})}),A=(t,e,n)=>I(t,e).then(i=>n?n(i):i).then(({ConfirmationText:i})=>i),y=(t,e)=>I(t,e,!0).then(n=>({valid:n.Validation.IsValid,errors:n.Validation.Errors,errorTypes:n.Validation.ErrorTypes})),j=(t,e)=>I(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 F(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"email.form",render:Promise.resolve().then(()=>require("./email-form-component-CIl0FWR3.js")),onEvaluate:n=>j(t,n),onValidate:n=>y(t,n),onSubmit:n=>A(t,n),onComplete:n=>b(t,n)})})}const q=(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 M(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(),q(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 q(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-D0fNPPU2.js"))})})}function z(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"custom.link",render:Promise.resolve().then(()=>require("./link-component-C9N5NmxE.js"))})})}function O(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"phone.text",render:Promise.resolve().then(()=>require("./phone-component-Cs-2D-oo.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 S.ComponentPlatform.getInstance(e).then(n=>new x(e,n))}handleAdapters(e){return ee(this.adapters,e)}static getInstance(e,n="contactMethods"){return k.lock(e)(()=>e.getAsync(n).then(i=>{let o=i;return o||S.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,P.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 H=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:v=()=>{},description:g,htmlParseInstruction:T,className:G,disabled:Q,guideId:X,dispatch:E=()=>{},expanded:L}=s,Y=$?{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:k.createParams({contactCategory:n,guideId:X,guideCategory:i,phrase:o,contactMethod:a,uriName:k.formatUrl(d)})};let R;if(l==="phone.text"||l==="ace.phone"||l==="ace.callback"){const h=document.createElement("div");h.innerHTML=g,R=h.innerText}return u.jsxs(te,{title:d,"aria-label":l==="phone.text"||l==="ace.phone"||l==="ace.callback"?`${d} ${R}`:d,className:G,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(D,{children:d}),u.jsx(H,{html:g,htmlParseInstruction:T})]}):u.jsx(D,{children:d})]})};return t.expanded?u.jsx(P.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
+ `},D=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:k.appendClassNames(o,"humany-contact-list"),items:t,renderItem:c?l=>u.jsx("li",{role:t.length===1&&t[0].expanded?"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&&t[0].expanded?"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},J=(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=J(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:($,v)=>{const g={schema:s,layout:a,data:v,meta:l};$.toString()==="submit"?p("submit",{id:n,form:g}):J(s,$).evaluate?p("evaluate",{id:n,form:g}):p("validate",{id:n,form:g})}})}return null},se=t=>{const[e,n]=P.useState(null),i=m.useContainer();return P.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 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=>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 ce extends S.Plugin{constructor(e,n){super(e,n),this.widget.implementation.configure(o=>{o.plugin(F).plugin(M).plugin(V).plugin(O).plugin(K).plugin(z)})}}exports.ContactList=ie;exports.ContactMethod=U;exports.ContactMethodPlatform=x;exports.DefaultContactMethodsPlugin=ce;exports.Description=H;exports.Form=re;exports.chatPopupPlugin=M;exports.complete=b;exports.contactItemList=B;exports.contactLink=W;exports.createSubmitAdapter=ae;exports.emailPlugin=F;exports.evaluate=j;exports.freeTextPlugin=V;exports.linkPlugin=z;exports.phonePlugin=O;exports.submit=A;exports.useContactMethod=se;exports.validate=y;exports.webServicePlugin=K;
@@ -1,25 +1,27 @@
1
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);
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";
2
+ var J = (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) => J(t, typeof e != "symbol" ? e + "" : e, 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 Q, formatUrl as X, appendClassNames as Y } from "@telia-ace/widget-utilities";
7
7
  import { lazy as Z, Suspense as _, useState as ee, useEffect as te } from "react";
8
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 { headingElement as D, Paragraph as ne, genericHtml as oe, borderTabStyle as L, linkTabStyle as ie, Html as re, StyledText as ae, Link as se, 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";
11
+ import { headingElement as D, Paragraph as ne, genericHtml as oe, borderTabStyle as L, linkTabStyle as ie, Html 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
15
- ), { router: c, matchingClient: r } = i, { params: a } = c.getRouteData();
16
- return e.guideId = e.body.guideId || a.guideId, r.customRequest(
15
+ ), { router: c, matchingClient: r } = i, { params: s } = c.getRouteData();
16
+ e.guideId = e.body.guideId || s.guideId;
17
+ const a = JSON.parse(o.get("components")) ?? {};
18
+ return a.site ?? (a.site = r.getConfiguration().site), o.set("components", JSON.stringify(a)), r.customRequest(
17
19
  `contactmethods/${e.id}${n ? "/validatedwithpayload" : ""}`,
18
20
  "POST",
19
21
  {
20
22
  body: o,
21
23
  configuration: {
22
- guideId: e.body.guideId || a.guideId
24
+ guideId: e.body.guideId || s.guideId
23
25
  }
24
26
  }
25
27
  );
@@ -30,7 +32,7 @@ const P = (t, e, n = !1) => t.getManyAsync("matchingClient", "router").then((i)
30
32
  errorTypes: n.Validation.ErrorTypes
31
33
  })
32
34
  ), M = (t, e) => P(t, e, !0).then(
33
- (n) => G.fromLegacyForm(
35
+ (n) => K.fromLegacyForm(
34
36
  e.id,
35
37
  n.ContactMethod.Form
36
38
  ).get()
@@ -43,7 +45,7 @@ function pe(t) {
43
45
  t.getAsync("contactMethods").then((e) => {
44
46
  e.create({
45
47
  clientName: "email.form",
46
- render: import("./email-form-component-BWOyYs-S.mjs"),
48
+ render: import("./email-form-component-BCofw5KQ.mjs"),
47
49
  onEvaluate: (n) => M(t, n),
48
50
  onValidate: (n) => y(t, n),
49
51
  onSubmit: (n) => F(t, n),
@@ -52,11 +54,11 @@ function pe(t) {
52
54
  });
53
55
  }
54
56
  const T = (t, e, n) => {
55
- const { url: i, width: o, height: c } = e, r = n || {}, a = document.createElement("a");
56
- return a.href = i, a.search.replace("?", "").split("&").forEach((s) => {
57
- const [d, l] = s.split("=");
57
+ const { url: i, width: o, height: c } = e, r = n || {}, s = document.createElement("a");
58
+ return s.href = i, s.search.replace("?", "").split("&").forEach((a) => {
59
+ const [d, l] = a.split("=");
58
60
  typeof l < "u" && (r[d] = l);
59
- }), a.search = Object.keys(r).map((s) => `${s}=${r[s]}`).join("&"), window.open(a.href, t, `width=${o},height=${c}`), "";
61
+ }), s.search = Object.keys(r).map((a) => `${a}=${r[a]}`).join("&"), window.open(s.href, t, `width=${o},height=${c}`), "";
60
62
  };
61
63
  function fe(t) {
62
64
  t.getAsync("contactMethods").then((e) => {
@@ -64,17 +66,17 @@ function fe(t) {
64
66
  clientName: "chat.popup",
65
67
  render: "email.form",
66
68
  handleClick: (n) => {
67
- const { title: i, body: o } = n, { form: c, guideId: r, confirmationFallback: a, ...s } = o;
69
+ const { title: i, body: o } = n, { form: c, guideId: r, confirmationFallback: s, ...a } = o;
68
70
  return c ? () => {
69
71
  } : (d) => {
70
- d.preventDefault(), T(i, s);
72
+ d.preventDefault(), T(i, a);
71
73
  };
72
74
  },
73
75
  onValidate: (n) => y(t, n),
74
76
  onComplete: (n) => b(t, n),
75
77
  onSubmit: (n) => {
76
- const { title: i, body: o } = n, { form: c, guideId: r, confirmationFallback: a, ...s } = o, d = new w(c).export().values;
77
- return T(i, s, d), a;
78
+ const { title: i, body: o } = n, { form: c, guideId: r, confirmationFallback: s, ...a } = o, d = new w(c).export().values;
79
+ return T(i, a, d), s;
78
80
  }
79
81
  });
80
82
  });
@@ -83,7 +85,7 @@ function ge(t) {
83
85
  t.getAsync("contactMethods").then((e) => {
84
86
  e.create({
85
87
  clientName: "custom.freetext",
86
- render: import("./free-text-component-_JCU7mWa.mjs")
88
+ render: import("./free-text-component-C8xYyKPg.mjs")
87
89
  });
88
90
  });
89
91
  }
@@ -107,8 +109,8 @@ const ve = async (t, e) => {
107
109
  const n = t.get(e.clientName);
108
110
  let { description: i, disabled: o, onClick: c } = e;
109
111
  if (n) {
110
- const { handleClick: r, handleDescription: a, handleDisabled: s } = n;
111
- typeof r == "function" && (c = await Promise.resolve(r(e))), typeof a == "function" && (i = await Promise.resolve(a(e))), typeof s == "function" && (o = await Promise.resolve(s(e)));
112
+ const { handleClick: r, handleDescription: s, handleDisabled: a } = n;
113
+ 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)));
112
114
  }
113
115
  return Promise.resolve({
114
116
  ...e,
@@ -124,11 +126,11 @@ class k {
124
126
  if (this.container = e, this.componentPlatform = n, n) {
125
127
  n.components().ofType("contact-list").select().actions.watch(
126
128
  "contact-list.fetched",
127
- async (r, a) => {
128
- const { contactMethods: s } = r;
129
- if (s) {
129
+ async (r, s) => {
130
+ const { contactMethods: a } = r;
131
+ if (a) {
130
132
  const d = Promise.all(
131
- s.map(
133
+ a.map(
132
134
  (l) => this.handleAdapters(l)
133
135
  )
134
136
  );
@@ -136,15 +138,15 @@ class k {
136
138
  r.contactMethods = l;
137
139
  });
138
140
  }
139
- return a(r);
141
+ return s(r);
140
142
  }
141
143
  );
142
144
  const o = n.components().ofType("guide").select();
143
- o.actions.watch("guide.fetched", async (r, a) => {
144
- const { contactMethods: s } = r;
145
- if (s) {
145
+ o.actions.watch("guide.fetched", async (r, s) => {
146
+ const { contactMethods: a } = r;
147
+ if (a) {
146
148
  const d = Promise.all(
147
- s.map(
149
+ a.map(
148
150
  (l) => this.handleAdapters(l)
149
151
  )
150
152
  );
@@ -152,12 +154,12 @@ class k {
152
154
  r.contactMethods = l;
153
155
  });
154
156
  }
155
- return a(r);
156
- }), o.actions.watch("guide.handover", async (r, a) => {
157
- const { handoverContactMethods: s } = r;
158
- if (s) {
157
+ return s(r);
158
+ }), o.actions.watch("guide.handover", async (r, s) => {
159
+ const { handoverContactMethods: a } = r;
160
+ if (a) {
159
161
  const d = Promise.all(
160
- s.map(
162
+ a.map(
161
163
  (l) => this.handleAdapters(l)
162
164
  )
163
165
  );
@@ -165,26 +167,26 @@ class k {
165
167
  r.handoverContactMethods = l;
166
168
  });
167
169
  }
168
- return a(r);
170
+ return s(r);
169
171
  }), n.components().ofType("contact-method").select().actions.watch(
170
172
  "contact-method.fetched",
171
- async (r, a) => {
172
- const { contactMethod: s } = r;
173
- return s ? this.handleAdapters(s).then((d) => a({ ...r, contactMethod: d })) : a(r);
173
+ async (r, s) => {
174
+ const { contactMethod: a } = r;
175
+ return a ? this.handleAdapters(a).then((d) => s({ ...r, contactMethod: d })) : s(r);
174
176
  }
175
177
  );
176
178
  }
177
179
  }
178
180
  static create(e) {
179
- return S.getInstance(e).then((n) => new k(e, n));
181
+ return A.getInstance(e).then((n) => new k(e, n));
180
182
  }
181
183
  handleAdapters(e) {
182
184
  return ve(this.adapters, e);
183
185
  }
184
186
  static getInstance(e, n = "contactMethods") {
185
- return J(e)(() => e.getAsync(n).then((i) => {
187
+ return W(e)(() => e.getAsync(n).then((i) => {
186
188
  let o = i;
187
- return o || S.getInstance(e).then((c) => (o = new k(
189
+ return o || A.getInstance(e).then((c) => (o = new k(
188
190
  e,
189
191
  c
190
192
  ), e.registerAsync(n, () => o), o));
@@ -207,9 +209,9 @@ class k {
207
209
  "contact-method-complete"
208
210
  /* ContactMethodComplete */
209
211
  );
210
- const a = this.adapters.get(o);
211
- if (a && a.onComplete)
212
- return a.onComplete(e);
212
+ const s = this.adapters.get(o);
213
+ if (s && s.onComplete)
214
+ return s.onComplete(e);
213
215
  }
214
216
  evaluate(e) {
215
217
  const { clientName: n } = e, i = this.adapters.get(n);
@@ -227,8 +229,8 @@ class k {
227
229
  "contact-method-validate"
228
230
  /* ContactMethodValidate */
229
231
  );
230
- const { events: a } = this.container.get("$widget");
231
- return a.dispatch("form:validated", { isValid: r.valid }), r;
232
+ const { events: s } = this.container.get("$widget");
233
+ return s.dispatch("form:validated", { isValid: r.valid }), r;
232
234
  }
233
235
  ) : Promise.resolve({ valid: !0 });
234
236
  }
@@ -295,8 +297,8 @@ const Ce = f(re)`
295
297
  }
296
298
  ) : null;
297
299
  const c = (r = {}) => {
298
- const a = { ...t, ...r }, {
299
- id: s,
300
+ const s = { ...t, ...r }, {
301
+ id: a,
300
302
  title: d,
301
303
  clientName: l,
302
304
  symbol: p,
@@ -304,44 +306,44 @@ const Ce = f(re)`
304
306
  onClick: g = () => {
305
307
  },
306
308
  description: u,
307
- htmlParseInstruction: x,
309
+ htmlParseInstruction: N,
308
310
  className: j,
309
- disabled: H,
310
- guideId: O,
311
- dispatch: N = () => {
311
+ disabled: O,
312
+ guideId: H,
313
+ dispatch: x = () => {
312
314
  },
313
315
  expanded: I
314
- } = a, q = v ? {
316
+ } = s, q = v ? {
315
317
  onKeyDown: (h) => {
316
- h.key && h.key === "Enter" && (g(h, a), h.defaultPrevented || !I && N("expand", s));
318
+ h.key && h.key === "Enter" && (g(h, s), h.defaultPrevented || !I && x("expand", a));
317
319
  },
318
320
  onClick: (h) => {
319
- g(h, a), h.defaultPrevented || !I && N("expand", s);
321
+ g(h, s), h.defaultPrevented || !I && x("expand", a);
320
322
  }
321
323
  } : {
322
- onClick: (h) => g(h, a),
324
+ onClick: (h) => g(h, s),
323
325
  routeName: "contact-method",
324
326
  params: Q({
325
327
  contactCategory: n,
326
- guideId: O,
328
+ guideId: H,
327
329
  guideCategory: i,
328
330
  phrase: o,
329
- contactMethod: s,
331
+ contactMethod: a,
330
332
  uriName: X(d)
331
333
  })
332
334
  };
333
- let A;
335
+ let S;
334
336
  if (l === "phone.text" || l === "ace.phone" || l === "ace.callback") {
335
337
  const h = document.createElement("div");
336
- h.innerHTML = u, A = h.innerText;
338
+ h.innerHTML = u, S = h.innerText;
337
339
  }
338
340
  return /* @__PURE__ */ E(
339
341
  we,
340
342
  {
341
343
  title: d,
342
- "aria-label": l === "phone.text" || l === "ace.phone" || l === "ace.callback" ? `${d} ${A}` : d,
344
+ "aria-label": l === "phone.text" || l === "ace.phone" || l === "ace.callback" ? `${d} ${S}` : d,
343
345
  className: j,
344
- disabled: H,
346
+ disabled: O,
345
347
  description: u,
346
348
  "data-client-name": l,
347
349
  ...r,
@@ -354,7 +356,7 @@ const Ce = f(re)`
354
356
  Ce,
355
357
  {
356
358
  html: u,
357
- htmlParseInstruction: x
359
+ htmlParseInstruction: N
358
360
  }
359
361
  )
360
362
  ] }) : /* @__PURE__ */ m(V, { children: d })
@@ -364,7 +366,7 @@ const Ce = f(re)`
364
366
  };
365
367
  return t.expanded ? /* @__PURE__ */ m(_, { fallback: null, children: /* @__PURE__ */ m(e, { ...t, renderDefault: c }) }) : c();
366
368
  }, ke = (t) => {
367
- var e, n, i, o, c, r, a, s;
369
+ var e, n, i, o, c, r, s, a;
368
370
  return C`
369
371
  display: flex;
370
372
  padding: ${(e = t.theme.sizes) == null ? void 0 : e.large};
@@ -379,18 +381,18 @@ const Ce = f(re)`
379
381
  margin: 0 ${(o = t.theme.sizes) == null ? void 0 : o.large} 0 0;
380
382
  min-height: ${(c = t.theme.fonts) == null ? void 0 : c.large};
381
383
  min-width: ${(r = t.theme.fonts) == null ? void 0 : r.large};
382
- line-height: ${(a = t.theme.fonts) == null ? void 0 : a.large};
384
+ line-height: ${(s = t.theme.fonts) == null ? void 0 : s.large};
383
385
  display: inline-block;
384
386
  vertical-align: bottom;
385
- color: ${(s = t.theme.colors) == null ? void 0 : s.text};
387
+ color: ${(a = t.theme.colors) == null ? void 0 : a.text};
386
388
  }
387
389
  `;
388
- }, V = f(ae)`
390
+ }, V = f(se)`
389
391
  line-height: ${(t) => {
390
392
  var e;
391
393
  return (e = t.theme.fonts) == null ? void 0 : e.large;
392
394
  }};
393
- `, we = f(se)`
395
+ `, we = f(ae)`
394
396
  ${(t) => ke(t)}
395
397
 
396
398
  &:focus-visible {
@@ -403,7 +405,7 @@ const Ce = f(re)`
403
405
  var e, n;
404
406
  return typeof ((e = t.theme.colors) == null ? void 0 : e.warning) < "u" && `color: ${(n = t.theme.colors) == null ? void 0 : n.warning};`;
405
407
  }}
406
- `, xe = (t) => {
408
+ `, Ne = (t) => {
407
409
  var e, n, i;
408
410
  return C`
409
411
  ${ue(t)}
@@ -456,8 +458,8 @@ const Ce = f(re)`
456
458
  }
457
459
  }
458
460
  `;
459
- }, Ne = f(he)`
460
- ${(t) => xe(t)}
461
+ }, xe = f(he)`
462
+ ${(t) => Ne(t)}
461
463
  `, Me = ({
462
464
  contactMethods: t,
463
465
  children: e,
@@ -467,13 +469,13 @@ const Ce = f(re)`
467
469
  itemRenderer: c,
468
470
  action: r = () => {
469
471
  },
470
- header: a = ""
472
+ header: s = ""
471
473
  }) => {
472
- const s = R(), { events: d } = s.get("$widget");
474
+ const a = R(), { events: d } = a.get("$widget");
473
475
  return t.length ? /* @__PURE__ */ m(
474
- Ne,
476
+ xe,
475
477
  {
476
- header: a,
478
+ header: s,
477
479
  className: Y(o, "humany-contact-list"),
478
480
  items: t,
479
481
  renderItem: c ? (l) => /* @__PURE__ */ m(
@@ -528,19 +530,19 @@ const Ce = f(re)`
528
530
  autoFocus: r
529
531
  }) => {
530
532
  if (e && !c) {
531
- const { schema: a, layout: s, data: d, meta: l } = e, p = o || i || (() => {
533
+ const { schema: s, layout: a, data: d, meta: l } = e, p = o || i || (() => {
532
534
  });
533
535
  return /* @__PURE__ */ m(
534
- U,
536
+ G,
535
537
  {
536
538
  className: t,
537
- schema: a,
538
- layout: s,
539
+ schema: s,
540
+ layout: a,
539
541
  data: d,
540
542
  autoFocus: r,
541
543
  onChange: (v, g) => {
542
- const u = { schema: a, layout: s, data: g, meta: l };
543
- v.toString() === "submit" ? p("submit", { id: n, form: u }) : z(a, v).evaluate ? p("evaluate", { id: n, form: u }) : p("validate", { id: n, form: u });
544
+ const u = { schema: s, layout: a, data: g, meta: l };
545
+ 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 });
544
546
  }
545
547
  }
546
548
  );
@@ -574,13 +576,13 @@ function Ie(t) {
574
576
  });
575
577
  });
576
578
  }
577
- const He = (t, e, n) => t.getAsync("contactMethods").then((i) => {
579
+ const Oe = (t, e, n) => t.getAsync("contactMethods").then((i) => {
578
580
  i.create({
579
581
  clientName: e,
580
582
  render: "email.form",
581
583
  handleClick: () => (o, c) => {
582
584
  const {
583
- body: { form: r, guideId: a, confirmationFallback: s, ...d }
585
+ body: { form: r, guideId: s, confirmationFallback: a, ...d }
584
586
  } = c;
585
587
  r || (o.preventDefault(), n(d));
586
588
  },
@@ -588,13 +590,13 @@ const He = (t, e, n) => t.getAsync("contactMethods").then((i) => {
588
590
  onComplete: (o) => b(t, o),
589
591
  onSubmit: (o) => {
590
592
  const {
591
- body: { form: c, guideId: r, confirmationFallback: a, ...s }
593
+ body: { form: c, guideId: r, confirmationFallback: s, ...a }
592
594
  } = o, { values: d } = new w(c).export();
593
- return Promise.resolve(n(s, d)).then((l) => l || a);
595
+ return Promise.resolve(n(a, d)).then((l) => l || s);
594
596
  }
595
597
  });
596
598
  });
597
- class Oe extends W {
599
+ class He extends U {
598
600
  constructor(e, n) {
599
601
  super(e, n), this.widget.implementation.configure((o) => {
600
602
  o.plugin(pe).plugin(fe).plugin(ge).plugin(be).plugin(Ie).plugin(ye);
@@ -608,12 +610,12 @@ export {
608
610
  $e as a,
609
611
  k as b,
610
612
  fe as c,
611
- Oe as d,
613
+ He as d,
612
614
  pe as e,
613
615
  ge as f,
614
- xe as g,
616
+ Ne as g,
615
617
  ke as h,
616
- He as i,
618
+ Oe as i,
617
619
  b as j,
618
620
  M as k,
619
621
  ye as l,
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-Bj6NPYaU.js");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-BFS2vrQq.js");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 e, C as s, a as l, b as o, d as u, F as i, e as n, f as c, l as d, p as P, w as f, g as m, h as r, i as g, j as C, k as h, s as p, v as b, u as F } from "./index-C0zDP2YF.mjs";
1
+ import { c as e, C as s, a as l, b as o, d as u, F as i, e as n, f as c, l as d, p as P, w as f, g as m, h as r, i as g, j as C, k as h, s as p, v as b, u as F } from "./index-D4XSiXsg.mjs";
2
2
  export {
3
3
  e as ChatPopupPlugin,
4
4
  s as ContactList,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/knowledge-widget-adapters",
3
- "version": "1.3.42-rc.0",
3
+ "version": "1.3.42",
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.3.42-rc.0",
15
- "@telia-ace/knowledge-widget-ui": "^1.3.42-rc.0",
16
- "@telia-ace/widget-forms": "^1.3.42-rc.0",
17
- "@telia-ace/widget-routing": "^1.3.42-rc.0",
18
- "@telia-ace/widget-utilities": "^1.3.42-rc.0",
14
+ "@telia-ace/knowledge-widget-core": "^1.3.42",
15
+ "@telia-ace/knowledge-widget-ui": "^1.3.42",
16
+ "@telia-ace/widget-forms": "^1.3.42",
17
+ "@telia-ace/widget-routing": "^1.3.42",
18
+ "@telia-ace/widget-utilities": "^1.3.42",
19
19
  "@webprovisions/platform": "^1.1.4"
20
20
  },
21
21
  "peerDependencies": {
package/index-Bj6NPYaU.js DELETED
@@ -1,97 +0,0 @@
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);const C=require("@telia-ace/widget-forms"),I=require("@telia-ace/knowledge-widget-core"),k=require("@telia-ace/widget-utilities"),P=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()),b=(t,e)=>t.getAsync("matchingClient").then(n=>{n.completeContactMethod(e.id,{guideId:e.guideId})});function F(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"email.form",render:Promise.resolve().then(()=>require("./email-form-component-BH0fpxsr.js")),onEvaluate:n=>j(t,n),onValidate:n=>y(t,n),onSubmit:n=>A(t,n),onComplete:n=>b(t,n)})})}const q=(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 M(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(),q(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 q(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-m6o_GGCc.js"))})})}function z(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"custom.link",render:Promise.resolve().then(()=>require("./link-component-C9N5NmxE.js"))})})}function H(t){t.getAsync("contactMethods").then(e=>{e.create({clientName:"phone.text",render:Promise.resolve().then(()=>require("./phone-component-Cs-2D-oo.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 k.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,P.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:v=()=>{},description:g,htmlParseInstruction:T,className:J,disabled:Q,guideId:X,dispatch:E=()=>{},expanded:L}=s,Y=$?{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:k.createParams({contactCategory:n,guideId:X,guideCategory:i,phrase:o,contactMethod:a,uriName:k.formatUrl(d)})};let R;if(l==="phone.text"||l==="ace.phone"||l==="ace.callback"){const h=document.createElement("div");h.innerHTML=g,R=h.innerText}return u.jsxs(te,{title:d,"aria-label":l==="phone.text"||l==="ace.phone"||l==="ace.callback"?`${d} ${R}`: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(D,{children:d}),u.jsx(O,{html:g,htmlParseInstruction:T})]}):u.jsx(D,{children:d})]})};return t.expanded?u.jsx(P.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
- `},D=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:k.appendClassNames(o,"humany-contact-list"),items:t,renderItem:c?l=>u.jsx("li",{role:t.length===1&&t[0].expanded?"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&&t[0].expanded?"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:($,v)=>{const g={schema:s,layout:a,data:v,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]=P.useState(null),i=m.useContainer();return P.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=>b(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=>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 ce extends I.Plugin{constructor(e,n){super(e,n),this.widget.implementation.configure(o=>{o.plugin(F).plugin(M).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=M;exports.complete=b;exports.contactItemList=B;exports.contactLink=W;exports.createSubmitAdapter=ae;exports.emailPlugin=F;exports.evaluate=j;exports.freeTextPlugin=V;exports.linkPlugin=z;exports.phonePlugin=H;exports.submit=A;exports.useContactMethod=se;exports.validate=y;exports.webServicePlugin=G;