@blotoutio/providers-blotout-wallet-sdk 0.65.1 → 0.67.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.mjs CHANGED
@@ -32,6 +32,18 @@ new Set([
32
32
  ...expand('911,921,922,923,924,926,927,932,933,935,942,944,946,950,953,955,957-958,960-969,974,975,976,977,981-982,987,988,990-999'),
33
33
  ]);
34
34
 
35
+ const EMAIL_RE = /^[\w!#$%&'*+/=?^`{|}~-]+(:?\.[\w!#$%&'*+/=?^`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
36
+ const normalizeEmail = (email) => {
37
+ if (!email) {
38
+ return '';
39
+ }
40
+ const trimmedEmail = email.trim().toLowerCase();
41
+ if (!EMAIL_RE.test(trimmedEmail)) {
42
+ return '';
43
+ }
44
+ return trimmedEmail;
45
+ };
46
+
35
47
  const delay = (n, resolvedValue) => new Promise((resolve) => setTimeout(() => resolve(resolvedValue), n));
36
48
 
37
49
  const createEnabled = () => ({
@@ -109,9 +121,11 @@ const customAttributes = {
109
121
  const packageName = 'blotoutWallet';
110
122
  const PREVIEW_KEY_NAME = '_blotoutWalletPreview';
111
123
 
112
- var _a;
124
+ var _a$1;
113
125
  const registryKey = Symbol.for('blotout-wallet');
114
- (_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
126
+ if (typeof window != 'undefined') {
127
+ (_a$1 = window[registryKey]) !== null && _a$1 !== void 0 ? _a$1 : (window[registryKey] = {});
128
+ }
115
129
 
116
130
  // eslint-disable-next-line @nx/enforce-module-boundaries
117
131
  const getPreviewKey = () => {
@@ -130,7 +144,7 @@ const tag = () => {
130
144
  cartToken: null,
131
145
  previewKey: getPreviewKey(),
132
146
  };
133
- if (!window) {
147
+ if (typeof window == 'undefined') {
134
148
  return result;
135
149
  }
136
150
  const store = window[registryKey].storeAPI;
@@ -140,6 +154,250 @@ const tag = () => {
140
154
  return result;
141
155
  };
142
156
 
157
+ /**
158
+ * @license
159
+ * Copyright 2019 Google LLC
160
+ * SPDX-License-Identifier: BSD-3-Clause
161
+ */
162
+ const t$3=globalThis,e$5=t$3.ShadowRoot&&(void 0===t$3.ShadyCSS||t$3.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$5=new WeakMap;let n$4 = class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s$2)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$5&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$5.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$5.set(s,t));}return t}toString(){return this.cssText}};const r$5=t=>new n$4("string"==typeof t?t:t+"",void 0,s$2),i$4=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new n$4(o,t,s$2)},S$1=(s,o)=>{if(e$5)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$3.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$5?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$5(e)})(t):t;
163
+
164
+ /**
165
+ * @license
166
+ * Copyright 2017 Google LLC
167
+ * SPDX-License-Identifier: BSD-3-Clause
168
+ */const{is:i$3,defineProperty:e$4,getOwnPropertyDescriptor:r$4,getOwnPropertyNames:h$1,getOwnPropertySymbols:o$4,getPrototypeOf:n$3}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$3(t,s),y$1={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let b$1 = class b extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=y$1){if(s.state&&(s.attribute=!1),this._$Ei(),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(t,i,s);void 0!==r&&e$4(this.prototype,t,r);}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=r$4(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get(){return e?.call(this)},set(s){const r=e?.call(this);h.call(this,s),this.requestUpdate(t,r,i);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??y$1}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$3(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...h$1(t),...o$4(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return !1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$EC(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const r=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==r?this.removeAttribute(e):this.setAttribute(e,r),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e,this[e]=r.fromAttribute(s,t.type),this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??f$1)(this[t],s))return;this.P(t,s,i);}!1===this.isUpdatePending&&(this._$ES=this._$ET());}P(t,s,i){this._$AL.has(t)||this._$AL.set(t,s),!0===i.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t);}async _$ET(){this.isUpdatePending=!0;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t)!0!==i.wrapped||this._$AL.has(s)||void 0===this[s]||this.P(s,this[s],i);}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EU();}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),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.forEach((t=>this._$EC(t,this[t]))),this._$EU();}updated(t){}firstUpdated(t){}};b$1.elementStyles=[],b$1.shadowRootOptions={mode:"open"},b$1[d$1("elementProperties")]=new Map,b$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:b$1}),(a$1.reactiveElementVersions??=[]).push("2.0.4");
169
+
170
+ /**
171
+ * @license
172
+ * Copyright 2017 Google LLC
173
+ * SPDX-License-Identifier: BSD-3-Clause
174
+ */
175
+ const t$2=globalThis,i$2=t$2.trustedTypes,s$1=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$3="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$3="?"+h,n$2=`<${o$3}>`,r$3=document,l=()=>r$3.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),b=y(2),w=Symbol.for("lit-noChange"),T=Symbol.for("lit-nothing"),A=new WeakMap,E=r$3.createTreeWalker(r$3,129);function C(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$1?s$1.createHTML(i):i}const P=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n$2:d>=0?(o.push(a),s.slice(0,d)+e$3+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [C(t,l+(t[s]||"<?>")+(2===i?"</svg>":"")),o]};class V{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=P(t,s);if(this.el=V.createElement(f,n),E.currentNode=this.el.content,2===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=E.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$3)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?k:"?"===e[1]?H:"@"===e[1]?I:R}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$2?i$2.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),E.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$3)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r$3.createElement("template");return s.innerHTML=t,s}}function N(t,i,s=t,e){if(i===w)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=N(t,h._$AS(t,i.values),h,e)),i}class S{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r$3).importNode(i,!0);E.currentNode=e;let h=E.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new M(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new L(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=E.nextNode(),o++);}return E.currentNode=r$3,e}p(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class M{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=T,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??!0;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=N(this,t,i),c(t)?t===T||null==t||""===t?(this._$AH!==T&&this._$AR(),this._$AH=T):t!==this._$AH&&t!==w&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}S(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t));}_(t){this._$AH!==T&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r$3.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=V.createElement(C(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new S(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new V(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new M(this.S(l()),this.S(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class R{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=T,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=T;}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=N(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==w,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=N(this,e[s+n],i,n),r===w&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===T?t=T:t!==T&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===T?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class k extends R{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===T?void 0:t;}}class H extends R{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==T);}}class I extends R{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=N(this,t,i,0)??T)===w)return;const s=this._$AH,e=t===T&&s!==T||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==T&&(s===T||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class L{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){N(this,t);}}const Z=t$2.litHtmlPolyfillSupport;Z?.(V,M),(t$2.litHtmlVersions??=[]).push("3.1.3");const j=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new M(i.insertBefore(l(),t),t,void 0,s??{});}return h._$AI(t),h};
176
+
177
+ /**
178
+ * @license
179
+ * Copyright 2017 Google LLC
180
+ * SPDX-License-Identifier: BSD-3-Clause
181
+ */class s extends b$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=j(i,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1);}render(){return w}}s._$litElement$=!0,s[("finalized")]=!0,globalThis.litElementHydrateSupport?.({LitElement:s});const r$2=globalThis.litElementPolyfillSupport;r$2?.({LitElement:s});(globalThis.litElementVersions??=[]).push("4.0.5");
182
+
183
+ const cart = (attrs) => b `<svg class=${attrs === null || attrs === void 0 ? void 0 : attrs.class} style=${attrs === null || attrs === void 0 ? void 0 : attrs.style} width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
184
+ <g clip-path="url(#clip0_10367_379)">
185
+ <path d="M20 60C22.2091 60 24 58.2091 24 56C24 53.7909 22.2091 52 20 52C17.7909 52 16 53.7909 16 56C16 58.2091 17.7909 60 20 60Z" fill="currentColor"/>
186
+ <path d="M48 60C50.2091 60 52 58.2091 52 56C52 53.7909 50.2091 52 48 52C45.7909 52 44 53.7909 44 56C44 58.2091 45.7909 60 48 60Z" fill="currentColor"/>
187
+ <path d="M56 14.0004H11.64L10 5.60041C9.9065 5.14186 9.65515 4.73061 9.28972 4.43826C8.92428 4.14591 8.46789 3.99097 8 4.00041H0V8.00041H6.36L14 46.4004C14.0935 46.859 14.3448 47.2702 14.7103 47.5626C15.0757 47.8549 15.5321 48.0098 16 48.0004H52V44.0004H17.64L16 36.0004H52C52.4623 36.0117 52.9143 35.8624 53.2789 35.578C53.6436 35.2936 53.8984 34.8916 54 34.4404L58 16.4404C58.067 16.1437 58.0655 15.8355 57.9954 15.5395C57.9254 15.2434 57.7888 14.9672 57.5959 14.7319C57.4031 14.4967 57.1591 14.3085 56.8825 14.1817C56.606 14.0549 56.3041 13.9929 56 14.0004ZM50.4 32.0004H15.24L12.44 18.0004H53.5L50.4 32.0004Z" fill="currentColor"/>
188
+ </g>
189
+ <defs>
190
+ <clipPath id="clip0_10367_379">
191
+ <rect width="64" height="64" fill="none"/>
192
+ </clipPath>
193
+ </defs>
194
+ </svg>
195
+ `;
196
+ const cartTick = (attrs) => b `<svg class=${attrs === null || attrs === void 0 ? void 0 : attrs.class} style=${attrs === null || attrs === void 0 ? void 0 : attrs.style} width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
197
+ <g clip-path="url(#clip0_10367_199)">
198
+ <path d="M20 60C22.2091 60 24 58.2091 24 56C24 53.7909 22.2091 52 20 52C17.7909 52 16 53.7909 16 56C16 58.2091 17.7909 60 20 60Z" fill="currentColor"/>
199
+ <path d="M48 60C50.2091 60 52 58.2091 52 56C52 53.7909 50.2091 52 48 52C45.7909 52 44 53.7909 44 56C44 58.2091 45.7909 60 48 60Z" fill="currentColor"/>
200
+ <path d="M9.9612 5.6078C9.87053 5.15441 9.62557 4.74645 9.26801 4.45332C8.91045 4.16018 8.46236 3.99999 8 4H0V8H6.36L14.0388 46.3922C14.1295 46.8456 14.3744 47.2536 14.732 47.5467C15.0896 47.8398 15.5376 48 16 48H52V44H17.64L16.04 36H52C52.455 36 52.8965 35.8449 53.2514 35.5601C53.6064 35.2754 53.8537 34.8782 53.9524 34.434L58.489 14H54.3942L50.3964 32H15.24L9.9612 5.6078Z" fill="currentColor"/>
201
+ <path d="M32 16.3992L26.8 11.1992L24 13.9992L32 21.9992L46 7.99922L43.2 5.19922L32 16.3992Z" fill="currentColor"/>
202
+ </g>
203
+ <defs>
204
+ <clipPath id="clip0_10367_199">
205
+ <rect width="64" height="64" fill="none"/>
206
+ </clipPath>
207
+ </defs>
208
+ </svg>
209
+ `;
210
+ const circleCross = (attrs) => b `<svg class=${attrs === null || attrs === void 0 ? void 0 : attrs.class} style=${attrs === null || attrs === void 0 ? void 0 : attrs.style} width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
211
+ <path d="M32 9.25C44.544 9.25 54.75 19.456 54.75 32C54.75 44.544 44.544 54.75 32 54.75C19.456 54.75 9.25 44.544 9.25 32C9.25 19.456 19.456 9.25 32 9.25ZM32 4C16.5361 4 4 16.5361 4 32C4 47.4639 16.5361 60 32 60C47.4639 60 60 47.4639 60 32C60 16.5361 47.4639 4 32 4Z" fill="currentColor"/>
212
+ <path d="M47.5332 12.334L51.2443 16.0451L15.5379 51.7515L11.8268 48.0404L47.5332 12.334Z" fill="currentColor"/>
213
+ </svg>
214
+ `;
215
+ const logoImage = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAgCAYAAABU1PscAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEt0lEQVRYhdWYX4hUdRTHP+d358+6azNGqUVqilrQXaNIClKSQHsQpJceSu4IBSFIvQRWLwWW9dBD0IMYvUTNSAUGGVRYGLFQQU8aO2VhhVpBlOHcdXd2Z+b+vj3MrG6z7c7OpO32hTt/DjO/+/2ec37nnPszgJEoXCvYB2w3WCIwFi5+B44AB3Kl8nEbKYTrJT4ZSLlV1cSb13zzmx2BGWlneGmo5rUvJfH8QMqtGm34hez1i0gkvBeIzUDkgO3V5P9BfhISYDgzdqQMFrenjQGZwDAgEdQXYF5J4IxrXTs1ZyCojHs9UU30QN3rlZSzsXlh2QFe4NqNzgzgvEnFfKn8ruCoQW2h5tg0AS0YWF8lCg3I/JeEukVqvgmYzezFuWBeBQRmeClJoAokvawxbwICMzz6WbAf7BhQp4cJYE4CDEg7I3CGJERzs0ui7kXSQ5UNHJjsq4b0ea40fKr7FZqYi4Ag5Yxqw39X8zoKHBfEhpYCdwPbsoEtq3k5dSNEgPCtT8RRuBK4AUhP2i6PAOOPsYbfCxwWVsmXhqcu/mqlEK6ZSLQ37WxnIuV9FxraUMg4e9wZ1xmGEA0vGppdTEcB+WJ5CBia/D5S2JAWygJjueKwzxfLPwF74ig8lQnsqbrXsq4icQlBzavevJd+aHG73ZndhJSZack5b+KRaPB6occkfx+wBPgljsJDwDu5UjnOlcovx1G4OhvYrrpXvofpw4DXgTdypfKPAHEUbnLGCx62zOSUOZXgkcLgeqEjAyn3ZNbZxrSzdX2B25IN7DVnvBRH4XIAwcGJRKfpIofb0P6/oFOb6BiB8d0brTZafbE/5W4da/jU5B3qCGcQmO0GfR1HYSlXKn8bR+GXKbPVDZTrMgoCHgG2xlF4BgiADYlYyyxPWB0F1MaqG4B7qonPtvPxgowzEmkH8AEQA8PO7AJSriv6kGScpZ2xCdgkoOFFIolZItp5D8hWpB2ZxgzuTCQkVgDZlumcGY0uyQMUa16fctnLKDqfNOv1P8IZmBFLF0kvphn+2WGt1xbVXKl8Fjjbmc/fMYc+YCe89H0msI31RKl21zgMB8c8qrRM673U32nZxINHdwKb4yic4EqNErni8Ggchc/VEhWzgV1T92o9DRl9gTGe+C8ScUimP+PC4FKku+qeqzr1gkQiMFvp0QH9i2FuTmU0Vyp/hLFzItGQF+MtAiOjDf9WIh4WnMoXvxFSIRvYzTA9UjOJwAgCY3Fg5Hu55tzIcsXyx5Vdt3xm3tYLloD9CpzNlYYbACOFwa2S9tS9lndTPqUeXd/CTAIEjOdLZVUK4ToTi4CTuTfLNaA89Yf+0dvsQrX+kKT9zuxG9ThH9AqLo9AzZfM4Ay8qwNPAGWAbUADea10nMRszKS+4A3gw7exeSf2Jem/BPQsYiULf3ugMSLmmSYAk0s5R955EjNGsGH2ZwDImrOY7jIxXCM6MlCB2xt+GL9E8CzIueTRJPAY4o3/SXuvlSeYywQyEzjngw0XBtOMhYHo6iOb4kKj5Pl+wpge9xGEn7NnRhj89kHJyC/XwZwoCM7LOkXY2BLxtAJUoXGPwDHC/wdUL8Xi9lbYe+A14HziYK5VP/AXU+TX099lFgwAAAABJRU5ErkJggg==`;
216
+
217
+ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, storeAPI, }) => {
218
+ if (!baseURL) {
219
+ throw new Error(`baseURL missing`);
220
+ }
221
+ if (!userId) {
222
+ throw new Error(`userId missing`);
223
+ }
224
+ if (!storeAPI) {
225
+ throw new Error(`store API implementation missing`);
226
+ }
227
+ const getHeaders = (json = false) => {
228
+ const headers = new Headers({ EdgeTagUserId: userId });
229
+ if (json) {
230
+ headers.set('Content-type', 'application/json; charset=utf-8');
231
+ }
232
+ return headers;
233
+ };
234
+ const getURL = (path) => {
235
+ const url = new URL(`/providers/blotoutWallet${path}`, baseURL);
236
+ const cartToken = storeAPI.getCartToken();
237
+ if (cartToken) {
238
+ url.searchParams.set('t', cartToken);
239
+ }
240
+ const previewKey = getPreviewKey();
241
+ if (previewKey) {
242
+ url.searchParams.set('pk', previewKey);
243
+ }
244
+ return url;
245
+ };
246
+ const getExpiredCarts = async () => {
247
+ const response = await fetchImpl(getURL('/cart/expired'), {
248
+ method: 'GET',
249
+ headers: getHeaders(),
250
+ });
251
+ if (!response.ok) {
252
+ throw new Error(`Unable to get expired cart - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
253
+ }
254
+ const result = (await response.json());
255
+ if (result.hasJustExpired) {
256
+ window.edgetag('tag', 'CartRecovery_CartExpiredOnVisit', undefined, undefined, { destination: baseURL });
257
+ }
258
+ return result;
259
+ };
260
+ const sendEvent = async (action) => {
261
+ const response = await fetchImpl(getURL('/user/event'), {
262
+ method: 'POST',
263
+ headers: getHeaders(true),
264
+ body: JSON.stringify({ action }),
265
+ });
266
+ if (!response.ok) {
267
+ throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
268
+ }
269
+ };
270
+ const saveEmail = async (email) => {
271
+ const normalized = normalizeEmail(email);
272
+ if (!normalized) {
273
+ throw new Error(`Could not save email - invalid email format`);
274
+ }
275
+ window.edgetag('user', 'email', normalized, {}, { destination: baseURL });
276
+ const response = await fetchImpl(getURL('/user/email'), {
277
+ method: 'POST',
278
+ headers: getHeaders(true),
279
+ body: JSON.stringify({ email: normalized }),
280
+ });
281
+ if (!response.ok) {
282
+ throw new Error(`Could not save email - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
283
+ }
284
+ window.edgetag('tag', 'CartRecovery_KeepCartEmailSaved', undefined, undefined, { destination: baseURL });
285
+ };
286
+ const restoreCart = async (cartId, isSilent) => {
287
+ const response = await fetchImpl(getURL(`/cart/restore/${encodeURIComponent(cartId)}`), {
288
+ method: 'POST',
289
+ headers: getHeaders(),
290
+ });
291
+ if (!response.ok) {
292
+ throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
293
+ }
294
+ // Send the request as beacon as there could be a immediate redirect in the next step
295
+ window.edgetag('tag', 'CartRecovery_CartRestored', { isSilent }, undefined, { method: 'beacon' });
296
+ };
297
+ const deleteCarts = async () => {
298
+ const response = await fetchImpl(getURL('/cart/skip'), {
299
+ method: 'POST',
300
+ headers: getHeaders(),
301
+ });
302
+ if (!response.ok) {
303
+ throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
304
+ }
305
+ window.edgetag('tag', 'CartRecovery_CartDeclined', undefined, undefined, {
306
+ destination: baseURL,
307
+ });
308
+ };
309
+ return {
310
+ getExpiredCarts,
311
+ sendEvent,
312
+ saveEmail,
313
+ restoreCart,
314
+ deleteCarts,
315
+ };
316
+ };
317
+
318
+ const logStyles = `
319
+ padding: 4px 8px 4px 36px;
320
+ border: 1px dashed red;
321
+ border-radius: 3px;
322
+ font-weight: bold;
323
+ background: url(${logoImage}) 8px 50% no-repeat;
324
+ background-size: 24px 16px;
325
+ `;
326
+ const log = (message) => console.log(`%c${message}`, logStyles);
327
+ const error = (message) => console.error(`%c${message}`, logStyles);
328
+ const init = (params) => {
329
+ var _a, _b, _c, _d, _e, _f, _g, _h;
330
+ if (typeof window == 'undefined' || typeof document == 'undefined') {
331
+ // if loaded in non-browser SDKs, return early
332
+ return;
333
+ }
334
+ let storeAPI = window[registryKey].storeAPI;
335
+ if (!storeAPI) {
336
+ storeAPI = window[registryKey].storeAPI =
337
+ (_b = (_a = window[registryKey]).storeAPIFactory) === null || _b === void 0 ? void 0 : _b.call(_a);
338
+ }
339
+ if (!storeAPI) {
340
+ console.error('Implementation for store API missing!');
341
+ return;
342
+ }
343
+ if (window.top !== window) {
344
+ // exit if not in top window
345
+ return;
346
+ }
347
+ const { enabled, previewKey, mode = 'disabled', } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
348
+ const experiment = createExperiment({
349
+ name: mode,
350
+ userId: params.userId,
351
+ previewKey,
352
+ userPreviewKey: getPreviewKey(),
353
+ });
354
+ if (experiment.name == 'preview') {
355
+ if (experiment.isEnabled) {
356
+ log('Previewing functionality using preview key');
357
+ }
358
+ else if (getPreviewKey()) {
359
+ log('Preview key set but does not match the configured key');
360
+ }
361
+ }
362
+ if (enabled || experiment.isEnabled) {
363
+ const uiImplementation = window[registryKey].ui;
364
+ if (!uiImplementation) {
365
+ error('UI implementation is missing');
366
+ return;
367
+ }
368
+ const walletAPI = createWalletAPI({
369
+ baseURL: params.baseUrl,
370
+ storeAPI,
371
+ userId: params.userId,
372
+ });
373
+ uiImplementation.init({
374
+ theme: (_e = (_d = params.manifest.variables) === null || _d === void 0 ? void 0 : _d.theme) !== null && _e !== void 0 ? _e : {},
375
+ afterRestore: (_g = (_f = params.manifest.variables) === null || _f === void 0 ? void 0 : _f.afterRestore) !== null && _g !== void 0 ? _g : {
376
+ action: 'none',
377
+ },
378
+ silentRestore: !!((_h = params.manifest.variables) === null || _h === void 0 ? void 0 : _h.silentRestore),
379
+ walletAPI,
380
+ storeAPI,
381
+ });
382
+ }
383
+ };
384
+
385
+ // eslint-disable-next-line @nx/enforce-module-boundaries
386
+ const data = {
387
+ name: packageName,
388
+ init,
389
+ tag,
390
+ };
391
+ try {
392
+ if (typeof window !== 'undefined') {
393
+ window.edgetagProviders = window.edgetagProviders || [];
394
+ window.edgetagProviders.push(data);
395
+ }
396
+ }
397
+ catch {
398
+ // no window
399
+ }
400
+
143
401
  /******************************************************************************
144
402
  Copyright (c) Microsoft Corporation.
145
403
 
@@ -173,32 +431,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
173
431
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
174
432
  };
175
433
 
176
- /**
177
- * @license
178
- * Copyright 2019 Google LLC
179
- * SPDX-License-Identifier: BSD-3-Clause
180
- */
181
- const t$3=globalThis,e$5=t$3.ShadowRoot&&(void 0===t$3.ShadyCSS||t$3.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$5=new WeakMap;let n$4 = class n{constructor(t,e,o){if(this._$cssResult$=!0,o!==s$2)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$5&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$5.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$5.set(s,t));}return t}toString(){return this.cssText}};const r$5=t=>new n$4("string"==typeof t?t:t+"",void 0,s$2),i$4=(t,...e)=>{const o=1===t.length?t[0]:e.reduce(((e,s,o)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(s)+t[o+1]),t[0]);return new n$4(o,t,s$2)},S$1=(s,o)=>{if(e$5)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$3.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$5?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$5(e)})(t):t;
182
-
183
- /**
184
- * @license
185
- * Copyright 2017 Google LLC
186
- * SPDX-License-Identifier: BSD-3-Clause
187
- */const{is:i$3,defineProperty:e$4,getOwnPropertyDescriptor:r$4,getOwnPropertyNames:h$1,getOwnPropertySymbols:o$4,getPrototypeOf:n$3}=Object,a$1=globalThis,c$1=a$1.trustedTypes,l$1=c$1?c$1.emptyScript:"",p$1=a$1.reactiveElementPolyfillSupport,d$1=(t,s)=>t,u$1={toAttribute(t,s){switch(s){case Boolean:t=t?l$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f$1=(t,s)=>!i$3(t,s),y$1={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;let b$1 = class b extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=y$1){if(s.state&&(s.attribute=!1),this._$Ei(),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(t,i,s);void 0!==r&&e$4(this.prototype,t,r);}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=r$4(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get(){return e?.call(this)},set(s){const r=e?.call(this);h.call(this,s),this.requestUpdate(t,r,i);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??y$1}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$3(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d$1("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(d$1("properties"))){const t=this.properties,s=[...h$1(t),...o$4(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$2(s));}else void 0!==s&&i.push(c$2(s));return i}static _$Eu(t,s){const i=s.attribute;return !1===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S$1(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$EC(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&!0===i.reflect){const r=(void 0!==i.converter?.toAttribute?i.converter:u$1).toAttribute(s,i.type);this._$Em=t,null==r?this.removeAttribute(e):this.setAttribute(e,r),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),r="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u$1;this._$Em=e,this[e]=r.fromAttribute(s,t.type),this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){if(i??=this.constructor.getPropertyOptions(t),!(i.hasChanged??f$1)(this[t],s))return;this.P(t,s,i);}!1===this.isUpdatePending&&(this._$ES=this._$ET());}P(t,s,i){this._$AL.has(t)||this._$AL.set(t,s),!0===i.reflect&&this._$Em!==t&&(this._$Ej??=new Set).add(t);}async _$ET(){this.isUpdatePending=!0;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t)!0!==i.wrapped||this._$AL.has(s)||void 0===this[s]||this.P(s,this[s],i);}let t=!1;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EU();}catch(s){throw t=!1,this._$EU(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),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.forEach((t=>this._$EC(t,this[t]))),this._$EU();}updated(t){}firstUpdated(t){}};b$1.elementStyles=[],b$1.shadowRootOptions={mode:"open"},b$1[d$1("elementProperties")]=new Map,b$1[d$1("finalized")]=new Map,p$1?.({ReactiveElement:b$1}),(a$1.reactiveElementVersions??=[]).push("2.0.4");
188
-
189
- /**
190
- * @license
191
- * Copyright 2017 Google LLC
192
- * SPDX-License-Identifier: BSD-3-Clause
193
- */
194
- const t$2=globalThis,i$2=t$2.trustedTypes,s$1=i$2?i$2.createPolicy("lit-html",{createHTML:t=>t}):void 0,e$3="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o$3="?"+h,n$2=`<${o$3}>`,r$3=document,l=()=>r$3.createComment(""),c=t=>null===t||"object"!=typeof t&&"function"!=typeof t,a=Array.isArray,u=t=>a(t)||"function"==typeof t?.[Symbol.iterator],d="[ \t\n\f\r]",f=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,_=/>/g,m=RegExp(`>|${d}(?:([^\\s"'>=/]+)(${d}*=${d}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),p=/'/g,g=/"/g,$=/^(?:script|style|textarea|title)$/i,y=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),x=y(1),b=y(2),w=Symbol.for("lit-noChange"),T=Symbol.for("lit-nothing"),A=new WeakMap,E=r$3.createTreeWalker(r$3,129);function C(t,i){if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==s$1?s$1.createHTML(i):i}const P=(t,i)=>{const s=t.length-1,o=[];let r,l=2===i?"<svg>":"",c=f;for(let i=0;i<s;i++){const s=t[i];let a,u,d=-1,y=0;for(;y<s.length&&(c.lastIndex=y,u=c.exec(s),null!==u);)y=c.lastIndex,c===f?"!--"===u[1]?c=v:void 0!==u[1]?c=_:void 0!==u[2]?($.test(u[2])&&(r=RegExp("</"+u[2],"g")),c=m):void 0!==u[3]&&(c=m):c===m?">"===u[0]?(c=r??f,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,a=u[1],c=void 0===u[3]?m:'"'===u[3]?g:p):c===g||c===p?c=m:c===v||c===_?c=f:(c=m,r=void 0);const x=c===m&&t[i+1].startsWith("/>")?" ":"";l+=c===f?s+n$2:d>=0?(o.push(a),s.slice(0,d)+e$3+s.slice(d)+h+x):s+h+(-2===d?i:x);}return [C(t,l+(t[s]||"<?>")+(2===i?"</svg>":"")),o]};class V{constructor({strings:t,_$litType$:s},n){let r;this.parts=[];let c=0,a=0;const u=t.length-1,d=this.parts,[f,v]=P(t,s);if(this.el=V.createElement(f,n),E.currentNode=this.el.content,2===s){const t=this.el.content.firstChild;t.replaceWith(...t.childNodes);}for(;null!==(r=E.nextNode())&&d.length<u;){if(1===r.nodeType){if(r.hasAttributes())for(const t of r.getAttributeNames())if(t.endsWith(e$3)){const i=v[a++],s=r.getAttribute(t).split(h),e=/([.?@])?(.*)/.exec(i);d.push({type:1,index:c,name:e[2],strings:s,ctor:"."===e[1]?k:"?"===e[1]?H:"@"===e[1]?I:R}),r.removeAttribute(t);}else t.startsWith(h)&&(d.push({type:6,index:c}),r.removeAttribute(t));if($.test(r.tagName)){const t=r.textContent.split(h),s=t.length-1;if(s>0){r.textContent=i$2?i$2.emptyScript:"";for(let i=0;i<s;i++)r.append(t[i],l()),E.nextNode(),d.push({type:2,index:++c});r.append(t[s],l());}}}else if(8===r.nodeType)if(r.data===o$3)d.push({type:2,index:c});else {let t=-1;for(;-1!==(t=r.data.indexOf(h,t+1));)d.push({type:7,index:c}),t+=h.length-1;}c++;}}static createElement(t,i){const s=r$3.createElement("template");return s.innerHTML=t,s}}function N(t,i,s=t,e){if(i===w)return i;let h=void 0!==e?s._$Co?.[e]:s._$Cl;const o=c(i)?void 0:i._$litDirective$;return h?.constructor!==o&&(h?._$AO?.(!1),void 0===o?h=void 0:(h=new o(t),h._$AT(t,s,e)),void 0!==e?(s._$Co??=[])[e]=h:s._$Cl=h),void 0!==h&&(i=N(t,h._$AS(t,i.values),h,e)),i}class S{constructor(t,i){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=i;}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:i},parts:s}=this._$AD,e=(t?.creationScope??r$3).importNode(i,!0);E.currentNode=e;let h=E.nextNode(),o=0,n=0,l=s[0];for(;void 0!==l;){if(o===l.index){let i;2===l.type?i=new M(h,h.nextSibling,this,t):1===l.type?i=new l.ctor(h,l.name,l.strings,this,t):6===l.type&&(i=new L(h,this,t)),this._$AV.push(i),l=s[++n];}o!==l?.index&&(h=E.nextNode(),o++);}return E.currentNode=r$3,e}p(t){let i=0;for(const s of this._$AV)void 0!==s&&(void 0!==s.strings?(s._$AI(t,s,i),i+=s.strings.length-2):s._$AI(t[i])),i++;}}class M{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(t,i,s,e){this.type=2,this._$AH=T,this._$AN=void 0,this._$AA=t,this._$AB=i,this._$AM=s,this.options=e,this._$Cv=e?.isConnected??!0;}get parentNode(){let t=this._$AA.parentNode;const i=this._$AM;return void 0!==i&&11===t?.nodeType&&(t=i.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,i=this){t=N(this,t,i),c(t)?t===T||null==t||""===t?(this._$AH!==T&&this._$AR(),this._$AH=T):t!==this._$AH&&t!==w&&this._(t):void 0!==t._$litType$?this.$(t):void 0!==t.nodeType?this.T(t):u(t)?this.k(t):this._(t);}S(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.S(t));}_(t){this._$AH!==T&&c(this._$AH)?this._$AA.nextSibling.data=t:this.T(r$3.createTextNode(t)),this._$AH=t;}$(t){const{values:i,_$litType$:s}=t,e="number"==typeof s?this._$AC(t):(void 0===s.el&&(s.el=V.createElement(C(s.h,s.h[0]),this.options)),s);if(this._$AH?._$AD===e)this._$AH.p(i);else {const t=new S(e,this),s=t.u(this.options);t.p(i),this.T(s),this._$AH=t;}}_$AC(t){let i=A.get(t.strings);return void 0===i&&A.set(t.strings,i=new V(t)),i}k(t){a(this._$AH)||(this._$AH=[],this._$AR());const i=this._$AH;let s,e=0;for(const h of t)e===i.length?i.push(s=new M(this.S(l()),this.S(l()),this,this.options)):s=i[e],s._$AI(h),e++;e<i.length&&(this._$AR(s&&s._$AB.nextSibling,e),i.length=e);}_$AR(t=this._$AA.nextSibling,i){for(this._$AP?.(!1,!0,i);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i;}}setConnected(t){void 0===this._$AM&&(this._$Cv=t,this._$AP?.(t));}}class R{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,i,s,e,h){this.type=1,this._$AH=T,this._$AN=void 0,this.element=t,this.name=i,this._$AM=e,this.options=h,s.length>2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=T;}_$AI(t,i=this,s,e){const h=this.strings;let o=!1;if(void 0===h)t=N(this,t,i,0),o=!c(t)||t!==this._$AH&&t!==w,o&&(this._$AH=t);else {const e=t;let n,r;for(t=h[0],n=0;n<h.length-1;n++)r=N(this,e[s+n],i,n),r===w&&(r=this._$AH[n]),o||=!c(r)||r!==this._$AH[n],r===T?t=T:t!==T&&(t+=(r??"")+h[n+1]),this._$AH[n]=r;}o&&!e&&this.j(t);}j(t){t===T?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"");}}class k extends R{constructor(){super(...arguments),this.type=3;}j(t){this.element[this.name]=t===T?void 0:t;}}class H extends R{constructor(){super(...arguments),this.type=4;}j(t){this.element.toggleAttribute(this.name,!!t&&t!==T);}}class I extends R{constructor(t,i,s,e,h){super(t,i,s,e,h),this.type=5;}_$AI(t,i=this){if((t=N(this,t,i,0)??T)===w)return;const s=this._$AH,e=t===T&&s!==T||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,h=t!==T&&(s===T||e);e&&this.element.removeEventListener(this.name,this,s),h&&this.element.addEventListener(this.name,this,t),this._$AH=t;}handleEvent(t){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,t):this._$AH.handleEvent(t);}}class L{constructor(t,i,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=i,this.options=s;}get _$AU(){return this._$AM._$AU}_$AI(t){N(this,t);}}const Z=t$2.litHtmlPolyfillSupport;Z?.(V,M),(t$2.litHtmlVersions??=[]).push("3.1.3");const j=(t,i,s)=>{const e=s?.renderBefore??i;let h=e._$litPart$;if(void 0===h){const t=s?.renderBefore??null;e._$litPart$=h=new M(i.insertBefore(l(),t),t,void 0,s??{});}return h._$AI(t),h};
195
-
196
- /**
197
- * @license
198
- * Copyright 2017 Google LLC
199
- * SPDX-License-Identifier: BSD-3-Clause
200
- */class s extends b$1{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0;}createRenderRoot(){const t=super.createRenderRoot();return this.renderOptions.renderBefore??=t.firstChild,t}update(t){const i=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=j(i,this.renderRoot,this.renderOptions);}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0);}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1);}render(){return w}}s._$litElement$=!0,s[("finalized")]=!0,globalThis.litElementHydrateSupport?.({LitElement:s});const r$2=globalThis.litElementPolyfillSupport;r$2?.({LitElement:s});(globalThis.litElementVersions??=[]).push("4.0.5");
201
-
202
434
  /**
203
435
  * @license
204
436
  * Copyright 2017 Google LLC
@@ -462,40 +694,6 @@ const logger = {
462
694
  },
463
695
  };
464
696
 
465
- const cart = (attrs) => b `<svg class=${attrs === null || attrs === void 0 ? void 0 : attrs.class} style=${attrs === null || attrs === void 0 ? void 0 : attrs.style} width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
466
- <g clip-path="url(#clip0_10367_379)">
467
- <path d="M20 60C22.2091 60 24 58.2091 24 56C24 53.7909 22.2091 52 20 52C17.7909 52 16 53.7909 16 56C16 58.2091 17.7909 60 20 60Z" fill="currentColor"/>
468
- <path d="M48 60C50.2091 60 52 58.2091 52 56C52 53.7909 50.2091 52 48 52C45.7909 52 44 53.7909 44 56C44 58.2091 45.7909 60 48 60Z" fill="currentColor"/>
469
- <path d="M56 14.0004H11.64L10 5.60041C9.9065 5.14186 9.65515 4.73061 9.28972 4.43826C8.92428 4.14591 8.46789 3.99097 8 4.00041H0V8.00041H6.36L14 46.4004C14.0935 46.859 14.3448 47.2702 14.7103 47.5626C15.0757 47.8549 15.5321 48.0098 16 48.0004H52V44.0004H17.64L16 36.0004H52C52.4623 36.0117 52.9143 35.8624 53.2789 35.578C53.6436 35.2936 53.8984 34.8916 54 34.4404L58 16.4404C58.067 16.1437 58.0655 15.8355 57.9954 15.5395C57.9254 15.2434 57.7888 14.9672 57.5959 14.7319C57.4031 14.4967 57.1591 14.3085 56.8825 14.1817C56.606 14.0549 56.3041 13.9929 56 14.0004ZM50.4 32.0004H15.24L12.44 18.0004H53.5L50.4 32.0004Z" fill="currentColor"/>
470
- </g>
471
- <defs>
472
- <clipPath id="clip0_10367_379">
473
- <rect width="64" height="64" fill="none"/>
474
- </clipPath>
475
- </defs>
476
- </svg>
477
- `;
478
- const cartTick = (attrs) => b `<svg class=${attrs === null || attrs === void 0 ? void 0 : attrs.class} style=${attrs === null || attrs === void 0 ? void 0 : attrs.style} width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
479
- <g clip-path="url(#clip0_10367_199)">
480
- <path d="M20 60C22.2091 60 24 58.2091 24 56C24 53.7909 22.2091 52 20 52C17.7909 52 16 53.7909 16 56C16 58.2091 17.7909 60 20 60Z" fill="currentColor"/>
481
- <path d="M48 60C50.2091 60 52 58.2091 52 56C52 53.7909 50.2091 52 48 52C45.7909 52 44 53.7909 44 56C44 58.2091 45.7909 60 48 60Z" fill="currentColor"/>
482
- <path d="M9.9612 5.6078C9.87053 5.15441 9.62557 4.74645 9.26801 4.45332C8.91045 4.16018 8.46236 3.99999 8 4H0V8H6.36L14.0388 46.3922C14.1295 46.8456 14.3744 47.2536 14.732 47.5467C15.0896 47.8398 15.5376 48 16 48H52V44H17.64L16.04 36H52C52.455 36 52.8965 35.8449 53.2514 35.5601C53.6064 35.2754 53.8537 34.8782 53.9524 34.434L58.489 14H54.3942L50.3964 32H15.24L9.9612 5.6078Z" fill="currentColor"/>
483
- <path d="M32 16.3992L26.8 11.1992L24 13.9992L32 21.9992L46 7.99922L43.2 5.19922L32 16.3992Z" fill="currentColor"/>
484
- </g>
485
- <defs>
486
- <clipPath id="clip0_10367_199">
487
- <rect width="64" height="64" fill="none"/>
488
- </clipPath>
489
- </defs>
490
- </svg>
491
- `;
492
- const circleCross = (attrs) => b `<svg class=${attrs === null || attrs === void 0 ? void 0 : attrs.class} style=${attrs === null || attrs === void 0 ? void 0 : attrs.style} width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
493
- <path d="M32 9.25C44.544 9.25 54.75 19.456 54.75 32C54.75 44.544 44.544 54.75 32 54.75C19.456 54.75 9.25 44.544 9.25 32C9.25 19.456 19.456 9.25 32 9.25ZM32 4C16.5361 4 4 16.5361 4 32C4 47.4639 16.5361 60 32 60C47.4639 60 60 47.4639 60 32C60 16.5361 47.4639 4 32 4Z" fill="currentColor"/>
494
- <path d="M47.5332 12.334L51.2443 16.0451L15.5379 51.7515L11.8268 48.0404L47.5332 12.334Z" fill="currentColor"/>
495
- </svg>
496
- `;
497
- const logoImage = `data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAgCAYAAABU1PscAAAACXBIWXMAAAsTAAALEwEAmpwYAAAEt0lEQVRYhdWYX4hUdRTHP+d358+6azNGqUVqilrQXaNIClKSQHsQpJceSu4IBSFIvQRWLwWW9dBD0IMYvUTNSAUGGVRYGLFQQU8aO2VhhVpBlOHcdXd2Z+b+vj3MrG6z7c7OpO32hTt/DjO/+/2ec37nnPszgJEoXCvYB2w3WCIwFi5+B44AB3Kl8nEbKYTrJT4ZSLlV1cSb13zzmx2BGWlneGmo5rUvJfH8QMqtGm34hez1i0gkvBeIzUDkgO3V5P9BfhISYDgzdqQMFrenjQGZwDAgEdQXYF5J4IxrXTs1ZyCojHs9UU30QN3rlZSzsXlh2QFe4NqNzgzgvEnFfKn8ruCoQW2h5tg0AS0YWF8lCg3I/JeEukVqvgmYzezFuWBeBQRmeClJoAokvawxbwICMzz6WbAf7BhQp4cJYE4CDEg7I3CGJERzs0ui7kXSQ5UNHJjsq4b0ea40fKr7FZqYi4Ag5Yxqw39X8zoKHBfEhpYCdwPbsoEtq3k5dSNEgPCtT8RRuBK4AUhP2i6PAOOPsYbfCxwWVsmXhqcu/mqlEK6ZSLQ37WxnIuV9FxraUMg4e9wZ1xmGEA0vGppdTEcB+WJ5CBia/D5S2JAWygJjueKwzxfLPwF74ig8lQnsqbrXsq4icQlBzavevJd+aHG73ZndhJSZack5b+KRaPB6occkfx+wBPgljsJDwDu5UjnOlcovx1G4OhvYrrpXvofpw4DXgTdypfKPAHEUbnLGCx62zOSUOZXgkcLgeqEjAyn3ZNbZxrSzdX2B25IN7DVnvBRH4XIAwcGJRKfpIofb0P6/oFOb6BiB8d0brTZafbE/5W4da/jU5B3qCGcQmO0GfR1HYSlXKn8bR+GXKbPVDZTrMgoCHgG2xlF4BgiADYlYyyxPWB0F1MaqG4B7qonPtvPxgowzEmkH8AEQA8PO7AJSriv6kGScpZ2xCdgkoOFFIolZItp5D8hWpB2ZxgzuTCQkVgDZlumcGY0uyQMUa16fctnLKDqfNOv1P8IZmBFLF0kvphn+2WGt1xbVXKl8Fjjbmc/fMYc+YCe89H0msI31RKl21zgMB8c8qrRM673U32nZxINHdwKb4yic4EqNErni8Ggchc/VEhWzgV1T92o9DRl9gTGe+C8ScUimP+PC4FKku+qeqzr1gkQiMFvp0QH9i2FuTmU0Vyp/hLFzItGQF+MtAiOjDf9WIh4WnMoXvxFSIRvYzTA9UjOJwAgCY3Fg5Hu55tzIcsXyx5Vdt3xm3tYLloD9CpzNlYYbACOFwa2S9tS9lndTPqUeXd/CTAIEjOdLZVUK4ToTi4CTuTfLNaA89Yf+0dvsQrX+kKT9zuxG9ThH9AqLo9AzZfM4Ay8qwNPAGWAbUADea10nMRszKS+4A3gw7exeSf2Jem/BPQsYiULf3ugMSLmmSYAk0s5R955EjNGsGH2ZwDImrOY7jIxXCM6MlCB2xt+GL9E8CzIueTRJPAY4o3/SXuvlSeYywQyEzjngw0XBtOMhYHo6iOb4kKj5Pl+wpge9xGEn7NnRhj89kHJyC/XwZwoCM7LOkXY2BLxtAJUoXGPwDHC/wdUL8Xi9lbYe+A14HziYK5VP/AXU+TX099lFgwAAAABJRU5ErkJggg==`;
498
-
499
697
  /**
500
698
  * Sets the max-age for the dismissed popup cookie
501
699
  */
