@zerohash-sdk/onboarding-react 1.15.4 → 1.15.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -61,6 +61,7 @@ declare type ErrorPayload = {
61
61
  * @param jwt - JWT token for authentication (required)
62
62
  * @param env - Target environment ("local" | "dev" | "cert" | "prod"). Omit for prod; init-only
63
63
  * @param theme - Theme mode ("auto" | "light" | "dark", defaults to "auto")
64
+ * @param onboardingFlow - Onboarding experience ("full_with_tax" | "full_without_tax" | "tax_only"); init-only
64
65
  * @param onCompleted - Callback invoked when the sell flow is successfully completed
65
66
  * @param onError - Callback invoked when an error occurs
66
67
  * @param onClose - Callback invoked when the user closes the widget
@@ -103,6 +104,15 @@ declare type OnboardingEvent = AppEvent<OnboardingEventType>;
103
104
 
104
105
  declare type OnboardingEventType = string;
105
106
 
107
+ /**
108
+ * Onboarding experience to render.
109
+ *
110
+ * - `"full_with_tax"` - Full onboarding plus brokerage tax certification
111
+ * - `"full_without_tax"` - Full onboarding, no tax certification
112
+ * - `"tax_only"` - Tax certification only, for existing participants
113
+ */
114
+ export declare type OnboardingFlow = 'full_with_tax' | 'full_without_tax' | 'tax_only';
115
+
106
116
  declare interface OnboardingProps {
107
117
  /**
108
118
  * JWT token used for authentication with the Connect Onboarding service.
@@ -161,6 +171,16 @@ declare interface OnboardingProps {
161
171
  * ```
162
172
  */
163
173
  theme?: Theme;
174
+ /**
175
+ * Onboarding experience to render. Optional; when omitted the default
176
+ * experience is used. Init-only: post-mount changes are ignored.
177
+ *
178
+ * @example
179
+ * ```tsx
180
+ * <Onboarding jwt={token} onboardingFlow="full_without_tax" />
181
+ * ```
182
+ */
183
+ onboardingFlow?: OnboardingFlow;
164
184
  /**
165
185
  * Callback invoked when the crypto sell flow is successfully completed.
166
186
  *
@@ -243,3 +263,34 @@ declare interface OnboardingProps {
243
263
  declare type Theme = 'auto' | 'light' | 'dark';
244
264
 
245
265
  export { }
266
+
267
+
268
+ declare global {
269
+ namespace JSX {
270
+ interface IntrinsicElements {
271
+ /**
272
+ * Connect Onboarding web component element
273
+ */
274
+ [WEB_COMPONENT_TAG]: React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
275
+ /**
276
+ * JWT token for authentication
277
+ */
278
+ jwt: string;
279
+ /**
280
+ * Target environment ("local" | "dev" | "cert" | "prod").
281
+ * Omit for prod; init-only.
282
+ */
283
+ env?: Environment;
284
+ /**
285
+ * Theme mode ("auto" | "light" | "dark")
286
+ */
287
+ theme?: Theme;
288
+ /**
289
+ * Onboarding experience to render. camelCase so React 19 sets it as a
290
+ * property before `connectedCallback` runs.
291
+ */
292
+ onboardingFlow?: OnboardingFlow;
293
+ };
294
+ }
295
+ }
296
+ }
package/dist/index.js CHANGED
@@ -1,268 +1,341 @@
1
- import { jsxs as W, jsx as d } from "react/jsx-runtime";
2
- import D, { useEffect as B, useState as L, useCallback as M, useRef as j } from "react";
3
- const V = {
4
- dev: "https://grafana-faro-collector.dev.0hash.com/collect",
5
- cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
6
- prod: "https://grafana-faro-collector.zerohash.com/collect",
7
- "eu-cert": "https://grafana-faro-collector.cert.zerohash.eu/collect",
8
- "eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
9
- sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
10
- production: "https://grafana-faro-collector.zerohash.com/collect"
11
- }, $ = (e) => {
12
- if (!e || typeof e != "string")
13
- return null;
14
- const t = e.split(".");
15
- if (t.length < 2)
16
- return null;
17
- try {
18
- const o = t[1].replace(/-/g, "+").replace(/_/g, "/"), r = o + "===".slice(0, (4 - o.length % 4) % 4), a = typeof atob < "u" ? atob(r) : Buffer.from(r, "base64").toString("utf-8"), c = JSON.parse(a)?.payload?.region;
19
- if (typeof c != "string")
20
- return null;
21
- const n = c.toLowerCase();
22
- return n === "us" || n === "eu" ? n : null;
23
- } catch {
24
- return null;
25
- }
26
- }, I = (e, t) => $(t) !== "eu" ? e : e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e, H = (e) => {
27
- if (!e || typeof e != "string")
28
- return {};
29
- const t = e.split(".");
30
- if (t.length < 2)
31
- return {};
32
- try {
33
- const o = t[1].replace(/-/g, "+").replace(/_/g, "/"), r = o + "===".slice(0, (4 - o.length % 4) % 4), a = typeof atob < "u" ? atob(r) : Buffer.from(r, "base64").toString("utf-8"), s = JSON.parse(a), c = s?.payload ?? {}, n = (i) => typeof i == "string" && i.length > 0 ? i : void 0;
34
- return {
35
- participantCode: n(c.participant_code),
36
- platformName: n(c.platform_name),
37
- platformCode: n(s.platform_code),
38
- region: n(c.region)
39
- };
40
- } catch {
41
- return {};
42
- }
43
- }, z = (e, t, o) => {
44
- const r = I(t, o);
45
- return e[r] ?? e[t] ?? e.prod;
46
- }, P = (e, t, o) => {
47
- const r = I(t, o);
48
- return e[r] ?? e[t];
49
- }, x = () => {
50
- }, J = () => {
51
- const e = new Uint8Array(8);
52
- return globalThis.crypto.getRandomValues(e), Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
53
- }, G = (e, t) => {
54
- const o = J(), r = globalThis.__ZH_WEB_SDK_VERSION__, a = {};
55
- e.claims.participantCode && (a.participant_code = e.claims.participantCode), e.claims.platformName && (a.platform_name = e.claims.platformName), e.claims.platformCode && (a.platform_code = e.claims.platformCode), e.claims.region && (a.region = e.claims.region), r && (a.zh_web_sdk_version = r);
56
- const s = {
57
- meta: {
58
- app: { name: e.appName, version: t ?? "unknown", environment: e.env },
59
- session: { id: o, attributes: a },
60
- browser: typeof navigator < "u" ? { userAgent: navigator.userAgent } : void 0,
61
- page: typeof window < "u" ? { url: window.location.origin } : void 0
62
- },
63
- logs: [
64
- {
65
- message: `Failed to load the script for ${e.webComponentTag} from ${e.env} environment.`,
66
- level: "error",
67
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
68
- context: {
69
- web_component: e.webComponentTag,
70
- script_url: e.scriptUrl,
71
- reason: e.reason,
72
- tried_fallback: String(e.triedFallback),
73
- elapsed_ms: String(e.elapsedMs)
74
- }
75
- }
76
- ]
77
- };
78
- return { sessionId: o, payload: s };
79
- }, K = (e, t, o) => {
80
- if (!e || typeof fetch > "u")
81
- return;
82
- const { sessionId: r, payload: a } = G(t, o);
83
- try {
84
- fetch(e, {
85
- method: "POST",
86
- headers: { "Content-Type": "application/json", "x-faro-session-id": r },
87
- body: JSON.stringify(a),
88
- keepalive: !0
89
- }).catch(() => {
90
- });
91
- } catch {
92
- }
93
- }, Z = (e) => {
94
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: s, collectorUrls: c, env: n, jwt: i, timeoutMs: f = 15e3, onLoad: b, onError: g } = e;
95
- if (typeof document > "u")
96
- return x;
97
- const h = `${t}-script-${n}`;
98
- if (customElements.get(t) || document.getElementById(h))
99
- return x;
100
- const S = H(i), k = e.report ?? ((p) => K(c && P(c, n, i), p, r));
101
- let m = !1, T = 0, v;
102
- const R = () => {
103
- v !== void 0 && clearTimeout(v);
104
- }, C = (p, y, l) => {
105
- if (m)
106
- return;
107
- const U = Math.round(performance.now() - T), E = {
108
- webComponentTag: t,
109
- appName: o,
110
- env: n,
111
- scriptUrl: y,
112
- reason: p,
113
- triedFallback: l,
114
- elapsedMs: U,
115
- claims: S
116
- };
117
- k(E);
118
- const O = l ? void 0 : z(s ?? {}, n, i);
119
- if (O && O !== y) {
120
- N(O, !0);
121
- return;
122
- }
123
- m = !0, R(), document.getElementById(h)?.remove(), g?.(E);
124
- }, N = (p, y) => {
125
- R(), T = performance.now();
126
- const l = document.createElement("script");
127
- l.id = h, l.src = p, l.type = "module", l.async = !0, l.onload = () => {
128
- setTimeout(() => {
129
- m || (customElements.get(t) ? (m = !0, R(), b?.()) : C("not-defined", p, y));
130
- }, 0);
131
- }, l.onerror = () => C("network", p, y), v = setTimeout(() => C("timeout", p, y), f), document.getElementById(h)?.remove(), document.head.appendChild(l);
132
- }, w = z(a, n, i);
133
- return w ? (N(w, !1), () => {
134
- m = !0, R();
135
- }) : x;
136
- }, q = {}, Q = typeof import.meta < "u" && q?.VITE_LOCAL_CDN_HOST || "http://localhost:5173", u = {
137
- local: Q,
138
- dev: "https://sdk-cdn.dev.0hash.com",
139
- cert: "https://sdk-cdn.cert.zerohash.com",
140
- prod: "https://sdk-cdn.zerohash.com",
141
- "eu-cert": "https://sdk-cdn.cert.zerohash.eu",
142
- "eu-prod": "https://sdk-cdn.zerohash.eu"
143
- }, X = "https://sdk-cdn.gating.0hash.com", Y = (e, t, o = {}) => {
144
- const { eu: r = !1, legacyAliases: a = !1, local: s = u.local } = o, c = (i) => `${i}/${e}/${t}`, n = {
145
- local: c(s),
146
- dev: c(u.dev),
147
- gating: c(X),
148
- cert: c(u.cert),
149
- prod: c(u.prod)
150
- };
151
- return a && (n.sandbox = c(u.cert), n.production = c(u.prod)), r && (n["eu-cert"] = c(u["eu-cert"]), n["eu-prod"] = c(u["eu-prod"])), n;
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import n, { useCallback as r, useEffect as i, useRef as a, useState as o } from "react";
3
+ //#region ../../../common/js-sdk-base/dist/constants.js
4
+ var s = {
5
+ dev: "https://grafana-faro-collector.dev.0hash.com/collect",
6
+ cert: "https://grafana-faro-collector.cert.zerohash.com/collect",
7
+ prod: "https://grafana-faro-collector.zerohash.com/collect",
8
+ "eu-cert": "https://grafana-faro-collector.cert.zerohash.eu/collect",
9
+ "eu-prod": "https://grafana-faro-collector.zerohash.eu/collect",
10
+ sandbox: "https://grafana-faro-collector.cert.zerohash.com/collect",
11
+ production: "https://grafana-faro-collector.zerohash.com/collect"
12
+ }, c = (e) => {
13
+ if (!e || typeof e != "string") return null;
14
+ let t = e.split(".");
15
+ if (t.length < 2) return null;
16
+ try {
17
+ let e = t[1].replace(/-/g, "+").replace(/_/g, "/"), n = e + "===".slice(0, (4 - e.length % 4) % 4), r = typeof atob < "u" ? atob(n) : Buffer.from(n, "base64").toString("utf-8"), i = JSON.parse(r)?.payload?.region;
18
+ if (typeof i != "string") return null;
19
+ let a = i.toLowerCase();
20
+ return a === "us" || a === "eu" ? a : null;
21
+ } catch {
22
+ return null;
23
+ }
24
+ }, l = (e, t) => c(t) === "eu" ? e === "cert" ? "eu-cert" : e === "prod" ? "eu-prod" : e : e, u = (e) => {
25
+ if (!e || typeof e != "string") return {};
26
+ let t = e.split(".");
27
+ if (t.length < 2) return {};
28
+ try {
29
+ let e = t[1].replace(/-/g, "+").replace(/_/g, "/"), n = e + "===".slice(0, (4 - e.length % 4) % 4), r = typeof atob < "u" ? atob(n) : Buffer.from(n, "base64").toString("utf-8"), i = JSON.parse(r), a = i?.payload ?? {}, o = (e) => typeof e == "string" && e.length > 0 ? e : void 0;
30
+ return {
31
+ participantCode: o(a.participant_code),
32
+ platformName: o(a.platform_name),
33
+ platformCode: o(i.platform_code),
34
+ region: o(a.region)
35
+ };
36
+ } catch {
37
+ return {};
38
+ }
39
+ }, d = (e, t, n) => e[l(t, n)] ?? e[t] ?? e.prod, f = (e, t, n) => e[l(t, n)] ?? e[t], p = () => void 0, m = () => {
40
+ let e = /* @__PURE__ */ new Uint8Array(8);
41
+ return globalThis.crypto.getRandomValues(e), Array.from(e, (e) => e.toString(16).padStart(2, "0")).join("");
42
+ }, h = (e, t) => {
43
+ let n = m(), r = globalThis.__ZH_WEB_SDK_VERSION__, i = {};
44
+ return e.claims.participantCode && (i.participant_code = e.claims.participantCode), e.claims.platformName && (i.platform_name = e.claims.platformName), e.claims.platformCode && (i.platform_code = e.claims.platformCode), e.claims.region && (i.region = e.claims.region), r && (i.zh_web_sdk_version = r), {
45
+ sessionId: n,
46
+ payload: {
47
+ meta: {
48
+ app: {
49
+ name: e.appName,
50
+ version: t ?? "unknown",
51
+ environment: e.env
52
+ },
53
+ session: {
54
+ id: n,
55
+ attributes: i
56
+ },
57
+ browser: typeof navigator < "u" ? { userAgent: navigator.userAgent } : void 0,
58
+ page: typeof window < "u" ? { url: window.location.origin } : void 0
59
+ },
60
+ logs: [{
61
+ message: `Failed to load the script for ${e.webComponentTag} from ${e.env} environment.`,
62
+ level: "error",
63
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
64
+ context: {
65
+ web_component: e.webComponentTag,
66
+ script_url: e.scriptUrl,
67
+ reason: e.reason,
68
+ tried_fallback: String(e.triedFallback),
69
+ elapsed_ms: String(e.elapsedMs)
70
+ }
71
+ }]
72
+ }
73
+ };
74
+ }, g = (e, t, n) => {
75
+ if (!e || typeof fetch > "u") return;
76
+ let { sessionId: r, payload: i } = h(t, n);
77
+ try {
78
+ fetch(e, {
79
+ method: "POST",
80
+ headers: {
81
+ "Content-Type": "application/json",
82
+ "x-faro-session-id": r
83
+ },
84
+ body: JSON.stringify(i),
85
+ keepalive: !0
86
+ }).catch(() => void 0);
87
+ } catch {}
88
+ }, _ = (e) => {
89
+ let { webComponentTag: t, appName: n, appVersion: r, scriptUrls: i, fallbackScriptUrls: a, collectorUrls: o, env: s, jwt: c, timeoutMs: l = 15e3, onLoad: m, onError: h } = e;
90
+ if (typeof document > "u") return p;
91
+ let _ = `${t}-script-${s}`;
92
+ if (customElements.get(t) || document.getElementById(_)) return p;
93
+ let v = u(c), y = e.report ?? ((e) => g(o && f(o, s, c), e, r)), b = !1, x = 0, S, C = () => {
94
+ S !== void 0 && clearTimeout(S);
95
+ }, w = (e, r, i) => {
96
+ if (b) return;
97
+ let o = Math.round(performance.now() - x), l = {
98
+ webComponentTag: t,
99
+ appName: n,
100
+ env: s,
101
+ scriptUrl: r,
102
+ reason: e,
103
+ triedFallback: i,
104
+ elapsedMs: o,
105
+ claims: v
106
+ };
107
+ y(l);
108
+ let u = i ? void 0 : d(a ?? {}, s, c);
109
+ if (u && u !== r) {
110
+ T(u, !0);
111
+ return;
112
+ }
113
+ b = !0, C(), document.getElementById(_)?.remove(), h?.(l);
114
+ }, T = (e, n) => {
115
+ C(), x = performance.now();
116
+ let r = document.createElement("script");
117
+ r.id = _, r.src = e, r.type = "module", r.async = !0, r.onload = () => {
118
+ setTimeout(() => {
119
+ b || (customElements.get(t) ? (b = !0, C(), m?.()) : w("not-defined", e, n));
120
+ }, 0);
121
+ }, r.onerror = () => w("network", e, n), S = setTimeout(() => w("timeout", e, n), l), document.getElementById(_)?.remove(), document.head.appendChild(r);
122
+ }, E = d(i, s, c);
123
+ return E ? (T(E, !1), () => {
124
+ b = !0, C();
125
+ }) : p;
126
+ }, v = {
127
+ local: {
128
+ BASE_URL: "/",
129
+ DEV: !1,
130
+ MODE: "production",
131
+ PROD: !0,
132
+ SSR: !1,
133
+ VITE_ASSETS_SERVICE_URL: "http://localhost:5173/assets",
134
+ VITE_CONNECT_API_BASE_URL: "/api/v1",
135
+ VITE_CONNECT_ENV: "local",
136
+ VITE_CONNECT_SDK_API_BASE_URL: "/sdk/v1",
137
+ VITE_DYNAMIC_ENVIRONMENT_ID: "38ce0330-c85e-414a-80b4-6129c548018f",
138
+ VITE_FARO_COLLECTOR_URL: "https://grafana-faro-collector.dev.0hash.com/collect",
139
+ VITE_FEATURE_SERVER_PROXY_URL: "https://ff-edge.dev.0hash.com/api/frontend",
140
+ VITE_INTERNAL_BUILD: "false",
141
+ VITE_ONBOARDING_API_BASE_URL: "/onboarding",
142
+ VITE_POST_MESSAGE_COMMUNICATION_PLATFORMS: "UW6VWU",
143
+ VITE_REDIRECT_HANDLER_URL: "http://localhost:4202/redirect-handler/index.html",
144
+ VITE_SCRAPER_EXTENSION_ID_CHROMIUM: "kofibejdfkmnbobmbogndbiimkflcllf",
145
+ VITE_TRADE_API_BASE_URL: "/trade",
146
+ VITE_UNLEASH_APIKEY: "zerohash-sdk:dev.b0d8aa594e9b94564f885167881bcb9dc69332f935fcb253e656ff34"
147
+ }.VITE_LOCAL_CDN_HOST || "http://localhost:5173",
148
+ dev: "https://sdk-cdn.dev.0hash.com",
149
+ cert: "https://sdk-cdn.cert.zerohash.com",
150
+ prod: "https://sdk-cdn.zerohash.com",
151
+ "eu-cert": "https://sdk-cdn.cert.zerohash.eu",
152
+ "eu-prod": "https://sdk-cdn.zerohash.eu"
153
+ }, y = "https://sdk-cdn.gating.0hash.com", b = (e, t, n = {}) => {
154
+ let { eu: r = !1, legacyAliases: i = !1, local: a = v.local } = n, o = (n) => `${n}/${e}/${t}`, s = {
155
+ local: o(a),
156
+ dev: o(v.dev),
157
+ gating: o(y),
158
+ cert: o(v.cert),
159
+ prod: o(v.prod)
160
+ };
161
+ return i && (s.sandbox = o(v.cert), s.production = o(v.prod)), r && (s["eu-cert"] = o(v["eu-cert"]), s["eu-prod"] = o(v["eu-prod"])), s;
152
162
  };
153
- var A;
163
+ ({
164
+ LOADED: "travel_rule_loaded",
165
+ COMPLETED: "travel_rule_completed"
166
+ }).LOADED;
167
+ //#endregion
168
+ //#region ../../../common/callbacks/dist/shared/models.js
169
+ var x;
154
170
  (function(e) {
155
- e.NETWORK_ERROR = "network_error", e.AUTH_ERROR = "auth_error", e.NOT_FOUND_ERROR = "not_found_error", e.VALIDATION_ERROR = "validation_error", e.SERVER_ERROR = "server_error", e.CLIENT_ERROR = "client_error", e.UNKNOWN_ERROR = "unknown_error";
156
- })(A || (A = {}));
157
- const _ = {
158
- evergreen: "#00381D",
159
- green: "#CCFFD0",
160
- offBlack: "#1C1B1C",
161
- grayLight: "#EBEBE9"
162
- }, ee = ({ onRetry: e, onClose: t }) => W("div", { role: "alert", style: {
163
- position: "relative",
164
- display: "flex",
165
- flexDirection: "column",
166
- alignItems: "center",
167
- gap: "8px",
168
- maxWidth: "360px",
169
- margin: "0 auto",
170
- padding: "32px 24px",
171
- textAlign: "center",
172
- fontFamily: "inherit",
173
- color: _.offBlack,
174
- background: "#FFFFFF",
175
- border: `1px solid ${_.grayLight}`,
176
- borderRadius: "12px"
177
- }, children: [t && d("button", { type: "button", onClick: t, "aria-label": "Close", style: {
178
- position: "absolute",
179
- top: "12px",
180
- right: "12px",
181
- display: "flex",
182
- padding: "4px",
183
- color: _.offBlack,
184
- background: "none",
185
- border: "none",
186
- cursor: "pointer",
187
- lineHeight: 0
188
- }, children: d("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("path", { d: "M18 6L6 18M6 6l12 12", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }) }), d("svg", { width: "32", height: "32", viewBox: "0 0 24 24", fill: "none", "aria-hidden": "true", children: d("path", { d: "M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z", stroke: _.evergreen, strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" }) }), d("p", { style: { margin: 0, fontSize: "16px", fontWeight: 600 }, children: "Something went wrong" }), d("p", { style: { margin: 0, fontSize: "14px", opacity: 0.75 }, children: "We couldn't load this content. Please check your internet connection and try again." }), d("button", { type: "button", onClick: e, style: {
189
- marginTop: "8px",
190
- padding: "8px 20px",
191
- fontSize: "14px",
192
- fontWeight: 600,
193
- fontFamily: "inherit",
194
- color: _.green,
195
- background: _.evergreen,
196
- border: "none",
197
- borderRadius: "8px",
198
- cursor: "pointer"
199
- }, children: "Try again" })] }), te = (e, t) => {
200
- B(() => {
201
- const o = e.current;
202
- if (o)
203
- for (const [r, a] of Object.entries(t))
204
- a !== void 0 && (o[r] = a);
205
- });
206
- }, oe = (e) => {
207
- const { webComponentTag: t, appName: o, appVersion: r, scriptUrls: a, fallbackScriptUrls: s, collectorUrls: c, env: n, jwt: i, timeoutMs: f } = e, [b, g] = L(!1), [h, S] = L(0);
208
- B(() => (g(!1), Z({
209
- webComponentTag: t,
210
- appName: o ?? t,
211
- appVersion: r,
212
- scriptUrls: a,
213
- fallbackScriptUrls: s,
214
- collectorUrls: c ?? V,
215
- env: n,
216
- jwt: i,
217
- timeoutMs: f,
218
- onError: () => g(!0)
219
- })), [
220
- t,
221
- o,
222
- r,
223
- a,
224
- s,
225
- c,
226
- n,
227
- i,
228
- f,
229
- h
230
- ]);
231
- const k = M(() => S((m) => m + 1), []);
232
- return { loadFailed: b, retry: k };
233
- }, re = Y("onboarding-web", "index.js", { eu: !0 }), F = "zerohash-onboarding", ce = ({
234
- jwt: e,
235
- env: t = "prod",
236
- theme: o,
237
- onCompleted: r,
238
- onError: a,
239
- onClose: s,
240
- onLoaded: c,
241
- onEvent: n,
242
- ...i
243
- }) => {
244
- const f = j(null);
245
- te(f, { theme: o, onCompleted: r, onError: a, onClose: s, onLoaded: c, onEvent: n });
246
- const { loadFailed: b, retry: g } = oe({
247
- webComponentTag: F,
248
- scriptUrls: re,
249
- env: t,
250
- jwt: e
251
- });
252
- return b ? /* @__PURE__ */ d(
253
- ee,
254
- {
255
- onRetry: g,
256
- onClose: s
257
- }
258
- ) : D.createElement(F, {
259
- ref: f,
260
- jwt: e,
261
- env: t,
262
- theme: o,
263
- ...i
264
- });
265
- };
266
- export {
267
- ce as Onboarding
171
+ e.NETWORK_ERROR = "network_error", e.AUTH_ERROR = "auth_error", e.NOT_FOUND_ERROR = "not_found_error", e.VALIDATION_ERROR = "validation_error", e.SERVER_ERROR = "server_error", e.CLIENT_ERROR = "client_error", e.UNKNOWN_ERROR = "unknown_error";
172
+ })(x ||= {});
173
+ //#endregion
174
+ //#region ../../../common/react-sdk-base/dist/script-load-fallback.js
175
+ var S = {
176
+ evergreen: "#00381D",
177
+ green: "#CCFFD0",
178
+ offBlack: "#1C1B1C",
179
+ grayLight: "#EBEBE9"
180
+ }, C = ({ onRetry: n, onClose: r }) => t("div", {
181
+ role: "alert",
182
+ style: {
183
+ position: "relative",
184
+ display: "flex",
185
+ flexDirection: "column",
186
+ alignItems: "center",
187
+ gap: "8px",
188
+ maxWidth: "360px",
189
+ margin: "0 auto",
190
+ padding: "32px 24px",
191
+ textAlign: "center",
192
+ fontFamily: "inherit",
193
+ color: S.offBlack,
194
+ background: "#FFFFFF",
195
+ border: `1px solid ${S.grayLight}`,
196
+ borderRadius: "12px"
197
+ },
198
+ children: [
199
+ r && e("button", {
200
+ type: "button",
201
+ onClick: r,
202
+ "aria-label": "Close",
203
+ style: {
204
+ position: "absolute",
205
+ top: "12px",
206
+ right: "12px",
207
+ display: "flex",
208
+ padding: "4px",
209
+ color: S.offBlack,
210
+ background: "none",
211
+ border: "none",
212
+ cursor: "pointer",
213
+ lineHeight: 0
214
+ },
215
+ children: e("svg", {
216
+ width: "20",
217
+ height: "20",
218
+ viewBox: "0 0 24 24",
219
+ fill: "none",
220
+ "aria-hidden": "true",
221
+ children: e("path", {
222
+ d: "M18 6L6 18M6 6l12 12",
223
+ stroke: "currentColor",
224
+ strokeWidth: "1.5",
225
+ strokeLinecap: "round",
226
+ strokeLinejoin: "round"
227
+ })
228
+ })
229
+ }),
230
+ e("svg", {
231
+ width: "32",
232
+ height: "32",
233
+ viewBox: "0 0 24 24",
234
+ fill: "none",
235
+ "aria-hidden": "true",
236
+ children: e("path", {
237
+ d: "M12 9v4m0 4h.01M10.29 3.86L1.82 18a2 2 0 001.71 3h16.94a2 2 0 001.71-3L13.71 3.86a2 2 0 00-3.42 0z",
238
+ stroke: S.evergreen,
239
+ strokeWidth: "1.5",
240
+ strokeLinecap: "round",
241
+ strokeLinejoin: "round"
242
+ })
243
+ }),
244
+ e("p", {
245
+ style: {
246
+ margin: 0,
247
+ fontSize: "16px",
248
+ fontWeight: 600
249
+ },
250
+ children: "Something went wrong"
251
+ }),
252
+ e("p", {
253
+ style: {
254
+ margin: 0,
255
+ fontSize: "14px",
256
+ opacity: .75
257
+ },
258
+ children: "We couldn't load this content. Please check your internet connection and try again."
259
+ }),
260
+ e("button", {
261
+ type: "button",
262
+ onClick: n,
263
+ style: {
264
+ marginTop: "8px",
265
+ padding: "8px 20px",
266
+ fontSize: "14px",
267
+ fontWeight: 600,
268
+ fontFamily: "inherit",
269
+ color: S.green,
270
+ background: S.evergreen,
271
+ border: "none",
272
+ borderRadius: "8px",
273
+ cursor: "pointer"
274
+ },
275
+ children: "Try again"
276
+ })
277
+ ]
278
+ }), w = (e, t) => {
279
+ i(() => {
280
+ let n = e.current;
281
+ if (n) for (let [e, r] of Object.entries(t)) r !== void 0 && (n[e] = r);
282
+ });
283
+ }, T = (e) => {
284
+ let { webComponentTag: t, appName: n, appVersion: a, scriptUrls: c, fallbackScriptUrls: l, collectorUrls: u, env: d, jwt: f, timeoutMs: p } = e, [m, h] = o(!1), [g, v] = o(0);
285
+ return i(() => (h(!1), _({
286
+ webComponentTag: t,
287
+ appName: n ?? t,
288
+ appVersion: a,
289
+ scriptUrls: c,
290
+ fallbackScriptUrls: l,
291
+ collectorUrls: u ?? s,
292
+ env: d,
293
+ jwt: f,
294
+ timeoutMs: p,
295
+ onError: () => h(!0)
296
+ })), [
297
+ t,
298
+ n,
299
+ a,
300
+ c,
301
+ l,
302
+ u,
303
+ d,
304
+ f,
305
+ p,
306
+ g
307
+ ]), {
308
+ loadFailed: m,
309
+ retry: r(() => v((e) => e + 1), [])
310
+ };
311
+ }, E = b("onboarding-web", "index.js", { eu: !0 }), D = "zerohash-onboarding", O = ({ jwt: t, env: r = "prod", theme: i, onboardingFlow: o, onCompleted: s, onError: c, onClose: l, onLoaded: u, onEvent: d, ...f }) => {
312
+ let p = a(null);
313
+ w(p, {
314
+ theme: i,
315
+ onboardingFlow: o,
316
+ onCompleted: s,
317
+ onError: c,
318
+ onClose: l,
319
+ onLoaded: u,
320
+ onEvent: d
321
+ });
322
+ let { loadFailed: m, retry: h } = T({
323
+ webComponentTag: D,
324
+ scriptUrls: E,
325
+ env: r,
326
+ jwt: t
327
+ });
328
+ return m ? /* @__PURE__ */ e(C, {
329
+ onRetry: h,
330
+ onClose: l
331
+ }) : n.createElement(D, {
332
+ ref: p,
333
+ jwt: t,
334
+ env: r,
335
+ theme: i,
336
+ onboardingFlow: o,
337
+ ...f
338
+ });
268
339
  };
340
+ //#endregion
341
+ export { O as Onboarding };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zerohash-sdk/onboarding-react",
3
- "version": "1.15.4",
3
+ "version": "1.15.6",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",