@telia-ace/knowledge-data-client-flamingo 1.0.22 → 1.0.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.
- package/{dist/create-serviceclient.d.ts → create-serviceclient.d.ts} +0 -1
- package/{dist/data-client.d.ts → data-client.d.ts} +0 -1
- package/index-373df3a5.js +6 -0
- package/{dist/index-d70f1e69.js → index-5c9c2abf.mjs} +13 -14
- package/{dist/index.d.ts → index.d.ts} +0 -1
- package/index.js +1 -0
- package/{dist/index.js → index.mjs} +361 -391
- package/{dist/legacy-conversion.d.ts → legacy-conversion.d.ts} +0 -1
- package/package.json +7 -31
- package/{dist/plugin.d.ts → plugin.d.ts} +0 -1
- package/LICENSE.txt +0 -0
- package/README.md +0 -3
- package/dist/create-serviceclient.d.ts.map +0 -1
- package/dist/data-client.d.ts.map +0 -1
- package/dist/index-d70f1e69.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/legacy-conversion.d.ts.map +0 -1
- package/dist/plugin.d.ts.map +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var p=typeof globalThis<"u"&&globalThis||typeof self<"u"&&self||typeof global<"u"&&global||{},b={searchParams:"URLSearchParams"in p,iterable:"Symbol"in p&&"iterator"in Symbol,blob:"FileReader"in p&&"Blob"in p&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in p,arrayBuffer:"ArrayBuffer"in p};function re(t){return t&&DataView.prototype.isPrototypeOf(t)}if(b.arrayBuffer)var ne=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],se=ArrayBuffer.isView||function(t){return t&&ne.indexOf(Object.prototype.toString.call(t))>-1};function S(t){if(typeof t!="string"&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(t)||t==="")throw new TypeError('Invalid character in header field name: "'+t+'"');return t.toLowerCase()}function M(t){return typeof t!="string"&&(t=String(t)),t}function G(t){var e={next:function(){var r=t.shift();return{done:r===void 0,value:r}}};return b.iterable&&(e[Symbol.iterator]=function(){return e}),e}function d(t){this.map={},t instanceof d?t.forEach(function(e,r){this.append(r,e)},this):Array.isArray(t)?t.forEach(function(e){if(e.length!=2)throw new TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}d.prototype.append=function(t,e){t=S(t),e=M(e);var r=this.map[t];this.map[t]=r?r+", "+e:e};d.prototype.delete=function(t){delete this.map[S(t)]};d.prototype.get=function(t){return t=S(t),this.has(t)?this.map[t]:null};d.prototype.has=function(t){return this.map.hasOwnProperty(S(t))};d.prototype.set=function(t,e){this.map[S(t)]=M(e)};d.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)};d.prototype.keys=function(){var t=[];return this.forEach(function(e,r){t.push(r)}),G(t)};d.prototype.values=function(){var t=[];return this.forEach(function(e){t.push(e)}),G(t)};d.prototype.entries=function(){var t=[];return this.forEach(function(e,r){t.push([r,e])}),G(t)};b.iterable&&(d.prototype[Symbol.iterator]=d.prototype.entries);function L(t){if(!t._noBody){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}}function W(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function oe(t){var e=new FileReader,r=W(e);return e.readAsArrayBuffer(t),r}function ie(t){var e=new FileReader,r=W(e),n=/charset=([A-Za-z0-9_-]+)/.exec(t.type),o=n?n[1]:"utf-8";return e.readAsText(t,o),r}function ae(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}function V(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function K(){return this.bodyUsed=!1,this._initBody=function(t){this.bodyUsed=this.bodyUsed,this._bodyInit=t,t?typeof t=="string"?this._bodyText=t:b.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:b.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:b.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():b.arrayBuffer&&b.blob&&re(t)?(this._bodyArrayBuffer=V(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):b.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||se(t))?this._bodyArrayBuffer=V(t):this._bodyText=t=Object.prototype.toString.call(t):(this._noBody=!0,this._bodyText=""),this.headers.get("content-type")||(typeof t=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):b.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},b.blob&&(this.blob=function(){var t=L(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var t=L(this);return t||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}else{if(b.blob)return this.blob().then(oe);throw new Error("could not read as ArrayBuffer")}},this.text=function(){var t=L(this);if(t)return t;if(this._bodyBlob)return ie(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(ae(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},b.formData&&(this.formData=function(){return this.text().then(ue)}),this.json=function(){return this.text().then(JSON.parse)},this}var ce=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function he(t){var e=t.toUpperCase();return ce.indexOf(e)>-1?e:t}function j(t,e){if(!(this instanceof j))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');e=e||{};var r=e.body;if(t instanceof j){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new d(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,!r&&t._bodyInit!=null&&(r=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",(e.headers||!this.headers)&&(this.headers=new d(e.headers)),this.method=he(e.method||this.method||"GET"),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal||function(){if("AbortController"in p){var s=new AbortController;return s.signal}}(),this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&r)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(r),(this.method==="GET"||this.method==="HEAD")&&(e.cache==="no-store"||e.cache==="no-cache")){var n=/([?&])_=[^&]*/;if(n.test(this.url))this.url=this.url.replace(n,"$1_="+new Date().getTime());else{var o=/\?/;this.url+=(o.test(this.url)?"&":"?")+"_="+new Date().getTime()}}}j.prototype.clone=function(){return new j(this,{body:this._bodyInit})};function ue(t){var e=new FormData;return t.trim().split("&").forEach(function(r){if(r){var n=r.split("="),o=n.shift().replace(/\+/g," "),s=n.join("=").replace(/\+/g," ");e.append(decodeURIComponent(o),decodeURIComponent(s))}}),e}function fe(t){var e=new d,r=t.replace(/\r?\n[\t ]+/g," ");return r.split("\r").map(function(n){return n.indexOf(`
|
|
2
|
+
`)===0?n.substr(1,n.length):n}).forEach(function(n){var o=n.split(":"),s=o.shift().trim();if(s){var a=o.join(":").trim();try{e.append(s,a)}catch(c){console.warn("Response "+c.message)}}}),e}K.call(j.prototype);function P(t,e){if(!(this instanceof P))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(e||(e={}),this.type="default",this.status=e.status===void 0?200:e.status,this.status<200||this.status>599)throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=e.statusText===void 0?"":""+e.statusText,this.headers=new d(e.headers),this.url=e.url||"",this._initBody(t)}K.call(P.prototype);P.prototype.clone=function(){return new P(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new d(this.headers),url:this.url})};P.error=function(){var t=new P(null,{status:200,statusText:""});return t.status=0,t.type="error",t};var le=[301,302,303,307,308];P.redirect=function(t,e){if(le.indexOf(e)===-1)throw new RangeError("Invalid status code");return new P(null,{status:e,headers:{location:t}})};var O=p.DOMException;try{new O}catch{O=function(e,r){this.message=e,this.name=r;var n=Error(e);this.stack=n.stack},O.prototype=Object.create(Error.prototype),O.prototype.constructor=O}function Y(t,e){return new Promise(function(r,n){var o=new j(t,e);if(o.signal&&o.signal.aborted)return n(new O("Aborted","AbortError"));var s=new XMLHttpRequest;function a(){s.abort()}s.onload=function(){var i={statusText:s.statusText,headers:fe(s.getAllResponseHeaders()||"")};o.url.startsWith("file://")&&(s.status<200||s.status>599)?i.status=200:i.status=s.status,i.url="responseURL"in s?s.responseURL:i.headers.get("X-Request-URL");var u="response"in s?s.response:s.responseText;setTimeout(function(){r(new P(u,i))},0)},s.onerror=function(){setTimeout(function(){n(new TypeError("Network request failed"))},0)},s.ontimeout=function(){setTimeout(function(){n(new TypeError("Network request timed out"))},0)},s.onabort=function(){setTimeout(function(){n(new O("Aborted","AbortError"))},0)};function c(i){try{return i===""&&p.location.href?p.location.href:i}catch{return i}}if(s.open(o.method,c(o.url),!0),o.credentials==="include"?s.withCredentials=!0:o.credentials==="omit"&&(s.withCredentials=!1),"responseType"in s&&(b.blob?s.responseType="blob":b.arrayBuffer&&(s.responseType="arraybuffer")),e&&typeof e.headers=="object"&&!(e.headers instanceof d||p.Headers&&e.headers instanceof p.Headers)){var h=[];Object.getOwnPropertyNames(e.headers).forEach(function(i){h.push(S(i)),s.setRequestHeader(i,M(e.headers[i]))}),o.headers.forEach(function(i,u){h.indexOf(u)===-1&&s.setRequestHeader(u,i)})}else o.headers.forEach(function(i,u){s.setRequestHeader(u,i)});o.signal&&(o.signal.addEventListener("abort",a),s.onreadystatechange=function(){s.readyState===4&&o.signal.removeEventListener("abort",a)}),s.send(typeof o._bodyInit>"u"?null:o._bodyInit)})}Y.polyfill=!0;p.fetch||(p.fetch=Y,p.Headers=d,p.Request=j,p.Response=P);self.fetch.bind(self);const F="functional",U="Humany__parameters";function de(t){const e={};return t&&Object.keys(t).forEach(r=>{const n=t[r];(_(n)==="array"?n:[n]).forEach(o=>{typeof e[r]>"u"&&(e[r]=[]),e[r].push(o)})}),e}class pe{constructor(e,r){this.isLoaded=!!e,this.parameters=de(e),r&&typeof r.get=="function"&&(this.container=r)}getAll(){return this.ensureIsLoaded(),l(!0,{},this.parameters)}add(e,r){this.ensureIsLoaded(),this.parameters[e]||(this.parameters[e]=[]),this.parameters[e].push(r),this.persist()}set(e,r){this.ensureIsLoaded(),this.parameters[e]=[r],this.persist()}remove(e,r){if(this.ensureIsLoaded(),typeof r>"u")delete this.parameters[e];else{const n=this.parameters[e]||[];n.forEach((o,s)=>{o===r&&n.splice(s,1)}),this.parameters[e]=n}this.persist()}clear(){this.ensureIsLoaded(),this.parameters={},this.persist()}persist(){try{R(this.container).indexOf(F)>-1?C(U,this.parameters,1):C(U,"",-1)}catch(e){window.console&&window.console.warn&&window.console.warn("Error occured when persisting parameter bag.",e)}}ensureIsLoaded(){if(!this.isLoaded){try{const e=q(U);this.parameters=e||{},R(this.container).indexOf(F)===-1&&C(U,"",-1)}catch(e){window.console&&window.console.warn&&window.console.warn("Error occured when loading parameter bag.",e)}this.isLoaded=!0}}}function E(){return Math.floor((1+Math.random())*65536).toString(16).substring(1)}function z(){return E()+E()+"-"+E()+"-"+E()+"-"+E()+"-"+E()+E()+E()}const Z="analytical",k="Humany__clientId";let T="";function ye(t){if(R(t).indexOf(Z)===-1)return C(k,"",-1),T.length||(T=z()),T;const e=q(k);return e||(T.length||(T=z()),C(k,T,1)),e||T}function be(){return"Default"}function me(...t){const e=window.location;return[t[0]!==!1?"http:":e.protocol,"//",e.host,e.pathname].join("")}function ge(){}const we={"[object Array]":"array","[object Boolean]":"boolean","[object Date]":"date","[object Function]":"function","[object Number]":"number","[object Object]":"object","[object RegExp]":"regexp","[object String]":"string"};function _(t){return t==null?t+"":typeof t=="object"||typeof t=="function"?we[{}.toString.call(t)]||"object":typeof t}function f(t){return _(t)==="function"}function J(t){let e;if(!t||_(t)!=="object"||t.nodeType)return!1;try{if(t.constructor&&!Object.prototype.hasOwnProperty.call(t,"constructor")&&!Object.prototype.hasOwnProperty.call(t.constructor.prototype,"isPrototypeOf"))return!1}catch{return!1}for(e in t);return e===void 0||Object.prototype.hasOwnProperty.call(t,e)}function l(...t){let e,r,n,o,s,a,c=t[0]||{},h=1;const i=t.length;let u=!1;for(typeof c=="boolean"&&(u=c,c=t[1]||{},h=2),typeof c!="object"&&!f(c)&&(c={});h<i;h++)if((e=t[h])!=null)for(r in e)n=c[r],o=e[r],c!==o&&(u&&o&&(J(o)||(s=_(o)==="array"))?(s?(s=!1,a=n&&_(n)==="array"?n:[]):a=n&&J(n)?n:{},c[r]=l(u,a,o)):o!==void 0&&(c[r]=o));return c}const q=t=>{const e=new RegExp(`(?:^|;)\\s?${t}=(.*?)(?:;|$)`,"i"),r=document.cookie.match(e),n=r&&r[1];if(n){if(t==="Humany__clientId")try{return JSON.parse(n)}catch{const s=JSON.stringify(n);return JSON.parse(s)}return JSON.parse(n)}},C=(t,e,r)=>{const n=JSON.stringify(e).trim().replace(/^"+|"+$/g,""),o=`${t}=${n}`,s=`expires=${ve(r)}`,a="path=/",c="SameSite=None",h="Secure";return document.cookie=`${o}; ${s}; ${a}; ${c}; ${h}`},R=t=>{const e=["necessary"];if(!t)return e;const r=t.get("$widget");if(!r||!r.implementation||!r.implementation.tenant)return e;const{implementation:{tenant:n}}=r,o=q(`humany_${n}`);return!o||!o.storagePolicy||!o.storagePolicy.value||!Array.isArray(o.storagePolicy.value)||!o.storagePolicy.value.length?e:o.storagePolicy.value},ve=(t=1)=>{const e=new Date;return e.setTime(e.getTime()+t*24*60*60*1e3),e.toUTCString()},Pe=(t=["necessary"])=>{t.indexOf(F)===-1&&C(U,"",-1),t.indexOf(Z)===-1&&C(k,"",-1)};function $(t,e,r){if(typeof e>"u"||typeof r>"u")return t;const n=t&&t.indexOf("?")!==-1?"&":"?";return`${t}${n}${encodeURIComponent(e)}=${encodeURIComponent(r)}`}const X="p.";function ee(t,e){let r=t;return Object.keys(e).forEach(n=>{const o=e[n];_(o)==="array"?o.forEach(s=>{r=$(r,`${X}${n}`,s)}):r=$(r,`${X}${n}`,o)}),r}class Q{constructor(e,r){l(!0,this,e,{_client:r})}}class H{constructor(e,r){l(!0,this,e,{_client:r})}}function A(t,e,r,n){const o=[];return t[e].forEach(s=>{const a=new r(s,n),c=s[e],h=_(c);s[e]&&(h==="array"||h==="object")&&(a[e]=A(s,e,r,n)),o.push(a)}),o}class N{constructor(e,r){l(!0,this,e,{_client:r})}}function x(t,e){return f(t)?e?t.call(e):t.call(window):t}function I(t,e,r,n){let o=Promise.resolve(r);for(let s=0,a=t.length;s<a;s++){const c=t[s][e];f(c)&&(o=o.then(()=>c(r,n)))}return o}class Ee{constructor(e,r={}){this.setBaseUrl(e),this.globalOptions=r,this.interceptors=r.interceptors||[]}constructUrl(e){return this.baseUrl+e}setBaseUrl(e){this.baseUrl=e+(e[e.length-1]!=="/"?"/":"")}request(e,r){const n=l(!0,{},this.globalOptions,r);let o=this.constructUrl(e);const s=this.interceptors;return n.credentials==="include"&&(o=$(o,"credentials","true")),new Promise((a,c)=>{I(s,"request",{url:o,options:n}).then(h=>fetch(h.url,h.options).then(i=>({response:i,request:h}))).then(({response:h,request:i})=>{if(h.ok){const u=h;return h.json().then(w=>{I(s,"response",{response:h,json:w,request:i}).then(()=>{n.envelope?a({json:w,response:u}):a(w),I(s,"responseEnd",{response:h,json:w,request:i})})})}else I(s,"responseError",h).then(u=>{f(n.onError)&&n.onError(u),c(u)})}).catch(h=>{I(s,"responseError",h).then(i=>{f(n.onError)&&n.onError(i),c(i)})})})}}const te=Ee;/*!
|
|
3
|
+
* Humany Service Client Library
|
|
4
|
+
* Version: 2.0
|
|
5
|
+
* Copyright 2017, Telia Company AB, http://www.humany.com/
|
|
6
|
+
*/class B{constructor(...e){const r=e[1]||{};if(this.proxy=typeof e[0]=="string"?new te(e[0]):e[0],this.settings=l(!0,{},B.defaults,e[1]||{}),this.parameters=new pe(e[2],e[3]),this.current={phrase:r.phrase},this.guideCache={},this.feedbackTypes={positive:"Positive",negative:"Negative",comment:"Comment"},this.handoverTypes={email:"Email",chat:"Chat",callback:"Callback",phone:"Phone",emailComplementary:"ComplementaryEmail",chatComplementary:"ComplementaryChat",callbackComplementary:"ComplementaryCallback",phoneComplementary:"ComplementaryPhone"},this.subscriptions=[],e[3]&&typeof e[3].get=="function"){this.container=e[3];const n=this.container.get("$widget");n&&n.events&&this.subscriptions.push(n.events.subscribe("storage:policy-changed",(o,s)=>Pe(s)))}}getConfiguration(){return{language:x(this.settings.language,this),client:x(()=>this.settings.client(this.container),this),funnel:x(this.settings.funnel,this),site:x(this.settings.site,this),reader:x(this.settings.reader,this),perspective:x(this.settings.perspective,this)}}customRequest(e,r,n={}){const o=n.configuration||{},s=n.parameters;return e=this.constructPath(e,o,s),this.proxy.request(e,{method:r,body:n.body}).then(a=>(n.success&&n.success(a),a)).catch(a=>(n.error&&n.error(a),a))}constructPath(e,r,n=!0){let o=e;const s=l(this.getConfiguration(),r);if(Object.keys(s).filter(a=>{const c=s[a];return c!==null&&typeof c<"u"}).forEach(a=>o=$(o,a,x(s[a]))),n){const a=n===!0?this.parameters.getAll():n;o=ee(o,a)}return o}match(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1]||{},o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(y){if(f(o)){const v=this;y=this.settings.useProxyClasses&&y?(()=>(y.Matches=A(y,"Matches",N,v),y))():y,o(y)}return y}function c(y){f(s)&&s(y)}const h=l(!0,this.getConfiguration(),this.settings.paging,n),i={};let u="GET";i.categories=h.categories||h.categoryId,i.language=h.language,i.phrase=r,i.attributes=h.attributes,i.skip=h.skip,i.take=h.take,i.reader=h.reader,i.disableNotices=h.disableNotices,i.tags=h.tags,i.includeCategories=h.includeCategories,i.groupByCategory=h.groupByCategory,n.statisticsDisabled||(u="POST",i.funnel=h.funnel,i.client=h.client,i.site=h.site,this.current.phrase=r);const w="guides";n.sorting&&(i["sorting.type"]=n.sorting.type,i["sorting.direction"]=n.sorting.direction);const m=this.constructPath(w,i);return this.proxy.request(m,{method:u}).then(a.bind(this)).catch(c.bind(this))}getGuide(...e){const r=e[0];let n,o={},s,a;typeof e[1]=="function"?(s=e[1],a=e[2]):typeof e[1]=="object"?(o=e[1]||{},s=e[2],a=e[3]):typeof e[1]=="string"?(n=e[1],typeof e[2]=="function"?(s=e[2],a=e[3]):(o=e[2]||{},s=e[3],a=e[4])):!e[1]&&typeof e[2]=="function"&&(s=e[2],a=e[3]);function c(v){if(f(s)){const g=this.settings.useProxyClasses&&v?new N(v,this):v;this.guideCache[g.Id]=g,s(g)}return v}function h(v){return f(a)&&a(v),Promise.reject(v)}const i=l(!0,this.getConfiguration(),o),u={};let w="GET";u.connectionId=n||i.connectionId,u.perspective=i.perspective,u.reader=i.reader,u.phrase=this.current.phrase,this.parameters.remove("LastGuideId"),this.parameters.add("LastGuideId",r);let m=`guides/${r}`;u.connectionId&&(m+=`/${u.connectionId}`);let y="";return!o.statisticsDisabled&&!u.connectionId?(w="POST",y=this.constructPath(m,l({},this.current,o))):y=this.constructPath(m,l({},this.current,o),!1),this.proxy.request(y,{method:w}).then(c.bind(this)).catch(h.bind(this))}getCategories(...e){let r={},n,o;typeof e[0]=="object"?(r=e[0]||{},n=e[1],o=e[2]):(n=e[0],o=e[1]);function s(i){if(f(n)){const u=this;i=this.settings.useProxyClasses&&i?(()=>(i.Children=A(i,"Children",Q,u),i))():i,n(i)}return i}function a(i){f(o)&&o(i)}let c="categories";r.categoryId&&(c+="/"+r.categoryId);const h=this.constructPath(c,l({},this.current,r));return this.proxy.request(h,{method:"GET"}).then(s.bind(this)).catch(a.bind(this))}answer(...e){const r=e[0],n=e[1];let o={},s,a,c;typeof e[2]=="object"?(o=e[2]||{},s=e[3],a=e[4]):(s=e[2],a=e[3]);const h=!!o.persist;function i(){!h&&c&&this.parameters.remove(c.Condition.ParameterName,c.Condition.Value)}function u(g){if(i(),f(s)){const D=this.settings.useProxyClasses&&g?new N(g,this):g;this.guideCache[D.Id]=D,s(D)}}function w(g){i(),f(a)&&a(g)}const m=this.guideCache[r];m.Options&&m.Options.forEach(g=>{this.parameters.remove(g.Condition.ParameterName,g.Condition.Value),g.ConnectionId===n&&(c=g)}),this.parameters.add(c.Condition.ParameterName,c.Condition.Value);const y=`guides/${r}/${n}`,v=this.constructPath(y,l({},this.current,o));return this.proxy.request(v,{method:"GET"}).then(u.bind(this)).catch(w.bind(this))}giveFeedback(...e){const r=e[0];let n,o,s={},a,c;typeof e[2]=="string"?(n=e[1],o=e[2],typeof e[3]=="object"?(s=e[3]||{},a=e[4],c=e[5]):(a=e[3],c=e[4])):(o=e[1],typeof e[2]=="object"&&(s=e[2]||{},a=e[3],c=e[4]));function h(m){return f(a)&&a(m),m}function i(m){return f(c)&&c(m),m}const u=`guides/${r}${n?"/"+n:""}/feedback`,w=this.constructPath(u,l({},s,{feedbackType:o}));return this.proxy.request(w,{method:"POST"}).then(h.bind(this)).catch(i.bind(this))}completeContactMethod(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(u){f(o)&&o(u)}function c(u){f(s)&&s(u)}const h=`contactmethods/${r}/completed`,i=this.constructPath(h,n);return this.proxy.request(i,{method:"PUT"}).then(a.bind(this)).catch(c.bind(this))}getContactMethod(...e){const r=e[0];let n={},o,s;typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2]);function a(u){if(f(o))o(u.ContactMethod);else return u}function c(u){if(f(s))s(u);else return u}const h=`contactmethods/${r}`,i=this.constructPath(h,l({},this.current,n));return this.proxy.request(i,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}contactMethods(...e){let r,n={},o,s;typeof e[0]=="number"?(r=e[0],n=e[1]||{},o=e[2],s=e[3]):typeof e[0]=="object"?(n=e[0]||{},o=e[1],s=e[2]):(o=e[0],s=e[1]);function a(u){return f(o)&&(u=this.settings.useProxyClasses&&u?(()=>(u.Matches=A(u,"Matches",H),u))():u,o(u)),u}function c(u){return f(s)&&s(u),u}const h=r?`guides/${r}/contactmethods`:"contactmethods",i=this.constructPath(h,l({},this.current,n));return this.proxy.request(i,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}contacts(...e){let r,n={},o,s;typeof e[0]=="number"?(r=e[0],typeof e[1]=="object"?(n=e[1],o=e[2],s=e[3]):(o=e[1],s=e[2])):typeof e[0]=="object"?(n=e[0]||{},o=e[1],s=e[2]):(o=e[0],s=e[1]);function a(i){if(f(o))i&&this.settings.useProxyClasses&&(i.Children&&(i.Children=A(i,"Children",Q)),i.Matches&&(i.Matches=A(i,"Matches",H)),i.Highlighted&&(i.Highlighted=A(i,"Highlighted",H))),o(i);else return i}function c(i){if(f(s))s(i);else return i}const h=this.constructPath(`contacts/${r||""}`,l({},this.current,n));return this.proxy.request(h,{method:"GET"}).then(a.bind(this)).catch(c.bind(this))}getSettings(e){const r=this.constructPath("config",this.current);return this.proxy.request(r,{method:"GET"}).then(e)}getAuthorized(e,r){const n=this.constructPath("interfaceauthorized",this.current);return this.proxy.request(n,{method:"GET",credentials:"include"}).then(e).catch(r)}submitForm(e,r,n,o,s){let a="forms/"+e;return n&&(a+="/"+n),a=this.constructPath("config",l({},this.current,r)),this.proxy.request(a,"POST",r,o,s)}getTab(e,r,n,o){var s=arguments;typeof s[1]=="object"?(r=s[1],n=s[2],o=s[3]):(r={},n=s[1],o=s[2]);const a=`tabs/${e}`;return this.proxy.request(a,{method:"GET"}).then(n).catch(o)}dispose(){this.subscriptions.forEach(e=>e())}}B.feedbackTypes={positive:"Positive",negative:"Negative",comment:"Comment"};B.handoverTypes={email:"Email",chat:"Chat",callback:"Callback",phone:"Phone",emailComplementary:"ComplementaryEmail",chatComplementary:"ComplementaryChat",callbackComplementary:"ComplementaryCallback",phoneComplementary:"ComplementaryPhone"};B.defaults={client:ye,funnel:be,site:me,language:ge,paging:{skip:0,take:10},useProxyClasses:!1};B.version="1.0";const Ce=B;exports.ServiceClient=Ce;exports.ServiceProxy=te;exports.appendParameters=ee;exports.appendQueryString=$;exports.getCookie=q;exports.getStoragePolicyConsent=R;exports.setCookie=C;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var p = typeof globalThis
|
|
2
|
-
typeof global
|
|
1
|
+
var p = typeof globalThis < "u" && globalThis || typeof self < "u" && self || // eslint-disable-next-line no-undef
|
|
2
|
+
typeof global < "u" && global || {}, b = {
|
|
3
3
|
searchParams: "URLSearchParams" in p,
|
|
4
4
|
iterable: "Symbol" in p && "iterator" in Symbol,
|
|
5
5
|
blob: "FileReader" in p && "Blob" in p && function() {
|
|
6
6
|
try {
|
|
7
7
|
return new Blob(), !0;
|
|
8
|
-
} catch
|
|
8
|
+
} catch {
|
|
9
9
|
return !1;
|
|
10
10
|
}
|
|
11
11
|
}(),
|
|
@@ -271,7 +271,7 @@ P.redirect = function(t, e) {
|
|
|
271
271
|
var A = p.DOMException;
|
|
272
272
|
try {
|
|
273
273
|
new A();
|
|
274
|
-
} catch
|
|
274
|
+
} catch {
|
|
275
275
|
A = function(e, r) {
|
|
276
276
|
this.message = e, this.name = r;
|
|
277
277
|
var n = Error(e);
|
|
@@ -303,7 +303,7 @@ function Y(t, e) {
|
|
|
303
303
|
}, 0);
|
|
304
304
|
}, s.ontimeout = function() {
|
|
305
305
|
setTimeout(function() {
|
|
306
|
-
n(new TypeError("Network request
|
|
306
|
+
n(new TypeError("Network request timed out"));
|
|
307
307
|
}, 0);
|
|
308
308
|
}, s.onabort = function() {
|
|
309
309
|
setTimeout(function() {
|
|
@@ -313,7 +313,7 @@ function Y(t, e) {
|
|
|
313
313
|
function c(i) {
|
|
314
314
|
try {
|
|
315
315
|
return i === "" && p.location.href ? p.location.href : i;
|
|
316
|
-
} catch
|
|
316
|
+
} catch {
|
|
317
317
|
return i;
|
|
318
318
|
}
|
|
319
319
|
}
|
|
@@ -330,7 +330,7 @@ function Y(t, e) {
|
|
|
330
330
|
});
|
|
331
331
|
o.signal && (o.signal.addEventListener("abort", a), s.onreadystatechange = function() {
|
|
332
332
|
s.readyState === 4 && o.signal.removeEventListener("abort", a);
|
|
333
|
-
}), s.send(typeof o._bodyInit
|
|
333
|
+
}), s.send(typeof o._bodyInit > "u" ? null : o._bodyInit);
|
|
334
334
|
});
|
|
335
335
|
}
|
|
336
336
|
Y.polyfill = !0;
|
|
@@ -342,7 +342,7 @@ function fe(t) {
|
|
|
342
342
|
return t && Object.keys(t).forEach((r) => {
|
|
343
343
|
const n = t[r];
|
|
344
344
|
(_(n) === "array" ? n : [n]).forEach((o) => {
|
|
345
|
-
typeof e[r]
|
|
345
|
+
typeof e[r] > "u" && (e[r] = []), e[r].push(o);
|
|
346
346
|
});
|
|
347
347
|
}), e;
|
|
348
348
|
}
|
|
@@ -360,7 +360,7 @@ class le {
|
|
|
360
360
|
this.ensureIsLoaded(), this.parameters[e] = [r], this.persist();
|
|
361
361
|
}
|
|
362
362
|
remove(e, r) {
|
|
363
|
-
if (this.ensureIsLoaded(), typeof r
|
|
363
|
+
if (this.ensureIsLoaded(), typeof r > "u")
|
|
364
364
|
delete this.parameters[e];
|
|
365
365
|
else {
|
|
366
366
|
const n = this.parameters[e] || [];
|
|
@@ -438,7 +438,7 @@ function J(t) {
|
|
|
438
438
|
try {
|
|
439
439
|
if (t.constructor && !Object.prototype.hasOwnProperty.call(t, "constructor") && !Object.prototype.hasOwnProperty.call(t.constructor.prototype, "isPrototypeOf"))
|
|
440
440
|
return !1;
|
|
441
|
-
} catch
|
|
441
|
+
} catch {
|
|
442
442
|
return !1;
|
|
443
443
|
}
|
|
444
444
|
for (e in t)
|
|
@@ -461,7 +461,7 @@ const G = (t) => {
|
|
|
461
461
|
if (t === "Humany__clientId")
|
|
462
462
|
try {
|
|
463
463
|
return JSON.parse(n);
|
|
464
|
-
} catch
|
|
464
|
+
} catch {
|
|
465
465
|
const s = JSON.stringify(n);
|
|
466
466
|
return JSON.parse(s);
|
|
467
467
|
}
|
|
@@ -488,7 +488,7 @@ const G = (t) => {
|
|
|
488
488
|
t.indexOf(H) === -1 && O(U, "", -1), t.indexOf(Z) === -1 && O($, "", -1);
|
|
489
489
|
};
|
|
490
490
|
function k(t, e, r) {
|
|
491
|
-
if (typeof e
|
|
491
|
+
if (typeof e > "u" || typeof r > "u")
|
|
492
492
|
return t;
|
|
493
493
|
const n = t && t.indexOf("?") !== -1 ? "&" : "?";
|
|
494
494
|
return `${t}${n}${encodeURIComponent(e)}=${encodeURIComponent(r)}`;
|
|
@@ -626,7 +626,7 @@ class B {
|
|
|
626
626
|
const s = l(this.getConfiguration(), r);
|
|
627
627
|
if (Object.keys(s).filter((a) => {
|
|
628
628
|
const c = s[a];
|
|
629
|
-
return c !== null && typeof c
|
|
629
|
+
return c !== null && typeof c < "u";
|
|
630
630
|
}).forEach((a) => o = k(o, a, T(s[a]))), n) {
|
|
631
631
|
const a = n === !0 ? this.parameters.getAll() : n;
|
|
632
632
|
o = ve(o, a);
|
|
@@ -881,4 +881,3 @@ export {
|
|
|
881
881
|
N as getStoragePolicyConsent,
|
|
882
882
|
O as setCookie
|
|
883
883
|
};
|
|
884
|
-
//# sourceMappingURL=index-d70f1e69.js.map
|
package/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=(n,e,t,...i)=>{const s=`[${n.get("$environment").name||"webprovisions"}] ${t}`;switch(e){case"info":console.info(s,...i);break;case"warning":console.warn(s,...i);break;case"error":console.error(s,...i);break}},Fe=n=>{const e=n.container||n;return{info:(t,...i)=>Y(e,"info",t,...i),warn:(t,...i)=>Y(e,"warning",t,...i),error:(t,...i)=>Y(e,"error",t,...i)}};var D=(n=>(n.Implementation="implementation",n.Widget="widget",n))(D||{}),x=(n=>(n.Pre="pre",n.Post="post",n))(x||{});const Ue=(n,e,t,i)=>{try{const s=new e(t,i);return{name:n,invoke:(r,a)=>{let o;return s[r]&&(o=s[r].call(s,a)),Promise.resolve(o)},getInstance:()=>s}}catch(s){if(s.message&&s.message.indexOf("is not a constructor")>=0)return{name:n,invoke:r=>{let a;return r==="initialize"&&(a=e(t,i)),Promise.resolve(a)},getInstance:()=>e};throw s}};function ue(n,e){return typeof n>"u"?e:n}let Be=class{constructor(e={}){this.part=e}createCommand(e,t,i){let s;typeof t=="function"?s={scope:D.Widget,stage:x.Post,defaultArgs:void 0,handlerResolver:t}:s={scope:ue(t.scope,D.Widget),stage:ue(t.stage,x.Post),defaultArgs:t.defaultArgs,handlerResolver:i};let r=this.part;const a=e.split(".");return a.forEach((o,c)=>{c===a.length-1?r[o]||(r[o]=()=>s):r=this.part[o]=this.part[o]||{}}),this}get(){return this.part}};const Ae=n=>{const e=new Be({});return n(e),e.get()};Ae(n=>{n.createCommand("types.register",{scope:D.Implementation,stage:x.Pre},e=>(t,i)=>{e.container.get("$types")[t]=i}).createCommand("type",{stage:x.Pre},e=>t=>{e.container.register("$type",t)}).createCommand("settings",{stage:x.Pre,defaultArgs:[null]},e=>t=>{e.events.dispatch("settings:change",t,{bubbles:!0}),e.container.register("$settings",t)}).createCommand("plugin",{stage:x.Pre},e=>(t,i,s)=>{const{container:r}=e;let a=null,o=t,c=i;typeof t=="string"&&(a=t,o=i,c=s);const h=d=>{const{transformPluginSettings:g}=e.container.get("$environmentOptions"),u=g?g(c||{},a,e.container,o):i;try{const p=Ue(a,o,r,u);r.get("$plugins").push(p),d&&p.invoke("initialize",null)}catch(p){Fe(e).warn("Error when initializing plugin",p)}};e.container.get("$instance")?h(!0):e.events.subscribeOnce("widget:instance-created",()=>h(!1))}).createCommand("container.register",e=>(t,i)=>{e.container.register(t,i)}).createCommand("container.registerAsync",e=>(t,i)=>{e.container.registerAsync(t,i)}).createCommand("container.registerFactory",e=>(t,i)=>{e.container.registerFactory(t,i)}).createCommand("container.touch",e=>(t,i)=>{e.container.touch(t,i)}).createCommand("csp",{},e=>t=>{e.container.register("csp",t)})});const We=Ae(n=>{n.createCommand("ready",{scope:D.Implementation,stage:x.Pre},e=>t=>{const{container:i}=e,s=i.owner;i.get("bootstrapping").ready?t(s):s.events.subscribeOnce("bootstrap:ready",()=>{t(s)})})}),Z=new WeakMap;function R(){return n=>(Z.has(n)||Z.set(n,{}),Z.get(n))}const J=(n,e,t,...i)=>{const s=`[${n.get("$environment").name||"webprovisions"}] ${t}`;switch(e){case"info":console.info(s,...i);break;case"warning":console.warn(s,...i);break;case"error":console.error(s,...i);break}},v=n=>{const e=n.container||n;return{info:(t,...i)=>J(e,"info",t,...i),warn:(t,...i)=>J(e,"warning",t,...i),error:(t,...i)=>J(e,"error",t,...i)}},m=R(),re=(()=>{let n=0;return()=>++n})(),oe=(n,e,t)=>{const i=m(n).touchQueue.get(e);i&&i.forEach(s=>{s(t,n)})};class Qe{constructor(e,t,i,s){this.key=e,this.factory=t,this.parent=i,this.container=s,this.id=re(),this.resolved=!1,this.constructed=!1,this.async=!0}resolve(){if(!this.constructed){const e=this.factory(this.parent,this.container);return this.constructed=!0,this.value=Promise.resolve(e).then(t=>(this.resolved=!0,oe(this.container,this.key,t),t))}return this.value}}class He{constructor(e,t,i,s){this.key=e,this.value=t,this.parent=i,this.container=s,this.id=re(),this.async=!1,this.resolved=!1,this.constructed=!0,this.resolve=()=>(this.resolved=!0,oe(this.container,this.key,this.value),this.value)}}class Ve{constructor(e,t,i,s){this.key=e,this.value=t,this.parent=i,this.container=s,this.id=re(),this.async=!1,this.resolved=!1,this.constructed=!1,this.resolve=()=>{this.resolved=!0,this.constructed=!0;const r=this.value(this.parent,this.container);return oe(this.container,this.key,this.value),r}}}class ae{constructor(e,t,i){this.owner=e,this.name=t,this.parent=i,m(this).resolvers=new Map,m(this).touchQueue=new Map,m(this).children=[]}delete(e){const t=m(this).resolvers,i=Array.from(t.values()).find(s=>s.id===e);return i?(m(this).touchQueue.delete(i.key),Promise.resolve(t.delete(i.key))):this.parent?this.parent.delete(e):Promise.resolve(!1)}clear(){const e=m(this).resolvers,t=Array.from(e.values());return Promise.all(t.map(i=>{if(i.constructed)return Promise.resolve(i.resolve()).then(s=>{if(s!==null&&typeof s=="object"&&typeof s.dispose=="function")return s.dispose.call(s,this,i)})})).then(()=>{t.forEach(i=>this.delete(i.id)),m(this).children.forEach(i=>i.clear())})}detach(){if(this.parent){const e=m(this.parent).children,t=e.indexOf(this);t>-1&&(e.splice(t,1),delete this.parent)}}touch(e,t){const i=m(this).resolvers.get(e);if(i&&i.constructed)Promise.resolve(i.resolve()).then(s=>{t(s,this)});else{const s=m(this).touchQueue;let r=s.get(e);r||(r=[],s.set(e,r)),r.push(t)}return this.parent&&!i?this.parent.touch(e,t):Promise.resolve()}registerAsync(e,t){const i=m(this).resolvers.get(e);i&&!i.async&&process.env.NODE_ENV!=="production"&&v(this).warn(`Mismatching resolver type. You are registering an async resolver with a key ('${e}') previously used by a non-async resolver.`);const s=new Qe(e,t,i,this);return m(this).resolvers.set(e,s),s.id}registerFactory(e,t){const i=m(this).resolvers.get(e);i&&i.async&&process.env.NODE_ENV!=="production"&&v(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${e}') previously used by an async resolver.`);const s=new Ve(e,t,i,this);return m(this).resolvers.set(e,s),s.id}register(e,t){const i=m(this).resolvers.get(e);i&&i.async&&process.env.NODE_ENV!=="production"&&v(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${e}') previously used by an async resolver.`);const s=new He(e,t,i,this);return m(this).resolvers.set(e,s),s.id}get(e){const t=m(this).resolvers.get(e);if(t)return t.async&&process.env.NODE_ENV!=="production"&&v(this).warn(`You are retrieving an async value (with key '${e}') by the non-async function 'container.get(key)'. This will not be supported in future versions. Use 'container.getAsync(key) instead.'`),t.resolve();if(this.parent)return this.parent.get(e)}getAsync(e){const t=m(this).resolvers.get(e);if(t){if(!t.async)throw process.env.NODE_ENV!=="production"&&v(this).warn(`You are retrieving a non-async value (with key '${e}') by the async function 'container.getAsync(key)'.Use 'container.get(key) instead.'`),"Mismatching resolver type";return t.resolve()}return this.parent?this.parent.getAsync(e):Promise.resolve(void 0)}getMany(...e){const t={};return e.forEach(i=>t[i]=this.get(i)),t}getManyAsync(...e){const t={};return Promise.all(e.map(i=>this.getAsync(i).then(s=>t[i]=s))).then(()=>t)}createChild(e,t){const i=new ae(e,t,this);return m(this).children.push(i),i}}class ge{constructor(e,t,i=!1,s=!1){this.type=e,this.target=t,this.cancelable=!!i,this.bubbles=!!s,this.defaultPrevented=!1}preventDefault(){this.cancelable&&(this.defaultPrevented=!0)}}const $=R(),pe=(n,e)=>[].concat($(n).listenerLookup.get(e.toLowerCase())||[],$(n).listenerLookup.get("*")||[]),me=(n,e,t,i)=>{let s,r;return e instanceof ge?(s=e,r=e.type):(s=new ge(e,n.target,!!t.cancelable,!!t.bubbles),r=e),{event:s,type:r,async:i}};let Ke=class Ne{constructor(e,t){this.target=e,this.parent=t,$(this).listenerLookup=new Map,$(this).children=[]}clear(){$(this).listenerLookup.clear(),$(this).children.forEach(e=>e.clear())}detach(){if(this.parent){const e=$(this.parent).children,t=e.indexOf(this);t>-1&&e.splice(t,1)}}subscribe(e,t,i){const s=$(this).listenerLookup,r=e.toLowerCase();return s.has(r)||s.set(r,[]),s.get(r).push(t),()=>this.unsubscribe(e,t)}subscribeOnce(e,t){const i=this.subscribe(e,(s,r)=>(i(),t(s,r)))}unsubscribe(e,t){const i=$(this).listenerLookup.get(e.toLowerCase());if(i){const s=i.indexOf(t);s>-1&&i.splice(s,1)}}dispatchAsync(e,t,i={}){const{event:s,type:r}=me(this,e,i,!0),a=pe(this,r);let o=0;const c=a.length;let h=Promise.resolve();for(o=0;o<c;o++)(d=>{h=h.then(g=>g?Promise.resolve(!0):Promise.resolve(d(s,t)).then(()=>s.defaultPrevented))})(a[o]);return h.then(d=>!d&&s.bubbles&&this.parent?this.parent.dispatchAsync(s,t):d)}dispatch(e,t,i={}){const{event:s,type:r}=me(this,e,i,!1),a=pe(this,r);let o=0;const c=a.length;let h=!1;for(o=0;o<c;o++)if(a[o](s,t),s.defaultPrevented){h=!0;break}return!h&&s.bubbles&&this.parent&&(h=this.parent.dispatch(s,t)),h}createChild(e){const t=new Ne(e,this);return $(this).children.push(t),t}};const z=(n,e,t)=>{const i=n.get("$plugins").map(s=>{try{return s.invoke(e,t)}catch(r){v(n).error("An error occured when invoking a plugin.",s,r)}});return Promise.all(i)};let Ye=class{constructor(e){this.widget=e.get("$widget"),this.events=this.widget.events,this.container=this.widget.container,this.initialized=null,this.activated=null,this.initialize=this.initialize.bind(this),this.activate=this.activate.bind(this),this.deactivate=this.deactivate.bind(this),this.invoke=this.invoke.bind(this),this.createInstance()}createInstance(){if(!this.widget.container.get("$instance")){const e=this.widget.container.get("$types"),t=this.widget.container.get("$type");!t&&v(this).error("Unable to create widget. No type is specified.");const i=e[t];!i&&v(this).error(`Unable to create widget. Type '${t}' is not registered.`),this.widget.events.dispatch("widget:create-instance",{},{bubbles:!0});try{this.widget.container.register("$instance",new i(this.container))}catch(s){v(this).error("Unable to create widget type.",s)}this.widget.events.dispatch("widget:instance-created",{},{bubbles:!0})}}initialize(e){return this.initialized=this.initialized||(()=>{const t=this.container.get("$instance"),i=t.initialize||(()=>{});return this.initialized=Promise.resolve(i.call(t,e)).then(()=>z(this.container,"initialize",e)).then(()=>{})})()}activate(e){return(this.initialized||this.initialize()).then(()=>{this.activated=this.activated||(()=>z(this.container,"activate").then(()=>{const t=this.container.get("$instance");return this.activated=t.activate(e)}))()})}deactivate(){const e=this.container.get("$instance"),t=e.deactivate||(()=>{});return z(this.container,"deactivate").then(()=>Promise.resolve(t.call(e))).then(()=>{this.initialized=null,this.activated=null}).then(()=>{})}invoke(e,...t){return z(this.container,"invoke",{command:e,args:t}).then(()=>{const i=this.container.get("$instance");if(i[e])return i[e].apply(i,t);const s=i.invoke;if(s)return s.call(i,e,...t)})}};const M=(n,e)=>{if(!e)return!0;if(typeof e=="string"){const t=e.split(",");for(let i=0,s=t.length;i<s;i++){const r=t[i].trim();if(r===n||r==="*")return!0}}return e instanceof Array?e.indexOf(n)>-1:!1},Ze=(n,e)=>{if(typeof e=="function")return e(n);const t=typeof e=="string"?et(e):e;return!(!M(n.implementation.tenant||"",t.tenant||"")||!M(n.implementation.name,t.implementation||"")||!M(n.name,t.widget||"")||!M(n.container.get("$type"),t.type||""))},Je=(n,e)=>{if(typeof e=="function")return e(n);const t=typeof e=="string"?tt(e):e;return!(!M(n.tenant||"",t.tenant||"")||!M(n.name,t.implementation||""))},xe=n=>e=>Ze(e,n),Xe=n=>e=>Je(e,n),E=n=>n instanceof Array&&n.length===1?n[0]:n,et=n=>{const e={},t=n.split(":");return t.length===1?e.widget=E(t[0].split(",")):t.length===2?(e.implementation=E(t[0].split(",")),e.widget=E(t[1].split(","))):(e.tenant=E(t[0].split(",")),e.implementation=E(t[1].split(",")),e.widget=E(t[2].split(","))),e},tt=n=>{const e={},t=n.split(":");return t.length===1?e.implementation=E(t[0].split(",")):(e.tenant=E(t[0].split(",")),e.implementation=E(t[1].split(","))),e},W=R(),fe=(n,e,t)=>n.filter(i=>i.stage===e&&xe(i.selector)(t));function nt(n){const e=n.container.get("$environment");let t=W(e).configurationCache;t&&(t=t.filter(i=>i[0]!==n),W(e).configurationCache=t)}var Q=(n=>(n.Implementation="implementation",n.Widget="widget",n))(Q||{}),A=(n=>(n.Pre="pre",n.Post="post",n))(A||{});const Oe=(n,e,t)=>(Object.keys(e).forEach(i=>{const s=e[i];if(typeof s=="function"){const r=s();typeof r.defaultArgs<"u"&&t(r,...r.defaultArgs),n[i]=(...a)=>{const o=Object.assign({},r,{handlerResolver:r.handlerResolver.bind({})});return t(o,...a),n}}else n[i]=Oe({},s,t)}),n),it=(n,e)=>{switch(e){case"implementation":return n.implementation;case"widget":return n}},ve=(n,e,t,i)=>(i.forEach(s=>{Oe(n,s,(r,...a)=>{const o={selector:e,stage:r.stage,handler:c=>{const h=it(c,r.scope),d={container:h.container,events:h.events},g=r.handlerResolver,u=g(d);let p=W(t.environment).configurationCache;return p||(p=W(t.environment).configurationCache=[]),p.find(w=>w.indexOf(h)>-1&&w.indexOf(g)>-1)?Promise.resolve():(p.push([h,g]),Promise.resolve(u(...a)))}};t.instructions.push(o)})}),n);function st(n,e){function t(i){return ve({},i,n,e)}return ve(t,"*",n,e)}const rt=(n,e,t,i)=>{try{const s=new e(t,i);return{name:n,invoke:(r,a)=>{let o;return s[r]&&(o=s[r].call(s,a)),Promise.resolve(o)},getInstance:()=>s}}catch(s){if(s.message&&s.message.indexOf("is not a constructor")>=0)return{name:n,invoke:r=>{let a;return r==="initialize"&&(a=e(t,i)),Promise.resolve(a)},getInstance:()=>e};throw s}};function ye(n,e){return typeof n>"u"?e:n}let ot=class{constructor(e={}){this.part=e}createCommand(e,t,i){let s;typeof t=="function"?s={scope:Q.Widget,stage:A.Post,defaultArgs:void 0,handlerResolver:t}:s={scope:ye(t.scope,Q.Widget),stage:ye(t.stage,A.Post),defaultArgs:t.defaultArgs,handlerResolver:i};let r=this.part;const a=e.split(".");return a.forEach((o,c)=>{c===a.length-1?r[o]||(r[o]=()=>s):r=this.part[o]=this.part[o]||{}}),this}get(){return this.part}};const Ie=n=>{const e=new ot({});return n(e),e.get()},at=Ie(n=>{n.createCommand("types.register",{scope:Q.Implementation,stage:A.Pre},e=>(t,i)=>{e.container.get("$types")[t]=i}).createCommand("type",{stage:A.Pre},e=>t=>{e.container.register("$type",t)}).createCommand("settings",{stage:A.Pre,defaultArgs:[null]},e=>t=>{e.events.dispatch("settings:change",t,{bubbles:!0}),e.container.register("$settings",t)}).createCommand("plugin",{stage:A.Pre},e=>(t,i,s)=>{const{container:r}=e;let a=null,o=t,c=i;typeof t=="string"&&(a=t,o=i,c=s);const h=d=>{const{transformPluginSettings:g}=e.container.get("$environmentOptions"),u=g?g(c||{},a,e.container,o):i;try{const p=rt(a,o,r,u);r.get("$plugins").push(p),d&&p.invoke("initialize",null)}catch(p){v(e).warn("Error when initializing plugin",p)}};e.container.get("$instance")?h(!0):e.events.subscribeOnce("widget:instance-created",()=>h(!1))}).createCommand("container.register",e=>(t,i)=>{e.container.register(t,i)}).createCommand("container.registerAsync",e=>(t,i)=>{e.container.registerAsync(t,i)}).createCommand("container.registerFactory",e=>(t,i)=>{e.container.registerFactory(t,i)}).createCommand("container.touch",e=>(t,i)=>{e.container.touch(t,i)}).createCommand("csp",{},e=>t=>{e.container.register("csp",t)})}),ct=at;function ht(n,e,t=[]){const i=[ct].concat(t),s=st(e,i);n(s,e)}class lt{constructor(){this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(e,t,i,s){this.tasks.push({task:e,resolve:t,reject:i,done:s}),this.next()}next(){this.current=this.current.then(()=>{const e=this.tasks.shift();if(e){const t=Promise.resolve(e.task());return Promise.resolve(t).then(this.next).then(()=>t.then(i=>{e.done(),e.resolve(i)})).catch(i=>(e.done(),e.reject(i),this.next()))}return Promise.resolve()})}}const F=new WeakMap;function dt(n){return F.has(n)||F.set(n,new lt),e=>new Promise((t,i)=>{const s=F.get(n);s.add(e,t,i,()=>{s.tasks.length||F.delete(n)})})}const be=n=>typeof n<"u",L=(n,e)=>{n.events.dispatch("widget:state-change",{state:e},{bubbles:!0}),n.state=e,n.events.dispatch("widget:state-changed",{},{bubbles:!0})},y=R(),ut=n=>{const{container:e,events:t}=n;e.get("$controller")||(e.register("$controller",new Ye(e)),t.dispatch("widget:controller-created",{},{bubbles:!0}))};let gt=class{constructor(e,t,i){this.state="deactivated",this.name=e,this.implementation=t,this.container=t.container.createChild(this,e),this.events=t.events.createChild(this),y(this).subscriptions=[],i&&t.configure(s=>{const r=s(e);be(i.type)&&r.type(i.type),be(i.settings)&&r.settings(i.settings),i.plugins&&Object.keys(i.plugins).forEach(a=>{var o;const c=(o=i.plugins)==null?void 0:o[a];r.plugin(a,c)})}),this.load=this.load.bind(this),this.activate=this.activate.bind(this),this.invoke=this.invoke.bind(this),this.deactivate=this.deactivate.bind(this)}load(){return dt(this)(()=>{y(this).deactivatedPromise=null;const e=this.state==="deactivated";e&&(L(this,"activating"),this.container.register("$widget",this),this.container.register("$controller",null),this.container.register("$plugins",[]),this.container.register("$type",null),this.container.register("$instance",null)),L(this,"loading");const t=this.implementation.instructions,i=fe(t,A.Pre,this);return Promise.all(i.map(s=>s.handler(this))).then(()=>{ut(this);const s=fe(t,A.Post,this);return Promise.all(s.map(r=>r.handler(this))).then(()=>{e&&this.container.get("$controller").initialize()})}).then(()=>(L(this,"activated"),this))})}activate(e){y(this).subscriptions.push(this.implementation.events.subscribe("implementation:configured",()=>{["activated","activating","loading"].indexOf(this.state)>-1&&this.load()}));const t=y(this).activatedPromise;return t?(process.env.NODE_ENV!=="production"&&v(this).warn(`Widget '${this.name}' has already been activated. The passed arguments for this activation will be discarded.`,e),t):y(this).activatedPromise=this.load().then(()=>this.container.get("$controller").activate(e))}invoke(e,...t){const i=y(this).activatedPromise,s=(r,...a)=>i.then(this.load).then(()=>this.container.get("$controller").invoke(r,...a));return i?s(e,...t):(process.env.NODE_ENV!=="production"&&v(this).warn("You are invoking a command on a deactivated widget. The invocation will be queued until the widget is activated.",this),new Promise(r=>{const a=this.events.subscribe("widget:state-changed",()=>{this.state==="activated"&&(a(),r(s(e,...t)))})}))}deactivate(){return y(this).deactivatedPromise||(this.state==="deactivated"?Promise.resolve():(L(this,"deactivating"),y(this).deactivatedPromise=this.container.get("$controller").deactivate().then(()=>(y(this).activatedPromise=null,y(this).subscriptions.forEach(t=>t()),y(this).subscriptions=[],this.container.clear().then(()=>{this.events.clear(),nt(this),L(this,"deactivated")})))))}};const we=R();class pt{constructor(e,t,i=[]){this.instructions=[],this.widgets=new Map,this.name=e.name,this.tenant=e.tenant,this.environment=t,this.container=t.container.createChild(this,this.name),this.events=t.events.createChild(this),this.container.register("$types",{}),we(this).configurationApiExtensions=i}load(){const e=Array.from(this.widgets.values());return Promise.all(e.map(t=>t.load())).then(()=>e)}configure(e){return ht(e,this,we(this).configurationApiExtensions),this.events.dispatch("implementation:configured",{implementation:this},{bubbles:!0}),this}createWidget(e,t){const i=new gt(e,this,t);return this.widgets.set(i.name,i),i}}function mt(n,e,t){const i=new pt(n,e,t);return n.widgets&&Object.keys(n.widgets).forEach(s=>{var r;const a=(r=n.widgets)==null?void 0:r[s];i.createWidget(s,a)}),i}let ke=class Me{constructor(e,t){this.selectorFactory=t,typeof e=="function"?this.resolver=e:this.resolver=()=>e}append(e){const t=typeof e=="function"?e:()=>e;return new Me(()=>this.all().concat(t()),this.selectorFactory)}all(){return this.resolver().concat([])}query(e){return this.all().filter(this.selectorFactory(e))}find(e){const t=this.query(e);if(t.length)return t[0]}};const ce="#____version____#",X=R(),ft=n=>n.tenant?`${n.name}:${n.tenant}`:n.name,Se=class{constructor(e,t=[],i={}){this.widgets=new ke(()=>{let s=[];return this.implementations.all().forEach(r=>{s=s.concat(Array.from(r.widgets.values()))}),s},xe),this.implementations=new ke([],Xe),this.name=e,this.container=new ae(this,e),this.events=new Ke(this),this.container.register("$version",ce),this.container.register("$environment",this),this.container.register("$environmentOptions",i),X(this).configurationApiExtensions=t}createImplementation(e){const t=ft(e);let i=this.implementations.find(t);if(i)return process.env.NODE_ENV!=="production"&&v(i).warn(`Implementation "${t}" already exist on current environment.`),i;const s=X(this).configurationApiExtensions;return i=mt(e,this,s),this.implementations=this.implementations.append([i]),this.events.dispatch("implementation:created",{implementation:i}),i}patch(e={}){const{name:t,configurationApiExtensions:i}=e;typeof t<"u"&&t!==null&&(this.name=t),i&&i.forEach(s=>{X(this).configurationApiExtensions.push(s)})}static create(e={}){return new Se(e.name||"",e.configurationApiExtensions,e.options)}};let Re=Se;Re.version=ce;const V=(n,e,...t)=>typeof e=="string"?n(`[humany] ${e}`,...t):n(e,...t),T=class{constructor(){this.keys=[],this.log=(e,...t)=>this.lookup(e,()=>T.log(...t)),this.warn=(e,...t)=>this.lookup(e,()=>T.warn(...t)),this.error=(e,...t)=>this.lookup(e,()=>T.error(...t)),this.info=(e,...t)=>this.lookup(e,()=>T.info(...t))}lookup(e,t){this.keys.indexOf(e)===-1&&(this.keys.push(e),t())}};let q=T;q.log=(...n)=>V(console.log,...n);q.warn=(...n)=>V(console.warn,...n);q.error=(...n)=>V(console.error,...n);q.info=(...n)=>V(console.info,...n);const _e=n=>{let e={},t,i;if(typeof n!="object"||n===null)return n;e=Array.isArray(n)?[]:{};for(i in n)t=n[i],e[i]=typeof t=="object"&&t!==null?_e(t):t;return e},vt=_e;class yt{constructor(e,t){this.lockWarningTime=e,this.lockErrorTime=t,this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(e,t,i,s){this.tasks.push({task:e,resolve:t,reject:i,done:s}),this.next()}next(){this.current=this.current.then(()=>{const e=this.tasks.shift();if(e){let t;const i=setTimeout(()=>{process.env.NODE_ENV!=="production"&&q.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),s=Promise.resolve(e.task()).then(r=>(clearTimeout(i),clearTimeout(t),r));return Promise.resolve(s).then(this.next).then(()=>s.then(r=>{e.done(),e.resolve(r)})).catch(r=>(e.done(),e.reject(r),this.next()))}return Promise.resolve()})}}const U=new WeakMap;function bt(n,e=5e3,t=1e3){return U.has(n)||U.set(n,new yt(e,t)),i=>new Promise((s,r)=>{const a=U.get(n);a.add(i,s,r,()=>{a.tasks.length||U.delete(n)})})}const wt=(n={})=>(Object.keys(n).forEach(e=>{(n[e]===null||typeof n[e]>"u")&&delete n[e]}),n),kt=wt,B=(n,e)=>{let t=!0;return Object.keys(n).length!==Object.keys(e).length||Object.keys(n).some(i=>!Object.keys(e).some(s=>i===s))?!1:(Object.keys(n).forEach(i=>{if(t){const s=typeof n[i]>"u"?"":n[i],r=typeof e[i]>"u"?"":e[i];t=s.toString()===r.toString()}}),t)};var Ct=Object.defineProperty,Ce=Object.getOwnPropertySymbols,$t=Object.prototype.hasOwnProperty,Pt=Object.prototype.propertyIsEnumerable,$e=(n,e,t)=>e in n?Ct(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Pe=(n,e)=>{for(var t in e||(e={}))$t.call(e,t)&&$e(n,t,e[t]);if(Ce)for(var t of Ce(e))Pt.call(e,t)&&$e(n,t,e[t]);return n};Ie(n=>{n.createCommand("components",e=>t=>{e.events.subscribeOnce("components:platform-created",(i,{platform:s})=>{t.handlers&&t.handlers.forEach(([r,a])=>{s.addComponentHandler(r,a)})})})});const Et="#____version____#",Le=class extends Re{constructor(n,e=[]){super(n,e,{transformPluginSettings:(t,i,s)=>{const r=s.get("$settings"),a=r.plugins&&i?r.plugins[i]||{}:{};return Pe(Pe({},a),t)}})}createImplementation(n){const e=super.createImplementation(n);return e.bindings=n.bindings,e}navigate(n,e,t){this.widgets.query(n).forEach(i=>i.invoke("navigate",{route:e,params:t}))}static create(n={}){const e=[We].concat(n.configurationApiExtensions||[]);return new Le("humany",e)}static createFromGlobal(n,e={}){if(this.isRuntime(n))return n.patch(e),n;const t=[],i=n&&n._c;i&&i.forEach(r=>t.push(r));const s=this.create(e);return s.container.register("$runtimecfg",t),s}static isRuntime(n){return!!(n&&typeof n=="object"&&n.container&&typeof n.container.get=="function"&&n.container.get("$environment")===n&&n.container.owner===n)}};let At=Le;At.version=`${Et} (${ce})`;var H=(n=>(n.open="open",n.closed="closed",n.hidden="hidden",n))(H||{});const Ee=n=>Promise.resolve().then(()=>require("./index-373df3a5.js")).then(({ServiceClient:e,ServiceProxy:t})=>n.get("settings").then(i=>{const{name:s,events:r}=n.get("$widget"),{data:{projection:a="",site:o="current",forceHttps:c=!1}}=i,h=new t(a,{credentials:"same-origin"}),d=new e(h,{funnel:s.replace("_contact-method","").replace("_contact",""),site:Nt(o,c)},null,n);return r.subscribe("widget:settings-updated",(g,{data:u})=>{u&&u.projection!==a&&d.proxy.setBaseUrl(u.projection)}),d})),Nt=(n,e)=>()=>{const t=s=>{const r=document.createElement("a");return r.href=s,r};let i=window.location;return n==="referrer"&&document.referrer&&(i=t(document.referrer)),[e?"https:":"","//",i.host,i.pathname].join("")},O=n=>{if(n){const{Type:e,Content:t}=n;if(e&&t)return{type:e,content:t}}},ie=n=>n.map(e=>{const t={id:e.Id.toString(),title:e.Name,symbol:O(e.DefaultIcon),activeSymbol:e.ActiveIcon&&O(e.ActiveIcon),description:e.Description||e.Attributes&&e.Attributes.description||"",matches:e.GuidesCount};return e.Children&&e.Children.length&&(t.items=ie(e.Children)),t}),P=(n,e)=>n.filter(({Type:t})=>t===e).map(({Id:t,Title:i,Body:s})=>({id:t.toString(),title:i,body:s})),ee=n=>n.map(({Id:e,Title:t,DefaultIcon:i,ListNotices:s,Notices:r})=>({id:e.toString(),title:t,symbol:O(i),defaultHeaderOptions:{visible:!!s.length},notifications:(s||[]).concat(r||[]).map(({Id:a,Title:o,Body:c,Type:h,Modified:d})=>({id:a.toString(),title:o,body:c,modified:d,expandable:h==="listNotice"}))})),te=({Id:n,Title:e,DefaultIcon:t,Exits:[i],ExitType:s,ConfirmationText:r,Description:a},o)=>{const{Adapter:c}=i||{Adapter:{}},{ClientName:h="",Settings:d={},CustomClientName:g=""}=c,u={id:n.toString(),title:e,description:a,symbol:O(t),clientName:h==="custom.adapter"?g:h,expanded:!0,inline:!0,body:{}};if(h.indexOf("phone")>-1||h.indexOf("freetext")>-1){const{displayTextBeforeClick:p,textBeforeClick:w}=d;p==="true"&&(u.expanded=!1,u.title=w),h.indexOf("phone.text")>-1?u.body.phoneNumber=d.phoneNumber:u.body.freetext=d.freetext}return(h.indexOf("chat.popup")>-1||h.indexOf("link")>-1||h==="custom.adapter"&&s==="custom")&&(u.body=d,u.body.confirmationFallback=r),h.indexOf("ace")>-1&&(u.body=d),u},j=(n=[])=>n.map(({Id:e,Title:t,TotalMatches:i,Symbol:s,DefaultIcon:r,ActiveIcon:a})=>({id:e.toString(),title:t,matches:i,symbol:O(r||s),defaultIcon:O(r),activeIcon:O(a)})),ne=n=>n.map(({Id:e,Title:t,Tags:i,FirstPublishedDate:s,Modified:r})=>({id:e.toString(),title:t,tags:j(i),published:s,modified:r})),Te=(n,e)=>{switch(n){case b.MatchByCategory:case b.Match:{const t={guides:[],matches:0,topNotifications:[],middleNotifications:[],bottomNotifications:[],notificationLists:[],tags:[],byCategory:[]},{Matches:i,TotalMatches:s,Notices:r,NoticeLists:a,Tags:o,ByCategory:c}=e;return t.guides=ne(i),t.matches=s,t.byCategory=(c||[]).map(({Id:h,Matches:d,TotalMatches:g})=>({id:h,guides:ne(d),matches:g})),t.tags=j(o),t.notificationLists=ee(a||[]),t.topNotifications=P(r||[],"noticeRowTop"),t.middleNotifications=P(r||[],"noticeRowMiddle"),t.bottomNotifications=P(r||[],"footerNotice"),t}case b.Categories:{const{Children:t,GuidesCountTotal:i}=e;return{categories:ie(t||[]),matches:i}}case b.Guide:{const{Id:t,Title:i,Body:s,Related:r,Options:a,ConnectionId:o,ContactMethods:c,EnableFeedback:h,HandoverExists:d,FirstPublishedDate:g,Modified:u,ModifiedByDisplayName:p,FirstPublishedByDisplayName:w,Categories:k,Tags:l,SeoMetaDescription:f,SeoAllowIndex:K,Perspectives:_,PerspectiveKey:he,Translations:le}=e,Ge=he||Object.values(_).find(N=>N===o)||_.Default||null,de={guide:{id:t.toString(),title:i,body:s,modified:u,published:g,modifiedBy:p,publishedBy:w,connection:o,categories:k,hasHandover:d,allowFeedback:h,seoMetaDescription:f,seoAllowIndex:K,perspectives:_,perspective:Ge,translations:Object.keys(le||{}).reduce((N,G)=>(N[G]=le[G].toString(),N),{})},related:ne(r||[]),dialog:[],contactMethods:(c||[]).map(N=>te(N)),tags:j(l)};return(a||[]).forEach(({CanAccess:N,Description:G,ConnectionId:ze,Properties:C})=>{if(!N)return;const I={id:t.toString(),title:G,connection:ze,connectionKey:C.ConnectionKey,type:"default",parent:{id:t.toString(),title:i,tags:j(l)}};if(C.Type==="Guide"||C.Type==="Link")switch(C.Id&&(I.id=C.Id.toString()),C.Uri&&(I.href=C.Uri),C.Target&&(I.target=C.Target),C.Type){case"Guide":I.type="guide";break;case"Link":I.type="link";break}de.dialog.push(I)}),de}case b.Contacts:{const{Children:t,Matches:i,Notices:s,NoticeLists:r}=e;return{contactMethods:(i||[]).map(o=>te(o)),categories:ie(t||[]),topNotifications:P(s||[],"noticeRowTop"),middleNotifications:P(s||[],"noticeRowMiddle"),bottomNotifications:P(s||[],"footerNotice"),notificationLists:ee(r||[])}}case b.ContactMethod:{const{ContactMethod:t}=e;return te(t||{})}case b.Tags:case b.TagsOnGuides:return j(e||[]);case b.Notifications:{const{Notices:t,NoticeLists:i}=e;return{topNotifications:P(t||[],"noticeRowTop"),middleNotifications:P(t||[],"noticeRowMiddle"),bottomNotifications:P(t||[],"footerNotice"),notificationLists:ee(i||[])}}default:return{}}};var je=(n=>(n.Guide="guide",n.Guides="guides",n.GuidesByCategory="guides-by-category",n.RowNotifications="row-notices",n.NotificationLists="notification-lists",n.GuideCategories="guide-categories",n.ContactMethodCategories="contact-method-categories",n.ContactMethod="contact-method",n.ContactMethods="contact-methods",n.Tags="tags",n.TagsOnGuides="tagsonguides",n))(je||{}),b=(n=>(n.Match="match",n.Categories="categories",n.Guide="guide",n.Contacts="contacts",n.ContactMethod="contact-method",n.MatchByCategory="match-by-category",n.Tags="tags",n.TagsOnGuides="tagsonguides",n.Notifications="notifications",n))(b||{}),De=(n=>(n.Positive="Positive",n.Negative="Negative",n))(De||{}),qe=(n=>(n.POPULARITY_DESCENDING="popularity-descending",n.ALPHABETIC_ASCENDING="alphabetic-ascending",n.ALPHABETIC_DESCENDING="alphabetic-descending",n.MODIFIED_ASCENDING="modified-ascending",n.MODIFIED_DESCENDING="modified-descending",n.PUBLISHED_ASCENDING="published-ascending",n.PUBLISHED_DESCENDING="published-descending",n))(qe||{});const se=n=>{switch(n){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"}},xt=async n=>{const{invoke:e}=n.get("$widget");return await e("renderState")===H.hidden};class S{constructor(e,t){this.container=e,this.matchingClient=t,this.queries=new Map,this.getUnresolvedQueries=()=>{let i=0;return this.queries.forEach((s,r)=>{s.some(o=>!o.resolved)&&(i=1)}),i},this.events=e.get("$widget").events,this.events.subscribe("widget:settings-updated",()=>this.queries=new Map),this.events.subscribe("widget:render-state-changed",(i,{next:s,previous:r})=>{r===H.hidden&&s===H.open&&this.fetchAllUnresolvedQueries()})}static getInstance(e,t="dataClient"){return bt(this)(()=>e.getAsync(t).then(async i=>{let s=await e.getAsync("matchingClient");s||(s=await Ee(e),e.registerAsync("matchingClient",()=>s));let r=i;return r||(r=new S(e,s),e.registerAsync(t,()=>r)),r}))}fetch(e,t,i){return new Promise((s,r)=>{t.take,kt(t);const a=se(e);let o=this.queries.get(a)||[],c=o.find(h=>B(h.params,t))||null;if(c&&(i!=null&&i.noCache)){const h=o.findIndex(d=>B(d.params,t));o=[...o.slice(0,h),...o.slice(h+1)],c=null}if(c){const h=o.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?r({error:c.error}):s(c.data)):c.resolvers.push({resolve:s,reject:r}),o.splice(h,1),o.push(c),this.queries.set(a,o),!c.loading&&!c.resolved)return this.runQuery(a,t)}else return o.push({params:t,resolved:!1,loading:!0,data:{},resolvers:[{resolve:s,reject:r}]}),this.queries.set(a,o),this.runQuery(a,t)}).then(s=>vt(s))}read(e,t){const{select:i}=t,s=se(e);return(this.queries.get(s)||[]).reduce((o,c)=>{if(typeof i=="function"){const h=i(c.data);h&&o.push(h)}else o.push(c.data);return o},[])}feedback(e,t,i){return this.matchingClient.giveFeedback(e,t,i)}setLoadingStatus(e,t,i){const s=this.queries.get(e)||[],r=s.find(a=>B(a.params,t));r&&(r.loading=i),this.queries.set(e,s)}async runQuery(e,t){const{searchPhrase:i="",categories:s="0",contactMethodCategoryId:r="0",contactMethodId:a="0",tagId:o=void 0,take:c=5,connection:h="",guideId:d,expandCategories:g="descendants",currentCategory:u,sorting:p="popularity-descending",guideIds:w=[]}=t,k=i.toString().trim();if(await xt(this.container))return Promise.resolve();switch(e){case"match":{const l=f=>{const[K,_]=f.split("-");return{type:new Map([["popularity","popularity"],["alphabetic","title"],["modified","lastModified"],["published","firstPublished"]]).get(K),direction:_}};return w.length?this.matchingClient.customRequest("guides","POST",{configuration:{ids:w,take:+c}}).then(f=>f&&this.handleResponse(f,e,t)):this.matchingClient.match(k,{categories:s==="0"?[]:Array.isArray(s)?s:[+s],take:+c,tags:o,sorting:l(p),ids:w}).then(f=>f&&this.handleResponse(f,e,t))}case"match-by-category":return this.matchingClient.match(k,{groupByCategory:!0,categories:s==="0"?[]:Array.isArray(s)?s:[+s],take:+c,tags:o}).then(l=>l&&this.handleResponse(l,e,t));case"guide":return this.matchingClient.getGuide(d,{connectionId:h}).then(l=>{l&&this.handleResponse(l,e,t)}).catch(l=>{const f={message:"Something went wrong.",status:l.status||400};f.status===404&&(f.message="The guide could not be found."),this.handleResponse({},e,t,f)});case"categories":return this.matchingClient.getCategories({phrase:k,expand:g,tags:o}).then(l=>l&&this.handleResponse(l,e,t));case"contacts":return d?this.matchingClient.contactMethods(+d,{phrase:k}).then(l=>l&&this.handleResponse(l,e,t)):this.matchingClient.contacts(+r,{phrase:k}).then(l=>l&&this.handleResponse(l,e,t));case"contact-method":return this.matchingClient.getContactMethod(+a,{guideId:d,currentCategory:u}).then(l=>l&&this.handleResponse(l,e,t));case"tags":return this.matchingClient.customRequest("tags","GET",{configuration:{take:999999,phrase:k,categories:s==="0"?[]:Array.isArray(s)?s:[+s]}}).then(l=>l&&this.handleResponse(l,e,t));case"tagsonguides":return this.matchingClient.customRequest("tagsonguides","GET",{configuration:{take:999999,phrase:k,categories:s==="0"?[]:Array.isArray(s)?s:[+s],tags:o}}).then(l=>l&&this.handleResponse(l,e,t));case"notifications":return this.matchingClient.customRequest("notices","GET",{configuration:{phrase:k,categories:s==="0"?[]:Array.isArray(s)?s:[+s]}}).then(l=>l&&this.handleResponse(l,e,t))}}handleResponse(e={},t,i,s){const r=this.queries.get(t)||[],a=r.find(o=>B(o.params,i));if(a){const o=s||Te(t,e);this.track(o,t,s),a.resolvers.forEach(h=>{s?h.reject({error:o}):h.resolve(o)});const c=r.indexOf(a);c>-1&&r.splice(c,1),r.push({...a,error:s,resolvers:[],data:o,resolved:!0}),this.setLoadingStatus(t,i,!1),this.queries.set(t,r),s||this.events.dispatch("data-client:fetched",{type:t,params:i,response:o,unresolvedQueries:this.getUnresolvedQueries()})}}fetchAllUnresolvedQueries(){for(const[e,t]of this.queries)t.filter(i=>!i.resolved).forEach(i=>{this.runQuery(e,i.params)})}track(e={},t,i){const s=this.container.get("$widget");s&&!i?s.events.dispatch("tracking:service-client-response",{type:t,data:e}):s&&s.events.dispatch("tracking:service-client-error",{type:t,error:i})}static create(e){return e.getAsync("matchingClient").then(async t=>{if(t)return new S(e,t);const i=await Ee(e);return e.registerAsync("matchingClient",()=>i),new S(e,i)})}getClient(){return this.matchingClient}}const Ot=async n=>{n.registerAsync("dataClient",()=>S.create(n))};exports.DataClient=S;exports.DataType=je;exports.FeedbackType=De;exports.KnowledgeDataClientPlugin=Ot;exports.ServiceClientQueryType=b;exports.SortingType=qe;exports.determineServiceClientQueryType=se;exports.formatLegacyData=Te;
|