@@ -528,45 +726,23 @@ let BlotoutWallet = class BlotoutWallet extends s {
528
726
  }
529
727
  const email = this.email.value.trim().toLowerCase();
530
728
  if (email) {
531
- window.edgetag('user', 'email', email, {}, { destination: this.edgeURL });
532
- const response = await fetch(this.getUrl('/user/email'), {
533
- method: 'POST',
534
- body: JSON.stringify({
535
- email: email,
536
- }),
537
- headers: this.getHeaders(true),
538
- });
539
- if (!response.ok) {
540
- throw new Error(`Could not save email ${response.status}: ${await response.text()}`);
541
- }
729
+ await this.walletAPI.saveEmail(email);
542
730
  this.email.value = '';
543
731
  this.hasEmail = true;
544
732
  this.dispatchEvent(new CustomEvent('blotout-wallet-email-saved', { bubbles: true }));
545
- window.edgetag('tag', 'CartRecovery_KeepCartEmailSaved', {}, {}, { destination: this.edgeURL });
546
733
  }
547
- this.restoreResponse = await this.storeApi.addItems(this.lastExpiredCart.items);
734
+ this.restoreResponse = await this.storeAPI.addItems(this.lastExpiredCart.items, this.lastExpiredCart.token);
548
735
  const expiredCartId = this.lastExpiredCart.cartId;
