@telia-ace/widget-site 1.0.4 → 1.0.6

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 CHANGED
@@ -12,11 +12,11 @@
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
13
  */const N=globalThis,W=N.trustedTypes,X=W?W.createPolicy("lit-html",{createHTML:n=>n}):void 0,ct="$lit$",_=`lit$${Math.random().toFixed(9).slice(2)}$`,lt="?"+_,bt=`<${lt}>`,w=document,H=()=>w.createComment(""),M=n=>n===null||typeof n!="object"&&typeof n!="function",Z=Array.isArray,Et=n=>Z(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",D=`[
14
14
  \f\r]`,x=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,tt=/-->/g,et=/>/g,y=RegExp(`>|${D}(?:([^\\s"'>=/]+)(${D}*=${D}*(?:[^
15
- \f\r"'\`<>=]|("|')|))|$)`,"g"),it=/'/g,st=/"/g,dt=/^(?:script|style|textarea|title)$/i,S=Symbol.for("lit-noChange"),l=Symbol.for("lit-nothing"),nt=new WeakMap,A=w.createTreeWalker(w,129);function pt(n,t){if(!Z(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return X!==void 0?X.createHTML(t):t}const St=(n,t)=>{const e=n.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",o=x;for(let c=0;c<e;c++){const a=n[c];let d,p,h=-1,u=0;for(;u<a.length&&(o.lastIndex=u,p=o.exec(a),p!==null);)u=o.lastIndex,o===x?p[1]==="!--"?o=tt:p[1]!==void 0?o=et:p[2]!==void 0?(dt.test(p[2])&&(s=RegExp("</"+p[2],"g")),o=y):p[3]!==void 0&&(o=y):o===y?p[0]===">"?(o=s??x,h=-1):p[1]===void 0?h=-2:(h=o.lastIndex-p[2].length,d=p[1],o=p[3]===void 0?y:p[3]==='"'?st:it):o===st||o===it?o=y:o===tt||o===et?o=x:(o=y,s=void 0);const $=o===y&&n[c+1].startsWith("/>")?" ":"";r+=o===x?a+bt:h>=0?(i.push(d),a.slice(0,h)+ct+a.slice(h)+_+$):a+_+(h===-2?c:$)}return[pt(n,r+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};class R{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,o=0;const c=t.length-1,a=this.parts,[d,p]=St(t,e);if(this.el=R.createElement(d,i),A.currentNode=this.el.content,e===2||e===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(s=A.nextNode())!==null&&a.length<c;){if(s.nodeType===1){if(s.hasAttributes())for(const h of s.getAttributeNames())if(h.endsWith(ct)){const u=p[o++],$=s.getAttribute(h).split(_),j=/([.?@])?(.*)/.exec(u);a.push({type:1,index:r,name:j[2],strings:$,ctor:j[1]==="."?Pt:j[1]==="?"?Ct:j[1]==="@"?Ot:k}),s.removeAttribute(h)}else h.startsWith(_)&&(a.push({type:6,index:r}),s.removeAttribute(h));if(dt.test(s.tagName)){const h=s.textContent.split(_),u=h.length-1;if(u>0){s.textContent=W?W.emptyScript:"";for(let $=0;$<u;$++)s.append(h[$],H()),A.nextNode(),a.push({type:2,index:++r});s.append(h[u],H())}}}else if(s.nodeType===8)if(s.data===lt)a.push({type:2,index:r});else{let h=-1;for(;(h=s.data.indexOf(_,h+1))!==-1;)a.push({type:7,index:r}),h+=_.length-1}r++}}static createElement(t,e){const i=w.createElement("template");return i.innerHTML=t,i}}function U(n,t,e=n,i){var o,c;if(t===S)return t;let s=i!==void 0?(o=e.o)==null?void 0:o[i]:e.l;const r=M(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((c=s==null?void 0:s._$AO)==null||c.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,e,i)),i!==void 0?(e.o??(e.o=[]))[i]=s:e.l=s),s!==void 0&&(t=U(n,s._$AS(n,t.values),s,i)),t}class Ut{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??w).importNode(e,!0);A.currentNode=s;let r=A.nextNode(),o=0,c=0,a=i[0];for(;a!==void 0;){if(o===a.index){let d;a.type===2?d=new I(r,r.nextSibling,this,t):a.type===1?d=new a.ctor(r,a.name,a.strings,this,t):a.type===6&&(d=new xt(r,this,t)),this._$AV.push(d),a=i[++c]}o!==(a==null?void 0:a.index)&&(r=A.nextNode(),o++)}return A.currentNode=w,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class I{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this.v}constructor(t,e,i,s){this.type=2,this._$AH=l,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this.v=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=U(this,t,e),M(t)?t===l||t==null||t===""?(this._$AH!==l&&this._$AR(),this._$AH=l):t!==this._$AH&&t!==S&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Et(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==l&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(w.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=R.createElement(pt(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(e);else{const o=new Ut(s,this),c=o.u(this.options);o.p(e),this.T(c),this._$AH=o}}_$AC(t){let e=nt.get(t.strings);return e===void 0&&nt.set(t.strings,e=new R(t)),e}k(t){Z(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new I(this.O(H()),this.O(H()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this.v=t,(e=this._$AP)==null||e.call(this,t))}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=l,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=l}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(r===void 0)t=U(this,t,e,0),o=!M(t)||t!==this._$AH&&t!==S,o&&(this._$AH=t);else{const c=t;let a,d;for(t=r[0],a=0;a<r.length-1;a++)d=U(this,c[i+a],e,a),d===S&&(d=this._$AH[a]),o||(o=!M(d)||d!==this._$AH[a]),d===l?t=l:t!==l&&(t+=(d??"")+r[a+1]),this._$AH[a]=d}o&&!s&&this.j(t)}j(t){t===l?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Pt extends k{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===l?void 0:t}}class Ct extends k{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==l)}}class Ot extends k{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=U(this,t,e,0)??l)===S)return;const i=this._$AH,s=t===l&&i!==l||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==l&&(i===l||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class xt{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){U(this,t)}}const V=N.litHtmlPolyfillSupport;V==null||V(R,I),(N.litHtmlVersions??(N.litHtmlVersions=[])).push("3.2.0");const Tt=(n,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const r=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new I(t.insertBefore(H(),r),r,void 0,e??{})}return s._$AI(n),s};/**
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),it=/'/g,st=/"/g,dt=/^(?:script|style|textarea|title)$/i,S=Symbol.for("lit-noChange"),l=Symbol.for("lit-nothing"),nt=new WeakMap,A=w.createTreeWalker(w,129);function pt(n,t){if(!Z(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return X!==void 0?X.createHTML(t):t}const St=(n,t)=>{const e=n.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",o=x;for(let c=0;c<e;c++){const a=n[c];let d,p,h=-1,u=0;for(;u<a.length&&(o.lastIndex=u,p=o.exec(a),p!==null);)u=o.lastIndex,o===x?p[1]==="!--"?o=tt:p[1]!==void 0?o=et:p[2]!==void 0?(dt.test(p[2])&&(s=RegExp("</"+p[2],"g")),o=y):p[3]!==void 0&&(o=y):o===y?p[0]===">"?(o=s??x,h=-1):p[1]===void 0?h=-2:(h=o.lastIndex-p[2].length,d=p[1],o=p[3]===void 0?y:p[3]==='"'?st:it):o===st||o===it?o=y:o===tt||o===et?o=x:(o=y,s=void 0);const $=o===y&&n[c+1].startsWith("/>")?" ":"";r+=o===x?a+bt:h>=0?(i.push(d),a.slice(0,h)+ct+a.slice(h)+_+$):a+_+(h===-2?c:$)}return[pt(n,r+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};class R{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,o=0;const c=t.length-1,a=this.parts,[d,p]=St(t,e);if(this.el=R.createElement(d,i),A.currentNode=this.el.content,e===2||e===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(s=A.nextNode())!==null&&a.length<c;){if(s.nodeType===1){if(s.hasAttributes())for(const h of s.getAttributeNames())if(h.endsWith(ct)){const u=p[o++],$=s.getAttribute(h).split(_),j=/([.?@])?(.*)/.exec(u);a.push({type:1,index:r,name:j[2],strings:$,ctor:j[1]==="."?Pt:j[1]==="?"?Ct:j[1]==="@"?Ot:k}),s.removeAttribute(h)}else h.startsWith(_)&&(a.push({type:6,index:r}),s.removeAttribute(h));if(dt.test(s.tagName)){const h=s.textContent.split(_),u=h.length-1;if(u>0){s.textContent=W?W.emptyScript:"";for(let $=0;$<u;$++)s.append(h[$],H()),A.nextNode(),a.push({type:2,index:++r});s.append(h[u],H())}}}else if(s.nodeType===8)if(s.data===lt)a.push({type:2,index:r});else{let h=-1;for(;(h=s.data.indexOf(_,h+1))!==-1;)a.push({type:7,index:r}),h+=_.length-1}r++}}static createElement(t,e){const i=w.createElement("template");return i.innerHTML=t,i}}function U(n,t,e=n,i){var o,c;if(t===S)return t;let s=i!==void 0?(o=e.o)==null?void 0:o[i]:e.l;const r=M(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((c=s==null?void 0:s._$AO)==null||c.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,e,i)),i!==void 0?(e.o??(e.o=[]))[i]=s:e.l=s),s!==void 0&&(t=U(n,s._$AS(n,t.values),s,i)),t}class Ut{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??w).importNode(e,!0);A.currentNode=s;let r=A.nextNode(),o=0,c=0,a=i[0];for(;a!==void 0;){if(o===a.index){let d;a.type===2?d=new I(r,r.nextSibling,this,t):a.type===1?d=new a.ctor(r,a.name,a.strings,this,t):a.type===6&&(d=new xt(r,this,t)),this._$AV.push(d),a=i[++c]}o!==(a==null?void 0:a.index)&&(r=A.nextNode(),o++)}return A.currentNode=w,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class I{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this.v}constructor(t,e,i,s){this.type=2,this._$AH=l,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this.v=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=U(this,t,e),M(t)?t===l||t==null||t===""?(this._$AH!==l&&this._$AR(),this._$AH=l):t!==this._$AH&&t!==S&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):Et(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==l&&M(this._$AH)?this._$AA.nextSibling.data=t:this.T(w.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=R.createElement(pt(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(e);else{const o=new Ut(s,this),c=o.u(this.options);o.p(e),this.T(c),this._$AH=o}}_$AC(t){let e=nt.get(t.strings);return e===void 0&&nt.set(t.strings,e=new R(t)),e}k(t){Z(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new I(this.O(H()),this.O(H()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this.v=t,(e=this._$AP)==null||e.call(this,t))}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=l,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=l}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(r===void 0)t=U(this,t,e,0),o=!M(t)||t!==this._$AH&&t!==S,o&&(this._$AH=t);else{const c=t;let a,d;for(t=r[0],a=0;a<r.length-1;a++)d=U(this,c[i+a],e,a),d===S&&(d=this._$AH[a]),o||(o=!M(d)||d!==this._$AH[a]),d===l?t=l:t!==l&&(t+=(d??"")+r[a+1]),this._$AH[a]=d}o&&!s&&this.j(t)}j(t){t===l?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Pt extends k{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===l?void 0:t}}class Ct extends k{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==l)}}class Ot extends k{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=U(this,t,e,0)??l)===S)return;const i=this._$AH,s=t===l&&i!==l||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==l&&(i===l||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class xt{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){U(this,t)}}const q=N.litHtmlPolyfillSupport;q==null||q(R,I),(N.litHtmlVersions??(N.litHtmlVersions=[])).push("3.2.0");const Tt=(n,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const r=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new I(t.insertBefore(H(),r),r,void 0,e??{})}return s._$AI(n),s};/**
16
16
  * @license
17
17
  * Copyright 2017 Google LLC
18
18
  * SPDX-License-Identifier: BSD-3-Clause
19
- */class E extends b{constructor(){super(...arguments),this.renderOptions={host:this},this.o=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this.o=Tt(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this.o)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.o)==null||t.setConnected(!1)}render(){return S}}var at;E._$litElement$=!0,E.finalized=!0,(at=globalThis.litElementHydrateSupport)==null||at.call(globalThis,{LitElement:E});const q=globalThis.litElementPolyfillSupport;q==null||q({LitElement:E});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.0");/**
19
+ */class E extends b{constructor(){super(...arguments),this.renderOptions={host:this},this.o=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this.o=Tt(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this.o)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this.o)==null||t.setConnected(!1)}render(){return S}}var at;E._$litElement$=!0,E.finalized=!0,(at=globalThis.litElementHydrateSupport)==null||at.call(globalThis,{LitElement:E});const V=globalThis.litElementPolyfillSupport;V==null||V({LitElement:E});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.0");/**
20
20
  * @license
