@incodetech/web 2.0.0-alpha.1 → 2.0.0-alpha.2

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.
Files changed (116) hide show
  1. package/.turbo/turbo-build.log +58 -0
  2. package/.turbo/turbo-coverage.log +23 -0
  3. package/.turbo/turbo-format.log +6 -0
  4. package/.turbo/turbo-lint$colon$fix.log +6 -0
  5. package/.turbo/turbo-lint.log +6 -0
  6. package/.turbo/turbo-test.log +1033 -0
  7. package/.turbo/turbo-typecheck.log +5 -0
  8. package/coverage/base.css +224 -0
  9. package/coverage/block-navigation.js +87 -0
  10. package/coverage/email/email.tsx.html +850 -0
  11. package/coverage/email/emailInput.tsx.html +340 -0
  12. package/coverage/email/index.html +131 -0
  13. package/coverage/favicon.png +0 -0
  14. package/coverage/flow/flow.tsx.html +961 -0
  15. package/coverage/flow/flowCompleted.tsx.html +448 -0
  16. package/coverage/flow/flowInit.ts.html +367 -0
  17. package/coverage/flow/flowStart.tsx.html +208 -0
  18. package/coverage/flow/index.html +221 -0
  19. package/coverage/flow/preloadFlow.ts.html +598 -0
  20. package/coverage/flow/unsupportedModule.tsx.html +202 -0
  21. package/coverage/flow/useFlowInitialization.ts.html +469 -0
  22. package/coverage/flow/useModuleLoader.ts.html +361 -0
  23. package/coverage/hooks/index.html +116 -0
  24. package/coverage/hooks/useManager.ts.html +205 -0
  25. package/coverage/index.html +401 -0
  26. package/coverage/permissions/boldWithArrow.tsx.html +208 -0
  27. package/coverage/permissions/denied.tsx.html +172 -0
  28. package/coverage/permissions/deniedAndroid.tsx.html +253 -0
  29. package/coverage/permissions/deniedDesktop.tsx.html +277 -0
  30. package/coverage/permissions/deniedIOS.tsx.html +304 -0
  31. package/coverage/permissions/deniedInstructions.tsx.html +142 -0
  32. package/coverage/permissions/iconWrapper.tsx.html +130 -0
  33. package/coverage/permissions/index.html +251 -0
  34. package/coverage/permissions/learnMore.tsx.html +340 -0
  35. package/coverage/permissions/numberedStep.tsx.html +127 -0
  36. package/coverage/permissions/permissions.tsx.html +289 -0
  37. package/coverage/phone/index.html +116 -0
  38. package/coverage/phone/phoneInput.tsx.html +832 -0
  39. package/coverage/prettify.css +1 -0
  40. package/coverage/prettify.js +2 -0
  41. package/coverage/selfie/index.html +131 -0
  42. package/coverage/selfie/selfie.tsx.html +334 -0
  43. package/coverage/selfie/tutorial.tsx.html +214 -0
  44. package/coverage/shared/baseTutorial/baseTutorial.tsx.html +250 -0
  45. package/coverage/shared/baseTutorial/index.html +131 -0
  46. package/coverage/shared/baseTutorial/replaceBaseTutorial.ts.html +289 -0
  47. package/coverage/shared/button/button.tsx.html +226 -0
  48. package/coverage/shared/button/index.html +116 -0
  49. package/coverage/shared/componentRoot/incodeComponent.tsx.html +121 -0
  50. package/coverage/shared/componentRoot/index.html +116 -0
  51. package/coverage/shared/countries/countries.ts.html +502 -0
  52. package/coverage/shared/countries/index.html +116 -0
  53. package/coverage/shared/icons/chevronDown.tsx.html +151 -0
  54. package/coverage/shared/icons/index.html +131 -0
  55. package/coverage/shared/icons/successIcon.tsx.html +163 -0
  56. package/coverage/shared/loader/index.html +116 -0
  57. package/coverage/shared/loader/loadingIcon.tsx.html +286 -0
  58. package/coverage/shared/otpInput/index.html +116 -0
  59. package/coverage/shared/otpInput/otpInput.tsx.html +808 -0
  60. package/coverage/shared/page/index.html +146 -0
  61. package/coverage/shared/page/page.tsx.html +358 -0
  62. package/coverage/shared/page/pageUiConfig.ts.html +277 -0
  63. package/coverage/shared/page/verifiedByIncode.tsx.html +310 -0
  64. package/coverage/shared/spacer/index.html +116 -0
  65. package/coverage/shared/spacer/spacer.tsx.html +349 -0
  66. package/coverage/shared/spinner/index.html +116 -0
  67. package/coverage/shared/spinner/spinner.tsx.html +280 -0
  68. package/coverage/shared/title/index.html +116 -0
  69. package/coverage/shared/title/title.tsx.html +121 -0
  70. package/coverage/shared/uiConfig/index.html +116 -0
  71. package/coverage/shared/uiConfig/uiConfig.ts.html +193 -0
  72. package/coverage/shared/webComponent/incodeModule.ts.html +172 -0
  73. package/coverage/shared/webComponent/index.html +131 -0
  74. package/coverage/shared/webComponent/registerIncodeElement.ts.html +130 -0
  75. package/coverage/sort-arrow-sprite.png +0 -0
  76. package/coverage/sorter.js +210 -0
  77. package/coverage/styles/cn.tsx.html +148 -0
  78. package/coverage/styles/fetchTheme.ts.html +349 -0
  79. package/coverage/styles/index.html +131 -0
  80. package/dist/asset-manifest.json +18 -0
  81. package/dist/browser-ponyfill-B6W6hHVY.js +344 -0
  82. package/dist/button-DeMZ_34N.js +266 -0
  83. package/dist/button.css +335 -0
  84. package/dist/email/email.es.js +145 -0
  85. package/dist/email/styles.css +123 -0
  86. package/dist/flow/flow.es.js +9 -0
  87. package/dist/flow/styles.css +204 -0
  88. package/dist/flow-ZK6OBsa3.js +568 -0
  89. package/dist/incodeModule-BF5MX9GT.js +243 -0
  90. package/dist/incodeModule.css +119 -0
  91. package/dist/index.es.js +101 -0
  92. package/dist/otpInput-BUrV4IAF.js +151 -0
  93. package/dist/otpInput.css +167 -0
  94. package/dist/phone/phone.es.js +3442 -0
  95. package/dist/phone/styles.css +305 -0
  96. package/dist/selfie/selfie.es.js +893 -0
  97. package/dist/selfie/styles.css +1163 -0
  98. package/dist/selfieTutorial-C-u5GufD.js +29 -0
  99. package/dist/styles/core.css +1013 -0
  100. package/dist/styles/tokens.css +543 -0
  101. package/dist/successIcon.css +4 -0
  102. package/dist/title-ng7q7YDh.js +2161 -0
  103. package/dist/title.css +38 -0
  104. package/dist/types/core.d.ts +1 -0
  105. package/dist/types/email/email.d.ts +2 -0
  106. package/dist/types/email.d.ts +50 -0
  107. package/dist/types/flow/flow.d.ts +2 -0
  108. package/dist/types/flow.d.ts +46 -0
  109. package/dist/types/index.d.ts +223 -0
  110. package/dist/types/phone/phone.d.ts +2 -0
  111. package/dist/types/phone.d.ts +51 -0
  112. package/dist/types/selfie/selfie.d.ts +2 -0
  113. package/dist/types/selfie.d.ts +24 -0
  114. package/dist/types/styles/core.d.ts +1 -0
  115. package/dist/vendor-preact-CK0WeTOR.js +584 -0
  116. package/package.json +17 -17