549
736
  // We attempt to mark the cart as restored, but if the request fails,
550
737
  // we log the error in the console and let the user continue. Since the
551
738
  // problem is probably in the `/cart/restore` endpoint, further attempts
552
739
  // would not resolve the problem, which would just increase the number
553
740
  // of failed calls and not solve the problem.
554
- await fetch(this.getUrl(`/cart/restore/${expiredCartId}`), {
555
- method: 'POST',
556
- headers: this.getHeaders(),
557
- })
558
- .then(async (response) => {
559
- if (!response.ok) {
560
- throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
561
- }
562
- })
563
- .catch(logger.error);
741
+ await this.walletAPI.restoreCart(expiredCartId, this.silentRestore).catch(logger.error);
564
742
  this.lastExpiredCart = undefined;
565
743
  this.dispatchEvent(new CustomEvent('blotout-wallet-cart-restored', {
566
744
  bubbles: true,
567
745
  }));
568
- // Send the request as beacon as there could be a immediate redirect in the next step
569
- window.edgetag('tag', 'CartRecovery_CartRestored', { isSilent: !!this.silentRestore }, {}, { method: 'beacon', destination: this.edgeURL });
570
746
  };
571
747
  this.onSubmit = async (ev) => {
572
748
  ev.preventDefault();
@@ -596,7 +772,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
596
772
  break;
597
773
  }
