@telia-ace/knowledge-data-client-flamingo 1.1.123-rc.9 → 1.1.123
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.
- package/index.js +1 -1
- package/index.mjs +47 -47
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=(s,e,t,...n)=>{const i=`[${s.get("$environment").name||"webprovisions"}] ${t}`;switch(e){case"info":console.info(i,...n);break;case"warning":console.warn(i,...n);break;case"error":console.error(i,...n);break}},se=s=>{const e=s.container||s;return{info:(t,...n)=>j(e,"info",t,...n),warn:(t,...n)=>j(e,"warning",t,...n),error:(t,...n)=>j(e,"error",t,...n)}};var T=(s=>(s.Implementation="implementation",s.Widget="widget",s))(T||{}),k=(s=>(s.Pre="pre",s.Post="post",s))(k||{});const ie=(s,e,t,n)=>{try{const i=new e(t,n);return{name:s,invoke:(o,a)=>{let r;return i[o]&&(r=i[o].call(i,a)),Promise.resolve(r)},getInstance:()=>i}}catch(i){if(i.message&&i.message.indexOf("is not a constructor")>=0)return{name:s,invoke:o=>{let a;return o==="initialize"&&(a=e(t,n)),Promise.resolve(a)},getInstance:()=>e};throw i}};function W(s,e){return typeof s>"u"?e:s}class ne{constructor(e={}){this.part=e}createCommand(e,t,n){let i;typeof t=="function"?i={scope:T.Widget,stage:k.Post,defaultArgs:void 0,handlerResolver:t}:i={scope:W(t.scope,T.Widget),stage:W(t.stage,k.Post),defaultArgs:t.defaultArgs,handlerResolver:n};let o=this.part;const a=e.split(".");return a.forEach((r,c)=>{c===a.length-1?o[r]||(o[r]=()=>i):o=this.part[r]=this.part[r]||{}}),this}get(){return this.part}}const z=s=>{const e=new ne({});return s(e),e.get()};z(s=>{s.createCommand("types.register",{scope:T.Implementation,stage:k.Pre},e=>(t,n)=>{e.container.get("$types")[t]=n}).createCommand("type",{stage:k.Pre},e=>t=>{e.container.register("$type",t)}).createCommand("settings",{stage:k.Pre,defaultArgs:[null]},e=>t=>{e.events.dispatch("settings:change",t,{bubbles:!0}),e.container.register("$settings",t)}).createCommand("plugin",{stage:k.Pre},e=>(t,n,i)=>{const{container:o}=e;let a=null,r=t,c=n;typeof t=="string"&&(a=t,r=n,c=i);const d=u=>{const{transformPluginSettings:f}=e.container.get("$environmentOptions"),h=f?f(c||{},a,e.container,r):n;try{const p=ie(a,r,o,h);o.get("$plugins").push(p),u&&p.invoke("initialize",null)}catch(p){se(e).warn("Error when initializing plugin",p)}};e.container.get("$instance")?d(!0):e.events.subscribeOnce("widget:instance-created",()=>d(!1))}).createCommand("container.register",e=>(t,n)=>{e.container.register(t,n)}).createCommand("container.registerAsync",e=>(t,n)=>{e.container.registerAsync(t,n)}).createCommand("container.registerFactory",e=>(t,n)=>{e.container.registerFactory(t,n)}).createCommand("container.touch",e=>(t,n)=>{e.container.touch(t,n)}).createCommand("csp",{},e=>t=>{e.container.register("csp",t)})});const G=(s,e,...t)=>typeof e=="string"?s(`[humany] ${e}`,...t):s(e,...t),M=class{constructor(){this.keys=[],this.log=(s,...e)=>this.lookup(s,()=>M.log(...e)),this.warn=(s,...e)=>this.lookup(s,()=>M.warn(...e)),this.error=(s,...e)=>this.lookup(s,()=>M.error(...e)),this.info=(s,...e)=>this.lookup(s,()=>M.info(...e))}lookup(s,e){this.keys.indexOf(s)===-1&&(this.keys.push(s),e())}};let S=M;S.log=(...s)=>G(console.log,...s);S.warn=(...s)=>G(console.warn,...s);S.error=(...s)=>G(console.error,...s);S.info=(...s)=>G(console.info,...s);const V=s=>{let e={},t,n;if(typeof s!="object"||s===null)return s;e=Array.isArray(s)?[]:{};for(n in s)t=s[n],e[n]=typeof t=="object"&&t!==null?V(t):t;return e};class oe{constructor(e,t){this.lockWarningTime=e,this.lockErrorTime=t,this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(e,t,n,i){this.tasks.push({task:e,resolve:t,reject:n,done:i}),this.next()}next(){this.current=this.current.then(()=>{const e=this.tasks.shift();if(e){let t;const n=setTimeout(()=>{process.env.NODE_ENV!=="production"&&S.warn(`A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,e),t=setTimeout(()=>{e.reject("lock timeout exceeded")},this.lockErrorTime)},this.lockWarningTime),i=Promise.resolve(e.task()).then(o=>(clearTimeout(n),clearTimeout(t),o));return Promise.resolve(i).then(this.next).then(()=>i.then(o=>{e.done(),e.resolve(o)})).catch(o=>(e.done(),e.reject(o),this.next()))}return Promise.resolve()})}}const P=new WeakMap;function re(s,e=5e3,t=1e3){return P.has(s)||P.set(s,new oe(e,t)),n=>new Promise((i,o)=>{const a=P.get(s);a.add(n,i,o,()=>{a.tasks.length||P.delete(s)})})}const ae=(s={})=>(Object.keys(s).forEach(e=>{(s[e]===null||typeof s[e]>"u")&&delete s[e]}),s),R=(s,e)=>{let t=!0;return Object.keys(s).length!==Object.keys(e).length||Object.keys(s).some(n=>!Object.keys(e).some(i=>n===i))?!1:(Object.keys(s).forEach(n=>{if(t){const i=typeof s[n]>"u"?"":s[n],o=typeof e[n]>"u"?"":e[n];t=i.toString()===o.toString()}}),t)};z(s=>{s.createCommand("components",e=>t=>{e.events.subscribeOnce("components:platform-created",(n,{platform:i})=>{t.handlers&&t.handlers.forEach(([o,a])=>{i.addComponentHandler(o,a)})})})});var q=(s=>(s.open="open",s.closed="closed",s.hidden="hidden",s))(q||{});const K=s=>Promise.resolve().then(()=>require("./index-WiNloX2z.js")).then(({ServiceClient:e,ServiceProxy:t})=>s.get("settings").then(n=>{const{name:i,events:o}=s.get("$widget"),{data:{projection:a="",site:r="current",forceHttps:c=!1}}=n,d=new t(a,{credentials:"same-origin"}),u=new e(d,{funnel:i.replace("_contact-method","").replace("_contact",""),site:ce(r,c)},null,s);return o.subscribe("widget:settings-updated",(f,{data:h})=>{h&&h.projection!==a&&u.proxy.setBaseUrl(h.projection)}),u})),ce=(s,e)=>()=>{const t=i=>{const o=document.createElement("a");return o.href=i,o};let n=window.location;return s==="referrer"&&document.referrer&&(n=t(document.referrer)),[e?"https:":"","//",n.host,n.pathname].join("")},N=s=>{if(s){const{Type:e,Content:t}=s;if(e&&t)return{type:e,content:t}}},U=s=>s.map(e=>{const t={id:e.Id.toString(),title:e.Name,symbol:N(e.DefaultIcon),activeSymbol:e.ActiveIcon&&N(e.ActiveIcon),description:e.Description||e.Attributes&&e.Attributes.description||"",matches:e.GuidesCount};return e.Children&&e.Children.length&&(t.items=U(e.Children)),t}),v=(s,e)=>s.filter(({Type:t})=>t===e).map(({Id:t,Title:n,Body:i})=>({id:t.toString(),title:n,body:i})),D=s=>s.map(({Id:e,Title:t,DefaultIcon:n,ListNotices:i,Notices:o})=>({id:e.toString(),title:t,symbol:N(n),defaultHeaderOptions:{visible:!!i.length},notifications:(i||[]).concat(o||[]).map(({Id:a,Title:r,Body:c,Type:d,Modified:u})=>({id:a.toString(),title:r,body:c,modified:u,expandable:d==="listNotice"}))})),B=({Id:s,Title:e,DefaultIcon:t,Exits:[n],ExitType:i,ConfirmationText:o,Description:a},r)=>{const{Adapter:c}=n||{Adapter:{}},{ClientName:d="",Settings:u={},CustomClientName:f=""}=c,h={id:s.toString(),title:e,description:a,symbol:N(t),clientName:d==="custom.adapter"?f:d,expanded:!0,inline:!0,body:{}};if(d.indexOf("phone")>-1||d.indexOf("freetext")>-1){const{displayTextBeforeClick:p,textBeforeClick:w}=u;p==="true"&&(h.expanded=!1,h.title=w),d.indexOf("phone.text")>-1?h.body.phoneNumber=u.phoneNumber:h.body.freetext=u.freetext}return(d.indexOf("chat.popup")>-1||d.indexOf("link")>-1||d==="custom.adapter"&&i==="custom")&&(h.body=u,h.body.confirmationFallback=o),d.indexOf("ace")>-1&&(h.body=u),h},E=(s=[])=>s.map(({Id:e,Title:t,TotalMatches:n,Symbol:i,DefaultIcon:o,ActiveIcon:a})=>({id:e.toString(),title:t,matches:n,symbol:N(o||i),defaultIcon:N(o),activeIcon:N(a)})),$=s=>s.map(({Id:e,Title:t,Tags:n,FirstPublishedDate:i,Modified:o})=>({id:e.toString(),title:t,tags:E(n),published:i,modified:o})),Y=(s,e)=>{switch(s){case m.MatchByCategory:case m.Match:{const t={guides:[],matches:0,topNotifications:[],middleNotifications:[],bottomNotifications:[],notificationLists:[],tags:[],byCategory:[]},{Matches:n,TotalMatches:i,Notices:o,NoticeLists:a,Tags:r,ByCategory:c}=e;return t.guides=$(n),t.matches=i,t.byCategory=(c||[]).map(({Id:d,Matches:u,TotalMatches:f})=>({id:d,guides:$(u),matches:f})),t.tags=E(r),t.notificationLists=D(a||[]),t.topNotifications=v(o||[],"noticeRowTop"),t.middleNotifications=v(o||[],"noticeRowMiddle"),t.bottomNotifications=v(o||[],"footerNotice"),t}case m.Categories:{const{Children:t,GuidesCountTotal:n}=e;return{categories:U(t||[]),matches:n}}case m.Guide:{const{Id:t,Title:n,Body:i,Related:o,Options:a,ConnectionId:r,ContactMethods:c,EnableFeedback:d,HandoverExists:u,FirstPublishedDate:f,Modified:h,ModifiedByDisplayName:p,FirstPublishedByDisplayName:w,Categories:y,Tags:l,SeoMetaDescription:g,SeoAllowIndex:L,Perspectives:x,PerspectiveKey:F,Translations:H}=e,ee=F||Object.values(x).find(b=>b===r)||x.Default||null,Q={guide:{id:t.toString(),title:n,body:i,modified:h,published:f,modifiedBy:p,publishedBy:w,connection:r,categories:y,hasHandover:u,allowFeedback:d,seoMetaDescription:g,seoAllowIndex:L,perspectives:x,perspective:ee,translations:Object.keys(H||{}).reduce((b,O)=>(b[O]=H[O].toString(),b),{})},related:$(o||[]),dialog:[],contactMethods:(c||[]).map(b=>B(b)),tags:E(l)};return(a||[]).forEach(({CanAccess:b,Description:O,ConnectionId:te,Properties:C})=>{if(!b)return;const A={id:t.toString(),title:O,connection:te,connectionKey:C.ConnectionKey,type:"default",parent:{id:t.toString(),title:n,tags:E(l)}};if(C.Type==="Guide"||C.Type==="Link")switch(C.Id&&(A.id=C.Id.toString()),C.Uri&&(A.href=C.Uri),C.Target&&(A.target=C.Target),C.Type){case"Guide":A.type="guide";break;case"Link":A.type="link";break}Q.dialog.push(A)}),Q}case m.Contacts:{const{Children:t,Matches:n,Notices:i,NoticeLists:o}=e;return{contactMethods:(n||[]).map(r=>B(r)),categories:U(t||[]),topNotifications:v(i||[],"noticeRowTop"),middleNotifications:v(i||[],"noticeRowMiddle"),bottomNotifications:v(i||[],"footerNotice"),notificationLists:D(o||[])}}case m.ContactMethod:{const{ContactMethod:t}=e;return B(t||{})}case m.Tags:case m.TagsOnGuides:return E(e||[]);case m.Notifications:{const{Notices:t,NoticeLists:n}=e;return{topNotifications:v(t||[],"noticeRowTop"),middleNotifications:v(t||[],"noticeRowMiddle"),bottomNotifications:v(t||[],"footerNotice"),notificationLists:D(n||[])}}default:return{}}};var J=(s=>(s.Guide="guide",s.Guides="guides",s.GuidesByCategory="guides-by-category",s.RowNotifications="row-notices",s.NotificationLists="notification-lists",s.GuideCategories="guide-categories",s.ContactMethodCategories="contact-method-categories",s.ContactMethod="contact-method",s.ContactMethods="contact-methods",s.Tags="tags",s.TagsOnGuides="tagsonguides",s))(J||{}),m=(s=>(s.Match="match",s.Categories="categories",s.Guide="guide",s.Contacts="contacts",s.ContactMethod="contact-method",s.MatchByCategory="match-by-category",s.Tags="tags",s.TagsOnGuides="tagsonguides",s.Notifications="notifications",s))(m||{}),X=(s=>(s.Positive="Positive",s.Negative="Negative",s))(X||{}),Z=(s=>(s.POPULARITY_DESCENDING="popularity-descending",s.ALPHABETIC_ASCENDING="alphabetic-ascending",s.ALPHABETIC_DESCENDING="alphabetic-descending",s.MODIFIED_ASCENDING="modified-ascending",s.MODIFIED_DESCENDING="modified-descending",s.PUBLISHED_ASCENDING="published-ascending",s.PUBLISHED_DESCENDING="published-descending",s))(Z||{});const _=s=>{switch(s){case"guides":return"match";case"guides-by-category":return"match-by-category";case"guide":return"guide";case"guide-categories":return"categories";case"contact-method-categories":case"contact-methods":return"contacts";case"contact-method":return"contact-method";case"tags":return"tags";case"tagsonguides":return"tagsonguides";case"notification-lists":case"row-notices":return"notifications";default:throw"error"}},de=async s=>{const{invoke:e}=s.get("$widget");return await e("renderState")===q.hidden};class I{constructor(e,t){this.container=e,this.matchingClient=t,this.queries=new Map,this.getUnresolvedQueries=()=>{let n=0;return this.queries.forEach((i,o)=>{i.some(r=>!r.resolved)&&(n=1)}),n},this.events=e.get("$widget").events,this.events.subscribe("widget:settings-updated",()=>this.queries=new Map),this.events.subscribe("widget:render-state-changed",(n,{next:i,previous:o})=>{o===q.hidden&&i===q.open&&this.fetchAllUnresolvedQueries()})}static getInstance(e,t="dataClient"){return re(this)(()=>e.getAsync(t).then(async n=>{let i=await e.getAsync("matchingClient");i||(i=await K(e),e.registerAsync("matchingClient",()=>i));let o=n;return o||(o=new I(e,i),e.registerAsync(t,()=>o)),o}))}fetch(e,t,n){return new Promise((i,o)=>{t.take,ae(t);const a=_(e);let r=this.queries.get(a)||[],c=r.find(d=>R(d.params,t))||null;if(c&&(n!=null&&n.noCache)){const d=r.findIndex(u=>R(u.params,t));r=[...r.slice(0,d),...r.slice(d+1)],c=null}if(c){const d=r.indexOf(c);if(c.resolved?(this.events.dispatch("data-client:fetched",{params:t,type:a,response:c.data,unresolvedQueries:this.getUnresolvedQueries()}),this.track(c.data,a,c.error),c.data&&c.error?o({error:c.error}):i(c.data)):c.resolvers.push({resolve:i,reject:o}),r.splice(d,1),r.push(c),this.queries.set(a,r),!c.loading&&!c.resolved)return this.runQuery(a,t)}else return r.push({params:t,resolved:!1,loading:!0,data:{},resolvers:[{resolve:i,reject:o}]}),this.queries.set(a,r),this.runQuery(a,t)}).then(i=>V(i))}read(e,t){const{select:n}=t,i=_(e);return(this.queries.get(i)||[]).reduce((r,c)=>{if(typeof n=="function"){const d=n(c.data);d&&r.push(d)}else r.push(c.data);return r},[])}feedback(e,t,n){return this.matchingClient.giveFeedback(e,t,n)}setLoadingStatus(e,t,n){const i=this.queries.get(e)||[],o=i.find(a=>R(a.params,t));o&&(o.loading=n),this.queries.set(e,i)}async runQuery(e,t){const{searchPhrase:n="",categories:i="0",contactMethodCategoryId:o="0",contactMethodId:a="0",tagId:r=void 0,take:c=5,connection:d="",guideId:u,expandCategories:f="descendants",currentCategory:h,sorting:p="popularity-descending",guideIds:w=[]}=t,y=n.toString().trim();if(await de(this.container))return Promise.resolve();switch(e){case"match":{const l=g=>{const[L,x]=g.split("-");return{type:new Map([["popularity","popularity"],["alphabetic","title"],["modified","lastModified"],["published","firstPublished"]]).get(L),direction:x}};return w.length?this.matchingClient.customRequest("guides","POST",{configuration:{ids:w,take:+c}}).then(g=>g&&this.handleResponse(g,e,t)):this.matchingClient.match(y,{categories:i==="0"?[]:Array.isArray(i)?i:[+i],take:+c,tags:r,sorting:l(p),ids:w}).then(g=>g&&this.handleResponse(g,e,t))}case"match-by-category":return this.matchingClient.match(y,{groupByCategory:!0,categories:i==="0"?[]:Array.isArray(i)?i:[+i],take:+c,tags:r}).then(l=>l&&this.handleResponse(l,e,t));case"guide":return this.matchingClient.getGuide(u,{connectionId:d}).then(l=>{l&&this.handleResponse(l,e,t)}).catch(l=>{const g={message:"Something went wrong.",status:l.status||400};g.status===404&&(g.message="The guide could not be found."),this.handleResponse({},e,t,g)});case"categories":return this.matchingClient.getCategories({phrase:y,expand:f,tags:r}).then(l=>l&&this.handleResponse(l,e,t));case"contacts":return u?this.matchingClient.contactMethods(+u,{phrase:y}).then(l=>l&&this.handleResponse(l,e,t)):this.matchingClient.contacts(+o,{phrase:y}).then(l=>l&&this.handleResponse(l,e,t));case"contact-method":return this.matchingClient.getContactMethod(+a,{guideId:u,currentCategory:h}).then(l=>l&&this.handleResponse(l,e,t));case"tags":return this.matchingClient.customRequest("tags","GET",{configuration:{take:999999,phrase:y,categories:i==="0"?[]:Array.isArray(i)?i:[+i]}}).then(l=>l&&this.handleResponse(l,e,t));case"tagsonguides":return this.matchingClient.customRequest("tagsonguides","GET",{configuration:{take:999999,phrase:y,categories:i==="0"?[]:Array.isArray(i)?i:[+i],tags:r}}).then(l=>l&&this.handleResponse(l,e,t));case"notifications":return this.matchingClient.customRequest("notices","GET",{configuration:{phrase:y,categories:i==="0"?[]:Array.isArray(i)?i:[+i]}}).then(l=>l&&this.handleResponse(l,e,t))}}handleResponse(e={},t,n,i){const o=this.queries.get(t)||[],a=o.find(r=>R(r.params,n));if(a){const r=i||Y(t,e);this.track(r,t,i),a.resolvers.forEach(d=>{i?d.reject({error:r}):d.resolve(r)});const c=o.indexOf(a);c>-1&&o.splice(c,1),o.push({...a,error:i,resolvers:[],data:r,resolved:!0}),this.setLoadingStatus(t,n,!1),this.queries.set(t,o),i||this.events.dispatch("data-client:fetched",{type:t,params:n,response:r,unresolvedQueries:this.getUnresolvedQueries()})}}fetchAllUnresolvedQueries(){for(const[e,t]of this.queries)t.filter(n=>!n.resolved).forEach(n=>{this.runQuery(e,n.params)})}track(e={},t,n){const i=this.container.get("$widget");i&&!n?i.events.dispatch("tracking:service-client-response",{type:t,data:e}):i&&i.events.dispatch("tracking:service-client-error",{type:t,error:n})}static create(e){return e.getAsync("matchingClient").then(async t=>{if(t)return new I(e,t);const n=await K(e);return e.registerAsync("matchingClient",()=>n),new I(e,n)})}getClient(){return this.matchingClient}}const le=async s=>{s.registerAsync("dataClient",()=>I.create(s))};exports.DataClient=I;exports.DataType=J;exports.FeedbackType=X;exports.KnowledgeDataClientPlugin=le;exports.ServiceClientQueryType=m;exports.SortingType=Z;exports.determineServiceClientQueryType=_;exports.formatLegacyData=Y;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=(s,e,t,...n)=>{const i=`[${s.get("$environment").name||"webprovisions"}] ${t}`;switch(e){case"info":console.info(i,...n);break;case"warning":console.warn(i,...n);break;case"error":console.error(i,...n);break}},se=s=>{const e=s.container||s;return{info:(t,...n)=>j(e,"info",t,...n),warn:(t,...n)=>j(e,"warning",t,...n),error:(t,...n)=>j(e,"error",t,...n)}};var T=(s=>(s.Implementation="implementation",s.Widget="widget",s))(T||{}),k=(s=>(s.Pre="pre",s.Post="post",s))(k||{});const ie=(s,e,t,n)=>{try{const i=new e(t,n);return{name:s,invoke:(o,a)=>{let r;return i[o]&&(r=i[o].call(i,a)),Promise.resolve(r)},getInstance:()=>i}}catch(i){if(i.message&&i.message.indexOf("is not a constructor")>=0)return{name:s,invoke:o=>{let a;return o==="initialize"&&(a=e(t,n)),Promise.resolve(a)},getInstance:()=>e};throw i}};function K(s,e){return typeof s>"u"?e:s}class ne{constructor(e={}){this.part=e}createCommand(e,t,n){let i;typeof t=="function"?i={scope:T.Widget,stage:k.Post,defaultArgs:void 0,handlerResolver:t}:i={scope:K(t.scope,T.Widget),stage:K(t.stage,k.Post),defaultArgs:t.defaultArgs,handlerResolver:n};let o=this.part;const a=e.split(".");return a.forEach((r,c)=>{c===a.length-1?o[r]||(o[r]=()=>i):o=this.part[r]=this.part[r]||{}}),this}get(){return this.part}}const z=s=>{const e=new ne({});return s(e),e.get()};z(s=>{s.createCommand("types.register",{scope:T.Implementation,stage:k.Pre},e=>(t,n)=>{e.container.get("$types")[t]=n}).createCommand("type",{stage:k.Pre},e=>t=>{e.container.register("$type",t)}).createCommand("settings",{stage:k.Pre,defaultArgs:[null]},e=>t=>{e.events.dispatch("settings:change",t,{bubbles:!0}),e.container.register("$settings",t)}).createCommand("plugin",{stage:k.Pre},e=>(t,n,i)=>{const{container:o}=e;let a=null,r=t,c=n;typeof t=="string"&&(a=t,r=n,c=i);const d=u=>{const{transformPluginSettings:f}=e.container.get("$environmentOptions"),h=f?f(c||{},a,e.container,r):n;try{const p=ie(a,r,o,h);o.get("$plugins").push(p),u&&p.invoke("initialize",null)}catch(p){se(e).warn("Error when initializing plugin",p)}};e.container.get("$instance")?d(!0):e.events.subscribeOnce("widget:instance-created",()=>d(!1))}).createCommand("container.register",e=>(t,n)=>{e.container.register(t,n)}).createCommand("container.registerAsync",e=>(t,n)=>{e.container.registerAsync(t,n)}).createCommand("container.registerFactory",e=>(t,n)=>{e.container.registerFactory(t,n)}).createCommand("container.touch",e=>(t,n)=>{e.container.touch(t,n)}).createCommand("csp",{},e=>t=>{e.container.register("csp",t)})});const G=(s,e,...t)=>typeof e=="string"?s(`[humany] ${e}`,...t):s(e,...t),S=class M{constructor(){this.keys=[],this.log=(e,...t)=>this.lookup(e,()=>M.log(...t)),this.warn=(e,...t)=>this.lookup(e,()=>M.warn(...t)),this.error=(e,...t)=>this.lookup(e,()=>M.error(...t)),this.info=(e,...t)=>this.lookup(e,()=>M.info(...t))}lookup(e,t){this.keys.indexOf(e)===-1&&(this.keys.push(e),t())}};S.log=(...s)=>G(console.log,...s);S.warn=(...s)=>G(console.warn,...s);S.error=(...s)=>G(console.error,...s);S.info=(...s)=>G(console.info,...s);let oe=S;const V=s=>{let e={},t,n;if(typeof s!="object"||s===null)return s;e=Array.isArray(s)?[]:{};for(n in s)t=s[n],e[n]=typeof t=="object"&&t!==null?V(t):t;return e};class re{constructor(e,t){this.lockWarningTime=e,this.lockErrorTime=t,this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(e,t,n,i){this.tasks.push({task:e,resolve:t,reject:n,done:i}),this.next()}next(){this.current=this.current.then(()=>{const e=this.tasks.shift();if(e){let t;const n=setTimeout(()=>{process.env.NODE_ENV!=="production"&&oe.warn(`A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,e),t=setTimeout(()=>{e.reject("lock timeout exceeded")},this.lockErrorTime)},this.lockWarningTime),i=Promise.resolve(e.task()).then(o=>(clearTimeout(n),clearTimeout(t),o));return Promise.resolve(i).then(this.next).then(()=>i.then(o=>{e.done(),e.resolve(o)})).catch(o=>(e.done(),e.reject(o),this.next()))}return Promise.resolve()})}}const P=new WeakMap;function ae(s,e=5e3,t=1e3){return P.has(s)||P.set(s,new re(e,t)),n=>new Promise((i,o)=>{const a=P.get(s);a.add(n,i,o,()=>{a.tasks.length||P.delete(s)})})}const ce=(s={})=>(Object.keys(s).forEach(e=>{(s[e]===null||typeof s[e]>"u")&&delete s[e]}),s),R=(s,e)=>{let t=!0;return Object.keys(s).length!==Object.keys(e).length||Object.keys(s).some(n=>!Object.keys(e).some(i=>n===i))?!1:(Object.keys(s).forEach(n=>{if(t){const i=typeof s[n]>"u"?"":s[n],o=typeof e[n]>"u"?"":e[n];t=i.toString()===o.toString()}}),t)};z(s=>{s.createCommand("components",e=>t=>{e.events.subscribeOnce("components:platform-created",(n,{platform:i})=>{t.handlers&&t.handlers.forEach(([o,a])=>{i.addComponentHandler(o,a)})})})});var q=(s=>(s.open="open",s.closed="closed",s.hidden="hidden",s))(q||{});const _=s=>Promise.resolve().then(()=>require("./index-WiNloX2z.js")).then(({ServiceClient:e,ServiceProxy:t})=>s.get("settings").then(n=>{const{name:i,events:o}=s.get("$widget"),{data:{projection:a="",site:r="current",forceHttps:c=!1}}=n,d=new t(a,{credentials:"same-origin"}),u=new e(d,{funnel:i.replace("_contact-method","").replace("_contact",""),site:de(r,c)},null,s);return o.subscribe("widget:settings-updated",(f,{data:h})=>{h&&h.projection!==a&&u.proxy.setBaseUrl(h.projection)}),u})),de=(s,e)=>()=>{const t=i=>{const o=document.createElement("a");return o.href=i,o};let n=window.location;return s==="referrer"&&document.referrer&&(n=t(document.referrer)),[e?"https:":"","//",n.host,n.pathname].join("")},N=s=>{if(s){const{Type:e,Content:t}=s;if(e&&t)return{type:e,content:t}}},U=s=>s.map(e=>{const t={id:e.Id.toString(),title:e.Name,symbol:N(e.DefaultIcon),activeSymbol:e.ActiveIcon&&N(e.ActiveIcon),description:e.Description||e.Attributes&&e.Attributes.description||"",matches:e.GuidesCount};return e.Children&&e.Children.length&&(t.items=U(e.Children)),t}),v=(s,e)=>s.filter(({Type:t})=>t===e).map(({Id:t,Title:n,Body:i})=>({id:t.toString(),title:n,body:i})),D=s=>s.map(({Id:e,Title:t,DefaultIcon:n,ListNotices:i,Notices:o})=>({id:e.toString(),title:t,symbol:N(n),defaultHeaderOptions:{visible:!!i.length},notifications:(i||[]).concat(o||[]).map(({Id:a,Title:r,Body:c,Type:d,Modified:u})=>({id:a.toString(),title:r,body:c,modified:u,expandable:d==="listNotice"}))})),B=({Id:s,Title:e,DefaultIcon:t,Exits:[n],ExitType:i,ConfirmationText:o,Description:a},r)=>{const{Adapter:c}=n||{Adapter:{}},{ClientName:d="",Settings:u={},CustomClientName:f=""}=c,h={id:s.toString(),title:e,description:a,symbol:N(t),clientName:d==="custom.adapter"?f:d,expanded:!0,inline:!0,body:{}};if(d.indexOf("phone")>-1||d.indexOf("freetext")>-1){const{displayTextBeforeClick:p,textBeforeClick:w}=u;p==="true"&&(h.expanded=!1,h.title=w),d.indexOf("phone.text")>-1?h.body.phoneNumber=u.phoneNumber:h.body.freetext=u.freetext}return(d.indexOf("chat.popup")>-1||d.indexOf("link")>-1||d==="custom.adapter"&&i==="custom")&&(h.body=u,h.body.confirmationFallback=o),d.indexOf("ace")>-1&&(h.body=u),h},E=(s=[])=>s.map(({Id:e,Title:t,TotalMatches:n,Symbol:i,DefaultIcon:o,ActiveIcon:a})=>({id:e.toString(),title:t,matches:n,symbol:N(o||i),defaultIcon:N(o),activeIcon:N(a)})),$=s=>s.map(({Id:e,Title:t,Tags:n,FirstPublishedDate:i,Modified:o})=>({id:e.toString(),title:t,tags:E(n),published:i,modified:o})),X=(s,e)=>{switch(s){case m.MatchByCategory:case m.Match:{const t={guides:[],matches:0,topNotifications:[],middleNotifications:[],bottomNotifications:[],notificationLists:[],tags:[],byCategory:[]},{Matches:n,TotalMatches:i,Notices:o,NoticeLists:a,Tags:r,ByCategory:c}=e;return t.guides=$(n),t.matches=i,t.byCategory=(c||[]).map(({Id:d,Matches:u,TotalMatches:f})=>({id:d,guides:$(u),matches:f})),t.tags=E(r),t.notificationLists=D(a||[]),t.topNotifications=v(o||[],"noticeRowTop"),t.middleNotifications=v(o||[],"noticeRowMiddle"),t.bottomNotifications=v(o||[],"footerNotice"),t}case m.Categories:{const{Children:t,GuidesCountTotal:n}=e;return{categories:U(t||[]),matches:n}}case m.Guide:{const{Id:t,Title:n,Body:i,Related:o,Options:a,ConnectionId:r,ContactMethods:c,EnableFeedback:d,HandoverExists:u,FirstPublishedDate:f,Modified:h,ModifiedByDisplayName:p,FirstPublishedByDisplayName:w,Categories:y,Tags:l,SeoMetaDescription:g,SeoAllowIndex:L,Perspectives:x,PerspectiveKey:F,Translations:Q}=e,ee=F||Object.values(x).find(b=>b===r)||x.Default||null,W={guide:{id:t.toString(),title:n,body:i,modified:h,published:f,modifiedBy:p,publishedBy:w,connection:r,categories:y,hasHandover:u,allowFeedback:d,seoMetaDescription:g,seoAllowIndex:L,perspectives:x,perspective:ee,translations:Object.keys(Q||{}).reduce((b,O)=>(b[O]=Q[O].toString(),b),{})},related:$(o||[]),dialog:[],contactMethods:(c||[]).map(b=>B(b)),tags:E(l)};return(a||[]).forEach(({CanAccess:b,Description:O,ConnectionId:te,Properties:C})=>{if(!b)return;const A={id:t.toString(),title:O,connection:te,connectionKey:C.ConnectionKey,type:"default",parent:{id:t.toString(),title:n,tags:E(l)}};if(C.Type==="Guide"||C.Type==="Link")switch(C.Id&&(A.id=C.Id.toString()),C.Uri&&(A.href=C.Uri),C.Target&&(A.target=C.Target),C.Type){case"Guide":A.type="guide";break;case"Link":A.type="link";break}W.dialog.push(A)}),W}case m.Contacts:{const{Children:t,Matches:n,Notices:i,NoticeLists:o}=e;return{contactMethods:(n||[]).map(r=>B(r)),categories:U(t||[]),topNotifications:v(i||[],"noticeRowTop"),middleNotifications:v(i||[],"noticeRowMiddle"),bottomNotifications:v(i||[],"footerNotice"),notificationLists:D(o||[])}}case m.ContactMethod:{const{ContactMethod:t}=e;return B(t||{})}case m.Tags:case m.TagsOnGuides:return E(e||[]);case m.Notifications:{const{Notices:t,NoticeLists:n}=e;return{topNotifications:v(t||[],"noticeRowTop"),middleNotifications:v(t||[],"noticeRowMiddle"),bottomNotifications:v(t||[],"footerNotice"),notificationLists:D(n||[])}}default:return{}}};var Y=(s=>(s.Guide="guide",s.Guides="guides",s.GuidesByCategory="guides-by-category",s.RowNotifications="row-notices",s.NotificationLists="notification-lists",s.GuideCategories="guide-categories",s.ContactMethodCategories="contact-method-categories",s.ContactMethod="contact-method",s.ContactMethods="contact-methods",s.Tags="tags",s.TagsOnGuides="tagsonguides",s))(Y||{}),m=(s=>(s.Match="match",s.Categories="categories",s.Guide="guide",s.Contacts="contacts",s.ContactMethod="contact-method",s.MatchByCategory="match-by-category",s.Tags="tags",s.TagsOnGuides="tagsonguides",s.Notifications="notifications",s))(m||{}),J=(s=>(s.Positive="Positive",s.Negative="Negative",s))(J||{}),Z=(s=>(s.POPULARITY_DESCENDING="popularity-descending",s.ALPHABETIC_ASCENDING="alphabetic-ascending",s.ALPHABETIC_DESCENDING="alphabetic-descending",s.MODIFIED_ASCENDING="modified-ascending",s.MODIFIED_DESCENDING="modified-descending",s.PUBLISHED_ASCENDING="published-ascending",s.PUBLISHED_DESCENDING="published-descending",s))(Z||{});const H=s=>{switch(s){case"guides":return"match";case"guides-by-category":return"match-by-category";case"guide":return"guide";case"guide-categories":return"categories";case"contact-method-categories":case"contact-methods":return"contacts";case"contact-method":return"contact-method";case"tags":return"tags";case"tagsonguides":return"tagsonguides";case"notification-lists":case"row-notices":return"notifications";default:throw"error"}},le=async s=>{const{invoke:e}=s.get("$widget");return await e("renderState")===q.hidden};class I{constructor(e,t){this.container=e,this.matchingClient=t,this.queries=new Map,this.getUnresolvedQueries=()=>{let n=0;return this.queries.forEach((i,o)=>{i.some(r=>!r.resolved)&&(n=1)}),n},this.events=e.get("$widget").events,this.events.subscribe("widget:settings-updated",()=>this.queries=new Map),this.events.subscribe("widget:render-state-changed",(n,{next:i,previous:o})=>{o===q.hidden&&i===q.open&&this.fetchAllUnresolvedQueries()})}static getInstance(e,t="dataClient"){return ae(this)(()=>e.getAsync(t).then(async n=>{let i=await e.getAsync("matchingClient");i||(i=await _(e),e.registerAsync("matchingClient",()=>i));let o=n;return o||(o=new I(e,i),e.registerAsync(t,()=>o)),o}))}fetch(e,t,n){return new Promise((i,o)=>{t.take,ce(t);const a=H(e);let r=this.queries.get(a)||[],c=r.find(d=>R(d.params,t))||null;if(c&&(n!=null&&n.noCache)){const d=r.findIndex(u=>R(u.params,t));r=[...r.slice(0,d),...r.slice(d+1)],c=null}if(c){const d=r.indexOf(c);if(c.resolved?(this.events.dispatch("data-client:fetched",{params:t,type:a,response:c.data,unresolvedQueries:this.getUnresolvedQueries()}),this.track(c.data,a,c.error),c.data&&c.error?o({error:c.error}):i(c.data)):c.resolvers.push({resolve:i,reject:o}),r.splice(d,1),r.push(c),this.queries.set(a,r),!c.loading&&!c.resolved)return this.runQuery(a,t)}else return r.push({params:t,resolved:!1,loading:!0,data:{},resolvers:[{resolve:i,reject:o}]}),this.queries.set(a,r),this.runQuery(a,t)}).then(i=>V(i))}read(e,t){const{select:n}=t,i=H(e);return(this.queries.get(i)||[]).reduce((r,c)=>{if(typeof n=="function"){const d=n(c.data);d&&r.push(d)}else r.push(c.data);return r},[])}feedback(e,t,n){return this.matchingClient.giveFeedback(e,t,n)}setLoadingStatus(e,t,n){const i=this.queries.get(e)||[],o=i.find(a=>R(a.params,t));o&&(o.loading=n),this.queries.set(e,i)}async runQuery(e,t){const{searchPhrase:n="",categories:i="0",contactMethodCategoryId:o="0",contactMethodId:a="0",tagId:r=void 0,take:c=5,connection:d="",guideId:u,expandCategories:f="descendants",currentCategory:h,sorting:p="popularity-descending",guideIds:w=[]}=t,y=n.toString().trim();if(await le(this.container))return Promise.resolve();switch(e){case"match":{const l=g=>{const[L,x]=g.split("-");return{type:new Map([["popularity","popularity"],["alphabetic","title"],["modified","lastModified"],["published","firstPublished"]]).get(L),direction:x}};return w.length?this.matchingClient.customRequest("guides","POST",{configuration:{ids:w,take:+c}}).then(g=>g&&this.handleResponse(g,e,t)):this.matchingClient.match(y,{categories:i==="0"?[]:Array.isArray(i)?i:[+i],take:+c,tags:r,sorting:l(p),ids:w}).then(g=>g&&this.handleResponse(g,e,t))}case"match-by-category":return this.matchingClient.match(y,{groupByCategory:!0,categories:i==="0"?[]:Array.isArray(i)?i:[+i],take:+c,tags:r}).then(l=>l&&this.handleResponse(l,e,t));case"guide":return this.matchingClient.getGuide(u,{connectionId:d}).then(l=>{l&&this.handleResponse(l,e,t)}).catch(l=>{const g={message:"Something went wrong.",status:l.status||400};g.status===404&&(g.message="The guide could not be found."),this.handleResponse({},e,t,g)});case"categories":return this.matchingClient.getCategories({phrase:y,expand:f,tags:r}).then(l=>l&&this.handleResponse(l,e,t));case"contacts":return u?this.matchingClient.contactMethods(+u,{phrase:y}).then(l=>l&&this.handleResponse(l,e,t)):this.matchingClient.contacts(+o,{phrase:y}).then(l=>l&&this.handleResponse(l,e,t));case"contact-method":return this.matchingClient.getContactMethod(+a,{guideId:u,currentCategory:h}).then(l=>l&&this.handleResponse(l,e,t));case"tags":return this.matchingClient.customRequest("tags","GET",{configuration:{take:999999,phrase:y,categories:i==="0"?[]:Array.isArray(i)?i:[+i]}}).then(l=>l&&this.handleResponse(l,e,t));case"tagsonguides":return this.matchingClient.customRequest("tagsonguides","GET",{configuration:{take:999999,phrase:y,categories:i==="0"?[]:Array.isArray(i)?i:[+i],tags:r}}).then(l=>l&&this.handleResponse(l,e,t));case"notifications":return this.matchingClient.customRequest("notices","GET",{configuration:{phrase:y,categories:i==="0"?[]:Array.isArray(i)?i:[+i]}}).then(l=>l&&this.handleResponse(l,e,t))}}handleResponse(e={},t,n,i){const o=this.queries.get(t)||[],a=o.find(r=>R(r.params,n));if(a){const r=i||X(t,e);this.track(r,t,i),a.resolvers.forEach(d=>{i?d.reject({error:r}):d.resolve(r)});const c=o.indexOf(a);c>-1&&o.splice(c,1),o.push({...a,error:i,resolvers:[],data:r,resolved:!0}),this.setLoadingStatus(t,n,!1),this.queries.set(t,o),i||this.events.dispatch("data-client:fetched",{type:t,params:n,response:r,unresolvedQueries:this.getUnresolvedQueries()})}}fetchAllUnresolvedQueries(){for(const[e,t]of this.queries)t.filter(n=>!n.resolved).forEach(n=>{this.runQuery(e,n.params)})}track(e={},t,n){const i=this.container.get("$widget");i&&!n?i.events.dispatch("tracking:service-client-response",{type:t,data:e}):i&&i.events.dispatch("tracking:service-client-error",{type:t,error:n})}static create(e){return e.getAsync("matchingClient").then(async t=>{if(t)return new I(e,t);const n=await _(e);return e.registerAsync("matchingClient",()=>n),new I(e,n)})}getClient(){return this.matchingClient}}const ue=async s=>{s.registerAsync("dataClient",()=>I.create(s))};exports.DataClient=I;exports.DataType=Y;exports.FeedbackType=J;exports.KnowledgeDataClientPlugin=ue;exports.ServiceClientQueryType=m;exports.SortingType=Z;exports.determineServiceClientQueryType=H;exports.formatLegacyData=X;
|
package/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ const j = (s, e, t, ...n) => {
|
|
|
11
11
|
console.error(i, ...n);
|
|
12
12
|
break;
|
|
13
13
|
}
|
|
14
|
-
},
|
|
14
|
+
}, J = (s) => {
|
|
15
15
|
const e = s.container || s;
|
|
16
16
|
return {
|
|
17
17
|
info: (t, ...n) => j(e, "info", t, ...n),
|
|
@@ -44,7 +44,7 @@ const Z = (s, e, t, n) => {
|
|
|
44
44
|
throw i;
|
|
45
45
|
}
|
|
46
46
|
};
|
|
47
|
-
function
|
|
47
|
+
function _(s, e) {
|
|
48
48
|
return typeof s > "u" ? e : s;
|
|
49
49
|
}
|
|
50
50
|
class ee {
|
|
@@ -59,8 +59,8 @@ class ee {
|
|
|
59
59
|
defaultArgs: void 0,
|
|
60
60
|
handlerResolver: t
|
|
61
61
|
} : i = {
|
|
62
|
-
scope:
|
|
63
|
-
stage:
|
|
62
|
+
scope: _(t.scope, G.Widget),
|
|
63
|
+
stage: _(t.stage, k.Post),
|
|
64
64
|
defaultArgs: t.defaultArgs,
|
|
65
65
|
handlerResolver: n
|
|
66
66
|
};
|
|
@@ -124,7 +124,7 @@ z((s) => {
|
|
|
124
124
|
);
|
|
125
125
|
o.get("$plugins").push(m), h && m.invoke("initialize", null);
|
|
126
126
|
} catch (m) {
|
|
127
|
-
|
|
127
|
+
J(e).warn("Error when initializing plugin", m);
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
e.container.get("$instance") ? d(!0) : e.events.subscribeOnce("widget:instance-created", () => d(!1));
|
|
@@ -157,19 +157,19 @@ z((s) => {
|
|
|
157
157
|
}
|
|
158
158
|
);
|
|
159
159
|
});
|
|
160
|
-
const T = (s, e, ...t) => typeof e == "string" ? s(`[humany] ${e}`, ...t) : s(e, ...t),
|
|
160
|
+
const T = (s, e, ...t) => typeof e == "string" ? s(`[humany] ${e}`, ...t) : s(e, ...t), O = class x {
|
|
161
161
|
constructor() {
|
|
162
|
-
this.keys = [], this.log = (
|
|
162
|
+
this.keys = [], this.log = (e, ...t) => this.lookup(e, () => x.log(...t)), this.warn = (e, ...t) => this.lookup(e, () => x.warn(...t)), this.error = (e, ...t) => this.lookup(e, () => x.error(...t)), this.info = (e, ...t) => this.lookup(e, () => x.info(...t));
|
|
163
163
|
}
|
|
164
|
-
lookup(
|
|
165
|
-
this.keys.indexOf(
|
|
164
|
+
lookup(e, t) {
|
|
165
|
+
this.keys.indexOf(e) === -1 && (this.keys.push(e), t());
|
|
166
166
|
}
|
|
167
167
|
};
|
|
168
|
-
let O = x;
|
|
169
168
|
O.log = (...s) => T(console.log, ...s);
|
|
170
169
|
O.warn = (...s) => T(console.warn, ...s);
|
|
171
170
|
O.error = (...s) => T(console.error, ...s);
|
|
172
171
|
O.info = (...s) => T(console.info, ...s);
|
|
172
|
+
let te = O;
|
|
173
173
|
const V = (s) => {
|
|
174
174
|
let e = {}, t, n;
|
|
175
175
|
if (typeof s != "object" || s === null)
|
|
@@ -179,7 +179,7 @@ const V = (s) => {
|
|
|
179
179
|
t = s[n], e[n] = typeof t == "object" && t !== null ? V(t) : t;
|
|
180
180
|
return e;
|
|
181
181
|
};
|
|
182
|
-
class
|
|
182
|
+
class se {
|
|
183
183
|
constructor(e, t) {
|
|
184
184
|
this.lockWarningTime = e, this.lockErrorTime = t, this.tasks = [], this.current = Promise.resolve(), this.next = this.next.bind(this);
|
|
185
185
|
}
|
|
@@ -192,7 +192,7 @@ class te {
|
|
|
192
192
|
if (e) {
|
|
193
193
|
let t;
|
|
194
194
|
const n = setTimeout(() => {
|
|
195
|
-
process.env.NODE_ENV !== "production" &&
|
|
195
|
+
process.env.NODE_ENV !== "production" && te.warn(
|
|
196
196
|
`A lock has exceeded ${this.lockWarningTime} ms. Waiting additional ${this.lockErrorTime} ms before rejecting the task.`,
|
|
197
197
|
e
|
|
198
198
|
), t = setTimeout(() => {
|
|
@@ -210,15 +210,15 @@ class te {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
const S = /* @__PURE__ */ new WeakMap();
|
|
213
|
-
function
|
|
214
|
-
return S.has(s) || S.set(s, new
|
|
213
|
+
function ie(s, e = 5e3, t = 1e3) {
|
|
214
|
+
return S.has(s) || S.set(s, new se(e, t)), (n) => new Promise((i, o) => {
|
|
215
215
|
const c = S.get(s);
|
|
216
216
|
c.add(n, i, o, () => {
|
|
217
217
|
c.tasks.length || S.delete(s);
|
|
218
218
|
});
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
|
-
const
|
|
221
|
+
const ne = (s = {}) => (Object.keys(s).forEach((e) => {
|
|
222
222
|
(s[e] === null || typeof s[e] > "u") && delete s[e];
|
|
223
223
|
}), s), P = (s, e) => {
|
|
224
224
|
let t = !0;
|
|
@@ -242,7 +242,7 @@ z((s) => {
|
|
|
242
242
|
});
|
|
243
243
|
});
|
|
244
244
|
var q = /* @__PURE__ */ ((s) => (s.open = "open", s.closed = "closed", s.hidden = "hidden", s))(q || {});
|
|
245
|
-
const
|
|
245
|
+
const K = (s) => import("./index-l7aSOU1E.mjs").then(
|
|
246
246
|
({ ServiceClient: e, ServiceProxy: t }) => s.get("settings").then((n) => {
|
|
247
247
|
const { name: i, events: o } = s.get("$widget"), {
|
|
248
248
|
data: { projection: c = "", site: r = "current", forceHttps: a = !1 }
|
|
@@ -252,7 +252,7 @@ const Q = (s) => import("./index-l7aSOU1E.mjs").then(
|
|
|
252
252
|
d,
|
|
253
253
|
{
|
|
254
254
|
funnel: i.replace("_contact-method", "").replace("_contact", ""),
|
|
255
|
-
site:
|
|
255
|
+
site: oe(r, a)
|
|
256
256
|
},
|
|
257
257
|
null,
|
|
258
258
|
s
|
|
@@ -261,7 +261,7 @@ const Q = (s) => import("./index-l7aSOU1E.mjs").then(
|
|
|
261
261
|
u && u.projection !== c && h.proxy.setBaseUrl(u.projection);
|
|
262
262
|
}), h;
|
|
263
263
|
})
|
|
264
|
-
),
|
|
264
|
+
), oe = (s, e) => () => {
|
|
265
265
|
const t = (i) => {
|
|
266
266
|
const o = document.createElement("a");
|
|
267
267
|
return o.href = i, o;
|
|
@@ -346,7 +346,7 @@ const Q = (s) => import("./index-l7aSOU1E.mjs").then(
|
|
|
346
346
|
tags: M(n),
|
|
347
347
|
published: i,
|
|
348
348
|
modified: o
|
|
349
|
-
})),
|
|
349
|
+
})), re = (s, e) => {
|
|
350
350
|
switch (s) {
|
|
351
351
|
case C.MatchByCategory:
|
|
352
352
|
case C.Match: {
|
|
@@ -402,11 +402,11 @@ const Q = (s) => import("./index-l7aSOU1E.mjs").then(
|
|
|
402
402
|
SeoMetaDescription: g,
|
|
403
403
|
SeoAllowIndex: L,
|
|
404
404
|
Perspectives: I,
|
|
405
|
-
PerspectiveKey:
|
|
406
|
-
Translations:
|
|
407
|
-
} = e,
|
|
405
|
+
PerspectiveKey: H,
|
|
406
|
+
Translations: F
|
|
407
|
+
} = e, X = H || Object.values(I).find(
|
|
408
408
|
(v) => v === r
|
|
409
|
-
) || I.Default || null,
|
|
409
|
+
) || I.Default || null, W = {
|
|
410
410
|
guide: {
|
|
411
411
|
id: t.toString(),
|
|
412
412
|
title: n,
|
|
@@ -422,8 +422,8 @@ const Q = (s) => import("./index-l7aSOU1E.mjs").then(
|
|
|
422
422
|
seoMetaDescription: g,
|
|
423
423
|
seoAllowIndex: L,
|
|
424
424
|
perspectives: I,
|
|
425
|
-
perspective:
|
|
426
|
-
translations: Object.keys(
|
|
425
|
+
perspective: X,
|
|
426
|
+
translations: Object.keys(F || {}).reduce((v, R) => (v[R] = F[R].toString(), v), {})
|
|
427
427
|
},
|
|
428
428
|
related: D(o || []),
|
|
429
429
|
dialog: [],
|
|
@@ -433,13 +433,13 @@ const Q = (s) => import("./index-l7aSOU1E.mjs").then(
|
|
|
433
433
|
tags: M(l)
|
|
434
434
|
};
|
|
435
435
|
return (c || []).forEach(
|
|
436
|
-
({ CanAccess: v, Description: R, ConnectionId:
|
|
436
|
+
({ CanAccess: v, Description: R, ConnectionId: Y, Properties: y }) => {
|
|
437
437
|
if (!v)
|
|
438
438
|
return;
|
|
439
439
|
const A = {
|
|
440
440
|
id: t.toString(),
|
|
441
441
|
title: R,
|
|
442
|
-
connection:
|
|
442
|
+
connection: Y,
|
|
443
443
|
connectionKey: y.ConnectionKey,
|
|
444
444
|
type: "default",
|
|
445
445
|
parent: {
|
|
@@ -457,9 +457,9 @@ const Q = (s) => import("./index-l7aSOU1E.mjs").then(
|
|
|
457
457
|
A.type = "link";
|
|
458
458
|
break;
|
|
459
459
|
}
|
|
460
|
-
|
|
460
|
+
W.dialog.push(A);
|
|
461
461
|
}
|
|
462
|
-
),
|
|
462
|
+
), W;
|
|
463
463
|
}
|
|
464
464
|
case C.Contacts: {
|
|
465
465
|
const {
|
|
@@ -499,8 +499,8 @@ const Q = (s) => import("./index-l7aSOU1E.mjs").then(
|
|
|
499
499
|
return {};
|
|
500
500
|
}
|
|
501
501
|
};
|
|
502
|
-
var
|
|
503
|
-
const
|
|
502
|
+
var ce = /* @__PURE__ */ ((s) => (s.Guide = "guide", s.Guides = "guides", s.GuidesByCategory = "guides-by-category", s.RowNotifications = "row-notices", s.NotificationLists = "notification-lists", s.GuideCategories = "guide-categories", s.ContactMethodCategories = "contact-method-categories", s.ContactMethod = "contact-method", s.ContactMethods = "contact-methods", s.Tags = "tags", s.TagsOnGuides = "tagsonguides", s))(ce || {}), C = /* @__PURE__ */ ((s) => (s.Match = "match", s.Categories = "categories", s.Guide = "guide", s.Contacts = "contacts", s.ContactMethod = "contact-method", s.MatchByCategory = "match-by-category", s.Tags = "tags", s.TagsOnGuides = "tagsonguides", s.Notifications = "notifications", s))(C || {}), ae = /* @__PURE__ */ ((s) => (s.Positive = "Positive", s.Negative = "Negative", s))(ae || {}), de = /* @__PURE__ */ ((s) => (s.POPULARITY_DESCENDING = "popularity-descending", s.ALPHABETIC_ASCENDING = "alphabetic-ascending", s.ALPHABETIC_DESCENDING = "alphabetic-descending", s.MODIFIED_ASCENDING = "modified-ascending", s.MODIFIED_DESCENDING = "modified-descending", s.PUBLISHED_ASCENDING = "published-ascending", s.PUBLISHED_DESCENDING = "published-descending", s))(de || {});
|
|
503
|
+
const Q = (s) => {
|
|
504
504
|
switch (s) {
|
|
505
505
|
case "guides":
|
|
506
506
|
return "match";
|
|
@@ -525,7 +525,7 @@ const K = (s) => {
|
|
|
525
525
|
default:
|
|
526
526
|
throw "error";
|
|
527
527
|
}
|
|
528
|
-
},
|
|
528
|
+
}, le = async (s) => {
|
|
529
529
|
const { invoke: e } = s.get("$widget");
|
|
530
530
|
return await e("renderState") === q.hidden;
|
|
531
531
|
};
|
|
@@ -547,17 +547,17 @@ class E {
|
|
|
547
547
|
);
|
|
548
548
|
}
|
|
549
549
|
static getInstance(e, t = "dataClient") {
|
|
550
|
-
return
|
|
550
|
+
return ie(this)(() => e.getAsync(t).then(async (n) => {
|
|
551
551
|
let i = await e.getAsync("matchingClient");
|
|
552
|
-
i || (i = await
|
|
552
|
+
i || (i = await K(e), e.registerAsync("matchingClient", () => i));
|
|
553
553
|
let o = n;
|
|
554
554
|
return o || (o = new E(e, i), e.registerAsync(t, () => o)), o;
|
|
555
555
|
}));
|
|
556
556
|
}
|
|
557
557
|
fetch(e, t, n) {
|
|
558
558
|
return new Promise((i, o) => {
|
|
559
|
-
t.take,
|
|
560
|
-
const c =
|
|
559
|
+
t.take, ne(t);
|
|
560
|
+
const c = Q(e);
|
|
561
561
|
let r = this.queries.get(c) || [], a = r.find((d) => P(d.params, t)) || null;
|
|
562
562
|
if (a && (n != null && n.noCache)) {
|
|
563
563
|
const d = r.findIndex(
|
|
@@ -586,7 +586,7 @@ class E {
|
|
|
586
586
|
}
|
|
587
587
|
// query the cached data
|
|
588
588
|
read(e, t) {
|
|
589
|
-
const { select: n } = t, i =
|
|
589
|
+
const { select: n } = t, i = Q(e);
|
|
590
590
|
return (this.queries.get(i) || []).reduce((r, a) => {
|
|
591
591
|
if (typeof n == "function") {
|
|
592
592
|
const d = n(a.data);
|
|
@@ -618,7 +618,7 @@ class E {
|
|
|
618
618
|
sorting: m = "popularity-descending",
|
|
619
619
|
guideIds: w = []
|
|
620
620
|
} = t, p = n.toString().trim();
|
|
621
|
-
if (await
|
|
621
|
+
if (await le(this.container))
|
|
622
622
|
return Promise.resolve();
|
|
623
623
|
switch (e) {
|
|
624
624
|
case "match": {
|
|
@@ -720,7 +720,7 @@ class E {
|
|
|
720
720
|
handleResponse(e = {}, t, n, i) {
|
|
721
721
|
const o = this.queries.get(t) || [], c = o.find((r) => P(r.params, n));
|
|
722
722
|
if (c) {
|
|
723
|
-
const r = i ||
|
|
723
|
+
const r = i || re(t, e);
|
|
724
724
|
this.track(r, t, i), c.resolvers.forEach((d) => {
|
|
725
725
|
i ? d.reject({ error: r }) : d.resolve(r);
|
|
726
726
|
});
|
|
@@ -759,7 +759,7 @@ class E {
|
|
|
759
759
|
return e.getAsync("matchingClient").then(async (t) => {
|
|
760
760
|
if (t)
|
|
761
761
|
return new E(e, t);
|
|
762
|
-
const n = await
|
|
762
|
+
const n = await K(e);
|
|
763
763
|
return e.registerAsync("matchingClient", () => n), new E(e, n);
|
|
764
764
|
});
|
|
765
765
|
}
|
|
@@ -767,16 +767,16 @@ class E {
|
|
|
767
767
|
return this.matchingClient;
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
|
-
const
|
|
770
|
+
const he = async (s) => {
|
|
771
771
|
s.registerAsync("dataClient", () => E.create(s));
|
|
772
772
|
};
|
|
773
773
|
export {
|
|
774
774
|
E as DataClient,
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
775
|
+
ce as DataType,
|
|
776
|
+
ae as FeedbackType,
|
|
777
|
+
he as KnowledgeDataClientPlugin,
|
|
778
778
|
C as ServiceClientQueryType,
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
779
|
+
de as SortingType,
|
|
780
|
+
Q as determineServiceClientQueryType,
|
|
781
|
+
re as formatLegacyData
|
|
782
782
|
};
|