@telia-ace/knowledge-widget-core 1.1.1-rc.2 → 1.1.1-rc.4
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 -3
- package/index.mjs +19 -2072
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class Ft{constructor(t){const{events:e}=t.get("$widget");this.events=e.createChild(this)}action(t,e,n){this.events.dispatch("data:action",{action:e,value:n,target:t},{bubbles:!0})}subscribe(t,e){return this.events.subscribe("data:action",(n,{action:i,value:r,target:o})=>t===o&&e(t,i,r))}}const B=(s,t,e,...n)=>{const i=`[${s.get("$environment").name||"webprovisions"}] ${e}`;switch(t){case"info":console.info(i,...n);break;case"warning":console.warn(i,...n);break;case"error":console.error(i,...n);break}},Ct=s=>{const t=s.container||s;return{info:(e,...n)=>B(t,"info",e,...n),warn:(e,...n)=>B(t,"warning",e,...n),error:(e,...n)=>B(t,"error",e,...n)}},ut=(s,t)=>{if(!t)return!0;if(typeof t=="string"){const e=t.split(",");for(let n=0,i=e.length;n<i;n++){const r=e[n].trim();if(r===s||r==="*")return!0}}return t instanceof Array?t.indexOf(s)>-1:!1},Bt=(s,t)=>{if(typeof t=="function")return t(s);const e=typeof t=="string"?Ut(t):t;return!(!ut(s.tenant||"",e.tenant||"")||!ut(s.name,e.implementation||""))},Qt=s=>t=>Bt(t,s),Q=s=>s instanceof Array&&s.length===1?s[0]:s,Ut=s=>{const t={},e=s.split(":");return e.length===1?t.implementation=Q(e[0].split(",")):(t.tenant=Q(e[0].split(",")),t.implementation=Q(e[1].split(","))),t};var D=(s=>(s.Implementation="implementation",s.Widget="widget",s))(D||{}),k=(s=>(s.Pre="pre",s.Post="post",s))(k||{});const Yt=(s,t,e,n)=>{try{const i=new t(e,n);return{name:s,invoke:(r,o)=>{let c;return i[r]&&(c=i[r].call(i,o)),Promise.resolve(c)},getInstance:()=>i}}catch(i){if(i.message&&i.message.indexOf("is not a constructor")>=0)return{name:s,invoke:r=>{let o;return r==="initialize"&&(o=t(e,n)),Promise.resolve(o)},getInstance:()=>t};throw i}};function lt(s,t){return typeof s>"u"?t:s}let Gt=class{constructor(t={}){this.part=t}createCommand(t,e,n){let i;typeof e=="function"?i={scope:D.Widget,stage:k.Post,defaultArgs:void 0,handlerResolver:e}:i={scope:lt(e.scope,D.Widget),stage:lt(e.stage,k.Post),defaultArgs:e.defaultArgs,handlerResolver:n};let r=this.part;const o=t.split(".");return o.forEach((c,l)=>{l===o.length-1?r[c]||(r[c]=()=>i):r=this.part[c]=this.part[c]||{}}),this}get(){return this.part}};const $t=s=>{const t=new Gt({});return s(t),t.get()};$t(s=>{s.createCommand("types.register",{scope:D.Implementation,stage:k.Pre},t=>(e,n)=>{t.container.get("$types")[e]=n}).createCommand("type",{stage:k.Pre},t=>e=>{t.container.register("$type",e)}).createCommand("settings",{stage:k.Pre,defaultArgs:[null]},t=>e=>{t.events.dispatch("settings:change",e,{bubbles:!0}),t.container.register("$settings",e)}).createCommand("plugin",{stage:k.Pre},t=>(e,n,i)=>{const{container:r}=t;let o=null,c=e,l=n;typeof e=="string"&&(o=e,c=n,l=i);const h=a=>{const{transformPluginSettings:u}=t.container.get("$environmentOptions"),p=u?u(l||{},o,t.container,c):n;try{const d=Yt(o,c,r,p);r.get("$plugins").push(d),a&&d.invoke("initialize",null)}catch(d){Ct(t).warn("Error when initializing plugin",d)}};t.container.get("$instance")?h(!0):t.events.subscribeOnce("widget:instance-created",()=>h(!1))}).createCommand("container.register",t=>(e,n)=>{t.container.register(e,n)}).createCommand("container.registerAsync",t=>(e,n)=>{t.container.registerAsync(e,n)}).createCommand("container.registerFactory",t=>(e,n)=>{t.container.registerFactory(e,n)}).createCommand("container.touch",t=>(e,n)=>{t.container.touch(e,n)}).createCommand("csp",{},t=>e=>{t.container.register("csp",e)})});function Kt(s,t,e){return Array.from(s.querySelectorAll(`div[id^="${t}_"], div[id^="${t}:"]`)).map(n=>{if(n.id.substr(0,7)===`${t}_`)return{widgetName:n.id.substr(7),element:n};const{3:i}=n.id.split(":");return{widgetName:i,element:n}})}const Jt=s=>{const t=s.map(e=>e.replace(/\./g,"\\.")).join("|");return new RegExp("^((http[s]?:)?//)?("+t+")/([^\\s]+)")},Xt=s=>s.href;function Zt(s,t){const e=Jt(t),n=i=>{const r=e.exec(Xt(i));return r?{element:i,widget:r[4]}:null};return Array.from(s.querySelectorAll("a")).map(i=>n(i)).filter(i=>!!i).map(i=>({element:i.element,widgetName:i.widget}))}function Et(s){return s.filter((t,e,n)=>n.indexOf(t)===e)}let te=class{constructor(t){this.container=t.container,this.events=t.events}watch(t){const e=this.container.get("triggerElements")||[],n=Et(e.concat(t));this.container.register("triggerElements",n),this.events.dispatch("bootstrap:trigger-elements-updated",{triggerElements:n},{bubbles:!0})}};function kt(s,...t){return s.implementation.events.subscribe("widget:create-instance",(e,n)=>{if(e.target===s){let i=s.container.get("bootstrapping.monitor");i||(i=new te(s),s.container.register("bootstrapping.monitor",i)),i.watch(t)}}),s.load()}function Pt(s,t=document){var e;const n=s.bindings,i=[].concat(Zt(t,n),Kt(t,((e=s.environment)==null?void 0:e.name)||"")),r=Et(i.map(({widgetName:o})=>o)).reduce((o,c)=>{const l=s.widgets.get(c);if(!l)return process.env.NODE_ENV!=="production"&&Ct(s).warn(`A trigger element for "${c}" was found but no widget with that name is available on the implementation ("${s.name}"). Make sure this is not a mistake.`),o;const h=i.filter(a=>a.widgetName===c).map(a=>a.element);return o.push(kt(l,...h)),o},[]);return Promise.all(r)}function ee(){return new Promise(s=>{document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>s()):s()})}const se=(s,t)=>{const e=s;e.scan=i=>Pt(e,i),e.bindings=t,e.attach=(i,...r)=>kt(i,...r);const{environment:n}=e;return typeof n.configure>"u"&&(n.configure=(i,r)=>{let o,c;r?(o=i,c=r):(o="*",c=i),n.implementations.query(o).forEach(l=>l.configure(c)),n.events.subscribe("implementation:created",(l,h)=>{const{implementation:a}=h;Qt(o)(a)&&a.configure(c)})}),e};function ne(s,t,e=()=>[],n){const i={ready:!1};s.container.register("bootstrapping",i);const r=se(s,t);return ee().then(()=>{s.configure((...o)=>{e().forEach(c=>c(...o))})}).then(()=>Pt(r,n())).then(()=>(i.ready=!0,s.events.dispatch("bootstrap:ready",{}),r))}function ie(s){const t={};return[].filter.call(s.attributes,e=>/^data-/.test(e.name)).map(e=>e.name).forEach(e=>t[e.substr(5)]=s.getAttribute(e)),t}const pt=(s,t,e)=>{const n=ie(s);e({sourceDOMElement:s,eventType:t,data:n})};function dt(s,t,e){s.forEach(n=>{n.dataset.attached!=="true"&&(t==="load"?pt(n,t,e):n.addEventListener(t,i=>{i.preventDefault(),pt(n,t,e)}),n.dataset.monitored="true")})}function re(s,t,e){const n=s.container.get("bootstrapping.monitor");n&&n.events.subscribe("bootstrap:trigger-elements-updated",(r,o)=>{dt(o.triggerElements,t,e)});const i=s.container.get("triggerElements");i&&dt(i,t,e)}const oe=$t(s=>{s.createCommand("ready",{scope:D.Implementation,stage:k.Pre},t=>e=>{const{container:n}=t,i=n.owner;n.get("bootstrapping").ready?e(i):i.events.subscribeOnce("bootstrap:ready",()=>{e(i)})})}),U=new WeakMap;function A(){return s=>(U.has(s)||U.set(s,{}),U.get(s))}const Y=(s,t,e,...n)=>{const i=`[${s.get("$environment").name||"webprovisions"}] ${e}`;switch(t){case"info":console.info(i,...n);break;case"warning":console.warn(i,...n);break;case"error":console.error(i,...n);break}},g=s=>{const t=s.container||s;return{info:(e,...n)=>Y(t,"info",e,...n),warn:(e,...n)=>Y(t,"warning",e,...n),error:(e,...n)=>Y(t,"error",e,...n)}},m=A(),X=(()=>{let s=0;return()=>++s})(),Z=(s,t,e)=>{const n=m(s).touchQueue.get(t);n&&n.forEach(i=>{i(e,s)})};class ce{constructor(t,e,n,i){this.key=t,this.factory=e,this.parent=n,this.container=i,this.id=X(),this.resolved=!1,this.constructed=!1,this.async=!0}resolve(){if(!this.constructed){const t=this.factory(this.parent,this.container);return this.constructed=!0,this.value=Promise.resolve(t).then(e=>(this.resolved=!0,Z(this.container,this.key,e),e))}return this.value}}class ae{constructor(t,e,n,i){this.key=t,this.value=e,this.parent=n,this.container=i,this.id=X(),this.async=!1,this.resolved=!1,this.constructed=!0,this.resolve=()=>(this.resolved=!0,Z(this.container,this.key,this.value),this.value)}}class he{constructor(t,e,n,i){this.key=t,this.value=e,this.parent=n,this.container=i,this.id=X(),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 Z(this.container,this.key,this.value),r}}}class tt{constructor(t,e,n){this.owner=t,this.name=e,this.parent=n,m(this).resolvers=new Map,m(this).touchQueue=new Map,m(this).children=[]}delete(t){const e=m(this).resolvers,n=Array.from(e.values()).find(i=>i.id===t);return n?(m(this).touchQueue.delete(n.key),Promise.resolve(e.delete(n.key))):this.parent?this.parent.delete(t):Promise.resolve(!1)}clear(){const t=m(this).resolvers,e=Array.from(t.values());return Promise.all(e.map(n=>{if(n.constructed)return Promise.resolve(n.resolve()).then(i=>{if(i!==null&&typeof i=="object"&&typeof i.dispose=="function")return i.dispose.call(i,this,n)})})).then(()=>{e.forEach(n=>this.delete(n.id)),m(this).children.forEach(n=>n.clear())})}detach(){if(this.parent){const t=m(this.parent).children,e=t.indexOf(this);e>-1&&(t.splice(e,1),delete this.parent)}}touch(t,e){const n=m(this).resolvers.get(t);if(n&&n.constructed)Promise.resolve(n.resolve()).then(i=>{e(i,this)});else{const i=m(this).touchQueue;let r=i.get(t);r||(r=[],i.set(t,r)),r.push(e)}return this.parent&&!n?this.parent.touch(t,e):Promise.resolve()}registerAsync(t,e){const n=m(this).resolvers.get(t);n&&!n.async&&process.env.NODE_ENV!=="production"&&g(this).warn(`Mismatching resolver type. You are registering an async resolver with a key ('${t}') previously used by a non-async resolver.`);const i=new ce(t,e,n,this);return m(this).resolvers.set(t,i),i.id}registerFactory(t,e){const n=m(this).resolvers.get(t);n&&n.async&&process.env.NODE_ENV!=="production"&&g(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${t}') previously used by an async resolver.`);const i=new he(t,e,n,this);return m(this).resolvers.set(t,i),i.id}register(t,e){const n=m(this).resolvers.get(t);n&&n.async&&process.env.NODE_ENV!=="production"&&g(this).warn(`Mismatching resolver type. You are registering a non-async resolver with a key ('${t}') previously used by an async resolver.`);const i=new ae(t,e,n,this);return m(this).resolvers.set(t,i),i.id}get(t){const e=m(this).resolvers.get(t);if(e)return e.async&&process.env.NODE_ENV!=="production"&&g(this).warn(`You are retrieving an async value (with key '${t}') by the non-async function 'container.get(key)'. This will not be supported in future versions. Use 'container.getAsync(key) instead.'`),e.resolve();if(this.parent)return this.parent.get(t)}getAsync(t){const e=m(this).resolvers.get(t);if(e){if(!e.async)throw process.env.NODE_ENV!=="production"&&g(this).warn(`You are retrieving a non-async value (with key '${t}') by the async function 'container.getAsync(key)'.Use 'container.get(key) instead.'`),"Mismatching resolver type";return e.resolve()}return this.parent?this.parent.getAsync(t):Promise.resolve(void 0)}getMany(...t){const e={};return t.forEach(n=>e[n]=this.get(n)),e}getManyAsync(...t){const e={};return Promise.all(t.map(n=>this.getAsync(n).then(i=>e[n]=i))).then(()=>e)}createChild(t,e){const n=new tt(t,e,this);return m(this).children.push(n),n}}class mt{constructor(t,e,n=!1,i=!1){this.type=t,this.target=e,this.cancelable=!!n,this.bubbles=!!i,this.defaultPrevented=!1}preventDefault(){this.cancelable&&(this.defaultPrevented=!0)}}const b=A(),gt=(s,t)=>[].concat(b(s).listenerLookup.get(t.toLowerCase())||[],b(s).listenerLookup.get("*")||[]),ft=(s,t,e,n)=>{let i,r;return t instanceof mt?(i=t,r=t.type):(i=new mt(t,s.target,!!e.cancelable,!!e.bubbles),r=t),{event:i,type:r,async:n}};class et{constructor(t,e){this.target=t,this.parent=e,b(this).listenerLookup=new Map,b(this).children=[]}clear(){b(this).listenerLookup.clear(),b(this).children.forEach(t=>t.clear())}detach(){if(this.parent){const t=b(this.parent).children,e=t.indexOf(this);e>-1&&t.splice(e,1)}}subscribe(t,e,n){const i=b(this).listenerLookup,r=t.toLowerCase();return i.has(r)||i.set(r,[]),i.get(r).push(e),()=>this.unsubscribe(t,e)}subscribeOnce(t,e){const n=this.subscribe(t,(i,r)=>(n(),e(i,r)))}unsubscribe(t,e){const n=b(this).listenerLookup.get(t.toLowerCase());if(n){const i=n.indexOf(e);i>-1&&n.splice(i,1)}}dispatchAsync(t,e,n={}){const{event:i,type:r}=ft(this,t,n,!0),o=gt(this,r);let c=0;const l=o.length;let h=Promise.resolve();for(c=0;c<l;c++)(a=>{h=h.then(u=>u?Promise.resolve(!0):Promise.resolve(a(i,e)).then(()=>i.defaultPrevented))})(o[c]);return h.then(a=>!a&&i.bubbles&&this.parent?this.parent.dispatchAsync(i,e):a)}dispatch(t,e,n={}){const{event:i,type:r}=ft(this,t,n,!1),o=gt(this,r);let c=0;const l=o.length;let h=!1;for(c=0;c<l;c++)if(o[c](i,e),i.defaultPrevented){h=!0;break}return!h&&i.bubbles&&this.parent&&(h=this.parent.dispatch(i,e)),h}createChild(t){const e=new et(t,this);return b(this).children.push(e),e}}const I=(s,t,e)=>{const n=s.get("$plugins").map(i=>{try{return i.invoke(t,e)}catch(r){g(s).error("An error occured when invoking a plugin.",i,r)}});return Promise.all(n)};class ue{constructor(t){this.widget=t.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 t=this.widget.container.get("$types"),e=this.widget.container.get("$type");!e&&g(this).error("Unable to create widget. No type is specified.");const n=t[e];!n&&g(this).error(`Unable to create widget. Type '${e}' is not registered.`),this.widget.events.dispatch("widget:create-instance",{},{bubbles:!0});try{this.widget.container.register("$instance",new n(this.container))}catch(i){g(this).error("Unable to create widget type.",i)}this.widget.events.dispatch("widget:instance-created",{},{bubbles:!0})}}initialize(t){return this.initialized=this.initialized||(()=>{const e=this.container.get("$instance"),n=e.initialize||(()=>{});return this.initialized=Promise.resolve(n.call(e,t)).then(()=>I(this.container,"initialize",t)).then(()=>{})})()}activate(t){return(this.initialized||this.initialize()).then(()=>{this.activated=this.activated||(()=>I(this.container,"activate").then(()=>{const e=this.container.get("$instance");return this.activated=e.activate(t)}))()})}deactivate(){const t=this.container.get("$instance"),e=t.deactivate||(()=>{});return I(this.container,"deactivate").then(()=>Promise.resolve(e.call(t))).then(()=>{this.initialized=null,this.activated=null}).then(()=>{})}invoke(t,...e){return I(this.container,"invoke",{command:t,args:e}).then(()=>{const n=this.container.get("$instance");if(n[t])return n[t].apply(n,e);const i=n.invoke;if(i)return i.call(n,t,...e)})}}const O=(s,t)=>{if(!t)return!0;if(typeof t=="string"){const e=t.split(",");for(let n=0,i=e.length;n<i;n++){const r=e[n].trim();if(r===s||r==="*")return!0}}return t instanceof Array?t.indexOf(s)>-1:!1},le=(s,t)=>{if(typeof t=="function")return t(s);const e=typeof t=="string"?de(t):t;return!(!O(s.implementation.tenant||"",e.tenant||"")||!O(s.implementation.name,e.implementation||"")||!O(s.name,e.widget||"")||!O(s.container.get("$type"),e.type||""))},pe=(s,t)=>{if(typeof t=="function")return t(s);const e=typeof t=="string"?me(t):t;return!(!O(s.tenant||"",e.tenant||"")||!O(s.name,e.implementation||""))},Ot=s=>t=>le(t,s),At=s=>t=>pe(t,s),x=s=>s instanceof Array&&s.length===1?s[0]:s,de=s=>{const t={},e=s.split(":");return e.length===1?t.widget=x(e[0].split(",")):e.length===2?(t.implementation=x(e[0].split(",")),t.widget=x(e[1].split(","))):(t.tenant=x(e[0].split(",")),t.implementation=x(e[1].split(",")),t.widget=x(e[2].split(","))),t},me=s=>{const t={},e=s.split(":");return e.length===1?t.implementation=x(e[0].split(",")):(t.tenant=x(e[0].split(",")),t.implementation=x(e[1].split(","))),t},S=A(),vt=(s,t,e)=>s.filter(n=>n.stage===t&&Ot(n.selector)(e));function ge(s){const t=s.container.get("$environment");let e=S(t).configurationCache;e&&(e=e.filter(n=>n[0]!==s),S(t).configurationCache=e)}var z=(s=>(s.Implementation="implementation",s.Widget="widget",s))(z||{}),C=(s=>(s.Pre="pre",s.Post="post",s))(C||{});const Nt=(s,t,e)=>(Object.keys(t).forEach(n=>{const i=t[n];if(typeof i=="function"){const r=i();typeof r.defaultArgs<"u"&&e(r,...r.defaultArgs),s[n]=(...o)=>{const c=Object.assign({},r,{handlerResolver:r.handlerResolver.bind({})});return e(c,...o),s}}else s[n]=Nt({},i,e)}),s),fe=(s,t)=>{switch(t){case"implementation":return s.implementation;case"widget":return s}},bt=(s,t,e,n)=>(n.forEach(i=>{Nt(s,i,(r,...o)=>{const c={selector:t,stage:r.stage,handler:l=>{const h=fe(l,r.scope),a={container:h.container,events:h.events},u=r.handlerResolver,p=u(a);let d=S(e.environment).configurationCache;return d||(d=S(e.environment).configurationCache=[]),d.find($=>$.indexOf(h)>-1&&$.indexOf(u)>-1)?Promise.resolve():(d.push([h,u]),Promise.resolve(p(...o)))}};e.instructions.push(c)})}),s);function ve(s,t){function e(n){return bt({},n,s,t)}return bt(e,"*",s,t)}class be{constructor(t,e){this.container=t,this.settings=e,this.widget=t.get("$widget"),this.events=this.widget.events}}const ye=(s,t,e,n)=>{try{const i=new t(e,n);return{name:s,invoke:(r,o)=>{let c;return i[r]&&(c=i[r].call(i,o)),Promise.resolve(c)},getInstance:()=>i}}catch(i){if(i.message&&i.message.indexOf("is not a constructor")>=0)return{name:s,invoke:r=>{let o;return r==="initialize"&&(o=t(e,n)),Promise.resolve(o)},getInstance:()=>t};throw i}};function yt(s,t){return typeof s>"u"?t:s}class we{constructor(t={}){this.part=t}createCommand(t,e,n){let i;typeof e=="function"?i={scope:z.Widget,stage:C.Post,defaultArgs:void 0,handlerResolver:e}:i={scope:yt(e.scope,z.Widget),stage:yt(e.stage,C.Post),defaultArgs:e.defaultArgs,handlerResolver:n};let r=this.part;const o=t.split(".");return o.forEach((c,l)=>{l===o.length-1?r[c]||(r[c]=()=>i):r=this.part[c]=this.part[c]||{}}),this}get(){return this.part}}const Rt=s=>{const t=new we({});return s(t),t.get()},xe=Rt(s=>{s.createCommand("types.register",{scope:z.Implementation,stage:C.Pre},t=>(e,n)=>{t.container.get("$types")[e]=n}).createCommand("type",{stage:C.Pre},t=>e=>{t.container.register("$type",e)}).createCommand("settings",{stage:C.Pre,defaultArgs:[null]},t=>e=>{t.events.dispatch("settings:change",e,{bubbles:!0}),t.container.register("$settings",e)}).createCommand("plugin",{stage:C.Pre},t=>(e,n,i)=>{const{container:r}=t;let o=null,c=e,l=n;typeof e=="string"&&(o=e,c=n,l=i);const h=a=>{const{transformPluginSettings:u}=t.container.get("$environmentOptions"),p=u?u(l||{},o,t.container,c):n;try{const d=ye(o,c,r,p);r.get("$plugins").push(d),a&&d.invoke("initialize",null)}catch(d){g(t).warn("Error when initializing plugin",d)}};t.container.get("$instance")?h(!0):t.events.subscribeOnce("widget:instance-created",()=>h(!1))}).createCommand("container.register",t=>(e,n)=>{t.container.register(e,n)}).createCommand("container.registerAsync",t=>(e,n)=>{t.container.registerAsync(e,n)}).createCommand("container.registerFactory",t=>(e,n)=>{t.container.registerFactory(e,n)}).createCommand("container.touch",t=>(e,n)=>{t.container.touch(e,n)}).createCommand("csp",{},t=>e=>{t.container.register("csp",e)})}),Ce=xe;function $e(s,t,e=[]){const n=[Ce].concat(e),i=ve(t,n);s(i,t)}class Ee{constructor(){this.tasks=[],this.current=Promise.resolve(),this.next=this.next.bind(this)}add(t,e,n,i){this.tasks.push({task:t,resolve:e,reject:n,done:i}),this.next()}next(){this.current=this.current.then(()=>{const t=this.tasks.shift();if(t){const e=Promise.resolve(t.task());return Promise.resolve(e).then(this.next).then(()=>e.then(n=>{t.done(),t.resolve(n)})).catch(n=>(t.done(),t.reject(n),this.next()))}return Promise.resolve()})}}const L=new WeakMap;function ke(s){return L.has(s)||L.set(s,new Ee),t=>new Promise((e,n)=>{const i=L.get(s);i.add(t,e,n,()=>{i.tasks.length||L.delete(s)})})}const wt=s=>typeof s<"u",R=(s,t)=>{s.events.dispatch("widget:state-change",{state:t},{bubbles:!0}),s.state=t,s.events.dispatch("widget:state-changed",{},{bubbles:!0})},v=A(),Pe=s=>{const{container:t,events:e}=s;t.get("$controller")||(t.register("$controller",new ue(t)),e.dispatch("widget:controller-created",{},{bubbles:!0}))};class _t{constructor(t,e,n){this.state="deactivated",this.name=t,this.implementation=e,this.container=e.container.createChild(this,t),this.events=e.events.createChild(this),v(this).subscriptions=[],n&&e.configure(i=>{const r=i(t);wt(n.type)&&r.type(n.type),wt(n.settings)&&r.settings(n.settings),n.plugins&&Object.keys(n.plugins).forEach(o=>{var c;const l=(c=n.plugins)==null?void 0:c[o];r.plugin(o,l)})}),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 ke(this)(()=>{v(this).deactivatedPromise=null;const t=this.state==="deactivated";t&&(R(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)),R(this,"loading");const e=this.implementation.instructions,n=vt(e,C.Pre,this);return Promise.all(n.map(i=>i.handler(this))).then(()=>{Pe(this);const i=vt(e,C.Post,this);return Promise.all(i.map(r=>r.handler(this))).then(()=>{t&&this.container.get("$controller").initialize()})}).then(()=>(R(this,"activated"),this))})}activate(t){v(this).subscriptions.push(this.implementation.events.subscribe("implementation:configured",()=>{["activated","activating","loading"].indexOf(this.state)>-1&&this.load()}));const e=v(this).activatedPromise;return e?(process.env.NODE_ENV!=="production"&&g(this).warn(`Widget '${this.name}' has already been activated. The passed arguments for this activation will be discarded.`,t),e):v(this).activatedPromise=this.load().then(()=>this.container.get("$controller").activate(t))}invoke(t,...e){const n=v(this).activatedPromise,i=(r,...o)=>n.then(this.load).then(()=>this.container.get("$controller").invoke(r,...o));return n?i(t,...e):(process.env.NODE_ENV!=="production"&&g(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 o=this.events.subscribe("widget:state-changed",()=>{this.state==="activated"&&(o(),r(i(t,...e)))})}))}deactivate(){return v(this).deactivatedPromise||(this.state==="deactivated"?Promise.resolve():(R(this,"deactivating"),v(this).deactivatedPromise=this.container.get("$controller").deactivate().then(()=>(v(this).activatedPromise=null,v(this).subscriptions.forEach(e=>e()),v(this).subscriptions=[],this.container.clear().then(()=>{this.events.clear(),ge(this),R(this,"deactivated")})))))}}const Oe=s=>s.deactivate().then(()=>{s.events.detach(),s.container.detach(),s.implementation.widgets.delete(s.name)});class Ae{constructor(t){this.container=t,this.widget=t.get("$widget"),this.settings=t.get("$settings"),this.events=this.widget.events,this.widget.events.subscribe("settings:change",(e,n)=>{this.settings=n})}}const xt=A();class Dt{constructor(t,e,n=[]){this.instructions=[],this.widgets=new Map,this.name=t.name,this.tenant=t.tenant,this.environment=e,this.container=e.container.createChild(this,this.name),this.events=e.events.createChild(this),this.container.register("$types",{}),xt(this).configurationApiExtensions=n}load(){const t=Array.from(this.widgets.values());return Promise.all(t.map(e=>e.load())).then(()=>t)}configure(t){return $e(t,this,xt(this).configurationApiExtensions),this.events.dispatch("implementation:configured",{implementation:this},{bubbles:!0}),this}createWidget(t,e){const n=new _t(t,this,e);return this.widgets.set(n.name,n),n}}function Ne(s,t,e){const n=new Dt(s,t,e);return s.widgets&&Object.keys(s.widgets).forEach(i=>{var r;const o=(r=s.widgets)==null?void 0:r[i];n.createWidget(i,o)}),n}class T{constructor(t,e){this.selectorFactory=e,typeof t=="function"?this.resolver=t:this.resolver=()=>t}append(t){const e=typeof t=="function"?t:()=>t;return new T(()=>this.all().concat(e()),this.selectorFactory)}all(){return this.resolver().concat([])}query(t){return this.all().filter(this.selectorFactory(t))}find(t){const e=this.query(t);if(e.length)return e[0]}}const st="#____version____#",G=A(),Re=s=>s.tenant?`${s.name}:${s.tenant}`:s.name,It=class{constructor(s,t=[],e={}){this.widgets=new T(()=>{let n=[];return this.implementations.all().forEach(i=>{n=n.concat(Array.from(i.widgets.values()))}),n},Ot),this.implementations=new T([],At),this.name=s,this.container=new tt(this,s),this.events=new et(this),this.container.register("$version",st),this.container.register("$environment",this),this.container.register("$environmentOptions",e),G(this).configurationApiExtensions=t}createImplementation(s){const t=Re(s);let e=this.implementations.find(t);if(e)return process.env.NODE_ENV!=="production"&&g(e).warn(`Implementation "${t}" already exist on current environment.`),e;const n=G(this).configurationApiExtensions;return e=Ne(s,this,n),this.implementations=this.implementations.append([e]),this.events.dispatch("implementation:created",{implementation:e}),e}patch(s={}){const{name:t,configurationApiExtensions:e}=s;typeof t<"u"&&t!==null&&(this.name=t),e&&e.forEach(n=>{G(this).configurationApiExtensions.push(n)})}static create(s={}){return new It(s.name||"",s.configurationApiExtensions,s.options)}};let Lt=It;Lt.version=st;const _e=(s,t,e={})=>ne(s,s.bindings,()=>{const n=s.container.get("$runtimecfg").map(i=>{const r=i[0];if(typeof r=="function")return r;if(At(r)(s))return i[1]}).filter(i=>!!i);return(t?[t]:[]).concat(n)},e.rootElementResolver||(()=>document.body)),Mt=s=>{const t=[];return[(n,i)=>{t.push(s.subscribe(n,i))},()=>{t.forEach(n=>{n()})}]};class W{constructor(t,e=[]){this.platform=t,this.rules=e}match(t){return this.rules.every(e=>!(e.id&&e.id!==t.id||e.type&&e.type!==t.type))}ofType(t){return this.rules.push({type:t}),this}withId(t){return this.rules.push({id:t}),this}select(){return new De(this.platform,this)}}class nt{constructor(t,e,n){this.platform=t,this.node=e,this.actions=new j(t,new W(t).withId(e.id),n);const[i,r]=Mt(this.platform.events);this.subscribe=i,this.unsubscribe=r}properties(t){return t&&this.node.touchProperties(e=>t(e)),this.node.attributes.properties}context(t){return t&&this.subscribe("components:context-changed",(e,{node:n})=>{n===this.node&&t(this.node.attributes.context)}),this.node.attributes.context}layout(t){return t&&this.subscribe("components:layout-changed",(e,{node:n})=>{n===this.node&&t(this.node.attributes.layout)}),this.node.attributes.layout}writeProperties(t,e){this.node.writeProperties(t,e)}writeContext(t,e){this.node.writeProperties(t,e)}writeLayout(t,e){this.node.writeLayout(t,e)}dispose(){this.unsubscribe(),this.actions.dispose()}}class De{constructor(t,e,n=!0){this.platform=t,this.target=e,this.clearOnDispose=n,this.removes=[],this.actions=new j(this.platform,this.target)}writeProperties(t,e){this.removes.push(this.platform.write({options:e,attributes:{properties:t},target:this.target,removable:this.clearOnDispose}))}writeContext(t,e){this.removes.push(this.platform.write({options:e,attributes:{context:t},target:this.target,removable:this.clearOnDispose}))}writeLayout(t,e){this.removes.push(this.platform.write({options:e,attributes:{layout:t},target:this.target,removable:this.clearOnDispose}))}dispose(){this.removes.forEach(t=>{t()}),this.actions.dispose()}}const Ie=(s,t,e)=>{const n=s.concat(),i=(r,o,c)=>{let l=!0;if(n.length){const h=n.shift(),a=(u,p)=>(l=!1,i(u,Object.assign({},o,p),c));return Promise.resolve(h(r,a,c)).then(u=>({...u,cancelled:l}))}return Promise.resolve({data:r,cancelled:!1,options:o})};return i(t,{},e)};class j{constructor(t,e,n){this.platform=t,this.target=e,this.ns=n,this.subscriptions=[],this.create=this.create.bind(this)}create(t,e=()=>{}){const n={key:t,fn:e,target:this.target,ns:this.ns};this.platform.actionsState.handlers.push(n);const i=()=>{const r=this.platform.actionsState.handlers.indexOf(n);r>-1&&this.platform.actionsState.handlers.splice(r,1)};return this.subscriptions.push(i),i}dispatch(t,e){const n=this.platform.nodes.all.concat(this.platform.nodes.detached),i={},r=this.platform.actionsState.handlers.filter(o=>o.key===t&&(!o.ns||!this.ns||o.ns===this.ns));return Promise.all(r.map(o=>{const c=n.filter(h=>o.target.match(h)&&this.target.match(h)),l=this.platform.actionsState.watchers.filter(h=>h.key===t&&(!h.ns||!this.ns||h.ns===this.ns)&&c.some(a=>h.target.match(a))).map(h=>h.fn);return Promise.all(c.map(h=>{const a=new nt(this.platform,h,this.ns);return Ie(l,e,a).then(u=>{const{data:p={},options:d,cancelled:$}=u;return Promise.resolve($?{}:o.fn(p,d,a)).then(N=>{i[h.id]=N})})}))})).then(()=>i)}watch(t,e){let n=t,i=this.ns;const r=t.split(".");r.length>1&&(i=r[0],n=r.splice(1).join("."));const o={fn:e,target:this.target,key:n,ns:i};this.platform.actionsState.watchers.push(o);const c=()=>{const l=this.platform.actionsState.watchers.indexOf(o);l>-1&&this.platform.actionsState.watchers.splice(l,1)};return this.subscriptions.push(c),c}dispose(){this.subscriptions.forEach(t=>t())}}const Le=Rt(s=>{s.createCommand("components",t=>e=>{t.events.subscribeOnce("components:platform-created",(n,{platform:i})=>{e.handlers&&e.handlers.forEach(([r,o])=>{i.addComponentHandler(r,o)})})})}),H=(s,t,...e)=>typeof t=="string"?s(`[humany] ${t}`,...e):s(t,...e),_=class{constructor(){this.keys=[],this.log=(s,...t)=>this.lookup(s,()=>_.log(...t)),this.warn=(s,...t)=>this.lookup(s,()=>_.warn(...t)),this.error=(s,...t)=>this.lookup(s,()=>_.error(...t)),this.info=(s,...t)=>this.lookup(s,()=>_.info(...t))}lookup(s,t){this.keys.indexOf(s)===-1&&(this.keys.push(s),t())}};let P=_;P.log=(...s)=>H(console.log,...s);P.warn=(...s)=>H(console.warn,...s);P.error=(...s)=>H(console.error,...s);P.info=(...s)=>H(console.info,...s);const E=()=>Math.floor((1+Math.random())*65536).toString(16).substring(1);function it(){return E()+E()+"-"+E()+"-"+E()+"-"+E()+"-"+E()+E()+E()}class J{constructor(t,e){this.events=t,this.tags=[],this.children={},this.changesets=[],this.mountCount=0,this.id=it(),this.type=e,this.attributes={context:{},properties:{},layout:{},tags:[]},this.writeLayout({size:"full",indent:0})}mount(t,e){let n=t.get("mounted-nodes");return n||(n=new Map,t.register("mounted-nodes",n)),n.has(this)?(process.env.NODE_ENV!=="production"&&P.error("Trying to mount an already mounted component node.",this),()=>{}):(this.events.dispatch("components:node-mounted",{node:this}),this.mountCount===0&&(this.mountCount=this.mountCount+1,this.events.dispatch("components:node-enter",{node:this})),()=>{n.delete(this),this.events.dispatch("components:node-unmounted",{node:this}),this.mountCount=this.mountCount-1,this.mountCount===0&&this.events.dispatch("components:node-exit",{node:this})})}appendChild(t,e="default"){if(t.parent){if(t.parent===this)return;t.parent.removeChild(t)}t.parent=this,this.children[e]||(this.children[e]=[]),this.children[e].push(t),this.events.dispatch("components:node-appended",{node:t})}prependChild(t,e="default"){if(t.parent){if(t.parent===this)return;t.parent.removeChild(t)}t.parent=this,this.children[e]||(this.children[e]=[]),this.children[e].unshift(t),this.events.dispatch("components:node-appended",{node:t})}touchProperties(t,e={},n){const r=[{properties:t},e];return this.changesets.push(r),this.events.dispatch("components:set-properties",{node:this}),()=>{if(n){const o=this.changesets.indexOf(r);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-properties",{node:this}))}}}writeProperties(t,e={},n){const r=[{properties:t},e];return this.changesets.push(r),this.events.dispatch("components:set-properties",{node:this}),()=>{if(n){const o=this.changesets.indexOf(r);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-properties",{node:this}))}}}writeLayout(t,e={},n){const r=[{layout:t},e];return this.changesets.push(r),this.events.dispatch("components:set-layout",{node:this}),()=>{if(!n)return;const o=this.changesets.indexOf(r);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-layout",{node:this}))}}writeContext(t,e={},n){const r=[{context:t},e];return this.changesets.push(r),this.events.dispatch("components:set-context",{node:this}),()=>{if(!n)return;const o=this.changesets.indexOf(r);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-context",{node:this}))}}getChildren(t="default"){const e=this.children[t]||[];return e.reduce((n,i,r)=>{const{order:o=r}=i.attributes.layout;return n[o]?n.splice(o,0,i):n[o]=i,n},Array(e.length))}remove(){this.parent&&this.parent.removeChild(this)}removeChild(t){Object.keys(this.children).forEach(e=>{const n=this.children[e],i=n.indexOf(t);i>-1&&(n.splice(i,1),this.events.dispatch("components:node-removed",{node:t,parentNode:this}))}),delete t.parent}}const St=(s,t,e)=>{for(let n=0,i=s.length;n<i&&e(s[n])!==!0;n++){const r=t[s[n].id]||"default",o=s[n].getChildren(r);St(o,t,e)}},q=(s,t,e)=>{if(e(s)!==!0){const n=t[s.id]||"default",i=s.children[n];St(i,t,e)}},M=(s,t)=>{const e=[];return q(s,t,n=>{e.push(n)}),e},zt=(s,t,e)=>{let n;return q(s,t,i=>{if(e(i))return n=i,!0}),n};class Me{constructor(t,e,n){this.root=t,this.switches=e,this.all=[],this.visible=[],this.detached=[],n.subscribe("components:node-appended",(i,r)=>{this.all.push(r.node),this.visible=M(t,e)}),n.subscribe("components:node-removed",(i,r)=>{let o=this.all.indexOf(r.node);o>-1&&this.all.splice(o,1),o=this.visible.indexOf(r.node),o>-1&&this.visible.splice(o,1),this.visible=M(t,e)}),n.subscribe("components:node-switched",(i,r)=>{this.visible=M(t,e)})}query(t={}){const e=[];return q(this.root,this.switches,n=>{Object.keys(t).every(r=>t[r]===n[r])&&e.push(n)}),e}get(t){return zt(this.root,this.switches,e=>e.id===t)||this.detached.find(e=>e.id===t)}}class Se{constructor(){this.handlers=new Map}add(t,e){this.handlers.set(t,e)}get(t){return this.handlers.get(t)}}const ze=s=>{let t=s,e=0;for(;t.parent;)e=e+1,t=t.parent;return e},Te=s=>s.map(([e,n])=>[ze(e),e,n]).sort(([e],[n])=>e-n).map(([,e,n])=>[e,n]),K=s=>s instanceof Date?!1:s&&typeof s=="object"&&!Array.isArray(s),w=(s,...t)=>{if(!t.length)return s;const e=t.shift();if(K(s)&&K(e))for(const n in e)K(e[n])?(s[n]||Object.assign(s,{[n]:{}}),w(s[n],e[n])):Object.assign(s,{[n]:e[n]});return w(s,...t)},Ve=(s,t)=>!s||s==="all"?!0:s.some(e=>t.indexOf(e)>-1),We=(s,t)=>{let e=[],n=[],i;const r=()=>{process.env.NODE_ENV!=="production"&&console.time("state-processor.flush");const c=new Map,l=Te(e.map((a,u)=>[a,n[u]])),h=(a,u)=>{var ht;const p=c.get(a)||{},d=u.context&&!p.context,$=u.properties&&!p.properties,N=u.layout&&!p.layout;c.set(a,{context:p.context||d,properties:p.properties||$,layout:p.layout||N}),$&&(a.attributes.properties={}),N&&(a.attributes.layout={}),d&&(a.attributes.context=w({},(ht=a.parent)==null?void 0:ht.attributes.context));const ot=[],ct=[],at=[];if(a.changesets.forEach(y=>{const[f,F]=y;Ve(F.breakpoints,s.breakpoints)&&($&&(typeof f.properties=="function"?ot.push(f.properties):w(a.attributes.properties,f.properties)),N&&(typeof f.layout=="function"?ct.push(f.layout):w(a.attributes.layout,f.layout)),d&&(typeof f.context=="function"?at.push(f.context):w(a.attributes.context,f.context)))}),ot.forEach(y=>{w(a.attributes.properties,y(a.attributes.properties))}),ct.forEach(y=>{w(a.attributes.layout,y(a.attributes.layout))}),at.forEach(y=>{w(a.attributes.context,y(a.attributes.context))}),d||u.recursive){const y=s.getBranch(a),f=u.recursive?u:{context:!!d};a.getChildren(y).forEach(F=>{h(F,f)})}};process.env.NODE_ENV!=="production"&&console.timeEnd("state-processor.flush"),l.forEach(([a,u])=>{h(a,u)}),e=[],n=[],t(c)},o=()=>{clearTimeout(i),i=setTimeout(r,0)};return(c,l)=>{const h=e.indexOf(c);if(h>-1){const a=n[h];return l.context&&(a.context=!0),l.properties&&(a.properties=!0),l.layout&&(a.layout=!0),l.recursive&&(a.recursive=!0),o()}return e.push(c),n.push(l),o()}};class Tt{constructor(t,e={}){this.providers=e,this.breakpoints=[],this.actionsState={handlers:[],watchers:[]},this.switches={},this.changesets=[],this.subscriptions=[],this.customComponentHandler=new Se,this.events=t.events.createChild(this);const n=new J(this.events,"root");n.name=`root-${t.name}`,this.nodes=new Me(n,this.switches,this.events);const i=this.processNode=We(this,r=>{const o=Array.from(r.keys());process.env.NODE_ENV!=="production"&&console.info(`STATE PROCESSOR: ${o.length} node(s) processed:
|
|
2
|
-
${o.map(c=>`${c.name||"<no name>"} (${c.id})
|
|
3
|
-
`)}`),o.forEach(c=>{const l=r.get(c);c.parent&&c.parent.type==="root"&&this.events.dispatch("components:root-children-changed",{node:c}),l!=null&&l.context&&this.events.dispatch("components:context-changed",{node:c}),l!=null&&l.properties&&this.events.dispatch("components:properties-changed",{node:c}),l!=null&&l.layout&&this.events.dispatch("components:layout-changed",{node:c})}),this.events.dispatch("components:component-model-initialized",{},{bubbles:!0})});Promise.all(Object.keys(e).map(r=>e[r].load(this))),this.subscriptions.push(this.events.subscribe("components:node-appended",(r,o)=>{const{node:c}=o;this.changesets.forEach(l=>{const{changeset:h,target:a,removes:u}=l,[p,d]=h;a.match(o.node)&&(p.properties&&u.push(c.writeProperties(p.properties,d)),p.context&&u.push(c.writeContext(p.context,d)),p.layout&&u.push(c.writeLayout(p.layout,d)))})})),this.subscriptions.push(this.events.subscribe("components:node-appended",(r,o)=>{i(o.node,{properties:!0,context:!0})})),this.subscriptions.push(this.events.subscribe("components:set-properties",(r,o)=>{i(o.node,{properties:!0})})),this.subscriptions.push(this.events.subscribe("components:set-context",(r,o)=>{i(o.node,{properties:!0,context:!0})})),this.subscriptions.push(this.events.subscribe("components:set-indent",(r,o)=>{i(o.node,{layout:!0})})),this.subscriptions.push(this.events.subscribe("components:set-layout",(r,o)=>{i(o.node,{layout:!0})})),this.subscriptions.push(this.events.subscribe("components:node-switched",(r,{node:o,branch:c})=>{i(o,{layout:!0,recursive:!0,properties:!0,context:!0})})),this.subscriptions.push(this.events.subscribe("components:node-removed",(r,{parentNode:o})=>{i(o,{properties:!0})})),this.events.parent&&this.events.parent.dispatch("components:platform-created",{platform:this})}static getInstance(t){return t.getAsync("components")}addBreakpoint(t){this.breakpoints.indexOf(t)===-1&&(this.breakpoints.push(t),this.processNode(this.nodes.root,{context:!0,properties:!0,layout:!0,recursive:!0}))}removeBreakpoint(t){const e=this.breakpoints.indexOf(t);e>-1&&(this.breakpoints.splice(e,1),this.processNode(this.nodes.root,{context:!0,properties:!0,layout:!0,recursive:!0}))}setSwitch(t,e){this.switches[t.id]=e,this.events.dispatch("components:node-switched",{node:t,branch:e})}getBranch(t){return this.switches[t.id]}createNode(t,e={}){const n=new J(this.events,t);return e.detached&&this.nodes.detached.push(n),n}components(){return new W(this)}actions(t,e){return new j(this,t,e)}write(t){const{provider:e,target:n,attributes:i,options:r={},removable:o}=t,c=t.key||it(),h={changeset:[i,r],target:n,removes:[]};if(e){const a=this.providers[e];a.write(c,n,i,r),h.removes.push(()=>{a.remove(c)})}return this.changesets.push(h),this.nodes.all.forEach(a=>{if(n.match(a)){let u=()=>{};i.properties&&(u=a.writeProperties(i.properties,r,o)),i.context&&(u=a.writeContext(i.context,r,o)),i.layout&&(u=a.writeContext(i.layout,r,o)),h.removes.push(u)}}),()=>{if(o){h.removes.forEach(u=>u());const a=this.changesets.indexOf(h);a>-1&&this.changesets.splice(a,1)}}}addComponentHandler(t,e){this.customComponentHandler.add(t,e)}getComponentHandler(t){return this.customComponentHandler.get(t)}dispose(){this.subscriptions.forEach(t=>t())}}const je=s=>{if(Array.isArray(s)){const[t,...e]=s;return{definitionId:t,overrides:e}}return{definitionId:s,overrides:[]}},V=(s,t,e,n,i,r)=>{e.forEach(o=>{const c=je(o),l=n[c.definitionId];if(c.definitionId==="view"){const h=s.createNode("view");h.name="view",Object.keys(i).forEach(a=>{const u=i[a];V(s,h,[u.entry],n,i,a)}),t.appendChild(h),c.overrides.forEach(a=>{a.properties&&h.writeProperties(a.properties,{breakpoints:a.breakpoints}),a.context&&h.writeContext(a.context,{breakpoints:a.breakpoints}),a.layout&&h.writeLayout(a.layout,{breakpoints:a.breakpoints})})}else if(s.getComponentHandler(l.type)){const h=s.getComponentHandler(l.type);h&&h(c,{platform:s,node:t,references:e,definitions:n,views:i,branch:r})}else{const h=n[c.definitionId];if(process.env.NODE_ENV!=="production"&&!h){P.error(`No definition found for component type '${c.definitionId}'.`);return}const a=s.createNode(h.type);a.name=c.definitionId,a.tags=h.tags||[],h.properties&&a.writeProperties(h.properties),h.context&&a.writeContext(h.context),h.layout&&a.writeLayout(h.layout),t.appendChild(a,r),c.overrides.forEach(u=>{const p={breakpoints:u.breakpoints};u.properties&&a.writeProperties(u.properties,p),u.context&&a.writeContext(u.context,p),u.layout&&a.writeLayout(u.layout,p)}),h.children&&V(s,a,h.children,n,i)}})},He=(s,t)=>{const{entry:e,components:n,breakpoints:i,views:r}=t,o=[];return Object.keys(i).forEach(c=>{const l=i[c],h=window.matchMedia(l);h.matches&&s.breakpoints.push(c);const a=u=>{u.matches?s.addBreakpoint(c):s.removeBreakpoint(c)};h.addListener(a),o.push(()=>h.removeListener(a))}),V(s,s.nodes.root,[e],n,r),()=>o.forEach(c=>{c()})},qe=(s,t)=>({id:s.id,type:s.type,name:s.name,branch:t||"default"}),Fe=(s,t,e,n=it(),i={})=>s.getAsync("components").then(r=>{let o;if(typeof t=="string"){const h=new W(r);h.ofType(t),o=h}else o=t;const c={},l=h=>{const a=c[h.id];return a?Promise.resolve(a.controller):Tt.getInstance(s).then(u=>new nt(u,h,n))};r.events.subscribe("components:node-enter",(h,{node:a})=>{o.match(a)&&l(a).then(u=>{Promise.resolve(e(u)).then(p=>{c[a.id]={dispose:p,controller:u}})})}),r.events.subscribe("components:node-exit",(h,{node:a})=>{const u=c[a.id];u&&(u.dispose&&u.dispose(),i.reuseController||(u.controller.dispose(),delete c[a.id]))})});class Be{constructor(t){this.aliases=new Map,this.components=new Map,this.logger=new P;const{events:e}=t.get("$widget");this.events=e}getComponent(t){const e=this.aliases.get(t),n=this.components.get(e||t)||null;return process.env.NODE_ENV!=="production"&&(n||this.logger.warn(e||t,`Unable to resolve component: "${e||t}". You most likely forgot to register the required plugin for: ${e||t}.`)),n}registerComponent(t,e){return this.components.set(t,e),this.events.dispatch("component-resolver:resolve",t),()=>{this.components.delete(t)}}registerResolver(t,e){return this.events.subscribe("component-resolver:resolve",(n,i)=>{if(i===t){const r=this.getComponent(t);e(r)}})}registerAlias(t,e){return this.aliases.set(t,e),this.events.dispatch("component-resolver:resolve",t),()=>{this.aliases.delete(t)}}}const Vt="#____version____#",Wt=class extends Lt{constructor(s,t=[]){super(s,t,{transformPluginSettings:(e,n,i)=>{const r=i.get("$settings");return{...r.plugins&&n?r.plugins[n]||{}:{},...e}}})}createImplementation(s){const t=super.createImplementation(s);return t.bindings=s.bindings,t}navigate(s,t,e){this.widgets.query(s).forEach(n=>n.invoke("navigate",{route:t,params:e}))}static create(s={}){const t=[oe].concat(s.configurationApiExtensions||[]);return new Wt("humany",t)}static createFromGlobal(s,t={}){if(this.isRuntime(s))return s.patch(t),s;const e=[],n=s&&s._c;n&&n.forEach(r=>e.push(r));const i=this.create(t);return i.container.register("$runtimecfg",e),i}static isRuntime(s){return!!(s&&typeof s=="object"&&s.container&&typeof s.container.get=="function"&&s.container.get("$environment")===s&&s.container.owner===s)}};let rt=Wt;rt.version=`${Vt} (${st})`;class Qe extends Dt{constructor(){super(...arguments),this.bindings=[]}}class Ue extends be{constructor(t,e){super(t,e)}}var jt=(s=>(s.open="open",s.closed="closed",s.hidden="hidden",s))(jt||{});class Ye extends Ae{constructor(t){super(t)}}var Ht=(s=>(s.guide="guide",s.link="link",s.default="default",s))(Ht||{}),qt=(s=>(s.MODAL="modal",s.DRAWER="drawer",s.DROPDOWN="dropdown",s.NONE="none",s))(qt||{});const Ge=(s,t)=>fetch(t+"/config.json").then(e=>e.json()).then(e=>e.implementation).then(e=>s.createImplementation(e)),Ke=(s,t)=>{const e=`${s}${t}/interfaceauthorized`;return fetch(e,{method:"GET",credentials:"include"}).then(n=>n.status===200&&n.ok)};exports.ActionResolver=Ft;exports.ActionsController=j;exports.ComponentNode=J;exports.ComponentNodeController=nt;exports.ComponentPlatform=Tt;exports.ComponentQuery=W;exports.ComponentResolver=Be;exports.DialogItemType=Ht;exports.Environment=rt;exports.Humany=rt;exports.Implementation=Qe;exports.PickerTypes=qt;exports.Plugin=Ue;exports.Widget=_t;exports.WidgetRenderState=jt;exports.WidgetType=Ye;exports.asDescriptor=qe;exports.bootstrap=_e;exports.componentConfigurationApi=Le;exports.createChildren=V;exports.createComponentModel=He;exports.createEventSubscriber=Mt;exports.destroy=Oe;exports.extendComponent=Fe;exports.findComponent=zt;exports.findVisibleComponents=M;exports.loadImplementation=Ge;exports.supportBootstrapping=re;exports.traverseComponents=q;exports.verifyAuth=Ke;exports.version=Vt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("@telia-ace/widget-core"),d=require("@webprovisions/bootstrapping"),u=require("@webprovisions/platform");var i=(e=>(e.guide="guide",e.link="link",e.default="default",e))(i||{}),a=(e=>(e.MODAL="modal",e.DRAWER="drawer",e.DROPDOWN="dropdown",e.NONE="none",e))(a||{});const l=(e,r)=>fetch(r+"/config.json").then(t=>t.json()).then(t=>t.implementation).then(t=>e.createImplementation(t)),c=(e,r)=>{const t=`${e}${r}/interfaceauthorized`;return fetch(t,{method:"GET",credentials:"include"}).then(o=>o.status===200&&o.ok)};Object.defineProperty(exports,"Humany",{enumerable:!0,get:()=>n.Environment});Object.defineProperty(exports,"supportBootstrapping",{enumerable:!0,get:()=>d.supportBootstrapping});Object.defineProperty(exports,"Widget",{enumerable:!0,get:()=>u.Widget});Object.defineProperty(exports,"destroy",{enumerable:!0,get:()=>u.destroyWidget});exports.DialogItemType=i;exports.PickerTypes=a;exports.loadImplementation=l;exports.verifyAuth=c;Object.keys(n).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>n[e]})});
|