@telia-ace/widget-site 1.0.0
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.d.ts +2 -0
- package/index.js +27 -0
- package/index.mjs +756 -0
- package/package.json +11 -0
- package/site.component.d.ts +37 -0
- package/widget.component.d.ts +19 -0
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/const j=globalThis,J=j.ShadowRoot&&(j.ShadyCSS===void 0||j.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,at=Symbol(),F=new WeakMap;let ut=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==at)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(J&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=F.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&F.set(e,t))}return t}toString(){return this.cssText}};const $t=r=>new ut(typeof r=="string"?r:r+"",void 0,at),_t=(r,t)=>{if(J)r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const s=document.createElement("style"),i=j.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,r.appendChild(s)}},G=J?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return $t(e)})(r):r;/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2017 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
9
|
+
*/const{is:ft,defineProperty:gt,getOwnPropertyDescriptor:mt,getOwnPropertyNames:yt,getOwnPropertySymbols:At,getPrototypeOf:wt}=Object,f=globalThis,Q=f.trustedTypes,vt=Q?Q.emptyScript:"",W=f.reactiveElementPolyfillSupport,C=(r,t)=>r,k={toAttribute(r,t){switch(t){case Boolean:r=r?vt:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},K=(r,t)=>!ft(r,t),Y={attribute:!0,type:String,converter:k,reflect:!1,hasChanged:K};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),f.litPropertyMetadata??(f.litPropertyMetadata=new WeakMap);class b 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=Y){if(e.state&&(e.attribute=!1),this._$Ei(),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&>(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=mt(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get(){return i==null?void 0:i.call(this)},set(o){const a=i==null?void 0:i.call(this);n.call(this,o),this.requestUpdate(t,a,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Y}static _$Ei(){if(this.hasOwnProperty(C("elementProperties")))return;const t=wt(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(C("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(C("properties"))){const e=this.properties,s=[...yt(e),...At(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(G(i))}else t!==void 0&&e.push(G(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s: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 s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);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 s;return(s=e.hostConnected)==null?void 0:s.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostDisconnected)==null?void 0:s.call(e)})}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$EC(t,e){var n;const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const o=(((n=s.converter)==null?void 0:n.toAttribute)!==void 0?s.converter:k).toAttribute(e,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,e){var n;const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const o=s.getPropertyOptions(i),a=typeof o.converter=="function"?{fromAttribute:o.converter}:((n=o.converter)==null?void 0:n.fromAttribute)!==void 0?o.converter:k;this._$Em=i,this[i]=a.fromAttribute(e,o.type),this._$Em=null}}requestUpdate(t,e,s){if(t!==void 0){if(s??(s=this.constructor.getPropertyOptions(t)),!(s.hasChanged??K)(this[t],e))return;this.P(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(t,e,s){this._$AL.has(t)||this._$AL.set(t,e),s.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 s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[n,o]of i)o.wrapped!==!0||this._$AL.has(n)||this[n]===void 0||this.P(n,this[n],o)}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(s=this._$EO)==null||s.forEach(i=>{var n;return(n=i.hostUpdate)==null?void 0:n.call(i)}),this.update(e)):this._$EU()}catch(i){throw t=!1,this._$EU(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),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){}}b.elementStyles=[],b.shadowRootOptions={mode:"open"},b[C("elementProperties")]=new Map,b[C("finalized")]=new Map,W==null||W({ReactiveElement:b}),(f.reactiveElementVersions??(f.reactiveElementVersions=[])).push("2.0.4");/**
|
|
10
|
+
* @license
|
|
11
|
+
* Copyright 2017 Google LLC
|
|
12
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
13
|
+
*/const O=globalThis,z=O.trustedTypes,X=z?z.createPolicy("lit-html",{createHTML:r=>r}):void 0,ct="$lit$",_=`lit$${Math.random().toFixed(9).slice(2)}$`,lt="?"+_,bt=`<${lt}>`,y=document,x=()=>y.createComment(""),T=r=>r===null||typeof r!="object"&&typeof r!="function",Z=Array.isArray,Et=r=>Z(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",B=`[
|
|
14
|
+
\f\r]`,P=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,tt=/-->/g,et=/>/g,g=RegExp(`>|${B}(?:([^\\s"'>=/]+)(${B}*=${B}*(?:[^
|
|
15
|
+
\f\r"'\`<>=]|("|')|))|$)`,"g"),st=/'/g,it=/"/g,dt=/^(?:script|style|textarea|title)$/i,S=Symbol.for("lit-noChange"),d=Symbol.for("lit-nothing"),rt=new WeakMap,m=y.createTreeWalker(y,129);function pt(r,t){if(!Z(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return X!==void 0?X.createHTML(t):t}const St=(r,t)=>{const e=r.length-1,s=[];let i,n=t===2?"<svg>":t===3?"<math>":"",o=P;for(let a=0;a<e;a++){const h=r[a];let l,p,c=-1,u=0;for(;u<h.length&&(o.lastIndex=u,p=o.exec(h),p!==null);)u=o.lastIndex,o===P?p[1]==="!--"?o=tt:p[1]!==void 0?o=et:p[2]!==void 0?(dt.test(p[2])&&(i=RegExp("</"+p[2],"g")),o=g):p[3]!==void 0&&(o=g):o===g?p[0]===">"?(o=i??P,c=-1):p[1]===void 0?c=-2:(c=o.lastIndex-p[2].length,l=p[1],o=p[3]===void 0?g:p[3]==='"'?it:st):o===it||o===st?o=g:o===tt||o===et?o=P:(o=g,i=void 0);const $=o===g&&r[a+1].startsWith("/>")?" ":"";n+=o===P?h+bt:c>=0?(s.push(l),h.slice(0,c)+ct+h.slice(c)+_+$):h+_+(c===-2?a:$)}return[pt(r,n+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class N{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const a=t.length-1,h=this.parts,[l,p]=St(t,e);if(this.el=N.createElement(l,s),m.currentNode=this.el.content,e===2||e===3){const c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(i=m.nextNode())!==null&&h.length<a;){if(i.nodeType===1){if(i.hasAttributes())for(const c of i.getAttributeNames())if(c.endsWith(ct)){const u=p[o++],$=i.getAttribute(c).split(_),I=/([.?@])?(.*)/.exec(u);h.push({type:1,index:n,name:I[2],strings:$,ctor:I[1]==="."?Pt:I[1]==="?"?Ct:I[1]==="@"?Ot:D}),i.removeAttribute(c)}else c.startsWith(_)&&(h.push({type:6,index:n}),i.removeAttribute(c));if(dt.test(i.tagName)){const c=i.textContent.split(_),u=c.length-1;if(u>0){i.textContent=z?z.emptyScript:"";for(let $=0;$<u;$++)i.append(c[$],x()),m.nextNode(),h.push({type:2,index:++n});i.append(c[u],x())}}}else if(i.nodeType===8)if(i.data===lt)h.push({type:2,index:n});else{let c=-1;for(;(c=i.data.indexOf(_,c+1))!==-1;)h.push({type:7,index:n}),c+=_.length-1}n++}}static createElement(t,e){const s=y.createElement("template");return s.innerHTML=t,s}}function U(r,t,e=r,s){var o,a;if(t===S)return t;let i=s!==void 0?(o=e.o)==null?void 0:o[s]:e.l;const n=T(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==n&&((a=i==null?void 0:i._$AO)==null||a.call(i,!1),n===void 0?i=void 0:(i=new n(r),i._$AT(r,e,s)),s!==void 0?(e.o??(e.o=[]))[s]=i:e.l=i),i!==void 0&&(t=U(r,i._$AS(r,t.values),i,s)),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:s}=this._$AD,i=((t==null?void 0:t.creationScope)??y).importNode(e,!0);m.currentNode=i;let n=m.nextNode(),o=0,a=0,h=s[0];for(;h!==void 0;){if(o===h.index){let l;h.type===2?l=new H(n,n.nextSibling,this,t):h.type===1?l=new h.ctor(n,h.name,h.strings,this,t):h.type===6&&(l=new xt(n,this,t)),this._$AV.push(l),h=s[++a]}o!==(h==null?void 0:h.index)&&(n=m.nextNode(),o++)}return m.currentNode=y,i}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class H{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this.v}constructor(t,e,s,i){this.type=2,this._$AH=d,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this.v=(i==null?void 0:i.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),T(t)?t===d||t==null||t===""?(this._$AH!==d&&this._$AR(),this._$AH=d):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!==d&&T(this._$AH)?this._$AA.nextSibling.data=t:this.T(y.createTextNode(t)),this._$AH=t}$(t){var n;const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=N.createElement(pt(s.h,s.h[0]),this.options)),s);if(((n=this._$AH)==null?void 0:n._$AD)===i)this._$AH.p(e);else{const o=new Ut(i,this),a=o.u(this.options);o.p(e),this.T(a),this._$AH=o}}_$AC(t){let e=rt.get(t.strings);return e===void 0&&rt.set(t.strings,e=new N(t)),e}k(t){Z(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new H(this.O(x()),this.O(x()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,e);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this.v=t,(e=this._$AP)==null||e.call(this,t))}}class D{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=d,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=d}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(n===void 0)t=U(this,t,e,0),o=!T(t)||t!==this._$AH&&t!==S,o&&(this._$AH=t);else{const a=t;let h,l;for(t=n[0],h=0;h<n.length-1;h++)l=U(this,a[s+h],e,h),l===S&&(l=this._$AH[h]),o||(o=!T(l)||l!==this._$AH[h]),l===d?t=d:t!==d&&(t+=(l??"")+n[h+1]),this._$AH[h]=l}o&&!i&&this.j(t)}j(t){t===d?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class Pt extends D{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===d?void 0:t}}class Ct extends D{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==d)}}class Ot extends D{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=U(this,t,e,0)??d)===S)return;const s=this._$AH,i=t===d&&s!==d||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==d&&(s===d||i);i&&this.element.removeEventListener(this.name,this,s),n&&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,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){U(this,t)}}const V=O.litHtmlPolyfillSupport;V==null||V(N,H),(O.litHtmlVersions??(O.litHtmlVersions=[])).push("3.2.0");const Tt=(r,t,e)=>{const s=(e==null?void 0:e.renderBefore)??t;let i=s._$litPart$;if(i===void 0){const n=(e==null?void 0:e.renderBefore)??null;s._$litPart$=i=new H(t.insertBefore(x(),n),n,void 0,e??{})}return i._$AI(r),i};/**
|
|
16
|
+
* @license
|
|
17
|
+
* Copyright 2017 Google LLC
|
|
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 ht;E._$litElement$=!0,E.finalized=!0,(ht=globalThis.litElementHydrateSupport)==null||ht.call(globalThis,{LitElement:E});const q=globalThis.litElementPolyfillSupport;q==null||q({LitElement:E});(globalThis.litElementVersions??(globalThis.litElementVersions=[])).push("4.1.0");/**
|
|
20
|
+
* @license
|
|
21
|
+
* Copyright 2017 Google LLC
|
|
22
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
23
|
+
*/const Nt={attribute:!0,type:String,converter:k,reflect:!1,hasChanged:K},Ht=(r=Nt,t,e)=>{const{kind:s,metadata:i}=e;let n=globalThis.litPropertyMetadata.get(i);if(n===void 0&&globalThis.litPropertyMetadata.set(i,n=new Map),n.set(e.name,r),s==="accessor"){const{name:o}=e;return{set(a){const h=t.get.call(this);t.set.call(this,a),this.requestUpdate(o,h,r)},init(a){return a!==void 0&&this.P(o,void 0,r),a}}}if(s==="setter"){const{name:o}=e;return function(a){const h=this[o];t.call(this,a),this.requestUpdate(o,h,r)}}throw Error("Unsupported decorator location: "+s)};function A(r){return(t,e)=>typeof e=="object"?Ht(r,t,e):((s,i,n)=>{const o=i.hasOwnProperty(n);return i.constructor.createProperty(n,o?{...s,wrapped:!0}:s),o?Object.getOwnPropertyDescriptor(i,n):void 0})(r,t,e)}/**
|
|
24
|
+
* @license
|
|
25
|
+
* Copyright 2017 Google LLC
|
|
26
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
27
|
+
*/function L(r){return A({...r,state:!0,attribute:!1})}var Mt=Object.defineProperty,Rt=Object.getOwnPropertyDescriptor,M=(r,t,e,s)=>{for(var i=s>1?void 0:s?Rt(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&Mt(t,e,i),i};const nt="https://widgets.ace.teliacompany.net",ot="https://embed.webprovisions.io";class w extends E{constructor(){super(...arguments),this.apiUrl=nt,this.embedUrl=ot,this._site=null,this._widgets={}}async connectedCallback(){super.connectedCallback(),await this.loadSite()}async disconnectedCallback(){super.disconnectedCallback()}async loadSite(){var s;const e=await(await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json();this._site=e,(((s=this._site)==null?void 0:s.widgets)||[]).forEach(async i=>{this.addWidgetEl(i.widgetId)})}addWidgetEl(t){const e=`ace-widget_${t}`;let s=document.getElementById(e);s||(s=document.createElement("ace-widget-wrapper"),s.setAttribute("id",e),s.setAttribute("widgetId",t),this.apiUrl!==nt&&s.setAttribute("apiUrl",this.apiUrl),this.embedUrl!==ot&&s.setAttribute("embedUrl",this.embedUrl),document.body.appendChild(s)),this._widgets={...this._widgets,[t]:s},window.ace=window.ace||{_c:[],_w:[],widget:function(i,n){window.ace._w.push([i,n])},configure:function(i){window.ace._c.push(i)}}}async render(){if(!this._site)return d;const t=[];(this._site.triggers||[]).filter(e=>e.triggerType==="visit").forEach(e=>{const s=window.location.pathname,i=e.condition.outputs||[];e.condition.type==="url"&&i.forEach(n=>{var h;const o=n.action.type==="render_widget";if((n.value===s||n.value==="*")&&o){let l={widgetId:""};try{l=JSON.parse(n.action.data)}catch{l={widgetId:""}}const p=t.findIndex(u=>u.widgetId===l.widgetId)>-1,c=(((h=this._site)==null?void 0:h.widgets)||[]).find(u=>u.widgetId===l.widgetId);c&&!p&&t.push(c)}})});for await(const e of t){const s=this._widgets[e.widgetId];s&&s.activate()}return d}}M([A({attribute:!0})],w.prototype,"siteId",2);M([A()],w.prototype,"apiUrl",2);M([A()],w.prototype,"embedUrl",2);M([L()],w.prototype,"_site",2);M([L()],w.prototype,"_widgets",2);window.customElements.get("ace-site")||window.customElements.define("ace-site",w);var It=Object.defineProperty,jt=Object.getOwnPropertyDescriptor,R=(r,t,e,s)=>{for(var i=s>1?void 0:s?jt(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&It(t,e,i),i};const kt="https://widgets.ace.teliacompany.net",zt="https://embed.webprovisions.io";class v extends E{constructor(){super(...arguments),this.apiUrl=kt,this.embedUrl=zt,this.widget=null,this.scriptEl=null}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}async activate(){this.widget||(this.widget=await this._loadWidget(this.widgetId)),this._createEmbedScript()}render(){return this.scriptEl?this.scriptEl:d}}R([A({attribute:!0})],v.prototype,"widgetId",2);R([A()],v.prototype,"apiUrl",2);R([A()],v.prototype,"embedUrl",2);R([L()],v.prototype,"widget",2);R([L()],v.prototype,"scriptEl",2);customElements.get("ace-widget-wrapper")||customElements.define("ace-widget-wrapper",v);exports.SiteComponent=w;exports.WidgetComponent=v;
|
package/index.mjs
ADDED
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
5
|
+
*/
|
|
6
|
+
const j = globalThis, J = j.ShadowRoot && (j.ShadyCSS === void 0 || j.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype, at = Symbol(), F = /* @__PURE__ */ new WeakMap();
|
|
7
|
+
let ut = class {
|
|
8
|
+
constructor(t, e, s) {
|
|
9
|
+
if (this._$cssResult$ = !0, s !== at)
|
|
10
|
+
throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
|
|
11
|
+
this.cssText = t, this.t = e;
|
|
12
|
+
}
|
|
13
|
+
get styleSheet() {
|
|
14
|
+
let t = this.o;
|
|
15
|
+
const e = this.t;
|
|
16
|
+
if (J && t === void 0) {
|
|
17
|
+
const s = e !== void 0 && e.length === 1;
|
|
18
|
+
s && (t = F.get(e)), t === void 0 && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), s && F.set(e, t));
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
}
|
|
22
|
+
toString() {
|
|
23
|
+
return this.cssText;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const $t = (r) => new ut(typeof r == "string" ? r : r + "", void 0, at), _t = (r, t) => {
|
|
27
|
+
if (J)
|
|
28
|
+
r.adoptedStyleSheets = t.map((e) => e instanceof CSSStyleSheet ? e : e.styleSheet);
|
|
29
|
+
else
|
|
30
|
+
for (const e of t) {
|
|
31
|
+
const s = document.createElement("style"), i = j.litNonce;
|
|
32
|
+
i !== void 0 && s.setAttribute("nonce", i), s.textContent = e.cssText, r.appendChild(s);
|
|
33
|
+
}
|
|
34
|
+
}, G = J ? (r) => r : (r) => r instanceof CSSStyleSheet ? ((t) => {
|
|
35
|
+
let e = "";
|
|
36
|
+
for (const s of t.cssRules)
|
|
37
|
+
e += s.cssText;
|
|
38
|
+
return $t(e);
|
|
39
|
+
})(r) : r;
|
|
40
|
+
/**
|
|
41
|
+
* @license
|
|
42
|
+
* Copyright 2017 Google LLC
|
|
43
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
44
|
+
*/
|
|
45
|
+
const { is: ft, defineProperty: gt, getOwnPropertyDescriptor: mt, getOwnPropertyNames: yt, getOwnPropertySymbols: At, getPrototypeOf: wt } = Object, f = globalThis, Q = f.trustedTypes, vt = Q ? Q.emptyScript : "", B = f.reactiveElementPolyfillSupport, C = (r, t) => r, k = { toAttribute(r, t) {
|
|
46
|
+
switch (t) {
|
|
47
|
+
case Boolean:
|
|
48
|
+
r = r ? vt : null;
|
|
49
|
+
break;
|
|
50
|
+
case Object:
|
|
51
|
+
case Array:
|
|
52
|
+
r = r == null ? r : JSON.stringify(r);
|
|
53
|
+
}
|
|
54
|
+
return r;
|
|
55
|
+
}, fromAttribute(r, t) {
|
|
56
|
+
let e = r;
|
|
57
|
+
switch (t) {
|
|
58
|
+
case Boolean:
|
|
59
|
+
e = r !== null;
|
|
60
|
+
break;
|
|
61
|
+
case Number:
|
|
62
|
+
e = r === null ? null : Number(r);
|
|
63
|
+
break;
|
|
64
|
+
case Object:
|
|
65
|
+
case Array:
|
|
66
|
+
try {
|
|
67
|
+
e = JSON.parse(r);
|
|
68
|
+
} catch {
|
|
69
|
+
e = null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return e;
|
|
73
|
+
} }, K = (r, t) => !ft(r, t), Y = { attribute: !0, type: String, converter: k, reflect: !1, hasChanged: K };
|
|
74
|
+
Symbol.metadata ?? (Symbol.metadata = Symbol("metadata")), f.litPropertyMetadata ?? (f.litPropertyMetadata = /* @__PURE__ */ new WeakMap());
|
|
75
|
+
class w extends HTMLElement {
|
|
76
|
+
static addInitializer(t) {
|
|
77
|
+
this._$Ei(), (this.l ?? (this.l = [])).push(t);
|
|
78
|
+
}
|
|
79
|
+
static get observedAttributes() {
|
|
80
|
+
return this.finalize(), this._$Eh && [...this._$Eh.keys()];
|
|
81
|
+
}
|
|
82
|
+
static createProperty(t, e = Y) {
|
|
83
|
+
if (e.state && (e.attribute = !1), this._$Ei(), this.elementProperties.set(t, e), !e.noAccessor) {
|
|
84
|
+
const s = Symbol(), i = this.getPropertyDescriptor(t, s, e);
|
|
85
|
+
i !== void 0 && gt(this.prototype, t, i);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
static getPropertyDescriptor(t, e, s) {
|
|
89
|
+
const { get: i, set: n } = mt(this.prototype, t) ?? { get() {
|
|
90
|
+
return this[e];
|
|
91
|
+
}, set(o) {
|
|
92
|
+
this[e] = o;
|
|
93
|
+
} };
|
|
94
|
+
return { get() {
|
|
95
|
+
return i == null ? void 0 : i.call(this);
|
|
96
|
+
}, set(o) {
|
|
97
|
+
const a = i == null ? void 0 : i.call(this);
|
|
98
|
+
n.call(this, o), this.requestUpdate(t, a, s);
|
|
99
|
+
}, configurable: !0, enumerable: !0 };
|
|
100
|
+
}
|
|
101
|
+
static getPropertyOptions(t) {
|
|
102
|
+
return this.elementProperties.get(t) ?? Y;
|
|
103
|
+
}
|
|
104
|
+
static _$Ei() {
|
|
105
|
+
if (this.hasOwnProperty(C("elementProperties")))
|
|
106
|
+
return;
|
|
107
|
+
const t = wt(this);
|
|
108
|
+
t.finalize(), t.l !== void 0 && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
|
|
109
|
+
}
|
|
110
|
+
static finalize() {
|
|
111
|
+
if (this.hasOwnProperty(C("finalized")))
|
|
112
|
+
return;
|
|
113
|
+
if (this.finalized = !0, this._$Ei(), this.hasOwnProperty(C("properties"))) {
|
|
114
|
+
const e = this.properties, s = [...yt(e), ...At(e)];
|
|
115
|
+
for (const i of s)
|
|
116
|
+
this.createProperty(i, e[i]);
|
|
117
|
+
}
|
|
118
|
+
const t = this[Symbol.metadata];
|
|
119
|
+
if (t !== null) {
|
|
120
|
+
const e = litPropertyMetadata.get(t);
|
|
121
|
+
if (e !== void 0)
|
|
122
|
+
for (const [s, i] of e)
|
|
123
|
+
this.elementProperties.set(s, i);
|
|
124
|
+
}
|
|
125
|
+
this._$Eh = /* @__PURE__ */ new Map();
|
|
126
|
+
for (const [e, s] of this.elementProperties) {
|
|
127
|
+
const i = this._$Eu(e, s);
|
|
128
|
+
i !== void 0 && this._$Eh.set(i, e);
|
|
129
|
+
}
|
|
130
|
+
this.elementStyles = this.finalizeStyles(this.styles);
|
|
131
|
+
}
|
|
132
|
+
static finalizeStyles(t) {
|
|
133
|
+
const e = [];
|
|
134
|
+
if (Array.isArray(t)) {
|
|
135
|
+
const s = new Set(t.flat(1 / 0).reverse());
|
|
136
|
+
for (const i of s)
|
|
137
|
+
e.unshift(G(i));
|
|
138
|
+
} else
|
|
139
|
+
t !== void 0 && e.push(G(t));
|
|
140
|
+
return e;
|
|
141
|
+
}
|
|
142
|
+
static _$Eu(t, e) {
|
|
143
|
+
const s = e.attribute;
|
|
144
|
+
return s === !1 ? void 0 : typeof s == "string" ? s : typeof t == "string" ? t.toLowerCase() : void 0;
|
|
145
|
+
}
|
|
146
|
+
constructor() {
|
|
147
|
+
super(), this._$Ep = void 0, this.isUpdatePending = !1, this.hasUpdated = !1, this._$Em = null, this._$Ev();
|
|
148
|
+
}
|
|
149
|
+
_$Ev() {
|
|
150
|
+
var t;
|
|
151
|
+
this._$ES = new Promise((e) => this.enableUpdating = e), this._$AL = /* @__PURE__ */ new Map(), this._$E_(), this.requestUpdate(), (t = this.constructor.l) == null || t.forEach((e) => e(this));
|
|
152
|
+
}
|
|
153
|
+
addController(t) {
|
|
154
|
+
var e;
|
|
155
|
+
(this._$EO ?? (this._$EO = /* @__PURE__ */ new Set())).add(t), this.renderRoot !== void 0 && this.isConnected && ((e = t.hostConnected) == null || e.call(t));
|
|
156
|
+
}
|
|
157
|
+
removeController(t) {
|
|
158
|
+
var e;
|
|
159
|
+
(e = this._$EO) == null || e.delete(t);
|
|
160
|
+
}
|
|
161
|
+
_$E_() {
|
|
162
|
+
const t = /* @__PURE__ */ new Map(), e = this.constructor.elementProperties;
|
|
163
|
+
for (const s of e.keys())
|
|
164
|
+
this.hasOwnProperty(s) && (t.set(s, this[s]), delete this[s]);
|
|
165
|
+
t.size > 0 && (this._$Ep = t);
|
|
166
|
+
}
|
|
167
|
+
createRenderRoot() {
|
|
168
|
+
const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
|
|
169
|
+
return _t(t, this.constructor.elementStyles), t;
|
|
170
|
+
}
|
|
171
|
+
connectedCallback() {
|
|
172
|
+
var t;
|
|
173
|
+
this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), (t = this._$EO) == null || t.forEach((e) => {
|
|
174
|
+
var s;
|
|
175
|
+
return (s = e.hostConnected) == null ? void 0 : s.call(e);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
enableUpdating(t) {
|
|
179
|
+
}
|
|
180
|
+
disconnectedCallback() {
|
|
181
|
+
var t;
|
|
182
|
+
(t = this._$EO) == null || t.forEach((e) => {
|
|
183
|
+
var s;
|
|
184
|
+
return (s = e.hostDisconnected) == null ? void 0 : s.call(e);
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
attributeChangedCallback(t, e, s) {
|
|
188
|
+
this._$AK(t, s);
|
|
189
|
+
}
|
|
190
|
+
_$EC(t, e) {
|
|
191
|
+
var n;
|
|
192
|
+
const s = this.constructor.elementProperties.get(t), i = this.constructor._$Eu(t, s);
|
|
193
|
+
if (i !== void 0 && s.reflect === !0) {
|
|
194
|
+
const o = (((n = s.converter) == null ? void 0 : n.toAttribute) !== void 0 ? s.converter : k).toAttribute(e, s.type);
|
|
195
|
+
this._$Em = t, o == null ? this.removeAttribute(i) : this.setAttribute(i, o), this._$Em = null;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
_$AK(t, e) {
|
|
199
|
+
var n;
|
|
200
|
+
const s = this.constructor, i = s._$Eh.get(t);
|
|
201
|
+
if (i !== void 0 && this._$Em !== i) {
|
|
202
|
+
const o = s.getPropertyOptions(i), a = typeof o.converter == "function" ? { fromAttribute: o.converter } : ((n = o.converter) == null ? void 0 : n.fromAttribute) !== void 0 ? o.converter : k;
|
|
203
|
+
this._$Em = i, this[i] = a.fromAttribute(e, o.type), this._$Em = null;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
requestUpdate(t, e, s) {
|
|
207
|
+
if (t !== void 0) {
|
|
208
|
+
if (s ?? (s = this.constructor.getPropertyOptions(t)), !(s.hasChanged ?? K)(this[t], e))
|
|
209
|
+
return;
|
|
210
|
+
this.P(t, e, s);
|
|
211
|
+
}
|
|
212
|
+
this.isUpdatePending === !1 && (this._$ES = this._$ET());
|
|
213
|
+
}
|
|
214
|
+
P(t, e, s) {
|
|
215
|
+
this._$AL.has(t) || this._$AL.set(t, e), s.reflect === !0 && this._$Em !== t && (this._$Ej ?? (this._$Ej = /* @__PURE__ */ new Set())).add(t);
|
|
216
|
+
}
|
|
217
|
+
async _$ET() {
|
|
218
|
+
this.isUpdatePending = !0;
|
|
219
|
+
try {
|
|
220
|
+
await this._$ES;
|
|
221
|
+
} catch (e) {
|
|
222
|
+
Promise.reject(e);
|
|
223
|
+
}
|
|
224
|
+
const t = this.scheduleUpdate();
|
|
225
|
+
return t != null && await t, !this.isUpdatePending;
|
|
226
|
+
}
|
|
227
|
+
scheduleUpdate() {
|
|
228
|
+
return this.performUpdate();
|
|
229
|
+
}
|
|
230
|
+
performUpdate() {
|
|
231
|
+
var s;
|
|
232
|
+
if (!this.isUpdatePending)
|
|
233
|
+
return;
|
|
234
|
+
if (!this.hasUpdated) {
|
|
235
|
+
if (this.renderRoot ?? (this.renderRoot = this.createRenderRoot()), this._$Ep) {
|
|
236
|
+
for (const [n, o] of this._$Ep)
|
|
237
|
+
this[n] = o;
|
|
238
|
+
this._$Ep = void 0;
|
|
239
|
+
}
|
|
240
|
+
const i = this.constructor.elementProperties;
|
|
241
|
+
if (i.size > 0)
|
|
242
|
+
for (const [n, o] of i)
|
|
243
|
+
o.wrapped !== !0 || this._$AL.has(n) || this[n] === void 0 || this.P(n, this[n], o);
|
|
244
|
+
}
|
|
245
|
+
let t = !1;
|
|
246
|
+
const e = this._$AL;
|
|
247
|
+
try {
|
|
248
|
+
t = this.shouldUpdate(e), t ? (this.willUpdate(e), (s = this._$EO) == null || s.forEach((i) => {
|
|
249
|
+
var n;
|
|
250
|
+
return (n = i.hostUpdate) == null ? void 0 : n.call(i);
|
|
251
|
+
}), this.update(e)) : this._$EU();
|
|
252
|
+
} catch (i) {
|
|
253
|
+
throw t = !1, this._$EU(), i;
|
|
254
|
+
}
|
|
255
|
+
t && this._$AE(e);
|
|
256
|
+
}
|
|
257
|
+
willUpdate(t) {
|
|
258
|
+
}
|
|
259
|
+
_$AE(t) {
|
|
260
|
+
var e;
|
|
261
|
+
(e = this._$EO) == null || e.forEach((s) => {
|
|
262
|
+
var i;
|
|
263
|
+
return (i = s.hostUpdated) == null ? void 0 : i.call(s);
|
|
264
|
+
}), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t);
|
|
265
|
+
}
|
|
266
|
+
_$EU() {
|
|
267
|
+
this._$AL = /* @__PURE__ */ new Map(), this.isUpdatePending = !1;
|
|
268
|
+
}
|
|
269
|
+
get updateComplete() {
|
|
270
|
+
return this.getUpdateComplete();
|
|
271
|
+
}
|
|
272
|
+
getUpdateComplete() {
|
|
273
|
+
return this._$ES;
|
|
274
|
+
}
|
|
275
|
+
shouldUpdate(t) {
|
|
276
|
+
return !0;
|
|
277
|
+
}
|
|
278
|
+
update(t) {
|
|
279
|
+
this._$Ej && (this._$Ej = this._$Ej.forEach((e) => this._$EC(e, this[e]))), this._$EU();
|
|
280
|
+
}
|
|
281
|
+
updated(t) {
|
|
282
|
+
}
|
|
283
|
+
firstUpdated(t) {
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
w.elementStyles = [], w.shadowRootOptions = { mode: "open" }, w[C("elementProperties")] = /* @__PURE__ */ new Map(), w[C("finalized")] = /* @__PURE__ */ new Map(), B == null || B({ ReactiveElement: w }), (f.reactiveElementVersions ?? (f.reactiveElementVersions = [])).push("2.0.4");
|
|
287
|
+
/**
|
|
288
|
+
* @license
|
|
289
|
+
* Copyright 2017 Google LLC
|
|
290
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
291
|
+
*/
|
|
292
|
+
const O = globalThis, z = O.trustedTypes, X = z ? z.createPolicy("lit-html", { createHTML: (r) => r }) : void 0, ct = "$lit$", _ = `lit$${Math.random().toFixed(9).slice(2)}$`, lt = "?" + _, bt = `<${lt}>`, y = document, x = () => y.createComment(""), T = (r) => r === null || typeof r != "object" && typeof r != "function", Z = Array.isArray, Et = (r) => Z(r) || typeof (r == null ? void 0 : r[Symbol.iterator]) == "function", W = `[
|
|
293
|
+
\f\r]`, P = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, tt = /-->/g, et = />/g, g = RegExp(`>|${W}(?:([^\\s"'>=/]+)(${W}*=${W}*(?:[^
|
|
294
|
+
\f\r"'\`<>=]|("|')|))|$)`, "g"), st = /'/g, it = /"/g, dt = /^(?:script|style|textarea|title)$/i, b = Symbol.for("lit-noChange"), d = Symbol.for("lit-nothing"), rt = /* @__PURE__ */ new WeakMap(), m = y.createTreeWalker(y, 129);
|
|
295
|
+
function pt(r, t) {
|
|
296
|
+
if (!Z(r) || !r.hasOwnProperty("raw"))
|
|
297
|
+
throw Error("invalid template strings array");
|
|
298
|
+
return X !== void 0 ? X.createHTML(t) : t;
|
|
299
|
+
}
|
|
300
|
+
const St = (r, t) => {
|
|
301
|
+
const e = r.length - 1, s = [];
|
|
302
|
+
let i, n = t === 2 ? "<svg>" : t === 3 ? "<math>" : "", o = P;
|
|
303
|
+
for (let a = 0; a < e; a++) {
|
|
304
|
+
const h = r[a];
|
|
305
|
+
let l, p, c = -1, u = 0;
|
|
306
|
+
for (; u < h.length && (o.lastIndex = u, p = o.exec(h), p !== null); )
|
|
307
|
+
u = o.lastIndex, o === P ? p[1] === "!--" ? o = tt : p[1] !== void 0 ? o = et : p[2] !== void 0 ? (dt.test(p[2]) && (i = RegExp("</" + p[2], "g")), o = g) : p[3] !== void 0 && (o = g) : o === g ? p[0] === ">" ? (o = i ?? P, c = -1) : p[1] === void 0 ? c = -2 : (c = o.lastIndex - p[2].length, l = p[1], o = p[3] === void 0 ? g : p[3] === '"' ? it : st) : o === it || o === st ? o = g : o === tt || o === et ? o = P : (o = g, i = void 0);
|
|
308
|
+
const $ = o === g && r[a + 1].startsWith("/>") ? " " : "";
|
|
309
|
+
n += o === P ? h + bt : c >= 0 ? (s.push(l), h.slice(0, c) + ct + h.slice(c) + _ + $) : h + _ + (c === -2 ? a : $);
|
|
310
|
+
}
|
|
311
|
+
return [pt(r, n + (r[e] || "<?>") + (t === 2 ? "</svg>" : t === 3 ? "</math>" : "")), s];
|
|
312
|
+
};
|
|
313
|
+
class N {
|
|
314
|
+
constructor({ strings: t, _$litType$: e }, s) {
|
|
315
|
+
let i;
|
|
316
|
+
this.parts = [];
|
|
317
|
+
let n = 0, o = 0;
|
|
318
|
+
const a = t.length - 1, h = this.parts, [l, p] = St(t, e);
|
|
319
|
+
if (this.el = N.createElement(l, s), m.currentNode = this.el.content, e === 2 || e === 3) {
|
|
320
|
+
const c = this.el.content.firstChild;
|
|
321
|
+
c.replaceWith(...c.childNodes);
|
|
322
|
+
}
|
|
323
|
+
for (; (i = m.nextNode()) !== null && h.length < a; ) {
|
|
324
|
+
if (i.nodeType === 1) {
|
|
325
|
+
if (i.hasAttributes())
|
|
326
|
+
for (const c of i.getAttributeNames())
|
|
327
|
+
if (c.endsWith(ct)) {
|
|
328
|
+
const u = p[o++], $ = i.getAttribute(c).split(_), I = /([.?@])?(.*)/.exec(u);
|
|
329
|
+
h.push({ type: 1, index: n, name: I[2], strings: $, ctor: I[1] === "." ? Pt : I[1] === "?" ? Ct : I[1] === "@" ? Ot : D }), i.removeAttribute(c);
|
|
330
|
+
} else
|
|
331
|
+
c.startsWith(_) && (h.push({ type: 6, index: n }), i.removeAttribute(c));
|
|
332
|
+
if (dt.test(i.tagName)) {
|
|
333
|
+
const c = i.textContent.split(_), u = c.length - 1;
|
|
334
|
+
if (u > 0) {
|
|
335
|
+
i.textContent = z ? z.emptyScript : "";
|
|
336
|
+
for (let $ = 0; $ < u; $++)
|
|
337
|
+
i.append(c[$], x()), m.nextNode(), h.push({ type: 2, index: ++n });
|
|
338
|
+
i.append(c[u], x());
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
} else if (i.nodeType === 8)
|
|
342
|
+
if (i.data === lt)
|
|
343
|
+
h.push({ type: 2, index: n });
|
|
344
|
+
else {
|
|
345
|
+
let c = -1;
|
|
346
|
+
for (; (c = i.data.indexOf(_, c + 1)) !== -1; )
|
|
347
|
+
h.push({ type: 7, index: n }), c += _.length - 1;
|
|
348
|
+
}
|
|
349
|
+
n++;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
static createElement(t, e) {
|
|
353
|
+
const s = y.createElement("template");
|
|
354
|
+
return s.innerHTML = t, s;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function E(r, t, e = r, s) {
|
|
358
|
+
var o, a;
|
|
359
|
+
if (t === b)
|
|
360
|
+
return t;
|
|
361
|
+
let i = s !== void 0 ? (o = e.o) == null ? void 0 : o[s] : e.l;
|
|
362
|
+
const n = T(t) ? void 0 : t._$litDirective$;
|
|
363
|
+
return (i == null ? void 0 : i.constructor) !== n && ((a = i == null ? void 0 : i._$AO) == null || a.call(i, !1), n === void 0 ? i = void 0 : (i = new n(r), i._$AT(r, e, s)), s !== void 0 ? (e.o ?? (e.o = []))[s] = i : e.l = i), i !== void 0 && (t = E(r, i._$AS(r, t.values), i, s)), t;
|
|
364
|
+
}
|
|
365
|
+
class Ut {
|
|
366
|
+
constructor(t, e) {
|
|
367
|
+
this._$AV = [], this._$AN = void 0, this._$AD = t, this._$AM = e;
|
|
368
|
+
}
|
|
369
|
+
get parentNode() {
|
|
370
|
+
return this._$AM.parentNode;
|
|
371
|
+
}
|
|
372
|
+
get _$AU() {
|
|
373
|
+
return this._$AM._$AU;
|
|
374
|
+
}
|
|
375
|
+
u(t) {
|
|
376
|
+
const { el: { content: e }, parts: s } = this._$AD, i = ((t == null ? void 0 : t.creationScope) ?? y).importNode(e, !0);
|
|
377
|
+
m.currentNode = i;
|
|
378
|
+
let n = m.nextNode(), o = 0, a = 0, h = s[0];
|
|
379
|
+
for (; h !== void 0; ) {
|
|
380
|
+
if (o === h.index) {
|
|
381
|
+
let l;
|
|
382
|
+
h.type === 2 ? l = new H(n, n.nextSibling, this, t) : h.type === 1 ? l = new h.ctor(n, h.name, h.strings, this, t) : h.type === 6 && (l = new xt(n, this, t)), this._$AV.push(l), h = s[++a];
|
|
383
|
+
}
|
|
384
|
+
o !== (h == null ? void 0 : h.index) && (n = m.nextNode(), o++);
|
|
385
|
+
}
|
|
386
|
+
return m.currentNode = y, i;
|
|
387
|
+
}
|
|
388
|
+
p(t) {
|
|
389
|
+
let e = 0;
|
|
390
|
+
for (const s of this._$AV)
|
|
391
|
+
s !== void 0 && (s.strings !== void 0 ? (s._$AI(t, s, e), e += s.strings.length - 2) : s._$AI(t[e])), e++;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
class H {
|
|
395
|
+
get _$AU() {
|
|
396
|
+
var t;
|
|
397
|
+
return ((t = this._$AM) == null ? void 0 : t._$AU) ?? this.v;
|
|
398
|
+
}
|
|
399
|
+
constructor(t, e, s, i) {
|
|
400
|
+
this.type = 2, this._$AH = d, this._$AN = void 0, this._$AA = t, this._$AB = e, this._$AM = s, this.options = i, this.v = (i == null ? void 0 : i.isConnected) ?? !0;
|
|
401
|
+
}
|
|
402
|
+
get parentNode() {
|
|
403
|
+
let t = this._$AA.parentNode;
|
|
404
|
+
const e = this._$AM;
|
|
405
|
+
return e !== void 0 && (t == null ? void 0 : t.nodeType) === 11 && (t = e.parentNode), t;
|
|
406
|
+
}
|
|
407
|
+
get startNode() {
|
|
408
|
+
return this._$AA;
|
|
409
|
+
}
|
|
410
|
+
get endNode() {
|
|
411
|
+
return this._$AB;
|
|
412
|
+
}
|
|
413
|
+
_$AI(t, e = this) {
|
|
414
|
+
t = E(this, t, e), T(t) ? t === d || t == null || t === "" ? (this._$AH !== d && this._$AR(), this._$AH = d) : t !== this._$AH && t !== b && this._(t) : t._$litType$ !== void 0 ? this.$(t) : t.nodeType !== void 0 ? this.T(t) : Et(t) ? this.k(t) : this._(t);
|
|
415
|
+
}
|
|
416
|
+
O(t) {
|
|
417
|
+
return this._$AA.parentNode.insertBefore(t, this._$AB);
|
|
418
|
+
}
|
|
419
|
+
T(t) {
|
|
420
|
+
this._$AH !== t && (this._$AR(), this._$AH = this.O(t));
|
|
421
|
+
}
|
|
422
|
+
_(t) {
|
|
423
|
+
this._$AH !== d && T(this._$AH) ? this._$AA.nextSibling.data = t : this.T(y.createTextNode(t)), this._$AH = t;
|
|
424
|
+
}
|
|
425
|
+
$(t) {
|
|
426
|
+
var n;
|
|
427
|
+
const { values: e, _$litType$: s } = t, i = typeof s == "number" ? this._$AC(t) : (s.el === void 0 && (s.el = N.createElement(pt(s.h, s.h[0]), this.options)), s);
|
|
428
|
+
if (((n = this._$AH) == null ? void 0 : n._$AD) === i)
|
|
429
|
+
this._$AH.p(e);
|
|
430
|
+
else {
|
|
431
|
+
const o = new Ut(i, this), a = o.u(this.options);
|
|
432
|
+
o.p(e), this.T(a), this._$AH = o;
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
_$AC(t) {
|
|
436
|
+
let e = rt.get(t.strings);
|
|
437
|
+
return e === void 0 && rt.set(t.strings, e = new N(t)), e;
|
|
438
|
+
}
|
|
439
|
+
k(t) {
|
|
440
|
+
Z(this._$AH) || (this._$AH = [], this._$AR());
|
|
441
|
+
const e = this._$AH;
|
|
442
|
+
let s, i = 0;
|
|
443
|
+
for (const n of t)
|
|
444
|
+
i === e.length ? e.push(s = new H(this.O(x()), this.O(x()), this, this.options)) : s = e[i], s._$AI(n), i++;
|
|
445
|
+
i < e.length && (this._$AR(s && s._$AB.nextSibling, i), e.length = i);
|
|
446
|
+
}
|
|
447
|
+
_$AR(t = this._$AA.nextSibling, e) {
|
|
448
|
+
var s;
|
|
449
|
+
for ((s = this._$AP) == null ? void 0 : s.call(this, !1, !0, e); t && t !== this._$AB; ) {
|
|
450
|
+
const i = t.nextSibling;
|
|
451
|
+
t.remove(), t = i;
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
setConnected(t) {
|
|
455
|
+
var e;
|
|
456
|
+
this._$AM === void 0 && (this.v = t, (e = this._$AP) == null || e.call(this, t));
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
class D {
|
|
460
|
+
get tagName() {
|
|
461
|
+
return this.element.tagName;
|
|
462
|
+
}
|
|
463
|
+
get _$AU() {
|
|
464
|
+
return this._$AM._$AU;
|
|
465
|
+
}
|
|
466
|
+
constructor(t, e, s, i, n) {
|
|
467
|
+
this.type = 1, this._$AH = d, this._$AN = void 0, this.element = t, this.name = e, this._$AM = i, this.options = n, s.length > 2 || s[0] !== "" || s[1] !== "" ? (this._$AH = Array(s.length - 1).fill(new String()), this.strings = s) : this._$AH = d;
|
|
468
|
+
}
|
|
469
|
+
_$AI(t, e = this, s, i) {
|
|
470
|
+
const n = this.strings;
|
|
471
|
+
let o = !1;
|
|
472
|
+
if (n === void 0)
|
|
473
|
+
t = E(this, t, e, 0), o = !T(t) || t !== this._$AH && t !== b, o && (this._$AH = t);
|
|
474
|
+
else {
|
|
475
|
+
const a = t;
|
|
476
|
+
let h, l;
|
|
477
|
+
for (t = n[0], h = 0; h < n.length - 1; h++)
|
|
478
|
+
l = E(this, a[s + h], e, h), l === b && (l = this._$AH[h]), o || (o = !T(l) || l !== this._$AH[h]), l === d ? t = d : t !== d && (t += (l ?? "") + n[h + 1]), this._$AH[h] = l;
|
|
479
|
+
}
|
|
480
|
+
o && !i && this.j(t);
|
|
481
|
+
}
|
|
482
|
+
j(t) {
|
|
483
|
+
t === d ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, t ?? "");
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
class Pt extends D {
|
|
487
|
+
constructor() {
|
|
488
|
+
super(...arguments), this.type = 3;
|
|
489
|
+
}
|
|
490
|
+
j(t) {
|
|
491
|
+
this.element[this.name] = t === d ? void 0 : t;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
class Ct extends D {
|
|
495
|
+
constructor() {
|
|
496
|
+
super(...arguments), this.type = 4;
|
|
497
|
+
}
|
|
498
|
+
j(t) {
|
|
499
|
+
this.element.toggleAttribute(this.name, !!t && t !== d);
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
class Ot extends D {
|
|
503
|
+
constructor(t, e, s, i, n) {
|
|
504
|
+
super(t, e, s, i, n), this.type = 5;
|
|
505
|
+
}
|
|
506
|
+
_$AI(t, e = this) {
|
|
507
|
+
if ((t = E(this, t, e, 0) ?? d) === b)
|
|
508
|
+
return;
|
|
509
|
+
const s = this._$AH, i = t === d && s !== d || t.capture !== s.capture || t.once !== s.once || t.passive !== s.passive, n = t !== d && (s === d || i);
|
|
510
|
+
i && this.element.removeEventListener(this.name, this, s), n && this.element.addEventListener(this.name, this, t), this._$AH = t;
|
|
511
|
+
}
|
|
512
|
+
handleEvent(t) {
|
|
513
|
+
var e;
|
|
514
|
+
typeof this._$AH == "function" ? this._$AH.call(((e = this.options) == null ? void 0 : e.host) ?? this.element, t) : this._$AH.handleEvent(t);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
class xt {
|
|
518
|
+
constructor(t, e, s) {
|
|
519
|
+
this.element = t, this.type = 6, this._$AN = void 0, this._$AM = e, this.options = s;
|
|
520
|
+
}
|
|
521
|
+
get _$AU() {
|
|
522
|
+
return this._$AM._$AU;
|
|
523
|
+
}
|
|
524
|
+
_$AI(t) {
|
|
525
|
+
E(this, t);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
const V = O.litHtmlPolyfillSupport;
|
|
529
|
+
V == null || V(N, H), (O.litHtmlVersions ?? (O.litHtmlVersions = [])).push("3.2.0");
|
|
530
|
+
const Tt = (r, t, e) => {
|
|
531
|
+
const s = (e == null ? void 0 : e.renderBefore) ?? t;
|
|
532
|
+
let i = s._$litPart$;
|
|
533
|
+
if (i === void 0) {
|
|
534
|
+
const n = (e == null ? void 0 : e.renderBefore) ?? null;
|
|
535
|
+
s._$litPart$ = i = new H(t.insertBefore(x(), n), n, void 0, e ?? {});
|
|
536
|
+
}
|
|
537
|
+
return i._$AI(r), i;
|
|
538
|
+
};
|
|
539
|
+
/**
|
|
540
|
+
* @license
|
|
541
|
+
* Copyright 2017 Google LLC
|
|
542
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
543
|
+
*/
|
|
544
|
+
class v extends w {
|
|
545
|
+
constructor() {
|
|
546
|
+
super(...arguments), this.renderOptions = { host: this }, this.o = void 0;
|
|
547
|
+
}
|
|
548
|
+
createRenderRoot() {
|
|
549
|
+
var e;
|
|
550
|
+
const t = super.createRenderRoot();
|
|
551
|
+
return (e = this.renderOptions).renderBefore ?? (e.renderBefore = t.firstChild), t;
|
|
552
|
+
}
|
|
553
|
+
update(t) {
|
|
554
|
+
const e = this.render();
|
|
555
|
+
this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this.o = Tt(e, this.renderRoot, this.renderOptions);
|
|
556
|
+
}
|
|
557
|
+
connectedCallback() {
|
|
558
|
+
var t;
|
|
559
|
+
super.connectedCallback(), (t = this.o) == null || t.setConnected(!0);
|
|
560
|
+
}
|
|
561
|
+
disconnectedCallback() {
|
|
562
|
+
var t;
|
|
563
|
+
super.disconnectedCallback(), (t = this.o) == null || t.setConnected(!1);
|
|
564
|
+
}
|
|
565
|
+
render() {
|
|
566
|
+
return b;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
var ht;
|
|
570
|
+
v._$litElement$ = !0, v.finalized = !0, (ht = globalThis.litElementHydrateSupport) == null || ht.call(globalThis, { LitElement: v });
|
|
571
|
+
const q = globalThis.litElementPolyfillSupport;
|
|
572
|
+
q == null || q({ LitElement: v });
|
|
573
|
+
(globalThis.litElementVersions ?? (globalThis.litElementVersions = [])).push("4.1.0");
|
|
574
|
+
/**
|
|
575
|
+
* @license
|
|
576
|
+
* Copyright 2017 Google LLC
|
|
577
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
578
|
+
*/
|
|
579
|
+
const Nt = { attribute: !0, type: String, converter: k, reflect: !1, hasChanged: K }, Ht = (r = Nt, t, e) => {
|
|
580
|
+
const { kind: s, metadata: i } = e;
|
|
581
|
+
let n = globalThis.litPropertyMetadata.get(i);
|
|
582
|
+
if (n === void 0 && globalThis.litPropertyMetadata.set(i, n = /* @__PURE__ */ new Map()), n.set(e.name, r), s === "accessor") {
|
|
583
|
+
const { name: o } = e;
|
|
584
|
+
return { set(a) {
|
|
585
|
+
const h = t.get.call(this);
|
|
586
|
+
t.set.call(this, a), this.requestUpdate(o, h, r);
|
|
587
|
+
}, init(a) {
|
|
588
|
+
return a !== void 0 && this.P(o, void 0, r), a;
|
|
589
|
+
} };
|
|
590
|
+
}
|
|
591
|
+
if (s === "setter") {
|
|
592
|
+
const { name: o } = e;
|
|
593
|
+
return function(a) {
|
|
594
|
+
const h = this[o];
|
|
595
|
+
t.call(this, a), this.requestUpdate(o, h, r);
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
throw Error("Unsupported decorator location: " + s);
|
|
599
|
+
};
|
|
600
|
+
function A(r) {
|
|
601
|
+
return (t, e) => typeof e == "object" ? Ht(r, t, e) : ((s, i, n) => {
|
|
602
|
+
const o = i.hasOwnProperty(n);
|
|
603
|
+
return i.constructor.createProperty(n, o ? { ...s, wrapped: !0 } : s), o ? Object.getOwnPropertyDescriptor(i, n) : void 0;
|
|
604
|
+
})(r, t, e);
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* @license
|
|
608
|
+
* Copyright 2017 Google LLC
|
|
609
|
+
* SPDX-License-Identifier: BSD-3-Clause
|
|
610
|
+
*/
|
|
611
|
+
function L(r) {
|
|
612
|
+
return A({ ...r, state: !0, attribute: !1 });
|
|
613
|
+
}
|
|
614
|
+
var Mt = Object.defineProperty, Rt = Object.getOwnPropertyDescriptor, M = (r, t, e, s) => {
|
|
615
|
+
for (var i = s > 1 ? void 0 : s ? Rt(t, e) : t, n = r.length - 1, o; n >= 0; n--)
|
|
616
|
+
(o = r[n]) && (i = (s ? o(t, e, i) : o(i)) || i);
|
|
617
|
+
return s && i && Mt(t, e, i), i;
|
|
618
|
+
};
|
|
619
|
+
const nt = "https://widgets.ace.teliacompany.net", ot = "https://embed.webprovisions.io";
|
|
620
|
+
class S extends v {
|
|
621
|
+
constructor() {
|
|
622
|
+
super(...arguments), this.apiUrl = nt, this.embedUrl = ot, this._site = null, this._widgets = {};
|
|
623
|
+
}
|
|
624
|
+
async connectedCallback() {
|
|
625
|
+
super.connectedCallback(), await this.loadSite();
|
|
626
|
+
}
|
|
627
|
+
async disconnectedCallback() {
|
|
628
|
+
super.disconnectedCallback();
|
|
629
|
+
}
|
|
630
|
+
async loadSite() {
|
|
631
|
+
var s;
|
|
632
|
+
const e = await (await fetch(`${this.apiUrl}/api/site/${this.siteId}`)).json();
|
|
633
|
+
this._site = e, (((s = this._site) == null ? void 0 : s.widgets) || []).forEach(async (i) => {
|
|
634
|
+
this.addWidgetEl(i.widgetId);
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
addWidgetEl(t) {
|
|
638
|
+
const e = `ace-widget_${t}`;
|
|
639
|
+
let s = document.getElementById(e);
|
|
640
|
+
s || (s = document.createElement("ace-widget-wrapper"), s.setAttribute("id", e), s.setAttribute("widgetId", t), this.apiUrl !== nt && s.setAttribute("apiUrl", this.apiUrl), this.embedUrl !== ot && s.setAttribute("embedUrl", this.embedUrl), document.body.appendChild(s)), this._widgets = {
|
|
641
|
+
...this._widgets,
|
|
642
|
+
[t]: s
|
|
643
|
+
}, window.ace = window.ace || {
|
|
644
|
+
_c: [],
|
|
645
|
+
_w: [],
|
|
646
|
+
widget: function(i, n) {
|
|
647
|
+
window.ace._w.push([i, n]);
|
|
648
|
+
},
|
|
649
|
+
configure: function(i) {
|
|
650
|
+
window.ace._c.push(i);
|
|
651
|
+
}
|
|
652
|
+
};
|
|
653
|
+
}
|
|
654
|
+
async render() {
|
|
655
|
+
if (!this._site)
|
|
656
|
+
return d;
|
|
657
|
+
const t = [];
|
|
658
|
+
(this._site.triggers || []).filter((e) => e.triggerType === "visit").forEach((e) => {
|
|
659
|
+
const s = window.location.pathname, i = e.condition.outputs || [];
|
|
660
|
+
e.condition.type === "url" && i.forEach((n) => {
|
|
661
|
+
var h;
|
|
662
|
+
const o = n.action.type === "render_widget";
|
|
663
|
+
if ((n.value === s || n.value === "*") && o) {
|
|
664
|
+
let l = { widgetId: "" };
|
|
665
|
+
try {
|
|
666
|
+
l = JSON.parse(n.action.data);
|
|
667
|
+
} catch {
|
|
668
|
+
l = {
|
|
669
|
+
widgetId: ""
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
const p = t.findIndex(
|
|
673
|
+
(u) => u.widgetId === l.widgetId
|
|
674
|
+
) > -1, c = (((h = this._site) == null ? void 0 : h.widgets) || []).find(
|
|
675
|
+
(u) => u.widgetId === l.widgetId
|
|
676
|
+
);
|
|
677
|
+
c && !p && t.push(c);
|
|
678
|
+
}
|
|
679
|
+
});
|
|
680
|
+
});
|
|
681
|
+
for await (const e of t) {
|
|
682
|
+
const s = this._widgets[e.widgetId];
|
|
683
|
+
s && s.activate();
|
|
684
|
+
}
|
|
685
|
+
return d;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
M([
|
|
689
|
+
A({ attribute: !0 })
|
|
690
|
+
], S.prototype, "siteId", 2);
|
|
691
|
+
M([
|
|
692
|
+
A()
|
|
693
|
+
], S.prototype, "apiUrl", 2);
|
|
694
|
+
M([
|
|
695
|
+
A()
|
|
696
|
+
], S.prototype, "embedUrl", 2);
|
|
697
|
+
M([
|
|
698
|
+
L()
|
|
699
|
+
], S.prototype, "_site", 2);
|
|
700
|
+
M([
|
|
701
|
+
L()
|
|
702
|
+
], S.prototype, "_widgets", 2);
|
|
703
|
+
window.customElements.get("ace-site") || window.customElements.define("ace-site", S);
|
|
704
|
+
var It = Object.defineProperty, jt = Object.getOwnPropertyDescriptor, R = (r, t, e, s) => {
|
|
705
|
+
for (var i = s > 1 ? void 0 : s ? jt(t, e) : t, n = r.length - 1, o; n >= 0; n--)
|
|
706
|
+
(o = r[n]) && (i = (s ? o(t, e, i) : o(i)) || i);
|
|
707
|
+
return s && i && It(t, e, i), i;
|
|
708
|
+
};
|
|
709
|
+
const kt = "https://widgets.ace.teliacompany.net", zt = "https://embed.webprovisions.io";
|
|
710
|
+
class U extends v {
|
|
711
|
+
constructor() {
|
|
712
|
+
super(...arguments), this.apiUrl = kt, this.embedUrl = zt, this.widget = null, this.scriptEl = null;
|
|
713
|
+
}
|
|
714
|
+
async connectedCallback() {
|
|
715
|
+
super.connectedCallback(), this.widget = await this._loadWidget(this.widgetId);
|
|
716
|
+
}
|
|
717
|
+
async _loadWidget(t) {
|
|
718
|
+
return await (await fetch(`${this.apiUrl}/api/widget/${t}`)).json();
|
|
719
|
+
}
|
|
720
|
+
_createEmbedScript() {
|
|
721
|
+
var e;
|
|
722
|
+
if (!((e = this.widget) != null && e.distributionName))
|
|
723
|
+
return;
|
|
724
|
+
let t = document.createElement("script");
|
|
725
|
+
t.setAttribute("type", "module"), t.setAttribute("async", "true"), t.setAttribute(
|
|
726
|
+
"src",
|
|
727
|
+
`${this.embedUrl}/d/${this.widget.organization}/${this.widget.distributionName}@latest/index.js`
|
|
728
|
+
), this.scriptEl = t;
|
|
729
|
+
}
|
|
730
|
+
async activate() {
|
|
731
|
+
this.widget || (this.widget = await this._loadWidget(this.widgetId)), this._createEmbedScript();
|
|
732
|
+
}
|
|
733
|
+
render() {
|
|
734
|
+
return this.scriptEl ? this.scriptEl : d;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
R([
|
|
738
|
+
A({ attribute: !0 })
|
|
739
|
+
], U.prototype, "widgetId", 2);
|
|
740
|
+
R([
|
|
741
|
+
A()
|
|
742
|
+
], U.prototype, "apiUrl", 2);
|
|
743
|
+
R([
|
|
744
|
+
A()
|
|
745
|
+
], U.prototype, "embedUrl", 2);
|
|
746
|
+
R([
|
|
747
|
+
L()
|
|
748
|
+
], U.prototype, "widget", 2);
|
|
749
|
+
R([
|
|
750
|
+
L()
|
|
751
|
+
], U.prototype, "scriptEl", 2);
|
|
752
|
+
customElements.get("ace-widget-wrapper") || customElements.define("ace-widget-wrapper", U);
|
|
753
|
+
export {
|
|
754
|
+
S as SiteComponent,
|
|
755
|
+
U as WidgetComponent
|
|
756
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { WidgetComponent } from './widget.component';
|
|
3
|
+
type Site = {
|
|
4
|
+
id: string;
|
|
5
|
+
name: string;
|
|
6
|
+
triggers: Trigger[];
|
|
7
|
+
widgets: WidgetDefition[];
|
|
8
|
+
};
|
|
9
|
+
type WidgetDefition = {
|
|
10
|
+
widgetId: string;
|
|
11
|
+
};
|
|
12
|
+
type Trigger = {
|
|
13
|
+
triggerType: string;
|
|
14
|
+
condition: {
|
|
15
|
+
type: 'url' | string;
|
|
16
|
+
outputs: {
|
|
17
|
+
value: string;
|
|
18
|
+
action: {
|
|
19
|
+
type: 'render_widget' | string;
|
|
20
|
+
data: string;
|
|
21
|
+
};
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare class SiteComponent extends LitElement {
|
|
26
|
+
siteId: string;
|
|
27
|
+
apiUrl: string;
|
|
28
|
+
embedUrl: string;
|
|
29
|
+
_site: Site | null;
|
|
30
|
+
_widgets: Record<string, WidgetComponent>;
|
|
31
|
+
connectedCallback(): Promise<void>;
|
|
32
|
+
disconnectedCallback(): Promise<void>;
|
|
33
|
+
loadSite(): Promise<void>;
|
|
34
|
+
addWidgetEl(widgetId: string): void;
|
|
35
|
+
protected render(): Promise<symbol>;
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
type Widget = {
|
|
3
|
+
id: string;
|
|
4
|
+
distributionName: string;
|
|
5
|
+
organization: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class WidgetComponent extends LitElement {
|
|
8
|
+
widgetId: string;
|
|
9
|
+
apiUrl: string;
|
|
10
|
+
embedUrl: string;
|
|
11
|
+
widget: Widget | null;
|
|
12
|
+
scriptEl: HTMLElement | null;
|
|
13
|
+
connectedCallback(): Promise<void>;
|
|
14
|
+
private _loadWidget;
|
|
15
|
+
private _createEmbedScript;
|
|
16
|
+
activate(): Promise<void>;
|
|
17
|
+
protected render(): unknown;
|
|
18
|
+
}
|
|
19
|
+
export {};
|