598
774
  case 'checkout': {
599
- const url = this.storeApi.getCheckoutURL();
775
+ const url = this.storeAPI.getCheckoutURL();
600
776
  if (url) {
601
777
  window.location.href = url.toString();
602
778
  }
@@ -685,26 +861,12 @@ let BlotoutWallet = class BlotoutWallet extends s {
685
861
  `;
686
862
  };
687
863
  }
688
- get storeApi() {
689
- var _a;
690
- return (_a = window[registryKey]) === null || _a === void 0 ? void 0 : _a.storeAPI;
691
- }
692
864
  get isPopUpDismissed() {
693
865
  return getCookieValue('isPopUpDismissed') === '1';
694
866
  }
695
867
  setDismissed() {
696
868
  setCookie('isPopUpDismissed', '1', { maxAge: DISMISSED_COOKIE_LIFETIME });
697
- fetch(this.getUrl('/user/event'), {
698
- method: 'POST',
699
- headers: this.getHeaders(),
700
- body: JSON.stringify({ action: 'popupDismissed' }),
701
- })
702
- .then(async (response) => {
703
- if (!response.ok) {
704
- throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
705
- }
706
- })
707
- .catch(logger.error);
869
+ this.walletAPI.sendEvent('popupDismissed').catch(logger.error);
708
870
  }
709
871
  connectedCallback() {
710
872
  var _a;
@@ -725,37 +887,22 @@ let BlotoutWallet = class BlotoutWallet extends s {
725
887
  }
726
888
  }
727
889
  async initialize() {
728
- var _a;
729
- if (!this.userId) {
730
- logger.error('No UserId set');
731
- return;
732
- }
733
890
  if (this.isPopUpDismissed) {
734
891
  return;
735
892
  }
736
893
  await delay(POPUP_IMPRESSION_DELAY);
737
894
  try {
738
- const response = await fetch(this.getUrl('/cart/expired'), {
739
- method: 'GET',
740
- headers: this.getHeaders(),
741
- });
742
- if (!response.ok) {
743
- throw new Error(`Unable to get Expired Cart ${response.status}: ${await response.text()}`);
744
- }
895
+ const { email, carts } = await this.walletAPI.getExpiredCarts();
745
896
  this.dispatchEvent(new CustomEvent('blotout-wallet-loaded', { bubbles: true }));
746
- const result = await response.json();
747
- this.hasEmail = result.email;
748
- this.lastExpiredCart = result.carts[0];
749
- if ((_a = result.carts) === null || _a === void 0 ? void 0 : _a.length) {
897
+ this.hasEmail = email;
898
+ this.lastExpiredCart = carts[0];
899
+ if (carts === null || carts === void 0 ? void 0 : carts.length) {
750
900
  if (this.silentRestore) {
751
901
  this.restoreCart().catch(logger.error);
752
902
  }
753
903
  else if (!this.isPopUpDismissed) {
754
904
  this.showModal();
755
905
  }
756
- if (result.hasJustExpired) {
757
- window.edgetag('tag', 'CartRecovery_CartExpiredOnVisit', {}, {}, { destination: this.edgeURL });
758
- }
759
906
  }
760
907
  }
761
908
  catch (err) {
@@ -768,17 +915,7 @@ let BlotoutWallet = class BlotoutWallet extends s {
768
915
  .catch(logger.error)
769
916
  .finally(() => fadeInDialog(this.dialog));
770
917
  this.dispatchEvent(new CustomEvent('blotout-wallet-shown', { bubbles: true }));
771
- fetch(this.getUrl('/user/event'), {
772
- method: 'POST',
773
- headers: this.getHeaders(),
774
- body: JSON.stringify({ action: 'popupShown' }),
775
- })
776
- .then(async (response) => {
777
- if (!response.ok) {
778
- throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
779
- }
780
- })
781
- .catch(logger.error);
918
+ this.walletAPI.sendEvent('popupShown').catch(logger.error);
782
919
  }
783
920
  hideModal(action) {
784
921
  fadeOutToBottom(this.dialog)
@@ -787,40 +924,10 @@ let BlotoutWallet = class BlotoutWallet extends s {
787
924
  this.dispatchEvent(new CustomEvent('blotout-wallet-hidden', { bubbles: true }));
788
925
  this.restoreResponse = undefined;
789
926
  }
790
- getHeaders(json = false) {
791
- const headers = new Headers({
792
- EdgeTagUserId: this.userId,
793
- });
794
- if (json) {
795
- headers.set('Content-type', 'application/json; charset=utf-8');
796
- }
797
- return headers;
798
- }
799
- getUrl(path) {
800
- const url = new URL(`/providers/blotoutWallet${path}`, this.edgeURL);
801
- if (this.storeApi) {
802
- const cartToken = this.storeApi.getCartToken();
803
- if (cartToken) {
804
- url.searchParams.set('t', cartToken);
805
- }
806
- const previewKey = getPreviewKey();
807
- if (previewKey) {
808
- url.searchParams.set('pk', previewKey);
809
- }
810
- }
811
- return url;
812
- }
813
927
  async skipCarts() {
814
928
  this.hideModal('skip');
815
929
  try {
816
- const response = await fetch(this.getUrl('/cart/skip'), {
817
- method: 'POST',
818
- headers: this.getHeaders(),
819
- });
820
- if (!response.ok) {
821
- throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
822
- }
823
- window.edgetag('tag', 'CartRecovery_CartDeclined', {}, {}, { destination: this.edgeURL });
930
+ await this.walletAPI.deleteCarts();
824
931
  this.lastExpiredCart = undefined;
825
932
  }
826
933
  catch (e) {
@@ -1007,86 +1114,29 @@ BlotoutWallet = __decorate([
1007
1114
  t$1('blotout-wallet')
1008
1115
  ], BlotoutWallet);
1009
1116
 
1010
- const logStyles = `
1011
- padding: 4px 8px 4px 36px;
1012
- border: 1px dashed red;
1013
- border-radius: 3px;
1014
- font-weight: bold;
1015
- background: url(${logoImage}) 8px 50% no-repeat;
1016
- background-size: 24px 16px;
1017
- `;
1018
- const log = (message) => console.log(`%c${message}`, logStyles);
1019
- const init = (params) => {
1020
- var _a, _b, _c, _d, _e, _f;
1021
- let store = window[registryKey].storeAPI;
1022
- if (!store) {
1023
- store = window[registryKey].storeAPI =
1024
- (_b = (_a = window[registryKey]).storeAPIFactory) === null || _b === void 0 ? void 0 : _b.call(_a);
1025
- }
1026
- if (!store) {
1027
- console.error('Implementation for store API missing!');
1028
- return;
1029
- }
1030
- if (
1031
- // if loaded in non-browser SDKs
1032
- !window ||
1033
- !document ||
1034
- window.top !== window) {
1035
- return;
1036
- }
1037
- const { enabled, previewKey, mode = 'disabled', } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
1038
- const experiment = createExperiment({
1039
- name: mode,
1040
- userId: params.userId,
1041
- previewKey,
1042
- userPreviewKey: getPreviewKey(),
1043
- });
1044
- if (experiment.name == 'preview') {
1045
- if (experiment.isEnabled) {
1046
- log('Previewing functionality using preview key');
1047
- }
1048
- else if (getPreviewKey()) {
1049
- log('Preview key set but does not match the configured key');
1050
- }
1051
- }
1052
- if (enabled || experiment.isEnabled) {
1053
- // if the component is already defined, skip creating the element to avoid
1054
- // layering multiple widgets
1055
- if (window[registryKey].wallet) {
1056
- return;
1057
- }
1058
- const element = (window[registryKey].wallet =
1059
- document.createElement('blotout-wallet'));
1060
- const theme = (_d = params.manifest.variables) === null || _d === void 0 ? void 0 : _d['theme'];
1061
- if (theme) {
1062
- element.style.cssText = Object.entries(theme)
1063
- .filter(([name]) => name.startsWith('--'))
1064
- .map(([name, value]) => `${name}:${value}`)
1065
- .join(';');
1066
- }
1067
- element.theme = theme;
1068
- element.edgeURL = params.baseUrl;
1069
- element.userId = params.userId;
1070
- element.afterRestore = (_e = params.manifest.variables) === null || _e === void 0 ? void 0 : _e.afterRestore;
1071
- element.silentRestore = (_f = params.manifest.variables) === null || _f === void 0 ? void 0 : _f.silentRestore;
1072
- document.body.append(element);
1073
- }
1074
- };
1075
-
1076
- // eslint-disable-next-line @nx/enforce-module-boundaries
1077
- const data = {
1078
- name: packageName,
1079
- init,
1080
- tag,
1081
- };
1082
- try {
1083
- if (window) {
1084
- window.edgetagProviders = window.edgetagProviders || [];
1085
- window.edgetagProviders.push(data);
1117
+ var _a;
1118
+ let wallet;
1119
+ if (typeof window != 'undefined' && typeof document != 'undefined') {
1120
+ (_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
1121
+ // if a custom implementation is already present, don't override it
1122
+ if (!window[registryKey].ui) {
1123
+ window[registryKey].ui = {
1124
+ init(params) {
1125
+ if (wallet) {
1126
+ return;
1127
+ }
1128
+ wallet = document.createElement('blotout-wallet');
1129
+ if (params.theme) {
1130
+ wallet.style.cssText = Object.entries(params.theme)
1131
+ .filter(([name]) => name.startsWith('--'))
1132
+ .map(([name, value]) => `${name}:${value}`)
1133
+ .join(';');
1134
+ }
1135
+ Object.assign(wallet, params);
1136
+ document.body.append(wallet);
1137
+ },
1138
+ };
1086
1139
  }
1087
1140
  }
1088
- catch {
1089
- // no window
1090
- }
1091
1141
 
1092
1142
  export { data as default };