@@ -0,0 +1,568 @@
1
+ import { b as K, u as i, L as W, S as R, s as E, B as q, c as _, a as V } from "./button-DeMZ_34N.js";
2
+ import { createOrchestratedFlowManager as Y, getRequiredWasmPipelines as N } from "@incodetech/core/flow";
3
+ import { k as $, A as U, d as k, y as v } from "./vendor-preact-CK0WeTOR.js";
4
+ import { T as Z, c as G, s as J, u as A } from "./title-ng7q7YDh.js";
5
+ import { setup as Q, api as D, warmupWasm as X } from "@incodetech/core";
6
+ import { emailMachine as ee } from "@incodetech/core/email";
7
+ import { phoneMachine as te } from "@incodetech/core/phone";
8
+ import { selfieMachine as re } from "@incodetech/core/selfie";
9
+ const ne = {
10
+ small: 24,
11
+ medium: 48,
12
+ large: 64
13
+ }, F = ({
14
+ title: t,
15
+ subtitle: e,
16
+ size: n = "medium",
17
+ fullScreen: o = !0,
18
+ className: l
19
+ }) => {
20
+ const c = ne[n], r = K(
21
+ "IncodeSpinner",
22
+ o && "IncodeSpinnerFullScreen",
23
+ l
24
+ );
25
+ return /* @__PURE__ */ i("div", { class: r, children: /* @__PURE__ */ i("div", { class: "IncodeSpinnerContent", children: [
26
+ /* @__PURE__ */ i(W, { size: c }),
27
+ (t || e) && /* @__PURE__ */ i($, { children: [
28
+ /* @__PURE__ */ i(R, { size: 16 }),
29
+ /* @__PURE__ */ i("div", { class: "IncodeSpinnerText", children: [
30
+ t && /* @__PURE__ */ i(Z, { className: "IncodeSpinnerTitle", children: t }),
31
+ e && /* @__PURE__ */ i($, { children: [
32
+ t && /* @__PURE__ */ i(R, { size: 12 }),
33
+ /* @__PURE__ */ i("p", { class: "IncodeSpinnerSubtitle", children: e })
34
+ ] })
35
+ ] })
36
+ ] })
37
+ ] }) });
38
+ };
39
+ async function oe({
40
+ apiURL: t,
41
+ token: e,
42
+ customHeaders: n,
43
+ timeout: o,
44
+ wasm: l,
45
+ i18n: c,
46
+ uiConfig: r
47
+ }) {
48
+ r && E(r), await Q({ apiURL: t, token: e, customHeaders: n, timeout: o, wasm: l });
49
+ const u = G(c);
50
+ J(u);
51
+ }
52
+ function se(t) {
53
+ let e = t.replace("#", "");
54
+ e.length === 3 && (e = e.split("").map((d) => d + d).join(""));
55
+ const n = /^([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);
56
+ if (!n) return null;
57
+ const o = Number.parseInt(n[1], 16) / 255, l = Number.parseInt(n[2], 16) / 255, c = Number.parseInt(n[3], 16) / 255, r = Math.max(o, l, c), u = Math.min(o, l, c);
58
+ let f = 0, p = 0;
59
+ const a = (r + u) / 2;
60
+ if (r !== u) {
61
+ const d = r - u;
62
+ switch (p = a > 0.5 ? d / (2 - r - u) : d / (r + u), r) {
63
+ case o:
64
+ f = ((l - c) / d + (l < c ? 6 : 0)) / 6;
65
+ break;
66
+ case l:
67
+ f = ((c - o) / d + 2) / 6;
68
+ break;
69
+ case c:
70
+ f = ((o - l) / d + 4) / 6;
71
+ break;
72
+ }
73
+ }
74
+ return { h: f * 360, s: p * 100, l: a * 100 };
75
+ }
76
+ function I(t, e, n) {
77
+ const o = t / 360, l = e / 100, c = n / 100;
78
+ let r, u, f;
79
+ if (l === 0)
80
+ r = u = f = c;
81
+ else {
82
+ const a = (s, g, m) => (m < 0 && (m += 1), m > 1 && (m -= 1), m < 0.16666666666666666 ? s + (g - s) * 6 * m : m < 0.5 ? g : m < 0.6666666666666666 ? s + (g - s) * (0.6666666666666666 - m) * 6 : s), d = c < 0.5 ? c * (1 + l) : c + l - c * l, h = 2 * c - d;
83
+ r = a(h, d, o + 1 / 3), u = a(h, d, o), f = a(h, d, o - 1 / 3);
84
+ }
85
+ const p = (a) => {
86
+ const d = Math.round(a * 255).toString(16);
87
+ return d.length === 1 ? `0${d}` : d;
88
+ };
89
+ return `#${p(r)}${p(u)}${p(f)}`;
90
+ }
91
+ function ae(t) {
92
+ const e = se(t);
93
+ if (!e)
94
+ throw new Error(`Invalid color format: ${t}`);
95
+ return {
96
+ 50: I(e.h, e.s, 95),
97
+ 200: I(e.h, e.s, 80),
98
+ 300: I(e.h, e.s, 65),
99
+ 400: I(e.h, e.s, Math.min(100, e.l + 10)),
100
+ 500: t,
101
+ 600: I(e.h, e.s, Math.max(0, e.l - 10)),
102
+ 900: I(e.h, e.s, 20)
103
+ };
104
+ }
105
+ function ie(t, e) {
106
+ if (typeof document > "u")
107
+ return;
108
+ const n = ae(t);
109
+ let o = document.getElementById(
110
+ "incode-theme"
111
+ );
112
+ o || (o = document.createElement("style"), o.id = "incode-theme", document.head.appendChild(o));
113
+ const l = e || "#ffffff", c = `
114
+ :root,
115
+ :host {
116
+ --primitive-color-brand-50: ${n[50]};
117
+ --primitive-color-brand-200: ${n[200]};
118
+ --primitive-color-brand-300: ${n[300]};
119
+ --primitive-color-brand-400: ${n[400]};
120
+ --primitive-color-brand-500: ${n[500]};
121
+ --primitive-color-brand-600: ${n[600]};
122
+ --primitive-color-brand-900: ${n[900]};
123
+ --button-primary-text-default: ${l};
124
+ }
125
+ `;
126
+ o.textContent = c;
127
+ }
128
+ async function le() {
129
+ return (await D.get("/omni/asset/fetch-all")).data;
130
+ }
131
+ const z = /* @__PURE__ */ new Map();
132
+ async function ce(t) {
133
+ if (t.startsWith("data:"))
134
+ return t;
135
+ const e = z.get(t);
136
+ if (e)
137
+ return e;
138
+ const o = await (await fetch(t)).blob(), l = await new Promise((c, r) => {
139
+ const u = new FileReader();
140
+ u.onloadend = () => c(u.result), u.onerror = r, u.readAsDataURL(o);
141
+ });
142
+ return z.set(t, l), l;
143
+ }
144
+ async function de() {
145
+ const t = await le();
146
+ if (!t.theme)
147
+ throw new Error("Theme URL not found in assets response");
148
+ const e = t.theme, n = e.startsWith("http://") || e.startsWith("https://");
149
+ let o;
150
+ if (n) {
151
+ const r = await fetch(e);
152
+ if (!r.ok)
153
+ throw new Error(`Failed to fetch theme: ${r.statusText}`);
154
+ o = await r.json();
155
+ } else
156
+ o = (await D.get(e)).data;
157
+ const l = t["logo.png"] || t["logo.svg"] || t["logo.jpg"] || t["logo.jpeg"] || t["logo.webp"] || o.logo;
158
+ let c = l;
159
+ return l && (c = await ce(l)), {
160
+ ...o,
161
+ logo: c
162
+ };
163
+ }
164
+ async function ue() {
165
+ const t = await de();
166
+ return t.main && ie(t.main, t.buttonColor), t;
167
+ }
168
+ const L = {
169
+ PHONE: () => import("./phone/phone.es.js").then((t) => t.Phone),
170
+ EMAIL: () => import("./email/email.es.js").then((t) => t.Email),
171
+ SELFIE: () => import("./selfie/selfie.es.js").then((t) => t.Selfie)
172
+ };
173
+ function j() {
174
+ return Y({
175
+ modules: {
176
+ PHONE: te,
177
+ EMAIL: ee,
178
+ SELFIE: re
179
+ }
180
+ });
181
+ }
182
+ async function H(t) {
183
+ await oe({
184
+ apiURL: t.apiURL,
185
+ token: t.token,
186
+ i18n: { lang: t.lang ?? "en" }
187
+ });
188
+ }
189
+ async function B() {
190
+ try {
191
+ const t = await ue(), e = {
192
+ logoSrc: t.logo,
193
+ hideFooterBranding: t.hideFooterBranding
194
+ };
195
+ return E(e), { theme: t, uiConfig: e };
196
+ } catch (t) {
197
+ return console.warn("Failed to fetch dashboard theme:", t), {};
198
+ }
199
+ }
200
+ function O(t, e) {
201
+ const n = N(t.flow);
202
+ n.length > 0 && X({
203
+ ...e,
204
+ pipelines: n
205
+ }).catch((o) => {
206
+ console.error("WASM warmup failed:", o);
207
+ });
208
+ }
209
+ function fe(t) {
210
+ const e = t.currentStep;
211
+ if (e) {
212
+ const n = L[e];
213
+ n && n().catch(() => {
214
+ });
215
+ }
216
+ }
217
+ const he = ({
218
+ moduleKey: t,
219
+ onNext: e
220
+ }) => {
221
+ const { t: n } = A();
222
+ return /* @__PURE__ */ i("section", { class: "IncodeUnsupportedModule", "aria-live": "polite", children: /* @__PURE__ */ i("div", { class: "IncodeUnsupportedModuleContent", children: [
223
+ /* @__PURE__ */ i("h2", { class: "IncodeUnsupportedModuleTitle", children: n("unsupportedModule.title", "Module not available") }),
224
+ /* @__PURE__ */ i("p", { class: "IncodeUnsupportedModuleMessage", children: n(
225
+ "unsupportedModule.message",
226
+ `The "${t}" module is not yet supported in this version.`
227
+ ) }),
228
+ /* @__PURE__ */ i(
229
+ q,
230
+ {
231
+ onClick: e,
232
+ class: "IncodeUnsupportedModuleButton",
233
+ "data-testid": "unsupported-module-next-button",
234
+ children: n("unsupportedModule.next", "Next")
235
+ }
236
+ )
237
+ ] }) });
238
+ }, y = /* @__PURE__ */ new Map();
239
+ function C(t) {
240
+ const e = y.get(t);
241
+ if (!e)
242
+ throw new Error("Preload state not found");
243
+ return {
244
+ get isReady() {
245
+ return e.status === "ready";
246
+ },
247
+ get error() {
248
+ return e.status === "error" ? e.error ?? null : null;
249
+ },
250
+ async waitUntilReady() {
251
+ if (e.status !== "ready") {
252
+ if (e.status === "error")
253
+ throw new Error(e.error ?? "Preload failed");
254
+ return e.readyPromise;
255
+ }
256
+ },
257
+ cancel() {
258
+ e.status === "loading" && (e.unsubscribe && e.unsubscribe(), e.flowManager.stop(), e.readyReject(new Error("Preload cancelled")), y.delete(t));
259
+ }
260
+ };
261
+ }
262
+ function Ue(t) {
263
+ const { token: e } = t;
264
+ if (y.has(e))
265
+ return C(e);
266
+ let n, o;
267
+ const l = new Promise((f, p) => {
268
+ n = f, o = p;
269
+ }), c = j(), r = {
270
+ status: "loading",
271
+ flowManager: c,
272
+ config: t,
273
+ readyPromise: l,
274
+ readyResolve: n,
275
+ readyReject: o
276
+ };
277
+ return y.set(e, r), (async () => {
278
+ try {
279
+ await H({
280
+ apiURL: t.apiURL,
281
+ token: t.token,
282
+ lang: t.lang
283
+ });
284
+ const f = t.disableDashboardTheme ? Promise.resolve({}) : B().then((a) => {
285
+ r.theme = a.theme, r.uiConfig = a.uiConfig;
286
+ }), p = c.subscribe((a) => {
287
+ if (a.status === "ready") {
288
+ const d = a;
289
+ t.wasmConfig && O(d, t.wasmConfig), fe(d), r.unsubscribe?.(), r.unsubscribe = void 0, r.status = "ready", r.readyResolve();
290
+ } else a.status === "error" && (r.unsubscribe?.(), r.unsubscribe = void 0, r.status = "error", r.error = a.error, r.readyReject(new Error(a.error)));
291
+ });
292
+ r.unsubscribe = p, c.load(), await f;
293
+ } catch (f) {
294
+ r.status = "error", r.error = f instanceof Error ? f.message : "Failed to preload", r.readyReject(
295
+ f instanceof Error ? f : new Error("Failed to preload")
296
+ ), y.delete(e);
297
+ }
298
+ })(), C(e);
299
+ }
300
+ function x(t) {
301
+ return y.get(t) ?? null;
302
+ }
303
+ function T(t) {
304
+ const e = x(t);
305
+ return e && y.delete(t), e;
306
+ }
307
+ function pe(t) {
308
+ const { apiURL: e, token: n, lang: o, disableDashboardTheme: l, onError: c } = t, r = U(null), [u, f] = k(() => {
309
+ const a = x(n);
310
+ if (a?.status === "ready") {
311
+ const h = T(n);
312
+ if (h)
313
+ return r.current = h.flowManager, h.uiConfig && E(h.uiConfig), { status: "ready", flowManager: h.flowManager };
314
+ }
315
+ const d = j();
316
+ return r.current = d, a?.status === "error" ? {
317
+ status: "error",
318
+ error: a.error ?? "Preload failed",
319
+ flowManager: d
320
+ } : { status: "initializing", flowManager: d };
321
+ }), p = U(!1);
322
+ return v(() => {
323
+ if (u.status !== "initializing")
324
+ return;
325
+ const a = x(n);
326
+ if (a?.status === "loading") {
327
+ a.readyPromise.then(() => {
328
+ const h = T(n);
329
+ h && (r.current = h.flowManager, h.uiConfig && E(h.uiConfig), f({ status: "ready", flowManager: h.flowManager }));
330
+ }).catch((h) => {
331
+ const s = h instanceof Error ? h.message : "Preload failed";
332
+ f({
333
+ status: "error",
334
+ error: s,
335
+ flowManager: u.flowManager
336
+ }), c?.(s);
337
+ });
338
+ return;
339
+ }
340
+ if (p.current)
341
+ return;
342
+ p.current = !0, (async () => {
343
+ try {
344
+ await H({ apiURL: e, token: n, lang: o });
345
+ const h = l ? Promise.resolve() : B().then((s) => {
346
+ s.uiConfig && E(s.uiConfig);
347
+ });
348
+ u.flowManager.load(), await h, f({ status: "ready", flowManager: u.flowManager });
349
+ } catch (h) {
350
+ const s = h instanceof Error ? h.message : "Failed to initialize SDK";
351
+ f({
352
+ status: "error",
353
+ error: s,
354
+ flowManager: u.flowManager
355
+ }), c?.(s);
356
+ }
357
+ })();
358
+ }, [e, n, o, l, c, u]), u;
359
+ }
360
+ function me(t) {
361
+ const { moduleKey: e, onModuleLoading: n, onModuleLoaded: o, onError: l } = t, [c, r] = k({ status: "idle" });
362
+ return v(() => {
363
+ if (!e) {
364
+ r({ status: "idle" });
365
+ return;
366
+ }
367
+ const u = L[e];
368
+ if (!u) {
369
+ r({ status: "unsupported", moduleKey: e });
370
+ return;
371
+ }
372
+ r({ status: "loading", moduleKey: e }), n?.(e);
373
+ let f = !1;
374
+ return u().then((p) => {
375
+ f || (r({ status: "loaded", moduleKey: e, Component: p }), o?.(e));
376
+ }).catch((p) => {
377
+ if (!f) {
378
+ const a = p instanceof Error ? p.message : "Failed to load module";
379
+ r({ status: "error", moduleKey: e, error: a }), l?.(`Failed to load ${e}: ${a}`);
380
+ }
381
+ }), () => {
382
+ f = !0;
383
+ };
384
+ }, [e, n, o, l]), c;
385
+ }
386
+ function ge(t, e) {
387
+ const n = U(/* @__PURE__ */ new Set());
388
+ v(() => {
389
+ if (e < t.length - 1) {
390
+ const o = t[e + 1];
391
+ if (o && !n.current.has(o)) {
392
+ n.current.add(o);
393
+ const l = L[o];
394
+ l && l().catch(() => {
395
+ n.current.delete(o);
396
+ });
397
+ }
398
+ }
399
+ }, [t, e]);
400
+ }
401
+ const we = ({
402
+ apiURL: t,
403
+ token: e,
404
+ wasmConfig: n,
405
+ lang: o,
406
+ disableDashboardTheme: l,
407
+ onComplete: c,
408
+ onError: r,
409
+ onModuleLoading: u,
410
+ onModuleLoaded: f,
411
+ onWasmWarmup: p,
412
+ spinnerConfig: a
413
+ }) => {
414
+ const { t: d } = A(), h = pe({
415
+ apiURL: t,
416
+ token: e,
417
+ lang: o,
418
+ disableDashboardTheme: l,
419
+ onError: r
420
+ }), [s, g] = V(() => h.flowManager, {
421
+ autoLoad: !1
422
+ }), m = me({
423
+ moduleKey: s?.status === "ready" ? s.currentStep : void 0,
424
+ onModuleLoading: u,
425
+ onModuleLoaded: f,
426
+ onError: r
427
+ });
428
+ if (ge(
429
+ s?.status === "ready" ? s.steps : [],
430
+ s?.status === "ready" ? s.currentStepIndex : -1
431
+ ), v(() => {
432
+ if (s?.status === "ready" && n) {
433
+ const w = s, b = N(w.flow);
434
+ b.length > 0 && (p?.(b), O(w, n));
435
+ }
436
+ }, [s?.status, n, s, p]), v(() => {
437
+ s?.status === "finished" && c(s.finishStatus);
438
+ }, [s?.status, c, s]), v(() => {
439
+ s?.status === "error" && r && r(s.error);
440
+ }, [s?.status, r, s]), h.status === "error")
441
+ return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i("div", { children: [
442
+ "Error: ",
443
+ h.error
444
+ ] }) });
445
+ if (h.status === "initializing")
446
+ return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
447
+ F,
448
+ {
449
+ title: a?.title ?? d("home.settingUp"),
450
+ subtitle: a?.subtitle,
451
+ size: a?.size,
452
+ fullScreen: !0
453
+ }
454
+ ) });
455
+ if (!s || s.status === "idle" || s.status === "loading")
456
+ return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
457
+ F,
458
+ {
459
+ title: a?.title ?? d("home.settingUp"),
460
+ subtitle: a?.subtitle,
461
+ size: a?.size,
462
+ fullScreen: !0
463
+ }
464
+ ) });
465
+ if (s.status === "error")
466
+ return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i("div", { children: [
467
+ "Error: ",
468
+ s.error
469
+ ] }) });
470
+ if (s.status === "finished")
471
+ return null;
472
+ if (s.status === "ready") {
473
+ const { currentStep: w, config: b } = s;
474
+ if (!w || !b)
475
+ return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
476
+ F,
477
+ {
478
+ title: a?.title ?? d("loadingCircle.hangOn"),
479
+ subtitle: a?.subtitle ?? d("loadingCircle.validating"),
480
+ size: a?.size,
481
+ fullScreen: !0
482
+ }
483
+ ) });
484
+ if (m.status === "unsupported")
485
+ return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
486
+ he,
487
+ {
488
+ moduleKey: w,
489
+ onNext: () => g.completeModule()
490
+ }
491
+ ) });
492
+ if (m.status === "idle" || m.status === "loading" || m.status === "error")
493
+ return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
494
+ F,
495
+ {
496
+ title: a?.title ?? d("loadingCircle.hangOn"),
497
+ subtitle: a?.subtitle ?? d("loadingCircle.validating"),
498
+ size: a?.size,
499
+ fullScreen: !0
500
+ }
501
+ ) });
502
+ const { Component: P } = m;
503
+ if (w === "SELFIE")
504
+ return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
505
+ P,
506
+ {
507
+ config: b,
508
+ onFinish: () => g.completeModule(),
509
+ onError: (S) => {
510
+ r?.(S ?? "Selfie verification error");
511
+ }
512
+ },
513
+ `selfie-${s.currentStepIndex}`
514
+ ) });
515
+ if (w === "PHONE")
516
+ return /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
517
+ P,
518
+ {
519
+ config: b,
520
+ onFinish: () => g.completeModule(),
521
+ onError: (S) => {
522
+ r?.(S ?? "Phone verification error");
523
+ }
524
+ },
525
+ `phone-${s.currentStepIndex}`
526
+ ) });
527
+ if (w === "EMAIL") {
528
+ const M = b;
529
+ return !M || typeof M.otpVerification != "boolean" || typeof M.otpExpirationInMinutes != "number" ? /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i("div", { children: "Error: Invalid email configuration" }) }) : /* @__PURE__ */ i("div", { class: "IncodeFlow", children: /* @__PURE__ */ i(
530
+ P,
531
+ {
532
+ config: {
533
+ ...M,
534
+ prefill: M.prefill ?? !1
535
+ },
536
+ onFinish: () => g.completeModule(),
537
+ onError: (S) => {
538
+ r?.(S ?? "Email verification error");
539
+ }
540
+ },
541
+ `email-${s.currentStepIndex}`
542
+ ) });
543
+ }
544
+ }
545
+ return null;
546
+ }, be = (t) => /* @__PURE__ */ i("div", { class: "IncodeComponent", children: /* @__PURE__ */ i(we, { ...t }) });
547
+ _(
548
+ be,
549
+ "incode-flow",
550
+ [
551
+ "apiURL",
552
+ "token",
553
+ "wasmConfig",
554
+ "lang",
555
+ "disableDashboardTheme",
556
+ "spinnerConfig",
557
+ "onComplete",
558
+ "onError"
559
+ ],
560
+ {
561
+ shadow: !1
562
+ }
563
+ );
564
+ export {
565
+ be as I,
566
+ Ue as p,
567
+ oe as s
568
+ };