21
21
  * Copyright 2017 Google LLC
22
22
  * SPDX-License-Identifier: BSD-3-Clause
@@ -24,4 +24,4 @@
24
24
  * @license
25
25
  * Copyright 2017 Google LLC
26
26
  * SPDX-License-Identifier: BSD-3-Clause
27
- */function P(n){return v({...n,state:!0,attribute:!1})}var Mt=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,C=(n,t,e,i)=>{for(var s=i>1?void 0:i?Rt(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Mt(t,e,s),s};const rt="https://widgets.ace.teliacompany.net",ot="https://embed.webprovisions.io",It=()=>{if(typeof window<"u"){const n=history.pushState,t=history.replaceState;history.pushState=function(...e){n.apply(history,e),window.dispatchEvent(new Event("locationchange"))},history.replaceState=function(...e){t.apply(history,e),window.dispatchEvent(new Event("locationchange"))}}};class g extends E{constructor(){super(...arguments),this.apiUrl=rt,this.embedUrl=ot,this._site=null,this._widgets={},this._path=""}async connectedCallback(){super.connectedCallback(),It(),await this.loadSite(),window.addEventListener("locationchange",this.routeChangeListener)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("locationchange",this.routeChangeListener)}routeChangeListener(){this._site&&(this._path=window.location.pathname)}async loadSite(){var i;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json();this._site=e,(((i=this._site)==null?void 0:i.widgets)||[]).forEach(async s=>{this.addWidgetEl(s.widgetId)})}addWidgetEl(t){const e=`ace-widget_${t}`;let i=document.getElementById(e);i||(i=document.createElement("ace-widget-wrapper"),i.setAttribute("id",e),i.setAttribute("widgetId",t),this.apiUrl!==rt&&i.setAttribute("apiUrl",this.apiUrl),this.embedUrl!==ot&&i.setAttribute("embedUrl",this.embedUrl),document.body.appendChild(i)),this._widgets={...this._widgets,[t]:i},window.ace=window.ace||{_c:[],_w:[],widget:function(s,r){window.ace._w.push([s,r])},configure:function(s){window.ace._c.push(s)}}}render(){if(!this._site)return l;const t=jt(this._site);for(const[e,i]of Object.entries(this._widgets))t.find(r=>r.widgetId===e)?i.isActivated()||i.activate():i.isActivated()&&i.deactivate();return l}}C([v({attribute:!0})],g.prototype,"siteId",2);C([v()],g.prototype,"apiUrl",2);C([v()],g.prototype,"embedUrl",2);C([P()],g.prototype,"_site",2);C([P()],g.prototype,"_widgets",2);C([P()],g.prototype,"_path",2);const jt=n=>{const t=[];return(n.triggers||[]).filter(e=>e.triggerType==="visit").forEach(e=>{const i=window.location.pathname,s=e.condition.outputs||[];e.condition.type==="url"&&s.forEach(r=>{const o=r.action.type==="render_widget";if((r.value===i||r.value==="*")&&o){let a={widgetId:""};try{a=JSON.parse(r.action.data)}catch{a={widgetId:""}}const d=t.findIndex(h=>h.widgetId===a.widgetId)>-1,p=((n==null?void 0:n.widgets)||[]).find(h=>h.widgetId===a.widgetId);p&&!d&&t.push(p)}})}),t};window.customElements.get("ace-site")||window.customElements.define("ace-site",g);var Lt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,O=(n,t,e,i)=>{for(var s=i>1?void 0:i?Bt(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Lt(t,e,s),s};const Wt="https://widgets.ace.teliacompany.net",kt="https://embed.webprovisions.io";class m extends E{constructor(){super(...arguments),this.apiUrl=Wt,this.embedUrl=kt,this.widget=null,this.scriptEl=null,this.activated=!1}async connectedCallback(){super.connectedCallback(),this.widget=await this._loadWidget(this.widgetId)}async _loadWidget(t){return await(await fetch(`${this.apiUrl}/api/widget/${t}`)).json()}_createEmbedScript(){var e;if(!((e=this.widget)!=null&&e.distributionName))return;let t=document.createElement("script");t.setAttribute("type","module"),t.setAttribute("async","true"),t.setAttribute("src",`${this.embedUrl}/d/${this.widget.organization}/${this.widget.distributionName}@latest/index.js`),this.scriptEl=t}isActivated(){return this.activated}async activate(){this.widget||(this.widget=await this._loadWidget(this.widgetId)),this._createEmbedScript(),console.log("activating"),this.activated=!0}async deactivate(){console.log("deactivating"),this.activated=!1}render(){return this.scriptEl?this.scriptEl:l}}O([v({attribute:!0})],m.prototype,"widgetId",2);O([v()],m.prototype,"apiUrl",2);O([v()],m.prototype,"embedUrl",2);O([P()],m.prototype,"widget",2);O([P()],m.prototype,"scriptEl",2);O([P()],m.prototype,"activated",2);customElements.get("ace-widget-wrapper")||customElements.define("ace-widget-wrapper",m);exports.SiteComponent=g;exports.WidgetComponent=m;
27
+ */function P(n){return v({...n,state:!0,attribute:!1})}var Mt=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,C=(n,t,e,i)=>{for(var s=i>1?void 0:i?Rt(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Mt(t,e,s),s};const rt="https://widgets.ace.teliacompany.net",ot="https://embed.webprovisions.io",It=()=>{if(typeof window<"u"){const n=history.pushState,t=history.replaceState;history.pushState=function(...e){n.apply(history,e),window.dispatchEvent(new Event("locationchange"))},history.replaceState=function(...e){t.apply(history,e),window.dispatchEvent(new Event("locationchange"))}}};class g extends E{constructor(){super(...arguments),this.apiUrl=rt,this.embedUrl=ot,this._site=null,this._widgets={},this._path=""}async connectedCallback(){super.connectedCallback(),It(),await this.loadSite(),window.addEventListener("locationchange",this.routeChangeListener)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("locationchange",this.routeChangeListener)}routeChangeListener(){this._path=window.location.pathname,this.requestUpdate()}async loadSite(){var i;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json();this._site=e,(((i=this._site)==null?void 0:i.widgets)||[]).forEach(async s=>{this.addWidgetEl(s.widgetId)})}addWidgetEl(t){const e=`ace-widget_${t}`;let i=document.getElementById(e);i||(i=document.createElement("ace-widget-wrapper"),i.setAttribute("id",e),i.setAttribute("widgetId",t),this.apiUrl!==rt&&i.setAttribute("apiUrl",this.apiUrl),this.embedUrl!==ot&&i.setAttribute("embedUrl",this.embedUrl),document.body.appendChild(i)),this._widgets={...this._widgets,[t]:i},window.ace=window.ace||{_c:[],_w:[],widget:function(s,r){window.ace._w.push([s,r])},configure:function(s){window.ace._c.push(s)}}}render(){if(console.log("path = ",this._path),!this._site)return l;const t=jt(this._site);for(const[e,i]of Object.entries(this._widgets))t.find(r=>r.widgetId===e)?i.isActivated()||i.activate():i.isActivated()&&i.deactivate();return l}}C([v({attribute:!0})],g.prototype,"siteId",2);C([v()],g.prototype,"apiUrl",2);C([v()],g.prototype,"embedUrl",2);C([P()],g.prototype,"_site",2);C([P()],g.prototype,"_widgets",2);C([P()],g.prototype,"_path",2);const jt=n=>{const t=[];return(n.triggers||[]).filter(e=>e.triggerType==="visit").forEach(e=>{const i=window.location.pathname,s=e.condition.outputs||[];e.condition.type==="url"&&s.forEach(r=>{const o=r.action.type==="render_widget";if((r.value===i||r.value==="*")&&o){let a={widgetId:""};try{a=JSON.parse(r.action.data)}catch{a={widgetId:""}}const d=t.findIndex(h=>h.widgetId===a.widgetId)>-1,p=((n==null?void 0:n.widgets)||[]).find(h=>h.widgetId===a.widgetId);p&&!d&&t.push(p)}})}),t};window.customElements.get("ace-site")||window.customElements.define("ace-site",g);var Lt=Object.defineProperty,Bt=Object.getOwnPropertyDescriptor,O=(n,t,e,i)=>{for(var s=i>1?void 0:i?Bt(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Lt(t,e,s),s};const Wt="https://widgets.ace.teliacompany.net",kt="https://embed.webprovisions.io";class m extends E{constructor(){super(...arguments),this.apiUrl=Wt,this.embedUrl=kt,this.widget=null,this.scriptEl=null,this.activated=!1}async connectedCallback(){super.connectedCallback(),this.widget=await this._loadWidget(this.widgetId)}async _loadWidget(t){return await(await fetch(`${this.apiUrl}/api/widget/${t}`)).json()}_createEmbedScript(){var e;if(!((e=this.widget)!=null&&e.distributionName))return;let t=document.createElement("script");t.setAttribute("type","module"),t.setAttribute("async","true"),t.setAttribute("src",`${this.embedUrl}/d/${this.widget.organization}/${this.widget.distributionName}@latest/index.js`),this.scriptEl=t}isActivated(){return this.activated}async activate(){this.widget||(this.widget=await this._loadWidget(this.widgetId)),this._createEmbedScript(),console.log("activating"),this.activated=!0}async deactivate(){console.log("deactivating"),this.activated=!1}render(){return this.scriptEl?this.scriptEl:l}}O([v({attribute:!0})],m.prototype,"widgetId",2);O([v()],m.prototype,"apiUrl",2);O([v()],m.prototype,"embedUrl",2);O([P()],m.prototype,"widget",2);O([P()],m.prototype,"scriptEl",2);O([P()],m.prototype,"activated",2);customElements.get("ace-widget-wrapper")||customElements.define("ace-widget-wrapper",m);exports.SiteComponent=g;exports.WidgetComponent=m;
package/index.mjs CHANGED
@@ -525,8 +525,8 @@ class xt {
525
525
  U(this, t);
526
526
  }
527
527
  }
528
- const V = N.litHtmlPolyfillSupport;
529
- V == null || V(R, I), (N.litHtmlVersions ?? (N.litHtmlVersions = [])).push("3.2.0");
528
+ const q = N.litHtmlPolyfillSupport;
529
+ q == null || q(R, I), (N.litHtmlVersions ?? (N.litHtmlVersions = [])).push("3.2.0");
530
530
  const Tt = (n, t, e) => {
531
531
  const i = (e == null ? void 0 : e.renderBefore) ?? t;
532
532
  let s = i._$litPart$;
@@ -568,8 +568,8 @@ class E extends b {
568
568
  }
569
569
  var at;
570
570
  E._$litElement$ = !0, E.finalized = !0, (at = globalThis.litElementHydrateSupport) == null || at.call(globalThis, { LitElement: E });
571
- const q = globalThis.litElementPolyfillSupport;
572
- q == null || q({ LitElement: E });
571
+ const V = globalThis.litElementPolyfillSupport;
572
+ V == null || V({ LitElement: E });
573
573
  (globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.0");
574
574
  /**
575
575
  * @license
@@ -637,7 +637,7 @@ class w extends E {
637
637
  super.disconnectedCallback(), window.removeEventListener("locationchange", this.routeChangeListener);
638
638
  }
639
639
  routeChangeListener() {
640
- this._site && (this._path = window.location.pathname);
640
+ this._path = window.location.pathname, this.requestUpdate();
641
641
  }
642
642
  async loadSite() {
643
643
  var i;
@@ -664,7 +664,7 @@ class w extends E {
664
664
  };
665
665
  }
666
666
  render() {
667
- if (!this._site)
667
+ if (console.log("path = ", this._path), !this._site)
668
668
  return l;
669
669
  const t = jt(this._site);
670
670
  for (const [e, i] of Object.entries(this._widgets))
package/index.umd.js CHANGED
@@ -6,13 +6,13 @@
6
6
  * @license
7
7
  * Copyright 2017 Google LLC
8
8
  * SPDX-License-Identifier: BSD-3-Clause
9
- */const{is:gt,defineProperty:mt,getOwnPropertyDescriptor:yt,getOwnPropertyNames:At,getOwnPropertySymbols:wt,getPrototypeOf:vt}=Object,f=globalThis,X=f.trustedTypes,bt=X?X.emptyScript:"",V=f.reactiveElementPolyfillSupport,N=(n,t)=>n,B={toAttribute(n,t){switch(t){case Boolean:n=n?bt:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},q=(n,t)=>!gt(n,t),tt={attribute:!0,type:String,converter:B,reflect:!1,hasChanged:q};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),f.litPropertyMetadata??(f.litPropertyMetadata=new WeakMap);class S extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=tt){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&mt(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:r}=yt(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get(){return s==null?void 0:s.call(this)},set(o){const c=s==null?void 0:s.call(this);r.call(this,o),this.requestUpdate(t,c,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??tt}static _$Ei(){if(this.hasOwnProperty(N("elementProperties")))return;const t=vt(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(N("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(N("properties"))){const e=this.properties,i=[...At(e),...wt(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(Y(s))}else t!==void 0&&e.push(Y(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return _t(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EC(t,e){var r;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const o=(((r=i.converter)==null?void 0:r.toAttribute)!==void 0?i.converter:B).toAttribute(e,i.type);this._$Em=t,o==null?this.removeAttribute(s):this.setAttribute(s,o),this._$Em=null}}_$AK(t,e){var r;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const o=i.getPropertyOptions(s),c=typeof o.converter=="function"?{fromAttribute:o.converter}:((r=o.converter)==null?void 0:r.fromAttribute)!==void 0?o.converter:B;this._$Em=s,this[s]=c.fromAttribute(e,o.type),this._$Em=null}}requestUpdate(t,e,i){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??q)(this[t],e))return;this.P(t,e,i)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[r,o]of this._$Ep)this[r]=o;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[r,o]of s)o.wrapped!==!0||this._$AL.has(r)||this[r]===void 0||this.P(r,this[r],o)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$EO)==null||i.forEach(s=>{var r;return(r=s.hostUpdate)==null?void 0:r.call(s)}),this.update(e)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}}S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[N("elementProperties")]=new Map,S[N("finalized")]=new Map,V==null||V({ReactiveElement:S}),(f.reactiveElementVersions??(f.reactiveElementVersions=[])).push("2.0.4");/**
9
+ */const{is:gt,defineProperty:mt,getOwnPropertyDescriptor:yt,getOwnPropertyNames:At,getOwnPropertySymbols:wt,getPrototypeOf:vt}=Object,f=globalThis,X=f.trustedTypes,bt=X?X.emptyScript:"",q=f.reactiveElementPolyfillSupport,N=(n,t)=>n,B={toAttribute(n,t){switch(t){case Boolean:n=n?bt:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,t){let e=n;switch(t){case Boolean:e=n!==null;break;case Number:e=n===null?null:Number(n);break;case Object:case Array:try{e=JSON.parse(n)}catch{e=null}}return e}},V=(n,t)=>!gt(n,t),tt={attribute:!0,type:String,converter:B,reflect:!1,hasChanged:V};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),f.litPropertyMetadata??(f.litPropertyMetadata=new WeakMap);class S extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=tt){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const i=Symbol(),s=this.getPropertyDescriptor(t,i,e);s!==void 0&&mt(this.prototype,t,s)}}static getPropertyDescriptor(t,e,i){const{get:s,set:o}=yt(this.prototype,t)??{get(){return this[e]},set(r){this[e]=r}};return{get(){return s==null?void 0:s.call(this)},set(r){const c=s==null?void 0:s.call(this);o.call(this,r),this.requestUpdate(t,c,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??tt}static _$Ei(){if(this.hasOwnProperty(N("elementProperties")))return;const t=vt(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(N("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(N("properties"))){const e=this.properties,i=[...At(e),...wt(e)];for(const s of i)this.createProperty(s,e[s])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[i,s]of e)this.elementProperties.set(i,s)}this._$Eh=new Map;for(const[e,i]of this.elementProperties){const s=this._$Eu(e,i);s!==void 0&&this._$Eh.set(s,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const i=new Set(t.flat(1/0).reverse());for(const s of i)e.unshift(Y(s))}else t!==void 0&&e.push(Y(t));return e}static _$Eu(t,e){const i=e.attribute;return i===!1?void 0:typeof i=="string"?i:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const i of e.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return _t(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostConnected)==null?void 0:i.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var i;return(i=e.hostDisconnected)==null?void 0:i.call(e)})}attributeChangedCallback(t,e,i){this._$AK(t,i)}_$EC(t,e){var o;const i=this.constructor.elementProperties.get(t),s=this.constructor._$Eu(t,i);if(s!==void 0&&i.reflect===!0){const r=(((o=i.converter)==null?void 0:o.toAttribute)!==void 0?i.converter:B).toAttribute(e,i.type);this._$Em=t,r==null?this.removeAttribute(s):this.setAttribute(s,r),this._$Em=null}}_$AK(t,e){var o;const i=this.constructor,s=i._$Eh.get(t);if(s!==void 0&&this._$Em!==s){const r=i.getPropertyOptions(s),c=typeof r.converter=="function"?{fromAttribute:r.converter}:((o=r.converter)==null?void 0:o.fromAttribute)!==void 0?r.converter:B;this._$Em=s,this[s]=c.fromAttribute(e,r.type),this._$Em=null}}requestUpdate(t,e,i){if(t!==void 0){if(i??(i=this.constructor.getPropertyOptions(t)),!(i.hasChanged??V)(this[t],e))return;this.P(t,e,i)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,i){this._$AL.has(t)||this._$AL.set(t,e),i.reflect===!0&&this._$Em!==t&&(this._$Ej??(this._$Ej=new Set)).add(t)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var i;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[o,r]of this._$Ep)this[o]=r;this._$Ep=void 0}const s=this.constructor.elementProperties;if(s.size>0)for(const[o,r]of s)r.wrapped!==!0||this._$AL.has(o)||this[o]===void 0||this.P(o,this[o],r)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(i=this._$EO)==null||i.forEach(s=>{var o;return(o=s.hostUpdate)==null?void 0:o.call(s)}),this.update(e)):this._$EU()}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(i=>{var s;return(s=i.hostUpdated)==null?void 0:s.call(i)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Ej&&(this._$Ej=this._$Ej.forEach(e=>this._$EC(e,this[e]))),this._$EU()}updated(t){}firstUpdated(t){}}S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[N("elementProperties")]=new Map,S[N("finalized")]=new Map,q==null||q({ReactiveElement:S}),(f.reactiveElementVersions??(f.reactiveElementVersions=[])).push("2.0.4");/**
10
10
  * @license
11
11
  * Copyright 2017 Google LLC
12
12
  * SPDX-License-Identifier: BSD-3-Clause
13
13
  */const H=globalThis,W=H.trustedTypes,et=W?W.createPolicy("lit-html",{createHTML:n=>n}):void 0,it="$lit$",_=`lit$${Math.random().toFixed(9).slice(2)}$`,st="?"+_,Et=`<${st}>`,w=document,M=()=>w.createComment(""),R=n=>n===null||typeof n!="object"&&typeof n!="function",J=Array.isArray,St=n=>J(n)||typeof(n==null?void 0:n[Symbol.iterator])=="function",K=`[
14
- \f\r]`,j=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,nt=/-->/g,rt=/>/g,v=RegExp(`>|${K}(?:([^\\s"'>=/]+)(${K}*=${K}*(?:[^
15
- \f\r"'\`<>=]|("|')|))|$)`,"g"),ot=/'/g,at=/"/g,ht=/^(?:script|style|textarea|title)$/i,U=Symbol.for("lit-noChange"),l=Symbol.for("lit-nothing"),ct=new WeakMap,b=w.createTreeWalker(w,129);function lt(n,t){if(!J(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return et!==void 0?et.createHTML(t):t}const Ut=(n,t)=>{const e=n.length-1,i=[];let s,r=t===2?"<svg>":t===3?"<math>":"",o=j;for(let c=0;c<e;c++){const a=n[c];let d,p,h=-1,u=0;for(;u<a.length&&(o.lastIndex=u,p=o.exec(a),p!==null);)u=o.lastIndex,o===j?p[1]==="!--"?o=nt:p[1]!==void 0?o=rt:p[2]!==void 0?(ht.test(p[2])&&(s=RegExp("</"+p[2],"g")),o=v):p[3]!==void 0&&(o=v):o===v?p[0]===">"?(o=s??j,h=-1):p[1]===void 0?h=-2:(h=o.lastIndex-p[2].length,d=p[1],o=p[3]===void 0?v:p[3]==='"'?at:ot):o===at||o===ot?o=v:o===nt||o===rt?o=j:(o=v,s=void 0);const y=o===v&&n[c+1].startsWith("/>")?" ":"";r+=o===j?a+Et:h>=0?(i.push(d),a.slice(0,h)+it+a.slice(h)+_+y):a+_+(h===-2?c:y)}return[lt(n,r+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};class I{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let r=0,o=0;const c=t.length-1,a=this.parts,[d,p]=Ut(t,e);if(this.el=I.createElement(d,i),b.currentNode=this.el.content,e===2||e===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(s=b.nextNode())!==null&&a.length<c;){if(s.nodeType===1){if(s.hasAttributes())for(const h of s.getAttributeNames())if(h.endsWith(it)){const u=p[o++],y=s.getAttribute(h).split(_),z=/([.?@])?(.*)/.exec(u);a.push({type:1,index:r,name:z[2],strings:y,ctor:z[1]==="."?Ct:z[1]==="?"?Ot:z[1]==="@"?xt:k}),s.removeAttribute(h)}else h.startsWith(_)&&(a.push({type:6,index:r}),s.removeAttribute(h));if(ht.test(s.tagName)){const h=s.textContent.split(_),u=h.length-1;if(u>0){s.textContent=W?W.emptyScript:"";for(let y=0;y<u;y++)s.append(h[y],M()),b.nextNode(),a.push({type:2,index:++r});s.append(h[u],M())}}}else if(s.nodeType===8)if(s.data===st)a.push({type:2,index:r});else{let h=-1;for(;(h=s.data.indexOf(_,h+1))!==-1;)a.push({type:7,index:r}),h+=_.length-1}r++}}static createElement(t,e){const i=w.createElement("template");return i.innerHTML=t,i}}function P(n,t,e=n,i){var o,c;if(t===U)return t;let s=i!==void 0?(o=e.o)==null?void 0:o[i]:e.l;const r=R(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==r&&((c=s==null?void 0:s._$AO)==null||c.call(s,!1),r===void 0?s=void 0:(s=new r(n),s._$AT(n,e,i)),i!==void 0?(e.o??(e.o=[]))[i]=s:e.l=s),s!==void 0&&(t=P(n,s._$AS(n,t.values),s,i)),t}class Pt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??w).importNode(e,!0);b.currentNode=s;let r=b.nextNode(),o=0,c=0,a=i[0];for(;a!==void 0;){if(o===a.index){let d;a.type===2?d=new L(r,r.nextSibling,this,t):a.type===1?d=new a.ctor(r,a.name,a.strings,this,t):a.type===6&&(d=new Tt(r,this,t)),this._$AV.push(d),a=i[++c]}o!==(a==null?void 0:a.index)&&(r=b.nextNode(),o++)}return b.currentNode=w,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class L{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this.v}constructor(t,e,i,s){this.type=2,this._$AH=l,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this.v=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=P(this,t,e),R(t)?t===l||t==null||t===""?(this._$AH!==l&&this._$AR(),this._$AH=l):t!==this._$AH&&t!==U&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):St(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==l&&R(this._$AH)?this._$AA.nextSibling.data=t:this.T(w.createTextNode(t)),this._$AH=t}$(t){var r;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=I.createElement(lt(i.h,i.h[0]),this.options)),i);if(((r=this._$AH)==null?void 0:r._$AD)===s)this._$AH.p(e);else{const o=new Pt(s,this),c=o.u(this.options);o.p(e),this.T(c),this._$AH=o}}_$AC(t){let e=ct.get(t.strings);return e===void 0&&ct.set(t.strings,e=new I(t)),e}k(t){J(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const r of t)s===e.length?e.push(i=new L(this.O(M()),this.O(M()),this,this.options)):i=e[s],i._$AI(r),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this.v=t,(e=this._$AP)==null||e.call(this,t))}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,r){this.type=1,this._$AH=l,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=r,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=l}_$AI(t,e=this,i,s){const r=this.strings;let o=!1;if(r===void 0)t=P(this,t,e,0),o=!R(t)||t!==this._$AH&&t!==U,o&&(this._$AH=t);else{const c=t;let a,d;for(t=r[0],a=0;a<r.length-1;a++)d=P(this,c[i+a],e,a),d===U&&(d=this._$AH[a]),o||(o=!R(d)||d!==this._$AH[a]),d===l?t=l:t!==l&&(t+=(d??"")+r[a+1]),this._$AH[a]=d}o&&!s&&this.j(t)}j(t){t===l?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ct extends k{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===l?void 0:t}}class Ot extends k{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==l)}}class xt extends k{constructor(t,e,i,s,r){super(t,e,i,s,r),this.type=5}_$AI(t,e=this){if((t=P(this,t,e,0)??l)===U)return;const i=this._$AH,s=t===l&&i!==l||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,r=t!==l&&(i===l||s);s&&this.element.removeEventListener(this.name,this,i),r&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class Tt{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){P(this,t)}}const Z=H.litHtmlPolyfillSupport;Z==null||Z(I,L),(H.litHtmlVersions??(H.litHtmlVersions=[])).push("3.2.0");const Nt=(n,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const r=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new L(t.insertBefore(M(),r),r,void 0,e??{})}return s._$AI(n),s};/**
14
+ \f\r]`,j=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,nt=/-->/g,ot=/>/g,v=RegExp(`>|${K}(?:([^\\s"'>=/]+)(${K}*=${K}*(?:[^
15
+ \f\r"'\`<>=]|("|')|))|$)`,"g"),rt=/'/g,at=/"/g,ht=/^(?:script|style|textarea|title)$/i,U=Symbol.for("lit-noChange"),l=Symbol.for("lit-nothing"),ct=new WeakMap,b=w.createTreeWalker(w,129);function lt(n,t){if(!J(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return et!==void 0?et.createHTML(t):t}const Ut=(n,t)=>{const e=n.length-1,i=[];let s,o=t===2?"<svg>":t===3?"<math>":"",r=j;for(let c=0;c<e;c++){const a=n[c];let d,p,h=-1,u=0;for(;u<a.length&&(r.lastIndex=u,p=r.exec(a),p!==null);)u=r.lastIndex,r===j?p[1]==="!--"?r=nt:p[1]!==void 0?r=ot:p[2]!==void 0?(ht.test(p[2])&&(s=RegExp("</"+p[2],"g")),r=v):p[3]!==void 0&&(r=v):r===v?p[0]===">"?(r=s??j,h=-1):p[1]===void 0?h=-2:(h=r.lastIndex-p[2].length,d=p[1],r=p[3]===void 0?v:p[3]==='"'?at:rt):r===at||r===rt?r=v:r===nt||r===ot?r=j:(r=v,s=void 0);const y=r===v&&n[c+1].startsWith("/>")?" ":"";o+=r===j?a+Et:h>=0?(i.push(d),a.slice(0,h)+it+a.slice(h)+_+y):a+_+(h===-2?c:y)}return[lt(n,o+(n[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),i]};class I{constructor({strings:t,_$litType$:e},i){let s;this.parts=[];let o=0,r=0;const c=t.length-1,a=this.parts,[d,p]=Ut(t,e);if(this.el=I.createElement(d,i),b.currentNode=this.el.content,e===2||e===3){const h=this.el.content.firstChild;h.replaceWith(...h.childNodes)}for(;(s=b.nextNode())!==null&&a.length<c;){if(s.nodeType===1){if(s.hasAttributes())for(const h of s.getAttributeNames())if(h.endsWith(it)){const u=p[r++],y=s.getAttribute(h).split(_),z=/([.?@])?(.*)/.exec(u);a.push({type:1,index:o,name:z[2],strings:y,ctor:z[1]==="."?Ct:z[1]==="?"?Ot:z[1]==="@"?xt:k}),s.removeAttribute(h)}else h.startsWith(_)&&(a.push({type:6,index:o}),s.removeAttribute(h));if(ht.test(s.tagName)){const h=s.textContent.split(_),u=h.length-1;if(u>0){s.textContent=W?W.emptyScript:"";for(let y=0;y<u;y++)s.append(h[y],M()),b.nextNode(),a.push({type:2,index:++o});s.append(h[u],M())}}}else if(s.nodeType===8)if(s.data===st)a.push({type:2,index:o});else{let h=-1;for(;(h=s.data.indexOf(_,h+1))!==-1;)a.push({type:7,index:o}),h+=_.length-1}o++}}static createElement(t,e){const i=w.createElement("template");return i.innerHTML=t,i}}function P(n,t,e=n,i){var r,c;if(t===U)return t;let s=i!==void 0?(r=e.o)==null?void 0:r[i]:e.l;const o=R(t)?void 0:t._$litDirective$;return(s==null?void 0:s.constructor)!==o&&((c=s==null?void 0:s._$AO)==null||c.call(s,!1),o===void 0?s=void 0:(s=new o(n),s._$AT(n,e,i)),i!==void 0?(e.o??(e.o=[]))[i]=s:e.l=s),s!==void 0&&(t=P(n,s._$AS(n,t.values),s,i)),t}class Pt{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:i}=this._$AD,s=((t==null?void 0:t.creationScope)??w).importNode(e,!0);b.currentNode=s;let o=b.nextNode(),r=0,c=0,a=i[0];for(;a!==void 0;){if(r===a.index){let d;a.type===2?d=new L(o,o.nextSibling,this,t):a.type===1?d=new a.ctor(o,a.name,a.strings,this,t):a.type===6&&(d=new Tt(o,this,t)),this._$AV.push(d),a=i[++c]}r!==(a==null?void 0:a.index)&&(o=b.nextNode(),r++)}return b.currentNode=w,s}p(t){let e=0;for(const i of this._$AV)i!==void 0&&(i.strings!==void 0?(i._$AI(t,i,e),e+=i.strings.length-2):i._$AI(t[e])),e++}}class L{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this.v}constructor(t,e,i,s){this.type=2,this._$AH=l,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=i,this.options=s,this.v=(s==null?void 0:s.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=P(this,t,e),R(t)?t===l||t==null||t===""?(this._$AH!==l&&this._$AR(),this._$AH=l):t!==this._$AH&&t!==U&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):St(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==l&&R(this._$AH)?this._$AA.nextSibling.data=t:this.T(w.createTextNode(t)),this._$AH=t}$(t){var o;const{values:e,_$litType$:i}=t,s=typeof i=="number"?this._$AC(t):(i.el===void 0&&(i.el=I.createElement(lt(i.h,i.h[0]),this.options)),i);if(((o=this._$AH)==null?void 0:o._$AD)===s)this._$AH.p(e);else{const r=new Pt(s,this),c=r.u(this.options);r.p(e),this.T(c),this._$AH=r}}_$AC(t){let e=ct.get(t.strings);return e===void 0&&ct.set(t.strings,e=new I(t)),e}k(t){J(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let i,s=0;for(const o of t)s===e.length?e.push(i=new L(this.O(M()),this.O(M()),this,this.options)):i=e[s],i._$AI(o),s++;s<e.length&&(this._$AR(i&&i._$AB.nextSibling,s),e.length=s)}_$AR(t=this._$AA.nextSibling,e){var i;for((i=this._$AP)==null?void 0:i.call(this,!1,!0,e);t&&t!==this._$AB;){const s=t.nextSibling;t.remove(),t=s}}setConnected(t){var e;this._$AM===void 0&&(this.v=t,(e=this._$AP)==null||e.call(this,t))}}class k{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,i,s,o){this.type=1,this._$AH=l,this._$AN=void 0,this.element=t,this.name=e,this._$AM=s,this.options=o,i.length>2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=l}_$AI(t,e=this,i,s){const o=this.strings;let r=!1;if(o===void 0)t=P(this,t,e,0),r=!R(t)||t!==this._$AH&&t!==U,r&&(this._$AH=t);else{const c=t;let a,d;for(t=o[0],a=0;a<o.length-1;a++)d=P(this,c[i+a],e,a),d===U&&(d=this._$AH[a]),r||(r=!R(d)||d!==this._$AH[a]),d===l?t=l:t!==l&&(t+=(d??"")+o[a+1]),this._$AH[a]=d}r&&!s&&this.j(t)}j(t){t===l?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Ct extends k{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===l?void 0:t}}class Ot extends k{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==l)}}class xt extends k{constructor(t,e,i,s,o){super(t,e,i,s,o),this.type=5}_$AI(t,e=this){if((t=P(this,t,e,0)??l)===U)return;const i=this._$AH,s=t===l&&i!==l||t.capture!==i.capture||t.once!==i.once||t.passive!==i.passive,o=t!==l&&(i===l||s);s&&this.element.removeEventListener(this.name,this,i),o&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class Tt{constructor(t,e,i){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=i}get _$AU(){return this._$AM._$AU}_$AI(t){P(this,t)}}const Z=H.litHtmlPolyfillSupport;Z==null||Z(I,L),(H.litHtmlVersions??(H.litHtmlVersions=[])).push("3.2.0");const Nt=(n,t,e)=>{const i=(e==null?void 0:e.renderBefore)??t;let s=i._$litPart$;if(s===void 0){const o=(e==null?void 0:e.renderBefore)??null;i._$litPart$=s=new L(t.insertBefore(M(),o),o,void 0,e??{})}return s._$AI(n),s};/**
16
16
  * @license
17
17
  * Copyright 2017 Google LLC
18
18
  * SPDX-License-Identifier: BSD-3-Clause
@@ -20,8 +20,8 @@
20
20
  * @license
21
21
  * Copyright 2017 Google LLC
22
22
  * SPDX-License-Identifier: BSD-3-Clause
23
- */const Ht={attribute:!0,type:String,converter:B,reflect:!1,hasChanged:q},Mt=(n=Ht,t,e)=>{const{kind:i,metadata:s}=e;let r=globalThis.litPropertyMetadata.get(s);if(r===void 0&&globalThis.litPropertyMetadata.set(s,r=new Map),r.set(e.name,n),i==="accessor"){const{name:o}=e;return{set(c){const a=t.get.call(this);t.set.call(this,c),this.requestUpdate(o,a,n)},init(c){return c!==void 0&&this.P(o,void 0,n),c}}}if(i==="setter"){const{name:o}=e;return function(c){const a=this[o];t.call(this,c),this.requestUpdate(o,a,n)}}throw Error("Unsupported decorator location: "+i)};function E(n){return(t,e)=>typeof e=="object"?Mt(n,t,e):((i,s,r)=>{const o=s.hasOwnProperty(r);return s.constructor.createProperty(r,o?{...i,wrapped:!0}:i),o?Object.getOwnPropertyDescriptor(s,r):void 0})(n,t,e)}/**
23
+ */const Ht={attribute:!0,type:String,converter:B,reflect:!1,hasChanged:V},Mt=(n=Ht,t,e)=>{const{kind:i,metadata:s}=e;let o=globalThis.litPropertyMetadata.get(s);if(o===void 0&&globalThis.litPropertyMetadata.set(s,o=new Map),o.set(e.name,n),i==="accessor"){const{name:r}=e;return{set(c){const a=t.get.call(this);t.set.call(this,c),this.requestUpdate(r,a,n)},init(c){return c!==void 0&&this.P(r,void 0,n),c}}}if(i==="setter"){const{name:r}=e;return function(c){const a=this[r];t.call(this,c),this.requestUpdate(r,a,n)}}throw Error("Unsupported decorator location: "+i)};function E(n){return(t,e)=>typeof e=="object"?Mt(n,t,e):((i,s,o)=>{const r=s.hasOwnProperty(o);return s.constructor.createProperty(o,r?{...i,wrapped:!0}:i),r?Object.getOwnPropertyDescriptor(s,o):void 0})(n,t,e)}/**
24
24
  * @license
25
25
  * Copyright 2017 Google LLC
26
26
  * SPDX-License-Identifier: BSD-3-Clause
27
- */function O(n){return E({...n,state:!0,attribute:!1})}var Rt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,x=(n,t,e,i)=>{for(var s=i>1?void 0:i?jt(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Rt(t,e,s),s};const dt="https://widgets.ace.teliacompany.net",pt="https://embed.webprovisions.io",It=()=>{if(typeof window<"u"){const n=history.pushState,t=history.replaceState;history.pushState=function(...e){n.apply(history,e),window.dispatchEvent(new Event("locationchange"))},history.replaceState=function(...e){t.apply(history,e),window.dispatchEvent(new Event("locationchange"))}}};class g extends C{constructor(){super(...arguments),this.apiUrl=dt,this.embedUrl=pt,this._site=null,this._widgets={},this._path=""}async connectedCallback(){super.connectedCallback(),It(),await this.loadSite(),window.addEventListener("locationchange",this.routeChangeListener)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("locationchange",this.routeChangeListener)}routeChangeListener(){this._site&&(this._path=window.location.pathname)}async loadSite(){var i;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json();this._site=e,(((i=this._site)==null?void 0:i.widgets)||[]).forEach(async s=>{this.addWidgetEl(s.widgetId)})}addWidgetEl(t){const e=`ace-widget_${t}`;let i=document.getElementById(e);i||(i=document.createElement("ace-widget-wrapper"),i.setAttribute("id",e),i.setAttribute("widgetId",t),this.apiUrl!==dt&&i.setAttribute("apiUrl",this.apiUrl),this.embedUrl!==pt&&i.setAttribute("embedUrl",this.embedUrl),document.body.appendChild(i)),this._widgets={...this._widgets,[t]:i},window.ace=window.ace||{_c:[],_w:[],widget:function(s,r){window.ace._w.push([s,r])},configure:function(s){window.ace._c.push(s)}}}render(){if(!this._site)return l;const t=Lt(this._site);for(const[e,i]of Object.entries(this._widgets))t.find(r=>r.widgetId===e)?i.isActivated()||i.activate():i.isActivated()&&i.deactivate();return l}}x([E({attribute:!0})],g.prototype,"siteId",2),x([E()],g.prototype,"apiUrl",2),x([E()],g.prototype,"embedUrl",2),x([O()],g.prototype,"_site",2),x([O()],g.prototype,"_widgets",2),x([O()],g.prototype,"_path",2);const Lt=n=>{const t=[];return(n.triggers||[]).filter(e=>e.triggerType==="visit").forEach(e=>{const i=window.location.pathname,s=e.condition.outputs||[];e.condition.type==="url"&&s.forEach(r=>{const o=r.action.type==="render_widget";if((r.value===i||r.value==="*")&&o){let a={widgetId:""};try{a=JSON.parse(r.action.data)}catch{a={widgetId:""}}const d=t.findIndex(h=>h.widgetId===a.widgetId)>-1,p=((n==null?void 0:n.widgets)||[]).find(h=>h.widgetId===a.widgetId);p&&!d&&t.push(p)}})}),t};window.customElements.get("ace-site")||window.customElements.define("ace-site",g);var Bt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,T=(n,t,e,i)=>{for(var s=i>1?void 0:i?Wt(t,e):t,r=n.length-1,o;r>=0;r--)(o=n[r])&&(s=(i?o(t,e,s):o(s))||s);return i&&s&&Bt(t,e,s),s};const kt="https://widgets.ace.teliacompany.net",zt="https://embed.webprovisions.io";class m extends C{constructor(){super(...arguments),this.apiUrl=kt,this.embedUrl=zt,this.widget=null,this.scriptEl=null,this.activated=!1}async connectedCallback(){super.connectedCallback(),this.widget=await this._loadWidget(this.widgetId)}async _loadWidget(t){return await(await fetch(`${this.apiUrl}/api/widget/${t}`)).json()}_createEmbedScript(){var e;if(!((e=this.widget)!=null&&e.distributionName))return;let t=document.createElement("script");t.setAttribute("type","module"),t.setAttribute("async","true"),t.setAttribute("src",`${this.embedUrl}/d/${this.widget.organization}/${this.widget.distributionName}@latest/index.js`),this.scriptEl=t}isActivated(){return this.activated}async activate(){this.widget||(this.widget=await this._loadWidget(this.widgetId)),this._createEmbedScript(),console.log("activating"),this.activated=!0}async deactivate(){console.log("deactivating"),this.activated=!1}render(){return this.scriptEl?this.scriptEl:l}}T([E({attribute:!0})],m.prototype,"widgetId",2),T([E()],m.prototype,"apiUrl",2),T([E()],m.prototype,"embedUrl",2),T([O()],m.prototype,"widget",2),T([O()],m.prototype,"scriptEl",2),T([O()],m.prototype,"activated",2),customElements.get("ace-widget-wrapper")||customElements.define("ace-widget-wrapper",m),A.SiteComponent=g,A.WidgetComponent=m,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
27
+ */function O(n){return E({...n,state:!0,attribute:!1})}var Rt=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,x=(n,t,e,i)=>{for(var s=i>1?void 0:i?jt(t,e):t,o=n.length-1,r;o>=0;o--)(r=n[o])&&(s=(i?r(t,e,s):r(s))||s);return i&&s&&Rt(t,e,s),s};const dt="https://widgets.ace.teliacompany.net",pt="https://embed.webprovisions.io",It=()=>{if(typeof window<"u"){const n=history.pushState,t=history.replaceState;history.pushState=function(...e){n.apply(history,e),window.dispatchEvent(new Event("locationchange"))},history.replaceState=function(...e){t.apply(history,e),window.dispatchEvent(new Event("locationchange"))}}};class g extends C{constructor(){super(...arguments),this.apiUrl=dt,this.embedUrl=pt,this._site=null,this._widgets={},this._path=""}async connectedCallback(){super.connectedCallback(),It(),await this.loadSite(),window.addEventListener("locationchange",this.routeChangeListener)}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("locationchange",this.routeChangeListener)}routeChangeListener(){this._path=window.location.pathname,this.requestUpdate()}async loadSite(){var i;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json();this._site=e,(((i=this._site)==null?void 0:i.widgets)||[]).forEach(async s=>{this.addWidgetEl(s.widgetId)})}addWidgetEl(t){const e=`ace-widget_${t}`;let i=document.getElementById(e);i||(i=document.createElement("ace-widget-wrapper"),i.setAttribute("id",e),i.setAttribute("widgetId",t),this.apiUrl!==dt&&i.setAttribute("apiUrl",this.apiUrl),this.embedUrl!==pt&&i.setAttribute("embedUrl",this.embedUrl),document.body.appendChild(i)),this._widgets={...this._widgets,[t]:i},window.ace=window.ace||{_c:[],_w:[],widget:function(s,o){window.ace._w.push([s,o])},configure:function(s){window.ace._c.push(s)}}}render(){if(console.log("path = ",this._path),!this._site)return l;const t=Lt(this._site);for(const[e,i]of Object.entries(this._widgets))t.find(o=>o.widgetId===e)?i.isActivated()||i.activate():i.isActivated()&&i.deactivate();return l}}x([E({attribute:!0})],g.prototype,"siteId",2),x([E()],g.prototype,"apiUrl",2),x([E()],g.prototype,"embedUrl",2),x([O()],g.prototype,"_site",2),x([O()],g.prototype,"_widgets",2),x([O()],g.prototype,"_path",2);const Lt=n=>{const t=[];return(n.triggers||[]).filter(e=>e.triggerType==="visit").forEach(e=>{const i=window.location.pathname,s=e.condition.outputs||[];e.condition.type==="url"&&s.forEach(o=>{const r=o.action.type==="render_widget";if((o.value===i||o.value==="*")&&r){let a={widgetId:""};try{a=JSON.parse(o.action.data)}catch{a={widgetId:""}}const d=t.findIndex(h=>h.widgetId===a.widgetId)>-1,p=((n==null?void 0:n.widgets)||[]).find(h=>h.widgetId===a.widgetId);p&&!d&&t.push(p)}})}),t};window.customElements.get("ace-site")||window.customElements.define("ace-site",g);var Bt=Object.defineProperty,Wt=Object.getOwnPropertyDescriptor,T=(n,t,e,i)=>{for(var s=i>1?void 0:i?Wt(t,e):t,o=n.length-1,r;o>=0;o--)(r=n[o])&&(s=(i?r(t,e,s):r(s))||s);return i&&s&&Bt(t,e,s),s};const kt="https://widgets.ace.teliacompany.net",zt="https://embed.webprovisions.io";class m extends C{constructor(){super(...arguments),this.apiUrl=kt,this.embedUrl=zt,this.widget=null,this.scriptEl=null,this.activated=!1}async connectedCallback(){super.connectedCallback(),this.widget=await this._loadWidget(this.widgetId)}async _loadWidget(t){return await(await fetch(`${this.apiUrl}/api/widget/${t}`)).json()}_createEmbedScript(){var e;if(!((e=this.widget)!=null&&e.distributionName))return;let t=document.createElement("script");t.setAttribute("type","module"),t.setAttribute("async","true"),t.setAttribute("src",`${this.embedUrl}/d/${this.widget.organization}/${this.widget.distributionName}@latest/index.js`),this.scriptEl=t}isActivated(){return this.activated}async activate(){this.widget||(this.widget=await this._loadWidget(this.widgetId)),this._createEmbedScript(),console.log("activating"),this.activated=!0}async deactivate(){console.log("deactivating"),this.activated=!1}render(){return this.scriptEl?this.scriptEl:l}}T([E({attribute:!0})],m.prototype,"widgetId",2),T([E()],m.prototype,"apiUrl",2),T([E()],m.prototype,"embedUrl",2),T([O()],m.prototype,"widget",2),T([O()],m.prototype,"scriptEl",2),T([O()],m.prototype,"activated",2),customElements.get("ace-widget-wrapper")||customElements.define("ace-widget-wrapper",m),A.SiteComponent=g,A.WidgetComponent=m,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-site",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "dependencies": {
5
5
  "lit": "^3.0.2",
6
6
  "lit-html": "^3.0.2"