@blotoutio/providers-blotout-wallet-sdk 0.66.0 → 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/core.cjs.js ADDED
@@ -0,0 +1,345 @@
1
+ 'use strict';
2
+
3
+ const expand = (str) => str.split(',').flatMap((entry) => {
4
+ if (!entry.includes('-')) {
5
+ return entry;
6
+ }
7
+ const result = [];
8
+ const [start, end] = entry.split('-').map(Number);
9
+ for (let i = start; i <= end; i++) {
10
+ result.push(i.toString());
11
+ }
12
+ return result;
13
+ });
14
+ /**
15
+ * Exported from https://en.wikipedia.org/wiki/List_of_North_American_Numbering_Plan_area_codes
16
+ *
17
+ * In Dev Tools, select the `tbody` element containing the area codes and run the following code,
18
+ * replacing the emdash character with a simple endash:
19
+ *
20
+ * ```ts
21
+ * [...$0.querySelectorAll('td:first-child')]
22
+ * .filter(cell => cell.firstChild.nodeName != 'A')
23
+ * .map(cell => cell.textContent.trim()).join(',')
24
+ * ```
25
+ */
26
+ new Set([
27
+ ...expand('200,211,221,222,230,232,233,235,237-238,241,243,244,245,247,255,257,258-259,261,265,266,271,273,274,275,277,278,280,282,283,285-287,288,290-299'),
28
+ ...expand('300,311,322,324,327,328,333,335,338,342,344,348-349,353,355,356,357-359,362,366,369,370-379,381,382,383-384,387,388,389,390-399'),
29
+ ...expand('400,411,420,421-422,426-427,428,429,433,439,444,446,449,451-454,455,456,457,459,460,461-462,465,466,467,471,476,477,481-483,485-486,487,488,489,490-499'),
30
+ ...expand('511,532,535,536,537,538,542-543,545-547,549-550,552-554,555,556,558,560,565,568,569,576,578,583,589,590-599'),
31
+ ...expand('611,621,624,625,627,632,633,634-635,637-638,642-643,644,648,652-654,655,663,665,666,668,673-676,677,679,685,686,687,688,690-699'),
32
+ ...expand('711,722,723,729,733,735-736,739,741,744,745-746,748,749-751,752,755,756,759,761,764,766,768,776,777,783,788,789,790-799'),
33
+ ...expand('811,821,822,823-824,827,834,836,841-842,846,851,852-853,871,874-875,879,880-887,889,890-899'),
34
+ ...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'),
35
+ ]);
36
+
37
+ const EMAIL_RE = /^[\w!#$%&'*+/=?^`{|}~-]+(:?\.[\w!#$%&'*+/=?^`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
38
+ const normalizeEmail = (email) => {
39
+ if (!email) {
40
+ return '';
41
+ }
42
+ const trimmedEmail = email.trim().toLowerCase();
43
+ if (!EMAIL_RE.test(trimmedEmail)) {
44
+ return '';
45
+ }
46
+ return trimmedEmail;
47
+ };
48
+
49
+ const createEnabled = () => ({
50
+ name: 'enabled',
51
+ groupNames: new Set(),
52
+ segment: 0,
53
+ groupName: '',
54
+ isEnabled: true,
55
+ });
56
+ const createDisabled = () => ({
57
+ name: 'disabled',
58
+ groupNames: new Set(),
59
+ segment: 0,
60
+ groupName: '',
61
+ isEnabled: false,
62
+ });
63
+ const createABTest = ({ userId }) => {
64
+ const [sample] = userId.split('-');
65
+ const segment = parseInt(sample, 16) % 2;
66
+ return {
67
+ name: 'ab-test',
68
+ groupNames: new Set(['enabled', 'control']),
69
+ segment,
70
+ groupName: segment == 1 ? 'enabled' : 'control',
71
+ isEnabled: segment == 1,
72
+ };
73
+ };
74
+ const createPreview = ({ previewKey, userPreviewKey }) => {
75
+ const isEnabled = !!(previewKey && previewKey === userPreviewKey);
76
+ return {
77
+ name: 'preview',
78
+ groupNames: new Set(['preview']),
79
+ groupName: isEnabled ? 'preview' : '',
80
+ segment: isEnabled ? 1 : 0,
81
+ isEnabled,
82
+ };
83
+ };
84
+ const createExperiment = (props) => {
85
+ switch (props.name) {
86
+ case 'enabled':
87
+ return createEnabled();
88
+ case 'disabled':
89
+ return createDisabled();
90
+ case 'ab-test':
91
+ return createABTest(props);
92
+ case 'preview':
93
+ return createPreview(props);
94
+ }
95
+ };
96
+
97
+ const packageName = 'blotoutWallet';
98
+ const PREVIEW_KEY_NAME = '_blotoutWalletPreview';
99
+
100
+ var _a;
101
+ const registryKey = Symbol.for('blotout-wallet');
102
+ if (typeof window != 'undefined') {
103
+ (_a = window[registryKey]) !== null && _a !== void 0 ? _a : (window[registryKey] = {});
104
+ }
105
+
106
+ // eslint-disable-next-line @nx/enforce-module-boundaries
107
+ const getPreviewKey = () => {
108
+ let key = null;
109
+ try {
110
+ key = localStorage.getItem(PREVIEW_KEY_NAME) || null;
111
+ }
112
+ catch {
113
+ /* do nothing */
114
+ }
115
+ return key;
116
+ };
117
+
118
+ const tag = () => {
119
+ const result = {
120
+ cartToken: null,
121
+ previewKey: getPreviewKey(),
122
+ };
123
+ if (typeof window == 'undefined') {
124
+ return result;
125
+ }
126
+ const store = window[registryKey].storeAPI;
127
+ if (store) {
128
+ result.cartToken = store.getCartToken();
129
+ }
130
+ return result;
131
+ };
132
+
133
+ /**
134
+ * @license
135
+ * Copyright 2019 Google LLC
136
+ * SPDX-License-Identifier: BSD-3-Clause
137
+ */
138
+ const t$1=globalThis,e$2=t$1.ShadowRoot&&(void 0===t$1.ShadyCSS||t$1.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s$2=Symbol(),o$2=new WeakMap;let n$2 = 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$2&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$2.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$2.set(s,t));}return t}toString(){return this.cssText}};const r$3=t=>new n$2("string"==typeof t?t:t+"",void 0,s$2),S$1=(s,o)=>{if(e$2)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t$1.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$2=e$2?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$3(e)})(t):t;
139
+
140
+ /**
141
+ * @license
142
+ * Copyright 2017 Google LLC
143
+ * SPDX-License-Identifier: BSD-3-Clause
144
+ */const{is:i$1,defineProperty:e$1,getOwnPropertyDescriptor:r$2,getOwnPropertyNames:h$1,getOwnPropertySymbols:o$1,getPrototypeOf:n$1}=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$1(t,s),y={attribute:!0,type:String,converter:u$1,reflect:!1,hasChanged:f$1};Symbol.metadata??=Symbol("metadata"),a$1.litPropertyMetadata??=new WeakMap;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){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$1(this.prototype,t,r);}}static getPropertyDescriptor(t,s,i){const{get:e,set:h}=r$2(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}static _$Ei(){if(this.hasOwnProperty(d$1("elementProperties")))return;const t=n$1(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$1(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.elementStyles=[],b.shadowRootOptions={mode:"open"},b[d$1("elementProperties")]=new Map,b[d$1("finalized")]=new Map,p$1?.({ReactiveElement:b}),(a$1.reactiveElementVersions??=[]).push("2.0.4");
145
+
146
+ /**
147
+ * @license
148
+ * Copyright 2017 Google LLC
149
+ * SPDX-License-Identifier: BSD-3-Clause
150
+ */
151
+ const t=globalThis,i=t.trustedTypes,s$1=i?i.createPolicy("lit-html",{createHTML:t=>t}):void 0,e="$lit$",h=`lit$${Math.random().toFixed(9).slice(2)}$`,o="?"+h,n=`<${o}>`,r$1=document,l=()=>r$1.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,w=Symbol.for("lit-noChange"),T=Symbol.for("lit-nothing"),A=new WeakMap,E=r$1.createTreeWalker(r$1,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:d>=0?(o.push(a),s.slice(0,d)+e+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)){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?i.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)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$1.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$1).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$1,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$1.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.litHtmlPolyfillSupport;Z?.(V,M),(t.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};
152
+
153
+ /**
154
+ * @license
155
+ * Copyright 2017 Google LLC
156
+ * SPDX-License-Identifier: BSD-3-Clause
157
+ */class s extends b{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=globalThis.litElementPolyfillSupport;r?.({LitElement:s});(globalThis.litElementVersions??=[]).push("4.0.5");
158
+
159
+ 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==`;
160
+
161
+ const createWalletAPI = ({ fetch: fetchImpl = window.fetch, baseURL, userId, storeAPI, }) => {
162
+ if (!baseURL) {
163
+ throw new Error(`baseURL missing`);
164
+ }
165
+ if (!userId) {
166
+ throw new Error(`userId missing`);
167
+ }
168
+ if (!storeAPI) {
169
+ throw new Error(`store API implementation missing`);
170
+ }
171
+ const getHeaders = (json = false) => {
172
+ const headers = new Headers({ EdgeTagUserId: userId });
173
+ if (json) {
174
+ headers.set('Content-type', 'application/json; charset=utf-8');
175
+ }
176
+ return headers;
177
+ };
178
+ const getURL = (path) => {
179
+ const url = new URL(`/providers/blotoutWallet${path}`, baseURL);
180
+ const cartToken = storeAPI.getCartToken();
181
+ if (cartToken) {
182
+ url.searchParams.set('t', cartToken);
183
+ }
184
+ const previewKey = getPreviewKey();
185
+ if (previewKey) {
186
+ url.searchParams.set('pk', previewKey);
187
+ }
188
+ return url;
189
+ };
190
+ const getExpiredCarts = async () => {
191
+ const response = await fetchImpl(getURL('/cart/expired'), {
192
+ method: 'GET',
193
+ headers: getHeaders(),
194
+ });
195
+ if (!response.ok) {
196
+ throw new Error(`Unable to get expired cart - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
197
+ }
198
+ const result = (await response.json());
199
+ if (result.hasJustExpired) {
200
+ window.edgetag('tag', 'CartRecovery_CartExpiredOnVisit', undefined, undefined, { destination: baseURL });
201
+ }
202
+ return result;
203
+ };
204
+ const sendEvent = async (action) => {
205
+ const response = await fetchImpl(getURL('/user/event'), {
206
+ method: 'POST',
207
+ headers: getHeaders(true),
208
+ body: JSON.stringify({ action }),
209
+ });
210
+ if (!response.ok) {
211
+ throw new Error(`Error while recording user event - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
212
+ }
213
+ };
214
+ const saveEmail = async (email) => {
215
+ const normalized = normalizeEmail(email);
216
+ if (!normalized) {
217
+ throw new Error(`Could not save email - invalid email format`);
218
+ }
219
+ window.edgetag('user', 'email', normalized, {}, { destination: baseURL });
220
+ const response = await fetchImpl(getURL('/user/email'), {
221
+ method: 'POST',
222
+ headers: getHeaders(true),
223
+ body: JSON.stringify({ email: normalized }),
224
+ });
225
+ if (!response.ok) {
226
+ throw new Error(`Could not save email - ${response.status}: ${response.statusText}\n\n${await response.text()}`);
227
+ }
228
+ window.edgetag('tag', 'CartRecovery_KeepCartEmailSaved', undefined, undefined, { destination: baseURL });
229
+ };
230
+ const restoreCart = async (cartId, isSilent) => {
231
+ const response = await fetchImpl(getURL(`/cart/restore/${encodeURIComponent(cartId)}`), {
232
+ method: 'POST',
233
+ headers: getHeaders(),
234
+ });
235
+ if (!response.ok) {
236
+ throw new Error(`Could not update status in DB - ${response.status}: ${response.text}\n\n${await response.text()}`);
237
+ }
238
+ // Send the request as beacon as there could be a immediate redirect in the next step
239
+ window.edgetag('tag', 'CartRecovery_CartRestored', { isSilent }, undefined, { method: 'beacon' });
240
+ };
241
+ const deleteCarts = async () => {
242
+ const response = await fetchImpl(getURL('/cart/skip'), {
243
+ method: 'POST',
244
+ headers: getHeaders(),
245
+ });
246
+ if (!response.ok) {
247
+ throw new Error(`Could not mark cart as skipped - ${response.status}: ${await response.text()}`);
248
+ }
249
+ window.edgetag('tag', 'CartRecovery_CartDeclined', undefined, undefined, {
250
+ destination: baseURL,
251
+ });
252
+ };
253
+ return {
254
+ getExpiredCarts,
255
+ sendEvent,
256
+ saveEmail,
257
+ restoreCart,
258
+ deleteCarts,
259
+ };
260
+ };
261
+
262
+ const logStyles = `
263
+ padding: 4px 8px 4px 36px;
264
+ border: 1px dashed red;
265
+ border-radius: 3px;
266
+ font-weight: bold;
267
+ background: url(${logoImage}) 8px 50% no-repeat;
268
+ background-size: 24px 16px;
269
+ `;
270
+ const log = (message) => console.log(`%c${message}`, logStyles);
271
+ const error = (message) => console.error(`%c${message}`, logStyles);
272
+ const init = (params) => {
273
+ var _a, _b, _c, _d, _e, _f, _g, _h;
274
+ if (typeof window == 'undefined' || typeof document == 'undefined') {
275
+ // if loaded in non-browser SDKs, return early
276
+ return;
277
+ }
278
+ let storeAPI = window[registryKey].storeAPI;
279
+ if (!storeAPI) {
280
+ storeAPI = window[registryKey].storeAPI =
281
+ (_b = (_a = window[registryKey]).storeAPIFactory) === null || _b === void 0 ? void 0 : _b.call(_a);
282
+ }
283
+ if (!storeAPI) {
284
+ console.error('Implementation for store API missing!');
285
+ return;
286
+ }
287
+ if (window.top !== window) {
288
+ // exit if not in top window
289
+ return;
290
+ }
291
+ const { enabled, previewKey, mode = 'disabled', } = (_c = params.manifest.variables) !== null && _c !== void 0 ? _c : {};
292
+ const experiment = createExperiment({
293
+ name: mode,
294
+ userId: params.userId,
295
+ previewKey,
296
+ userPreviewKey: getPreviewKey(),
297
+ });
298
+ if (experiment.name == 'preview') {
299
+ if (experiment.isEnabled) {
300
+ log('Previewing functionality using preview key');
301
+ }
302
+ else if (getPreviewKey()) {
303
+ log('Preview key set but does not match the configured key');
304
+ }
305
+ }
306
+ if (enabled || experiment.isEnabled) {
307
+ const uiImplementation = window[registryKey].ui;
308
+ if (!uiImplementation) {
309
+ error('UI implementation is missing');
310
+ return;
311
+ }
312
+ const walletAPI = createWalletAPI({
313
+ baseURL: params.baseUrl,
314
+ storeAPI,
315
+ userId: params.userId,
316
+ });
317
+ uiImplementation.init({
318
+ theme: (_e = (_d = params.manifest.variables) === null || _d === void 0 ? void 0 : _d.theme) !== null && _e !== void 0 ? _e : {},
319
+ afterRestore: (_g = (_f = params.manifest.variables) === null || _f === void 0 ? void 0 : _f.afterRestore) !== null && _g !== void 0 ? _g : {
320
+ action: 'none',
321
+ },
322
+ silentRestore: !!((_h = params.manifest.variables) === null || _h === void 0 ? void 0 : _h.silentRestore),
323
+ walletAPI,
324
+ storeAPI,
325
+ });
326
+ }
327
+ };
328
+
329
+ // eslint-disable-next-line @nx/enforce-module-boundaries
330
+ const data = {
331
+ name: packageName,
332
+ init,
333
+ tag,
334
+ };
335
+ try {
336
+ if (typeof window !== 'undefined') {
337
+ window.edgetagProviders = window.edgetagProviders || [];
338
+ window.edgetagProviders.push(data);
339
+ }
340
+ }
341
+ catch {
342
+ // no window
343
+ }
344
+
345
+ module.exports = data;