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

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 (212) hide show
  1. package/dist/asset-manifest.json +18 -0
  2. package/dist/browser-ponyfill-B6W6hHVY.js +344 -0
  3. package/dist/button-DeMZ_34N.js +266 -0
  4. package/dist/button.css +335 -0
  5. package/dist/email/email.es.js +145 -0
  6. package/dist/email/styles.css +123 -0
  7. package/dist/flow/flow.es.js +9 -0
  8. package/dist/flow/styles.css +204 -0
  9. package/dist/flow-ZK6OBsa3.js +568 -0
  10. package/dist/incodeModule-BF5MX9GT.js +243 -0
  11. package/dist/incodeModule.css +119 -0
  12. package/dist/index.es.js +101 -0
  13. package/dist/otpInput-BUrV4IAF.js +151 -0
  14. package/dist/otpInput.css +167 -0
  15. package/dist/phone/phone.es.js +3442 -0
  16. package/dist/phone/styles.css +305 -0
  17. package/dist/selfie/selfie.es.js +893 -0
  18. package/dist/selfie/styles.css +1163 -0
  19. package/dist/selfieTutorial-C-u5GufD.js +29 -0
  20. package/dist/styles/core.css +1013 -0
  21. package/dist/styles/tokens.css +543 -0
  22. package/dist/successIcon.css +4 -0
  23. package/dist/title-ng7q7YDh.js +2161 -0
  24. package/dist/title.css +38 -0
  25. package/dist/types/core.d.ts +1 -0
  26. package/dist/types/email/email.d.ts +2 -0
  27. package/dist/types/email.d.ts +50 -0
  28. package/dist/types/flow/flow.d.ts +2 -0
  29. package/dist/types/flow.d.ts +46 -0
  30. package/dist/types/index.d.ts +223 -0
  31. package/dist/types/phone/phone.d.ts +2 -0
  32. package/dist/types/phone.d.ts +51 -0
  33. package/dist/types/selfie/selfie.d.ts +2 -0
  34. package/dist/types/selfie.d.ts +24 -0
  35. package/dist/types/styles/core.d.ts +1 -0
  36. package/dist/vendor-preact-CK0WeTOR.js +584 -0
  37. package/package.json +20 -17
  38. package/dev/README.md +0 -163
  39. package/dev/getToken.ts +0 -36
  40. package/dev/headless.html +0 -875
  41. package/dev/index.html +0 -366
  42. package/dev/main-headless.tsx +0 -1332
  43. package/dev/main-orchestrated-flow.tsx +0 -1158
  44. package/dev/main-preact.tsx +0 -323
  45. package/dev/main-simplified.tsx +0 -123
  46. package/dev/main-web-component.tsx +0 -256
  47. package/dev/main.tsx +0 -332
  48. package/dev/manual.html +0 -27
  49. package/dev/orchestrated-flow.html +0 -64
  50. package/dev/simplified.html +0 -64
  51. package/dev/tiktok-logo.svg +0 -7
  52. package/src/defineCustomElement.tsx +0 -30
  53. package/src/email/email.test.tsx +0 -368
  54. package/src/email/email.tsx +0 -255
  55. package/src/email/emailInput.test.tsx +0 -264
  56. package/src/email/emailInput.tsx +0 -85
  57. package/src/email/styles.css +0 -59
  58. package/src/flow/flow.test.tsx +0 -796
  59. package/src/flow/flow.tsx +0 -292
  60. package/src/flow/flowCompleted.css +0 -30
  61. package/src/flow/flowCompleted.test.tsx +0 -331
  62. package/src/flow/flowCompleted.tsx +0 -121
  63. package/src/flow/flowInit.test.ts +0 -264
  64. package/src/flow/flowInit.ts +0 -94
  65. package/src/flow/flowStart.css +0 -58
  66. package/src/flow/flowStart.test.tsx +0 -49
  67. package/src/flow/flowStart.tsx +0 -41
  68. package/src/flow/incode-logo.svg +0 -8
  69. package/src/flow/index.ts +0 -7
  70. package/src/flow/preloadFlow.test.ts +0 -421
  71. package/src/flow/preloadFlow.ts +0 -171
  72. package/src/flow/styles.css +0 -9
  73. package/src/flow/unsupportedModule.css +0 -21
  74. package/src/flow/unsupportedModule.tsx +0 -39
  75. package/src/flow/useFlowInitialization.test.tsx +0 -292
  76. package/src/flow/useFlowInitialization.ts +0 -128
  77. package/src/flow/useModuleLoader.test.tsx +0 -212
  78. package/src/flow/useModuleLoader.ts +0 -92
  79. package/src/hooks/index.ts +0 -1
  80. package/src/hooks/useManager.test.ts +0 -91
  81. package/src/hooks/useManager.ts +0 -40
  82. package/src/i18n/index.ts +0 -3
  83. package/src/i18n/instance.ts +0 -16
  84. package/src/i18n/setup.ts +0 -184
  85. package/src/i18n/useTranslation.ts +0 -42
  86. package/src/index.ts +0 -27
  87. package/src/permissions/assets/android-dots-icon.svg +0 -7
  88. package/src/permissions/assets/android-settings-icon.svg +0 -16
  89. package/src/permissions/assets/android-toggle-icon.svg +0 -20
  90. package/src/permissions/assets/bank-card-icon.svg +0 -14
  91. package/src/permissions/assets/camera-icon.svg +0 -12
  92. package/src/permissions/assets/camera-ios.svg +0 -53
  93. package/src/permissions/assets/check-icon.svg +0 -8
  94. package/src/permissions/assets/chrome-icon.svg +0 -43
  95. package/src/permissions/assets/password-icon.svg +0 -11
  96. package/src/permissions/assets/permissions-img.svg +0 -51
  97. package/src/permissions/assets/safari-icon.svg +0 -37
  98. package/src/permissions/assets/settings-icon.svg +0 -33
  99. package/src/permissions/assets/toggle-icon.svg +0 -19
  100. package/src/permissions/assets/warning-icon.svg +0 -6
  101. package/src/permissions/boldWithArrow.css +0 -9
  102. package/src/permissions/boldWithArrow.tsx +0 -41
  103. package/src/permissions/denied.css +0 -37
  104. package/src/permissions/denied.tsx +0 -29
  105. package/src/permissions/deniedAndroid.tsx +0 -56
  106. package/src/permissions/deniedDesktop.css +0 -9
  107. package/src/permissions/deniedDesktop.tsx +0 -64
  108. package/src/permissions/deniedIOS.tsx +0 -73
  109. package/src/permissions/deniedInstructions.tsx +0 -19
  110. package/src/permissions/iconWrapper.css +0 -9
  111. package/src/permissions/iconWrapper.tsx +0 -15
  112. package/src/permissions/learnMore.css +0 -37
  113. package/src/permissions/learnMore.tsx +0 -85
  114. package/src/permissions/numberedStep.css +0 -13
  115. package/src/permissions/numberedStep.tsx +0 -14
  116. package/src/permissions/permissions.css +0 -13
  117. package/src/permissions/permissions.tsx +0 -68
  118. package/src/phone/phone.tsx +0 -246
  119. package/src/phone/phoneInput.test.tsx +0 -275
  120. package/src/phone/phoneInput.tsx +0 -249
  121. package/src/phone/styles.css +0 -158
  122. package/src/selfie/cameraButton.css +0 -13
  123. package/src/selfie/cameraButton.tsx +0 -35
  124. package/src/selfie/capture.css +0 -57
  125. package/src/selfie/capture.tsx +0 -232
  126. package/src/selfie/errorModal.tsx +0 -218
  127. package/src/selfie/errorModalContent.css +0 -33
  128. package/src/selfie/errorModalContent.tsx +0 -44
  129. package/src/selfie/faceOutline.css +0 -5
  130. package/src/selfie/faceOutline.tsx +0 -22
  131. package/src/selfie/loadingBorder.css +0 -12
  132. package/src/selfie/loadingBorder.tsx +0 -77
  133. package/src/selfie/manualCaptureButton.css +0 -13
  134. package/src/selfie/manualCaptureButton.tsx +0 -35
  135. package/src/selfie/noMoreAttemptsModal.tsx +0 -44
  136. package/src/selfie/notification.css +0 -9
  137. package/src/selfie/notification.tsx +0 -36
  138. package/src/selfie/retryErrorModal.tsx +0 -56
  139. package/src/selfie/selfie.test.tsx +0 -458
  140. package/src/selfie/selfie.tsx +0 -83
  141. package/src/selfie/selfieTutorial.json +0 -2626
  142. package/src/selfie/styles.css +0 -1
  143. package/src/selfie/tutorial.test.tsx +0 -200
  144. package/src/selfie/tutorial.tsx +0 -43
  145. package/src/setup.ts +0 -33
  146. package/src/shared/baseTutorial/baseTutorial.css +0 -21
  147. package/src/shared/baseTutorial/baseTutorial.test.tsx +0 -184
  148. package/src/shared/baseTutorial/baseTutorial.tsx +0 -55
  149. package/src/shared/baseTutorial/replaceBaseTutorial.test.ts +0 -267
  150. package/src/shared/baseTutorial/replaceBaseTutorial.ts +0 -68
  151. package/src/shared/button/button.css +0 -55
  152. package/src/shared/button/button.test.tsx +0 -101
  153. package/src/shared/button/button.tsx +0 -47
  154. package/src/shared/componentRoot/incodeComponent.tsx +0 -12
  155. package/src/shared/countries/countries.test.ts +0 -75
  156. package/src/shared/countries/countries.ts +0 -139
  157. package/src/shared/countries/index.ts +0 -6
  158. package/src/shared/icons/chevronDown.tsx +0 -22
  159. package/src/shared/icons/index.ts +0 -2
  160. package/src/shared/icons/successIcon.css +0 -5
  161. package/src/shared/icons/successIcon.test.tsx +0 -40
  162. package/src/shared/icons/successIcon.tsx +0 -26
  163. package/src/shared/loader/loadingIcon.css +0 -28
  164. package/src/shared/loader/loadingIcon.tsx +0 -67
  165. package/src/shared/lottie/lottie.tsx +0 -108
  166. package/src/shared/otpInput/otpInput.css +0 -85
  167. package/src/shared/otpInput/otpInput.test.tsx +0 -356
  168. package/src/shared/otpInput/otpInput.tsx +0 -241
  169. package/src/shared/page/incode-logo.svg +0 -3
  170. package/src/shared/page/page.css +0 -47
  171. package/src/shared/page/page.test.tsx +0 -97
  172. package/src/shared/page/page.tsx +0 -91
  173. package/src/shared/page/pageUiConfig.test.ts +0 -112
  174. package/src/shared/page/pageUiConfig.ts +0 -64
  175. package/src/shared/page/verifiedByIncode.css +0 -5
  176. package/src/shared/page/verifiedByIncode.tsx +0 -75
  177. package/src/shared/spacer/spacer.css +0 -149
  178. package/src/shared/spacer/spacer.test.tsx +0 -143
  179. package/src/shared/spacer/spacer.tsx +0 -88
  180. package/src/shared/spinner/index.ts +0 -2
  181. package/src/shared/spinner/spinner.css +0 -28
  182. package/src/shared/spinner/spinner.test.tsx +0 -82
  183. package/src/shared/spinner/spinner.tsx +0 -65
  184. package/src/shared/title/title.css +0 -7
  185. package/src/shared/title/title.tsx +0 -12
  186. package/src/shared/uiConfig/uiConfig.ts +0 -36
  187. package/src/shared/webComponent/incodeModule.ts +0 -29
  188. package/src/shared/webComponent/registerIncodeElement.ts +0 -15
  189. package/src/styles/__mocks__/fetchTheme.ts +0 -19
  190. package/src/styles/applyTheme.ts +0 -37
  191. package/src/styles/cn.test.tsx +0 -57
  192. package/src/styles/cn.tsx +0 -21
  193. package/src/styles/core.css +0 -12
  194. package/src/styles/fetchTheme.test.ts +0 -390
  195. package/src/styles/fetchTheme.ts +0 -88
  196. package/src/styles/generatePalette.ts +0 -111
  197. package/src/styles/reset.css +0 -65
  198. package/src/styles/resolveCssVariableToHex.ts +0 -28
  199. package/src/styles/tailwind.css +0 -291
  200. package/src/styles/themeTypes.ts +0 -18
  201. package/src/styles/tokens/colors.css +0 -190
  202. package/src/styles/tokens/components.css +0 -174
  203. package/src/styles/tokens/index.css +0 -4
  204. package/src/styles/tokens/primitives.css +0 -129
  205. package/src/styles/tokens/semantic.css +0 -51
  206. package/src/svg.d.ts +0 -4
  207. package/src/types/assets.d.ts +0 -1
  208. package/src/types/custom-elements.d.ts +0 -104
  209. package/tsconfig.json +0 -22
  210. package/vite.config.ts +0 -260
  211. package/vitest.config.ts +0 -40
  212. package/vitest.setup.ts +0 -16
@@ -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
+ };