@salla.sa/twilight-bundles 0.1.35 → 0.1.37

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