@telia-ace/widget-core-flamingo 1.1.76-rc.0 → 1.1.76-rc.10
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +12 -12
- package/index.mjs +83 -69
- package/models/application.d.ts +1 -0
- package/package.json +1 -1
package/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var gt=function(s,t){return gt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,i){e.__proto__=i}||function(e,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(e[r]=i[r])},gt(s,t)};function V(s,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");gt(s,t);function e(){this.constructor=s}s.prototype=t===null?Object.create(t):(e.prototype=t.prototype,new e)}function mt(s){var t=typeof Symbol=="function"&&Symbol.iterator,e=t&&s[t],i=0;if(e)return e.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&i>=s.length&&(s=void 0),{value:s&&s[i++],done:!s}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function G(s,t){var e=typeof Symbol=="function"&&s[Symbol.iterator];if(!e)return s;var i=e.call(s),r,o=[],n;try{for(;(t===void 0||t-- >0)&&!(r=i.next()).done;)o.push(r.value)}catch(a){n={error:a}}finally{try{r&&!r.done&&(e=i.return)&&e.call(i)}finally{if(n)throw n.error}}return o}function X(s,t,e){if(e||arguments.length===2)for(var i=0,r=t.length,o;i<r;i++)(o||!(i in t))&&(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return s.concat(o||Array.prototype.slice.call(t))}function _(s){return typeof s=="function"}function Qt(s){var t=function(i){Error.call(i),i.stack=new Error().stack},e=s(t);return e.prototype=Object.create(Error.prototype),e.prototype.constructor=e,e}var nt=Qt(function(s){return function(e){s(this),this.message=e?e.length+` errors occurred during unsubscription:
|
2
2
|
`+e.map(function(i,r){return r+1+") "+i.toString()}).join(`
|
3
|
-
`):"",this.name="UnsubscriptionError",this.errors=e}});function vt(s,t){if(s){var e=s.indexOf(t);0<=e&&s.splice(e,1)}}var it=function(){function s(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return s.prototype.unsubscribe=function(){var t,e,i,r,o;if(!this.closed){this.closed=!0;var n=this._parentage;if(n)if(this._parentage=null,Array.isArray(n))try{for(var a=mt(n),c=a.next();!c.done;c=a.next()){var h=c.value;h.remove(this)}}catch(y){t={error:y}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else n.remove(this);var l=this.initialTeardown;if(_(l))try{l()}catch(y){o=y instanceof nt?y.errors:[y]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var p=mt(d),f=p.next();!f.done;f=p.next()){var g=f.value;try{Ot(g)}catch(y){o=o??[],y instanceof nt?o=X(X([],G(o)),G(y.errors)):o.push(y)}}}catch(y){i={error:y}}finally{try{f&&!f.done&&(r=p.return)&&r.call(p)}finally{if(i)throw i.error}}}if(o)throw new nt(o)}},s.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Ot(t);else{if(t instanceof s){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},s.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},s.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},s.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&vt(e,t)},s.prototype.remove=function(t){var e=this._finalizers;e&&vt(e,t),t instanceof s&&t._removeParent(this)},s.EMPTY=function(){var t=new s;return t.closed=!0,t}(),s}(),te=it.EMPTY;function ee(s){return s instanceof it||s&&"closed"in s&&_(s.remove)&&_(s.add)&&_(s.unsubscribe)}function Ot(s){_(s)?s():s.unsubscribe()}var ie={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},yt={setTimeout:function(s,t){for(var e=[],i=2;i<arguments.length;i++)e[i-2]=arguments[i];var r=yt.delegate;return r!=null&&r.setTimeout?r.setTimeout.apply(r,X([s,t],G(e))):setTimeout.apply(void 0,X([s,t],G(e)))},clearTimeout:function(s){var t=yt.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(s)},delegate:void 0};function Ee(s){yt.setTimeout(function(){throw s})}function Tt(){}function Z(s){s()}var se=function(s){V(t,s);function t(e){var i=s.call(this)||this;return i.isStopped=!1,e?(i.destination=e,ee(e)&&e.add(i)):i.destination=Ie,i}return t.create=function(e,i,r){return new bt(e,i,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,s.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(it),Pe=Function.prototype.bind;function at(s,t){return Pe.call(s,t)}var Oe=function(){function s(t){this.partialObserver=t}return s.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(i){K(i)}},s.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(i){K(i)}else K(t)},s.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){K(e)}},s}(),bt=function(s){V(t,s);function t(e,i,r){var o=s.call(this)||this,n;if(_(e)||!e)n={next:e??void 0,error:i??void 0,complete:r??void 0};else{var a;o&&ie.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return o.unsubscribe()},n={next:e.next&&at(e.next,a),error:e.error&&at(e.error,a),complete:e.complete&&at(e.complete,a)}):n=e}return o.destination=new Oe(n),o}return t}(se);function K(s){Ee(s)}function Te(s){throw s}var Ie={closed:!0,next:Tt,error:Te,complete:Tt},Re=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function ke(s){return s}function Ne(s){return s.length===0?ke:s.length===1?s[0]:function(e){return s.reduce(function(i,r){return r(i)},e)}}var It=function(){function s(t){t&&(this._subscribe=t)}return s.prototype.lift=function(t){var e=new s;return e.source=this,e.operator=t,e},s.prototype.subscribe=function(t,e,i){var r=this,o=Me(t)?t:new bt(t,e,i);return Z(function(){var n=r,a=n.operator,c=n.source;o.add(a?a.call(o,c):c?r._subscribe(o):r._trySubscribe(o))}),o},s.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},s.prototype.forEach=function(t,e){var i=this;return e=Rt(e),new e(function(r,o){var n=new bt({next:function(a){try{t(a)}catch(c){o(c),n.unsubscribe()}},error:o,complete:r});i.subscribe(n)})},s.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},s.prototype[Re]=function(){return this},s.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Ne(t)(this)},s.prototype.toPromise=function(t){var e=this;return t=Rt(t),new t(function(i,r){var o;e.subscribe(function(n){return o=n},function(n){return r(n)},function(){return i(o)})})},s.create=function(t){return new s(t)},s}();function Rt(s){var t;return(t=s??ie.Promise)!==null&&t!==void 0?t:Promise}function Ue(s){return s&&_(s.next)&&_(s.error)&&_(s.complete)}function Me(s){return s&&s instanceof se||Ue(s)&&ee(s)}var je=Qt(function(s){return function(){s(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}})
|
3
|
+
`):"",this.name="UnsubscriptionError",this.errors=e}});function vt(s,t){if(s){var e=s.indexOf(t);0<=e&&s.splice(e,1)}}var it=function(){function s(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return s.prototype.unsubscribe=function(){var t,e,i,r,o;if(!this.closed){this.closed=!0;var n=this._parentage;if(n)if(this._parentage=null,Array.isArray(n))try{for(var a=mt(n),c=a.next();!c.done;c=a.next()){var h=c.value;h.remove(this)}}catch(y){t={error:y}}finally{try{c&&!c.done&&(e=a.return)&&e.call(a)}finally{if(t)throw t.error}}else n.remove(this);var l=this.initialTeardown;if(_(l))try{l()}catch(y){o=y instanceof nt?y.errors:[y]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var p=mt(d),f=p.next();!f.done;f=p.next()){var g=f.value;try{Ot(g)}catch(y){o=o??[],y instanceof nt?o=X(X([],G(o)),G(y.errors)):o.push(y)}}}catch(y){i={error:y}}finally{try{f&&!f.done&&(r=p.return)&&r.call(p)}finally{if(i)throw i.error}}}if(o)throw new nt(o)}},s.prototype.add=function(t){var e;if(t&&t!==this)if(this.closed)Ot(t);else{if(t instanceof s){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(e=this._finalizers)!==null&&e!==void 0?e:[]).push(t)}},s.prototype._hasParent=function(t){var e=this._parentage;return e===t||Array.isArray(e)&&e.includes(t)},s.prototype._addParent=function(t){var e=this._parentage;this._parentage=Array.isArray(e)?(e.push(t),e):e?[e,t]:t},s.prototype._removeParent=function(t){var e=this._parentage;e===t?this._parentage=null:Array.isArray(e)&&vt(e,t)},s.prototype.remove=function(t){var e=this._finalizers;e&&vt(e,t),t instanceof s&&t._removeParent(this)},s.EMPTY=function(){var t=new s;return t.closed=!0,t}(),s}(),te=it.EMPTY;function ee(s){return s instanceof it||s&&"closed"in s&&_(s.remove)&&_(s.add)&&_(s.unsubscribe)}function Ot(s){_(s)?s():s.unsubscribe()}var ie={onUnhandledError:null,onStoppedNotification:null,Promise:void 0,useDeprecatedSynchronousErrorHandling:!1,useDeprecatedNextContext:!1},yt={setTimeout:function(s,t){for(var e=[],i=2;i<arguments.length;i++)e[i-2]=arguments[i];var r=yt.delegate;return r!=null&&r.setTimeout?r.setTimeout.apply(r,X([s,t],G(e))):setTimeout.apply(void 0,X([s,t],G(e)))},clearTimeout:function(s){var t=yt.delegate;return((t==null?void 0:t.clearTimeout)||clearTimeout)(s)},delegate:void 0};function Ee(s){yt.setTimeout(function(){throw s})}function Tt(){}function Z(s){s()}var se=function(s){V(t,s);function t(e){var i=s.call(this)||this;return i.isStopped=!1,e?(i.destination=e,ee(e)&&e.add(i)):i.destination=Ie,i}return t.create=function(e,i,r){return new bt(e,i,r)},t.prototype.next=function(e){this.isStopped||this._next(e)},t.prototype.error=function(e){this.isStopped||(this.isStopped=!0,this._error(e))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,s.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(e){this.destination.next(e)},t.prototype._error=function(e){try{this.destination.error(e)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t}(it),Pe=Function.prototype.bind;function at(s,t){return Pe.call(s,t)}var Oe=function(){function s(t){this.partialObserver=t}return s.prototype.next=function(t){var e=this.partialObserver;if(e.next)try{e.next(t)}catch(i){K(i)}},s.prototype.error=function(t){var e=this.partialObserver;if(e.error)try{e.error(t)}catch(i){K(i)}else K(t)},s.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(e){K(e)}},s}(),bt=function(s){V(t,s);function t(e,i,r){var o=s.call(this)||this,n;if(_(e)||!e)n={next:e??void 0,error:i??void 0,complete:r??void 0};else{var a;o&&ie.useDeprecatedNextContext?(a=Object.create(e),a.unsubscribe=function(){return o.unsubscribe()},n={next:e.next&&at(e.next,a),error:e.error&&at(e.error,a),complete:e.complete&&at(e.complete,a)}):n=e}return o.destination=new Oe(n),o}return t}(se);function K(s){Ee(s)}function Te(s){throw s}var Ie={closed:!0,next:Tt,error:Te,complete:Tt},Re=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();function ke(s){return s}function Ne(s){return s.length===0?ke:s.length===1?s[0]:function(e){return s.reduce(function(i,r){return r(i)},e)}}var It=function(){function s(t){t&&(this._subscribe=t)}return s.prototype.lift=function(t){var e=new s;return e.source=this,e.operator=t,e},s.prototype.subscribe=function(t,e,i){var r=this,o=Me(t)?t:new bt(t,e,i);return Z(function(){var n=r,a=n.operator,c=n.source;o.add(a?a.call(o,c):c?r._subscribe(o):r._trySubscribe(o))}),o},s.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(e){t.error(e)}},s.prototype.forEach=function(t,e){var i=this;return e=Rt(e),new e(function(r,o){var n=new bt({next:function(a){try{t(a)}catch(c){o(c),n.unsubscribe()}},error:o,complete:r});i.subscribe(n)})},s.prototype._subscribe=function(t){var e;return(e=this.source)===null||e===void 0?void 0:e.subscribe(t)},s.prototype[Re]=function(){return this},s.prototype.pipe=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return Ne(t)(this)},s.prototype.toPromise=function(t){var e=this;return t=Rt(t),new t(function(i,r){var o;e.subscribe(function(n){return o=n},function(n){return r(n)},function(){return i(o)})})},s.create=function(t){return new s(t)},s}();function Rt(s){var t;return(t=s??ie.Promise)!==null&&t!==void 0?t:Promise}function Ue(s){return s&&_(s.next)&&_(s.error)&&_(s.complete)}function Me(s){return s&&s instanceof se||Ue(s)&&ee(s)}var je=Qt(function(s){return function(){s(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),$t=function(s){V(t,s);function t(){var e=s.call(this)||this;return e.closed=!1,e.currentObservers=null,e.observers=[],e.isStopped=!1,e.hasError=!1,e.thrownError=null,e}return t.prototype.lift=function(e){var i=new kt(this,this);return i.operator=e,i},t.prototype._throwIfClosed=function(){if(this.closed)throw new je},t.prototype.next=function(e){var i=this;Z(function(){var r,o;if(i._throwIfClosed(),!i.isStopped){i.currentObservers||(i.currentObservers=Array.from(i.observers));try{for(var n=mt(i.currentObservers),a=n.next();!a.done;a=n.next()){var c=a.value;c.next(e)}}catch(h){r={error:h}}finally{try{a&&!a.done&&(o=n.return)&&o.call(n)}finally{if(r)throw r.error}}}})},t.prototype.error=function(e){var i=this;Z(function(){if(i._throwIfClosed(),!i.isStopped){i.hasError=i.isStopped=!0,i.thrownError=e;for(var r=i.observers;r.length;)r.shift().error(e)}})},t.prototype.complete=function(){var e=this;Z(function(){if(e._throwIfClosed(),!e.isStopped){e.isStopped=!0;for(var i=e.observers;i.length;)i.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var e;return((e=this.observers)===null||e===void 0?void 0:e.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(e){return this._throwIfClosed(),s.prototype._trySubscribe.call(this,e)},t.prototype._subscribe=function(e){return this._throwIfClosed(),this._checkFinalizedStatuses(e),this._innerSubscribe(e)},t.prototype._innerSubscribe=function(e){var i=this,r=this,o=r.hasError,n=r.isStopped,a=r.observers;return o||n?te:(this.currentObservers=null,a.push(e),new it(function(){i.currentObservers=null,vt(a,e)}))},t.prototype._checkFinalizedStatuses=function(e){var i=this,r=i.hasError,o=i.thrownError,n=i.isStopped;r?e.error(o):n&&e.complete()},t.prototype.asObservable=function(){var e=new It;return e.source=this,e},t.create=function(e,i){return new kt(e,i)},t}(It),kt=function(s){V(t,s);function t(e,i){var r=s.call(this)||this;return r.destination=e,r.source=i,r}return t.prototype.next=function(e){var i,r;(r=(i=this.destination)===null||i===void 0?void 0:i.next)===null||r===void 0||r.call(i,e)},t.prototype.error=function(e){var i,r;(r=(i=this.destination)===null||i===void 0?void 0:i.error)===null||r===void 0||r.call(i,e)},t.prototype.complete=function(){var e,i;(i=(e=this.destination)===null||e===void 0?void 0:e.complete)===null||i===void 0||i.call(e)},t.prototype._subscribe=function(e){var i,r;return(r=(i=this.source)===null||i===void 0?void 0:i.subscribe(e))!==null&&r!==void 0?r:te},t}($t),re=function(s){V(t,s);function t(e){var i=s.call(this)||this;return i._value=e,i}return Object.defineProperty(t.prototype,"value",{get:function(){return this.getValue()},enumerable:!1,configurable:!0}),t.prototype._subscribe=function(e){var i=s.prototype._subscribe.call(this,e);return!i.closed&&e.next(this._value),i},t.prototype.getValue=function(){var e=this,i=e.hasError,r=e.thrownError,o=e._value;if(i)throw r;return this._throwIfClosed(),o},t.prototype.next=function(e){s.prototype.next.call(this,this._value=e)},t}($t),oe=(s=>(s.Loading="loading",s.Ready="ready",s))(oe||{});class wt{constructor(t,e){this.state=new re("loading"),this.resolvers=new Map,this.name=t,this.environment=e,this.state.next("ready")}setState(t){this.state.next(t)}async register(t,e){this.resolvers.set(t,e)}async get(t){return this.resolvers.get(t)}}/**
|
4
4
|
* @license
|
5
5
|
* Copyright 2019 Google LLC
|
6
6
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -22,11 +22,11 @@
|
|
22
22
|
* @license
|
23
23
|
* Copyright 2017 Google LLC
|
24
24
|
* SPDX-License-Identifier: BSD-3-Clause
|
25
|
-
*/const si={attribute:!0,type:String,converter:Q,reflect:!1,hasChanged:xt},ri=(s=si,t,e)=>{const{kind:i,metadata:r}=e;let o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),o.set(e.name,s),i==="accessor"){const{name:n}=e;return{set(a){const c=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,c,s)},init(a){return a!==void 0&&this.P(n,void 0,s),a}}}if(i==="setter"){const{name:n}=e;return function(a){const c=this[n];t.call(this,a),this.requestUpdate(n,c,s)}}throw Error("Unsupported decorator location: "+i)};function
|
25
|
+
*/const si={attribute:!0,type:String,converter:Q,reflect:!1,hasChanged:xt},ri=(s=si,t,e)=>{const{kind:i,metadata:r}=e;let o=globalThis.litPropertyMetadata.get(r);if(o===void 0&&globalThis.litPropertyMetadata.set(r,o=new Map),o.set(e.name,s),i==="accessor"){const{name:n}=e;return{set(a){const c=t.get.call(this);t.set.call(this,a),this.requestUpdate(n,c,s)},init(a){return a!==void 0&&this.P(n,void 0,s),a}}}if(i==="setter"){const{name:n}=e;return function(a){const c=this[n];t.call(this,a),this.requestUpdate(n,c,s)}}throw Error("Unsupported decorator location: "+i)};function v(s){return(t,e)=>typeof e=="object"?ri(s,t,e):((i,r,o)=>{const n=r.hasOwnProperty(o);return r.constructor.createProperty(o,n?{...i,wrapped:!0}:i),n?Object.getOwnPropertyDescriptor(r,o):void 0})(s,t,e)}/**
|
26
26
|
* @license
|
27
27
|
* Copyright 2017 Google LLC
|
28
28
|
* SPDX-License-Identifier: BSD-3-Clause
|
29
|
-
*/function U(s){return
|
29
|
+
*/function U(s){return v({...s,state:!0,attribute:!1})}var oi=Object.defineProperty,ni=Object.getOwnPropertyDescriptor,ai=(s,t,e,i)=>{for(var r=i>1?void 0:i?ni(t,e):t,o=s.length-1,n;o>=0;o--)(n=s[o])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&oi(t,e,r),r};class rt extends A{constructor(){super(...arguments),this.anchor="BottomRight"}appendChild(t){var e;return(e=this.shadowRoot)==null||e.appendChild(t),t}render(){return this.anchor==="BottomLeft"?this.renderRoot.host.classList.add("bottom-left"):this.anchor==="BottomRight"&&this.renderRoot.host.classList.add("bottom-right"),u}}rt.styles=[N`
|
30
30
|
:host {
|
31
31
|
position: fixed;
|
32
32
|
display: flex;
|
@@ -42,7 +42,7 @@
|
|
42
42
|
bottom: 20px;
|
43
43
|
left: 20px;
|
44
44
|
}
|
45
|
-
`];ai([
|
45
|
+
`];ai([v({attribute:!0})],rt.prototype,"anchor",2);/**
|
46
46
|
* @license
|
47
47
|
* Copyright 2017 Google LLC
|
48
48
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -58,11 +58,11 @@
|
|
58
58
|
* @license
|
59
59
|
* Copyright 2018 Google LLC
|
60
60
|
* SPDX-License-Identifier: BSD-3-Clause
|
61
|
-
*/const Jt=St(class extends pe{constructor(s){var t;if(super(s),s.type!==Ct.ATTRIBUTE||s.name!=="class"||((t=s.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(s){return" "+Object.keys(s).filter(t=>s[t]).join(" ")+" "}update(s,[t]){var i,r;if(this.st===void 0){this.st=new Set,s.strings!==void 0&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter(o=>o!=="")));for(const o in t)t[o]&&!((i=this.nt)!=null&&i.has(o))&&this.st.add(o);return this.render(t)}const e=s.element.classList;for(const o of this.st)o in t||(e.remove(o),this.st.delete(o));for(const o in t){const n=!!t[o];n===this.st.has(o)||(r=this.nt)!=null&&r.has(o)||(n?(e.add(o),this.st.add(o)):(e.remove(o),this.st.delete(o)))}return T}})
|
61
|
+
*/const Jt=St(class extends pe{constructor(s){var t;if(super(s),s.type!==Ct.ATTRIBUTE||s.name!=="class"||((t=s.strings)==null?void 0:t.length)>2)throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute.")}render(s){return" "+Object.keys(s).filter(t=>s[t]).join(" ")+" "}update(s,[t]){var i,r;if(this.st===void 0){this.st=new Set,s.strings!==void 0&&(this.nt=new Set(s.strings.join(" ").split(/\s/).filter(o=>o!=="")));for(const o in t)t[o]&&!((i=this.nt)!=null&&i.has(o))&&this.st.add(o);return this.render(t)}const e=s.element.classList;for(const o of this.st)o in t||(e.remove(o),this.st.delete(o));for(const o in t){const n=!!t[o];n===this.st.has(o)||(r=this.nt)!=null&&r.has(o)||(n?(e.add(o),this.st.add(o)):(e.remove(o),this.st.delete(o)))}return T}}),w=(s,t,e)=>{s&&e.style.setProperty(t,s)},ge=(s,t)=>{var e,i,r,o,n,a,c,h,l;w((e=s.colors)==null?void 0:e.primaryBackground,"--primary-background",t),w((i=s.colors)==null?void 0:i.textOnPrimaryBackground,"--text-on-primary-background",t),w((r=s.colors)==null?void 0:r.secondaryBackground,"--secondary-background",t),w((o=s.colors)==null?void 0:o.textOnSecondaryBackground,"--text-on-secondary-background",t),w((n=s.colors)==null?void 0:n.interactiveDestructiveBackground,"--destructive-color",t),w((a=s.colors)==null?void 0:a.interactiveTextOnDestructiveBackground,"--text-on-destructive-color",t),w((c=s.colors)==null?void 0:c.interactivePrimaryBackground,"--interactive-primary-background",t),w((h=s.colors)==null?void 0:h.interactiveTextOnPrimaryBackground,"--interactive-text-on-primary-background",t),w((l=s.colors)==null?void 0:l.focusColor,"--focus-color",t)};/**
|
62
62
|
* @license
|
63
63
|
* Copyright 2020 Google LLC
|
64
64
|
* SPDX-License-Identifier: BSD-3-Clause
|
65
|
-
*/const me=()=>new bi;class bi{}const ft=new WeakMap,ve=St(class extends fe{render(s){return u}update(s,[t]){var i;const e=t!==this.Y;return e&&this.Y!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.Y=t,this.ht=(i=s.options)==null?void 0:i.host,this.rt(this.ct=s.element)),u}rt(s){if(typeof this.Y=="function"){const t=this.ht??globalThis;let e=ft.get(t);e===void 0&&(e=new WeakMap,ft.set(t,e)),e.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),e.set(this.Y,s),s!==void 0&&this.Y.call(this.ht,s)}else this.Y.value=s}get lt(){var s,t;return typeof this.Y=="function"?(s=ft.get(this.ht??globalThis))==null?void 0:s.get(this.Y):(t=this.Y)==null?void 0:t.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var
|
65
|
+
*/const me=()=>new bi;class bi{}const ft=new WeakMap,ve=St(class extends fe{render(s){return u}update(s,[t]){var i;const e=t!==this.Y;return e&&this.Y!==void 0&&this.rt(void 0),(e||this.lt!==this.ct)&&(this.Y=t,this.ht=(i=s.options)==null?void 0:i.host,this.rt(this.ct=s.element)),u}rt(s){if(typeof this.Y=="function"){const t=this.ht??globalThis;let e=ft.get(t);e===void 0&&(e=new WeakMap,ft.set(t,e)),e.get(this.Y)!==void 0&&this.Y.call(this.ht,void 0),e.set(this.Y,s),s!==void 0&&this.Y.call(this.ht,s)}else this.Y.value=s}get lt(){var s,t;return typeof this.Y=="function"?(s=ft.get(this.ht??globalThis))==null?void 0:s.get(this.Y):(t=this.Y)==null?void 0:t.value}disconnected(){this.lt===this.ct&&this.rt(void 0)}reconnected(){this.rt(this.ct)}});var wi=Object.defineProperty,$i=Object.getOwnPropertyDescriptor,q=(s,t,e,i)=>{for(var r=i>1?void 0:i?$i(t,e):t,o=s.length-1,n;o>=0;o--)(n=s[o])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&wi(t,e,r),r};class b extends A{constructor(){super(...arguments),this.active=!1,this.triggerVisible=!0,this.loaded=!1,this.containerRef=me(),this.widgetActive$=new re(!1),this.componentIsDestroyed$=new $t}async connectedCallback(){super.connectedCallback(),this.icon=await this._renderSymbol(),this.loaded=!0,this._applyBranding()}disconnectedCallback(){super.disconnectedCallback(),this.componentIsDestroyed$.next(),this.componentIsDestroyed$.complete()}toggleActive(){var t;if(!((t=this.application)!=null&&t.root)){console.warn("Could not activate widget. No root element assigned to widget.");return}this.active=!this.active,this.active?(this.application.appendToDOM(),this.widgetActive$.next(!0),this.hideTrigger()):(this.application.hide(),this.widgetActive$.next(!1),this.showTrigger())}_applyBranding(){var t;(t=this.application)!=null&&t.settings&&ge(this.application.settings.branding,this)}async _renderSymbol(){var a,c,h;const t=(a=this.application)==null?void 0:a.branding(),e=(c=t==null?void 0:t.graphics)==null?void 0:c.trigger;if(e)return R` <img src=${e} class="trigger-icon" alt="" /> `;const i=(h=this.application)==null?void 0:h.triggerIcon;if(!i)return u;const r=async l=>yi,{type:o,content:n}=i;switch(o){case"Telia":{const l=await r();return l?R`<telia-icon
|
66
66
|
class="trigger-icon"
|
67
67
|
svg=${l.svg}
|
68
68
|
size="lg"
|
@@ -244,7 +244,7 @@
|
|
244
244
|
.trigger-label:hover {
|
245
245
|
opacity: 0.8;
|
246
246
|
}
|
247
|
-
`];q([
|
247
|
+
`];q([v({attribute:!1})],b.prototype,"application",2);q([U()],b.prototype,"active",2);q([U()],b.prototype,"triggerVisible",2);q([U()],b.prototype,"loaded",2);q([U()],b.prototype,"icon",2);var _i=Object.defineProperty,Ai=Object.getOwnPropertyDescriptor,E=(s,t,e,i)=>{for(var r=i>1?void 0:i?Ai(t,e):t,o=s.length-1,n;o>=0;o--)(n=s[o])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&_i(t,e,r),r};const ye=s=>{class t extends s{constructor(){super(...arguments),this.properties={},this.context={},this.layout={},this.nodes=[]}writeProperties(i){this.properties=i}writeLayout(i){this.layout=i}writeContext(i){this.context=i}addChild(i){i.parent=this,this.nodes.push(i)}connectedCallback(){super.connectedCallback(),this.renderRoot.host.style.setProperty("--width",this.layout.size==="full"?"var(--columns, 1)":`min(${this.layout.size||"var(--columns)"}, var(--columns))`),this.application.mountComponent(this)}}return t.styles=[N`
|
248
248
|
:host {
|
249
249
|
font-family: var(--font-family);
|
250
250
|
grid-column: span var(--width);
|
@@ -256,7 +256,7 @@
|
|
256
256
|
* {
|
257
257
|
box-sizing: border-box;
|
258
258
|
}
|
259
|
-
`],E([
|
259
|
+
`],E([v()],t.prototype,"properties",2),E([v()],t.prototype,"context",2),E([v()],t.prototype,"layout",2),E([v()],t.prototype,"name",2),E([v()],t.prototype,"type",2),E([v({attribute:!1})],t.prototype,"application",2),E([v({attribute:!1})],t.prototype,"parent",2),t};class Et extends ye(A){render(){return R`Non resolved component`}}Et.styles=[N`
|
260
260
|
:host {
|
261
261
|
display: block;
|
262
262
|
}
|
@@ -264,7 +264,7 @@
|
|
264
264
|
* @license
|
265
265
|
* Copyright 2021 Google LLC
|
266
266
|
* SPDX-License-Identifier: BSD-3-Clause
|
267
|
-
*/function*xi(s,t){if(s!==void 0){let e=0;for(const i of s)yield t(i,e++)}}var
|
267
|
+
*/function*xi(s,t){if(s!==void 0){let e=0;for(const i of s)yield t(i,e++)}}var $=(s=>(s.Inline="inline",s.Trigger="trigger",s))($||{});/**
|
268
268
|
* @license
|
269
269
|
* Copyright 2021 Google LLC
|
270
270
|
* SPDX-License-Identifier: BSD-3-Clause
|
@@ -284,7 +284,7 @@
|
|
284
284
|
* @license
|
285
285
|
* Copyright 2017 Google LLC
|
286
286
|
* SPDX-License-Identifier: BSD-3-Clause
|
287
|
-
*/function Pi({context:s}){return(t,e)=>{const i=new WeakMap;if(typeof e=="object")return e.addInitializer(function(){i.set(this,new Gt(this,{context:s}))}),{get(){return t.get.call(this)},set(r){var o;return(o=i.get(this))==null||o.setValue(r),t.set.call(this,r)},init(r){var o;return(o=i.get(this))==null||o.setValue(r),r}};{t.constructor.addInitializer(n=>{i.set(n,new Gt(n,{context:s}))});const r=Object.getOwnPropertyDescriptor(t,e);let o;if(r===void 0){const n=new WeakMap;o={get:function(){return n.get(this)},set:function(a){i.get(this).setValue(a),n.set(this,a)},configurable:!0,enumerable:!0}}else{const n=r.set;o={...r,set:function(a){i.get(this).setValue(a),n==null||n.call(this,a)}}}return void Object.defineProperty(t,e,o)}}}var Oi=Object.defineProperty,Ti=Object.getOwnPropertyDescriptor,Ii=(s,t,e,i)=>{for(var r=i>1?void 0:i?Ti(t,e):t,o=s.length-1,n;o>=0;o--)(n=s[o])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&Oi(t,e,r),r};const be="application";class ot extends A{constructor(){super(...arguments),this.nodes=[],this.wrapperRef=me()}addChild(t){t.parent=this,this.nodes.push(t)}applyBranding(){if(!this.wrapperRef.value)return;const t=this.application.settings;t!=null&&t.branding&&ge(t.branding,this.wrapperRef.value)}applyStyles(){if(!this.wrapperRef.value)return;const t=this.application.styles(),e=this.wrapperRef.value;Object.entries(t).forEach(([i,r])=>{e.style.setProperty(`--${i}`,r)})}firstUpdated(t){this.applyBranding(),this.applyStyles()}render(){var i,r;const t=this.application.settings.components.conversation;return((r=(i=t==null?void 0:t.properties)==null?void 0:i.chat)==null?void 0:r.isThirdPartyWidget)?this.renderRoot.host.classList.add("third-party"):this.application.renderStrategy
|
287
|
+
*/function Pi({context:s}){return(t,e)=>{const i=new WeakMap;if(typeof e=="object")return e.addInitializer(function(){i.set(this,new Gt(this,{context:s}))}),{get(){return t.get.call(this)},set(r){var o;return(o=i.get(this))==null||o.setValue(r),t.set.call(this,r)},init(r){var o;return(o=i.get(this))==null||o.setValue(r),r}};{t.constructor.addInitializer(n=>{i.set(n,new Gt(n,{context:s}))});const r=Object.getOwnPropertyDescriptor(t,e);let o;if(r===void 0){const n=new WeakMap;o={get:function(){return n.get(this)},set:function(a){i.get(this).setValue(a),n.set(this,a)},configurable:!0,enumerable:!0}}else{const n=r.set;o={...r,set:function(a){i.get(this).setValue(a),n==null||n.call(this,a)}}}return void Object.defineProperty(t,e,o)}}}var Oi=Object.defineProperty,Ti=Object.getOwnPropertyDescriptor,Ii=(s,t,e,i)=>{for(var r=i>1?void 0:i?Ti(t,e):t,o=s.length-1,n;o>=0;o--)(n=s[o])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&Oi(t,e,r),r};const be="application";class ot extends A{constructor(){super(...arguments),this.nodes=[],this.wrapperRef=me()}addChild(t){t.parent=this,this.nodes.push(t)}applyBranding(){if(!this.wrapperRef.value)return;const t=this.application.settings;t!=null&&t.branding&&ge(t.branding,this.wrapperRef.value)}applyStyles(){if(!this.wrapperRef.value)return;const t=this.application.styles(),e=this.wrapperRef.value;Object.entries(t).forEach(([i,r])=>{e.style.setProperty(`--${i}`,r)})}firstUpdated(t){this.applyBranding(),this.applyStyles()}render(){var i,r;const t=this.application.settings.components.conversation;return((r=(i=t==null?void 0:t.properties)==null?void 0:i.chat)==null?void 0:r.isThirdPartyWidget)?this.renderRoot.host.classList.add("third-party"):this.application.renderStrategy===$.Trigger&&(this.renderRoot.host.classList.add("floating"),this.application.anchor==="BottomLeft"?this.renderRoot.host.classList.add("bottom-left"):this.application.anchor==="BottomRight"&&this.renderRoot.host.classList.add("bottom-right")),R`<div class="widget-container" ${ve(this.wrapperRef)}>
|
288
288
|
${xi(this.nodes,o=>o)}
|
289
289
|
</div>`}}ot.styles=N`
|
290
290
|
:host {
|
@@ -421,8 +421,8 @@
|
|
421
421
|
animation: slideDown 0.3s linear;
|
422
422
|
pointer-events: none;
|
423
423
|
}
|
424
|
-
`;Ii([m({attribute:!1}),Pi({context:be})],ot.prototype,"application",2);class Ri{constructor(){this.root=this.createRoot()}createComponentModel(t,e){this.root.application=e;const i=a=>{if(Array.isArray(a)){const[c,...h]=a;return{definitionId:c,overrides:h}}return{definitionId:a,overrides:[]}},r=(a,c,h,l)=>{h.forEach(d=>{const p=i(d),f=l[p.definitionId];if(!f){console.error(`No definition found for component type '${p.definitionId}'.`);return}const g=a.createNode(f.type,f.type);g&&(g.name=p.definitionId,g.application=e,f.properties&&g.writeProperties(f.properties),f.context&&g.writeContext(f.context),f.layout&&g.writeLayout(f.layout),c.addChild(g),f.children&&r(a,g,f.children,l))})},{entry:o,components:n}=t;return r(this,this.root,[o],n),this.root}createRoot(){return new ot}createNode(t,e){const i=this.resolveComponent(e);if(!i)return console.warn(`Unable to resolve component: ${e}`),new Et;const r=new i;return r.type=e,r.name=t,r}resolveComponent(t){return customElements.get(`ace-${t}`)}getRoot(){return this.root}}const $e=class{constructor(){this.components=new Map}getComponent(s){const t=this.components.get(s);return t||console.warn(`Unable to resolve component: ${s}. You most likely forgot to register the required plugin.`),t}registerComponent(s,t){this.components.set(s,t)}async loadComponents(){const s=[...this.components.entries()].map(([t,e])=>e.then(i=>{this.defineAsWebComponent(t,i.default)}));await Promise.all(s)}defineAsWebComponent(s,t){const e=$e.ResolveWebComponentName(s);customElements.get(e)||customElements.define(e,t)}};let we=$e;we.ResolveWebComponentName=s=>`ace-${s}`;var v=(s=>(s.Necessary="necessary",s.Functional="functional",s.Analytics="analytics",s))(v||{});class _e{constructor(t,e,i){this.disallowedKeys=[],this.widgetId=t,this.storage=e==="localStorage"?window.localStorage:window.sessionStorage,this.policy=i}set(t,e,i){if(!this.disallowedKeys.includes(t))if(this.policy[i]){const r={value:e,category:i};this.storage.setItem(this._prefixKey(t),JSON.stringify(r))}else console.warn(`Storage policy does not allow storing items in category: ${i}`)}get(t){const e=this.storage.getItem(this._prefixKey(t));if(!e)return null;try{const i=JSON.parse(e);return this.policy[i.category]?i.value:(console.warn(`Storage policy does not allow retrieving items from category: ${i.category}`),null)}catch{return null}}removeItem(t){this.storage.removeItem(this._prefixKey(t))}enforcePolicy(){var t;for(const[e,i]of Object.entries(this.storage)){const r=(t=JSON.parse(i))==null?void 0:t.category;this.policy[r]||this.storage.removeItem(e)}}updatePolicy(t){this.policy=t,this.enforcePolicy()}disallowKey(t){this.disallowedKeys.includes(t)||this.disallowedKeys.push(t),this.removeItem(t)}_prefixKey(t){return`ace_${this.widgetId.substring(0,7)}-${t}`}}class ki{constructor(){this.texts=new Map}loadTexts(t){this.texts=new Map(Object.entries(t))}get(t,e){const i=this.texts.get(t);return i||e||null}getOrFallback(t,e){return this.texts.get(t)||e}}class Ni{constructor(t){this.widget=t,this.name=t.name}open(){this.widget.appendToDOM()}close(){this.widget.hide()}setZIndex(t){this.widget.setZIndex(t)}}class Ae{constructor(t,e,i,r,o){this.id=t,this.name=e,this.container=i,this.settings=r,this.options=o,this.platform=new Ri,this.texts=new ki,this.renderStrategy=w.Inline,this.anchor="BottomRight",this.autoActivate=!1,this.plugins=[],this.componentResolver=new we,this.components=[],this.trigger=null,this.api=new Ni(this),this.renderStrategy=this.options.renderStrategy||w.Inline,this.triggerIcon=this.options.triggerIcon;const n={[v.Necessary]:!0,[v.Functional]:!0,[v.Analytics]:!0};this.storage=new _e(this.id,"sessionStorage",n),typeof o.autoActivate=="boolean"&&(this.autoActivate=o.autoActivate),o.anchor&&(this.anchor=o.anchor),this.container.register("$settings",r),this.texts.loadTexts(r.texts||{})}async activate(){if(await this.loadPlugins(),await this.componentResolver.loadComponents(),this.root=this.platform.createComponentModel(this.settings,this),this.container.setState(oe.Ready),this.autoActivate){const t=this.render();t&&this._getTargetElement().appendChild(t)}}async loadPlugins(){for await(const t of this.plugins)await t(this)}styles(){return this.settings.styles||{}}branding(){return this.settings.branding||{}}plugin(t){return this.plugins.push(t),this}appendToDOM(){this.root&&(this.root.classList.add("expanded"),this.root.classList.remove("hidden"),document.body.appendChild(this.root)),this.storage.set("open",!0,v.Necessary)}hide(){this.root&&(this.root.classList.add("hidden"),this.root.classList.remove("expanded")),this.storage.set("open",!1,v.Necessary)}setZIndex(t){this.root&&(this.root.style.zIndex=t.toString())}mute(){this.storage.set("muteAudioNotifications",!0,v.Necessary)}unmute(){this.storage.set("muteAudioNotifications",!1,v.Necessary)}registerComponent(t,e){this.componentResolver.registerComponent(t,e)}resolveComponent(t){return this.componentResolver.getComponent(t)}mountComponent(t){this.components.push(t)}getComponent(t){const e=this.components.find(i=>i.type===t);return e||null}_getTargetElement(){let t="bottom-right";if(this.anchor==="BottomRight"?t="bottom-right":this.anchor==="BottomLeft"&&(t="bottom-left"),this.renderStrategy===w.Trigger){let e=document.querySelector(`ace-trigger-slot.${t}`);return e||(e=new rt,e.anchor=this.anchor,document.body.appendChild(e)),e}return document.body}render(){if(this.renderStrategy===w.Trigger){const t=new b;return t.application=this,this.trigger=t,this.storage.get("open")&&this.trigger.toggleActive(),t}return this.root}}const Ui=s=>new F(s),xe=class{constructor(s=xe.endpoint){this._endpoint=s}async getSite(s){const e=await(await fetch(s)).json();return e?{id:e.id,triggers:e.triggers||[],apps:e.widgets.map(i=>{let r=w.Inline;return i.renderStrategy==="Trigger"&&(r=w.Trigger),{id:i.id,widgetId:i.widgetId,renderStrategy:r,autoActivate:i.autoActivate,anchor:i.anchor,triggerIcon:{type:"Telia",content:i.triggerIcon}}})}:null}async getWidget(s){const e=await(await fetch(`${this._endpoint}/widget/${s}`)).json();return e?{name:e.name,config:JSON.parse(e.configuration)}:null}};let F=xe;F.endpoint="https://widgets.ace.teliacompany.net/api";class Mi{constructor(t){this.site=t}storagePolicy(t){var i;(((i=this.site.environment)==null?void 0:i.applications)||[]).forEach(r=>{if(r.storage){const o={[v.Analytics]:t.includes("analytics"),[v.Necessary]:t.includes("necessary"),[v.Functional]:t.includes("functional")};r.storage.updatePolicy(o)}})}disallowStorageKey(t){var e;(((e=this.site.environment)==null?void 0:e.applications)||[]).forEach(i=>{i.storage&&i.storage.disallowKey(t)})}}class Ce{constructor(){this.applications=[],this.container=new $t("environment",this),this.bootstrapped=!1,this.site=null,this.widgetAPIHandlers=new Map,this.siteConfigurationHandlers=[],setTimeout(()=>{this.notifyWidgetsOfCreation()},1e3)}async bootstrap(){await this.activate(),this.siteConfigurationHandlers.forEach(t=>{this.site&&t(this.site.api)});for(const[t,e]of this.widgetAPIHandlers)e.forEach(i=>{i()});this.bootstrapped=!0}async activate(){var e;const t=this.applications.filter(i=>i.autoActivate);(((e=this.site)==null?void 0:e.triggers)||[]).filter(i=>i.triggerType==="visit").forEach(i=>{const r=window.location.pathname,o=i.condition.outputs||[];i.condition.type==="url"&&o.forEach(n=>{const a=n.action.type==="render_widget";if((n.value===r||n.value==="*")&&a){let h={widgetId:""};try{h=JSON.parse(n.action.data)}catch{h={widgetId:""}}const l=t.findIndex(p=>p.id===h.widgetId)>-1,d=this.applications.find(p=>p.id===h.widgetId);d&&!l&&(d.autoActivate=!0,t.push(d))}})});for await(const i of t)await i.activate()}notifyWidgetsOfCreation(){document.querySelectorAll("ace-widget").forEach(e=>{const i=this.applications.find(r=>r.name===e.name);i&&e.dispatchEvent(new CustomEvent("environment-created",{detail:{widget:i}}))})}configure(t){if(!this.site||!this.bootstrapped){this.siteConfigurationHandlers.push(t);return}t(this.site.api)}widget(t,e){const i=this.applications.find(r=>r.name===t);if(!i){const r=this.widgetAPIHandlers.get(t)||[];r.push(()=>{const o=this.applications.find(n=>n.name===t);e(o==null?void 0:o.api)}),this.widgetAPIHandlers.set(t,r);return}e(i==null?void 0:i.api)}registerApp(t,e,i,r){const o=new $t(e,this),n=new Ae(t,e,o,i,r);this.applications.push(n)}registerSite(t){this.site=t}plugin(t){return this.applications.forEach(e=>{e.plugin(t)}),this}}class Se{constructor(t){this.configurations=[],this.httpClient=new F,this.api=new Mi(this),this.triggers=[],this.httpClient=new F,typeof t=="string"?this.url=t:(t.httpClient&&(this.httpClient=t.httpClient),this.loadFromConfig(t))}async load(t){const e=await this.httpClient.getSite(t);if(!e){console.warn(`Unable to load site from the url provided: ${t}`);return}this.configurations=e.apps,this.triggers=e.triggers||[]}loadFromConfig(t){this.configurations=t.apps.map(e=>({id:"",renderStrategy:e.renderStrategy,widgetId:e.widgetId,autoActivate:e.autoActivate,anchor:e.anchor,triggerIcon:{type:"Telia",content:e.triggerIcon||"question"}}))}setHttpClient(t){this.httpClient=t}async bootstrap(t){var e;this.url&&await this.load(this.url),this.environment=new Ce,this.addGlobal(this.environment);for await(const i of this.configurations){const r=await this.httpClient.getWidget(i.widgetId);r&&((e=this.environment)==null||e.registerApp(i.widgetId,r.name,r.config,{renderStrategy:i.renderStrategy,triggerIcon:i.triggerIcon,autoActivate:i.autoActivate,anchor:i.anchor}))}t(this.environment),this.environment.registerSite(this),await this.environment.bootstrap()}addGlobal(t){const e=globalThis.ace;((e==null?void 0:e._w)||[]).forEach(([i,r])=>{t.widget(i,r)}),((e==null?void 0:e._c)||[]).forEach(i=>{t.configure(i)}),globalThis.ace=t}}var ji=Object.defineProperty,Hi=Object.getOwnPropertyDescriptor,Pt=(s,t,e,i)=>{for(var r=i>1?void 0:i?Hi(t,e):t,o=s.length-1,n;o>=0;o--)(n=s[o])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&ji(t,e,r),r};class M extends A{constructor(){super(),this.status="deactivated",this.addEventListener("environment-created",this.onEnvironmentCreated)}async connectedCallback(){super.connectedCallback(),await this.getGlobalEnvironment()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("environment-created",this.onEnvironmentCreated)}async onEnvironmentCreated(t){this.widget=t.detail.widget,await this.activate(),this.requestUpdate()}async activate(){this.widget&&(await this.widget.activate(),this.status="activated")}async getGlobalEnvironment(){const t=globalThis.widgets;t&&(this.widget=t.applications.find(e=>e.name===this.name),await this.activate())}render(){if(!this.widget||this.status!=="activated")return u;if(this.widget.renderStrategy===w.Trigger){const t=new b;return t.application=this.widget,t}return this.widget.render()}}M.styles=[N`
|
424
|
+
`;Ii([v({attribute:!1}),Pi({context:be})],ot.prototype,"application",2);class Ri{constructor(){this.root=this.createRoot()}createComponentModel(t,e){this.root.application=e;const i=a=>{if(Array.isArray(a)){const[c,...h]=a;return{definitionId:c,overrides:h}}return{definitionId:a,overrides:[]}},r=(a,c,h,l)=>{h.forEach(d=>{const p=i(d),f=l[p.definitionId];if(!f){console.error(`No definition found for component type '${p.definitionId}'.`);return}const g=a.createNode(f.type,f.type);g&&(g.name=p.definitionId,g.application=e,f.properties&&g.writeProperties(f.properties),f.context&&g.writeContext(f.context),f.layout&&g.writeLayout(f.layout),c.addChild(g),f.children&&r(a,g,f.children,l))})},{entry:o,components:n}=t;return r(this,this.root,[o],n),this.root}createRoot(){return typeof window<"u"&&(window.customElements.get("ace-wrapper")||window.customElements.define("ace-wrapper",ot)),document.createElement("ace-wrapper")}createNode(t,e){if(!this.resolveComponent(e))return console.warn(`Unable to resolve component: ${e}`),new Et;const r=document.createElement(`ace-${e}`);return r.type=e,r.name=t,r}resolveComponent(t){return customElements.get(`ace-${t}`)}getRoot(){return this.root}}const we=class{constructor(){this.components=new Map}getComponent(s){const t=this.components.get(s);return t||console.warn(`Unable to resolve component: ${s}. You most likely forgot to register the required plugin.`),t}registerComponent(s,t){this.components.set(s,t)}async loadComponents(){const s=[...this.components.entries()].map(([t,e])=>e.then(i=>{this.defineAsWebComponent(t,i.default)}));await Promise.all(s)}defineAsWebComponent(s,t){const e=we.ResolveWebComponentName(s);customElements.get(e)||customElements.define(e,t)}};let $e=we;$e.ResolveWebComponentName=s=>`ace-${s}`;var m=(s=>(s.Necessary="necessary",s.Functional="functional",s.Analytics="analytics",s))(m||{});class _e{constructor(t,e,i){this.disallowedKeys=[],this.widgetId=t,this.storage=e==="localStorage"?window.localStorage:window.sessionStorage,this.policy=i}set(t,e,i){if(!this.disallowedKeys.includes(t))if(this.policy[i]){const r={value:e,category:i};this.storage.setItem(this._prefixKey(t),JSON.stringify(r))}else console.warn(`Storage policy does not allow storing items in category: ${i}`)}get(t){const e=this.storage.getItem(this._prefixKey(t));if(!e)return null;try{const i=JSON.parse(e);return this.policy[i.category]?i.value:(console.warn(`Storage policy does not allow retrieving items from category: ${i.category}`),null)}catch{return null}}removeItem(t){this.storage.removeItem(this._prefixKey(t))}enforcePolicy(){var t;for(const[e,i]of Object.entries(this.storage)){const r=(t=JSON.parse(i))==null?void 0:t.category;this.policy[r]||this.storage.removeItem(e)}}updatePolicy(t){this.policy=t,this.enforcePolicy()}disallowKey(t){this.disallowedKeys.includes(t)||this.disallowedKeys.push(t),this.removeItem(t)}_prefixKey(t){return`ace_${this.widgetId.substring(0,7)}-${t}`}}class ki{constructor(){this.texts=new Map}loadTexts(t){this.texts=new Map(Object.entries(t))}get(t,e){const i=this.texts.get(t);return i||e||null}getOrFallback(t,e){return this.texts.get(t)||e}}class Ni{constructor(t){this.widget=t,this.name=t.name}open(){this.widget.appendToDOM()}close(){this.widget.hide()}setZIndex(t){this.widget.setZIndex(t)}}class Ae{constructor(t,e,i,r,o){this.id=t,this.name=e,this.container=i,this.settings=r,this.options=o,this.platform=new Ri,this.texts=new ki,this.renderStrategy=$.Inline,this.anchor="BottomRight",this.autoActivate=!1,this.plugins=[],this.componentResolver=new $e,this.components=[],this.trigger=null,this.api=new Ni(this),this.onMessageReceived=async a=>{var h;const c=a.data;switch(console.log("postmessage received",a,a.data),c.type){case"deactivate-widget":{console.log("deactivating widget");const l=this.storage.get("open");this.hide(),(h=this.trigger)==null||h.hideTrigger(),l&&this.storage.set("open",!0,m.Necessary);return}default:return}},this.renderStrategy=this.options.renderStrategy||$.Inline,this.triggerIcon=this.options.triggerIcon;const n={[m.Necessary]:!0,[m.Functional]:!0,[m.Analytics]:!0};this.storage=new _e(this.id,"sessionStorage",n),typeof o.autoActivate=="boolean"&&(this.autoActivate=o.autoActivate),o.anchor&&(this.anchor=o.anchor),this.container.register("$settings",r),this.texts.loadTexts(r.texts||{}),window.addEventListener("message",this.onMessageReceived)}async activate(){if(await this.loadPlugins(),await this.componentResolver.loadComponents(),this.root=this.platform.createComponentModel(this.settings,this),this.container.setState(oe.Ready),this.autoActivate){const t=this.render();t&&this._getTargetElement().appendChild(t)}}async loadPlugins(){for await(const t of this.plugins)await t(this)}styles(){return this.settings.styles||{}}branding(){return this.settings.branding||{}}plugin(t){return this.plugins.push(t),this}appendToDOM(){this.root&&(this.root.classList.add("expanded"),this.root.classList.remove("hidden"),document.body.appendChild(this.root)),this.storage.set("open",!0,m.Necessary)}hide(){this.root&&(this.root.classList.add("hidden"),this.root.classList.remove("expanded")),this.storage.set("open",!1,m.Necessary)}setZIndex(t){this.root&&(this.root.style.zIndex=t.toString())}mute(){this.storage.set("muteAudioNotifications",!0,m.Necessary)}unmute(){this.storage.set("muteAudioNotifications",!1,m.Necessary)}registerComponent(t,e){this.componentResolver.registerComponent(t,e)}resolveComponent(t){return this.componentResolver.getComponent(t)}mountComponent(t){this.components.push(t)}getComponent(t){const e=this.components.find(i=>i.type===t);return e||null}_getTargetElement(){let t="bottom-right";if(this.anchor==="BottomRight"?t="bottom-right":this.anchor==="BottomLeft"&&(t="bottom-left"),this.renderStrategy===$.Trigger){let e=document.querySelector(`ace-trigger-slot.${t}`);return e||(e=new rt,e.anchor=this.anchor,document.body.appendChild(e)),e}return document.body}render(){if(this.renderStrategy===$.Trigger){const t=new b;return t.application=this,this.trigger=t,this.storage.get("open")&&this.trigger.toggleActive(),t}return this.root}}const Ui=s=>new F(s),xe=class{constructor(s=xe.endpoint){this._endpoint=s}async getSite(s){const e=await(await fetch(s)).json();return e?{id:e.id,triggers:e.triggers||[],apps:e.widgets.map(i=>{let r=$.Inline;return i.renderStrategy==="Trigger"&&(r=$.Trigger),{id:i.id,widgetId:i.widgetId,renderStrategy:r,autoActivate:i.autoActivate,anchor:i.anchor,triggerIcon:{type:"Telia",content:i.triggerIcon}}})}:null}async getWidget(s){const e=await(await fetch(`${this._endpoint}/widget/${s}`)).json();return e?{name:e.name,config:JSON.parse(e.configuration)}:null}};let F=xe;F.endpoint="https://widgets.ace.teliacompany.net/api";class Mi{constructor(t){this.site=t}storagePolicy(t){var i;(((i=this.site.environment)==null?void 0:i.applications)||[]).forEach(r=>{if(r.storage){const o={[m.Analytics]:t.includes("analytics"),[m.Necessary]:t.includes("necessary"),[m.Functional]:t.includes("functional")};r.storage.updatePolicy(o)}})}disallowStorageKey(t){var e;(((e=this.site.environment)==null?void 0:e.applications)||[]).forEach(i=>{i.storage&&i.storage.disallowKey(t)})}}class Ce{constructor(){this.applications=[],this.container=new wt("environment",this),this.bootstrapped=!1,this.site=null,this.widgetAPIHandlers=new Map,this.siteConfigurationHandlers=[],setTimeout(()=>{this.notifyWidgetsOfCreation()},1e3)}async bootstrap(){await this.activate(),this.siteConfigurationHandlers.forEach(t=>{this.site&&t(this.site.api)});for(const[t,e]of this.widgetAPIHandlers)e.forEach(i=>{i()});this.bootstrapped=!0}async activate(){var e;const t=this.applications.filter(i=>i.autoActivate);(((e=this.site)==null?void 0:e.triggers)||[]).filter(i=>i.triggerType==="visit").forEach(i=>{const r=window.location.pathname,o=i.condition.outputs||[];i.condition.type==="url"&&o.forEach(n=>{const a=n.action.type==="render_widget";if((n.value===r||n.value==="*")&&a){let h={widgetId:""};try{h=JSON.parse(n.action.data)}catch{h={widgetId:""}}const l=t.findIndex(p=>p.id===h.widgetId)>-1,d=this.applications.find(p=>p.id===h.widgetId);d&&!l&&(d.autoActivate=!0,t.push(d))}})});for await(const i of t)await i.activate()}notifyWidgetsOfCreation(){document.querySelectorAll("ace-widget").forEach(e=>{const i=this.applications.find(r=>r.name===e.name);i&&e.dispatchEvent(new CustomEvent("environment-created",{detail:{widget:i}}))})}configure(t){if(!this.site||!this.bootstrapped){this.siteConfigurationHandlers.push(t);return}t(this.site.api)}widget(t,e){const i=this.applications.find(r=>r.name===t);if(!i){const r=this.widgetAPIHandlers.get(t)||[];r.push(()=>{const o=this.applications.find(n=>n.name===t);e(o==null?void 0:o.api)}),this.widgetAPIHandlers.set(t,r);return}e(i==null?void 0:i.api)}registerApp(t,e,i,r){const o=new wt(e,this),n=new Ae(t,e,o,i,r);this.applications.push(n)}registerSite(t){this.site=t}plugin(t){return this.applications.forEach(e=>{e.plugin(t)}),this}}class Se{constructor(t){this.configurations=[],this.httpClient=new F,this.api=new Mi(this),this.triggers=[],this.httpClient=new F,typeof t=="string"?this.url=t:(t.httpClient&&(this.httpClient=t.httpClient),this.loadFromConfig(t))}async load(t){const e=await this.httpClient.getSite(t);if(!e){console.warn(`Unable to load site from the url provided: ${t}`);return}this.configurations=e.apps,this.triggers=e.triggers||[]}loadFromConfig(t){this.configurations=t.apps.map(e=>({id:"",renderStrategy:e.renderStrategy,widgetId:e.widgetId,autoActivate:e.autoActivate,anchor:e.anchor,triggerIcon:{type:"Telia",content:e.triggerIcon||"question"}}))}setHttpClient(t){this.httpClient=t}async bootstrap(t){var e;this.url&&await this.load(this.url),this.environment=new Ce,this.addGlobal(this.environment);for await(const i of this.configurations){const r=await this.httpClient.getWidget(i.widgetId);r&&((e=this.environment)==null||e.registerApp(i.widgetId,r.name,r.config,{renderStrategy:i.renderStrategy,triggerIcon:i.triggerIcon,autoActivate:i.autoActivate,anchor:i.anchor}))}t(this.environment),this.environment.registerSite(this),await this.environment.bootstrap()}addGlobal(t){const e=globalThis.ace;((e==null?void 0:e._w)||[]).forEach(([i,r])=>{t.widget(i,r)}),((e==null?void 0:e._c)||[]).forEach(i=>{t.configure(i)}),globalThis.ace=t}}var ji=Object.defineProperty,Hi=Object.getOwnPropertyDescriptor,Pt=(s,t,e,i)=>{for(var r=i>1?void 0:i?Hi(t,e):t,o=s.length-1,n;o>=0;o--)(n=s[o])&&(r=(i?n(t,e,r):n(r))||r);return i&&r&&ji(t,e,r),r};class M extends A{constructor(){super(),this.status="deactivated",this.addEventListener("environment-created",this.onEnvironmentCreated)}async connectedCallback(){super.connectedCallback(),await this.getGlobalEnvironment()}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("environment-created",this.onEnvironmentCreated)}async onEnvironmentCreated(t){this.widget=t.detail.widget,await this.activate(),this.requestUpdate()}async activate(){this.widget&&(await this.widget.activate(),this.status="activated")}async getGlobalEnvironment(){const t=globalThis.widgets;t&&(this.widget=t.applications.find(e=>e.name===this.name),await this.activate())}render(){if(!this.widget||this.status!=="activated")return u;if(this.widget.renderStrategy===$.Trigger){const t=new b;return t.application=this.widget,t}return this.widget.render()}}M.styles=[N`
|
425
425
|
:host {
|
426
426
|
display: block;
|
427
427
|
}
|
428
|
-
`];Pt([
|
428
|
+
`];Pt([v({attribute:!0})],M.prototype,"name",2);Pt([U()],M.prototype,"widget",2);Pt([U()],M.prototype,"status",2);customElements.get("ace-trigger-slot")||customElements.define("ace-trigger-slot",rt);customElements.get("ace-trigger")||customElements.define("ace-trigger",b);customElements.get("ace-unresolved-component")||customElements.define("ace-unresolved-component",Et);customElements.get("ace-wrapper")||customElements.define("ace-wrapper",ot);customElements.get("ace-widget")||customElements.define("ace-widget",M);const Li=async(s,t,e={})=>{const i=new Se(s);e.httpClient&&i.setHttpClient(e.httpClient),await i.bootstrap(t)};exports.AceWidget=M;exports.Application=Ae;exports.Container=wt;exports.Environment=Ce;exports.HttpClient=F;exports.Site=Se;exports.StorageCategory=m;exports.StorageService=_e;exports.Trigger=b;exports.WidgetComponent=ye;exports.applicationContext=be;exports.bootstrap=Li;exports.createHttpClient=Ui;
|
package/index.mjs
CHANGED
@@ -53,7 +53,7 @@ function G(s, t, e) {
|
|
53
53
|
(o || !(i in t)) && (o || (o = Array.prototype.slice.call(t, 0, i)), o[i] = t[i]);
|
54
54
|
return s.concat(o || Array.prototype.slice.call(t));
|
55
55
|
}
|
56
|
-
function
|
56
|
+
function $(s) {
|
57
57
|
return typeof s == "function";
|
58
58
|
}
|
59
59
|
function Qt(s) {
|
@@ -93,8 +93,8 @@ var it = function() {
|
|
93
93
|
var h = c.value;
|
94
94
|
h.remove(this);
|
95
95
|
}
|
96
|
-
} catch (
|
97
|
-
t = { error:
|
96
|
+
} catch (y) {
|
97
|
+
t = { error: y };
|
98
98
|
} finally {
|
99
99
|
try {
|
100
100
|
c && !c.done && (e = a.return) && e.call(a);
|
@@ -106,11 +106,11 @@ var it = function() {
|
|
106
106
|
else
|
107
107
|
n.remove(this);
|
108
108
|
var l = this.initialTeardown;
|
109
|
-
if (
|
109
|
+
if ($(l))
|
110
110
|
try {
|
111
111
|
l();
|
112
|
-
} catch (
|
113
|
-
o =
|
112
|
+
} catch (y) {
|
113
|
+
o = y instanceof nt ? y.errors : [y];
|
114
114
|
}
|
115
115
|
var d = this._finalizers;
|
116
116
|
if (d) {
|
@@ -120,12 +120,12 @@ var it = function() {
|
|
120
120
|
var g = f.value;
|
121
121
|
try {
|
122
122
|
Pt(g);
|
123
|
-
} catch (
|
124
|
-
o = o ?? [],
|
123
|
+
} catch (y) {
|
124
|
+
o = o ?? [], y instanceof nt ? o = G(G([], J(o)), J(y.errors)) : o.push(y);
|
125
125
|
}
|
126
126
|
}
|
127
|
-
} catch (
|
128
|
-
i = { error:
|
127
|
+
} catch (y) {
|
128
|
+
i = { error: y };
|
129
129
|
} finally {
|
130
130
|
try {
|
131
131
|
f && !f.done && (r = p.return) && r.call(p);
|
@@ -169,10 +169,10 @@ var it = function() {
|
|
169
169
|
}(), s;
|
170
170
|
}(), te = it.EMPTY;
|
171
171
|
function ee(s) {
|
172
|
-
return s instanceof it || s && "closed" in s &&
|
172
|
+
return s instanceof it || s && "closed" in s && $(s.remove) && $(s.add) && $(s.unsubscribe);
|
173
173
|
}
|
174
174
|
function Pt(s) {
|
175
|
-
|
175
|
+
$(s) ? s() : s.unsubscribe();
|
176
176
|
}
|
177
177
|
var ie = {
|
178
178
|
onUnhandledError: null,
|
@@ -193,7 +193,7 @@ var ie = {
|
|
193
193
|
},
|
194
194
|
delegate: void 0
|
195
195
|
};
|
196
|
-
function
|
196
|
+
function $e(s) {
|
197
197
|
yt.setTimeout(function() {
|
198
198
|
throw s;
|
199
199
|
});
|
@@ -273,7 +273,7 @@ var Ae = function() {
|
|
273
273
|
W(t, s);
|
274
274
|
function t(e, i, r) {
|
275
275
|
var o = s.call(this) || this, n;
|
276
|
-
if (
|
276
|
+
if ($(e) || !e)
|
277
277
|
n = {
|
278
278
|
next: e ?? void 0,
|
279
279
|
error: i ?? void 0,
|
@@ -294,7 +294,7 @@ var Ae = function() {
|
|
294
294
|
return t;
|
295
295
|
}(se);
|
296
296
|
function q(s) {
|
297
|
-
|
297
|
+
$e(s);
|
298
298
|
}
|
299
299
|
function xe(s) {
|
300
300
|
throw s;
|
@@ -382,7 +382,7 @@ function It(s) {
|
|
382
382
|
return (t = s ?? ie.Promise) !== null && t !== void 0 ? t : Promise;
|
383
383
|
}
|
384
384
|
function Oe(s) {
|
385
|
-
return s &&
|
385
|
+
return s && $(s.next) && $(s.error) && $(s.complete);
|
386
386
|
}
|
387
387
|
function Te(s) {
|
388
388
|
return s && s instanceof se || Oe(s) && ee(s);
|
@@ -391,7 +391,7 @@ var Ie = Qt(function(s) {
|
|
391
391
|
return function() {
|
392
392
|
s(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
|
393
393
|
};
|
394
|
-
}),
|
394
|
+
}), wt = function(s) {
|
395
395
|
W(t, s);
|
396
396
|
function t() {
|
397
397
|
var e = s.call(this) || this;
|
@@ -490,7 +490,7 @@ var Ie = Qt(function(s) {
|
|
490
490
|
var i, r;
|
491
491
|
return (r = (i = this.source) === null || i === void 0 ? void 0 : i.subscribe(e)) !== null && r !== void 0 ? r : te;
|
492
492
|
}, t;
|
493
|
-
}(
|
493
|
+
}(wt), re = function(s) {
|
494
494
|
W(t, s);
|
495
495
|
function t(e) {
|
496
496
|
var i = s.call(this) || this;
|
@@ -513,7 +513,7 @@ var Ie = Qt(function(s) {
|
|
513
513
|
}, t.prototype.next = function(e) {
|
514
514
|
s.prototype.next.call(this, this._value = e);
|
515
515
|
}, t;
|
516
|
-
}(
|
516
|
+
}(wt), oe = /* @__PURE__ */ ((s) => (s.Loading = "loading", s.Ready = "ready", s))(oe || {});
|
517
517
|
class kt {
|
518
518
|
constructor(t, e) {
|
519
519
|
this.state = new re(
|
@@ -539,7 +539,7 @@ class kt {
|
|
539
539
|
* Copyright 2019 Google LLC
|
540
540
|
* SPDX-License-Identifier: BSD-3-Clause
|
541
541
|
*/
|
542
|
-
const Z = globalThis,
|
542
|
+
const Z = globalThis, $t = Z.ShadowRoot && (Z.ShadyCSS === void 0 || Z.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, _t = Symbol(), Nt = /* @__PURE__ */ new WeakMap();
|
543
543
|
let ne = class {
|
544
544
|
constructor(t, e, i) {
|
545
545
|
if (this._$cssResult$ = !0, i !== _t)
|
@@ -549,7 +549,7 @@ let ne = class {
|
|
549
549
|
get styleSheet() {
|
550
550
|
let t = this.o;
|
551
551
|
const e = this.t;
|
552
|
-
if (
|
552
|
+
if ($t && t === void 0) {
|
553
553
|
const i = e !== void 0 && e.length === 1;
|
554
554
|
i && (t = Nt.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), i && Nt.set(e, t));
|
555
555
|
}
|
@@ -569,14 +569,14 @@ const Re = (s) => new ne(typeof s == "string" ? s : s + "", void 0, _t), N = (s,
|
|
569
569
|
})(r) + s[o + 1], s[0]);
|
570
570
|
return new ne(e, s, _t);
|
571
571
|
}, ke = (s, t) => {
|
572
|
-
if (
|
572
|
+
if ($t)
|
573
573
|
s.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
|
574
574
|
else
|
575
575
|
for (const e of t) {
|
576
576
|
const i = document.createElement("style"), r = Z.litNonce;
|
577
577
|
r !== void 0 && i.setAttribute("nonce", r), i.textContent = e.cssText, s.appendChild(i);
|
578
578
|
}
|
579
|
-
}, Ut =
|
579
|
+
}, Ut = $t ? (s) => s : (s) => s instanceof CSSStyleSheet ? ((t) => {
|
580
580
|
let e = "";
|
581
581
|
for (const i of t.cssRules)
|
582
582
|
e += i.cssText;
|
@@ -1142,7 +1142,7 @@ const Ge = { attribute: !0, type: String, converter: X, reflect: !1, hasChanged:
|
|
1142
1142
|
}
|
1143
1143
|
throw Error("Unsupported decorator location: " + i);
|
1144
1144
|
};
|
1145
|
-
function
|
1145
|
+
function v(s) {
|
1146
1146
|
return (t, e) => typeof e == "object" ? Xe(s, t, e) : ((i, r, o) => {
|
1147
1147
|
const n = r.hasOwnProperty(o);
|
1148
1148
|
return r.constructor.createProperty(o, n ? { ...i, wrapped: !0 } : i), n ? Object.getOwnPropertyDescriptor(r, o) : void 0;
|
@@ -1154,7 +1154,7 @@ function m(s) {
|
|
1154
1154
|
* SPDX-License-Identifier: BSD-3-Clause
|
1155
1155
|
*/
|
1156
1156
|
function U(s) {
|
1157
|
-
return
|
1157
|
+
return v({ ...s, state: !0, attribute: !1 });
|
1158
1158
|
}
|
1159
1159
|
var Qe = Object.defineProperty, ti = Object.getOwnPropertyDescriptor, ei = (s, t, e, i) => {
|
1160
1160
|
for (var r = i > 1 ? void 0 : i ? ti(t, e) : t, o = s.length - 1, n; o >= 0; o--)
|
@@ -1193,7 +1193,7 @@ rt.styles = [
|
|
1193
1193
|
`
|
1194
1194
|
];
|
1195
1195
|
ei([
|
1196
|
-
|
1196
|
+
v({ attribute: !0 })
|
1197
1197
|
], rt.prototype, "anchor", 2);
|
1198
1198
|
/**
|
1199
1199
|
* @license
|
@@ -1608,7 +1608,7 @@ var fi = Object.defineProperty, gi = Object.getOwnPropertyDescriptor, V = (s, t,
|
|
1608
1608
|
};
|
1609
1609
|
class A extends _ {
|
1610
1610
|
constructor() {
|
1611
|
-
super(...arguments), this.active = !1, this.triggerVisible = !0, this.loaded = !1, this.containerRef = me(), this.widgetActive$ = new re(!1), this.componentIsDestroyed$ = new
|
1611
|
+
super(...arguments), this.active = !1, this.triggerVisible = !0, this.loaded = !1, this.containerRef = me(), this.widgetActive$ = new re(!1), this.componentIsDestroyed$ = new wt();
|
1612
1612
|
}
|
1613
1613
|
async connectedCallback() {
|
1614
1614
|
super.connectedCallback(), this.icon = await this._renderSymbol(), this.loaded = !0, this._applyBranding();
|
@@ -1857,7 +1857,7 @@ A.styles = [
|
|
1857
1857
|
`
|
1858
1858
|
];
|
1859
1859
|
V([
|
1860
|
-
|
1860
|
+
v({ attribute: !1 })
|
1861
1861
|
], A.prototype, "application", 2);
|
1862
1862
|
V([
|
1863
1863
|
U()
|
@@ -1916,19 +1916,19 @@ const yi = (s) => {
|
|
1916
1916
|
}
|
1917
1917
|
`
|
1918
1918
|
], E([
|
1919
|
-
|
1919
|
+
v()
|
1920
1920
|
], t.prototype, "properties", 2), E([
|
1921
|
-
|
1921
|
+
v()
|
1922
1922
|
], t.prototype, "context", 2), E([
|
1923
|
-
|
1923
|
+
v()
|
1924
1924
|
], t.prototype, "layout", 2), E([
|
1925
|
-
|
1925
|
+
v()
|
1926
1926
|
], t.prototype, "name", 2), E([
|
1927
|
-
|
1927
|
+
v()
|
1928
1928
|
], t.prototype, "type", 2), E([
|
1929
|
-
|
1929
|
+
v({ attribute: !1 })
|
1930
1930
|
], t.prototype, "application", 2), E([
|
1931
|
-
|
1931
|
+
v({ attribute: !1 })
|
1932
1932
|
], t.prototype, "parent", 2), t;
|
1933
1933
|
};
|
1934
1934
|
class St extends yi(_) {
|
@@ -1955,13 +1955,13 @@ function* bi(s, t) {
|
|
1955
1955
|
yield t(i, e++);
|
1956
1956
|
}
|
1957
1957
|
}
|
1958
|
-
var
|
1958
|
+
var w = /* @__PURE__ */ ((s) => (s.Inline = "inline", s.Trigger = "trigger", s))(w || {});
|
1959
1959
|
/**
|
1960
1960
|
* @license
|
1961
1961
|
* Copyright 2021 Google LLC
|
1962
1962
|
* SPDX-License-Identifier: BSD-3-Clause
|
1963
1963
|
*/
|
1964
|
-
let
|
1964
|
+
let wi = class extends Event {
|
1965
1965
|
constructor(t, e, i) {
|
1966
1966
|
super("context-request", { bubbles: !0, composed: !0 }), this.context = t, this.callback = e, this.subscribe = i ?? !1;
|
1967
1967
|
}
|
@@ -1976,7 +1976,7 @@ let $i = class extends Event {
|
|
1976
1976
|
* Copyright 2021 Google LLC
|
1977
1977
|
* SPDX-License-Identifier: BSD-3-Clause
|
1978
1978
|
*/
|
1979
|
-
class
|
1979
|
+
class $i {
|
1980
1980
|
get value() {
|
1981
1981
|
return this.o;
|
1982
1982
|
}
|
@@ -2016,7 +2016,7 @@ let _i = class extends Event {
|
|
2016
2016
|
super("context-provider", { bubbles: !0, composed: !0 }), this.context = t;
|
2017
2017
|
}
|
2018
2018
|
};
|
2019
|
-
class Gt extends
|
2019
|
+
class Gt extends $i {
|
2020
2020
|
constructor(t, e, i) {
|
2021
2021
|
var r, o;
|
2022
2022
|
super(e.context !== void 0 ? e.initialValue : i), this.onContextRequest = (n) => {
|
@@ -2028,7 +2028,7 @@ class Gt extends wi {
|
|
2028
2028
|
return;
|
2029
2029
|
const c = /* @__PURE__ */ new Set();
|
2030
2030
|
for (const [h, { consumerHost: l }] of this.subscriptions)
|
2031
|
-
c.has(h) || (c.add(h), l.dispatchEvent(new
|
2031
|
+
c.has(h) || (c.add(h), l.dispatchEvent(new wi(this.context, h, !0)));
|
2032
2032
|
n.stopPropagation();
|
2033
2033
|
}, this.host = t, e.context !== void 0 ? this.context = e.context : this.context = e, this.attachListeners(), (o = (r = this.host).addController) == null || o.call(r, this);
|
2034
2034
|
}
|
@@ -2115,7 +2115,7 @@ class ot extends _ {
|
|
2115
2115
|
render() {
|
2116
2116
|
var i, r;
|
2117
2117
|
const t = this.application.settings.components.conversation;
|
2118
|
-
return ((r = (i = t == null ? void 0 : t.properties) == null ? void 0 : i.chat) == null ? void 0 : r.isThirdPartyWidget) ? this.renderRoot.host.classList.add("third-party") : this.application.renderStrategy ===
|
2118
|
+
return ((r = (i = t == null ? void 0 : t.properties) == null ? void 0 : i.chat) == null ? void 0 : r.isThirdPartyWidget) ? this.renderRoot.host.classList.add("third-party") : this.application.renderStrategy === w.Trigger && (this.renderRoot.host.classList.add("floating"), this.application.anchor === "BottomLeft" ? this.renderRoot.host.classList.add("bottom-left") : this.application.anchor === "BottomRight" && this.renderRoot.host.classList.add("bottom-right")), R`<div class="widget-container" ${ve(this.wrapperRef)}>
|
2119
2119
|
${bi(this.nodes, (o) => o)}
|
2120
2120
|
</div>`;
|
2121
2121
|
}
|
@@ -2257,7 +2257,7 @@ ot.styles = N`
|
|
2257
2257
|
}
|
2258
2258
|
`;
|
2259
2259
|
Si([
|
2260
|
-
|
2260
|
+
v({ attribute: !1 }),
|
2261
2261
|
Ai({ context: Ei })
|
2262
2262
|
], ot.prototype, "application", 2);
|
2263
2263
|
class Pi {
|
@@ -2300,13 +2300,14 @@ class Pi {
|
|
2300
2300
|
return r(this, this.root, [o], n), this.root;
|
2301
2301
|
}
|
2302
2302
|
createRoot() {
|
2303
|
-
return
|
2303
|
+
return typeof window < "u" && (window.customElements.get("ace-wrapper") || window.customElements.define("ace-wrapper", ot)), document.createElement("ace-wrapper");
|
2304
2304
|
}
|
2305
2305
|
createNode(t, e) {
|
2306
|
-
|
2307
|
-
if (!i)
|
2306
|
+
if (!this.resolveComponent(e))
|
2308
2307
|
return console.warn(`Unable to resolve component: ${e}`), new St();
|
2309
|
-
const r =
|
2308
|
+
const r = document.createElement(
|
2309
|
+
`ace-${e}`
|
2310
|
+
);
|
2310
2311
|
return r.type = e, r.name = t, r;
|
2311
2312
|
}
|
2312
2313
|
resolveComponent(t) {
|
@@ -2342,7 +2343,7 @@ const ye = class {
|
|
2342
2343
|
};
|
2343
2344
|
let be = ye;
|
2344
2345
|
be.ResolveWebComponentName = (s) => `ace-${s}`;
|
2345
|
-
var
|
2346
|
+
var m = /* @__PURE__ */ ((s) => (s.Necessary = "necessary", s.Functional = "functional", s.Analytics = "analytics", s))(m || {});
|
2346
2347
|
class Oi {
|
2347
2348
|
constructor(t, e, i) {
|
2348
2349
|
this.disallowedKeys = [], this.widgetId = t, this.storage = e === "localStorage" ? window.localStorage : window.sessionStorage, this.policy = i;
|
@@ -2421,13 +2422,26 @@ class Ii {
|
|
2421
2422
|
}
|
2422
2423
|
class Ri {
|
2423
2424
|
constructor(t, e, i, r, o) {
|
2424
|
-
this.id = t, this.name = e, this.container = i, this.settings = r, this.options = o, this.platform = new Pi(), this.texts = new Ti(), this.renderStrategy =
|
2425
|
+
this.id = t, this.name = e, this.container = i, this.settings = r, this.options = o, this.platform = new Pi(), this.texts = new Ti(), this.renderStrategy = w.Inline, this.anchor = "BottomRight", this.autoActivate = !1, this.plugins = [], this.componentResolver = new be(), this.components = [], this.trigger = null, this.api = new Ii(this), this.onMessageReceived = async (a) => {
|
2426
|
+
var h;
|
2427
|
+
const c = a.data;
|
2428
|
+
switch (console.log("postmessage received", a, a.data), c.type) {
|
2429
|
+
case "deactivate-widget": {
|
2430
|
+
console.log("deactivating widget");
|
2431
|
+
const l = this.storage.get("open");
|
2432
|
+
this.hide(), (h = this.trigger) == null || h.hideTrigger(), l && this.storage.set("open", !0, m.Necessary);
|
2433
|
+
return;
|
2434
|
+
}
|
2435
|
+
default:
|
2436
|
+
return;
|
2437
|
+
}
|
2438
|
+
}, this.renderStrategy = this.options.renderStrategy || w.Inline, this.triggerIcon = this.options.triggerIcon;
|
2425
2439
|
const n = {
|
2426
|
-
[
|
2427
|
-
[
|
2428
|
-
[
|
2440
|
+
[m.Necessary]: !0,
|
2441
|
+
[m.Functional]: !0,
|
2442
|
+
[m.Analytics]: !0
|
2429
2443
|
};
|
2430
|
-
this.storage = new Oi(this.id, "sessionStorage", n), typeof o.autoActivate == "boolean" && (this.autoActivate = o.autoActivate), o.anchor && (this.anchor = o.anchor), this.container.register("$settings", r), this.texts.loadTexts(r.texts || {});
|
2444
|
+
this.storage = new Oi(this.id, "sessionStorage", n), typeof o.autoActivate == "boolean" && (this.autoActivate = o.autoActivate), o.anchor && (this.anchor = o.anchor), this.container.register("$settings", r), this.texts.loadTexts(r.texts || {}), window.addEventListener("message", this.onMessageReceived);
|
2431
2445
|
}
|
2432
2446
|
async activate() {
|
2433
2447
|
if (await this.loadPlugins(), await this.componentResolver.loadComponents(), this.root = this.platform.createComponentModel(this.settings, this), this.container.setState(oe.Ready), this.autoActivate) {
|
@@ -2449,22 +2463,22 @@ class Ri {
|
|
2449
2463
|
return this.plugins.push(t), this;
|
2450
2464
|
}
|
2451
2465
|
appendToDOM() {
|
2452
|
-
this.root && (this.root.classList.add("expanded"), this.root.classList.remove("hidden"), document.body.appendChild(this.root)), this.storage.set("open", !0,
|
2466
|
+
this.root && (this.root.classList.add("expanded"), this.root.classList.remove("hidden"), document.body.appendChild(this.root)), this.storage.set("open", !0, m.Necessary);
|
2453
2467
|
}
|
2454
2468
|
hide() {
|
2455
|
-
this.root && (this.root.classList.add("hidden"), this.root.classList.remove("expanded")), this.storage.set("open", !1,
|
2469
|
+
this.root && (this.root.classList.add("hidden"), this.root.classList.remove("expanded")), this.storage.set("open", !1, m.Necessary);
|
2456
2470
|
}
|
2457
2471
|
setZIndex(t) {
|
2458
2472
|
this.root && (this.root.style.zIndex = t.toString());
|
2459
2473
|
}
|
2460
2474
|
mute() {
|
2461
|
-
this.storage.set("muteAudioNotifications", !0,
|
2475
|
+
this.storage.set("muteAudioNotifications", !0, m.Necessary);
|
2462
2476
|
}
|
2463
2477
|
unmute() {
|
2464
2478
|
this.storage.set(
|
2465
2479
|
"muteAudioNotifications",
|
2466
2480
|
!1,
|
2467
|
-
|
2481
|
+
m.Necessary
|
2468
2482
|
);
|
2469
2483
|
}
|
2470
2484
|
registerComponent(t, e) {
|
@@ -2482,7 +2496,7 @@ class Ri {
|
|
2482
2496
|
}
|
2483
2497
|
_getTargetElement() {
|
2484
2498
|
let t = "bottom-right";
|
2485
|
-
if (this.anchor === "BottomRight" ? t = "bottom-right" : this.anchor === "BottomLeft" && (t = "bottom-left"), this.renderStrategy ===
|
2499
|
+
if (this.anchor === "BottomRight" ? t = "bottom-right" : this.anchor === "BottomLeft" && (t = "bottom-left"), this.renderStrategy === w.Trigger) {
|
2486
2500
|
let e = document.querySelector(
|
2487
2501
|
`ace-trigger-slot.${t}`
|
2488
2502
|
);
|
@@ -2491,17 +2505,17 @@ class Ri {
|
|
2491
2505
|
return document.body;
|
2492
2506
|
}
|
2493
2507
|
render() {
|
2494
|
-
if (this.renderStrategy ===
|
2508
|
+
if (this.renderStrategy === w.Trigger) {
|
2495
2509
|
const t = new A();
|
2496
2510
|
return t.application = this, this.trigger = t, this.storage.get("open") && this.trigger.toggleActive(), t;
|
2497
2511
|
}
|
2498
2512
|
return this.root;
|
2499
2513
|
}
|
2500
2514
|
}
|
2501
|
-
const Fi = (s) => new et(s),
|
2515
|
+
const Fi = (s) => new et(s), we = class {
|
2502
2516
|
// TODO:
|
2503
2517
|
// private static endpoint = 'http://localhost:5299/api'; // TODO:
|
2504
|
-
constructor(s =
|
2518
|
+
constructor(s = we.endpoint) {
|
2505
2519
|
this._endpoint = s;
|
2506
2520
|
}
|
2507
2521
|
async getSite(s) {
|
@@ -2510,8 +2524,8 @@ const Fi = (s) => new et(s), $e = class {
|
|
2510
2524
|
id: e.id,
|
2511
2525
|
triggers: e.triggers || [],
|
2512
2526
|
apps: e.widgets.map((i) => {
|
2513
|
-
let r =
|
2514
|
-
return i.renderStrategy === "Trigger" && (r =
|
2527
|
+
let r = w.Inline;
|
2528
|
+
return i.renderStrategy === "Trigger" && (r = w.Trigger), {
|
2515
2529
|
id: i.id,
|
2516
2530
|
widgetId: i.widgetId,
|
2517
2531
|
renderStrategy: r,
|
@@ -2533,7 +2547,7 @@ const Fi = (s) => new et(s), $e = class {
|
|
2533
2547
|
} : null;
|
2534
2548
|
}
|
2535
2549
|
};
|
2536
|
-
let et =
|
2550
|
+
let et = we;
|
2537
2551
|
et.endpoint = "https://widgets.ace.teliacompany.net/api";
|
2538
2552
|
class ki {
|
2539
2553
|
constructor(t) {
|
@@ -2544,9 +2558,9 @@ class ki {
|
|
2544
2558
|
(((i = this.site.environment) == null ? void 0 : i.applications) || []).forEach((r) => {
|
2545
2559
|
if (r.storage) {
|
2546
2560
|
const o = {
|
2547
|
-
[
|
2548
|
-
[
|
2549
|
-
[
|
2561
|
+
[m.Analytics]: t.includes("analytics"),
|
2562
|
+
[m.Necessary]: t.includes("necessary"),
|
2563
|
+
[m.Functional]: t.includes("functional")
|
2550
2564
|
};
|
2551
2565
|
r.storage.updatePolicy(o);
|
2552
2566
|
}
|
@@ -2733,7 +2747,7 @@ class Y extends _ {
|
|
2733
2747
|
render() {
|
2734
2748
|
if (!this.widget || this.status !== "activated")
|
2735
2749
|
return u;
|
2736
|
-
if (this.widget.renderStrategy ===
|
2750
|
+
if (this.widget.renderStrategy === w.Trigger) {
|
2737
2751
|
const t = new A();
|
2738
2752
|
return t.application = this.widget, t;
|
2739
2753
|
}
|
@@ -2748,7 +2762,7 @@ Y.styles = [
|
|
2748
2762
|
`
|
2749
2763
|
];
|
2750
2764
|
Et([
|
2751
|
-
|
2765
|
+
v({ attribute: !0 })
|
2752
2766
|
], Y.prototype, "name", 2);
|
2753
2767
|
Et([
|
2754
2768
|
U()
|
@@ -2772,7 +2786,7 @@ export {
|
|
2772
2786
|
Ni as Environment,
|
2773
2787
|
et as HttpClient,
|
2774
2788
|
Ui as Site,
|
2775
|
-
|
2789
|
+
m as StorageCategory,
|
2776
2790
|
Oi as StorageService,
|
2777
2791
|
A as Trigger,
|
2778
2792
|
yi as WidgetComponent,
|
package/models/application.d.ts
CHANGED
@@ -29,6 +29,7 @@ export declare class Application {
|
|
29
29
|
constructor(id: string, name: string, container: Container, settings: WidgetConfig, options: ApplicationOptions);
|
30
30
|
activate(): Promise<void>;
|
31
31
|
private loadPlugins;
|
32
|
+
onMessageReceived: (event: any) => Promise<void>;
|
32
33
|
styles(): Record<string, any>;
|
33
34
|
branding(): Record<string, any>;
|
34
35
|
plugin(plugin: PluginType): this;
|