@fileflow/sdk 0.1.6 → 0.1.8

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.
@@ -0,0 +1,756 @@
1
+ import { jsxs as s, jsx as e, Fragment as oe } from "react/jsx-runtime";
2
+ import de, { useCallback as E, useState as me, useEffect as ue } from "react";
3
+ import { f as w, h as pe, D as A, u as he, X as Z, j as D, U as ve, A as ye, k as B, m as H, L, n as V, g as M, o as ge } from "./index-CEvc89fO.mjs";
4
+ /**
5
+ * @license lucide-react v0.321.0 - ISC
6
+ *
7
+ * This source code is licensed under the ISC license.
8
+ * See the LICENSE file in the root directory of this source tree.
9
+ */
10
+ const xe = w("Car", [
11
+ [
12
+ "path",
13
+ {
14
+ d: "M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2",
15
+ key: "5owen"
16
+ }
17
+ ],
18
+ ["circle", { cx: "7", cy: "17", r: "2", key: "u2ysq9" }],
19
+ ["path", { d: "M9 17h6", key: "r8uit2" }],
20
+ ["circle", { cx: "17", cy: "17", r: "2", key: "axvx0g" }]
21
+ ]);
22
+ /**
23
+ * @license lucide-react v0.321.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */
28
+ const W = w("Clock", [
29
+ ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
30
+ ["polyline", { points: "12 6 12 12 16 14", key: "68esgv" }]
31
+ ]);
32
+ /**
33
+ * @license lucide-react v0.321.0 - ISC
34
+ *
35
+ * This source code is licensed under the ISC license.
36
+ * See the LICENSE file in the root directory of this source tree.
37
+ */
38
+ const G = w("FileText", [
39
+ ["path", { d: "M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z", key: "1rqfz7" }],
40
+ ["path", { d: "M14 2v4a2 2 0 0 0 2 2h4", key: "tnqrlb" }],
41
+ ["path", { d: "M10 9H8", key: "b1mrlr" }],
42
+ ["path", { d: "M16 13H8", key: "t4e002" }],
43
+ ["path", { d: "M16 17H8", key: "z1uh3a" }]
44
+ ]);
45
+ /**
46
+ * @license lucide-react v0.321.0 - ISC
47
+ *
48
+ * This source code is licensed under the ISC license.
49
+ * See the LICENSE file in the root directory of this source tree.
50
+ */
51
+ const Ne = w("Home", [
52
+ ["path", { d: "m3 9 9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z", key: "y5dka4" }],
53
+ ["polyline", { points: "9 22 9 12 15 12 15 22", key: "e2us08" }]
54
+ ]);
55
+ /**
56
+ * @license lucide-react v0.321.0 - ISC
57
+ *
58
+ * This source code is licensed under the ISC license.
59
+ * See the LICENSE file in the root directory of this source tree.
60
+ */
61
+ const be = w("Image", [
62
+ ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
63
+ ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
64
+ ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
65
+ ]);
66
+ /**
67
+ * @license lucide-react v0.321.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */
72
+ const we = w("ShieldCheck", [
73
+ ["path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10", key: "1irkt0" }],
74
+ ["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
75
+ ]);
76
+ /**
77
+ * @license lucide-react v0.321.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */
82
+ const Ce = w("Shield", [
83
+ ["path", { d: "M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10", key: "1irkt0" }]
84
+ ]), $ = (c) => ({
85
+ id: null,
86
+ type: c,
87
+ status: "uploaded",
88
+ file: null,
89
+ previewUrl: null,
90
+ extractedData: null,
91
+ confidence: 0,
92
+ fraudFlags: [],
93
+ error: null
94
+ }), X = {
95
+ sessionId: null,
96
+ status: "idle",
97
+ step: "select",
98
+ requiredDocuments: [],
99
+ currentDocumentType: null,
100
+ documents: /* @__PURE__ */ new Map(),
101
+ isVerified: !1,
102
+ verificationStatus: null,
103
+ isLoading: !1,
104
+ error: null
105
+ }, j = pe((c, o) => ({
106
+ ...X,
107
+ setSessionId: (f) => c({ sessionId: f }),
108
+ setRequiredDocuments: (f) => {
109
+ const t = /* @__PURE__ */ new Map();
110
+ for (const l of f)
111
+ t.set(l, $(l));
112
+ c({
113
+ requiredDocuments: f,
114
+ documents: t,
115
+ currentDocumentType: f[0] || null
116
+ });
117
+ },
118
+ setCurrentDocumentType: (f) => c({ currentDocumentType: f }),
119
+ setDocumentFile: (f, t) => {
120
+ const { documents: l } = o(), r = l.get(f) || $(f), a = URL.createObjectURL(t), p = new Map(l);
121
+ p.set(f, {
122
+ ...r,
123
+ file: t,
124
+ previewUrl: a,
125
+ status: "uploaded",
126
+ error: null
127
+ }), c({ documents: p });
128
+ },
129
+ setDocumentStatus: (f, t) => {
130
+ const { documents: l } = o(), r = l.get(f);
131
+ if (r) {
132
+ const a = new Map(l);
133
+ a.set(f, { ...r, status: t }), c({ documents: a });
134
+ }
135
+ },
136
+ setDocumentData: (f, t) => {
137
+ const { documents: l } = o(), r = l.get(f);
138
+ if (r) {
139
+ const a = new Map(l);
140
+ a.set(f, { ...r, ...t }), c({ documents: a });
141
+ }
142
+ },
143
+ clearDocumentPreview: (f) => {
144
+ const { documents: t } = o(), l = t.get(f);
145
+ l != null && l.previewUrl && URL.revokeObjectURL(l.previewUrl);
146
+ },
147
+ setStep: (f) => c({ step: f }),
148
+ nextDocument: () => {
149
+ const { requiredDocuments: f, currentDocumentType: t, documents: l } = o(), r = t ? f.indexOf(t) : -1;
150
+ for (let a = r + 1; a < f.length; a++) {
151
+ const p = f[a], u = l.get(p);
152
+ if (!(u != null && u.file)) {
153
+ c({ currentDocumentType: p });
154
+ return;
155
+ }
156
+ }
157
+ c({
158
+ currentDocumentType: null,
159
+ step: "processing"
160
+ });
161
+ },
162
+ setVerificationStatus: (f) => c({ verificationStatus: f }),
163
+ setVerified: (f) => c({ isVerified: f }),
164
+ setStatus: (f) => c({ status: f }),
165
+ setLoading: (f) => c({ isLoading: f }),
166
+ setError: (f) => c({ error: f }),
167
+ getNextRequiredDocument: () => {
168
+ const { requiredDocuments: f, documents: t } = o();
169
+ for (const l of f) {
170
+ const r = t.get(l);
171
+ if (!(r != null && r.file))
172
+ return l;
173
+ }
174
+ return null;
175
+ },
176
+ areAllDocumentsUploaded: () => {
177
+ const { requiredDocuments: f, documents: t } = o();
178
+ return f.every((l) => {
179
+ const r = t.get(l);
180
+ return (r == null ? void 0 : r.file) !== null;
181
+ });
182
+ },
183
+ areAllDocumentsProcessed: () => {
184
+ const { requiredDocuments: f, documents: t } = o();
185
+ return f.every((l) => {
186
+ const r = t.get(l);
187
+ return (r == null ? void 0 : r.status) === "completed" || (r == null ? void 0 : r.status) === "requires_review";
188
+ });
189
+ },
190
+ reset: () => {
191
+ const { documents: f } = o();
192
+ for (const t of f.values())
193
+ t.previewUrl && URL.revokeObjectURL(t.previewUrl);
194
+ c(X);
195
+ }
196
+ })), De = ({
197
+ documentType: c,
198
+ onFileSelect: o
199
+ }) => {
200
+ const { documents: f, setDocumentFile: t, isLoading: l } = j(), r = f.get(c), a = A[c], p = E(
201
+ (d, q) => {
202
+ if (!(q.length > 0) && d.length > 0) {
203
+ const v = d[0];
204
+ t(c, v), o == null || o(v);
205
+ }
206
+ },
207
+ [c, o, t]
208
+ ), { getRootProps: u, getInputProps: m, isDragActive: x } = he({
209
+ onDrop: p,
210
+ accept: {
211
+ "application/pdf": [".pdf"],
212
+ "image/jpeg": [".jpg", ".jpeg"],
213
+ "image/png": [".png"]
214
+ },
215
+ maxSize: a.maxFileSize,
216
+ multiple: !1,
217
+ disabled: l
218
+ }), k = (d) => d < 1024 ? `${d} B` : d < 1024 * 1024 ? `${(d / 1024).toFixed(1)} KB` : `${(d / (1024 * 1024)).toFixed(1)} MB`, z = () => {
219
+ var d;
220
+ return ((d = r == null ? void 0 : r.file) == null ? void 0 : d.type) === "application/pdf" ? /* @__PURE__ */ e(G, { className: "ff-w-6 ff-h-6" }) : /* @__PURE__ */ e(be, { className: "ff-w-6 ff-h-6" });
221
+ }, F = (d) => {
222
+ d.stopPropagation(), j.getState().clearDocumentPreview(c), t(c, null);
223
+ };
224
+ return r != null && r.file && r.previewUrl ? /* @__PURE__ */ s("div", { className: "ff-space-y-4", children: [
225
+ /* @__PURE__ */ e("div", { className: "ff-p-4 ff-rounded-xl", style: { backgroundColor: "var(--ff-primary-20)", border: "1px solid var(--ff-primary-50)" }, children: /* @__PURE__ */ s("div", { className: "ff-flex ff-items-center ff-gap-3", children: [
226
+ /* @__PURE__ */ e("div", { className: "ff-p-2 ff-rounded-lg", style: { backgroundColor: "var(--ff-primary-30)" }, children: /* @__PURE__ */ e("span", { style: { color: "var(--ff-primary-90)" }, children: z() }) }),
227
+ /* @__PURE__ */ s("div", { className: "ff-flex-1 ff-min-w-0", children: [
228
+ /* @__PURE__ */ e("p", { className: "ff-font-medium ff-truncate", style: { color: "var(--ff-primary-110)" }, children: r.file.name }),
229
+ /* @__PURE__ */ e("p", { className: "ff-text-sm", style: { color: "var(--ff-primary-90)" }, children: k(r.file.size) })
230
+ ] }),
231
+ /* @__PURE__ */ e(
232
+ "button",
233
+ {
234
+ onClick: F,
235
+ className: "ff-p-1.5 ff-rounded-full ff-transition-colors",
236
+ style: { color: "var(--ff-primary-90)" },
237
+ "aria-label": "Remove file",
238
+ children: /* @__PURE__ */ e(Z, { className: "ff-w-5 ff-h-5" })
239
+ }
240
+ )
241
+ ] }) }),
242
+ /* @__PURE__ */ e("div", { className: "ff-document-preview ff-aspect-[3/4] ff-max-h-96", children: r.file.type === "application/pdf" ? /* @__PURE__ */ e(
243
+ "iframe",
244
+ {
245
+ src: r.previewUrl,
246
+ className: "ff-w-full ff-h-full ff-rounded-xl",
247
+ title: "Document preview"
248
+ }
249
+ ) : /* @__PURE__ */ e(
250
+ "img",
251
+ {
252
+ src: r.previewUrl,
253
+ alt: "Document preview",
254
+ className: "ff-w-full ff-h-full ff-object-contain ff-rounded-xl"
255
+ }
256
+ ) })
257
+ ] }) : /* @__PURE__ */ s("div", { className: "ff-space-y-6", children: [
258
+ /* @__PURE__ */ s("div", { className: "ff-text-center ff-mb-4", children: [
259
+ /* @__PURE__ */ e("h3", { className: "ff-text-lg ff-font-semibold", style: { color: "var(--ff-text-primary)" }, children: a.label }),
260
+ /* @__PURE__ */ e("p", { className: "ff-text-sm ff-mt-1", style: { color: "var(--ff-text-muted)" }, children: a.description })
261
+ ] }),
262
+ /* @__PURE__ */ s(
263
+ "div",
264
+ {
265
+ ...u(),
266
+ className: D(
267
+ "ff-dropzone",
268
+ x && "ff-dropzone-active",
269
+ l && "ff-opacity-50 ff-cursor-not-allowed"
270
+ ),
271
+ children: [
272
+ /* @__PURE__ */ e("input", { ...m() }),
273
+ /* @__PURE__ */ e("div", { className: "ff-dropzone-icon-wrapper", children: /* @__PURE__ */ e(ve, { className: "ff-dropzone-icon" }) }),
274
+ /* @__PURE__ */ e("h3", { className: "ff-dropzone-text", children: x ? "Drop your document here" : "Upload your document" }),
275
+ /* @__PURE__ */ e("p", { className: "ff-dropzone-hint", children: "Drag and drop or click to select" }),
276
+ /* @__PURE__ */ e("label", { className: "ff-inline-block", children: /* @__PURE__ */ e("span", { className: D(
277
+ "ff-btn ff-btn-primary",
278
+ l && "ff-opacity-50 ff-cursor-wait"
279
+ ), children: l ? "Processing..." : "Choose file" }) }),
280
+ /* @__PURE__ */ s("div", { className: "ff-flex ff-flex-wrap ff-justify-center ff-gap-2 ff-mt-3", children: [
281
+ a.acceptedFormats.map((d) => /* @__PURE__ */ e(
282
+ "span",
283
+ {
284
+ className: "ff-px-2 ff-py-1 ff-rounded ff-text-xs",
285
+ style: { backgroundColor: "var(--ff-bg-tertiary)", color: "var(--ff-text-muted)" },
286
+ children: d.toUpperCase()
287
+ },
288
+ d
289
+ )),
290
+ /* @__PURE__ */ s("span", { className: "ff-px-2 ff-py-1 ff-text-xs", style: { color: "var(--ff-text-muted)" }, children: [
291
+ "Max ",
292
+ k(a.maxFileSize)
293
+ ] })
294
+ ] })
295
+ ]
296
+ }
297
+ ),
298
+ (r == null ? void 0 : r.error) && /* @__PURE__ */ s("div", { className: "ff-flex ff-items-center ff-gap-2 ff-p-4 ff-rounded-lg ff-text-sm", style: { backgroundColor: "var(--ff-error-light)", color: "var(--ff-error)" }, children: [
299
+ /* @__PURE__ */ e(ye, { className: "ff-w-4 ff-h-4 ff-flex-shrink-0" }),
300
+ /* @__PURE__ */ e("p", { children: r.error })
301
+ ] }),
302
+ /* @__PURE__ */ s("div", { className: "ff-rounded-xl ff-p-4", style: { backgroundColor: "var(--ff-bg-secondary)" }, children: [
303
+ /* @__PURE__ */ e("h4", { className: "ff-text-sm ff-font-medium ff-mb-2", style: { color: "var(--ff-text-secondary)" }, children: "Tips for best results:" }),
304
+ /* @__PURE__ */ s("ul", { className: "ff-text-sm ff-space-y-1 ff-list-disc ff-list-inside", style: { color: "var(--ff-text-muted)" }, children: [
305
+ /* @__PURE__ */ e("li", { children: "Ensure all text is clearly visible and readable" }),
306
+ /* @__PURE__ */ e("li", { children: "Avoid glare, shadows, or blurry images" }),
307
+ /* @__PURE__ */ e("li", { children: "Include all four corners of the document" }),
308
+ /* @__PURE__ */ e("li", { children: "Use good lighting when taking photos" })
309
+ ] })
310
+ ] })
311
+ ] });
312
+ }, ke = ({
313
+ documentType: c,
314
+ showDetails: o = !0
315
+ }) => {
316
+ const { documents: f } = j(), t = f.get(c), l = A[c], a = ((m) => {
317
+ switch (m) {
318
+ case "completed":
319
+ return {
320
+ icon: V,
321
+ iconColor: "var(--ff-success)",
322
+ bgColor: "var(--ff-success-light)",
323
+ label: "Verified",
324
+ labelColor: "var(--ff-success)",
325
+ description: "Document successfully processed"
326
+ };
327
+ case "requires_review":
328
+ return {
329
+ icon: H,
330
+ iconColor: "var(--ff-warning)",
331
+ bgColor: "var(--ff-warning-light)",
332
+ label: "Review Required",
333
+ labelColor: "var(--ff-warning)",
334
+ description: "Manual verification may be needed"
335
+ };
336
+ case "failed":
337
+ return {
338
+ icon: B,
339
+ iconColor: "var(--ff-error)",
340
+ bgColor: "var(--ff-error-light)",
341
+ label: "Failed",
342
+ labelColor: "var(--ff-error)",
343
+ description: "Unable to process document"
344
+ };
345
+ case "processing":
346
+ return {
347
+ icon: L,
348
+ iconColor: "var(--ff-primary-90)",
349
+ bgColor: "var(--ff-primary-20)",
350
+ label: "Processing",
351
+ labelColor: "var(--ff-primary-90)",
352
+ description: "Analyzing document..."
353
+ };
354
+ case "uploaded":
355
+ return {
356
+ icon: W,
357
+ iconColor: "var(--ff-text-secondary)",
358
+ bgColor: "var(--ff-bg-tertiary)",
359
+ label: "Pending",
360
+ labelColor: "var(--ff-text-secondary)",
361
+ description: "Waiting to be processed"
362
+ };
363
+ default:
364
+ return {
365
+ icon: W,
366
+ iconColor: "var(--ff-text-muted)",
367
+ bgColor: "var(--ff-bg-tertiary)",
368
+ label: "Not Uploaded",
369
+ labelColor: "var(--ff-text-muted)",
370
+ description: "Upload document to continue"
371
+ };
372
+ }
373
+ })(t == null ? void 0 : t.status), p = a.icon, u = (m) => m >= 0.8 ? "var(--ff-success)" : m >= 0.6 ? "var(--ff-warning)" : "var(--ff-error)";
374
+ return /* @__PURE__ */ s("div", { className: "ff-space-y-3", children: [
375
+ /* @__PURE__ */ s("div", { className: "ff-flex ff-items-center ff-gap-3", children: [
376
+ /* @__PURE__ */ e("div", { className: "ff-p-2 ff-rounded-xl", style: { backgroundColor: a.bgColor }, children: /* @__PURE__ */ e(
377
+ p,
378
+ {
379
+ className: D(
380
+ "ff-w-5 ff-h-5",
381
+ (t == null ? void 0 : t.status) === "processing" && "ff-animate-spin"
382
+ ),
383
+ style: { color: a.iconColor }
384
+ }
385
+ ) }),
386
+ /* @__PURE__ */ s("div", { children: [
387
+ /* @__PURE__ */ e("p", { className: "ff-font-medium", style: { color: "var(--ff-text-primary)" }, children: l.label }),
388
+ /* @__PURE__ */ e("p", { className: "ff-text-sm", style: { color: a.labelColor }, children: a.label })
389
+ ] })
390
+ ] }),
391
+ (t == null ? void 0 : t.confidence) !== void 0 && t.confidence > 0 && /* @__PURE__ */ s("div", { className: "ff-space-y-1", children: [
392
+ /* @__PURE__ */ s("div", { className: "ff-flex ff-items-center ff-justify-between ff-text-sm", children: [
393
+ /* @__PURE__ */ e("span", { style: { color: "var(--ff-text-secondary)" }, children: "Confidence" }),
394
+ /* @__PURE__ */ s("span", { className: "ff-font-medium", style: { color: u(t.confidence) }, children: [
395
+ Math.round(t.confidence * 100),
396
+ "%"
397
+ ] })
398
+ ] }),
399
+ /* @__PURE__ */ e("div", { className: "ff-progress", children: /* @__PURE__ */ e(
400
+ "div",
401
+ {
402
+ className: "ff-progress-bar",
403
+ style: {
404
+ width: `${t.confidence * 100}%`,
405
+ backgroundColor: u(t.confidence)
406
+ }
407
+ }
408
+ ) })
409
+ ] }),
410
+ o && (t == null ? void 0 : t.fraudFlags) && t.fraudFlags.length > 0 && /* @__PURE__ */ s("div", { className: "ff-space-y-2", children: [
411
+ /* @__PURE__ */ e("p", { className: "ff-text-sm ff-font-medium", style: { color: "var(--ff-text-secondary)" }, children: "Issues Detected" }),
412
+ /* @__PURE__ */ e("div", { className: "ff-space-y-1", children: t.fraudFlags.map((m, x) => /* @__PURE__ */ s(
413
+ "div",
414
+ {
415
+ className: "ff-flex ff-items-start ff-gap-2 ff-p-2 ff-rounded-lg ff-text-sm",
416
+ style: {
417
+ backgroundColor: m.severity === "high" ? "var(--ff-error-light)" : m.severity === "medium" ? "var(--ff-warning-light)" : "var(--ff-bg-tertiary)",
418
+ color: m.severity === "high" ? "var(--ff-error)" : m.severity === "medium" ? "var(--ff-warning)" : "var(--ff-text-secondary)"
419
+ },
420
+ children: [
421
+ m.severity === "high" ? /* @__PURE__ */ e(B, { className: "ff-w-4 ff-h-4 ff-flex-shrink-0 ff-mt-0.5" }) : /* @__PURE__ */ e(H, { className: "ff-w-4 ff-h-4 ff-flex-shrink-0 ff-mt-0.5" }),
422
+ /* @__PURE__ */ e("span", { children: m.message })
423
+ ]
424
+ },
425
+ x
426
+ )) })
427
+ ] }),
428
+ o && (t == null ? void 0 : t.extractedData) && t.status === "completed" && /* @__PURE__ */ s("div", { className: "ff-rounded-xl ff-p-3", style: { backgroundColor: "var(--ff-bg-tertiary)" }, children: [
429
+ /* @__PURE__ */ e("p", { className: "ff-text-sm ff-font-medium ff-mb-2", style: { color: "var(--ff-text-secondary)" }, children: "Extracted Information" }),
430
+ /* @__PURE__ */ s("dl", { className: "ff-space-y-1 ff-text-sm", children: [
431
+ "fullName" in t.extractedData && /* @__PURE__ */ s("div", { className: "ff-flex ff-justify-between", children: [
432
+ /* @__PURE__ */ e("dt", { style: { color: "var(--ff-text-muted)" }, children: "Name" }),
433
+ /* @__PURE__ */ e("dd", { className: "ff-font-medium", style: { color: "var(--ff-text-primary)" }, children: t.extractedData.fullName })
434
+ ] }),
435
+ "dateOfBirth" in t.extractedData && /* @__PURE__ */ s("div", { className: "ff-flex ff-justify-between", children: [
436
+ /* @__PURE__ */ e("dt", { style: { color: "var(--ff-text-muted)" }, children: "Date of Birth" }),
437
+ /* @__PURE__ */ e("dd", { style: { color: "var(--ff-text-primary)" }, children: t.extractedData.dateOfBirth })
438
+ ] }),
439
+ t.extractedData.documentType === "passport" && "passportNumber" in t.extractedData && /* @__PURE__ */ s("div", { className: "ff-flex ff-justify-between", children: [
440
+ /* @__PURE__ */ e("dt", { style: { color: "var(--ff-text-muted)" }, children: "Passport #" }),
441
+ /* @__PURE__ */ e("dd", { className: "ff-font-mono", style: { color: "var(--ff-text-primary)" }, children: t.extractedData.passportNumber })
442
+ ] }),
443
+ t.extractedData.documentType === "drivers_license" && "licenseNumber" in t.extractedData && /* @__PURE__ */ s("div", { className: "ff-flex ff-justify-between", children: [
444
+ /* @__PURE__ */ e("dt", { style: { color: "var(--ff-text-muted)" }, children: "License #" }),
445
+ /* @__PURE__ */ e("dd", { className: "ff-font-mono", style: { color: "var(--ff-text-primary)" }, children: t.extractedData.licenseNumber })
446
+ ] }),
447
+ "address" in t.extractedData && t.extractedData.address && /* @__PURE__ */ s("div", { className: "ff-flex ff-justify-between", children: [
448
+ /* @__PURE__ */ e("dt", { style: { color: "var(--ff-text-muted)" }, children: "Address" }),
449
+ /* @__PURE__ */ s("dd", { className: "ff-text-right", style: { color: "var(--ff-text-primary)" }, children: [
450
+ t.extractedData.address.city,
451
+ ",",
452
+ " ",
453
+ t.extractedData.address.province
454
+ ] })
455
+ ] })
456
+ ] })
457
+ ] })
458
+ ] });
459
+ }, T = ["select", "upload", "review", "complete"], Ue = {
460
+ passport: G,
461
+ drivers_license: xe,
462
+ proof_of_address: Ne
463
+ }, ze = ({
464
+ requiredDocuments: c,
465
+ onComplete: o,
466
+ onCancel: f,
467
+ onError: t
468
+ }) => {
469
+ const {
470
+ sessionId: l,
471
+ step: r,
472
+ currentDocumentType: a,
473
+ documents: p,
474
+ isVerified: u,
475
+ verificationStatus: m,
476
+ isLoading: x,
477
+ error: k,
478
+ setSessionId: z,
479
+ setRequiredDocuments: F,
480
+ setCurrentDocumentType: d,
481
+ setDocumentStatus: q,
482
+ setDocumentData: v,
483
+ setStep: N,
484
+ nextDocument: J,
485
+ setVerificationStatus: Q,
486
+ setVerified: ee,
487
+ setLoading: C,
488
+ setError: S,
489
+ areAllDocumentsUploaded: _,
490
+ areAllDocumentsProcessed: O,
491
+ reset: te
492
+ } = j(), [Ie, b] = me(null);
493
+ ue(() => (F(c), re(), () => {
494
+ b(null);
495
+ }), [c]);
496
+ const re = async () => {
497
+ try {
498
+ C(!0);
499
+ const n = await M().createKYCSession(c);
500
+ z(n.sessionId), N("upload");
501
+ } catch (i) {
502
+ const n = i;
503
+ S(n.message), t == null || t(n);
504
+ } finally {
505
+ C(!1);
506
+ }
507
+ }, fe = E(
508
+ async (i) => {
509
+ if (!(!l || !a))
510
+ try {
511
+ C(!0), S(null);
512
+ const h = await M().uploadKYCDocument(l, a, i);
513
+ v(a, {
514
+ id: h.documentId,
515
+ status: "processing"
516
+ }), b(h.documentId), se(h.documentId);
517
+ } catch (n) {
518
+ const h = n;
519
+ v(a, {
520
+ status: "failed",
521
+ error: h.message
522
+ }), t == null || t(h);
523
+ } finally {
524
+ C(!1);
525
+ }
526
+ },
527
+ [l, a]
528
+ ), se = async (i) => {
529
+ let y = 0, I = 0;
530
+ const R = async () => {
531
+ var Y;
532
+ if (y >= 30) {
533
+ b(null), a && v(a, {
534
+ status: "failed",
535
+ error: "Processing timed out. Please try again."
536
+ });
537
+ return;
538
+ }
539
+ if (I >= 3) {
540
+ b(null), a && v(a, {
541
+ status: "failed",
542
+ error: "Failed to check document status. Please refresh and try again."
543
+ });
544
+ return;
545
+ }
546
+ try {
547
+ const g = (await M().getKYCDocument(i)).document;
548
+ I = 0;
549
+ const ie = g.type;
550
+ if (v(ie, {
551
+ id: g.id,
552
+ status: g.status,
553
+ extractedData: g.extractedData,
554
+ confidence: g.confidence,
555
+ fraudFlags: g.fraudFlags,
556
+ error: null
557
+ // Clear any previous errors
558
+ }), g.status === "completed" || g.status === "requires_review" || g.status === "failed") {
559
+ b(null), _() ? O() && N("review") : J();
560
+ return;
561
+ }
562
+ y++, setTimeout(R, 2e3);
563
+ } catch (K) {
564
+ const P = K;
565
+ if (I++, y++, P.status === 404 || (Y = P.message) != null && Y.includes("not found")) {
566
+ b(null), a && v(a, {
567
+ status: "failed",
568
+ error: "Session not found or invalid state"
569
+ });
570
+ return;
571
+ }
572
+ I < 3 ? setTimeout(R, 3e3 * I) : (b(null), a && v(a, {
573
+ status: "failed",
574
+ error: P.message || "Failed to process document"
575
+ }));
576
+ }
577
+ };
578
+ R();
579
+ }, ae = async () => {
580
+ if (l)
581
+ try {
582
+ C(!0), S(null);
583
+ const n = await M().verifyKYCSession(l, !0);
584
+ Q(n.verificationStatus);
585
+ const h = n.verificationStatus;
586
+ ee(h.isVerified), N("complete"), o == null || o(n);
587
+ } catch (i) {
588
+ const n = i;
589
+ S(n.message), t == null || t(n);
590
+ } finally {
591
+ C(!1);
592
+ }
593
+ }, le = () => {
594
+ te(), f == null || f();
595
+ }, ce = (i) => {
596
+ d(i), N("upload");
597
+ }, ne = (i) => {
598
+ const n = p.get(i);
599
+ return (n == null ? void 0 : n.status) === "completed" || (n == null ? void 0 : n.status) === "requires_review";
600
+ }, U = () => {
601
+ const i = r === "processing" ? "upload" : r;
602
+ return T.indexOf(i);
603
+ };
604
+ return /* @__PURE__ */ s("div", { className: "ff-container ff-modal", children: [
605
+ /* @__PURE__ */ s("div", { className: "ff-modal-header", children: [
606
+ /* @__PURE__ */ s("div", { className: "ff-modal-header-left", children: [
607
+ /* @__PURE__ */ s("div", { className: "ff-flex ff-items-center ff-gap-3", children: [
608
+ /* @__PURE__ */ e("div", { className: "ff-modal-icon", children: /* @__PURE__ */ e(Ce, {}) }),
609
+ /* @__PURE__ */ e("h2", { className: "ff-modal-title", children: "Identity Verification" })
610
+ ] }),
611
+ /* @__PURE__ */ e("div", { className: "ff-steps ff-ml-4", children: T.map((i, n) => /* @__PURE__ */ s(de.Fragment, { children: [
612
+ /* @__PURE__ */ e(
613
+ "div",
614
+ {
615
+ className: D(
616
+ "ff-step",
617
+ U() === n && "ff-step-active",
618
+ U() > n && "ff-step-complete",
619
+ U() < n && "ff-step-pending"
620
+ ),
621
+ children: U() > n ? "✓" : n + 1
622
+ }
623
+ ),
624
+ n < T.length - 1 && /* @__PURE__ */ e("div", { className: D(
625
+ "ff-step-connector",
626
+ U() > n && "ff-step-connector-complete"
627
+ ) })
628
+ ] }, i)) })
629
+ ] }),
630
+ /* @__PURE__ */ e(
631
+ "button",
632
+ {
633
+ onClick: le,
634
+ className: "ff-modal-close",
635
+ children: /* @__PURE__ */ e(Z, { className: "ff-w-5 ff-h-5" })
636
+ }
637
+ )
638
+ ] }),
639
+ /* @__PURE__ */ s("div", { className: "ff-modal-body", children: [
640
+ k && /* @__PURE__ */ e("div", { className: "ff-mb-4 ff-p-4 ff-rounded-lg ff-text-sm", style: { backgroundColor: "var(--ff-error-light)", color: "var(--ff-error)" }, children: k }),
641
+ r === "select" && /* @__PURE__ */ s("div", { className: "ff-space-y-4", children: [
642
+ /* @__PURE__ */ e("p", { className: "ff-text-center ff-mb-6", style: { color: "var(--ff-text-muted)" }, children: "Please upload the following documents to verify your identity" }),
643
+ /* @__PURE__ */ e("div", { className: "ff-grid ff-gap-3", children: c.map((i) => {
644
+ const n = Ue[i], h = A[i];
645
+ p.get(i);
646
+ const y = ne(i);
647
+ return /* @__PURE__ */ s(
648
+ "button",
649
+ {
650
+ onClick: () => ce(i),
651
+ className: D(
652
+ "ff-flex ff-items-center ff-gap-4 ff-p-4 ff-rounded-xl ff-border-2 ff-text-left ff-transition-all ff-duration-150",
653
+ y ? "ff-border-transparent" : "ff-border-transparent hover:ff-border-transparent"
654
+ ),
655
+ style: {
656
+ backgroundColor: y ? "var(--ff-success-light)" : "var(--ff-bg-secondary)",
657
+ borderColor: y ? "var(--ff-success)" : "var(--ff-border-light)"
658
+ },
659
+ children: [
660
+ /* @__PURE__ */ e(
661
+ "div",
662
+ {
663
+ className: "ff-p-3 ff-rounded-xl",
664
+ style: {
665
+ backgroundColor: y ? "rgba(41, 142, 51, 0.15)" : "var(--ff-bg-tertiary)"
666
+ },
667
+ children: y ? /* @__PURE__ */ e(V, { className: "ff-w-6 ff-h-6", style: { color: "var(--ff-success)" } }) : /* @__PURE__ */ e(n, { className: "ff-w-6 ff-h-6", style: { color: "var(--ff-text-secondary)" } })
668
+ }
669
+ ),
670
+ /* @__PURE__ */ s("div", { className: "ff-flex-1", children: [
671
+ /* @__PURE__ */ e("p", { className: "ff-font-medium", style: { color: "var(--ff-text-primary)" }, children: h.label }),
672
+ /* @__PURE__ */ e("p", { className: "ff-text-sm", style: { color: "var(--ff-text-muted)" }, children: h.description })
673
+ ] }),
674
+ /* @__PURE__ */ e(ge, { className: "ff-w-5 ff-h-5", style: { color: "var(--ff-text-muted)" } })
675
+ ]
676
+ },
677
+ i
678
+ );
679
+ }) })
680
+ ] }),
681
+ r === "upload" && a && /* @__PURE__ */ e("div", { className: "ff-py-4", children: /* @__PURE__ */ e("div", { className: "ff-max-w-lg ff-mx-auto", children: /* @__PURE__ */ e(De, { documentType: a, onFileSelect: fe }) }) }),
682
+ r === "processing" && /* @__PURE__ */ s("div", { className: "ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-12", children: [
683
+ /* @__PURE__ */ e(L, { className: "ff-w-12 ff-h-12 ff-animate-spin ff-mb-4", style: { color: "var(--ff-primary-90)" } }),
684
+ /* @__PURE__ */ e("h3", { className: "ff-text-lg ff-font-semibold ff-mb-2", style: { color: "var(--ff-text-primary)" }, children: "Processing Documents" }),
685
+ /* @__PURE__ */ e("p", { style: { color: "var(--ff-text-muted)" }, className: "ff-text-center", children: "We're analyzing your documents. This may take a moment..." })
686
+ ] }),
687
+ r === "review" && /* @__PURE__ */ s("div", { className: "ff-space-y-6", children: [
688
+ /* @__PURE__ */ s("div", { className: "ff-text-center ff-mb-6", children: [
689
+ /* @__PURE__ */ e("h3", { className: "ff-text-lg ff-font-semibold", style: { color: "var(--ff-text-primary)" }, children: "Review Your Documents" }),
690
+ /* @__PURE__ */ e("p", { style: { color: "var(--ff-text-muted)" }, children: "Please review the extracted information before completing verification" })
691
+ ] }),
692
+ /* @__PURE__ */ e("div", { className: "ff-grid ff-gap-4", children: c.map((i) => /* @__PURE__ */ e(
693
+ "div",
694
+ {
695
+ className: "ff-rounded-xl ff-p-4",
696
+ style: { backgroundColor: "var(--ff-bg-secondary)", border: "1px solid var(--ff-border-light)" },
697
+ children: /* @__PURE__ */ e(ke, { documentType: i, showDetails: !0 })
698
+ },
699
+ i
700
+ )) })
701
+ ] }),
702
+ r === "complete" && /* @__PURE__ */ s("div", { className: "ff-flex ff-flex-col ff-items-center ff-justify-center ff-py-12", children: [
703
+ /* @__PURE__ */ e(
704
+ "div",
705
+ {
706
+ className: "ff-w-16 ff-h-16 ff-rounded-full ff-flex ff-items-center ff-justify-center ff-mb-4",
707
+ style: { backgroundColor: u ? "var(--ff-success-light)" : "var(--ff-warning-light)" },
708
+ children: u ? /* @__PURE__ */ e(V, { className: "ff-w-10 ff-h-10", style: { color: "var(--ff-success)" } }) : /* @__PURE__ */ e(we, { className: "ff-w-10 ff-h-10", style: { color: "var(--ff-warning)" } })
709
+ }
710
+ ),
711
+ /* @__PURE__ */ e("h3", { className: "ff-text-xl ff-font-semibold ff-mb-2", style: { color: "var(--ff-text-primary)" }, children: u ? "Verification Complete!" : "Review Required" }),
712
+ /* @__PURE__ */ e("p", { style: { color: "var(--ff-text-muted)" }, className: "ff-text-center", children: u ? "Your identity has been successfully verified." : "Additional review may be required. We will contact you if needed." })
713
+ ] })
714
+ ] }),
715
+ r !== "complete" && /* @__PURE__ */ s("div", { className: "ff-modal-footer", children: [
716
+ /* @__PURE__ */ e(
717
+ "button",
718
+ {
719
+ onClick: () => {
720
+ (r === "upload" || r === "review") && N("select");
721
+ },
722
+ disabled: x,
723
+ className: "ff-btn ff-btn-secondary",
724
+ children: "Back"
725
+ }
726
+ ),
727
+ r === "review" && /* @__PURE__ */ e(
728
+ "button",
729
+ {
730
+ onClick: ae,
731
+ disabled: x || !O(),
732
+ className: "ff-btn ff-btn-primary",
733
+ children: x ? /* @__PURE__ */ s(oe, { children: [
734
+ /* @__PURE__ */ e(L, { className: "ff-w-4 ff-h-4 ff-animate-spin" }),
735
+ "Verifying..."
736
+ ] }) : "Complete Verification"
737
+ }
738
+ ),
739
+ r === "select" && _() && /* @__PURE__ */ e(
740
+ "button",
741
+ {
742
+ onClick: () => N("review"),
743
+ className: "ff-btn ff-btn-primary",
744
+ children: "Review & Verify"
745
+ }
746
+ )
747
+ ] })
748
+ ] });
749
+ };
750
+ export {
751
+ De as D,
752
+ ze as K,
753
+ ke as a,
754
+ j as u
755
+ };
756
+ //# sourceMappingURL=KYCWizard-D4RKtikr.mjs.map