@casperid/react 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/README.md +1 -1
  2. package/dist/_commonjsHelpers-DKOUU3wS.cjs +2 -0
  3. package/dist/_commonjsHelpers-DKOUU3wS.cjs.map +1 -0
  4. package/dist/_commonjsHelpers-DaMA6jEr.js +9 -0
  5. package/dist/_commonjsHelpers-DaMA6jEr.js.map +1 -0
  6. package/dist/camera_utils-BQaOSBPu.js +397 -0
  7. package/dist/camera_utils-BQaOSBPu.js.map +1 -0
  8. package/dist/camera_utils-wchtqrQn.cjs +2 -0
  9. package/dist/camera_utils-wchtqrQn.cjs.map +1 -0
  10. package/dist/face_mesh-DYMPc5Ce.js +4212 -0
  11. package/dist/face_mesh-DYMPc5Ce.js.map +1 -0
  12. package/dist/face_mesh-fEvyDoPt.cjs +19 -0
  13. package/dist/face_mesh-fEvyDoPt.cjs.map +1 -0
  14. package/dist/index.cjs +41 -41
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.mjs +1786 -1501
  17. package/dist/index.mjs.map +1 -1
  18. package/dist/style.css +1 -1
  19. package/package.json +23 -10
  20. package/src/CasperIDModal.tsx +0 -777
  21. package/src/index.css +0 -217
  22. package/src/index.ts +0 -41
  23. package/src/screens/AuthSelection.tsx +0 -221
  24. package/src/screens/DocumentScan.tsx +0 -348
  25. package/src/screens/FaceScan.tsx +0 -368
  26. package/src/screens/IdentityVerified.tsx +0 -51
  27. package/src/screens/L1Setup.tsx +0 -335
  28. package/src/screens/Login.tsx +0 -186
  29. package/src/screens/MintingIdentity.tsx +0 -446
  30. package/src/screens/PasskeyAuth.tsx +0 -259
  31. package/src/screens/PasskeyRegister.tsx +0 -281
  32. package/src/screens/PermissionsRequest.tsx +0 -96
  33. package/src/screens/PinVerification.tsx +0 -321
  34. package/src/screens/ReviewData.tsx +0 -315
  35. package/src/screens/SecurityUpgrade.tsx +0 -83
  36. package/src/screens/VerifyIdentityChoice.tsx +0 -59
  37. package/src/shared/Footer.tsx +0 -13
  38. package/src/shared/GlassContainer.tsx +0 -17
  39. package/src/shared/Header.tsx +0 -62
  40. package/src/types.ts +0 -342
  41. package/src/utils/fetchWithTimeout.ts +0 -52
  42. package/src/utils/i18n.ts +0 -640
  43. package/src/utils/webauthn.ts +0 -261
package/dist/index.cjs CHANGED
@@ -1,179 +1,179 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),i=require("react"),z=require("framer-motion"),ye=({children:a,className:s="",theme:n=""})=>e.jsx("div",{className:`glass-container relative w-full h-full rounded-[var(--casperid-radius,1.5rem)] overflow-hidden flex flex-col shadow-2xl border dark:border-white/10 border-white/40 ${s} ${n}`,children:a});/**
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),a=require("react"),E=require("framer-motion"),Re=({children:i,className:s="",theme:r=""})=>e.jsx("div",{className:`glass-container relative w-full h-full rounded-[var(--casperid-radius,1.5rem)] overflow-hidden flex flex-col shadow-2xl border dark:border-white/10 border-white/40 ${s} ${r}`,children:i});/**
2
2
  * @license lucide-react v0.400.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const bt=a=>a.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Oe=(...a)=>a.filter((s,n,o)=>!!s&&o.indexOf(s)===n).join(" ");/**
6
+ */const wt=i=>i.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Be=(...i)=>i.filter((s,r,l)=>!!s&&l.indexOf(s)===r).join(" ");/**
7
7
  * @license lucide-react v0.400.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */var _t={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
11
+ */var kt={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
12
12
  * @license lucide-react v0.400.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const yt=i.forwardRef(({color:a="currentColor",size:s=24,strokeWidth:n=2,absoluteStrokeWidth:o,className:_="",children:d,iconNode:u,...c},r)=>i.createElement("svg",{ref:r,..._t,width:s,height:s,stroke:a,strokeWidth:o?Number(n)*24/Number(s):n,className:Oe("lucide",_),...c},[...u.map(([l,m])=>i.createElement(l,m)),...Array.isArray(d)?d:[d]]));/**
16
+ */const jt=a.forwardRef(({color:i="currentColor",size:s=24,strokeWidth:r=2,absoluteStrokeWidth:l,className:k="",children:f,iconNode:p,...m},n)=>a.createElement("svg",{ref:n,...kt,width:s,height:s,stroke:i,strokeWidth:l?Number(r)*24/Number(s):r,className:Be("lucide",k),...m},[...p.map(([c,d])=>a.createElement(c,d)),...Array.isArray(f)?f:[f]]));/**
17
17
  * @license lucide-react v0.400.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const M=(a,s)=>{const n=i.forwardRef(({className:o,..._},d)=>i.createElement(yt,{ref:d,iconNode:s,className:Oe(`lucide-${bt(a)}`,o),..._}));return n.displayName=`${a}`,n};/**
21
+ */const z=(i,s)=>{const r=a.forwardRef(({className:l,...k},f)=>a.createElement(jt,{ref:f,iconNode:s,className:Be(`lucide-${wt(i)}`,l),...k}));return r.displayName=`${i}`,r};/**
22
22
  * @license lucide-react v0.400.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const ke=M("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
26
+ */const ze=z("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
27
27
  * @license lucide-react v0.400.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const je=M("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
31
+ */const Ve=z("BadgeCheck",[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
32
32
  * @license lucide-react v0.400.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const gt=M("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
36
+ */const Nt=z("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
37
37
  * @license lucide-react v0.400.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const vt=M("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/**
41
+ */const Ct=z("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/**
42
42
  * @license lucide-react v0.400.0 - ISC
43
43
  *
44
44
  * This source code is licensed under the ISC license.
45
45
  * See the LICENSE file in the root directory of this source tree.
46
- */const ge=M("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
46
+ */const De=z("ChevronRight",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);/**
47
47
  * @license lucide-react v0.400.0 - ISC
48
48
  *
49
49
  * This source code is licensed under the ISC license.
50
50
  * See the LICENSE file in the root directory of this source tree.
51
- */const te=M("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
51
+ */const xe=z("CircleAlert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);/**
52
52
  * @license lucide-react v0.400.0 - ISC
53
53
  *
54
54
  * This source code is licensed under the ISC license.
55
55
  * See the LICENSE file in the root directory of this source tree.
56
- */const de=M("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
56
+ */const ve=z("CircleCheck",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
57
57
  * @license lucide-react v0.400.0 - ISC
58
58
  *
59
59
  * This source code is licensed under the ISC license.
60
60
  * See the LICENSE file in the root directory of this source tree.
61
- */const wt=M("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
61
+ */const It=z("CircleHelp",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);/**
62
62
  * @license lucide-react v0.400.0 - ISC
63
63
  *
64
64
  * This source code is licensed under the ISC license.
65
65
  * See the LICENSE file in the root directory of this source tree.
66
- */const Ve=M("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/**
66
+ */const He=z("CreditCard",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);/**
67
67
  * @license lucide-react v0.400.0 - ISC
68
68
  *
69
69
  * This source code is licensed under the ISC license.
70
70
  * See the LICENSE file in the root directory of this source tree.
71
- */const kt=M("Delete",[["path",{d:"M20 5H9l-7 7 7 7h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2Z",key:"1oy587"}],["line",{x1:"18",x2:"12",y1:"9",y2:"15",key:"1olkx5"}],["line",{x1:"12",x2:"18",y1:"9",y2:"15",key:"1n50pc"}]]);/**
71
+ */const St=z("Delete",[["path",{d:"M20 5H9l-7 7 7 7h11a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2Z",key:"1oy587"}],["line",{x1:"18",x2:"12",y1:"9",y2:"15",key:"1olkx5"}],["line",{x1:"12",x2:"18",y1:"9",y2:"15",key:"1n50pc"}]]);/**
72
72
  * @license lucide-react v0.400.0 - ISC
73
73
  *
74
74
  * This source code is licensed under the ISC license.
75
75
  * See the LICENSE file in the root directory of this source tree.
76
- */const le=M("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);/**
76
+ */const ge=z("Fingerprint",[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]]);/**
77
77
  * @license lucide-react v0.400.0 - ISC
78
78
  *
79
79
  * This source code is licensed under the ISC license.
80
80
  * See the LICENSE file in the root directory of this source tree.
81
- */const jt=M("Flashlight",[["path",{d:"M18 6c0 2-2 2-2 4v10a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4V2h12z",key:"1orkel"}],["line",{x1:"6",x2:"18",y1:"6",y2:"6",key:"1z11jq"}],["line",{x1:"12",x2:"12",y1:"12",y2:"12",key:"1f4yc1"}]]);/**
81
+ */const Et=z("Flashlight",[["path",{d:"M18 6c0 2-2 2-2 4v10a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4V2h12z",key:"1orkel"}],["line",{x1:"6",x2:"18",y1:"6",y2:"6",key:"1z11jq"}],["line",{x1:"12",x2:"12",y1:"12",y2:"12",key:"1f4yc1"}]]);/**
82
82
  * @license lucide-react v0.400.0 - ISC
83
83
  *
84
84
  * This source code is licensed under the ISC license.
85
85
  * See the LICENSE file in the root directory of this source tree.
86
- */const Le=M("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
86
+ */const We=z("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
87
87
  * @license lucide-react v0.400.0 - ISC
88
88
  *
89
89
  * This source code is licensed under the ISC license.
90
90
  * See the LICENSE file in the root directory of this source tree.
91
- */const Nt=M("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
91
+ */const At=z("Key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);/**
92
92
  * @license lucide-react v0.400.0 - ISC
93
93
  *
94
94
  * This source code is licensed under the ISC license.
95
95
  * See the LICENSE file in the root directory of this source tree.
96
- */const J=M("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
96
+ */const me=z("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
97
97
  * @license lucide-react v0.400.0 - ISC
98
98
  *
99
99
  * This source code is licensed under the ISC license.
100
100
  * See the LICENSE file in the root directory of this source tree.
101
- */const Ne=M("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
101
+ */const Ge=z("Lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);/**
102
102
  * @license lucide-react v0.400.0 - ISC
103
103
  *
104
104
  * This source code is licensed under the ISC license.
105
105
  * See the LICENSE file in the root directory of this source tree.
106
- */const Ct=M("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
106
+ */const Rt=z("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
107
107
  * @license lucide-react v0.400.0 - ISC
108
108
  *
109
109
  * This source code is licensed under the ISC license.
110
110
  * See the LICENSE file in the root directory of this source tree.
111
- */const It=M("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
111
+ */const Dt=z("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
112
112
  * @license lucide-react v0.400.0 - ISC
113
113
  *
114
114
  * This source code is licensed under the ISC license.
115
115
  * See the LICENSE file in the root directory of this source tree.
116
- */const St=M("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
116
+ */const Pt=z("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
117
117
  * @license lucide-react v0.400.0 - ISC
118
118
  *
119
119
  * This source code is licensed under the ISC license.
120
120
  * See the LICENSE file in the root directory of this source tree.
121
- */const Et=M("Puzzle",[["path",{d:"M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.077.877.528 1.073 1.01a2.5 2.5 0 1 0 3.259-3.259c-.482-.196-.933-.558-1.01-1.073-.05-.336.062-.676.303-.917l1.525-1.525A2.402 2.402 0 0 1 12 1.998c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.237 3.237c-.464.18-.894.527-.967 1.02Z",key:"i0oyt7"}]]);/**
121
+ */const Tt=z("Puzzle",[["path",{d:"M19.439 7.85c-.049.322.059.648.289.878l1.568 1.568c.47.47.706 1.087.706 1.704s-.235 1.233-.706 1.704l-1.611 1.611a.98.98 0 0 1-.837.276c-.47-.07-.802-.48-.968-.925a2.501 2.501 0 1 0-3.214 3.214c.446.166.855.497.925.968a.979.979 0 0 1-.276.837l-1.61 1.61a2.404 2.404 0 0 1-1.705.707 2.402 2.402 0 0 1-1.704-.706l-1.568-1.568a1.026 1.026 0 0 0-.877-.29c-.493.074-.84.504-1.02.968a2.5 2.5 0 1 1-3.237-3.237c.464-.18.894-.527.967-1.02a1.026 1.026 0 0 0-.289-.877l-1.568-1.568A2.402 2.402 0 0 1 1.998 12c0-.617.236-1.234.706-1.704L4.23 8.77c.24-.24.581-.353.917-.303.515.077.877.528 1.073 1.01a2.5 2.5 0 1 0 3.259-3.259c-.482-.196-.933-.558-1.01-1.073-.05-.336.062-.676.303-.917l1.525-1.525A2.402 2.402 0 0 1 12 1.998c.617 0 1.234.236 1.704.706l1.568 1.568c.23.23.556.338.877.29.493-.074.84-.504 1.02-.968a2.5 2.5 0 1 1 3.237 3.237c-.464.18-.894.527-.967 1.02Z",key:"i0oyt7"}]]);/**
122
122
  * @license lucide-react v0.400.0 - ISC
123
123
  *
124
124
  * This source code is licensed under the ISC license.
125
125
  * See the LICENSE file in the root directory of this source tree.
126
- */const he=M("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
126
+ */const Se=z("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);/**
127
127
  * @license lucide-react v0.400.0 - ISC
128
128
  *
129
129
  * This source code is licensed under the ISC license.
130
130
  * See the LICENSE file in the root directory of this source tree.
131
- */const At=M("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
131
+ */const zt=z("RotateCcw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);/**
132
132
  * @license lucide-react v0.400.0 - ISC
133
133
  *
134
134
  * This source code is licensed under the ISC license.
135
135
  * See the LICENSE file in the root directory of this source tree.
136
- */const oe=M("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
136
+ */const we=z("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
137
137
  * @license lucide-react v0.400.0 - ISC
138
138
  *
139
139
  * This source code is licensed under the ISC license.
140
140
  * See the LICENSE file in the root directory of this source tree.
141
- */const qe=M("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
141
+ */const Ye=z("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
142
142
  * @license lucide-react v0.400.0 - ISC
143
143
  *
144
144
  * This source code is licensed under the ISC license.
145
145
  * See the LICENSE file in the root directory of this source tree.
146
- */const Ce=M("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
146
+ */const Me=z("Smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);/**
147
147
  * @license lucide-react v0.400.0 - ISC
148
148
  *
149
149
  * This source code is licensed under the ISC license.
150
150
  * See the LICENSE file in the root directory of this source tree.
151
- */const Dt=M("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
151
+ */const Vt=z("Sparkles",[["path",{d:"M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z",key:"4pj2yx"}],["path",{d:"M20 3v4",key:"1olli1"}],["path",{d:"M22 5h-4",key:"1gvqau"}],["path",{d:"M4 17v2",key:"vumght"}],["path",{d:"M5 18H3",key:"zchphs"}]]);/**
152
152
  * @license lucide-react v0.400.0 - ISC
153
153
  *
154
154
  * This source code is licensed under the ISC license.
155
155
  * See the LICENSE file in the root directory of this source tree.
156
- */const Rt=M("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
156
+ */const Mt=z("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
157
157
  * @license lucide-react v0.400.0 - ISC
158
158
  *
159
159
  * This source code is licensed under the ISC license.
160
160
  * See the LICENSE file in the root directory of this source tree.
161
- */const Pt=M("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
161
+ */const Ft=z("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
162
162
  * @license lucide-react v0.400.0 - ISC
163
163
  *
164
164
  * This source code is licensed under the ISC license.
165
165
  * See the LICENSE file in the root directory of this source tree.
166
- */const Tt=M("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/**
166
+ */const Lt=z("Wallet",[["path",{d:"M19 7V4a1 1 0 0 0-1-1H5a2 2 0 0 0 0 4h15a1 1 0 0 1 1 1v4h-3a2 2 0 0 0 0 4h3a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1",key:"18etb6"}],["path",{d:"M3 5v14a2 2 0 0 0 2 2h15a1 1 0 0 0 1-1v-4",key:"xoc0q4"}]]);/**
167
167
  * @license lucide-react v0.400.0 - ISC
168
168
  *
169
169
  * This source code is licensed under the ISC license.
170
170
  * See the LICENSE file in the root directory of this source tree.
171
- */const zt=M("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),ve=({onClose:a,title:s="CasperID",subtitle:n="SECURE SDK",showClose:o=!0,theme:_,toggleTheme:d,logoUrl:u})=>e.jsxs("header",{className:"flex items-center justify-between px-6 pt-8 pb-4 relative z-20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-brand rounded-xl flex items-center justify-center shadow-brand",children:u?e.jsx("img",{src:u,alt:s,className:"w-5 h-5 object-contain"}):e.jsx(qe,{className:"text-white w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold tracking-tight text-main",children:s}),n&&e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-brand font-bold",children:n})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:d,className:"p-2 dark:hover:bg-white/10 hover:bg-slate-200/50 rounded-xl transition-colors text-muted","aria-label":"Toggle theme",children:_==="dark"?e.jsx(Rt,{className:"w-5 h-5"}):e.jsx(It,{className:"w-5 h-5"})}),o&&e.jsx("button",{onClick:a,className:"p-2 dark:hover:bg-white/10 hover:bg-slate-200/50 rounded-full transition-colors text-muted","aria-label":"Close",children:e.jsx(zt,{className:"w-5 h-5"})})]})]}),we=({children:a})=>e.jsx("footer",{className:"p-8 text-center relative z-20",children:a}),_e={EN:{welcome_back:"Welcome back",enter_email:"Enter your email to receive a verification code.",email_address:"Email Address",continue:"Continue",sending_code:"Sending Code...",verify_email:"Verify Email",enter_code:"Enter the 6-digit code sent to",verification_failed:"Verification Failed",verifying:"Verifying...",resend_code:"Resend Code",resend_in:"Resend in",secure_sdk:"SECURE SDK",permission_request:"PERMISSION REQUEST",review_data:"Review Data",mint_identity:"Mint Identity",face_scan:"Face Scan",document_scan:"Document Scan",verification_step:"VERIFICATION STEP",kyc_required:"KYC REQUIRED",security_upgrade_required:"Security Upgrade Required",security_upgrade_desc:"Your account requires a biometric security upgrade to perform this action.",biometric_secure:"BIOMETRIC SECURE",zero_knowledge:"ZERO KNOWLEDGE",start_upgrade:"Start Upgrade",do_this_later:"I'll do this later",sign_in_with_extension:"Sign in with Extension",sign_in_with_otp:"Sign in with OTP",extension_detected:"Extension Detected",secure_wallet:"Secure Wallet",fully_audited:"FULLY AUDITED",non_custodial:"NON-CUSTODIAL",verify_identity:"Verify Your Identity",choose_document:"Choose a document type to begin verification.",passport:"Passport",drivers_license:"Driver License",national_id:"ID Card",passport_desc:"All countries supported",drivers_license_desc:"Government issued card",national_id_desc:"National identity document",position_face:"Position your face in the frame",blink_slowly:"Blink slowly",turn_head_left:"Turn your head slowly to the left",turn_head_right:"Turn your head slowly to the right",processing:"Processing...",camera_permission_denied:"Camera permission denied",unable_access_camera:"Unable to access camera",live_camera:"LIVE CAMERA",initializing:"INITIALIZING",processing_verification:"Processing Verification...",processing_subtitle:"Validating your documents and biometrics",minting_identity:"Minting your Identity...",minting_subtitle:"Securing your decentralized identity on the Casper Network",identity_minted:"Identity Minted!",minted_subtitle:"Your CasperID has been successfully created",verification_failed_subtitle:"There was an issue with your verification",try_again:"Try Again",credential_hash:"Credential Hash",identity_verified:"Identity Verified",identity_verified_desc:"Your CasperID has been successfully authenticated on the Casper blockchain. You're ready to go.",share_data_consent:"Share Data Consent",authorize_dapps:"Authorize dApps to access your credentials",return_to_app:"Return to App",verify_data_desc:"Verify your extracted identity information. This data will be used to mint your CasperID.",ocr_confidence:"OCR Confidence",first_name:"First Name",last_name:"Last Name",document_number:"Document Number",date_of_birth:"Date of Birth",nationality:"Nationality",enter_first_name:"Enter first name",enter_last_name:"Enter last name",enter_nationality:"Enter nationality",scanned_successfully:"Scanned Successfully",secured_by_casper:"Secured by CasperID Protocol.",confirm_mint:"Confirm & Mint",submitting:"Submitting...",retake_photo:"Retake Photo",auth_subtitle:"Secure your Web3 identity with our premium authentication layer.",extension_connect_msg:"Click the CasperID extension icon in your browser to connect.",extension_not_detected:"CasperID extension not detected. Please install the extension or use OTP sign-in.",connecting:"Connecting...",two_factor_auth:"Two-Factor Auth",security_notice:"Your data is encrypted and never stored on central servers. Powered by Casper Network.",e2e_encrypted:"End-to-End Encrypted",error_email_required:"Please enter your email",error_invalid_email:"Please enter a valid email address",error_passkey_registered:"You have a passkey registered. Please use extension sign-in.",error_send_code_failed:"Failed to send verification code. Please try again.",error_connection_failed:"Unable to connect. Please check your internet connection.",verify_code:"Verification Code",code_expired:"Code expired",invalid_code:"Invalid code",error_pin_incomplete:"Please enter all 6 digits",verify:"Verify",invalid_code_attempts:"Invalid code. {attempts} attempts remaining.",awaiting_calibration:"Awaiting Calibration",transaction_status:"Transaction Status",complete_percent:"{percent}% Complete",validating_docs:"Validating documents...",broadcasting_tx:"Broadcasting to Casper Mainnet Node...",tx_confirmed:"Transaction confirmed on Casper Network",scan_instruction:"Scan {side} of your {docType}",review_capture:"Review your capture. Ensure all text is clearly visible.",align_document:"Align your document within the glowing frame. Ensure all four corners are visible.",next_back_side:"Next: Back Side",confirm:"Confirm",capture:"Capture",verify_data_carefully:"Please verify the extracted data carefully.",enter_doc_number:"Enter document number",date_format:"DD/MM/YYYY",error_required_fields:"Please fill in all required fields.",front:"front",back:"back",requesting_access:"Requesting Access",privacy_note:"Privacy Note",privacy_desc:"Only cryptographic proofs are shared. No private keys are ever exposed.",approve_verify:"Approve & Verify",deny:"Deny",perm_identity:"Verify Identity Status",perm_profile:"Read Public Profile",perm_kyc:"Share KYC Level",full_name:"FULL NAME",id_number:"ID NUMBER",passkey_auth_subtitle:"Use your passkey to sign in securely.",signing_in_as:"Signing in as",use_passkey:"Use Your Passkey",authenticating:"Authenticating...",authentication_failed:"Authentication Failed",passkey_auth_hint:"Touch ID, Face ID, or security key",passkey_cancelled:"Authentication was cancelled. Try again when ready.",authenticate:"Authenticate",use_email_instead:"Use email code instead",biometric_secured:"Biometric Secured",webauthn_not_supported:"Your browser doesn't support passkeys. Please use email verification.",create_passkey:"Create Your Passkey",passkey_register_subtitle:"Set up biometric authentication for secure, passwordless sign-in.",passkey_benefits_title:"Why use a passkey?",passkey_benefit_1:"No passwords to remember",passkey_benefit_2:"Phishing-resistant security",passkey_benefit_3:"Works across your devices",register_passkey:"Create Passkey",creating_passkey:"Creating passkey...",passkey_created:"Passkey created successfully!",passkey_create_failed:"Failed to create passkey",l1_setup_title:"Setting Up Your Identity",l1_setup_subtitle:"Creating your secure wallet and decentralized identity.",generating_wallet:"Generating secure wallet...",minting_did:"Minting your DID...",l1_complete:"Identity setup complete!",l1_failed:"Setup failed. Please try again."},ES:{welcome_back:"Bienvenido de nuevo",enter_email:"Ingrese su correo para recibir un código.",email_address:"Correo electrónico",continue:"Continuar",sending_code:"Enviando código...",verify_email:"Verificar correo",enter_code:"Ingrese el código de 6 dígitos enviado a",verification_failed:"Error de verificación",verifying:"Verificando...",resend_code:"Reenviar código",resend_in:"Reenviar en",secure_sdk:"SDK SEGURO",permission_request:"SOLICITUD DE PERMISO",review_data:"Revisar datos",mint_identity:"Mint Identidad",face_scan:"Escaneo facial",document_scan:"Escaneo de documentos",verification_step:"PASO DE VERIFICACIÓN",kyc_required:"KYC REQUERIDO",security_upgrade_required:"Actualización de Seguridad Requerida",security_upgrade_desc:"Su cuenta requiere una actualización de seguridad biométrica para esta acción.",biometric_secure:"BIOMÉTRICO SEGURO",zero_knowledge:"CONOCIMIENTO CERO",start_upgrade:"Iniciar actualización",do_this_later:"Lo haré más tarde",sign_in_with_extension:"Iniciar sesión con extensión",sign_in_with_otp:"Iniciar sesión con OTP",extension_detected:"Extensión detectada",secure_wallet:"Billetera segura",fully_audited:"TOTALMENTE AUDITADO",non_custodial:"SIN CUSTODIA",verify_identity:"Verifique su identidad",choose_document:"Elija un tipo de documento para comenzar.",passport:"Pasaporte",drivers_license:"Licencia de conducir",national_id:"DNI / Cédula",passport_desc:"Todos los países soportados",drivers_license_desc:"Tarjeta emitida por el gobierno",national_id_desc:"Documento nacional de identidad",position_face:"Coloque su cara en el marco",blink_slowly:"Parpadee lentamente",turn_head_left:"Gire la cabeza hacia la izquierda",turn_head_right:"Gire la cabeza hacia la derecha",processing:"Procesando...",camera_permission_denied:"Permiso de cámara denegado",unable_access_camera:"No se puede acceder a la cámara",live_camera:"CÁMARA EN VIVO",initializing:"INICIALIZANDO",processing_verification:"Procesando verificación...",processing_subtitle:"Validando sus documentos y biometría",minting_identity:"Minting identidad...",minting_subtitle:"Asegurando su identidad descentralizada en Casper Network",identity_minted:"¡Identidad Minted!",minted_subtitle:"Su CasperID ha sido creado con éxito",verification_failed_subtitle:"Hubo un problema con su verificación",try_again:"Intentar de nuevo",credential_hash:"Hash de credencial",identity_verified:"Identidad verificada",identity_verified_desc:"Su CasperID ha sido autenticado con éxito en la cadena de bloques Casper.",share_data_consent:"Consentimiento de datos",authorize_dapps:"Autorizar dApps para acceder a credenciales",return_to_app:"Volver a la aplicación",verify_data_desc:"Verifique su información de identidad. Estos datos se usarán para crear su CasperID.",ocr_confidence:"Confianza OCR",first_name:"Nombre",last_name:"Apellido",document_number:"Número de documento",date_of_birth:"Fecha de nacimiento",nationality:"Nacionalidad",enter_first_name:"Ingrese nombre",enter_last_name:"Ingrese apellido",enter_nationality:"Ingrese nacionalidad",scanned_successfully:"Escaneado con éxito",secured_by_casper:"Protegido por CasperID Protocol.",confirm_mint:"Confirmar y crear",submitting:"Enviando...",retake_photo:"Tomar otra foto",auth_subtitle:"Asegure su identidad Web3 con nuestra capa de autenticación premium.",extension_connect_msg:"Haga clic en el icono de la extensión CasperID en su navegador para conectarse.",extension_not_detected:"No se detectó la extensión CasperID. Instale la extensión o use el inicio de sesión OTP.",connecting:"Conectando...",two_factor_auth:"Autenticación de dos factores",security_notice:"Sus datos están encriptados y nunca se almacenan en servidores centrales. Desarrollado por Casper Network.",e2e_encrypted:"Cifrado de extremo a extremo",error_email_required:"Por favor ingrese su correo",error_invalid_email:"Por favor ingrese un correo válido",error_passkey_registered:"Tiene una clave de paso registrada. Utilice el inicio de sesión por extensión.",error_send_code_failed:"Error al enviar el código de verificación. Inténtelo de nuevo.",error_connection_failed:"No se puede conectar. Compruebe su conexión a internet.",verify_code:"Código de verificación",code_expired:"Código expirado",invalid_code:"Código inválido",error_pin_incomplete:"Por favor ingrese los 6 dígitos",verify:"Verificar",invalid_code_attempts:"Código inválido. {attempts} intentos restantes.",awaiting_calibration:"Esperando calibración",transaction_status:"Estado de la transacción",complete_percent:"{percent}% completado",validating_docs:"Validando documentos...",broadcasting_tx:"Transmitiendo al nodo principal de Casper...",tx_confirmed:"Transacción confirmada en Casper Network",scan_instruction:"Escanee el {side} de su {docType}",review_capture:"Revise su captura. Asegúrese de que todo el texto sea visible.",align_document:"Alinee su documento dentro del marco brillante. Asegúrese de que las cuatro esquinas sean visibles.",next_back_side:"Siguiente: Reverso",confirm:"Confirmar",capture:"Capturar",verify_data_carefully:"Verifique los datos extraídos cuidadosamente.",enter_doc_number:"Ingrese el número de documento",date_format:"DD/MM/AAAA",error_required_fields:"Por favor complete todos los campos obligatorios.",front:"frente",back:"reverso",requesting_access:"Solicitando acceso",privacy_note:"Nota de privacidad",privacy_desc:"Solo se comparten pruebas criptográficas. Nunca se exponen las claves privadas.",approve_verify:"Aprobar y Verificar",deny:"Denegar",perm_identity:"Verificar estado de identidad",perm_profile:"Leer perfil público",perm_kyc:"Compartir nivel de KYC",full_name:"NOMBRE COMPLETO",id_number:"NÚMERO DE IDENTIFICACIÓN",passkey_auth_subtitle:"Use su clave de paso para iniciar sesión de forma segura.",signing_in_as:"Iniciando sesión como",use_passkey:"Use su clave de paso",authenticating:"Autenticando...",authentication_failed:"Autenticación fallida",passkey_auth_hint:"Touch ID, Face ID o llave de seguridad",passkey_cancelled:"Autenticación cancelada. Intente de nuevo cuando esté listo.",authenticate:"Autenticar",use_email_instead:"Usar código de correo",biometric_secured:"Biométrico seguro",webauthn_not_supported:"Su navegador no admite claves de paso. Use verificación por correo.",create_passkey:"Crear su clave de paso",passkey_register_subtitle:"Configure autenticación biométrica para inicio de sesión sin contraseña.",passkey_benefits_title:"¿Por qué usar clave de paso?",passkey_benefit_1:"Sin contraseñas que recordar",passkey_benefit_2:"Seguridad resistente al phishing",passkey_benefit_3:"Funciona en todos sus dispositivos",register_passkey:"Crear clave de paso",creating_passkey:"Creando clave de paso...",passkey_created:"¡Clave de paso creada!",passkey_create_failed:"Error al crear clave de paso",l1_setup_title:"Configurando su identidad",l1_setup_subtitle:"Creando su billetera segura e identidad descentralizada.",generating_wallet:"Generando billetera segura...",minting_did:"Minting su DID...",l1_complete:"¡Configuración de identidad completa!",l1_failed:"Configuración fallida. Intente de nuevo."},FR:{welcome_back:"Bon retour",enter_email:"Entrez votre email pour un code.",email_address:"Adresse email",continue:"Continuer",sending_code:"Envoi du code...",verify_email:"Vérifier l'email",enter_code:"Entrez le code à 6 chiffres envoyé à",verification_failed:"Échec de vérification",verifying:"Vérification...",resend_code:"Renvoyer le code",resend_in:"Renvoyer dans",secure_sdk:"SDK SÉCURISÉ",permission_request:"DEMANDE DE PERMISSION",review_data:"Réviser les données",mint_identity:"Mint Identité",face_scan:"Scan du visage",document_scan:"Scan du document",verification_step:"ÉTAPE DE VÉRIFICATION",kyc_required:"KYC REQUIS",security_upgrade_required:"Mise à niveau de sécurité requise",security_upgrade_desc:"Votre compte nécessite une mise à niveau biométrique pour cette action.",biometric_secure:"BIOMÉTRIE SÉCURISÉE",zero_knowledge:"ZÉRO CONNAISSANCE",start_upgrade:"Démarrer la mise à jour",do_this_later:"Je ferai ça plus tard",sign_in_with_extension:"Connexion avec l'extension",sign_in_with_otp:"Connexion avec OTP",extension_detected:"Extension détectée",secure_wallet:"Portefeuille sécurisé",fully_audited:"ENTIÈREMENT AUDITÉ",non_custodial:"NON FONGIBLE",verify_identity:"Vérifiez votre identité",choose_document:"Choisissez un type de document.",passport:"Passeport",drivers_license:"Permis de conduire",national_id:"Carte d'identité",passport_desc:"Tous les pays supportés",drivers_license_desc:"Carte émise par le gouvernement",national_id_desc:"Document d'identité national",position_face:"Placez votre visage dans le cadre",blink_slowly:"Clignez des yeux lentement",turn_head_left:"Tournez la tête vers la gauche",turn_head_right:"Tournez la tête vers la droite",processing:"Traitement...",camera_permission_denied:"Permission caméra refusée",unable_access_camera:"Accès caméra impossible",live_camera:"CAMÉRA EN DIRECT",initializing:"INITIALISATION",processing_verification:"Traitement de la vérification...",processing_subtitle:"Validation de vos documents et biométrie",minting_identity:"Mint Identité en cours...",minting_subtitle:"Sécurisation de votre identité sur le réseau Casper",identity_minted:"Identité créée !",minted_subtitle:"Votre CasperID a été créé avec succès",verification_failed_subtitle:"Il y a eu un problème avec votre vérification",try_again:"Réessayer",credential_hash:"Hachage de créance",identity_verified:"Identité vérifiée",identity_verified_desc:"Votre CasperID a été authentifié avec succès sur la blockchain Casper.",share_data_consent:"Partage de données",authorize_dapps:"Autoriser dApps à accéder aux identifiants",return_to_app:"Retour à l'application",verify_data_desc:"Vérifiez vos informations d'identité. Ces données seront utilisées pour créer votre CasperID.",ocr_confidence:"Confiance OCR",first_name:"Prénom",last_name:"Nom",document_number:"Numéro de document",date_of_birth:"Date de naissance",nationality:"Nationalité",enter_first_name:"Entrez le prénom",enter_last_name:"Entrez le nom",enter_nationality:"Entrez la nationalité",scanned_successfully:"Scanné avec succès",secured_by_casper:"Sécurisé par CasperID Protocol.",confirm_mint:"Confirmer et Créer",submitting:"Soumission...",retake_photo:"Reprendre la photo",auth_subtitle:"Sécurisez votre identité Web3 avec notre couche d'authentification premium.",extension_connect_msg:"Cliquez sur l'icône de l'extension CasperID dans votre navigateur pour vous connecter.",extension_not_detected:"Extension CasperID non détectée. Veuillez installer l'extension ou utiliser la connexion OTP.",connecting:"Connexion...",two_factor_auth:"Authentification à deux facteurs",security_notice:"Vos données sont cryptées et ne sont jamais stockées sur des serveurs centraux. Propulsé par Casper Network.",e2e_encrypted:"Chiffré de bout en bout",error_email_required:"Veuillez entrer votre email",error_invalid_email:"Veuillez entrer une adresse email valide",error_passkey_registered:"Vous avez une clé de sécurité enregistrée. Veuillez utiliser la connexion par extension.",error_send_code_failed:"Échec de l'envoi du code de vérification. Veuillez réessayer.",error_connection_failed:"Impossible de se connecter. Veuillez vérifier votre connexion internet.",verify_code:"Code de vérification",code_expired:"Code expiré",invalid_code:"Code invalide",error_pin_incomplete:"Veuillez entrer les 6 chiffres",verify:"Vérifier",invalid_code_attempts:"Code invalide. {attempts} tentatives restantes.",awaiting_calibration:"En attente de calibrage",transaction_status:"Statut de la transaction",complete_percent:"{percent}% terminé",validating_docs:"Validation des documents...",broadcasting_tx:"Diffusion sur le nœud Casper Mainnet...",tx_confirmed:"Transaction confirmée sur le réseau Casper",scan_instruction:"Scannez le {side} de votre {docType}",review_capture:"Réviser votre capture. Assurez-vous que tout le texte est visible.",align_document:"Alignez votre document dans le cadre. Assurez-vous que les quatre coins sont visibles.",next_back_side:"Suivant: Verso",confirm:"Confirmer",capture:"Capturer",verify_data_carefully:"Veuillez vérifier soigneusement les données extraites.",enter_doc_number:"Entrez le numéro du document",date_format:"JJ/MM/AAAA",error_required_fields:"Veuillez remplir tous les champs obligatoires.",front:"recto",back:"verso",requesting_access:"Demande d'accès",privacy_note:"Note de confidentialité",privacy_desc:"Seules des preuves cryptographiques sont partagées. Aucune clé privée n'est jamais exposée.",approve_verify:"Approuver et Vérifier",deny:"Refuser",perm_identity:"Vérifier le statut d'identité",perm_profile:"Lire le profil public",perm_kyc:"Partager le niveau KYC",full_name:"NOM COMPLET",id_number:"NUMÉRO DE DOCUMENT",passkey_auth_subtitle:"Utilisez votre clé d'accès pour vous connecter en toute sécurité.",signing_in_as:"Connexion en tant que",use_passkey:"Utilisez votre clé d'accès",authenticating:"Authentification...",authentication_failed:"Échec de l'authentification",passkey_auth_hint:"Touch ID, Face ID ou clé de sécurité",passkey_cancelled:"Authentification annulée. Réessayez quand vous êtes prêt.",authenticate:"Authentifier",use_email_instead:"Utiliser un code par email",biometric_secured:"Sécurisé biométrique",webauthn_not_supported:"Votre navigateur ne prend pas en charge les clés d'accès. Utilisez la vérification par email.",create_passkey:"Créer votre clé d'accès",passkey_register_subtitle:"Configurez l'authentification biométrique pour une connexion sans mot de passe.",passkey_benefits_title:"Pourquoi utiliser une clé d'accès?",passkey_benefit_1:"Pas de mot de passe à retenir",passkey_benefit_2:"Sécurité résistante au phishing",passkey_benefit_3:"Fonctionne sur tous vos appareils",register_passkey:"Créer la clé d'accès",creating_passkey:"Création de la clé d'accès...",passkey_created:"Clé d'accès créée!",passkey_create_failed:"Échec de la création de la clé d'accès",l1_setup_title:"Configuration de votre identité",l1_setup_subtitle:"Création de votre portefeuille sécurisé et identité décentralisée.",generating_wallet:"Génération du portefeuille sécurisé...",minting_did:"Création de votre DID...",l1_complete:"Configuration d'identité terminée!",l1_failed:"Échec de la configuration. Réessayez."},DE:{welcome_back:"Willkommen zurück",enter_email:"E-Mail für Bestätigungscode eingeben.",email_address:"E-Mail-Adresse",continue:"Weiter",sending_code:"Code wird gesendet...",verify_email:"E-Mail verifizieren",enter_code:"6-stelligen Code eingeben, gesendet an",verification_failed:"Verifizierung fehlgeschlagen",verifying:"Verifizierung...",resend_code:"Code erneut senden",resend_in:"Erneut in",secure_sdk:"SICHERES SDK",permission_request:"BERECHTIGUNGSANFRAGE",review_data:"Daten überprüfen",mint_identity:"Identität prägen",face_scan:"Gesichtsscan",document_scan:"Dokumentenscan",verification_step:"VERIFIZIERUNGSSCHRITT",kyc_required:"KYC ERFORDERLICH",security_upgrade_required:"Sicherheits-Upgrade erforderlich",security_upgrade_desc:"Ihr Konto erfordert ein biometrisches Upgrade für diese Aktion.",biometric_secure:"BIOMETRISCH SICHER",zero_knowledge:"ZERO-KNOWLEDGE",start_upgrade:"Upgrade starten",do_this_later:"Später erledigen",sign_in_with_extension:"Mit Erweiterung anmelden",sign_in_with_otp:"Mit OTP anmelden",extension_detected:"Erweiterung erkannt",secure_wallet:"Sichere Wallet",fully_audited:"VOLLSTÄNDIG GEPRÜFT",non_custodial:"NON-CUSTODIAL",verify_identity:"Identität verifizieren",choose_document:"Dokumenttyp auswählen.",passport:"Reisepass",drivers_license:"Führerschein",national_id:"Personalausweis",passport_desc:"Alle Länder unterstützt",drivers_license_desc:"Staatlicher Ausweis",national_id_desc:"Nationaler Identitätsnachweis",position_face:"Gesicht im Rahmen positionieren",blink_slowly:"Langsam blinzeln",turn_head_left:"Kopf langsam nach links drehen",turn_head_right:"Kopf langsam nach rechts drehen",processing:"Verarbeitung...",camera_permission_denied:"Kamerazugriff verweigert",unable_access_camera:"Kamerazugriff nicht möglich",live_camera:"LIVE-KAMERA",initializing:"INITIALISIERUNG",processing_verification:"Verifizierung wird verarbeitet...",processing_subtitle:"Dokumente und Biometrie werden validiert",minting_identity:"Identität wird geprägt...",minting_subtitle:"Ihre dezentrale Identität wird im Casper-Netzwerk gesichert",identity_minted:"Identität geprägt!",minted_subtitle:"Ihre CasperID wurde erfolgreich erstellt",verification_failed_subtitle:"Es gab ein Problem mit Ihrer Verifizierung",try_again:"Erneut versuchen",credential_hash:"Anmeldedaten-Hash",identity_verified:"Identität verifiziert",identity_verified_desc:"Ihre CasperID wurde erfolgreich in der Casper-Blockchain authentifiziert.",share_data_consent:"Datenfreigabe",authorize_dapps:"dApps Zugriff auf Anmeldedaten erlauben",return_to_app:"Zurück zur App",verify_data_desc:"Überprüfen Sie Ihre Identitätsdaten. Diese werden zur Erstellung Ihrer CasperID verwendet.",ocr_confidence:"OCR-Vertrauen",first_name:"Vorname",last_name:"Nachname",document_number:"Ausweisnummer",date_of_birth:"Geburtsdatum",nationality:"Nationalität",enter_first_name:"Vorname eingeben",enter_last_name:"Nachname eingeben",enter_nationality:"Nationalität eingeben",scanned_successfully:"Erfolgreich gescannt",secured_by_casper:"Gesichert durch CasperID Protocol.",confirm_mint:"Bestätigen & Prägen",submitting:"Wird gesendet...",retake_photo:"Foto erneut aufnehmen",auth_subtitle:"Sichern Sie Ihre Web3-Identität mit unserer Premium-Authentifizierungsschicht.",extension_connect_msg:"Klicken Sie auf das CasperID-Erweiterungssymbol in Ihrem Browser, um eine Verbindung herzustellen.",extension_not_detected:"CasperID-Erweiterung nicht erkannt. Bitte installieren Sie die Erweiterung oder verwenden Sie die OTP-Anmeldung.",connecting:"Verbindung wird hergestellt...",two_factor_auth:"Zwei-Faktor-Authentifizierung",security_notice:"Ihre Daten sind verschlüsselt und werden niemals auf zentralen Servern gespeichert. Unterstützt von Casper Network.",e2e_encrypted:"Ende-zu-Ende verschlüsselt",error_email_required:"Bitte geben Sie Ihre E-Mail-Adresse ein",error_invalid_email:"Bitte geben Sie eine gültige E-Mail-Adresse ein",error_passkey_registered:"Sie haben einen Passkey registriert. Bitte verwenden Sie die Anmeldung über die Erweiterung.",error_send_code_failed:"Der Verifizierungscode konnte nicht gesendet werden. Bitte versuchen Sie es erneut.",error_connection_failed:"Verbindung nicht möglich. Bitte überprüfen Sie Ihre Internetverbindung.",verify_code:"Verifizierungscode",code_expired:"Code abgelaufen",invalid_code:"Ungültiger Code",error_pin_incomplete:"Bitte alle 6 Ziffern eingeben",verify:"Verifizieren",invalid_code_attempts:"Ungültiger Code. {attempts} Versuche übrig.",error_verify_failed:"Verifizierung nicht möglich. Bitte erneut versuchen.",error_resend_failed:"Code konnte nicht gesendet werden. Bitte erneut versuchen.",sending:"Senden...",secure_face_scan_desc:"Sicherer Gesichtsscan • Verschlüsselt",analyzing_liveness:"Lebendigkeitsprüfung",calibration_complete:"Kalibrierung abgeschlossen",awaiting_calibration:"Warten auf Kalibrierung",transaction_status:"Transaktionsstatus",complete_percent:"{percent}% abgeschlossen",validating_docs:"Dokumente werden validiert...",broadcasting_tx:"Übertragung an Casper Mainnet Node...",tx_confirmed:"Transaktion im Casper-Netzwerk bestätigt",scan_instruction:"Scannen Sie die {side} Ihres {docType}",review_capture:"Überprüfen Sie Ihre Aufnahme. Stellen Sie sicher, dass der Text lesbar ist.",align_document:"Richten Sie Ihr Dokument im Rahmen aus. Alle vier Ecken müssen sichtbar sein.",next_back_side:"Weiter: Rückseite",confirm:"Bestätigen",capture:"Aufnehmen",verify_data_carefully:"Bitte überprüfen Sie die extrahierten Daten sorgfältig.",enter_doc_number:"Ausweisnummer eingeben",date_format:"TT/MM/JJJJ",error_required_fields:"Bitte füllen Sie alle Pflichtfelder aus.",front:"Vorderseite",back:"Rückseite",requesting_access:"Zugriff anfordern",privacy_note:"Datenschutzhinweis",privacy_desc:"Es werden nur kryptografische Beweise geteilt. Private Schlüssel werden niemals offengelegt.",approve_verify:"Genehmigen & Verifizieren",deny:"Ablehnen",perm_identity:"Identitätsstatus überprüfen",perm_profile:"Öffentliches Profil lesen",perm_kyc:"KYC-Level teilen",full_name:"VOLLSTÄNDIGER NAME",id_number:"AUSWEISNUMMER",passkey_auth_subtitle:"Verwenden Sie Ihren Passkey für sichere Anmeldung.",signing_in_as:"Anmeldung als",use_passkey:"Passkey verwenden",authenticating:"Authentifizierung...",authentication_failed:"Authentifizierung fehlgeschlagen",passkey_auth_hint:"Touch ID, Face ID oder Sicherheitsschlüssel",passkey_cancelled:"Authentifizierung abgebrochen. Versuchen Sie es erneut.",authenticate:"Authentifizieren",use_email_instead:"E-Mail-Code verwenden",biometric_secured:"Biometrisch gesichert",webauthn_not_supported:"Ihr Browser unterstützt keine Passkeys. Verwenden Sie E-Mail-Verifizierung.",create_passkey:"Passkey erstellen",passkey_register_subtitle:"Richten Sie biometrische Authentifizierung für passwortlose Anmeldung ein.",passkey_benefits_title:"Warum einen Passkey verwenden?",passkey_benefit_1:"Keine Passwörter merken",passkey_benefit_2:"Phishing-resistente Sicherheit",passkey_benefit_3:"Funktioniert auf allen Geräten",register_passkey:"Passkey erstellen",creating_passkey:"Passkey wird erstellt...",passkey_created:"Passkey erstellt!",passkey_create_failed:"Passkey-Erstellung fehlgeschlagen",l1_setup_title:"Identität einrichten",l1_setup_subtitle:"Sichere Wallet und dezentrale Identität werden erstellt.",generating_wallet:"Sichere Wallet wird generiert...",minting_did:"DID wird geprägt...",l1_complete:"Identitätseinrichtung abgeschlossen!",l1_failed:"Einrichtung fehlgeschlagen. Erneut versuchen."}},t=(a,s="EN")=>{const n=s.toUpperCase();return(_e[n]||_e.EN)[a]||_e.EN[a]||a},Ue=({onNext:a,onExtensionSuccess:s,onError:n,language:o="EN"})=>{const[_,d]=i.useState(!1),[u,c]=i.useState(null),[r,l]=i.useState("");i.useEffect(()=>{m()},[]),i.useEffect(()=>{const h=b=>{d(!1),b.detail&&b.detail.wallet&&(s==null||s(b.detail))};return window.addEventListener("casperid-login",h),()=>{window.removeEventListener("casperid-login",h)}},[s]);const m=i.useCallback(()=>{const h=document.getElementById("casperid-draggable-anchor");let b=null;try{b=localStorage.getItem("casperid_user")}catch{}return h||b?(c(!0),!0):(setTimeout(()=>{const f=document.getElementById("casperid-draggable-anchor");c(!!f)},500),!1)},[]),y=h=>typeof h=="object"&&h!==null&&"wallet"in h&&typeof h.wallet=="string"&&h.wallet.length>0,P=async()=>{d(!0),l("");try{const b=localStorage.getItem("casperid_user");if(b){const f=JSON.parse(b);if(y(f)){d(!1),s==null||s(f);return}}}catch{}const h=document.getElementById("casperid-draggable-anchor");h?(h.click(),setTimeout(()=>{d(!1);try{localStorage.getItem("casperid_user")||l(t("extension_connect_msg",o))}catch{l(t("extension_connect_msg",o))}},3e3)):(d(!1),l(t("extension_not_detected",o)),n==null||n("Extension not installed"))},O=()=>{l(""),a("otp")};return e.jsxs(z.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"flex-1 px-8 flex flex-col justify-center gap-8",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("div",{className:"relative w-24 h-24 mx-auto mb-6",children:[e.jsx("div",{className:"absolute inset-0 bg-brand-20 blur-2xl rounded-full"}),e.jsx("div",{className:"relative w-full h-full glass-container flex items-center justify-center rounded-2xl border border-brand-30",children:e.jsx(le,{className:"w-10 h-10 text-brand"})})]}),e.jsx("h1",{className:"text-2xl font-extrabold leading-tight tracking-tight text-main",children:t("welcome_back",o)}),e.jsx("p",{className:"text-muted text-sm leading-relaxed",children:t("auth_subtitle",o)})]}),r&&e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-2xl",children:[e.jsx(te,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm font-medium",children:r})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:P,disabled:_,className:"w-full group relative overflow-hidden flex items-center gap-4 bg-brand hover:bg-brand-90 text-white py-5 px-6 rounded-2xl font-bold transition-all transform active:scale-[0.98] disabled:opacity-70 disabled:cursor-not-allowed shadow-brand",children:[e.jsx("div",{className:"bg-white/20 p-2 rounded-lg",children:_?e.jsx(J,{className:"w-5 h-5 animate-spin"}):e.jsx(Et,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{className:"text-base",children:t(_?"connecting":"sign_in_with_extension",o)}),e.jsx("span",{className:"text-[10px] uppercase tracking-widest text-white/70",children:t(u===!0?"extension_detected":"secure_wallet",o)})]}),e.jsx(ge,{className:"ml-auto w-4 h-4 opacity-50 group-hover:opacity-100 transition-opacity"})]}),e.jsxs("button",{onClick:O,disabled:_,className:"w-full group relative overflow-hidden flex items-center gap-4 dark:bg-white/5 bg-slate-100/50 hover:dark:bg-white/10 hover:bg-slate-200/80 border dark:border-white/10 border-slate-200 text-main py-5 px-6 rounded-2xl font-bold transition-all transform active:scale-[0.98] disabled:opacity-50",children:[e.jsx("div",{className:"bg-brand-10 p-2 rounded-lg",children:e.jsx(Ce,{className:"w-5 h-5 text-brand"})}),e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{className:"text-base",children:t("sign_in_with_otp",o)}),e.jsx("span",{className:"text-[10px] uppercase tracking-widest text-brand font-bold",children:t("two_factor_auth",o)})]}),e.jsx(ge,{className:"ml-auto w-4 h-4 opacity-50 group-hover:opacity-100 transition-opacity"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"glass-container p-4 rounded-2xl flex flex-col items-center gap-2 text-center border-slate-200/50",children:[e.jsx(oe,{className:"w-5 h-5 text-brand"}),e.jsx("span",{className:"text-[10px] font-bold text-muted",children:t("fully_audited",o)})]}),e.jsxs("div",{className:"glass-container p-4 rounded-2xl flex flex-col items-center gap-2 text-center border-slate-200/50",children:[e.jsx(he,{className:"w-5 h-5 text-brand"}),e.jsx("span",{className:"text-[10px] font-bold text-muted",children:t("non_custodial",o)})]})]})]})},Fe=({onNext:a,onPasskeyUser:s,onError:n,apiBaseUrl:o="https://apis.casperid.com",previewMode:_=!1,language:d="EN"})=>{const[u,c]=i.useState(""),[r,l]=i.useState(!1),[m,y]=i.useState(""),P=async()=>{if(!u.trim()){y(t("error_email_required",d));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u)){y(t("error_invalid_email",d));return}if(l(!0),y(""),_){setTimeout(()=>{l(!1),a(u.trim().toLowerCase(),"mock-v-id-123456789")},1e3);return}try{const b=await fetch(`${o}/api/auth/send-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:u.trim().toLowerCase()})});if(!b.ok){const N=await b.json().catch(()=>({}));throw new Error(N.error||`Request failed with status ${b.status}`)}const f=await b.json();if(f.success){if(f.userExists&&f.hasPasskey){s?s(u.trim().toLowerCase()):y(t("error_passkey_registered",d)),l(!1);return}f.verificationId?a(u.trim().toLowerCase(),f.verificationId):y(t("error_send_code_failed",d))}else y(f.error||t("error_send_code_failed",d)),n==null||n(f.error||t("error_send_code_failed",d))}catch{const f=t("error_connection_failed",d);y(f),n==null||n(f)}finally{l(!1)}},O=h=>{h.key==="Enter"&&!r&&P()};return e.jsxs(z.motion.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex-1 flex flex-col px-8 pt-12",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-3xl font-extrabold text-main tracking-tight leading-tight",children:t("welcome_back",d)}),e.jsx("p",{className:"text-muted mt-3 text-sm leading-relaxed",children:t("enter_email",d)})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-widest ml-1",children:t("email_address",d)}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{className:`w-full dark:bg-black/20 bg-slate-100/50 border ${m?"border-red-400 dark:border-red-500":"dark:border-white/10 border-slate-200"} rounded-2xl h-14 px-5 text-main placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-brand-30 transition-all font-medium`,placeholder:"name@example.com",type:"email",value:u,onChange:h=>{c(h.target.value),m&&y("")},onKeyDown:O,disabled:r,autoComplete:"email",autoFocus:!0}),e.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 flex items-center text-slate-400",children:e.jsx(Ct,{className:"w-5 h-5"})})]}),m&&e.jsx("p",{className:"text-red-500 text-xs font-medium ml-1 mt-1",children:m})]}),e.jsx("button",{onClick:P,disabled:r,className:"w-full h-14 bg-brand hover:bg-brand/90 text-white font-bold rounded-2xl shadow-xl shadow-brand flex items-center justify-center gap-2 transition-transform active:scale-[0.98] disabled:opacity-70 disabled:cursor-not-allowed",children:r?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("sending_code",d)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:t("continue",d)}),e.jsx(ke,{className:"w-5 h-5"})]})})]}),e.jsxs("div",{className:"mt-auto pb-8",children:[e.jsx("div",{className:"p-4 dark:bg-white/5 bg-slate-100/50 rounded-2xl mb-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(je,{className:"text-[#6DE8EC] w-5 h-5 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-[11px] text-muted leading-normal font-medium",children:t("security_notice",d)})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-2 opacity-50",children:[e.jsx(Ne,{className:"text-muted w-3 h-3"}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.2em] font-bold text-muted",children:t("e2e_encrypted",d)})]})]})]})};function X(a){const s=new Uint8Array(a);let n="";for(let o=0;o<s.byteLength;o++)n+=String.fromCharCode(s[o]);return btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ce(a){const s="=".repeat((4-a.length%4)%4),n=a.replace(/-/g,"+").replace(/_/g,"/")+s,o=atob(n),_=new Uint8Array(o.length);for(let d=0;d<o.length;d++)_[d]=o.charCodeAt(d);return _.buffer}function ue(){return!!(window.PublicKeyCredential&&typeof window.PublicKeyCredential=="function")}async function $e(){if(!ue())return!1;try{return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}catch{return!1}}function Mt(){const a=navigator.userAgent.toLowerCase();return/iphone|ipod|android.*mobile|windows phone|blackberry/i.test(a)?"mobile":/ipad|android(?!.*mobile)|tablet/i.test(a)?"tablet":"desktop"}function Ot(){return{platform:navigator.platform||"unknown",userAgent:navigator.userAgent,deviceType:Mt()}}function Vt(a){var s;return{...a,challenge:ce(a.challenge),user:{...a.user,id:ce(a.user.id)},excludeCredentials:(s=a.excludeCredentials)==null?void 0:s.map(n=>({...n,id:ce(n.id)}))}}function Lt(a){var s;return{...a,challenge:ce(a.challenge),allowCredentials:(s=a.allowCredentials)==null?void 0:s.map(n=>({...n,id:ce(n.id)}))}}function qt(a){const s=a.response;return{id:a.id,rawId:X(a.rawId),type:a.type,response:{clientDataJSON:X(s.clientDataJSON),attestationObject:X(s.attestationObject)},clientExtensionResults:a.getClientExtensionResults(),deviceInfo:Ot()}}function Ut(a){const s=a.response;return{id:a.id,rawId:X(a.rawId),type:a.type,response:{clientDataJSON:X(s.clientDataJSON),authenticatorData:X(s.authenticatorData),signature:X(s.signature),userHandle:s.userHandle?X(s.userHandle):null},clientExtensionResults:a.getClientExtensionResults()}}async function Ft(a){if(!ue())throw new Error("WebAuthn is not supported in this browser");const s=Vt(a),n=await navigator.credentials.create({publicKey:s});if(!n)throw new Error("Passkey creation was cancelled or failed");return qt(n)}async function $t(a){if(!ue())throw new Error("WebAuthn is not supported in this browser");const s=Lt(a),n=await navigator.credentials.get({publicKey:s});if(!n)throw new Error("Passkey authentication was cancelled or failed");return Ut(n)}const Bt=({email:a,onSuccess:s,onError:n,onFallbackToOTP:o,apiBaseUrl:_="https://apis.casperid.com",previewMode:d=!1,language:u="EN"})=>{const[c,r]=i.useState(!1),[l,m]=i.useState(""),[y,P]=i.useState(!0),[O,h]=i.useState(!1);i.useEffect(()=>{(async()=>{const N=ue(),R=await $e();P(N&&R),(!N||!R)&&m(t("webauthn_not_supported",u))})()},[u]),i.useEffect(()=>{if(y&&!O&&!d){h(!0);const f=setTimeout(()=>{b()},500);return()=>clearTimeout(f)}},[y,O,d]);const b=async()=>{if(!c){if(r(!0),m(""),d){setTimeout(()=>{r(!1),s("mock-session-token",{user_id:"mock-user-id",email:a,tier:"layer_1"})},1500);return}try{const f=await fetch(`${_}/api/passkey/auth/begin`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:a})});if(!f.ok){const T=await f.json().catch(()=>({}));throw new Error(T.error||"Failed to initialize authentication")}const N=await f.json();if(!N.success||!N.options)throw new Error(N.error||"Invalid authentication options");const R=await $t(N.options),j=await fetch(`${_}/api/passkey/auth/finish`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({email:a,credential:R})});if(!j.ok){const T=await j.json().catch(()=>({}));throw new Error(T.error||"Authentication failed")}const k=await j.json();if(k.success&&k.session_token)s(k.session_token,k.user,k.business_token);else throw new Error(k.error||"Authentication failed")}catch(f){const N=f instanceof Error?f.message:"Authentication failed";N.includes("cancelled")||N.includes("NotAllowedError")?m(t("passkey_cancelled",u)):(m(N),n==null||n(N))}finally{r(!1)}}};return e.jsxs(z.motion.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex-1 flex flex-col px-8 pt-12",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-3xl font-extrabold text-main tracking-tight leading-tight",children:t("welcome_back",u)}),e.jsx("p",{className:"text-muted mt-3 text-sm leading-relaxed",children:t("passkey_auth_subtitle",u)})]}),e.jsxs("div",{className:"mb-6 p-4 dark:bg-white/5 bg-slate-100/50 rounded-2xl",children:[e.jsx("p",{className:"text-xs text-muted mb-1",children:t("signing_in_as",u)}),e.jsx("p",{className:"text-main font-semibold",children:a})]}),e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-8",children:[e.jsx(z.motion.div,{animate:c?{scale:[1,1.1,1],opacity:[1,.7,1]}:{},transition:{duration:1.5,repeat:c?1/0:0,ease:"easeInOut"},className:`w-24 h-24 rounded-full flex items-center justify-center mb-6 ${c?"bg-brand/20 border-2 border-brand":l?"bg-red-500/10 border-2 border-red-400":"bg-brand/10 border-2 border-brand/30"}`,children:c?e.jsx(J,{className:"w-10 h-10 text-brand animate-spin"}):l?e.jsx(te,{className:"w-10 h-10 text-red-400"}):e.jsx(le,{className:"w-10 h-10 text-brand"})}),e.jsx("p",{className:"text-main font-semibold text-center mb-2",children:t(c?"authenticating":l?"authentication_failed":"use_passkey",u)}),l&&e.jsx("p",{className:"text-red-500 text-sm text-center mb-4 max-w-xs",children:l}),!c&&e.jsx("p",{className:"text-muted text-sm text-center max-w-xs",children:t("passkey_auth_hint",u)})]}),e.jsxs("div",{className:"space-y-3 pb-8",children:[!c&&e.jsx("button",{onClick:b,disabled:!y,className:"w-full h-14 bg-brand hover:bg-brand/90 text-white font-bold rounded-2xl shadow-xl shadow-brand/30 flex items-center justify-center gap-2 transition-transform active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed",children:l?e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"w-5 h-5"}),e.jsx("span",{children:t("try_again",u)})]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-5 h-5"}),e.jsx("span",{children:t("authenticate",u)})]})}),o&&e.jsx("button",{onClick:o,disabled:c,className:"w-full h-12 bg-transparent border dark:border-white/10 border-slate-200 text-muted hover:text-main font-medium rounded-2xl flex items-center justify-center gap-2 transition-colors disabled:opacity-50",children:t("use_email_instead",u)})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 pb-4 opacity-50",children:[e.jsx(oe,{className:"text-muted w-3 h-3"}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.2em] font-bold text-muted",children:t("biometric_secured",u)})]})]})},Ht=({email:a,sessionToken:s,onSuccess:n,onError:o,onSkip:_,apiBaseUrl:d="https://apis.casperid.com",previewMode:u=!1,language:c="EN"})=>{const[r,l]=i.useState(!1),[m,y]=i.useState(""),[P,O]=i.useState(!0),[h,b]=i.useState(!1);i.useEffect(()=>{(async()=>{const j=ue(),k=await $e();O(j&&k),(!j||!k)&&y(t("webauthn_not_supported",c))})()},[c]);const f=async()=>{if(!r){if(l(!0),y(""),u){setTimeout(()=>{l(!1),b(!0),setTimeout(()=>{n({user_id:"mock-user-id",email:a,tier:"layer_0"})},1e3)},1500);return}try{const R=await fetch(`${d}/api/passkey/register/begin`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},credentials:"include",body:JSON.stringify({email:a})});if(!R.ok){const A=await R.json().catch(()=>({}));throw new Error(A.error||"Failed to initialize registration")}const j=await R.json();if(!j.success||!j.options)throw new Error(j.error||"Invalid registration options");const k=await Ft(j.options),T=await fetch(`${d}/api/passkey/register/finish`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},credentials:"include",body:JSON.stringify({userId:j.userId,credential:k,deviceInfo:{userAgent:navigator.userAgent}})});if(!T.ok){const A=await T.json().catch(()=>({}));throw new Error(A.error||"Registration failed")}const I=await T.json();if(I.success)b(!0),setTimeout(()=>{n(I.user,I.business_token)},1e3);else throw new Error(I.error||"Registration failed")}catch(R){const j=R instanceof Error?R.message:"Registration failed";j.includes("cancelled")||j.includes("NotAllowedError")?y(t("passkey_cancelled",c)):(y(j),o==null||o(j))}finally{l(!1)}}},N=[{icon:Nt,text:t("passkey_benefit_1",c)},{icon:oe,text:t("passkey_benefit_2",c)},{icon:Ce,text:t("passkey_benefit_3",c)}];return e.jsxs(z.motion.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex-1 flex flex-col px-8 pt-12",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-3xl font-extrabold text-main tracking-tight leading-tight",children:t("create_passkey",c)}),e.jsx("p",{className:"text-muted mt-3 text-sm leading-relaxed",children:t("passkey_register_subtitle",c)})]}),e.jsxs("div",{className:"mb-6 p-4 dark:bg-white/5 bg-slate-100/50 rounded-2xl",children:[e.jsx("p",{className:"text-xs text-muted mb-1",children:t("signing_in_as",c)}),e.jsx("p",{className:"text-main font-semibold",children:a})]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("p",{className:"text-sm font-semibold text-main mb-4",children:t("passkey_benefits_title",c)}),e.jsx("div",{className:"space-y-3",children:N.map((R,j)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-brand/10 flex items-center justify-center",children:e.jsx(R.icon,{className:"w-5 h-5 text-brand"})}),e.jsx("span",{className:"text-sm text-muted",children:R.text})]},j))})]}),(r||h||m)&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-4",children:[e.jsx(z.motion.div,{animate:r?{scale:[1,1.1,1],opacity:[1,.7,1]}:{},transition:{duration:1.5,repeat:r?1/0:0,ease:"easeInOut"},className:`w-20 h-20 rounded-full flex items-center justify-center mb-4 ${h?"bg-green-500/20 border-2 border-green-400":r?"bg-brand/20 border-2 border-brand":"bg-red-500/10 border-2 border-red-400"}`,children:h?e.jsx(de,{className:"w-10 h-10 text-green-400"}):r?e.jsx(J,{className:"w-10 h-10 text-brand animate-spin"}):e.jsx(te,{className:"w-10 h-10 text-red-400"})}),e.jsx("p",{className:"text-main font-semibold text-center",children:t(h?"passkey_created":r?"creating_passkey":"passkey_create_failed",c)}),m&&e.jsx("p",{className:"text-red-500 text-sm text-center mt-2 max-w-xs",children:m})]}),e.jsxs("div",{className:"mt-auto space-y-3 pb-8",children:[!h&&e.jsx("button",{onClick:f,disabled:!P||r,className:"w-full h-14 bg-brand hover:bg-brand/90 text-white font-bold rounded-2xl shadow-xl shadow-brand/30 flex items-center justify-center gap-2 transition-transform active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed",children:r?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("creating_passkey",c)})]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-5 h-5"}),e.jsx("span",{children:t("register_passkey",c)})]})}),_&&!r&&!h&&e.jsx("button",{onClick:_,className:"w-full h-12 bg-transparent border dark:border-white/10 border-slate-200 text-muted hover:text-main font-medium rounded-2xl flex items-center justify-center transition-colors",children:t("do_this_later",c)})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 pb-4 opacity-50",children:[e.jsx(Ne,{className:"text-muted w-3 h-3"}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.2em] font-bold text-muted",children:t("e2e_encrypted",c)})]})]})},Be=({email:a,verificationId:s,onNext:n,onError:o,apiBaseUrl:_="https://apis.casperid.com",apiKey:d,previewMode:u=!1,language:c="EN"})=>{const[r,l]=i.useState(["","","","","",""]),[m,y]=i.useState(!1),[P,O]=i.useState(!1),[h,b]=i.useState(""),[f,N]=i.useState(0),[R,j]=i.useState(s);i.useEffect(()=>{if(f>0){const g=setTimeout(()=>N(f-1),1e3);return()=>clearTimeout(g)}},[f]),i.useEffect(()=>{r.every(g=>g!=="")&&!m&&I()},[r]);const k=i.useCallback(g=>{b(""),l(w=>{const v=[...w],S=v.findIndex(D=>D==="");return S!==-1&&(v[S]=g),v})},[]),T=i.useCallback(()=>{b(""),l(g=>{const w=[...g];for(let v=w.length-1;v>=0;v--)if(w[v]!==""){w[v]="";break}return w})},[]);i.useEffect(()=>{const g=w=>{m||(/^[0-9]$/.test(w.key)?(w.preventDefault(),k(w.key)):(w.key==="Backspace"||w.key==="Delete")&&(w.preventDefault(),T()))};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[m,k,T]);const I=async()=>{const g=r.join("");if(g.length!==6){b(t("error_pin_incomplete",c));return}if(y(!0),b(""),u){setTimeout(()=>{y(!1),n("mock-session-token",null)},1e3);return}try{const w=await fetch(`${_}/api/auth/verify-otp`,{method:"POST",headers:{"Content-Type":"application/json","X-App-ID":d||""},body:JSON.stringify({verificationId:R,otp:g})});if(!w.ok){const S=await w.json().catch(()=>({}));throw new Error(S.error||`Verification failed with status ${w.status}`)}const v=await w.json();v.success&&v.sessionToken?n(v.sessionToken,v.userAccount,v.business_token):(b(v.error||t("invalid_code",c)),v.attemptsLeft!==void 0&&b(t("invalid_code_attempts",c).replace("{attempts}",v.attemptsLeft.toString())),l(["","","","","",""]),o==null||o(v.error||t("verification_failed",c)))}catch{const v=t("error_verify_failed",c);b(v),l(["","","","","",""]),o==null||o(v)}finally{y(!1)}},A=async()=>{if(!(f>0||P)){if(O(!0),b(""),u){setTimeout(()=>{O(!1),N(60),l(["","","","","",""])},800);return}try{const g=await fetch(`${_}/api/auth/resend-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({verificationId:R})});if(!g.ok){const v=await g.json().catch(()=>({}));throw new Error(v.error||`Request failed with status ${g.status}`)}const w=await g.json();w.success?(N(60),l(["","","","","",""])):b(w.error||t("error_resend_failed",c))}catch{b(t("error_resend_failed",c))}finally{O(!1)}}},L=a.replace(/(.{2})(.*)(@.*)/,"$1***$3");return e.jsxs(z.motion.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.05},className:"flex-1 flex flex-col px-8 pt-12",children:[e.jsxs("div",{className:"space-y-2 mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight text-main",children:t("verify_email",c)}),e.jsxs("p",{className:"text-muted text-sm font-medium",children:[t("enter_code",c)," ",e.jsx("span",{className:"text-main font-semibold",children:L})]})]}),e.jsx("div",{className:"flex justify-between gap-2 mb-6",children:r.map((g,w)=>e.jsxs("div",{className:`size-12 rounded-2xl dark:bg-black/20 bg-slate-100/50 flex items-center justify-center text-xl font-bold border transition-all ${g?"text-brand dark:border-brand-30 border-brand-50":"text-muted dark:border-white/10 border-slate-200"} ${h?"border-red-400 dark:border-red-500":""}`,children:[g,!g&&r.findIndex(v=>v==="")===w&&e.jsx("div",{className:"w-0.5 h-6 bg-brand animate-pulse"})]},w))}),h&&e.jsx("p",{className:"text-red-500 text-xs font-medium text-center mb-4",children:h}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-8",children:[[1,2,3,4,5,6,7,8,9].map(g=>e.jsx("button",{onClick:()=>k(g.toString()),disabled:m,className:"h-14 rounded-2xl dark:hover:bg-white/5 hover:bg-slate-100 flex items-center justify-center text-xl font-bold transition-colors text-main disabled:opacity-50",children:g},g)),e.jsx("div",{className:"h-14"}),e.jsx("button",{onClick:()=>k("0"),disabled:m,className:"h-14 rounded-2xl dark:hover:bg-white/5 hover:bg-slate-100 flex items-center justify-center text-xl font-bold transition-colors text-main disabled:opacity-50",children:"0"}),e.jsx("button",{onClick:T,disabled:m,className:"h-14 rounded-2xl dark:hover:bg-white/5 hover:bg-slate-100 flex items-center justify-center transition-colors text-main disabled:opacity-50",children:e.jsx(kt,{className:"w-6 h-6"})})]}),e.jsxs("div",{className:"mt-auto pb-8 space-y-4",children:[e.jsx("button",{onClick:I,disabled:m||r.some(g=>g===""),className:"w-full h-14 bg-brand hover:bg-brand/90 text-white font-bold rounded-2xl transition-all shadow-lg shadow-brand flex items-center justify-center gap-2 group disabled:opacity-50 disabled:cursor-not-allowed",children:m?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("verifying",c)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:t("verify",c)}),e.jsx(ke,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})}),e.jsx("button",{onClick:A,disabled:f>0||P,className:"w-full h-14 dark:bg-white/5 hover:dark:bg-white/10 bg-slate-100 hover:bg-slate-200 text-muted font-bold rounded-2xl transition-all border dark:border-white/10 border-slate-200 flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:P?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:t("sending",c)})]}):f>0?e.jsxs("span",{children:[t("resend_code",c)," (",f,"s)"]}):e.jsxs(e.Fragment,{children:[e.jsx(he,{className:"w-4 h-4"}),e.jsx("span",{children:t("resend_code",c)})]})})]})]})},He=({onNext:a,onSkip:s,language:n="EN"})=>e.jsxs(z.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"p-6 pb-2",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-widest text-brand/80",children:t("verification_step",n)}),e.jsx("span",{className:"text-xs font-bold text-muted",children:t("kyc_required",n)})]}),e.jsx("div",{className:"w-full bg-brand/10 h-1.5 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand h-full rounded-full",style:{width:"40%"}})})]}),e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-8 text-center gap-8",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute inset-0 bg-cyan-400/20 blur-3xl rounded-full scale-75 group-hover:scale-100 transition-transform duration-500"}),e.jsx("div",{className:"relative w-32 h-32 rounded-full bg-gradient-to-tr from-brand-20 to-brand-5 flex items-center justify-center border border-brand-30 shadow-inner",children:e.jsx(je,{className:"w-16 h-16 text-brand"})}),e.jsx("div",{className:"absolute bottom-1 right-1 w-8 h-8 rounded-full dark:bg-[#171220] bg-white border-2 border-brand flex items-center justify-center",children:e.jsx(he,{className:"w-4 h-4 text-brand"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight text-main leading-tight",children:t("security_upgrade_required",n)}),e.jsx("p",{className:"text-muted text-base leading-relaxed font-medium",children:t("security_upgrade_desc",n)})]}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[e.jsx("span",{className:"px-3 py-1 bg-brand/10 rounded-xl text-[10px] font-bold text-brand uppercase tracking-tighter border border-brand-10",children:t("biometric_secure",n)}),e.jsx("span",{className:"px-3 py-1 bg-cyan-400/10 rounded-xl text-[10px] font-bold text-cyan-500 uppercase tracking-tighter border border-cyan-400/10",children:t("zero_knowledge",n)})]})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsx("button",{onClick:a,className:"w-full bg-brand hover:bg-brand/90 text-white rounded-2xl py-4 font-bold text-lg shadow-xl shadow-brand transition-all active:scale-[0.98]",children:t("start_upgrade",n)}),s&&e.jsx("button",{onClick:s,className:"w-full dark:text-slate-400 text-slate-500 text-sm font-bold dark:hover:text-slate-200 hover:text-slate-800 transition-colors",children:t("do_this_later",n)})]})]}),ae=["position_face","blink_slowly","turn_head_left","turn_head_right","processing"],Ke=({requestId:a,onNext:s,onError:n,apiBaseUrl:o="https://apis.casperid.com",previewMode:_=!1,language:d="EN"})=>{const u=i.useRef(null),c=i.useRef(null),r=i.useRef(null),l=i.useRef([]),[m,y]=i.useState(0),[P,O]=i.useState(!1),[h,b]=i.useState(""),[f,N]=i.useState(!1),[R,j]=i.useState(!1);i.useEffect(()=>((async()=>{try{const A=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:640,height:480}});r.current=A,u.current&&(u.current.srcObject=A,u.current.onloadedmetadata=()=>{O(!0)})}catch(A){A.name==="NotAllowedError"?(j(!0),b(t("camera_permission_denied",d))):b(t("unable_access_camera",d)),n==null||n("Camera access failed")}})(),()=>{r.current&&r.current.getTracks().forEach(A=>A.stop())}),[n]),i.useCallback(()=>{if(!u.current||!c.current)return null;const I=c.current,A=u.current,L=I.getContext("2d");return L?(I.width=A.videoWidth,I.height=A.videoHeight,L.drawImage(A,0,0),new Promise(g=>{I.toBlob(w=>g(w),"image/jpeg",.8)})):null},[]),i.useEffect(()=>{if(!P||f)return;const A=setTimeout(async()=>{const L=await new Promise(g=>{if(!u.current||!c.current){g(null);return}const w=c.current,v=u.current,S=w.getContext("2d");if(!S){g(null);return}w.width=v.videoWidth,w.height=v.videoHeight,S.drawImage(v,0,0),w.toBlob(D=>g(D),"image/jpeg",.8)});L&&l.current.push(L),m<ae.length-1?y(g=>g+1):k()},2500);return()=>clearTimeout(A)},[m,P,f]);const k=async()=>{var I;if(N(!0),y(4),_){setTimeout(()=>{N(!1),s(!0)},2e3);return}try{const A=new FormData;A.append("requestId",a),l.current.forEach((w,v)=>{A.append("imageFrames",w,`frame_${v}.jpg`)}),A.append("metadata",JSON.stringify({capturedAt:new Date().toISOString(),frameCount:l.current.length,instructions:ae.slice(0,-1)}));const L=await fetch(`${o}/api/v2/verification/liveness`,{method:"POST",body:A,credentials:"include"});if(!L.ok){const w=await L.json().catch(()=>({}));throw new Error(w.error||`Liveness check failed with status ${L.status}`)}const g=await L.json();g.success&&((I=g.liveness)!=null&&I.passed)?(r.current&&r.current.getTracks().forEach(w=>w.stop()),s(!0)):(b(g.error||"Liveness check failed. Please try again."),y(0),l.current=[],N(!1))}catch{b("Verification failed. Please try again."),y(0),l.current=[],N(!1),n==null||n("Liveness submission failed")}},T=()=>{b(""),y(0),l.current=[],N(!1)};return R?e.jsxs(z.motion.div,{initial:{opacity:0},animate:{opacity:1},className:"flex-1 flex flex-col items-center justify-center px-8 text-center",children:[e.jsx(te,{className:"w-16 h-16 text-red-500 mb-6"}),e.jsx("h2",{className:"text-xl font-bold text-main mb-3",children:"Camera Access Required"}),e.jsx("p",{className:"text-muted text-sm mb-6",children:"Please enable camera access in your browser settings to continue with face verification."}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-6 py-3 bg-brand text-white rounded-2xl font-bold",children:"Try Again"})]}):e.jsxs(z.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col relative dark:bg-[#050a0a] bg-slate-50 overflow-hidden",children:[e.jsx("canvas",{ref:c,className:"hidden"}),e.jsx("div",{className:"absolute inset-0 z-0",children:e.jsx("div",{className:"w-full h-full opacity-20 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-[#6fe8ec]/30 via-transparent to-transparent"})}),e.jsx("div",{className:"relative z-40 pt-12 pb-4 flex items-center justify-center",children:e.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 dark:bg-black/40 bg-white/40 backdrop-blur-md rounded-xl border dark:border-white/5 border-black/5",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${P?"bg-[#6fe8ec] shadow-[0_0_8px_#6fe8ec]":"bg-yellow-500 animate-pulse"}`}),e.jsx("span",{className:"text-[10px] text-muted uppercase tracking-[0.2em] font-bold",children:t(P?"live_camera":"initializing",d)})]})}),e.jsxs("div",{className:"relative z-20 flex-1 flex items-center justify-center",children:[e.jsx("div",{className:"absolute inset-0 z-10 dark:bg-[#050a0a]/80 bg-white/80 backdrop-blur-[2px]",style:{mask:"radial-gradient(ellipse 100px 145px at center, transparent 99%, black 100%)",WebkitMask:"radial-gradient(ellipse 100px 145px at center, transparent 99%, black 100%)"}}),e.jsxs("div",{className:"relative z-30 flex items-center justify-center",children:[e.jsxs("div",{className:"w-[200px] h-[290px] flex-shrink-0 rounded-full border-[3px] border-[#6fe8ec] shadow-[0_0_40px_rgba(111,232,236,0.4),inset_0_0_20px_rgba(111,232,236,0.2)] relative overflow-hidden",children:[e.jsx("video",{ref:u,autoPlay:!0,playsInline:!0,muted:!0,className:"absolute inset-0 w-full h-full object-cover scale-x-[-1]"}),e.jsx(z.motion.div,{animate:{opacity:[.4,1,.4]},transition:{duration:2,repeat:1/0},className:"absolute inset-0 rounded-full border-[1px] border-white/30"}),e.jsx(z.motion.div,{animate:{top:["-10%","110%"]},transition:{duration:3,repeat:1/0,ease:"easeInOut"},className:"absolute left-0 w-full h-[3px] bg-gradient-to-r from-transparent via-[#6fe8ec] to-transparent shadow-[0_0_20px_#6fe8ec] z-10"})]}),e.jsxs("div",{className:"absolute w-[280px] h-[380px] pointer-events-none flex items-center justify-center",children:[e.jsx("div",{className:"absolute top-0 left-0 w-10 h-10 border-t-2 border-l-2 border-[#6fe8ec]/30 rounded-tl-2xl"}),e.jsx("div",{className:"absolute top-0 right-0 w-10 h-10 border-t-2 border-r-2 border-[#6fe8ec]/30 rounded-tr-2xl"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-10 h-10 border-b-2 border-l-2 border-[#6fe8ec]/30 rounded-bl-2xl"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-10 h-10 border-b-2 border-r-2 border-[#6fe8ec]/30 rounded-br-2xl"})]})]})]}),e.jsxs("footer",{className:"relative z-40 p-8 flex flex-col items-center gap-6",children:[h?e.jsxs("div",{className:"dark:bg-red-900/30 bg-red-50 backdrop-blur-2xl border border-red-500/30 w-full p-6 rounded-[2.5rem] text-center",children:[e.jsx("p",{className:"text-red-500 font-bold text-lg mb-4",children:h}),e.jsx("button",{onClick:T,className:"px-6 py-2 bg-red-500 text-white rounded-xl font-bold",children:"Try Again"})]}):e.jsxs("div",{className:"dark:bg-[#0a1515]/95 bg-white/90 backdrop-blur-2xl border dark:border-white/10 border-black/5 w-full p-6 rounded-2xl text-center shadow-2xl",children:[e.jsx(z.AnimatePresence,{mode:"wait",children:e.jsx(z.motion.p,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},className:"text-[#6fe8ec] font-bold text-2xl tracking-tight mb-2",children:f?e.jsxs("span",{className:"flex items-center justify-center gap-3",children:[e.jsx(J,{className:"w-6 h-6 animate-spin"}),"Verifying..."]}):t(ae[m],d)},m)}),e.jsxs("div",{className:"flex items-center justify-center gap-2 text-muted text-[10px] font-bold uppercase tracking-widest",children:[e.jsx(Ne,{className:"w-3 h-3"}),t("secure_face_scan_desc",d)]})]}),e.jsx("div",{className:"flex gap-2 w-full max-w-[140px]",children:[0,1,2].map(I=>e.jsx("div",{className:`h-1.5 flex-1 rounded-full transition-all duration-700 ${I<=Math.floor(m/(ae.length-1)*2)?"bg-[#6fe8ec] shadow-[0_0_15px_#6fe8ec]":"dark:bg-slate-800 bg-slate-200"}`},I))}),e.jsxs("div",{className:"px-6 py-2.5 dark:bg-black/60 bg-white/60 backdrop-blur-md rounded-xl border dark:border-white/5 border-black/5 flex items-center gap-3",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${f?"bg-yellow-400 animate-pulse":m===ae.length-1?"bg-emerald-400 shadow-[0_0_10px_#34d399]":"bg-[#6fe8ec] animate-pulse"}`}),e.jsx("span",{className:"text-[10px] dark:text-slate-400 text-slate-600 uppercase tracking-[0.25em] font-black",children:f?t("analyzing_liveness",d):m===ae.length-1?t("calibration_complete",d):t("awaiting_calibration",d)})]})]})]})},Kt=[{id:"passport",title:"Passport",desc:"All countries supported",Icon:Le},{id:"drivers_license",title:"Driver License",desc:"Government issued card",Icon:Ve},{id:"national_id",title:"ID Card",desc:"National identity document",Icon:Ce}],We=({onNext:a,language:s="EN"})=>e.jsxs(z.motion.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex-1 px-6 pt-4 flex flex-col",children:[e.jsx("h3",{className:"text-2xl font-bold mb-2 text-main",children:t("verify_identity",s)}),e.jsx("p",{className:"text-muted text-sm mb-8 leading-relaxed",children:t("choose_document",s)}),e.jsxs("div",{className:"space-y-4 overflow-y-auto pr-1 pb-6",children:[Kt.map(({id:n,title:o,desc:_,Icon:d})=>e.jsxs("button",{onClick:()=>a(n),className:"w-full group cursor-pointer dark:bg-white/5 bg-slate-100/50 border dark:border-white/10 border-slate-200 rounded-2xl p-5 flex items-center gap-4 hover:dark:bg-brand/15 hover:bg-brand/5 hover:dark:border-brand-40 hover:border-brand-30 transition-all transform hover:-translate-y-1",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl dark:bg-slate-800/50 bg-white flex items-center justify-center text-brand group-hover:bg-brand/20 transition-colors border dark:border-transparent border-slate-100",children:e.jsx(d,{className:"w-8 h-8"})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("h4",{className:"font-bold text-base text-main",children:t(n,s)}),e.jsx("p",{className:"text-xs text-muted font-medium",children:t(`${n}_desc`,s)})]}),e.jsx(ge,{className:"text-brand w-5 h-5"})]},n)),e.jsxs("div",{className:"mt-8 relative h-32 w-full rounded-2xl overflow-hidden dark:bg-white/5 bg-slate-100/30 flex items-center justify-center border border-dashed dark:border-brand-30 border-brand-40",children:[e.jsx("div",{className:"absolute inset-0 opacity-10 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-brand via-transparent to-transparent"}),e.jsxs("div",{className:"text-center z-10",children:[e.jsx(oe,{className:"text-brand/40 w-10 h-10 mx-auto mb-1"}),e.jsx("p",{className:"text-[10px] text-muted uppercase tracking-tighter font-bold",children:"Encrypted E2E"})]})]})]})]}),Wt=a=>({passport:t("passport",a),drivers_license:t("drivers_license",a),national_id:t("national_id",a)}),Ge=({requestId:a,documentType:s,onNext:n,onError:o,apiBaseUrl:_="https://apis.casperid.com",previewMode:d=!1,language:u="EN"})=>{const c=i.useRef(null),r=i.useRef(null),l=i.useRef(null),[m,y]=i.useState(!1),[P,O]=i.useState(null),[h,b]=i.useState(null),[f,N]=i.useState(!1),[R,j]=i.useState(""),[k,T]=i.useState("front"),[I,A]=i.useState(null);i.useEffect(()=>((async()=>{try{const S=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment",width:{ideal:1280},height:{ideal:720}}});l.current=S,c.current&&(c.current.srcObject=S,c.current.onloadedmetadata=()=>{y(!0)})}catch{try{const D=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}}});l.current=D,c.current&&(c.current.srcObject=D,c.current.onloadedmetadata=()=>{y(!0)})}catch{j(t("unable_access_camera",u)),o==null||o("Camera access failed")}}})(),()=>{l.current&&l.current.getTracks().forEach(S=>S.stop()),h&&URL.revokeObjectURL(h)}),[o]);const L=async()=>{if(!c.current||!r.current)return;const v=r.current,S=c.current,D=v.getContext("2d");D&&(v.width=S.videoWidth,v.height=S.videoHeight,D.drawImage(S,0,0),v.toBlob(F=>{F&&(O(F),b(URL.createObjectURL(F)))},"image/jpeg",.9))},g=()=>{h&&URL.revokeObjectURL(h),O(null),b(null),j("")},w=async()=>{if(N(!0),d){setTimeout(()=>{N(!1),n({first_name:"JOHN",last_name:"DOE",date_of_birth:"01 JAN 1990",nationality:"Nigerian"},"mock-upload-id-789")},2e3);return}if(!P){N(!1);return}if(k==="front"&&s!=="passport"){A(P),O(null),b(null),T("back"),N(!1);return}N(!0),j("");try{const v=new FormData;v.append("document_type",s),I?(v.append("front_image",I,"front.jpg"),v.append("back_image",P,"back.jpg")):v.append("front_image",P,"document.jpg");const S=await fetch(`${_}/api/v2/verification/layer3/documents/upload`,{method:"POST",body:v,credentials:"include",headers:{"X-Request-Id":a}});if(!S.ok){const F=await S.json().catch(()=>({}));throw new Error(F.error||`Document upload failed with status ${S.status}`)}const D=await S.json();D.success&&D.extracted_data?(l.current&&l.current.getTracks().forEach(F=>F.stop()),n(D.extracted_data,D.upload_id||"")):(j(D.error||"Failed to process document. Please try again."),N(!1))}catch{j("Upload failed. Please try again."),N(!1),o==null||o("Document upload failed")}};return e.jsxs(z.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col relative",children:[e.jsx("canvas",{ref:r,className:"hidden"}),e.jsxs("div",{className:"absolute inset-0 z-0",children:[e.jsx("div",{className:"w-full h-full bg-slate-800 flex items-center justify-center",children:e.jsx("div",{className:"w-full h-full opacity-30 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-[#6DE8EC]/20 via-transparent to-transparent"})}),e.jsx("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-[2px]"})]}),e.jsx("div",{className:"relative z-10 p-6 flex flex-col items-center",children:e.jsx("div",{className:"text-center px-4 py-2 dark:bg-black/40 bg-white/40 backdrop-blur-xl rounded-full border dark:border-white/10 border-black/5",children:e.jsx("h3",{className:"text-main text-sm font-medium tracking-wide uppercase",children:t("scan_instruction",u).replace("{side}",t(k,u)).replace("{docType}",Wt(u)[s])})})}),e.jsx("div",{className:"relative z-10 flex-1 flex items-center justify-center px-6",children:e.jsxs("div",{className:"w-full aspect-[1.58/1] relative",children:[h?e.jsx("img",{src:h,alt:"Captured document",className:"absolute inset-0 w-full h-full object-cover rounded-2xl"}):e.jsx("video",{ref:c,autoPlay:!0,playsInline:!0,muted:!0,className:"absolute inset-0 w-full h-full object-cover rounded-2xl"}),e.jsx("div",{className:"absolute inset-0 border border-[#6DE8EC] rounded-2xl shadow-[0_0_20px_rgba(109,232,236,0.3),inset_0_0_15px_rgba(109,232,236,0.2)]"}),e.jsx("div",{className:"absolute top-0 left-0 w-8 h-8 border-t-4 border-l-4 border-[#6DE8EC] rounded-tl-2xl"}),e.jsx("div",{className:"absolute top-0 right-0 w-8 h-8 border-t-4 border-r-4 border-[#6DE8EC] rounded-tr-2xl"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-8 h-8 border-b-4 border-l-4 border-[#6DE8EC] rounded-bl-2xl"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-8 h-8 border-b-4 border-r-4 border-[#6DE8EC] rounded-br-2xl"}),!h&&m&&e.jsx(z.motion.div,{animate:{top:["0%","100%","0%"]},transition:{duration:4,repeat:1/0,ease:"linear"},className:"absolute left-0 w-full h-[2px] bg-gradient-to-r from-transparent via-[#6DE8EC] to-transparent opacity-50"}),!m&&!h&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 rounded-2xl",children:e.jsx(J,{className:"w-8 h-8 text-[#6DE8EC] animate-spin"})})]})}),R&&e.jsxs("div",{className:"relative z-10 mx-6 mb-4 p-4 bg-red-500/20 border border-red-500/30 rounded-xl flex items-center gap-3",children:[e.jsx(te,{className:"w-5 h-5 text-red-500 shrink-0"}),e.jsx("p",{className:"text-red-400 text-sm font-medium",children:R})]}),e.jsxs("div",{className:"relative z-10 p-8 dark:bg-black/60 bg-white/60 backdrop-blur-2xl border-t dark:border-white/10 border-black/5 rounded-t-3xl",children:[e.jsx("p",{className:"text-muted text-xs text-center mb-6 font-medium",children:t(h?"review_capture":"align_document",u)}),e.jsx("div",{className:"flex items-center justify-between gap-4",children:h?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:g,disabled:f,className:"w-12 h-12 rounded-xl dark:bg-white/5 bg-black/5 flex items-center justify-center text-muted disabled:opacity-50",children:e.jsx(At,{className:"w-6 h-6"})}),e.jsx("button",{onClick:w,disabled:f,className:"flex-1 bg-brand hover:bg-brand/90 text-white h-14 rounded-2xl flex items-center justify-center gap-2 font-bold text-lg transition-all active:scale-95 shadow-[0_0_25px_rgba(130,66,240,0.5)] disabled:opacity-70",children:f?e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-6 h-6 animate-spin"}),e.jsx("span",{children:t("processing",u)})]}):e.jsx("span",{children:t(k==="front"&&s!=="passport"?"next_back_side":"confirm",u)})}),e.jsx("div",{className:"w-12 h-12"})," "]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-12 h-12 rounded-xl dark:bg-white/5 bg-black/5 flex items-center justify-center text-muted",children:e.jsx(jt,{className:"w-6 h-6"})}),e.jsxs("button",{onClick:L,disabled:!m,className:"flex-1 bg-brand hover:bg-brand/90 text-white h-14 rounded-2xl flex items-center justify-center gap-2 font-bold text-lg transition-all active:scale-95 shadow-[0_0_25px_rgba(130,66,240,0.5)] disabled:opacity-50",children:[e.jsx(vt,{className:"w-6 h-6"}),e.jsx("span",{children:t("capture",u)})]}),e.jsx("button",{className:"w-12 h-12 rounded-xl dark:bg-white/5 bg-black/5 flex items-center justify-center text-muted",children:e.jsx(wt,{className:"w-6 h-6"})})]})}),e.jsx("div",{className:"w-32 h-1.5 bg-slate-600/30 rounded-full mx-auto mt-8"})]})]})},Ye=({requestId:a,documentType:s,extractedData:n,uploadId:o,onNext:_,onRetake:d,onError:u,apiBaseUrl:c="https://apis.casperid.com",previewMode:r=!1,language:l="EN"})=>{const[m,y]=i.useState({firstName:n.first_name||"",lastName:n.last_name||"",documentNumber:n.document_number||"",dateOfBirth:n.date_of_birth||"",nationality:n.nationality||"",gender:n.gender||""}),[P,O]=i.useState(!1),[h,b]=i.useState(""),f=(k,T)=>{y(I=>({...I,[k]:T}))},N=async()=>{if(!m.firstName||!m.lastName||!m.documentNumber){b(t("error_required_fields",l));return}if(O(!0),b(""),r){setTimeout(()=>{O(!1),_({first_name:m.firstName,last_name:m.lastName,document_number:m.documentNumber,date_of_birth:m.dateOfBirth,nationality:m.nationality,gender:m.gender,document_type:s})},1500);return}try{const k=await fetch(`${c}/api/v2/verification/layer3/submit`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({upload_id:o,liveness_verified:!0,document_data:{first_name:m.firstName,last_name:m.lastName,document_number:m.documentNumber,date_of_birth:m.dateOfBirth,nationality:m.nationality,gender:m.gender,document_type:s}})});if(!k.ok){const I=await k.json().catch(()=>({}));throw new Error(I.error||`Data submission failed with status ${k.status}`)}const T=await k.json();T.success?_({first_name:m.firstName,last_name:m.lastName,document_number:m.documentNumber,date_of_birth:m.dateOfBirth,nationality:m.nationality,gender:m.gender,document_type:s}):(b(T.error||"Failed to submit data. Please try again."),O(!1))}catch{b("Failed to submit data. Please try again."),O(!1),u==null||u("Data submission failed")}},R=n.confidence||0,j=Math.round(R*100);return e.jsxs(z.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"flex-1 overflow-y-auto px-6 pb-6",children:[e.jsx("div",{className:"flex gap-1 mb-6",children:[1,2,3,0].map((k,T)=>e.jsx("div",{className:`h-1 flex-1 rounded-xl ${k?"bg-brand":"bg-brand/20"}`},T))}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-main mb-2",children:t("review_data",l)}),e.jsx("p",{className:"text-muted text-sm leading-relaxed",children:t("verify_data_desc",l)})]}),R>0&&e.jsxs("div",{className:"mb-6 p-3 rounded-xl dark:bg-white/5 bg-black/5 border dark:border-white/10 border-black/5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs font-semibold text-muted",children:t("ocr_confidence",l)}),e.jsxs("span",{className:`text-xs font-bold ${j>=80?"text-green-500":j>=60?"text-yellow-500":"text-red-500"}`,children:[j,"%"]})]}),e.jsx("div",{className:"w-full h-1.5 dark:bg-white/10 bg-black/10 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${j>=80?"bg-green-500":j>=60?"bg-yellow-500":"bg-red-500"}`,style:{width:`${j}%`}})}),j<80&&e.jsx("p",{className:"text-[10px] text-yellow-500 mt-2",children:t("verify_data_carefully",l)})]}),h&&e.jsxs("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/30 rounded-xl flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4 text-red-500 shrink-0"}),e.jsx("p",{className:"text-red-400 text-xs font-medium",children:h})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-xs font-bold uppercase tracking-[0.15em] text-brand ml-1",children:t("full_name",l)}),e.jsxs("div",{className:"flex items-center px-1 transition-all",children:[e.jsx(Pt,{className:"text-brand mr-4 w-6 h-6 shrink-0"}),e.jsx("div",{className:"flex flex-col w-full",children:e.jsx("input",{className:"bg-transparent border-none p-0 w-full focus:ring-0 text-main font-bold text-lg focus:outline-none placeholder:text-slate-300",type:"text",value:`${m.firstName} ${m.lastName}`,onChange:k=>{const T=k.target.value.split(" ");f("firstName",T[0]||""),f("lastName",T.slice(1).join(" ")||"")},placeholder:t("enter_first_name",l)})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-xs font-bold uppercase tracking-[0.15em] text-brand ml-1",children:t("id_number",l)}),e.jsxs("div",{className:"flex items-center px-1 transition-all",children:[e.jsx(Ve,{className:"text-brand mr-4 w-6 h-6 shrink-0"}),e.jsx("input",{className:"bg-transparent border-none p-0 w-full focus:ring-0 text-main font-bold text-lg focus:outline-none placeholder:text-slate-300",type:"text",value:m.documentNumber,onChange:k=>f("documentNumber",k.target.value),placeholder:t("enter_doc_number",l)})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-xs font-bold uppercase tracking-[0.15em] text-brand ml-1",children:t("date_of_birth",l)}),e.jsxs("div",{className:"flex items-center px-1 transition-all",children:[e.jsx(gt,{className:"text-brand mr-4 w-6 h-6 shrink-0"}),e.jsx("input",{className:"bg-transparent border-none p-0 w-full focus:ring-0 text-main font-bold text-lg focus:outline-none placeholder:text-slate-300",type:"text",value:m.dateOfBirth,onChange:k=>f("dateOfBirth",k.target.value),placeholder:t("date_format",l)})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-xs font-bold uppercase tracking-[0.15em] text-brand ml-1",children:t("nationality",l)}),e.jsxs("div",{className:"flex items-center px-1 transition-all",children:[e.jsx(Le,{className:"text-brand mr-4 w-6 h-6 shrink-0"}),e.jsx("input",{className:"bg-transparent border-none p-0 w-full focus:ring-0 text-main font-bold text-lg focus:outline-none placeholder:text-slate-300",type:"text",value:m.nationality,onChange:k=>f("nationality",k.target.value),placeholder:t("enter_nationality",l)})]})]}),e.jsxs("div",{className:"mt-8 relative h-32 w-full rounded-2xl overflow-hidden border border-brand-20 group",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-tr from-brand-20 to-cyan-500/10 blur-sm"}),e.jsxs("div",{className:"absolute inset-0 bg-brand/10 flex flex-col items-center justify-center p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(de,{className:"text-brand w-5 h-5"}),e.jsx("span",{className:"text-xs font-bold dark:text-slate-200 text-slate-700",children:t("scanned_successfully",l)})]}),d&&e.jsx("button",{onClick:d,className:"mt-2 text-[10px] text-brand underline font-medium",type:"button",children:t("retake_photo",l)})]})]})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx("button",{onClick:N,disabled:P,className:"w-full bg-brand hover:bg-brand/90 text-white font-bold py-4 rounded-2xl shadow-lg shadow-brand flex items-center justify-center gap-2 transition-transform active:scale-95 disabled:opacity-70",children:P?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin"}),e.jsx("span",{children:t("submitting",l)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:t("confirm_mint",l)}),e.jsx(Dt,{className:"w-5 h-5"})]})}),e.jsx("p",{className:"text-center text-[10px] mt-4 text-slate-500",children:t("secured_by_casper",l)})]})]})},Gt=(a,s)=>a==="layer_1"?{processing:{title:t("generating_wallet",s),subtitle:t("wallet_subtitle",s)},minting:{title:t("minting_did",s),subtitle:t("did_subtitle",s)},completed:{title:t("identity_created",s),subtitle:t("identity_created_subtitle",s)},failed:{title:t("setup_failed",s),subtitle:t("setup_failed_subtitle",s)}}:{processing:{title:t(a==="layer_2"?"processing_liveness":"processing_documents",s),subtitle:t("processing_subtitle",s)},minting:{title:t("minting_identity",s),subtitle:t("minting_subtitle",s)},completed:{title:t("verification_submitted",s),subtitle:t("verification_submitted_subtitle",s)},failed:{title:t("verification_failed",s),subtitle:t("verification_failed_subtitle",s)}},Je=({tier:a,sessionToken:s,requestId:n,onNext:o,onError:_,apiBaseUrl:d="https://apis.casperid.com",previewMode:u=!1,language:c="EN"})=>{const[r,l]=i.useState("processing"),[m,y]=i.useState(0),[P,O]=i.useState(""),[h,b]=i.useState(null),[f,N]=i.useState(null),[R,j]=i.useState(null),[k,T]=i.useState(null),I=i.useRef(!1),L=Gt(a,c)[r];i.useEffect(()=>{I.current||(I.current=!0,u?g():w())},[]);const g=async()=>{l("processing"),y(20),await D(1e3),y(50),await D(1e3),l("minting"),y(70),await D(1e3),y(100),l("completed"),a==="layer_1"?(b("account-hash-abc123..."),T("casper-user-1234"),N("did:casper:abc123...")):j("mock-credential-hash-xyz"),await D(1500),o({wallet:"account-hash-abc123...",didAddress:"did:casper:abc123...",credentialHash:"mock-credential-hash-xyz"})},w=async()=>{try{a==="layer_1"?await v():await S()}catch(B){const q=B instanceof Error?B.message:"Setup failed";O(q),l("failed"),_==null||_(q)}},v=async()=>{var Y;l("processing"),y(10);const B=await fetch(`${d}/api/passkey/wallet/generate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},credentials:"include"});if(!B.ok){const $=await B.json().catch(()=>({}));throw new Error($.error||"Failed to generate wallet")}const q=await B.json();if(!q.success||!((Y=q.walletInfo)!=null&&Y.walletAddress))throw new Error(q.error||"Wallet generation failed");b(q.walletInfo.walletAddress),q.walletInfo.humanId&&T(q.walletInfo.humanId),y(50),l("minting"),y(60);const H=await fetch(`${d}/api/passkey/did/mint`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`},credentials:"include"});if(!H.ok){const $=await H.json().catch(()=>({}));throw new Error($.error||"Failed to mint DID")}const K=await H.json();if(!K.success)throw new Error(K.error||"DID minting failed");N(K.did_address),j(K.transaction_hash),y(100),l("completed"),await D(1500),o({wallet:q.walletInfo.walletAddress,didAddress:K.did_address,credentialHash:K.transaction_hash})},S=async()=>{l("processing"),y(30),await D(500),y(60),l("minting"),y(80),await D(500),y(100),l("completed"),await D(1500),o({credentialHash:n})},D=B=>new Promise(q=>setTimeout(q,B)),F=()=>{l("processing"),y(0),O(""),I.current=!1,u?g():w()},G=()=>a==="layer_1"?r==="minting"?e.jsx(le,{className:"text-brand w-4 h-4"}):e.jsx(Tt,{className:"text-brand w-4 h-4"}):e.jsx(qe,{className:"text-brand w-4 h-4"}),ie=()=>{if(a==="layer_1"){if(r==="processing")return t("creating_wallet",c);if(r==="minting")return t("minting_did_chain",c);if(r==="completed")return t("identity_live",c)}else{if(r==="processing")return t("validating_docs",c);if(r==="minting")return t("submitting_verification",c);if(r==="completed")return t("verification_queued",c)}return""};return e.jsxs(z.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col items-center justify-center px-8 text-center",children:[e.jsxs("div",{className:"relative w-64 h-64 flex items-center justify-center mb-12",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-4 border-dashed border-brand-20 animate-[spin_10s_linear_infinite]"}),e.jsx("div",{className:"absolute inset-4 rounded-full border-2 border-[#6DE8EC]/20 animate-[spin_6s_linear_infinite_reverse]"}),e.jsxs(z.motion.div,{animate:r!=="failed"?{rotateY:[0,180,360],y:[-10,10,-10]}:{},transition:{duration:6,repeat:1/0,ease:"easeInOut"},className:`relative w-40 h-56 backdrop-blur-xl border rounded-2xl flex flex-col p-4 ${r==="completed"?"bg-green-500/10 border-green-500/30 shadow-[0_0_50px_-12px_rgba(34,197,94,0.5)]":r==="failed"?"bg-red-500/10 border-red-500/30 shadow-[0_0_50px_-12px_rgba(239,68,68,0.5)]":"bg-brand/10 border-brand-30 shadow-[0_0_50px_-12px_rgba(114,43,238,0.5)]"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-6",children:[e.jsx("div",{className:`w-8 h-8 rounded flex items-center justify-center ${r==="completed"?"bg-green-500/30":r==="failed"?"bg-red-500/30":"bg-brand/30"}`,children:r==="completed"?e.jsx(de,{className:"text-green-500 w-4 h-4"}):r==="failed"?e.jsx(te,{className:"text-red-500 w-4 h-4"}):G()}),e.jsx("div",{className:`w-6 h-1 rounded-full ${r==="completed"?"bg-green-500/40":r==="failed"?"bg-red-500/40":"bg-brand/40"}`})]}),e.jsxs("div",{className:"space-y-3 mb-auto",children:[e.jsx("div",{className:`h-2 w-3/4 rounded-full ${r==="completed"?"bg-green-500/20":r==="failed"?"bg-red-500/20":"bg-brand/20"}`}),e.jsx("div",{className:`h-2 w-1/2 rounded-full ${r==="completed"?"bg-green-500/20":r==="failed"?"bg-red-500/20":"bg-brand/20"}`})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-4",children:[e.jsx("div",{className:`size-6 rounded-full overflow-hidden border border-white/10 ${r==="completed"?"bg-gradient-to-tr from-green-500 to-[#6DE8EC]":r==="failed"?"bg-gradient-to-tr from-red-500 to-orange-500":"bg-gradient-to-tr from-brand to-[#6DE8EC]"}`}),e.jsxs("div",{className:"flex flex-col items-start max-w-[80px]",children:[k?e.jsx(z.motion.span,{initial:{opacity:0},animate:{opacity:1},className:"text-[10px] font-bold text-white/90 truncate w-full text-left",children:k}):e.jsx("div",{className:"h-1.5 w-12 bg-white/20 rounded-full mb-1"}),e.jsx("div",{className:"h-1 w-8 bg-white/10 rounded-full"})]})]}),r!=="failed"&&r!=="completed"&&e.jsx(z.motion.div,{animate:{top:["0%","100%","0%"]},transition:{duration:2,repeat:1/0},className:"absolute inset-0 bg-gradient-to-b from-transparent via-brand-10 to-transparent h-1/2 w-full"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:`text-2xl font-bold bg-clip-text ${r==="completed"?"text-green-500":r==="failed"?"text-red-500":"dark:bg-gradient-to-r dark:from-slate-100 dark:to-slate-400 bg-slate-900 dark:text-transparent text-slate-900"}`,children:L.title}),e.jsx("p",{className:"dark:text-slate-400 text-slate-500 text-sm leading-relaxed max-w-[280px] mx-auto",children:L.subtitle})]}),r==="failed"&&e.jsxs("div",{className:"mt-6 space-y-3",children:[e.jsx("p",{className:"text-red-500 text-sm",children:P}),e.jsx("button",{onClick:F,className:"px-6 py-3 bg-brand text-white rounded-2xl font-bold",children:t("try_again",c)})]}),a==="layer_1"&&h&&r==="completed"&&e.jsxs("div",{className:"mt-6 p-3 dark:bg-white/5 bg-black/5 rounded-xl border dark:border-white/10 border-black/5",children:[e.jsx("p",{className:"text-[10px] text-muted mb-1",children:t("your_wallet",c)}),e.jsxs("p",{className:"text-xs font-mono text-main break-all",children:[h.slice(0,20),"...",h.slice(-10)]})]}),a!=="layer_1"&&R&&r==="completed"&&e.jsxs("div",{className:"mt-6 p-3 dark:bg-white/5 bg-black/5 rounded-xl border dark:border-white/10 border-black/5",children:[e.jsx("p",{className:"text-[10px] text-muted mb-1",children:t("verification_id",c)}),e.jsxs("p",{className:"text-xs font-mono text-main break-all",children:[R.slice(0,20),"..."]})]}),r!=="failed"&&e.jsxs("div",{className:"w-full mt-12 p-6 dark:bg-brand/5 bg-brand/5 border-t dark:border-white/5 border-black/5",children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsx("span",{className:"text-xs font-medium text-brand uppercase tracking-widest",children:t(a==="layer_1"?"setup_status":"transaction_status",c)}),e.jsx("span",{className:`text-xs font-bold ${r==="completed"?"text-green-500":"text-[#6DE8EC]"}`,children:t("complete_percent",c).replace("{percent}",m.toString())})]}),e.jsx("div",{className:"w-full h-1.5 dark:bg-brand/10 bg-brand/10 rounded-full overflow-hidden mb-4",children:e.jsx(z.motion.div,{initial:{width:"0%"},animate:{width:`${m}%`},transition:{duration:.5},className:`h-full rounded-full ${r==="completed"?"bg-gradient-to-r from-green-500 to-[#6DE8EC]":"bg-gradient-to-r from-brand to-[#6DE8EC]"} shadow-[0_0_10px_rgba(114,43,238,0.5)]`})}),e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 dark:bg-brand/10 bg-brand/10 rounded-xl border dark:border-brand-10 border-brand-5",children:[e.jsx(St,{className:`w-4 h-4 ${r==="completed"?"text-green-500":"text-brand"}`}),e.jsx("p",{className:"text-[10px] dark:text-slate-300 text-slate-600 font-medium",children:ie()})]})]})]})},Ze=({onNext:a,language:s="EN"})=>e.jsxs(z.motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.1},className:"flex-1 flex flex-col items-center justify-center px-8 text-center",children:[e.jsxs("div",{className:"relative mb-10 group",children:[e.jsx("div",{className:"absolute inset-0 bg-[#6fe8ec]/30 rounded-3xl blur-3xl group-hover:blur-2xl transition-all"}),e.jsx("div",{className:"relative w-32 h-32 rounded-2xl bg-[#6fe8ec] flex items-center justify-center shadow-[0_0_40px_rgba(111,232,236,0.4)] border-4 dark:border-white border-slate-100",children:e.jsx(de,{className:"text-slate-900 w-16 h-16"})})]}),e.jsx("h1",{className:"text-main text-3xl font-bold leading-tight mb-3",children:t("identity_verified",s)}),e.jsx("p",{className:"text-muted text-base leading-relaxed mb-12",children:t("identity_verified_desc",s)}),e.jsxs("div",{className:"w-full dark:bg-white/5 bg-black/5 rounded-2xl p-5 mb-8 flex items-center justify-between text-left",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-main font-bold text-sm",children:t("share_data_consent",s)}),e.jsx("p",{className:"text-muted text-xs leading-normal",children:t("authorize_dapps",s)})]}),e.jsx("div",{className:"w-11 h-6 bg-brand rounded-full relative p-1 cursor-pointer",children:e.jsx("div",{className:"absolute right-1 top-1 size-4 bg-white rounded-full"})})]}),e.jsxs("button",{onClick:a,className:"w-full bg-[#6fe8ec] hover:brightness-105 active:scale-[0.98] transition-all text-slate-900 font-bold py-4 rounded-2xl shadow-lg shadow-[#6fe8ec]/20 flex items-center justify-center gap-2",children:[t("return_to_app",s),e.jsx(ke,{className:"w-5 h-5"})]})]}),Yt=["perm_identity","perm_profile","perm_kyc"],Qe=({appName:a="This App",appLogo:s,onApprove:n,onDeny:o,language:_="EN"})=>e.jsxs(z.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"flex-1 px-8 pt-8 flex flex-col items-center",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4 mb-10",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 rounded-full shadow-[0_0_20px_rgba(134,81,225,0.3)] animate-pulse"}),e.jsx("div",{className:"relative w-24 h-24 rounded-full border-2 border-brand-40 p-1 dark:bg-black/50 bg-white",children:s?e.jsx("div",{className:"w-full h-full rounded-full overflow-hidden",children:e.jsx("img",{src:s,alt:a,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"w-full h-full rounded-full bg-gradient-to-br from-emerald-500 to-teal-700 flex items-center justify-center text-white font-bold text-2xl",children:a.slice(0,2).toUpperCase()})})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight text-main",children:a}),e.jsx("p",{className:"text-brand/70 text-sm font-medium mt-1 uppercase tracking-wider",children:t("requesting_access",_)})]})]}),e.jsxs("div",{className:"w-full space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-widest text-slate-500 mb-4 px-1",children:t("permission_request",_)}),Yt.map(d=>e.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-2xl dark:bg-white/5 bg-black/5 transition-all",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-cyan-400/10 text-cyan-400 shrink-0",children:e.jsx(de,{className:"w-5 h-5"})}),e.jsx("p",{className:"text-sm font-medium text-main",children:t(d,_)})]},d))]}),e.jsxs("div",{className:"mt-8 flex gap-3 p-4 rounded-2xl dark:bg-brand/5 bg-brand/5",children:[e.jsx(oe,{className:"text-brand w-5 h-5 shrink-0"}),e.jsxs("p",{className:"text-xs leading-relaxed text-muted",children:[e.jsxs("span",{className:"font-bold text-main",children:[t("privacy_note",_),":"]})," ",t("privacy_desc",_)]})]}),e.jsxs("footer",{className:"mt-auto w-full pb-8 flex flex-col gap-3",children:[e.jsxs("button",{onClick:n,className:"w-full py-4 rounded-2xl bg-brand hover:bg-brand-90 text-white font-bold text-base shadow-xl shadow-brand transition-all flex items-center justify-center gap-2",children:[t("approve_verify",_),e.jsx(je,{className:"w-5 h-5"})]}),e.jsx("button",{onClick:o,className:"w-full py-3 rounded-2xl bg-transparent dark:hover:bg-white/5 hover:bg-black/5 dark:text-slate-400 text-slate-500 font-semibold text-sm transition-all",children:t("deny",_)})]})]});function Te(a="light"){return a==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a}const ze=["AuthSelection","Login","PasskeyAuth","PinVerification","PasskeyRegister"],Jt="https://apis.casperid.com",Me={requestId:"",verificationTier:"layer_3"},Xe=({isOpen:a,apiKey:s,theme:n={},requiredTier:o,onSuccess:_,onClose:d,onError:u,mode:c="login",previewMode:r=!1,initialScreen:l,apiBaseUrl:m,termsUrl:y="#",privacyUrl:P="#",logoUrl:O,language:h="EN",layout:b})=>{var Pe;const[f,N]=i.useState({}),[R,j]=i.useState(!r&&!!s),{primaryColor:k,borderRadius:T,fontFamily:I,mode:A="light",layout:L}=n,g=k||f.primaryColor||"#8651e1",w=T||f.borderRadius||"12",v=I||f.fontFamily||"Inter",S=b||L||f.layout||"auto",[D,F]=i.useState(Te(A)),[G,ie]=i.useState(l??(c==="verify"?"SecurityUpgrade":"AuthSelection")),[B,q]=i.useState({email:"",verificationId:""}),[H,K]=i.useState(null),[Y,$]=i.useState({email:"",userExists:!1,hasPasskey:!1,userAccount:null}),[Z,ee]=i.useState(Me),[tt,fe]=i.useState(""),[Xt,Ie]=i.useState(""),[se,st]=i.useState(null),W=m||Jt,xe=w.toString().endsWith("px")?w.toString():`${w}px`,be=v.includes(" ")?`"${v}", sans-serif`:`${v}, sans-serif`,re=i.useId().replace(/:/g,""),Se={"--casperid-primary":g,"--casperid-radius":xe,"--casperid-font":be},Ee=`${re}-${g}-${xe}-${be}`,Ae=`
172
- #casperid-modal-${re},
173
- #casperid-modal-${re} * {
174
- --casperid-primary: ${g} !important;
175
- --casperid-radius: ${xe} !important;
176
- --casperid-font: ${be} !important;
171
+ */const Ot=z("X",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]),Pe=({onClose:i,title:s="CasperID",subtitle:r="SECURE SDK",showClose:l=!0,theme:k,toggleTheme:f,logoUrl:p})=>e.jsxs("header",{className:"flex items-center justify-between px-6 pt-8 pb-4 relative z-20",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 bg-brand rounded-xl flex items-center justify-center shadow-brand",children:p?e.jsx("img",{src:p,alt:s,className:"w-5 h-5 object-contain"}):e.jsx(Ye,{className:"text-white w-5 h-5"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-bold tracking-tight text-main",children:s}),r&&e.jsx("p",{className:"text-[10px] uppercase tracking-widest text-brand font-bold",children:r})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:f,className:"p-2 dark:hover:bg-slate-200 dark:bg-white/10 hover:bg-slate-200/50 rounded-xl transition-colors text-muted","aria-label":"Toggle theme",children:k==="dark"?e.jsx(Mt,{className:"w-5 h-5"}):e.jsx(Dt,{className:"w-5 h-5"})}),l&&e.jsx("button",{onClick:i,className:"p-2 dark:hover:bg-slate-200 dark:bg-white/10 hover:bg-slate-200/50 rounded-full transition-colors text-muted","aria-label":"Close",children:e.jsx(Ot,{className:"w-5 h-5"})})]})]}),Te=({children:i})=>e.jsx("footer",{className:"p-8 text-center relative z-20",children:i}),Ae={EN:{welcome_back:"Welcome back",enter_email:"Enter your email to receive a verification code.",email_address:"Email Address",continue:"Continue",sending_code:"Sending Code...",verify_email:"Verify Email",enter_code:"Enter the 6-digit code sent to",verification_failed:"Verification Failed",verifying:"Verifying...",resend_code:"Resend Code",resend_in:"Resend in",secure_sdk:"SECURE SDK",permission_request:"PERMISSION REQUEST",review_data:"Review Data",mint_identity:"Mint Identity",face_scan:"Face Scan",document_scan:"Document Scan",verification_step:"VERIFICATION STEP",kyc_required:"KYC REQUIRED",security_upgrade_required:"Security Upgrade Required",security_upgrade_desc:"Your account requires a biometric security upgrade to perform this action.",biometric_secure:"BIOMETRIC SECURE",zero_knowledge:"ZERO KNOWLEDGE",start_upgrade:"Start Upgrade",do_this_later:"I'll do this later",sign_in_with_extension:"Sign in with Extension",sign_in_with_otp:"Sign in with OTP",extension_detected:"Extension Detected",secure_wallet:"Secure Wallet",fully_audited:"FULLY AUDITED",non_custodial:"NON-CUSTODIAL",verify_identity:"Verify Your Identity",choose_document:"Choose a document type to begin verification.",passport:"Passport",drivers_license:"Driver License",national_id:"ID Card",passport_desc:"All countries supported",drivers_license_desc:"Government issued card",national_id_desc:"National identity document",position_face:"Position your face in the frame",blink_slowly:"Blink slowly",turn_head_left:"Turn your head slowly to the left",turn_head_right:"Turn your head slowly to the right",processing:"Processing...",camera_permission_denied:"Camera permission denied",unable_access_camera:"Unable to access camera",live_camera:"LIVE CAMERA",initializing:"INITIALIZING",processing_verification:"Processing Verification...",processing_liveness:"Verifying Liveness...",processing_documents:"Processing Documents...",processing_subtitle:"Validating your documents and biometrics",minting_identity:"Minting your Identity...",minting_subtitle:"Securing your decentralized identity on the Casper Network",identity_minted:"Identity Minted!",minted_subtitle:"Your CasperID has been successfully created",verification_failed_subtitle:"There was an issue with your verification",try_again:"Try Again",credential_hash:"Credential Hash",identity_verified:"Identity Verified",identity_verified_subtitle:"Your liveness check passed. You are now verified.",identity_verified_desc:"Your CasperID has been successfully authenticated on the Casper blockchain. You're ready to go.",submitting_for_review:"Submitting for Review...",submitting_review_subtitle:"Your documents are being prepared for verification",verification_submitted:"Verification Submitted",verification_submitted_subtitle:"Your documents are under review. You'll be notified once verified.",share_data_consent:"Share Data Consent",authorize_dapps:"Authorize dApps to access your credentials",return_to_app:"Return to App",verify_data_desc:"Verify your extracted identity information. This data will be used to mint your CasperID.",ocr_confidence:"OCR Confidence",first_name:"First Name",last_name:"Last Name",document_number:"Document Number",date_of_birth:"Date of Birth",nationality:"Nationality",enter_first_name:"Enter first name",enter_last_name:"Enter last name",enter_nationality:"Enter nationality",scanned_successfully:"Scanned Successfully",secured_by_casper:"Secured by CasperID Protocol.",confirm_mint:"Confirm & Mint",submitting:"Submitting...",retake_photo:"Retake Photo",auth_subtitle:"Secure your Web3 identity with our premium authentication layer.",extension_connect_msg:"Click the CasperID extension icon in your browser to connect.",extension_not_detected:"CasperID extension not detected. Please install the extension or use OTP sign-in.",connecting:"Connecting...",two_factor_auth:"Two-Factor Auth",security_notice:"Your data is encrypted and never stored on central servers. Powered by Casper Network.",e2e_encrypted:"End-to-End Encrypted",error_email_required:"Please enter your email",error_invalid_email:"Please enter a valid email address",error_passkey_registered:"You have a passkey registered. Please use extension sign-in.",error_send_code_failed:"Failed to send verification code. Please try again.",error_connection_failed:"Unable to connect. Please check your internet connection.",verify_code:"Verification Code",code_expired:"Code expired",invalid_code:"Invalid code",error_pin_incomplete:"Please enter all 6 digits",verify:"Verify",invalid_code_attempts:"Invalid code. {attempts} attempts remaining.",awaiting_calibration:"Awaiting Calibration",transaction_status:"Transaction Status",complete_percent:"{percent}% Complete",validating_docs:"Validating documents...",broadcasting_tx:"Broadcasting to Casper Mainnet Node...",tx_confirmed:"Transaction confirmed on Casper Network",scan_instruction:"Scan {side} of your {docType}",review_capture:"Review your capture. Ensure all text is clearly visible.",align_document:"Align your document within the glowing frame. Ensure all four corners are visible.",next_back_side:"Next: Back Side",confirm:"Confirm",capture:"Capture",verify_data_carefully:"Please verify the extracted data carefully.",enter_doc_number:"Enter document number",date_format:"DD/MM/YYYY",error_required_fields:"Please fill in all required fields.",front:"front",back:"back",requesting_access:"Requesting Access",privacy_note:"Privacy Note",privacy_desc:"Only cryptographic proofs are shared. No private keys are ever exposed.",approve_verify:"Approve & Verify",deny:"Deny",perm_identity:"Verify Identity Status",perm_profile:"Read Public Profile",perm_kyc:"Share KYC Level","verify:identity":"Verify Identity Status","read:profile":"Read Public Profile","read:kyc_level":"Share KYC Level","read:email":"Access Email Address","read:wallet":"View Wallet Address",full_name:"FULL NAME",id_number:"ID NUMBER",passkey_auth_subtitle:"Use your passkey to sign in securely.",signing_in_as:"Signing in as",use_passkey:"Use Your Passkey",authenticating:"Authenticating...",authentication_failed:"Authentication Failed",passkey_auth_hint:"Touch ID, Face ID, or security key",passkey_cancelled:"Authentication was cancelled. Try again when ready.",authenticate:"Authenticate",use_email_instead:"Use email code instead",biometric_secured:"Biometric Secured",webauthn_not_supported:"Your browser doesn't support passkeys. Please use email verification.",create_passkey:"Create Your Passkey",passkey_register_subtitle:"Set up biometric authentication for secure, passwordless sign-in.",passkey_benefits_title:"Why use a passkey?",passkey_benefit_1:"No passwords to remember",passkey_benefit_2:"Phishing-resistant security",passkey_benefit_3:"Works across your devices",register_passkey:"Create Passkey",creating_passkey:"Creating passkey...",passkey_created:"Passkey created successfully!",passkey_create_failed:"Failed to create passkey",l1_setup_title:"Setting Up Your Identity",l1_setup_subtitle:"Creating your secure wallet and decentralized identity.",generating_wallet:"Generating secure wallet...",minting_did:"Minting your DID...",l1_complete:"Identity setup complete!",l1_failed:"Setup failed. Please try again.",facial_verification:"Facial Verification",secure_face_scan_desc:"Secure Face Scan • Encrypted",analyzing_liveness:"Analyzing Liveness",calibration_complete:"Calibration Complete"},ES:{welcome_back:"Bienvenido de nuevo",enter_email:"Ingrese su correo para recibir un código.",email_address:"Correo electrónico",continue:"Continuar",sending_code:"Enviando código...",verify_email:"Verificar correo",enter_code:"Ingrese el código de 6 dígitos enviado a",verification_failed:"Error de verificación",verifying:"Verificando...",resend_code:"Reenviar código",resend_in:"Reenviar en",secure_sdk:"SDK SEGURO",permission_request:"SOLICITUD DE PERMISO",review_data:"Revisar datos",mint_identity:"Mint Identidad",face_scan:"Escaneo facial",document_scan:"Escaneo de documentos",verification_step:"PASO DE VERIFICACIÓN",kyc_required:"KYC REQUERIDO",security_upgrade_required:"Actualización de Seguridad Requerida",security_upgrade_desc:"Su cuenta requiere una actualización de seguridad biométrica para esta acción.",biometric_secure:"BIOMÉTRICO SEGURO",zero_knowledge:"CONOCIMIENTO CERO",start_upgrade:"Iniciar actualización",do_this_later:"Lo haré más tarde",sign_in_with_extension:"Iniciar sesión con extensión",sign_in_with_otp:"Iniciar sesión con OTP",extension_detected:"Extensión detectada",secure_wallet:"Billetera segura",fully_audited:"TOTALMENTE AUDITADO",non_custodial:"SIN CUSTODIA",verify_identity:"Verifique su identidad",choose_document:"Elija un tipo de documento para comenzar.",passport:"Pasaporte",drivers_license:"Licencia de conducir",national_id:"DNI / Cédula",passport_desc:"Todos los países soportados",drivers_license_desc:"Tarjeta emitida por el gobierno",national_id_desc:"Documento nacional de identidad",position_face:"Coloque su cara en el marco",blink_slowly:"Parpadee lentamente",turn_head_left:"Gire la cabeza hacia la izquierda",turn_head_right:"Gire la cabeza hacia la derecha",processing:"Procesando...",camera_permission_denied:"Permiso de cámara denegado",unable_access_camera:"No se puede acceder a la cámara",live_camera:"CÁMARA EN VIVO",initializing:"INICIALIZANDO",processing_verification:"Procesando verificación...",processing_liveness:"Verificando vivacidad...",processing_documents:"Procesando documentos...",processing_subtitle:"Validando sus documentos y biometría",minting_identity:"Minting identidad...",minting_subtitle:"Asegurando su identidad descentralizada en Casper Network",identity_minted:"¡Identidad Minted!",minted_subtitle:"Su CasperID ha sido creado con éxito",verification_failed_subtitle:"Hubo un problema con su verificación",try_again:"Intentar de nuevo",credential_hash:"Hash de credencial",identity_verified:"Identidad verificada",identity_verified_subtitle:"Su verificación de vida fue exitosa. Ahora está verificado.",identity_verified_desc:"Su CasperID ha sido autenticado con éxito en la cadena de bloques Casper.",submitting_for_review:"Enviando para revisión...",submitting_review_subtitle:"Sus documentos están siendo preparados para verificación",verification_submitted:"Verificación Enviada",verification_submitted_subtitle:"Sus documentos están en revisión. Le notificaremos una vez verificado.",share_data_consent:"Consentimiento de datos",authorize_dapps:"Autorizar dApps para acceder a credenciales",return_to_app:"Volver a la aplicación",verify_data_desc:"Verifique su información de identidad. Estos datos se usarán para crear su CasperID.",ocr_confidence:"Confianza OCR",first_name:"Nombre",last_name:"Apellido",document_number:"Número de documento",date_of_birth:"Fecha de nacimiento",nationality:"Nacionalidad",enter_first_name:"Ingrese nombre",enter_last_name:"Ingrese apellido",enter_nationality:"Ingrese nacionalidad",scanned_successfully:"Escaneado con éxito",secured_by_casper:"Protegido por CasperID Protocol.",confirm_mint:"Confirmar y crear",submitting:"Enviando...",retake_photo:"Tomar otra foto",auth_subtitle:"Asegure su identidad Web3 con nuestra capa de autenticación premium.",extension_connect_msg:"Haga clic en el icono de la extensión CasperID en su navegador para conectarse.",extension_not_detected:"No se detectó la extensión CasperID. Instale la extensión o use el inicio de sesión OTP.",connecting:"Conectando...",two_factor_auth:"Autenticación de dos factores",security_notice:"Sus datos están encriptados y nunca se almacenan en servidores centrales. Desarrollado por Casper Network.",e2e_encrypted:"Cifrado de extremo a extremo",error_email_required:"Por favor ingrese su correo",error_invalid_email:"Por favor ingrese un correo válido",error_passkey_registered:"Tiene una clave de paso registrada. Utilice el inicio de sesión por extensión.",error_send_code_failed:"Error al enviar el código de verificación. Inténtelo de nuevo.",error_connection_failed:"No se puede conectar. Compruebe su conexión a internet.",verify_code:"Código de verificación",code_expired:"Código expirado",invalid_code:"Código inválido",error_pin_incomplete:"Por favor ingrese los 6 dígitos",verify:"Verificar",invalid_code_attempts:"Código inválido. {attempts} intentos restantes.",awaiting_calibration:"Esperando calibración",transaction_status:"Estado de la transacción",complete_percent:"{percent}% completado",validating_docs:"Validando documentos...",broadcasting_tx:"Transmitiendo al nodo principal de Casper...",tx_confirmed:"Transacción confirmada en Casper Network",scan_instruction:"Escanee el {side} de su {docType}",review_capture:"Revise su captura. Asegúrese de que todo el texto sea visible.",align_document:"Alinee su documento dentro del marco brillante. Asegúrese de que las cuatro esquinas sean visibles.",next_back_side:"Siguiente: Reverso",confirm:"Confirmar",capture:"Capturar",verify_data_carefully:"Verifique los datos extraídos cuidadosamente.",enter_doc_number:"Ingrese el número de documento",date_format:"DD/MM/AAAA",error_required_fields:"Por favor complete todos los campos obligatorios.",front:"frente",back:"reverso",requesting_access:"Solicitando acceso",privacy_note:"Nota de privacidad",privacy_desc:"Solo se comparten pruebas criptográficas. Nunca se exponen las claves privadas.",approve_verify:"Aprobar y Verificar",deny:"Denegar",perm_identity:"Verificar estado de identidad",perm_profile:"Leer perfil público",perm_kyc:"Compartir nivel de KYC","verify:identity":"Verificar estado de identidad","read:profile":"Leer perfil público","read:kyc_level":"Compartir nivel de KYC","read:email":"Acceso a correo electrónico","read:wallet":"Ver dirección de billetera",full_name:"NOMBRE COMPLETO",id_number:"NÚMERO DE IDENTIFICACIÓN",passkey_auth_subtitle:"Use su clave de paso para iniciar sesión de forma segura.",signing_in_as:"Iniciando sesión como",use_passkey:"Use su clave de paso",authenticating:"Autenticando...",authentication_failed:"Autenticación fallida",passkey_auth_hint:"Touch ID, Face ID o llave de seguridad",passkey_cancelled:"Autenticación cancelada. Intente de nuevo cuando esté listo.",authenticate:"Autenticar",use_email_instead:"Usar código de correo",biometric_secured:"Biométrico seguro",webauthn_not_supported:"Su navegador no admite claves de paso. Use verificación por correo.",create_passkey:"Crear su clave de paso",passkey_register_subtitle:"Configure autenticación biométrica para inicio de sesión sin contraseña.",passkey_benefits_title:"¿Por qué usar clave de paso?",passkey_benefit_1:"Sin contraseñas que recordar",passkey_benefit_2:"Seguridad resistente al phishing",passkey_benefit_3:"Funciona en todos sus dispositivos",register_passkey:"Crear clave de paso",creating_passkey:"Creando clave de paso...",passkey_created:"¡Clave de paso creada!",passkey_create_failed:"Error al crear clave de paso",l1_setup_title:"Configurando su identidad",l1_setup_subtitle:"Creando su billetera segura e identidad descentralizada.",generating_wallet:"Generando billetera segura...",minting_did:"Minting su DID...",l1_complete:"¡Configuración de identidad completa!",l1_failed:"Configuración fallida. Intente de nuevo.",facial_verification:"Verificación Facial",secure_face_scan_desc:"Escaneo Facial Seguro • Encriptado",analyzing_liveness:"Analizando Vivacidad",calibration_complete:"Calibración Completa"},FR:{welcome_back:"Bon retour",enter_email:"Entrez votre email pour un code.",email_address:"Adresse email",continue:"Continuer",sending_code:"Envoi du code...",verify_email:"Vérifier l'email",enter_code:"Entrez le code à 6 chiffres envoyé à",verification_failed:"Échec de vérification",verifying:"Vérification...",resend_code:"Renvoyer le code",resend_in:"Renvoyer dans",secure_sdk:"SDK SÉCURISÉ",permission_request:"DEMANDE DE PERMISSION",review_data:"Réviser les données",mint_identity:"Mint Identité",face_scan:"Scan du visage",document_scan:"Scan du document",verification_step:"ÉTAPE DE VÉRIFICATION",kyc_required:"KYC REQUIS",security_upgrade_required:"Mise à niveau de sécurité requise",security_upgrade_desc:"Votre compte nécessite une mise à niveau biométrique pour cette action.",biometric_secure:"BIOMÉTRIE SÉCURISÉE",zero_knowledge:"ZÉRO CONNAISSANCE",start_upgrade:"Démarrer la mise à jour",do_this_later:"Je ferai ça plus tard",sign_in_with_extension:"Connexion avec l'extension",sign_in_with_otp:"Connexion avec OTP",extension_detected:"Extension détectée",secure_wallet:"Portefeuille sécurisé",fully_audited:"ENTIÈREMENT AUDITÉ",non_custodial:"NON FONGIBLE",verify_identity:"Vérifiez votre identité",choose_document:"Choisissez un type de document.",passport:"Passeport",drivers_license:"Permis de conduire",national_id:"Carte d'identité",passport_desc:"Tous les pays supportés",drivers_license_desc:"Carte émise par le gouvernement",national_id_desc:"Document d'identité national",position_face:"Placez votre visage dans le cadre",blink_slowly:"Clignez des yeux lentement",turn_head_left:"Tournez la tête vers la gauche",turn_head_right:"Tournez la tête vers la droite",processing:"Traitement...",camera_permission_denied:"Permission caméra refusée",unable_access_camera:"Accès caméra impossible",live_camera:"CAMÉRA EN DIRECT",initializing:"INITIALISATION",processing_verification:"Traitement de la vérification...",processing_liveness:"Vérification de la vivacité...",processing_documents:"Traitement des documents...",processing_subtitle:"Validation de vos documents et biométrie",minting_identity:"Mint Identité en cours...",minting_subtitle:"Sécurisation de votre identité sur le réseau Casper",identity_minted:"Identité créée !",minted_subtitle:"Votre CasperID a été créé avec succès",verification_failed_subtitle:"Il y a eu un problème avec votre vérification",try_again:"Réessayer",credential_hash:"Hachage de créance",identity_verified:"Identité vérifiée",identity_verified_subtitle:"Votre vérification de vivacité a réussi. Vous êtes maintenant vérifié.",identity_verified_desc:"Votre CasperID a été authentifié avec succès sur la blockchain Casper.",submitting_for_review:"Soumission pour révision...",submitting_review_subtitle:"Vos documents sont en cours de préparation pour la vérification",verification_submitted:"Vérification Soumise",verification_submitted_subtitle:"Vos documents sont en cours de révision. Vous serez notifié une fois vérifié.",share_data_consent:"Partage de données",authorize_dapps:"Autoriser dApps à accéder aux identifiants",return_to_app:"Retour à l'application",verify_data_desc:"Vérifiez vos informations d'identité. Ces données seront utilisées pour créer votre CasperID.",ocr_confidence:"Confiance OCR",first_name:"Prénom",last_name:"Nom",document_number:"Numéro de document",date_of_birth:"Date de naissance",nationality:"Nationalité",enter_first_name:"Entrez le prénom",enter_last_name:"Entrez le nom",enter_nationality:"Entrez la nationalité",scanned_successfully:"Scanné avec succès",secured_by_casper:"Sécurisé par CasperID Protocol.",confirm_mint:"Confirmer et Créer",submitting:"Soumission...",retake_photo:"Reprendre la photo",auth_subtitle:"Sécurisez votre identité Web3 avec notre couche d'authentification premium.",extension_connect_msg:"Cliquez sur l'icône de l'extension CasperID dans votre navigateur pour vous connecter.",extension_not_detected:"Extension CasperID non détectée. Veuillez installer l'extension ou utiliser la connexion OTP.",connecting:"Connexion...",two_factor_auth:"Authentification à deux facteurs",security_notice:"Vos données sont cryptées et ne sont jamais stockées sur des serveurs centraux. Propulsé par Casper Network.",e2e_encrypted:"Chiffré de bout en bout",error_email_required:"Veuillez entrer votre email",error_invalid_email:"Veuillez entrer une adresse email valide",error_passkey_registered:"Vous avez une clé de sécurité enregistrée. Veuillez utiliser la connexion par extension.",error_send_code_failed:"Échec de l'envoi du code de vérification. Veuillez réessayer.",error_connection_failed:"Impossible de se connecter. Veuillez vérifier votre connexion internet.",verify_code:"Code de vérification",code_expired:"Code expiré",invalid_code:"Code invalide",error_pin_incomplete:"Veuillez entrer les 6 chiffres",verify:"Vérifier",invalid_code_attempts:"Code invalide. {attempts} tentatives restantes.",awaiting_calibration:"En attente de calibrage",transaction_status:"Statut de la transaction",complete_percent:"{percent}% terminé",validating_docs:"Validation des documents...",broadcasting_tx:"Diffusion sur le nœud Casper Mainnet...",tx_confirmed:"Transaction confirmée sur le réseau Casper",scan_instruction:"Scannez le {side} de votre {docType}",review_capture:"Réviser votre capture. Assurez-vous que tout le texte est visible.",align_document:"Alignez votre document dans le cadre. Assurez-vous que les quatre coins sont visibles.",next_back_side:"Suivant: Verso",confirm:"Confirmer",capture:"Capturer",verify_data_carefully:"Veuillez vérifier soigneusement les données extraites.",enter_doc_number:"Entrez le numéro du document",date_format:"JJ/MM/AAAA",error_required_fields:"Veuillez remplir tous les champs obligatoires.",front:"recto",back:"verso",requesting_access:"Demande d'accès",privacy_note:"Note de confidentialité",privacy_desc:"Seules des preuves cryptographiques sont partagées. Aucune clé privée n'est jamais exposée.",approve_verify:"Approuver et Vérifier",deny:"Refuser",perm_identity:"Vérifier le statut d'identité",perm_profile:"Lire le profil public",perm_kyc:"Partager le niveau KYC","verify:identity":"Vérifier le statut d'identité","read:profile":"Lire le profil public","read:kyc_level":"Partager le niveau KYC","read:email":"Accéder à l'adresse email","read:wallet":"Voir l'adresse du portefeuille",full_name:"NOM COMPLET",id_number:"NUMÉRO DE DOCUMENT",passkey_auth_subtitle:"Utilisez votre clé d'accès pour vous connecter en toute sécurité.",signing_in_as:"Connexion en tant que",use_passkey:"Utilisez votre clé d'accès",authenticating:"Authentification...",authentication_failed:"Échec de l'authentification",passkey_auth_hint:"Touch ID, Face ID ou clé de sécurité",passkey_cancelled:"Authentification annulée. Réessayez quand vous êtes prêt.",authenticate:"Authentifier",use_email_instead:"Utiliser un code par email",biometric_secured:"Sécurisé biométrique",webauthn_not_supported:"Votre navigateur ne prend pas en charge les clés d'accès. Utilisez la vérification par email.",create_passkey:"Créer votre clé d'accès",passkey_register_subtitle:"Configurez l'authentification biométrique pour une connexion sans mot de passe.",passkey_benefits_title:"Pourquoi utiliser une clé d'accès?",passkey_benefit_1:"Pas de mot de passe à retenir",passkey_benefit_2:"Sécurité résistante au phishing",passkey_benefit_3:"Fonctionne sur tous vos appareils",register_passkey:"Créer la clé d'accès",creating_passkey:"Création de la clé d'accès...",passkey_created:"Clé d'accès créée!",passkey_create_failed:"Échec de la création de la clé d'accès",l1_setup_title:"Configuration de votre identité",l1_setup_subtitle:"Création de votre portefeuille sécurisé et identité décentralisée.",generating_wallet:"Génération du portefeuille sécurisé...",minting_did:"Création de votre DID...",l1_complete:"Configuration d'identité terminée!",l1_failed:"Échec de la configuration. Réessayez.",facial_verification:"Vérification Faciale",secure_face_scan_desc:"Scan Facial Sécurisé • Crypté",analyzing_liveness:"Analyse de Vivacité",calibration_complete:"Calibration Terminée"},DE:{welcome_back:"Willkommen zurück",enter_email:"E-Mail für Bestätigungscode eingeben.",email_address:"E-Mail-Adresse",continue:"Weiter",sending_code:"Code wird gesendet...",verify_email:"E-Mail verifizieren",enter_code:"6-stelligen Code eingeben, gesendet an",verification_failed:"Verifizierung fehlgeschlagen",verifying:"Verifizierung...",resend_code:"Code erneut senden",resend_in:"Erneut in",secure_sdk:"SICHERES SDK",permission_request:"BERECHTIGUNGSANFRAGE",review_data:"Daten überprüfen",mint_identity:"Identität prägen",face_scan:"Gesichtsscan",document_scan:"Dokumentenscan",verification_step:"VERIFIZIERUNGSSCHRITT",kyc_required:"KYC ERFORDERLICH",security_upgrade_required:"Sicherheits-Upgrade erforderlich",security_upgrade_desc:"Ihr Konto erfordert ein biometrisches Upgrade für diese Aktion.",biometric_secure:"BIOMETRISCH SICHER",zero_knowledge:"ZERO-KNOWLEDGE",start_upgrade:"Upgrade starten",do_this_later:"Später erledigen",sign_in_with_extension:"Mit Erweiterung anmelden",sign_in_with_otp:"Mit OTP anmelden",extension_detected:"Erweiterung erkannt",secure_wallet:"Sichere Wallet",fully_audited:"VOLLSTÄNDIG GEPRÜFT",non_custodial:"NON-CUSTODIAL",verify_identity:"Identität verifizieren",choose_document:"Dokumenttyp auswählen.",passport:"Reisepass",drivers_license:"Führerschein",national_id:"Personalausweis",passport_desc:"Alle Länder unterstützt",drivers_license_desc:"Staatlicher Ausweis",national_id_desc:"Nationaler Identitätsnachweis",position_face:"Gesicht im Rahmen positionieren",blink_slowly:"Langsam blinzeln",turn_head_left:"Kopf langsam nach links drehen",turn_head_right:"Kopf langsam nach rechts drehen",processing:"Verarbeitung...",camera_permission_denied:"Kamerazugriff verweigert",unable_access_camera:"Kamerazugriff nicht möglich",live_camera:"LIVE-KAMERA",initializing:"INITIALISIERUNG",processing_verification:"Verifizierung wird verarbeitet...",processing_liveness:"Lebendigkeitsprüfung läuft...",processing_documents:"Dokumente werden verarbeitet...",processing_subtitle:"Dokumente und Biometrie werden validiert",minting_identity:"Identität wird geprägt...",minting_subtitle:"Ihre dezentrale Identität wird im Casper-Netzwerk gesichert",identity_minted:"Identität geprägt!",minted_subtitle:"Ihre CasperID wurde erfolgreich erstellt",verification_failed_subtitle:"Es gab ein Problem mit Ihrer Verifizierung",try_again:"Erneut versuchen",credential_hash:"Anmeldedaten-Hash",identity_verified:"Identität verifiziert",identity_verified_subtitle:"Ihre Lebendigkeitsprüfung war erfolgreich. Sie sind jetzt verifiziert.",identity_verified_desc:"Ihre CasperID wurde erfolgreich in der Casper-Blockchain authentifiziert.",submitting_for_review:"Zur Überprüfung einreichen...",submitting_review_subtitle:"Ihre Dokumente werden für die Verifizierung vorbereitet",verification_submitted:"Verifizierung eingereicht",verification_submitted_subtitle:"Ihre Dokumente werden überprüft. Sie werden benachrichtigt, sobald verifiziert.",share_data_consent:"Datenfreigabe",authorize_dapps:"dApps Zugriff auf Anmeldedaten erlauben",return_to_app:"Zurück zur App",verify_data_desc:"Überprüfen Sie Ihre Identitätsdaten. Diese werden zur Erstellung Ihrer CasperID verwendet.",ocr_confidence:"OCR-Vertrauen",first_name:"Vorname",last_name:"Nachname",document_number:"Ausweisnummer",date_of_birth:"Geburtsdatum",nationality:"Nationalität",enter_first_name:"Vorname eingeben",enter_last_name:"Nachname eingeben",enter_nationality:"Nationalität eingeben",scanned_successfully:"Erfolgreich gescannt",secured_by_casper:"Gesichert durch CasperID Protocol.",confirm_mint:"Bestätigen & Prägen",submitting:"Wird gesendet...",retake_photo:"Foto erneut aufnehmen",auth_subtitle:"Sichern Sie Ihre Web3-Identität mit unserer Premium-Authentifizierungsschicht.",extension_connect_msg:"Klicken Sie auf das CasperID-Erweiterungssymbol in Ihrem Browser, um eine Verbindung herzustellen.",extension_not_detected:"CasperID-Erweiterung nicht erkannt. Bitte installieren Sie die Erweiterung oder verwenden Sie die OTP-Anmeldung.",connecting:"Verbindung wird hergestellt...",two_factor_auth:"Zwei-Faktor-Authentifizierung",security_notice:"Ihre Daten sind verschlüsselt und werden niemals auf zentralen Servern gespeichert. Unterstützt von Casper Network.",e2e_encrypted:"Ende-zu-Ende verschlüsselt",error_email_required:"Bitte geben Sie Ihre E-Mail-Adresse ein",error_invalid_email:"Bitte geben Sie eine gültige E-Mail-Adresse ein",error_passkey_registered:"Sie haben einen Passkey registriert. Bitte verwenden Sie die Anmeldung über die Erweiterung.",error_send_code_failed:"Der Verifizierungscode konnte nicht gesendet werden. Bitte versuchen Sie es erneut.",error_connection_failed:"Verbindung nicht möglich. Bitte überprüfen Sie Ihre Internetverbindung.",verify_code:"Verifizierungscode",code_expired:"Code abgelaufen",invalid_code:"Ungültiger Code",error_pin_incomplete:"Bitte alle 6 Ziffern eingeben",verify:"Verifizieren",invalid_code_attempts:"Ungültiger Code. {attempts} Versuche übrig.",error_verify_failed:"Verifizierung nicht möglich. Bitte erneut versuchen.",error_resend_failed:"Code konnte nicht gesendet werden. Bitte erneut versuchen.",sending:"Senden...",facial_verification:"Gesichtsverifizierung",secure_face_scan_desc:"Sicherer Gesichtsscan • Verschlüsselt",analyzing_liveness:"Lebendigkeitsprüfung",calibration_complete:"Kalibrierung abgeschlossen",awaiting_calibration:"Warten auf Kalibrierung",transaction_status:"Transaktionsstatus",complete_percent:"{percent}% abgeschlossen",validating_docs:"Dokumente werden validiert...",broadcasting_tx:"Übertragung an Casper Mainnet Node...",tx_confirmed:"Transaktion im Casper-Netzwerk bestätigt",scan_instruction:"Scannen Sie die {side} Ihres {docType}",review_capture:"Überprüfen Sie Ihre Aufnahme. Stellen Sie sicher, dass der Text lesbar ist.",align_document:"Richten Sie Ihr Dokument im Rahmen aus. Alle vier Ecken müssen sichtbar sein.",next_back_side:"Weiter: Rückseite",confirm:"Bestätigen",capture:"Aufnehmen",verify_data_carefully:"Bitte überprüfen Sie die extrahierten Daten sorgfältig.",enter_doc_number:"Ausweisnummer eingeben",date_format:"TT/MM/JJJJ",error_required_fields:"Bitte füllen Sie alle Pflichtfelder aus.",front:"Vorderseite",back:"Rückseite",requesting_access:"Zugriff anfordern",privacy_note:"Datenschutzhinweis",privacy_desc:"Es werden nur kryptografische Beweise geteilt. Private Schlüssel werden niemals offengelegt.",approve_verify:"Genehmigen & Verifizieren",deny:"Ablehnen",perm_identity:"Identitätsstatus überprüfen",perm_profile:"Öffentliches Profil lesen",perm_kyc:"KYC-Level teilen","verify:identity":"Identitätsstatus überprüfen","read:profile":"Öffentliches Profil lesen","read:kyc_level":"KYC-Level teilen","read:email":"E-Mail-Adresse zugreifen","read:wallet":"Wallet-Adresse anzeigen",full_name:"VOLLSTÄNDIGER NAME",id_number:"AUSWEISNUMMER",passkey_auth_subtitle:"Verwenden Sie Ihren Passkey für sichere Anmeldung.",signing_in_as:"Anmeldung als",use_passkey:"Passkey verwenden",authenticating:"Authentifizierung...",authentication_failed:"Authentifizierung fehlgeschlagen",passkey_auth_hint:"Touch ID, Face ID oder Sicherheitsschlüssel",passkey_cancelled:"Authentifizierung abgebrochen. Versuchen Sie es erneut.",authenticate:"Authentifizieren",use_email_instead:"E-Mail-Code verwenden",biometric_secured:"Biometrisch gesichert",webauthn_not_supported:"Ihr Browser unterstützt keine Passkeys. Verwenden Sie E-Mail-Verifizierung.",create_passkey:"Passkey erstellen",passkey_register_subtitle:"Richten Sie biometrische Authentifizierung für passwortlose Anmeldung ein.",passkey_benefits_title:"Warum einen Passkey verwenden?",passkey_benefit_1:"Keine Passwörter merken",passkey_benefit_2:"Phishing-resistente Sicherheit",passkey_benefit_3:"Funktioniert auf allen Geräten",register_passkey:"Passkey erstellen",creating_passkey:"Passkey wird erstellt...",passkey_created:"Passkey erstellt!",passkey_create_failed:"Passkey-Erstellung fehlgeschlagen",l1_setup_title:"Identität einrichten",l1_setup_subtitle:"Sichere Wallet und dezentrale Identität werden erstellt.",generating_wallet:"Sichere Wallet wird generiert...",minting_did:"DID wird geprägt...",l1_complete:"Identitätseinrichtung abgeschlossen!",l1_failed:"Einrichtung fehlgeschlagen. Erneut versuchen."}},t=(i,s="EN")=>{const r=s.toUpperCase();return(Ae[r]||Ae.EN)[i]||Ae.EN[i]||i},Je=({onNext:i,onExtensionSuccess:s,onError:r,language:l="EN",platform:k="desktop"})=>{const[f,p]=a.useState(!1),[m,n]=a.useState(null),[c,d]=a.useState("");a.useEffect(()=>{A()},[]),a.useEffect(()=>{const o=j=>{p(!1),j.detail&&j.detail.wallet&&(s==null||s(j.detail))};return window.addEventListener("casperid-login",o),()=>{window.removeEventListener("casperid-login",o)}},[s]);const A=a.useCallback(()=>{const o=document.getElementById("casperid-draggable-anchor");let j=null;try{j=localStorage.getItem("casperid_user")}catch{}return o||j?(n(!0),!0):(setTimeout(()=>{const y=document.getElementById("casperid-draggable-anchor");n(!!y)},500),!1)},[]),h=o=>typeof o=="object"&&o!==null&&"wallet"in o&&typeof o.wallet=="string"&&o.wallet.length>0,S=async()=>{p(!0),d("");try{const j=localStorage.getItem("casperid_user");if(j){const y=JSON.parse(j);if(h(y)){p(!1),s==null||s(y);return}}}catch{}const o=document.getElementById("casperid-draggable-anchor");o?(o.click(),setTimeout(()=>{p(!1);try{localStorage.getItem("casperid_user")||d(t("extension_connect_msg",l))}catch{d(t("extension_connect_msg",l))}},3e3)):(p(!1),d(t("extension_not_detected",l)),r==null||r("Extension not installed"))},b=()=>{d(""),i("otp")};return e.jsxs(E.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"flex-1 px-8 flex flex-col justify-center gap-8",children:[e.jsxs("div",{className:"text-center space-y-3",children:[e.jsxs("div",{className:"relative w-24 h-24 mx-auto mb-6",children:[e.jsx("div",{className:"absolute inset-0 bg-brand-20 blur-2xl rounded-full"}),e.jsx("div",{className:"relative w-full h-full glass-container flex items-center justify-center rounded-2xl border border-brand-30",children:e.jsx(ge,{className:"w-10 h-10 text-brand"})})]}),e.jsx("h1",{className:"text-2xl font-extrabold leading-tight tracking-tight text-main",children:t("welcome_back",l)}),e.jsx("p",{className:"text-muted text-sm leading-relaxed",children:t("auth_subtitle",l)})]}),c&&e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-2xl",children:[e.jsx(xe,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),e.jsx("p",{className:"text-red-600 dark:text-red-400 text-sm font-medium",children:c})]}),e.jsxs("div",{className:"space-y-4",children:[k==="desktop"&&e.jsxs("button",{onClick:S,disabled:f,className:"w-full group relative overflow-hidden flex items-center gap-4 bg-brand hover:bg-brand-90 text-white py-5 px-6 rounded-2xl font-bold transition-all transform active:scale-[0.98] disabled:opacity-70 disabled:cursor-not-allowed shadow-brand",children:[e.jsx("div",{className:"bg-white/20 p-2 rounded-lg",children:f?e.jsx(me,{className:"w-5 h-5 animate-spin"}):e.jsx(Tt,{className:"w-5 h-5"})}),e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{className:"text-base",children:t(f?"connecting":"sign_in_with_extension",l)}),e.jsx("span",{className:"text-[10px] uppercase tracking-widest text-slate-600 dark:text-white/70",children:t(m===!0?"extension_detected":"secure_wallet",l)})]}),e.jsx(De,{className:"ml-auto w-4 h-4 opacity-50 group-hover:opacity-100 transition-opacity"})]}),e.jsxs("button",{onClick:b,disabled:f,className:"w-full group relative overflow-hidden flex items-center gap-4 dark:bg-white/5 bg-slate-100/50 hover:dark:bg-white/10 hover:bg-slate-200/80 border dark:border-white/10 border-slate-200 text-main py-5 px-6 rounded-2xl font-bold transition-all transform active:scale-[0.98] disabled:opacity-50",children:[e.jsx("div",{className:"bg-brand-10 p-2 rounded-lg",children:e.jsx(Me,{className:"w-5 h-5 text-brand"})}),e.jsxs("div",{className:"flex flex-col items-start",children:[e.jsx("span",{className:"text-base",children:t("sign_in_with_otp",l)}),e.jsx("span",{className:"text-[10px] uppercase tracking-widest text-brand font-bold",children:t("two_factor_auth",l)})]}),e.jsx(De,{className:"ml-auto w-4 h-4 opacity-50 group-hover:opacity-100 transition-opacity"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"glass-container p-4 rounded-2xl flex flex-col items-center gap-2 text-center border-slate-200/50",children:[e.jsx(we,{className:"w-5 h-5 text-brand"}),e.jsx("span",{className:"text-[10px] font-bold text-muted",children:t("fully_audited",l)})]}),e.jsxs("div",{className:"glass-container p-4 rounded-2xl flex flex-col items-center gap-2 text-center border-slate-200/50",children:[e.jsx(Se,{className:"w-5 h-5 text-brand"}),e.jsx("span",{className:"text-[10px] font-bold text-muted",children:t("non_custodial",l)})]})]})]})},Ke=({onNext:i,onPasskeyUser:s,onError:r,apiBaseUrl:l="https://apis.casperid.com",apiKey:k="",previewMode:f=!1,language:p="EN"})=>{const[m,n]=a.useState(""),[c,d]=a.useState(!1),[A,h]=a.useState(""),S=async()=>{if(!m.trim()){h(t("error_email_required",p));return}if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(m)){h(t("error_invalid_email",p));return}if(d(!0),h(""),f){setTimeout(()=>{d(!1),i(m.trim().toLowerCase(),"mock-v-id-123456789")},1e3);return}try{const j=await fetch(`${l}/api/auth/send-otp`,{method:"POST",headers:{"Content-Type":"application/json",...k?{"X-App-Id":k}:{}},body:JSON.stringify({email:m.trim().toLowerCase()})});if(!j.ok){const w=await j.json().catch(()=>({}));throw new Error(w.error||`Request failed with status ${j.status}`)}const y=await j.json();if(y.success){if(y.userExists&&y.hasPasskey){s?s(m.trim().toLowerCase()):h(t("error_passkey_registered",p)),d(!1);return}y.verificationId?i(m.trim().toLowerCase(),y.verificationId):h(t("error_send_code_failed",p))}else h(y.error||t("error_send_code_failed",p)),r==null||r(y.error||t("error_send_code_failed",p))}catch{const y=t("error_connection_failed",p);h(y),r==null||r(y)}finally{d(!1)}},b=o=>{o.key==="Enter"&&!c&&S()};return e.jsxs(E.motion.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex-1 flex flex-col px-8 pt-12",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-3xl font-extrabold text-main tracking-tight leading-tight",children:t("welcome_back",p)}),e.jsx("p",{className:"text-muted mt-3 text-sm leading-relaxed",children:t("enter_email",p)})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-bold text-slate-500 uppercase tracking-widest ml-1",children:t("email_address",p)}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{className:`w-full dark:bg-black/20 bg-slate-100/50 border ${A?"border-red-400 dark:border-red-500":"dark:border-white/10 border-slate-200"} rounded-2xl h-14 px-5 text-main placeholder:text-slate-400 focus:outline-none focus:ring-2 focus:ring-brand-30 transition-all font-medium`,placeholder:"name@example.com",type:"email",value:m,onChange:o=>{n(o.target.value),A&&h("")},onKeyDown:b,disabled:c,autoComplete:"email",autoFocus:!0}),e.jsx("div",{className:"absolute right-4 top-1/2 -translate-y-1/2 flex items-center text-slate-400",children:e.jsx(Rt,{className:"w-5 h-5"})})]}),A&&e.jsx("p",{className:"text-red-500 text-xs font-medium ml-1 mt-1",children:A})]}),e.jsx("button",{onClick:S,disabled:c,className:"w-full h-14 bg-brand hover:bg-brand/90 text-white font-bold rounded-2xl shadow-xl shadow-brand flex items-center justify-center gap-2 transition-transform active:scale-[0.98] disabled:opacity-70 disabled:cursor-not-allowed",children:c?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("sending_code",p)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:t("continue",p)}),e.jsx(ze,{className:"w-5 h-5"})]})})]}),e.jsxs("div",{className:"mt-auto pb-8",children:[e.jsx("div",{className:"p-4 dark:bg-white/5 bg-slate-100/50 rounded-2xl mb-6",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ve,{className:"text-[#6DE8EC] w-5 h-5 mt-0.5 shrink-0"}),e.jsx("p",{className:"text-[11px] text-muted leading-normal font-medium",children:t("security_notice",p)})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-2 opacity-50",children:[e.jsx(Ge,{className:"text-muted w-3 h-3"}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.2em] font-bold text-muted",children:t("e2e_encrypted",p)})]})]})]})};function pe(i){const s=new Uint8Array(i);let r="";for(let l=0;l<s.byteLength;l++)r+=String.fromCharCode(s[l]);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function ye(i){const s="=".repeat((4-i.length%4)%4),r=i.replace(/-/g,"+").replace(/_/g,"/")+s,l=atob(r),k=new Uint8Array(l.length);for(let f=0;f<l.length;f++)k[f]=l.charCodeAt(f);return k.buffer}function ke(){return!!(window.PublicKeyCredential&&typeof window.PublicKeyCredential=="function")}async function Ze(){if(!ke())return!1;try{return await PublicKeyCredential.isUserVerifyingPlatformAuthenticatorAvailable()}catch{return!1}}function qt(){const i=navigator.userAgent.toLowerCase();return/iphone|ipod|android.*mobile|windows phone|blackberry/i.test(i)?"mobile":/ipad|android(?!.*mobile)|tablet/i.test(i)?"tablet":"desktop"}function Ut(){return{platform:navigator.platform||"unknown",userAgent:navigator.userAgent,deviceType:qt()}}function $t(i){var s;return{...i,challenge:ye(i.challenge),user:{...i.user,id:ye(i.user.id)},excludeCredentials:(s=i.excludeCredentials)==null?void 0:s.map(r=>({...r,id:ye(r.id)}))}}function Bt(i){var s;return{...i,challenge:ye(i.challenge),allowCredentials:(s=i.allowCredentials)==null?void 0:s.map(r=>({...r,id:ye(r.id)}))}}function Ht(i){const s=i.response;return{id:i.id,rawId:pe(i.rawId),type:i.type,response:{clientDataJSON:pe(s.clientDataJSON),attestationObject:pe(s.attestationObject)},clientExtensionResults:i.getClientExtensionResults(),deviceInfo:Ut()}}function Wt(i){const s=i.response;return{id:i.id,rawId:pe(i.rawId),type:i.type,response:{clientDataJSON:pe(s.clientDataJSON),authenticatorData:pe(s.authenticatorData),signature:pe(s.signature),userHandle:s.userHandle?pe(s.userHandle):null},clientExtensionResults:i.getClientExtensionResults()}}async function Gt(i){if(!ke())throw new Error("WebAuthn is not supported in this browser");const s=$t(i),r=await navigator.credentials.create({publicKey:s});if(!r)throw new Error("Passkey creation was cancelled or failed");return Ht(r)}async function Yt(i){if(!ke())throw new Error("WebAuthn is not supported in this browser");const s=Bt(i),r=await navigator.credentials.get({publicKey:s});if(!r)throw new Error("Passkey authentication was cancelled or failed");return Wt(r)}const Jt=({email:i,onSuccess:s,onError:r,onFallbackToOTP:l,apiBaseUrl:k="https://apis.casperid.com",apiKey:f="",previewMode:p=!1,language:m="EN"})=>{const[n,c]=a.useState(!1),[d,A]=a.useState(""),[h,S]=a.useState(!0),[b,o]=a.useState(!1);a.useEffect(()=>{(async()=>{const w=ke(),T=await Ze();S(w&&T),(!w||!T)&&A(t("webauthn_not_supported",m))})()},[m]),a.useEffect(()=>{if(h&&!b&&!p){o(!0);const y=setTimeout(()=>{j()},500);return()=>clearTimeout(y)}},[h,b,p]);const j=async()=>{if(!n){if(c(!0),A(""),p){setTimeout(()=>{c(!1),s("mock-session-token",{user_id:"mock-user-id",email:i,tier:"layer_1"})},1500);return}try{const y=await fetch(`${k}/api/passkey/auth/begin`,{method:"POST",headers:{"Content-Type":"application/json",...f?{"X-App-Id":f}:{}},credentials:"include",body:JSON.stringify({email:i})});if(!y.ok){const W=await y.json().catch(()=>({}));throw new Error(W.error||"Failed to initialize authentication")}const w=await y.json();if(!w.success||!w.options)throw new Error(w.error||"Invalid authentication options");const T=await Yt(w.options),v=await fetch(`${k}/api/passkey/auth/finish`,{method:"POST",headers:{"Content-Type":"application/json",...f?{"X-App-Id":f}:{}},credentials:"include",body:JSON.stringify({email:i,challengeId:w.challengeId,credential:T})});if(!v.ok){const W=await v.json().catch(()=>({}));throw new Error(W.error||"Authentication failed")}const D=await v.json();if(D.success&&D.session_token)s(D.session_token,D.user,D.business_token);else throw new Error(D.error||"Authentication failed")}catch(y){const w=y instanceof Error?y.message:"Authentication failed";w.includes("cancelled")||w.includes("NotAllowedError")?A(t("passkey_cancelled",m)):(A(w),r==null||r(w))}finally{c(!1)}}};return e.jsxs(E.motion.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex-1 flex flex-col px-8 pt-12",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-3xl font-extrabold text-main tracking-tight leading-tight",children:t("welcome_back",m)}),e.jsx("p",{className:"text-muted mt-3 text-sm leading-relaxed",children:t("passkey_auth_subtitle",m)})]}),e.jsxs("div",{className:"mb-6 p-4 dark:bg-white/5 bg-slate-100/50 rounded-2xl",children:[e.jsx("p",{className:"text-xs text-muted mb-1",children:t("signing_in_as",m)}),e.jsx("p",{className:"text-main font-semibold",children:i})]}),e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-8",children:[e.jsx(E.motion.div,{animate:n?{scale:[1,1.1,1],opacity:[1,.7,1]}:{},transition:{duration:1.5,repeat:n?1/0:0,ease:"easeInOut"},className:`w-24 h-24 rounded-full flex items-center justify-center mb-6 ${n?"bg-brand/20 border-2 border-brand":d?"bg-red-500/10 border-2 border-red-400":"bg-brand/10 border-2 border-brand/30"}`,children:n?e.jsx(me,{className:"w-10 h-10 text-brand animate-spin"}):d?e.jsx(xe,{className:"w-10 h-10 text-red-400"}):e.jsx(ge,{className:"w-10 h-10 text-brand"})}),e.jsx("p",{className:"text-main font-semibold text-center mb-2",children:t(n?"authenticating":d?"authentication_failed":"use_passkey",m)}),d&&e.jsx("p",{className:"text-red-500 text-sm text-center mb-4 max-w-xs",children:d}),!n&&e.jsx("p",{className:"text-muted text-sm text-center max-w-xs",children:t("passkey_auth_hint",m)})]}),e.jsxs("div",{className:"space-y-3 pb-8",children:[!n&&e.jsx("button",{onClick:j,disabled:!h,className:"w-full h-14 bg-brand hover:bg-brand/90 text-white font-bold rounded-2xl shadow-xl shadow-brand/30 flex items-center justify-center gap-2 transition-transform active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed",children:d?e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"w-5 h-5"}),e.jsx("span",{children:t("try_again",m)})]}):e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-5 h-5"}),e.jsx("span",{children:t("authenticate",m)})]})}),l&&e.jsx("button",{onClick:l,disabled:n,className:"w-full h-12 bg-transparent border dark:border-white/10 border-slate-200 text-muted hover:text-main font-medium rounded-2xl flex items-center justify-center gap-2 transition-colors disabled:opacity-50",children:t("use_email_instead",m)})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 pb-4 opacity-50",children:[e.jsx(we,{className:"text-muted w-3 h-3"}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.2em] font-bold text-muted",children:t("biometric_secured",m)})]})]})},Kt=({email:i,sessionToken:s,onSuccess:r,onError:l,onSkip:k,apiBaseUrl:f="https://apis.casperid.com",apiKey:p="",previewMode:m=!1,language:n="EN"})=>{const[c,d]=a.useState(!1),[A,h]=a.useState(""),[S,b]=a.useState(!0),[o,j]=a.useState(!1);a.useEffect(()=>{(async()=>{const v=ke(),D=await Ze();b(v&&D),(!v||!D)&&h(t("webauthn_not_supported",n))})()},[n]);const y=async()=>{if(!c){if(d(!0),h(""),m){setTimeout(()=>{d(!1),j(!0),setTimeout(()=>{r({user_id:"mock-user-id",email:i,tier:"layer_0"})},1e3)},1500);return}try{const T=await fetch(`${f}/api/passkey/register/begin`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`,...p?{"X-App-Id":p}:{}},credentials:"include",body:JSON.stringify({email:i})});if(!T.ok){const $=await T.json().catch(()=>({}));throw new Error($.error||"Failed to initialize registration")}const v=await T.json();if(!v.success||!v.options)throw new Error(v.error||"Invalid registration options");const D=await Gt(v.options),W=await fetch(`${f}/api/passkey/register/finish`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`,...p?{"X-App-Id":p}:{}},credentials:"include",body:JSON.stringify({userId:v.userId,credential:D,deviceInfo:{userAgent:navigator.userAgent}})});if(!W.ok){const $=await W.json().catch(()=>({}));throw new Error($.error||"Registration failed")}const H=await W.json();if(H.success)j(!0),setTimeout(()=>{r(H.user,H.business_token)},1e3);else throw new Error(H.error||"Registration failed")}catch(T){const v=T instanceof Error?T.message:"Registration failed";v.includes("cancelled")||v.includes("NotAllowedError")?h(t("passkey_cancelled",n)):(h(v),l==null||l(v))}finally{d(!1)}}},w=[{icon:At,text:t("passkey_benefit_1",n)},{icon:we,text:t("passkey_benefit_2",n)},{icon:Me,text:t("passkey_benefit_3",n)}];return e.jsxs(E.motion.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex-1 flex flex-col px-8 pt-12",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-3xl font-extrabold text-main tracking-tight leading-tight",children:t("create_passkey",n)}),e.jsx("p",{className:"text-muted mt-3 text-sm leading-relaxed",children:t("passkey_register_subtitle",n)})]}),e.jsxs("div",{className:"mb-6 p-4 dark:bg-white/5 bg-slate-100/50 rounded-2xl",children:[e.jsx("p",{className:"text-xs text-muted mb-1",children:t("signing_in_as",n)}),e.jsx("p",{className:"text-main font-semibold",children:i})]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("p",{className:"text-sm font-semibold text-main mb-4",children:t("passkey_benefits_title",n)}),e.jsx("div",{className:"space-y-3",children:w.map((T,v)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-brand/10 flex items-center justify-center",children:e.jsx(T.icon,{className:"w-5 h-5 text-brand"})}),e.jsx("span",{className:"text-sm text-muted",children:T.text})]},v))})]}),(c||o||A)&&e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-4",children:[e.jsx(E.motion.div,{animate:c?{scale:[1,1.1,1],opacity:[1,.7,1]}:{},transition:{duration:1.5,repeat:c?1/0:0,ease:"easeInOut"},className:`w-20 h-20 rounded-full flex items-center justify-center mb-4 ${o?"bg-green-500/20 border-2 border-green-400":c?"bg-brand/20 border-2 border-brand":"bg-red-500/10 border-2 border-red-400"}`,children:o?e.jsx(ve,{className:"w-10 h-10 text-green-400"}):c?e.jsx(me,{className:"w-10 h-10 text-brand animate-spin"}):e.jsx(xe,{className:"w-10 h-10 text-red-400"})}),e.jsx("p",{className:"text-main font-semibold text-center",children:t(o?"passkey_created":c?"creating_passkey":"passkey_create_failed",n)}),A&&e.jsx("p",{className:"text-red-500 text-sm text-center mt-2 max-w-xs",children:A})]}),e.jsxs("div",{className:"mt-auto space-y-3 pb-8",children:[!o&&e.jsx("button",{onClick:y,disabled:!S||c,className:"w-full h-14 bg-brand hover:bg-brand/90 text-white font-bold rounded-2xl shadow-xl shadow-brand/30 flex items-center justify-center gap-2 transition-transform active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed",children:c?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("creating_passkey",n)})]}):e.jsxs(e.Fragment,{children:[e.jsx(ge,{className:"w-5 h-5"}),e.jsx("span",{children:t("register_passkey",n)})]})}),k&&!c&&!o&&e.jsx("button",{onClick:k,className:"w-full h-12 bg-transparent border dark:border-white/10 border-slate-200 text-muted hover:text-main font-medium rounded-2xl flex items-center justify-center transition-colors",children:t("do_this_later",n)})]}),e.jsxs("div",{className:"flex items-center justify-center gap-2 pb-4 opacity-50",children:[e.jsx(Ge,{className:"text-muted w-3 h-3"}),e.jsx("span",{className:"text-[10px] uppercase tracking-[0.2em] font-bold text-muted",children:t("e2e_encrypted",n)})]})]})},Xe=({email:i,verificationId:s,onNext:r,onError:l,apiBaseUrl:k="https://apis.casperid.com",apiKey:f,previewMode:p=!1,language:m="EN"})=>{const[n,c]=a.useState(["","","","","",""]),[d,A]=a.useState(!1),[h,S]=a.useState(!1),[b,o]=a.useState(""),[j,y]=a.useState(0),[w,T]=a.useState(s);a.useEffect(()=>{if(j>0){const x=setTimeout(()=>y(j-1),1e3);return()=>clearTimeout(x)}},[j]),a.useEffect(()=>{n.every(x=>x!=="")&&!d&&W()},[n]);const v=a.useCallback(x=>{o(""),c(N=>{const C=[...N],M=C.findIndex(F=>F==="");return M!==-1&&(C[M]=x),C})},[]),D=a.useCallback(()=>{o(""),c(x=>{const N=[...x];for(let C=N.length-1;C>=0;C--)if(N[C]!==""){N[C]="";break}return N})},[]);a.useEffect(()=>{const x=N=>{d||(/^[0-9]$/.test(N.key)?(N.preventDefault(),v(N.key)):(N.key==="Backspace"||N.key==="Delete")&&(N.preventDefault(),D()))};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[d,v,D]);const W=async()=>{const x=n.join("");if(x.length!==6){o(t("error_pin_incomplete",m));return}if(A(!0),o(""),p){setTimeout(()=>{A(!1),r("mock-session-token",null)},1e3);return}try{const N=await fetch(`${k}/api/auth/verify-otp`,{method:"POST",headers:{"Content-Type":"application/json","X-App-ID":f||""},body:JSON.stringify({verificationId:w,otp:x})});if(!N.ok){const M=await N.json().catch(()=>({}));throw new Error(M.error||`Verification failed with status ${N.status}`)}const C=await N.json();C.success&&C.sessionToken?r(C.sessionToken,C.userAccount,C.business_token):(o(C.error||t("invalid_code",m)),C.attemptsLeft!==void 0&&o(t("invalid_code_attempts",m).replace("{attempts}",C.attemptsLeft.toString())),c(["","","","","",""]),l==null||l(C.error||t("verification_failed",m)))}catch{const C=t("error_verify_failed",m);o(C),c(["","","","","",""]),l==null||l(C)}finally{A(!1)}},H=async()=>{if(!(j>0||h)){if(S(!0),o(""),p){setTimeout(()=>{S(!1),y(60),c(["","","","","",""])},800);return}try{const x=await fetch(`${k}/api/auth/resend-otp`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({verificationId:w})});if(!x.ok){const C=await x.json().catch(()=>({}));throw new Error(C.error||`Request failed with status ${x.status}`)}const N=await x.json();N.success?(y(60),c(["","","","","",""])):o(N.error||t("error_resend_failed",m))}catch{o(t("error_resend_failed",m))}finally{S(!1)}}},$=i.replace(/(.{2})(.*)(@.*)/,"$1***$3");return e.jsxs(E.motion.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.05},className:"flex-1 flex flex-col px-8 pt-12",children:[e.jsxs("div",{className:"space-y-2 mb-8",children:[e.jsx("h1",{className:"text-3xl font-bold tracking-tight text-main",children:t("verify_email",m)}),e.jsxs("p",{className:"text-muted text-sm font-medium",children:[t("enter_code",m)," ",e.jsx("span",{className:"text-main font-semibold",children:$})]})]}),e.jsx("div",{className:"flex justify-between gap-2 mb-6",children:n.map((x,N)=>e.jsxs("div",{className:`size-12 rounded-2xl dark:bg-black/20 bg-slate-100/50 flex items-center justify-center text-xl font-bold border transition-all ${x?"text-brand dark:border-brand-30 border-brand-50":"text-muted dark:border-white/10 border-slate-200"} ${b?"border-red-400 dark:border-red-500":""}`,children:[x,!x&&n.findIndex(C=>C==="")===N&&e.jsx("div",{className:"w-0.5 h-6 bg-brand animate-pulse"})]},N))}),b&&e.jsx("p",{className:"text-red-500 text-xs font-medium text-center mb-4",children:b}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 mb-8",children:[[1,2,3,4,5,6,7,8,9].map(x=>e.jsx("button",{onClick:()=>v(x.toString()),disabled:d,className:"h-14 rounded-2xl dark:hover:bg-slate-100 dark:bg-white/5 hover:bg-slate-100 flex items-center justify-center text-xl font-bold transition-colors text-main disabled:opacity-50",children:x},x)),e.jsx("div",{className:"h-14"}),e.jsx("button",{onClick:()=>v("0"),disabled:d,className:"h-14 rounded-2xl dark:hover:bg-slate-100 dark:bg-white/5 hover:bg-slate-100 flex items-center justify-center text-xl font-bold transition-colors text-main disabled:opacity-50",children:"0"}),e.jsx("button",{onClick:D,disabled:d,className:"h-14 rounded-2xl dark:hover:bg-slate-100 dark:bg-white/5 hover:bg-slate-100 flex items-center justify-center transition-colors text-main disabled:opacity-50",children:e.jsx(St,{className:"w-6 h-6"})})]}),e.jsxs("div",{className:"mt-auto pb-8 space-y-4",children:[e.jsx("button",{onClick:W,disabled:d||n.some(x=>x===""),className:"w-full h-14 bg-brand hover:bg-brand/90 text-white font-bold rounded-2xl transition-all shadow-lg shadow-brand flex items-center justify-center gap-2 group disabled:opacity-50 disabled:cursor-not-allowed",children:d?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-5 h-5 animate-spin"}),e.jsx("span",{children:t("verifying",m)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:t("verify",m)}),e.jsx(ze,{className:"w-5 h-5 group-hover:translate-x-1 transition-transform"})]})}),e.jsx("button",{onClick:H,disabled:j>0||h,className:"w-full h-14 dark:bg-white/5 hover:dark:bg-white/10 bg-slate-100 hover:bg-slate-200 text-muted font-bold rounded-2xl transition-all border dark:border-white/10 border-slate-200 flex items-center justify-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",children:h?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-4 h-4 animate-spin"}),e.jsx("span",{children:t("sending",m)})]}):j>0?e.jsxs("span",{children:[t("resend_code",m)," (",j,"s)"]}):e.jsxs(e.Fragment,{children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{children:t("resend_code",m)})]})})]})]})},Qe=({onNext:i,onSkip:s,language:r="EN"})=>e.jsxs(E.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col",children:[e.jsxs("div",{className:"p-6 pb-2",children:[e.jsxs("div",{className:"flex justify-between items-center mb-4",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-widest text-brand/80",children:t("verification_step",r)}),e.jsx("span",{className:"text-xs font-bold text-muted",children:t("kyc_required",r)})]}),e.jsx("div",{className:"w-full bg-brand-10 h-1.5 rounded-full overflow-hidden",children:e.jsx("div",{className:"bg-brand h-full rounded-full",style:{width:"40%"}})})]}),e.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-8 text-center gap-8",children:[e.jsxs("div",{className:"relative group",children:[e.jsx("div",{className:"absolute inset-0 bg-cyan-400/20 blur-3xl rounded-full scale-75 group-hover:scale-100 transition-transform duration-500"}),e.jsx("div",{className:"relative w-32 h-32 rounded-full bg-gradient-to-tr from-brand-20 to-brand-5 flex items-center justify-center border border-brand-30 shadow-inner",children:e.jsx(Ve,{className:"w-16 h-16 text-brand"})}),e.jsx("div",{className:"absolute bottom-1 right-1 w-8 h-8 rounded-full glass-container border-2 border-brand flex items-center justify-center",children:e.jsx(Se,{className:"w-4 h-4 text-brand"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight text-main leading-tight",children:t("security_upgrade_required",r)}),e.jsx("p",{className:"text-muted text-base leading-relaxed font-medium",children:t("security_upgrade_desc",r)})]}),e.jsxs("div",{className:"flex flex-wrap justify-center gap-2",children:[e.jsx("span",{className:"px-3 py-1 bg-brand/10 rounded-xl text-[10px] font-bold text-brand uppercase tracking-tighter border border-brand-10",children:t("biometric_secure",r)}),e.jsx("span",{className:"px-3 py-1 bg-cyan-400/10 rounded-xl text-[10px] font-bold text-cyan-500 uppercase tracking-tighter border border-cyan-400/10",children:t("zero_knowledge",r)})]})]}),e.jsxs("div",{className:"p-8 space-y-4",children:[e.jsx("button",{onClick:i,className:"w-full bg-brand hover:bg-brand/90 text-white rounded-2xl py-4 font-bold text-lg shadow-xl shadow-brand transition-all active:scale-[0.98]",children:t("start_upgrade",r)}),s&&e.jsx("button",{onClick:s,className:"w-full text-muted text-sm font-bold hover:text-main transition-colors",children:t("do_this_later",r)})]})]}),_e=["Position your face in the frame","Blink 3 times naturally","Open your mouth","Hold still","Processing verification..."],Ie=(i,s)=>Math.sqrt(Math.pow(i.x-s.x,2)+Math.pow(i.y-s.y,2)),et=({requestId:i,onNext:s,onError:r,apiBaseUrl:l="https://apis.casperid.com",apiKey:k="",previewMode:f=!1,language:p="EN"})=>{const m=a.useRef(null),n=a.useRef(null),c=a.useRef(null),d=a.useRef([]),A=a.useRef(null),h=a.useRef(null),[S,b]=a.useState(0),[o,j]=a.useState(!1),[y,w]=a.useState(""),[T,v]=a.useState(!1),[D,W]=a.useState(!1),[H,$]=a.useState(0),[x,N]=a.useState(!1),[C,M]=a.useState(0),F=a.useRef(0),L=a.useRef(0),G=a.useRef(!1),Z=a.useRef(0),re=a.useRef(!1),ne=g=>{F.current=g,b(g)},Q=g=>{L.current=g,$(g)},ee=g=>{G.current=g,N(g)},O=g=>{Z.current=g,M(g)},oe=S===0?0:S===1?H/3*100:S===2?C:S===3?100:Math.min(100,Math.round(S/(_e.length-1)*100));a.useEffect(()=>((async()=>{try{const{FaceMesh:V}=await Promise.resolve().then(()=>require("./face_mesh-fEvyDoPt.cjs")).then(P=>P.face_mesh),{Camera:J}=await Promise.resolve().then(()=>require("./camera_utils-wchtqrQn.cjs")).then(P=>P.camera_utils),le=new V({locateFile:P=>`https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh/${P}`});if(le.setOptions({maxNumFaces:1,refineLandmarks:!0,minDetectionConfidence:.3,minTrackingConfidence:.3}),console.log("✅ MediaPipe FaceMesh loaded successfully"),le.onResults(Y),A.current=le,m.current){const P=new J(m.current,{onFrame:async()=>{A.current&&m.current&&await A.current.send({image:m.current})},width:640,height:480});await P.start(),h.current=P,j(!0),console.log("📹 Camera started successfully")}}catch(V){console.error("FaceMesh initialization error:",V),V.name==="NotAllowedError"?(W(!0),w("Camera permission denied. Please enable camera access.")):w("Unable to initialize face detection. Please try again."),r==null||r("FaceMesh initialization failed")}})(),()=>{h.current&&h.current.stop(),c.current&&c.current.getTracks().forEach(V=>V.stop())}),[]);const Y=g=>{if(!n.current||T)return;const V=n.current,J=V.getContext("2d");if(!(!J||!g.image))if(J.save(),J.clearRect(0,0,V.width,V.height),J.translate(V.width,0),J.scale(-1,1),J.drawImage(g.image,0,0,V.width,V.height),J.restore(),g.multiFaceLandmarks&&g.multiFaceLandmarks.length>0){const le=g.multiFaceLandmarks[0];ce(le)}else console.log("⚠️ No face detected in frame")},ce=g=>{const V=F.current,J=L.current,le=G.current;if(V===0){const P=g[1],K=P.x>.35&&P.x<.65&&P.y>.35&&P.y<.65;Math.random()<.05&&console.log(`📍 Face position: x=${P.x.toFixed(2)}, y=${P.y.toFixed(2)} (centered: ${K})`),K&&(console.log("✅ Face centered! Advancing to blink detection..."),setTimeout(()=>ne(1),500))}else if(V===1){const P=Ie(g[159],g[145]),K=Ie(g[33],g[133]),de=P/K;if(Math.random()<.1&&console.log(`👁️ Eye ratio: ${de.toFixed(3)} (threshold: 0.16, ${de<.16?"CLOSED":"OPEN"})`),de<.16)le||(console.log("👁️ Blink started (eye closed)"),ee(!0));else if(le){const B=J+1;console.log(`✅ Blink detected! Count: ${B}/3`),ee(!1),Q(B),X(),B>=3&&(console.log("🎉 All 3 blinks completed! Moving to mouth opening step..."),setTimeout(()=>{ne(2),O(0)},300))}}else if(V===2){const P=g[13],K=g[14],de=Ie(P,K),B=g[10],ie=g[152],he=Ie(B,ie),te=de/he,fe=Math.min(te/.15*100,100);O(fe),d.current.length<15&&X(),te>.12&&d.current.length>=10&&!re.current&&(re.current=!0,X(),setTimeout(()=>{ne(3),se()},500))}},X=()=>{!n.current||d.current.length>=25||n.current.toBlob(g=>{g&&d.current.push(g)},"image/jpeg",.8)},se=async()=>{var g,V,J,le;if(v(!0),ne(4),f){setTimeout(()=>{v(!1),s(!0)},2e3);return}try{const P=new FormData,K=!!i,de=K?`${l}/api/v2/verification/liveness`:`${l}/api/ai/verify-liveness-sequence`;if(K){P.append("requestId",i);const te={totalFrames:d.current.length,stepSequence:["blink","open_mouth"],timestamp:Date.now()};P.append("metadata",JSON.stringify(te)),d.current.slice(-10).forEach((je,Ne)=>{P.append("imageFrames",je,`frame_${Ne}.jpg`)})}else d.current.forEach((te,fe)=>{P.append(`frame_${fe}`,te,`frame_${fe}.jpg`)}),P.append("totalFrames",d.current.length.toString()),P.append("stepSequence",JSON.stringify(["blink","open_mouth"]));const B=await fetch(de,{method:"POST",headers:{...k?{"X-App-Id":k}:{}},body:P,credentials:"include"});if(!B.ok){const te=await B.json().catch(()=>({}));throw new Error(te.error||`Liveness check failed with status ${B.status}`)}const ie=await B.json();if(K?ie.success&&(((g=ie.liveness)==null?void 0:g.success)||((V=ie.liveness)==null?void 0:V.status)==="completed"||((J=ie.liveness)==null?void 0:J.status)==="approved"):ie.success&&ie.passed)h.current&&h.current.stop(),c.current&&c.current.getTracks().forEach(te=>te.stop()),s(!0);else{const te=ie.error||((le=ie.liveness)==null?void 0:le.error)||"Liveness check failed. Please try again.";w(te),ne(0),Q(0),O(0),d.current=[],v(!1),re.current=!1}}catch{w("Verification failed. Please try again."),ne(0),Q(0),O(0),d.current=[],v(!1),r==null||r("Liveness submission failed")}},q=()=>{w(""),ne(0),Q(0),O(0),d.current=[],v(!1),re.current=!1};return D?e.jsxs(E.motion.div,{initial:{opacity:0},animate:{opacity:1},className:"flex-1 flex flex-col items-center justify-center px-8 text-center bg-black",children:[e.jsx("div",{className:"w-16 h-16 text-red-500 mb-6 text-5xl",children:"⚠️"}),e.jsx("h2",{className:"text-xl font-bold text-white mb-3",children:"Camera Access Required"}),e.jsx("p",{className:"text-gray-400 text-sm mb-6",children:"Please enable camera access in your browser settings to continue with face verification."}),e.jsx("button",{onClick:()=>window.location.reload(),className:"px-6 py-3 bg-[#8651e1] text-white rounded-2xl font-bold",children:"Try Again"})]}):e.jsxs(E.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col relative bg-black overflow-hidden",children:[e.jsx("video",{ref:m,className:"hidden",playsInline:!0,muted:!0}),e.jsx("div",{className:"absolute inset-0 z-0 bg-gradient-to-b from-transparent via-[#8651e1]/5 to-[#8651e1]/10 pointer-events-none"}),e.jsx("div",{className:"relative z-20 flex-1 flex flex-col items-center justify-center pt-8",children:e.jsxs("div",{className:"relative w-72 h-96 flex items-center justify-center",children:[e.jsxs("div",{className:"absolute inset-0 rounded-[3rem] overflow-hidden border-2 border-slate-200 dark:border-white/10 shadow-2xl",children:[e.jsx("canvas",{ref:n,width:640,height:480,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-[#8651e1]/10 mix-blend-overlay"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black via-transparent to-transparent h-1/3 mt-auto"})]}),e.jsx("div",{className:"absolute inset-0 z-30 pointer-events-none",children:[{t:"30%",l:"50%"},{t:"35%",l:"40%"},{t:"35%",l:"60%"},{t:"45%",l:"50%"},{t:"52%",l:"35%"},{t:"52%",l:"65%"},{t:"60%",l:"45%"},{t:"60%",l:"55%"},{t:"70%",l:"50%"}].map((g,V)=>e.jsx(E.motion.div,{initial:{scale:0,opacity:0},animate:{scale:[0,1.5,1],opacity:oe>V*11?1:0},className:"absolute w-2 h-2 bg-[#6DE8EC] rounded-full shadow-[0_0_12px_#6DE8EC]",style:{top:g.t,left:g.l}},V))}),e.jsxs("div",{className:"absolute -inset-6 z-40",children:[e.jsx(E.motion.div,{animate:{opacity:[.3,1,.3]},transition:{duration:2,repeat:1/0},className:"absolute top-0 left-0 w-20 h-20 border-t-4 border-l-4 border-[#14b8a6] rounded-tl-[3.5rem]"}),e.jsx(E.motion.div,{animate:{opacity:[.3,1,.3]},transition:{duration:2,repeat:1/0},className:"absolute top-0 right-0 w-20 h-20 border-t-4 border-r-4 border-[#14b8a6] rounded-tr-[3.5rem]"}),e.jsx(E.motion.div,{animate:{opacity:[.3,1,.3]},transition:{duration:2,repeat:1/0},className:"absolute bottom-0 left-0 w-20 h-20 border-b-4 border-l-4 border-[#14b8a6] rounded-bl-[3.5rem]"}),e.jsx(E.motion.div,{animate:{opacity:[.3,1,.3]},transition:{duration:2,repeat:1/0},className:"absolute bottom-0 right-0 w-20 h-20 border-b-4 border-r-4 border-[#14b8a6] rounded-br-[3.5rem]"})]}),e.jsx(E.motion.div,{animate:{top:["0%","100%"]},transition:{duration:3,repeat:1/0,ease:"linear"},className:"absolute left-0 right-0 h-1 bg-gradient-to-r from-transparent via-[#6DE8EC] to-transparent shadow-[0_0_15px_#6DE8EC] z-50 pointer-events-none",style:{borderRadius:"100%"}})]})}),e.jsxs("div",{className:"relative z-50 px-8 pb-20 pt-4 flex flex-col items-center gap-6",children:[y?e.jsxs(E.motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},className:"bg-red-900/30 border border-red-500/50 p-6 rounded-3xl w-full text-center",children:[e.jsx("p",{className:"text-red-400 font-bold text-lg mb-4",children:y}),e.jsx("button",{onClick:q,className:"px-8 py-3 bg-red-500 hover:bg-red-600 text-white rounded-xl font-bold transition-colors",children:"Try Again"})]}):e.jsx(E.AnimatePresence,{mode:"wait",children:e.jsx(E.motion.div,{initial:{opacity:0,y:10,filter:"blur(5px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},exit:{opacity:0,y:-10,filter:"blur(5px)"},className:"text-white text-center font-bold text-xl leading-tight min-h-[3rem] flex items-center justify-center drop-shadow-lg flex-col gap-2",children:T&&S===4?e.jsxs("span",{className:"flex items-center gap-3",children:[e.jsxs("svg",{className:"animate-spin h-5 w-5",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4",fill:"none"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),_e[S]]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:_e[S]}),S===1&&e.jsxs("span",{className:"text-[#6DE8EC] text-2xl",children:["(",H,"/3)"]})]})},S===1?`${_e[S]}-${H}`:_e[S])}),e.jsx("div",{className:"w-full max-w-[240px] h-1.5 bg-slate-200 dark:bg-white/10 rounded-full overflow-hidden",children:e.jsx(E.motion.div,{className:"h-full bg-gradient-to-r from-[#8651e1] to-[#6DE8EC]",animate:{width:`${oe}%`},transition:{duration:.3}})}),!y&&e.jsxs("div",{className:"flex items-center gap-2 text-gray-400 text-xs",children:[e.jsx("div",{className:`w-2 h-2 rounded-full ${o?"bg-[#6DE8EC] shadow-[0_0_8px_#6DE8EC]":"bg-yellow-500 animate-pulse"}`}),e.jsx("span",{className:"uppercase tracking-widest font-bold",children:o?"LIVE CAMERA":"INITIALIZING..."})]})]})]})},Zt=[{id:"passport",title:"Passport",desc:"All countries supported",Icon:We},{id:"drivers_license",title:"Driver License",desc:"Government issued card",Icon:He},{id:"national_id",title:"ID Card",desc:"National identity document",Icon:Me}],tt=({onNext:i,language:s="EN"})=>e.jsxs(E.motion.div,{initial:{opacity:0,x:20},animate:{opacity:1,x:0},exit:{opacity:0,x:-20},className:"flex-1 px-6 pt-4 flex flex-col",children:[e.jsx("h3",{className:"text-2xl font-bold mb-2 text-main",children:t("verify_identity",s)}),e.jsx("p",{className:"text-muted text-sm mb-8 leading-relaxed",children:t("choose_document",s)}),e.jsxs("div",{className:"space-y-4 overflow-y-auto pr-1 pb-6",children:[Zt.map(({id:r,title:l,desc:k,Icon:f})=>e.jsxs("button",{onClick:()=>i(r),className:"w-full group cursor-pointer dark:bg-white/5 bg-slate-100/50 border dark:border-white/10 border-slate-200 rounded-2xl p-5 flex items-center gap-4 hover:dark:bg-brand/15 hover:bg-brand/5 hover:dark:border-brand-40 hover:border-brand-30 transition-all transform hover:-translate-y-1",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl dark:bg-slate-800/50 bg-white flex items-center justify-center text-brand group-hover:bg-brand/20 transition-colors border dark:border-transparent border-slate-100",children:e.jsx(f,{className:"w-8 h-8"})}),e.jsxs("div",{className:"flex-1 text-left",children:[e.jsx("h4",{className:"font-bold text-base text-main",children:t(r,s)}),e.jsx("p",{className:"text-xs text-muted font-medium",children:t(`${r}_desc`,s)})]}),e.jsx(De,{className:"text-brand w-5 h-5"})]},r)),e.jsxs("div",{className:"mt-8 relative h-32 w-full rounded-2xl overflow-hidden dark:bg-white/5 bg-slate-100/30 flex items-center justify-center border border-dashed dark:border-brand-30 border-brand-40",children:[e.jsx("div",{className:"absolute inset-0 opacity-10 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-brand via-transparent to-transparent"}),e.jsxs("div",{className:"text-center z-10",children:[e.jsx(we,{className:"text-brand/40 w-10 h-10 mx-auto mb-1"}),e.jsx("p",{className:"text-[10px] text-muted uppercase tracking-tighter font-bold",children:"Encrypted E2E"})]})]})]})]}),Xt=i=>({passport:t("passport",i),drivers_license:t("drivers_license",i),national_id:t("national_id",i)}),st=({requestId:i,documentType:s,onNext:r,onError:l,apiBaseUrl:k="https://apis.casperid.com",apiKey:f="",previewMode:p=!1,language:m="EN"})=>{const n=a.useRef(null),c=a.useRef(null),d=a.useRef(null),[A,h]=a.useState(!1),[S,b]=a.useState(null),[o,j]=a.useState(null),[y,w]=a.useState(!1),[T,v]=a.useState(""),[D,W]=a.useState("front"),[H,$]=a.useState(null);a.useEffect(()=>((async()=>{try{const F=await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment",width:{ideal:1280},height:{ideal:720}}});d.current=F,n.current&&(n.current.srcObject=F,n.current.onloadedmetadata=()=>{h(!0)})}catch{try{const L=await navigator.mediaDevices.getUserMedia({video:{facingMode:"user",width:{ideal:1280},height:{ideal:720}}});d.current=L,n.current&&(n.current.srcObject=L,n.current.onloadedmetadata=()=>{h(!0)})}catch{v(t("unable_access_camera",m)),l==null||l("Camera access failed")}}})(),()=>{d.current&&d.current.getTracks().forEach(F=>F.stop()),o&&URL.revokeObjectURL(o)}),[l]);const x=async()=>{if(!n.current||!c.current)return;const M=c.current,F=n.current,L=M.getContext("2d");L&&(M.width=F.videoWidth,M.height=F.videoHeight,L.drawImage(F,0,0),M.toBlob(G=>{G&&(b(G),j(URL.createObjectURL(G)))},"image/jpeg",.9))},N=()=>{o&&URL.revokeObjectURL(o),b(null),j(null),v("")},C=async()=>{if(w(!0),p){setTimeout(()=>{w(!1),r({first_name:"JOHN",last_name:"DOE",date_of_birth:"01 JAN 1990",nationality:""},"mock-upload-id-789",{frontImageUrl:"mock-front-url",frontImageFileId:"mock-front-id",backImageUrl:"mock-back-url",backImageFileId:"mock-back-id"})},2e3);return}if(!S){w(!1);return}if(D==="front"&&s!=="passport"){$(S),b(null),j(null),W("back"),w(!1);return}w(!0),v("");try{const M=new FormData;M.append("document_type",s),H?(M.append("front_image",H,"front.jpg"),M.append("back_image",S,"back.jpg")):M.append("front_image",S,"document.jpg");const F=await fetch(`${k}/api/v2/verification/layer3/documents/upload`,{method:"POST",body:M,credentials:"include",headers:{"X-Request-Id":i,...f?{"X-App-Id":f}:{}}});if(!F.ok){const G=await F.json().catch(()=>({}));throw new Error(G.error||`Document upload failed with status ${F.status}`)}const L=await F.json();L.success&&L.extracted_data?(d.current&&d.current.getTracks().forEach(G=>G.stop()),r(L.extracted_data,L.upload_id||"",{frontImageUrl:L.front_image_url,frontImageFileId:L.front_image_file_id,backImageUrl:L.back_image_url,backImageFileId:L.back_image_file_id})):(v(L.error||"Failed to process document. Please try again."),w(!1))}catch{v("Upload failed. Please try again."),w(!1),l==null||l("Document upload failed")}};return e.jsxs(E.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col relative",children:[e.jsx("canvas",{ref:c,className:"hidden"}),e.jsxs("div",{className:"absolute inset-0 z-0",children:[e.jsx("div",{className:"w-full h-full bg-main opacity-10 flex items-center justify-center",children:e.jsx("div",{className:"w-full h-full opacity-30 bg-[radial-gradient(circle_at_center,_var(--tw-gradient-stops))] from-[#6DE8EC]/20 via-transparent to-transparent"})}),e.jsx("div",{className:"absolute inset-0 bg-black/30 backdrop-blur-[2px]"})]}),e.jsx("div",{className:"relative z-10 p-6 flex flex-col items-center",children:e.jsx("div",{className:"text-center px-4 py-2 bg-brand-10 backdrop-blur-xl rounded-full border border-brand-10",children:e.jsx("h3",{className:"text-main text-sm font-medium tracking-wide uppercase",children:t("scan_instruction",m).replace("{side}",t(D,m)).replace("{docType}",Xt(m)[s])})})}),e.jsx("div",{className:"relative z-10 flex-1 flex items-center justify-center px-6",children:e.jsxs("div",{className:"w-full aspect-[1.58/1] relative",children:[o?e.jsx("img",{src:o,alt:"Captured document",className:"absolute inset-0 w-full h-full object-cover rounded-2xl"}):e.jsx("video",{ref:n,autoPlay:!0,playsInline:!0,muted:!0,className:"absolute inset-0 w-full h-full object-cover rounded-2xl"}),e.jsx("div",{className:"absolute inset-0 border border-[#6DE8EC] rounded-2xl shadow-[0_0_20px_rgba(109,232,236,0.3),inset_0_0_15px_rgba(109,232,236,0.2)]"}),e.jsx("div",{className:"absolute top-0 left-0 w-8 h-8 border-t-4 border-l-4 border-[#6DE8EC] rounded-tl-2xl"}),e.jsx("div",{className:"absolute top-0 right-0 w-8 h-8 border-t-4 border-r-4 border-[#6DE8EC] rounded-tr-2xl"}),e.jsx("div",{className:"absolute bottom-0 left-0 w-8 h-8 border-b-4 border-l-4 border-[#6DE8EC] rounded-bl-2xl"}),e.jsx("div",{className:"absolute bottom-0 right-0 w-8 h-8 border-b-4 border-r-4 border-[#6DE8EC] rounded-br-2xl"}),!o&&A&&e.jsx(E.motion.div,{animate:{top:["0%","100%","0%"]},transition:{duration:4,repeat:1/0,ease:"linear"},className:"absolute left-0 w-full h-[2px] bg-gradient-to-r from-transparent via-[#6DE8EC] to-transparent opacity-50"}),!A&&!o&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/50 rounded-2xl",children:e.jsx(me,{className:"w-8 h-8 text-[#6DE8EC] animate-spin"})})]})}),T&&e.jsxs("div",{className:"relative z-10 mx-6 mb-4 p-4 bg-red-500/20 border border-red-500/30 rounded-xl flex items-center gap-3",children:[e.jsx(xe,{className:"w-5 h-5 text-red-500 shrink-0"}),e.jsx("p",{className:"text-red-400 text-sm font-medium",children:T})]}),e.jsxs("div",{className:"relative z-10 p-8 glass-container backdrop-blur-2xl border-t border-brand-10 rounded-t-3xl",children:[e.jsx("p",{className:"text-muted text-xs text-center mb-6 font-medium",children:t(o?"review_capture":"align_document",m)}),e.jsx("div",{className:"flex items-center justify-between gap-4",children:o?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:N,disabled:y,className:"w-12 h-12 rounded-xl bg-brand-5 flex items-center justify-center text-muted disabled:opacity-50",children:e.jsx(zt,{className:"w-6 h-6"})}),e.jsx("button",{onClick:C,disabled:y,className:"flex-1 bg-brand hover:bg-brand/90 text-white h-14 rounded-2xl flex items-center justify-center gap-2 font-bold text-lg transition-all active:scale-95 shadow-[0_0_25px_rgba(130,66,240,0.5)] disabled:opacity-70",children:y?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-6 h-6 animate-spin"}),e.jsx("span",{children:t("processing",m)})]}):e.jsx("span",{children:t(D==="front"&&s!=="passport"?"next_back_side":"confirm",m)})}),e.jsx("div",{className:"w-12 h-12"})," "]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{className:"w-12 h-12 rounded-xl bg-brand-5 flex items-center justify-center text-muted",children:e.jsx(Et,{className:"w-6 h-6"})}),e.jsxs("button",{onClick:x,disabled:!A,className:"flex-1 bg-brand hover:bg-brand/90 text-white h-14 rounded-2xl flex items-center justify-center gap-2 font-bold text-lg transition-all active:scale-95 shadow-[0_0_25px_rgba(130,66,240,0.5)] disabled:opacity-50",children:[e.jsx(Ct,{className:"w-6 h-6"}),e.jsx("span",{children:t("capture",m)})]}),e.jsx("button",{className:"w-12 h-12 rounded-xl bg-brand-5 flex items-center justify-center text-muted",children:e.jsx(It,{className:"w-6 h-6"})})]})}),e.jsx("div",{className:"w-32 h-1.5 bg-brand-10 rounded-full mx-auto mt-8"})]})]})},it=({requestId:i,documentType:s,extractedData:r,uploadId:l,frontImageUrl:k,frontImageFileId:f,backImageUrl:p,backImageFileId:m,onNext:n,onRetake:c,onError:d,apiBaseUrl:A="https://apis.casperid.com",apiKey:h="",previewMode:S=!1,language:b="EN"})=>{const[o,j]=a.useState({firstName:r.first_name||"",lastName:r.last_name||"",documentNumber:r.document_number||"",dateOfBirth:r.date_of_birth||"",nationality:r.nationality||"",gender:r.gender||""}),[y,w]=a.useState(!1),[T,v]=a.useState(""),D=(x,N)=>{j(C=>({...C,[x]:N}))},W=async()=>{if(!o.firstName||!o.lastName||!o.documentNumber){v(t("error_required_fields",b));return}if(w(!0),v(""),S){setTimeout(()=>{w(!1),n({first_name:o.firstName,last_name:o.lastName,document_number:o.documentNumber,date_of_birth:o.dateOfBirth,nationality:o.nationality,gender:o.gender,document_type:s})},1500);return}try{const x=await fetch(`${A}/api/v2/verification/layer3/submit`,{method:"POST",headers:{"Content-Type":"application/json",...h?{"X-App-Id":h}:{}},credentials:"include",body:JSON.stringify({upload_id:l,front_image_url:k,front_image_file_id:f,back_image_url:p,back_image_file_id:m,liveness_verified:!1,document_data:{first_name:o.firstName,last_name:o.lastName,document_number:o.documentNumber,date_of_birth:o.dateOfBirth,nationality:o.nationality,gender:o.gender,document_type:s}})});if(!x.ok){const C=await x.json().catch(()=>({}));throw new Error(C.error||`Data submission failed with status ${x.status}`)}const N=await x.json();N.success?n({first_name:o.firstName,last_name:o.lastName,document_number:o.documentNumber,date_of_birth:o.dateOfBirth,nationality:o.nationality,gender:o.gender,document_type:s}):(v(N.error||"Failed to submit data. Please try again."),w(!1))}catch{v("Failed to submit data. Please try again."),w(!1),d==null||d("Data submission failed")}},H=r.confidence||0,$=Math.round(H);return e.jsxs(E.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"flex-1 overflow-y-auto px-6 pb-6",children:[e.jsx("div",{className:"flex gap-1 mb-6",children:[1,2,3,0].map((x,N)=>e.jsx("div",{className:`h-1 flex-1 rounded-xl ${x?"bg-brand":"bg-brand/20"}`},N))}),e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-main mb-2",children:t("review_data",b)}),e.jsx("p",{className:"text-muted text-sm leading-relaxed",children:t("verify_data_desc",b)})]}),H>0&&e.jsxs("div",{className:"mb-6 p-3 rounded-xl bg-brand-5 border border-brand-10",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("span",{className:"text-xs font-semibold text-muted",children:t("ocr_confidence",b)}),e.jsxs("span",{className:`text-xs font-bold ${$>=80?"text-green-500":$>=60?"text-yellow-500":"text-red-500"}`,children:[$,"%"]})]}),e.jsx("div",{className:"w-full h-1.5 bg-brand-10 rounded-full overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${$>=80?"bg-green-500":$>=60?"bg-yellow-500":"bg-red-500"}`,style:{width:`${$}%`}})}),$<80&&e.jsx("p",{className:"text-[10px] text-yellow-500 mt-2",children:t("verify_data_carefully",b)})]}),T&&e.jsxs("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/30 rounded-xl flex items-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4 text-red-500 shrink-0"}),e.jsx("p",{className:"text-red-400 text-xs font-medium",children:T})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-xs font-bold uppercase tracking-[0.15em] text-brand ml-1",children:t("first_name",b)||"First Name"}),e.jsxs("div",{className:"flex items-center px-1 transition-all",children:[e.jsx(Ft,{className:"text-brand mr-3 w-5 h-5 shrink-0"}),e.jsx("div",{className:"flex flex-col w-full",children:e.jsx("input",{className:"bg-transparent border-none p-0 w-full focus:ring-0 text-main font-bold text-lg focus:outline-none placeholder:text-muted",type:"text",value:o.firstName,onChange:x=>D("firstName",x.target.value),placeholder:t("enter_first_name",b)||"First name"})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-xs font-bold uppercase tracking-[0.15em] text-brand ml-1",children:t("last_name",b)||"Last Name"}),e.jsx("div",{className:"flex items-center px-1 transition-all",children:e.jsx("div",{className:"flex flex-col w-full",children:e.jsx("input",{className:"bg-transparent border-none p-0 w-full focus:ring-0 text-main font-bold text-lg focus:outline-none placeholder:text-muted",type:"text",value:o.lastName,onChange:x=>D("lastName",x.target.value),placeholder:t("enter_last_name",b)||"Last name"})})})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-xs font-bold uppercase tracking-[0.15em] text-brand ml-1",children:t("id_number",b)}),e.jsxs("div",{className:"flex items-center px-1 transition-all",children:[e.jsx(He,{className:"text-brand mr-4 w-6 h-6 shrink-0"}),e.jsx("input",{className:"bg-transparent border-none p-0 w-full focus:ring-0 text-main font-bold text-lg focus:outline-none placeholder:text-muted",type:"text",value:o.documentNumber,onChange:x=>D("documentNumber",x.target.value),placeholder:t("enter_doc_number",b)})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-xs font-bold uppercase tracking-[0.15em] text-brand ml-1",children:t("date_of_birth",b)}),e.jsxs("div",{className:"flex items-center px-1 transition-all",children:[e.jsx(Nt,{className:"text-brand mr-4 w-6 h-6 shrink-0"}),e.jsx("input",{className:"bg-transparent border-none p-0 w-full focus:ring-0 text-main font-bold text-lg focus:outline-none placeholder:text-muted",type:"text",value:o.dateOfBirth,onChange:x=>D("dateOfBirth",x.target.value),placeholder:t("date_format",b)})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx("label",{className:"text-xs font-bold uppercase tracking-[0.15em] text-brand ml-1",children:t("nationality",b)}),e.jsxs("div",{className:"flex items-center px-1 transition-all",children:[e.jsx(We,{className:"text-brand mr-4 w-6 h-6 shrink-0"}),e.jsx("input",{className:"bg-transparent border-none p-0 w-full focus:ring-0 text-main font-bold text-lg focus:outline-none placeholder:text-muted",type:"text",value:o.nationality,onChange:x=>D("nationality",x.target.value),placeholder:t("enter_nationality",b)})]})]}),e.jsxs("div",{className:"mt-8 relative h-32 w-full rounded-2xl overflow-hidden border border-brand-20 group",children:[e.jsx("div",{className:"absolute inset-0 bg-gradient-to-tr from-brand-20 to-cyan-500/10 blur-sm"}),e.jsxs("div",{className:"absolute inset-0 bg-brand/10 flex flex-col items-center justify-center p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ve,{className:"text-brand w-5 h-5"}),e.jsx("span",{className:"text-xs font-bold text-main",children:t("scanned_successfully",b)})]}),c&&e.jsx("button",{onClick:c,className:"mt-2 text-[10px] text-brand underline font-medium",type:"button",children:t("retake_photo",b)})]})]})]}),e.jsxs("div",{className:"mt-8",children:[e.jsx("button",{onClick:W,disabled:y,className:"w-full bg-brand hover:bg-brand/90 text-white font-bold py-4 rounded-2xl shadow-lg shadow-brand flex items-center justify-center gap-2 transition-transform active:scale-95 disabled:opacity-70",children:y?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-5 h-5 border-2 border-white/30 border-t-white rounded-full animate-spin"}),e.jsx("span",{children:t("submitting",b)})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{children:t("confirm_mint",b)}),e.jsx(Vt,{className:"w-5 h-5"})]})}),e.jsx("p",{className:"text-center text-[10px] mt-4 text-muted",children:t("secured_by_casper",b)})]})]})},Qt=(i,s)=>i==="layer_1"?{processing:{title:t("generating_wallet",s),subtitle:t("wallet_subtitle",s)},minting:{title:t("minting_did",s),subtitle:t("did_subtitle",s)},completed:{title:t("identity_created",s),subtitle:t("identity_created_subtitle",s)},failed:{title:t("setup_failed",s),subtitle:t("setup_failed_subtitle",s)}}:i==="layer_2"?{processing:{title:t("processing_liveness",s),subtitle:t("processing_subtitle",s)},minting:{title:t("minting_identity",s),subtitle:t("minting_subtitle",s)},completed:{title:t("identity_verified",s),subtitle:t("identity_verified_subtitle",s)},failed:{title:t("verification_failed",s),subtitle:t("verification_failed_subtitle",s)}}:{processing:{title:t("processing_documents",s),subtitle:t("processing_subtitle",s)},minting:{title:t("submitting_for_review",s),subtitle:t("submitting_review_subtitle",s)},completed:{title:t("verification_submitted",s),subtitle:t("verification_submitted_subtitle",s)},failed:{title:t("verification_failed",s),subtitle:t("verification_failed_subtitle",s)}},at=({tier:i,sessionToken:s,requestId:r,onNext:l,onError:k,apiBaseUrl:f="https://apis.casperid.com",apiKey:p="",previewMode:m=!1,language:n="EN"})=>{const[c,d]=a.useState("processing"),[A,h]=a.useState(0),[S,b]=a.useState(""),[o,j]=a.useState(null),[y,w]=a.useState(null),[T,v]=a.useState(null),[D,W]=a.useState(null),H=a.useRef(!1),x=Qt(i,n)[c];a.useEffect(()=>{H.current||(H.current=!0,m?N():C())},[]);const N=async()=>{d("processing"),h(20),await Z(1e3),h(50),await Z(1e3),d("minting"),h(70),await Z(1e3),h(100),d("completed"),i==="layer_1"?(j("account-hash-abc123..."),W("casper-user-1234"),w("did:casper:abc123...")):v("mock-credential-hash-xyz"),await Z(1500),l({wallet:"account-hash-abc123...",didAddress:"did:casper:abc123...",credentialHash:"mock-credential-hash-xyz"})},C=async()=>{try{i==="layer_1"?await M():await G()}catch(ee){const O=ee instanceof Error?ee.message:"Setup failed";b(O),d("failed"),k==null||k(O)}},M=async()=>{var ce;d("processing"),h(10);const ee=await fetch(`${f}/api/passkey/wallet/generate`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`,...p?{"X-App-Id":p}:{}},credentials:"include"});if(!ee.ok){const X=await ee.json().catch(()=>({}));throw new Error(X.error||"Failed to generate wallet")}const O=await ee.json();if(!O.success||!((ce=O.walletInfo)!=null&&ce.walletAddress))throw new Error(O.error||"Wallet generation failed");j(O.walletInfo.walletAddress),O.walletInfo.humanId&&W(O.walletInfo.humanId),h(50),d("minting"),h(60);const oe=await fetch(`${f}/api/passkey/did/mint`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s}`,...p?{"X-App-Id":p}:{}},credentials:"include"});if(!oe.ok){const X=await oe.json().catch(()=>({}));throw new Error(X.error||"Failed to mint DID")}const Y=await oe.json();if(!Y.success)throw new Error(Y.error||"DID minting failed");w(Y.did_address),v(Y.transaction_hash),h(100),d("completed"),await Z(1500),l({wallet:O.walletInfo.walletAddress,didAddress:Y.did_address,credentialHash:Y.transaction_hash})},F=async()=>{var oe,Y,ce,X;if(d("processing"),h(20),!r)throw new Error("No verification request ID provided");const ee=10,O=1500;for(let se=0;se<ee;se++)try{const q=await fetch(`${f}/api/v2/verification/${r}/status`,{method:"GET",headers:{"Content-Type":"application/json",...p?{"X-App-Id":p}:{}},credentials:"include"});if(!q.ok)throw new Error("Failed to check verification status");const g=await q.json(),V=(oe=g.verification)==null?void 0:oe.status;if(h(Math.min(20+se*8,80)),V==="completed"){d("minting"),h(90),await Z(500),h(100),d("completed");const J=(ce=(Y=g.verification)==null?void 0:Y.results)==null?void 0:ce.proofHash;await Z(1500),l({credentialHash:J||r});return}if(V==="failed")throw new Error(((X=g.verification)==null?void 0:X.error)||"Verification failed");await Z(O)}catch(q){if(se===ee-1)throw q;await Z(O)}d("minting"),h(90),await Z(500),h(100),d("completed"),await Z(1500),l({credentialHash:r})},L=async()=>{d("processing"),h(30),await Z(800),h(60),d("minting"),h(80),await Z(800),h(100),d("completed"),await Z(2e3),l({credentialHash:r})},G=async()=>{i==="layer_2"?await F():await L()},Z=ee=>new Promise(O=>setTimeout(O,ee)),re=()=>{d("processing"),h(0),b(""),H.current=!1,m?N():C()},ne=()=>i==="layer_1"?c==="minting"?e.jsx(ge,{className:"text-brand w-4 h-4"}):e.jsx(Lt,{className:"text-brand w-4 h-4"}):e.jsx(Ye,{className:"text-brand w-4 h-4"}),Q=()=>{if(i==="layer_1"){if(c==="processing")return t("creating_wallet",n);if(c==="minting")return t("minting_did_chain",n);if(c==="completed")return t("identity_live",n)}else{if(c==="processing")return t("validating_docs",n);if(c==="minting")return t("submitting_verification",n);if(c==="completed")return t("verification_queued",n)}return""};return e.jsxs(E.motion.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:"flex-1 flex flex-col items-center justify-center px-8 text-center",children:[e.jsxs("div",{className:"relative w-64 h-64 flex items-center justify-center mb-12",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-4 border-dashed border-brand-20 animate-[spin_10s_linear_infinite]"}),e.jsx("div",{className:"absolute inset-4 rounded-full border-2 border-[#6DE8EC]/20 animate-[spin_6s_linear_infinite_reverse]"}),e.jsxs(E.motion.div,{animate:c!=="failed"?{rotateY:[0,180,360],y:[-10,10,-10]}:{},transition:{duration:6,repeat:1/0,ease:"easeInOut"},className:`relative w-40 h-56 backdrop-blur-xl border rounded-2xl flex flex-col p-4 ${c==="completed"?"bg-green-500/10 border-green-500/30 shadow-[0_0_50px_-12px_rgba(34,197,94,0.5)]":c==="failed"?"bg-red-500/10 border-red-500/30 shadow-[0_0_50px_-12px_rgba(239,68,68,0.5)]":"bg-brand/10 border-brand-30 shadow-[0_0_50px_-12px_rgba(114,43,238,0.5)]"}`,children:[e.jsxs("div",{className:"flex justify-between items-start mb-6",children:[e.jsx("div",{className:`w-8 h-8 rounded flex items-center justify-center ${c==="completed"?"bg-green-500/30":c==="failed"?"bg-red-500/30":"bg-brand/30"}`,children:c==="completed"?e.jsx(ve,{className:"text-green-500 w-4 h-4"}):c==="failed"?e.jsx(xe,{className:"text-red-500 w-4 h-4"}):ne()}),e.jsx("div",{className:`w-6 h-1 rounded-full ${c==="completed"?"bg-green-500/40":c==="failed"?"bg-red-500/40":"bg-brand/40"}`})]}),e.jsxs("div",{className:"space-y-3 mb-auto",children:[e.jsx("div",{className:`h-2 w-3/4 rounded-full ${c==="completed"?"bg-green-500/20":c==="failed"?"bg-red-500/20":"bg-brand/20"}`}),e.jsx("div",{className:`h-2 w-1/2 rounded-full ${c==="completed"?"bg-green-500/20":c==="failed"?"bg-red-500/20":"bg-brand/20"}`})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-4",children:[e.jsx("div",{className:`size-6 rounded-full overflow-hidden border border-slate-200 dark:border-white/10 ${c==="completed"?"bg-gradient-to-tr from-green-500 to-[#6DE8EC]":c==="failed"?"bg-gradient-to-tr from-red-500 to-orange-500":"bg-gradient-to-tr from-brand to-[#6DE8EC]"}`}),e.jsxs("div",{className:"flex flex-col items-start max-w-[80px]",children:[D?e.jsx(E.motion.span,{initial:{opacity:0},animate:{opacity:1},className:"text-[10px] font-bold text-slate-800 dark:text-white/90 truncate w-full text-left",children:D}):e.jsx("div",{className:"h-1.5 w-12 bg-white/20 rounded-full mb-1"}),e.jsx("div",{className:"h-1 w-8 bg-slate-200 dark:bg-white/10 rounded-full"})]})]}),c!=="failed"&&c!=="completed"&&e.jsx(E.motion.div,{animate:{top:["0%","100%","0%"]},transition:{duration:2,repeat:1/0},className:"absolute inset-0 bg-gradient-to-b from-transparent via-brand-10 to-transparent h-1/2 w-full"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h2",{className:`text-2xl font-bold bg-clip-text ${c==="completed"?"text-green-500":c==="failed"?"text-red-500":"dark:bg-gradient-to-r dark:from-slate-100 dark:to-slate-400 bg-slate-900 dark:text-transparent text-slate-900"}`,children:x.title}),e.jsx("p",{className:"dark:text-slate-400 text-slate-500 text-sm leading-relaxed max-w-[280px] mx-auto",children:x.subtitle})]}),c==="failed"&&e.jsxs("div",{className:"mt-6 space-y-3",children:[e.jsx("p",{className:"text-red-500 text-sm",children:S}),e.jsx("button",{onClick:re,className:"px-6 py-3 bg-brand text-white rounded-2xl font-bold",children:t("try_again",n)})]}),i==="layer_1"&&o&&c==="completed"&&e.jsxs("div",{className:"mt-6 p-3 dark:bg-white/5 bg-black/5 rounded-xl border dark:border-white/10 border-black/5",children:[e.jsx("p",{className:"text-[10px] text-muted mb-1",children:t("your_wallet",n)}),e.jsxs("p",{className:"text-xs font-mono text-main break-all",children:[o.slice(0,20),"...",o.slice(-10)]})]}),i!=="layer_1"&&T&&c==="completed"&&e.jsxs("div",{className:"mt-6 p-3 dark:bg-white/5 bg-black/5 rounded-xl border dark:border-white/10 border-black/5",children:[e.jsx("p",{className:"text-[10px] text-muted mb-1",children:t("verification_id",n)}),e.jsxs("p",{className:"text-xs font-mono text-main break-all",children:[T.slice(0,20),"..."]})]}),c!=="failed"&&e.jsxs("div",{className:"w-full mt-12 p-6 dark:bg-brand/5 bg-brand/5 border-t dark:border-white/5 border-black/5",children:[e.jsxs("div",{className:"flex justify-between items-center mb-3",children:[e.jsx("span",{className:"text-xs font-medium text-brand uppercase tracking-widest",children:t(i==="layer_1"?"setup_status":"transaction_status",n)}),e.jsx("span",{className:`text-xs font-bold ${c==="completed"?"text-green-500":"text-[#6DE8EC]"}`,children:t("complete_percent",n).replace("{percent}",A.toString())})]}),e.jsx("div",{className:"w-full h-1.5 dark:bg-brand/10 bg-brand/10 rounded-full overflow-hidden mb-4",children:e.jsx(E.motion.div,{initial:{width:"0%"},animate:{width:`${A}%`},transition:{duration:.5},className:`h-full rounded-full ${c==="completed"?"bg-gradient-to-r from-green-500 to-[#6DE8EC]":"bg-gradient-to-r from-brand to-[#6DE8EC]"} shadow-[0_0_10px_rgba(114,43,238,0.5)]`})}),e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 dark:bg-brand/10 bg-brand/10 rounded-xl border dark:border-brand-10 border-brand-5",children:[e.jsx(Pt,{className:`w-4 h-4 ${c==="completed"?"text-green-500":"text-brand"}`}),e.jsx("p",{className:"text-[10px] dark:text-slate-300 text-slate-600 font-medium",children:Q()})]})]})]})},rt=({onNext:i,language:s="EN"})=>e.jsxs(E.motion.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:1.1},className:"flex-1 flex flex-col items-center justify-center px-8 text-center",children:[e.jsxs("div",{className:"relative mb-10 group",children:[e.jsx("div",{className:"absolute inset-0 bg-[#6fe8ec]/30 rounded-3xl blur-3xl group-hover:blur-2xl transition-all"}),e.jsx("div",{className:"relative w-32 h-32 rounded-2xl bg-[#6fe8ec] flex items-center justify-center shadow-[0_0_40px_rgba(111,232,236,0.4)] border-4 dark:border-white border-slate-100",children:e.jsx(ve,{className:"text-slate-900 w-16 h-16"})})]}),e.jsx("h1",{className:"text-main text-3xl font-bold leading-tight mb-3",children:t("identity_verified",s)}),e.jsx("p",{className:"text-muted text-base leading-relaxed mb-12",children:t("identity_verified_desc",s)}),e.jsxs("div",{className:"w-full bg-white dark:bg-white/5 shadow-sm border border-slate-200 dark:border-white/10 rounded-2xl p-5 mb-8 flex items-center justify-between text-left",children:[e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-main font-bold text-sm",children:t("share_data_consent",s)}),e.jsx("p",{className:"text-muted text-xs leading-normal",children:t("authorize_dapps",s)})]}),e.jsx("div",{className:"w-11 h-6 bg-brand rounded-full relative p-1 cursor-pointer",children:e.jsx("div",{className:"absolute right-1 top-1 size-4 bg-white rounded-full"})})]}),e.jsxs("button",{onClick:i,className:"w-full bg-[#6fe8ec] hover:brightness-105 active:scale-[0.98] transition-all text-slate-900 font-bold py-4 rounded-2xl shadow-lg shadow-[#6fe8ec]/20 flex items-center justify-center gap-2",children:[t("return_to_app",s),e.jsx(ze,{className:"w-5 h-5"})]})]}),es=["verify:identity","read:profile","read:kyc_level"],nt=({appName:i="This App",appLogo:s,requestedScopes:r,onApprove:l,onDeny:k,language:f="EN"})=>{const p=r||es;return e.jsxs(E.motion.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},className:"flex-1 px-8 pt-8 flex flex-col items-center",children:[e.jsxs("div",{className:"flex flex-col items-center gap-4 mb-10",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"absolute inset-0 rounded-full shadow-[0_0_20px_rgba(134,81,225,0.3)] animate-pulse"}),e.jsx("div",{className:"relative w-24 h-24 rounded-full border-2 border-brand-40 p-1 dark:bg-black/50 bg-white",children:s?e.jsx("div",{className:"w-full h-full rounded-full overflow-hidden",children:e.jsx("img",{src:s,alt:i,className:"w-full h-full object-cover"})}):e.jsx("div",{className:"w-full h-full rounded-full bg-gradient-to-br from-emerald-500 to-teal-700 flex items-center justify-center text-white font-bold text-2xl",children:i.slice(0,2).toUpperCase()})})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-2xl font-bold tracking-tight text-main",children:i}),e.jsx("p",{className:"text-brand/70 text-sm font-medium mt-1 uppercase tracking-wider",children:t("requesting_access",f)})]})]}),e.jsxs("div",{className:"w-full space-y-3",children:[e.jsx("h3",{className:"text-xs font-semibold uppercase tracking-widest text-slate-500 mb-4 px-1",children:t("permission_request",f)}),p.map(m=>e.jsxs("div",{className:"flex items-center gap-4 p-4 rounded-2xl dark:bg-white/5 bg-black/5 transition-all",children:[e.jsx("div",{className:"flex items-center justify-center w-8 h-8 rounded-full bg-cyan-400/10 text-cyan-400 shrink-0",children:e.jsx(ve,{className:"w-5 h-5"})}),e.jsx("p",{className:"text-sm font-medium text-main",children:t(m,f)})]},m))]}),e.jsxs("div",{className:"mt-8 flex gap-3 p-4 rounded-2xl dark:bg-brand/5 bg-brand/5",children:[e.jsx(we,{className:"text-brand w-5 h-5 shrink-0"}),e.jsxs("p",{className:"text-xs leading-relaxed text-muted",children:[e.jsxs("span",{className:"font-bold text-main",children:[t("privacy_note",f),":"]})," ",t("privacy_desc",f)]})]}),e.jsxs("footer",{className:"mt-auto w-full pb-8 flex flex-col gap-3",children:[e.jsxs("button",{onClick:l,className:"w-full py-4 rounded-2xl bg-brand hover:bg-brand-90 text-white font-bold text-base shadow-xl shadow-brand transition-all flex items-center justify-center gap-2",children:[t("approve_verify",f),e.jsx(Ve,{className:"w-5 h-5"})]}),e.jsx("button",{onClick:k,className:"w-full py-3 rounded-2xl bg-transparent dark:hover:bg-slate-100 dark:bg-white/5 hover:bg-black/5 dark:text-slate-400 text-slate-500 font-semibold text-sm transition-all",children:t("deny",f)})]})]})};function qe(i="light"){return i==="system"?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":i}const Ue=["AuthSelection","Login","PasskeyAuth","PinVerification","PasskeyRegister"],ts="https://apis.casperid.com",$e={requestId:"",verificationTier:"layer_3"},ct=({isOpen:i,apiKey:s,theme:r={},requiredTier:l,onSuccess:k,onClose:f,onError:p,mode:m="login",previewMode:n=!1,initialScreen:c,apiBaseUrl:d,termsUrl:A="#",privacyUrl:h="#",logoUrl:S,language:b="EN",layout:o,platform:j})=>{var Oe;const[y,w]=a.useState({}),[T,v]=a.useState(!n&&!!s),{primaryColor:D,borderRadius:W,fontFamily:H,mode:$="light",layout:x,platform:N}=r||{},C=typeof navigator<"u"&&/iPhone|iPad|iPod|Android/i.test(navigator.userAgent),M=D||y.primaryColor||"#8651e1",F=W||y.borderRadius||"12",L=H||y.fontFamily||"Inter",G=o||x||y.layout||"auto",Z=j||N||y.platform||(C?"mobile":"desktop"),[re,ne]=a.useState(qe($)),[Q,ee]=a.useState(c??(m==="verify"?"SecurityUpgrade":"AuthSelection")),[O,oe]=a.useState({email:"",verificationId:""}),[Y,ce]=a.useState(null),[X,se]=a.useState({email:"",userExists:!1,hasPasskey:!1,userAccount:null}),[q,g]=a.useState($e),[V,J]=a.useState(""),[le,P]=a.useState(""),[K,de]=a.useState(null),B=d||ts,ie=F.toString().endsWith("px")?F.toString():`${F}px`,he=L.includes(" ")?`"${L}", sans-serif`:`${L}, sans-serif`,te=a.useId().replace(/:/g,""),fe={"--casperid-primary":M,"--casperid-radius":ie,"--casperid-font":he},je=`${te}-${M}-${ie}-${he}`,Ne=`
172
+ #casperid-modal-${te},
173
+ #casperid-modal-${te} * {
174
+ --casperid-primary: ${M} !important;
175
+ --casperid-radius: ${ie} !important;
176
+ --casperid-font: ${he} !important;
177
177
  }
178
- `;i.useEffect(()=>{if(A==="system"){const p=window.matchMedia("(prefers-color-scheme: dark)"),x=C=>F(C.matches?"dark":"light");return p.addEventListener("change",x),()=>p.removeEventListener("change",x)}else F(Te(A))},[A]),i.useEffect(()=>{r&&l&&ie(l)},[r,l]),i.useEffect(()=>{a&&!r&&(ie(l??(c==="verify"?"SecurityUpgrade":"AuthSelection")),q({email:"",verificationId:""}),K(null),$({email:"",userExists:!1,hasPasskey:!1,userAccount:null}),ee(Me),fe(""),Ie(""))},[a,c,r,l]),i.useEffect(()=>{if(!s||r){j(!1);return}(async()=>{try{const x=await fetch(`${W}/api/business/app-metadata/${s}`);if(x.ok){const C=await x.json();C.success&&C.app&&(st(C.app),C.app.theme&&N({primaryColor:C.app.theme.primaryColor,borderRadius:C.app.theme.borderRadius,fontFamily:C.app.theme.fontFamily,layout:C.app.theme.layout}))}}catch(x){console.warn("[CasperID] Failed to fetch app metadata:",x)}finally{j(!1)}})()},[s,W,r]);const De=()=>F(p=>p==="dark"?"light":"dark"),E=i.useCallback(p=>ie(p),[]),me=i.useCallback(async p=>{try{const x=p==="layer_2"?`${m}/api/v2/verification/layer2/start`:`${m}/api/v2/verification/layer3/start`,C=await fetch(x,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":s},credentials:"include",body:JSON.stringify({purpose:"sdk_verification",...p==="layer_3"?{verificationMethod:"document"}:{}})});if(!C.ok){const U=await C.json().catch(()=>({}));throw new Error(U.error||`Request failed with status ${C.status}`)}const V=await C.json();if(V.success&&V.verification)return ee(U=>({...U,requestId:V.verification.requestId,verificationTier:p})),V.verification.requestId;throw new Error(V.error||"Failed to start verification")}catch(x){return u==null||u(x instanceof Error?x:new Error("Failed to start verification")),null}},[m,s,u]),at=i.useCallback((p,x,C)=>{K(p),$(V=>({...V,sessionToken:p,businessToken:C,userAccount:x||null})),x!=null&&x.wallet&&(x!=null&&x.did_address)&&Y.hasPasskey?pe(x.tier):E("PasskeyRegister")},[E,Y.hasPasskey]),it=i.useCallback(p=>{$(x=>({...x,email:p,hasPasskey:!0,userExists:!0})),E("PasskeyAuth")},[E]),rt=i.useCallback((p,x,C)=>{K(p),$(V=>({...V,sessionToken:p,businessToken:C,userAccount:x?{user_id:x.user_id,wallet:x.wallet,tier:x.tier,did_address:x.did_address}:null})),pe(x==null?void 0:x.tier)},[]),nt=i.useCallback((p,x)=>{$(C=>({...C,hasPasskey:!0,businessToken:x,userAccount:p?{user_id:p.user_id,tier:p.tier}:C.userAccount})),E("MintingIdentity")},[E]),pe=i.useCallback(p=>{const x=p||"layer_0";if(!o){E("IdentityVerified");return}const C=o==="L1"?"layer_1":o==="L2"?"layer_2":o==="L3"?"layer_3":"layer_1",V=["layer_0","layer_1","layer_2","layer_3"],U=V.indexOf(x),ne=V.indexOf(C);U>=ne?E("IdentityVerified"):ne>=2?E("SecurityUpgrade"):E("IdentityVerified")},[o,E]),ct=i.useCallback(async p=>{var C;if(p!=null&&p.wallet&&$(V=>{var U;return{...V,userAccount:{...V.userAccount,user_id:((U=V.userAccount)==null?void 0:U.user_id)||"",wallet:p.wallet,did_address:p.didAddress,tier:"layer_1"}}}),p!=null&&p.credentialHash&&Ie(p.credentialHash),H&&!r)try{const V=await fetch(`${W}/api/casperid/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:H,apiKey:s})});if(V.ok){const U=await V.json();U.success&&U.token&&(console.log("[CasperID SDK] Token refreshed after verification"),K(U.token),$(ne=>({...ne,sessionToken:U.token,businessToken:U.business_token||ne.businessToken})))}}catch(V){console.warn("[CasperID SDK] Failed to refresh token after verification:",V)}const x=p!=null&&p.wallet?"layer_1":((C=Y.userAccount)==null?void 0:C.tier)||"layer_1";pe(x)},[(Pe=Y.userAccount)==null?void 0:Pe.tier,pe,H,W,r]),lt=i.useCallback(p=>{const x=(p==null?void 0:p.sessionToken)||(p==null?void 0:p.token),C=(p==null?void 0:p.business_token)||(p==null?void 0:p.businessToken);x&&K(x),C&&$(V=>({...V,businessToken:C})),E("SecurityUpgrade")},[E]),dt=i.useCallback(async()=>{await me("layer_2")&&E("FaceScan")},[me,E]),ot=i.useCallback(async p=>{ee(x=>({...x,livenessVerified:p})),o==="L3"?await me("layer_3")&&E("VerifyIdentityChoice"):E("MintingIdentity")},[o,me,E]),ut=i.useCallback(p=>{ee(x=>({...x,documentType:p})),E("DocumentScan")},[E]),mt=i.useCallback((p,x)=>{ee(C=>({...C,extractedData:p})),fe(x),E("ReviewData")},[E]),pt=i.useCallback(p=>{ee(x=>({...x,extractedData:p})),E("MintingIdentity")},[E]),ht=i.useCallback(()=>{ee(p=>({...p,extractedData:void 0})),fe(""),E("DocumentScan")},[E]),ft=i.useCallback(()=>{if(!H){u==null||u(new Error("No valid session token available"));return}_==null||_(H,{businessToken:Y.businessToken}),d==null||d()},[H,Y.businessToken,_,d,u]),Q=i.useCallback(p=>{u==null||u(new Error(p))},[u]),xt=i.useCallback((p,x)=>{q({email:p,verificationId:x}),$(C=>({...C,email:p})),E("PinVerification")},[E]);if(!a&&!r)return null;if(R&&!r)return e.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0,0,0,0.6)",backdropFilter:"blur(6px)"},children:e.jsx("div",{className:"w-12 h-12 border-3 border-white/20 border-t-white/80 rounded-full animate-spin"})});const Re=()=>{switch(G){case"AuthSelection":return e.jsx(Ue,{onNext:x=>E(x==="otp"?"Login":"SecurityUpgrade"),onExtensionSuccess:lt,onError:Q,language:h});case"Login":return e.jsx(Fe,{onNext:xt,onPasskeyUser:it,onError:Q,apiBaseUrl:W,previewMode:r,language:h});case"PasskeyAuth":return e.jsx(Bt,{email:Y.email,onSuccess:rt,onError:Q,onFallbackToOTP:()=>E("Login"),apiBaseUrl:W,previewMode:r,language:h});case"PasskeyRegister":return e.jsx(Ht,{email:Y.email||B.email,sessionToken:H||"",onSuccess:nt,onError:Q,apiBaseUrl:W,previewMode:r,language:h});case"PinVerification":return e.jsx(Be,{email:B.email,verificationId:B.verificationId,onNext:at,onError:Q,apiBaseUrl:W,apiKey:s,previewMode:r,language:h});case"SecurityUpgrade":return e.jsx(He,{onNext:dt,onSkip:()=>E("IdentityVerified"),language:h});case"FaceScan":return e.jsx(Ke,{requestId:Z.requestId,onNext:ot,onError:Q,apiBaseUrl:W,previewMode:r,language:h});case"VerifyIdentityChoice":return e.jsx(We,{onNext:ut,language:h});case"DocumentScan":return e.jsx(Ge,{requestId:Z.requestId,documentType:Z.documentType||"passport",onNext:mt,onError:Q,apiBaseUrl:W,previewMode:r,language:h});case"ReviewData":return e.jsx(Ye,{requestId:Z.requestId,documentType:Z.documentType||"passport",extractedData:Z.extractedData||{},uploadId:tt,onNext:pt,onRetake:ht,onError:Q,apiBaseUrl:W,previewMode:r,language:h});case"MintingIdentity":const p=Z.requestId?Z.verificationTier:"layer_1";return e.jsx(Je,{tier:p,sessionToken:H||"",requestId:Z.requestId,onNext:ct,onError:Q,apiBaseUrl:W,previewMode:r,language:h});case"IdentityVerified":return e.jsx(Ze,{onNext:()=>E("PermissionsRequest"),language:h});case"PermissionsRequest":return e.jsx(Qe,{onApprove:ft,onDeny:()=>d==null?void 0:d(),language:h,appName:se==null?void 0:se.name,appLogo:O||(se==null?void 0:se.logo_url)});default:return null}};return r?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:Ae},Ee),e.jsx("div",{id:`casperid-modal-${re}`,style:Se,className:`relative ${D}`,children:e.jsxs(ye,{className:"backdrop-blur-3xl",theme:D,children:[e.jsx(ve,{onClose:d,showClose:G!=="AuthSelection",subtitle:G==="PermissionsRequest"?"PERMISSION REQUEST":"SECURE SDK",theme:D,toggleTheme:De}),e.jsx("div",{className:"flex-1 flex flex-col relative overflow-hidden",children:e.jsx(z.AnimatePresence,{mode:"wait",children:e.jsx(z.motion.div,{className:"flex-1 flex flex-col",children:Re()},G)})}),ze.includes(G)&&e.jsx(we,{children:e.jsxs("p",{className:"text-[11px] text-slate-500 font-medium",children:["By connecting, you agree to our"," ",e.jsx("a",{className:"text-brand hover:underline ml-1",href:y,target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"})," ","&"," ",e.jsx("a",{className:"text-brand hover:underline ml-1",href:P,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"})]})})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx("style",{children:Ae},Ee),e.jsxs("div",{className:`fixed inset-0 z-[9999] flex items-center justify-center ${S==="fullscreen"?"p-0":"p-4"}`,style:{backgroundColor:S==="fullscreen"?"transparent":"rgba(0,0,0,0.6)",backdropFilter:S==="fullscreen"?"none":"blur(6px)"},onClick:p=>p.target===p.currentTarget&&(d==null?void 0:d()),children:[S!=="fullscreen"&&e.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[40%] rounded-full blur-[120px]",style:{backgroundColor:`${g}1a`}}),e.jsx("div",{className:"absolute bottom-[-5%] right-[-5%] w-[50%] h-[30%] bg-[#6DE8EC]/5 blur-[100px] rounded-full"})]}),e.jsx(z.motion.div,{id:`casperid-modal-${re}`,initial:S==="fullscreen"?{opacity:0}:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:S==="fullscreen"?{opacity:0}:{opacity:0,scale:.95,y:20},transition:{type:"spring",damping:28,stiffness:300},style:Se,className:`relative selection:bg-brand/30 ${D} ${S==="fullscreen"?"w-full h-full":""}`,children:e.jsxs(ye,{className:`backdrop-blur-3xl ${S==="fullscreen"?"w-full h-full rounded-none":""}`,theme:D,children:[e.jsx(ve,{onClose:d,showClose:G!=="AuthSelection",subtitle:G==="PermissionsRequest"?"PERMISSION REQUEST":"SECURE SDK",theme:D,toggleTheme:De}),e.jsx("div",{className:"flex-1 flex flex-col relative overflow-hidden",children:e.jsx(z.AnimatePresence,{mode:"wait",children:e.jsx(z.motion.div,{className:"flex-1 flex flex-col",children:Re()},G)})}),ze.includes(G)&&e.jsx(we,{children:e.jsxs("p",{className:"text-[11px] text-slate-500 font-medium",children:["By connecting, you agree to our"," ",e.jsx("a",{className:"text-brand hover:underline ml-1",href:y,target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"})," ","&"," ",e.jsx("a",{className:"text-brand hover:underline ml-1",href:P,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"})]})})]})})]})]})};async function Zt(a,s={},n=3e4){const o=new AbortController,_=setTimeout(()=>o.abort(),n);try{return await fetch(a,{...s,signal:o.signal})}finally{clearTimeout(_)}}class et extends Error{constructor(s,n){super(s),this.name="ApiError",this.status=n}}async function Qt(a){if(!a.ok){const s=await a.json().catch(()=>({}));throw new et(s.error||s.message||`Request failed with status ${a.status}`,a.status)}return a.json()}exports.ApiError=et;exports.AuthSelectionScreen=Ue;exports.CasperIDModal=Xe;exports.DocumentScanScreen=Ge;exports.FaceScanScreen=Ke;exports.Footer=we;exports.GlassContainer=ye;exports.Header=ve;exports.IdentityVerifiedScreen=Ze;exports.LoginScreen=Fe;exports.MintingIdentityScreen=Je;exports.PermissionsRequestScreen=Qe;exports.PinVerificationScreen=Be;exports.ReviewDataScreen=Ye;exports.SecurityUpgradeScreen=He;exports.VerifyIdentityChoiceScreen=We;exports.default=Xe;exports.fetchWithTimeout=Zt;exports.handleApiResponse=Qt;
178
+ `;a.useEffect(()=>{if($==="system"){const u=window.matchMedia("(prefers-color-scheme: dark)"),_=I=>ne(I.matches?"dark":"light");return u.addEventListener("change",_),()=>u.removeEventListener("change",_)}else ne(qe($))},[$]),a.useEffect(()=>{n&&c&&ee(c)},[n,c]),a.useEffect(()=>{i&&!n&&(ee(c??(m==="verify"?"SecurityUpgrade":"AuthSelection")),oe({email:"",verificationId:""}),ce(null),se({email:"",userExists:!1,hasPasskey:!1,userAccount:null}),g($e),J(""),P(""))},[i,m,n,c]),a.useEffect(()=>{if(!s||n){v(!1);return}(async()=>{try{const _=await fetch(`${B}/api/business/app-metadata/${s}`);if(_.ok){const I=await _.json();I.success&&I.app&&(de(I.app),I.app.theme&&w({primaryColor:I.app.theme.primaryColor,borderRadius:I.app.theme.borderRadius,fontFamily:I.app.theme.fontFamily,layout:I.app.theme.layout,platform:I.app.theme.platform}))}}catch(_){console.warn("[CasperID] Failed to fetch app metadata:",_)}finally{v(!1)}})()},[s,B,n]);const Fe=()=>ne(u=>u==="dark"?"light":"dark"),R=a.useCallback(u=>ee(u),[]),Ee=a.useCallback(async u=>{try{const _=u==="layer_2"?`${d}/api/v2/verification/layer2/start`:`${d}/api/v2/verification/layer3/start`,I=await fetch(_,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":s},credentials:"include",body:JSON.stringify({purpose:"sdk_verification",...u==="layer_3"?{verificationMethod:"document"}:{}})});if(!I.ok){const ae=await I.json().catch(()=>({}));throw new Error(ae.error||`Request failed with status ${I.status}`)}const U=await I.json();if(U.success&&U.verification)return g(ae=>({...ae,requestId:U.verification.requestId,verificationTier:u})),U.verification.requestId;throw new Error(U.error||"Failed to start verification")}catch(_){return p==null||p(_ instanceof Error?_:new Error("Failed to start verification")),null}},[d,s,p]),lt=a.useCallback((u,_,I)=>{ce(u),se(U=>({...U,sessionToken:u,businessToken:I,userAccount:_||null})),_!=null&&_.wallet&&(_!=null&&_.did_address)&&X.hasPasskey?Ce(_.tier):R("PasskeyRegister")},[R,X.hasPasskey]),dt=a.useCallback(u=>{se(_=>({..._,email:u,hasPasskey:!0,userExists:!0})),R("PasskeyAuth")},[R]),ut=a.useCallback((u,_,I)=>{ce(u),se(U=>({...U,sessionToken:u,businessToken:I,userAccount:_?{user_id:_.user_id,wallet:_.wallet,tier:_.tier,did_address:_.did_address}:null})),Ce(_==null?void 0:_.tier)},[]),mt=a.useCallback((u,_)=>{se(I=>({...I,hasPasskey:!0,businessToken:_,userAccount:u?{user_id:u.user_id,tier:u.tier}:I.userAccount})),R("MintingIdentity")},[R]),Ce=a.useCallback(u=>{const _=u||"layer_0";if(!l){R("IdentityVerified");return}const I=l==="L1"?"layer_1":l==="L2"?"layer_2":l==="L3"?"layer_3":"layer_1",U=["layer_0","layer_1","layer_2","layer_3"],ae=U.indexOf(_),be=U.indexOf(I);ae>=be?R("IdentityVerified"):be>=2?R("SecurityUpgrade"):R("IdentityVerified")},[l,R]),ft=a.useCallback(async u=>{var I;if(u!=null&&u.wallet&&se(U=>{var ae;return{...U,userAccount:{...U.userAccount,user_id:((ae=U.userAccount)==null?void 0:ae.user_id)||"",wallet:u.wallet,did_address:u.didAddress,tier:"layer_1"}}}),u!=null&&u.credentialHash&&P(u.credentialHash),Y&&!n)try{const U=await fetch(`${B}/api/casperid/refresh`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:Y,apiKey:s})});if(U.ok){const ae=await U.json();ae.success&&ae.token&&(console.log("[CasperID SDK] Token refreshed after verification"),ce(ae.token),se(be=>({...be,sessionToken:ae.token,businessToken:ae.business_token||be.businessToken})))}}catch(U){console.warn("[CasperID SDK] Failed to refresh token after verification:",U)}let _=u!=null&&u.wallet?"layer_1":((I=X.userAccount)==null?void 0:I.tier)||"layer_1";q.livenessVerified&&q.verificationTier==="layer_2"?_="layer_2":q.documentType&&q.verificationTier==="layer_3"&&(_="layer_3"),Ce(_)},[(Oe=X.userAccount)==null?void 0:Oe.tier,Ce,Y,B,n,q]),pt=a.useCallback(u=>{const _=(u==null?void 0:u.sessionToken)||(u==null?void 0:u.token),I=(u==null?void 0:u.business_token)||(u==null?void 0:u.businessToken);_&&ce(_),I&&se(U=>({...U,businessToken:I})),R("SecurityUpgrade")},[R]),ht=a.useCallback(async()=>{l==="L3"?await Ee("layer_3")&&R("VerifyIdentityChoice"):await Ee("layer_2")&&R("FaceScan")},[l,Ee,R]),xt=a.useCallback(async u=>{g(_=>({..._,livenessVerified:u})),R("MintingIdentity")},[R]),bt=a.useCallback(u=>{g(_=>({..._,documentType:u})),R("DocumentScan")},[R]),_t=a.useCallback((u,_,I)=>{g(U=>({...U,extractedData:u,frontImageUrl:I.frontImageUrl,frontImageFileId:I.frontImageFileId,backImageUrl:I.backImageUrl,backImageFileId:I.backImageFileId})),J(_),R("ReviewData")},[R]),yt=a.useCallback(u=>{g(_=>({..._,extractedData:u})),R("FaceScan")},[R]);a.useCallback(()=>{g(u=>({...u,extractedData:void 0})),J(""),R("DocumentScan")},[R]);const gt=a.useCallback(()=>{if(!Y){p==null||p(new Error("No valid session token available"));return}k==null||k(Y,{businessToken:X.businessToken}),f==null||f()},[Y,X.businessToken,k,f,p]),ue=a.useCallback(u=>{p==null||p(new Error(u))},[p]),vt=a.useCallback((u,_)=>{oe({email:u,verificationId:_}),se(I=>({...I,email:u})),R("PinVerification")},[R]);if(!i&&!n)return null;if(T&&!n)return e.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center p-4",style:{backgroundColor:"rgba(0,0,0,0.6)",backdropFilter:"blur(6px)"},children:e.jsx("div",{className:"w-12 h-12 border-3 border-white/20 border-t-white/80 rounded-full animate-spin"})});const Le=()=>{switch(Q){case"AuthSelection":return e.jsx(Je,{onNext:_=>R(_==="otp"?"Login":"SecurityUpgrade"),onExtensionSuccess:pt,onError:ue,language:b,platform:Z});case"Login":return e.jsx(Ke,{onNext:vt,onPasskeyUser:dt,onError:ue,apiBaseUrl:B,apiKey:s,previewMode:n,language:b});case"PasskeyAuth":return e.jsx(Jt,{email:X.email,onSuccess:ut,onError:ue,onFallbackToOTP:()=>R("Login"),apiBaseUrl:B,apiKey:s,previewMode:n,language:b});case"PasskeyRegister":return e.jsx(Kt,{email:X.email||O.email,sessionToken:Y||"",onSuccess:mt,onError:ue,apiBaseUrl:B,apiKey:s,previewMode:n,language:b});case"PinVerification":return e.jsx(Xe,{email:O.email,verificationId:O.verificationId,onNext:lt,onError:ue,apiBaseUrl:B,apiKey:s,previewMode:n,language:b});case"SecurityUpgrade":return e.jsx(Qe,{onNext:ht,onSkip:()=>R("IdentityVerified"),language:b});case"FaceScan":return e.jsx(et,{requestId:q.requestId,onNext:xt,onError:ue,apiBaseUrl:B,apiKey:s,previewMode:n,language:b});case"VerifyIdentityChoice":return e.jsx(tt,{onNext:bt,language:b});case"DocumentScan":return e.jsx(st,{requestId:q.requestId,documentType:q.documentType,onNext:_t,onError:ue,apiBaseUrl:B,apiKey:s,previewMode:n,language:b});case"ReviewData":return e.jsx(it,{requestId:q.requestId,documentType:q.documentType,extractedData:q.extractedData,uploadId:V,frontImageUrl:q.frontImageUrl,frontImageFileId:q.frontImageFileId,backImageUrl:q.backImageUrl,backImageFileId:q.backImageFileId,onNext:yt,onRetake:()=>R("DocumentScan"),onError:ue,apiBaseUrl:B,apiKey:s,previewMode:n,language:b});case"MintingIdentity":const u=q.requestId?q.verificationTier:"layer_1";return e.jsx(at,{tier:u,sessionToken:Y||"",requestId:q.requestId,onNext:ft,onError:ue,apiBaseUrl:B,apiKey:s,previewMode:n,language:b});case"IdentityVerified":return e.jsx(rt,{onNext:()=>R("PermissionsRequest"),language:b});case"PermissionsRequest":return e.jsx(nt,{onApprove:gt,onDeny:()=>f==null?void 0:f(),language:b,appName:K==null?void 0:K.name,appLogo:S||(K==null?void 0:K.logo_url),requestedScopes:K==null?void 0:K.requested_scopes});default:return null}};return n?e.jsxs(e.Fragment,{children:[e.jsx("style",{children:Ne},je),e.jsx("div",{id:`casperid-modal-${te}`,style:fe,className:`relative ${re}`,children:e.jsxs(Re,{className:"backdrop-blur-3xl",theme:re,children:[Q!=="FaceScan"&&e.jsx(Pe,{onClose:f,showClose:Q!=="AuthSelection",subtitle:Q==="PermissionsRequest"?"PERMISSION REQUEST":"SECURE SDK",theme:re,toggleTheme:Fe}),e.jsx("div",{className:"flex-1 flex flex-col relative overflow-hidden",children:e.jsx(E.AnimatePresence,{mode:"wait",children:e.jsx(E.motion.div,{className:"flex-1 flex flex-col",children:Le()},Q)})}),Ue.includes(Q)&&e.jsx(Te,{children:e.jsxs("p",{className:"text-[11px] text-slate-500 font-medium",children:["By connecting, you agree to our"," ",e.jsx("a",{className:"text-brand hover:underline ml-1",href:A,target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"})," ","&"," ",e.jsx("a",{className:"text-brand hover:underline ml-1",href:h,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"})]})})]})})]}):e.jsxs(e.Fragment,{children:[e.jsx("style",{children:Ne},je),e.jsxs("div",{className:`fixed inset-0 z-[9999] flex items-center justify-center ${G==="fullscreen"?"p-0":"p-4"}`,style:{backgroundColor:G==="fullscreen"?"transparent":"rgba(0,0,0,0.6)",backdropFilter:G==="fullscreen"?"none":"blur(6px)"},onClick:u=>u.target===u.currentTarget&&(f==null?void 0:f()),children:[G!=="fullscreen"&&e.jsxs("div",{className:"absolute inset-0 pointer-events-none overflow-hidden",children:[e.jsx("div",{className:"absolute top-[-10%] left-[-10%] w-[60%] h-[40%] rounded-full blur-[120px]",style:{backgroundColor:`${M}1a`}}),e.jsx("div",{className:"absolute bottom-[-5%] right-[-5%] w-[50%] h-[30%] bg-[#6DE8EC]/5 blur-[100px] rounded-full"})]}),e.jsx(E.motion.div,{id:`casperid-modal-${te}`,initial:G==="fullscreen"?{opacity:0}:{opacity:0,scale:.95,y:20},animate:{opacity:1,scale:1,y:0},exit:G==="fullscreen"?{opacity:0}:{opacity:0,scale:.95,y:20},transition:{type:"spring",damping:28,stiffness:300},style:fe,className:`relative selection:bg-brand/30 ${re} ${G==="fullscreen"?"w-full h-full":Z==="mobile"?"w-full max-w-md h-[90vh] max-h-[800px]":"w-full max-w-xl h-[85vh] max-h-[900px]"}`,children:e.jsxs(Re,{className:`backdrop-blur-3xl ${G==="fullscreen"?"w-full h-full rounded-none":""}`,theme:re,children:[Q!=="FaceScan"&&e.jsx(Pe,{onClose:f,showClose:Q!=="AuthSelection",subtitle:Q==="PermissionsRequest"?"PERMISSION REQUEST":"SECURE SDK",theme:re,toggleTheme:Fe}),e.jsx("div",{className:"flex-1 flex flex-col relative overflow-hidden",children:e.jsx(E.AnimatePresence,{mode:"wait",children:e.jsx(E.motion.div,{className:"flex-1 flex flex-col",children:Le()},Q)})}),Ue.includes(Q)&&e.jsx(Te,{children:e.jsxs("p",{className:"text-[11px] text-slate-500 font-medium",children:["By connecting, you agree to our"," ",e.jsx("a",{className:"text-brand hover:underline ml-1",href:A,target:"_blank",rel:"noopener noreferrer",children:"Terms of Service"})," ","&"," ",e.jsx("a",{className:"text-brand hover:underline ml-1",href:h,target:"_blank",rel:"noopener noreferrer",children:"Privacy Policy"})]})})]})})]})]})};async function ss(i,s={},r=3e4){const l=new AbortController,k=setTimeout(()=>l.abort(),r);try{return await fetch(i,{...s,signal:l.signal})}finally{clearTimeout(k)}}class ot extends Error{constructor(s,r){super(s),this.name="ApiError",this.status=r}}async function is(i){if(!i.ok){const s=await i.json().catch(()=>({}));throw new ot(s.error||s.message||`Request failed with status ${i.status}`,i.status)}return i.json()}exports.ApiError=ot;exports.AuthSelectionScreen=Je;exports.CasperIDModal=ct;exports.DocumentScanScreen=st;exports.FaceScanScreen=et;exports.Footer=Te;exports.GlassContainer=Re;exports.Header=Pe;exports.IdentityVerifiedScreen=rt;exports.LoginScreen=Ke;exports.MintingIdentityScreen=at;exports.PermissionsRequestScreen=nt;exports.PinVerificationScreen=Xe;exports.ReviewDataScreen=it;exports.SecurityUpgradeScreen=Qe;exports.VerifyIdentityChoiceScreen=tt;exports.default=ct;exports.fetchWithTimeout=ss;exports.handleApiResponse=is;
179
179
  //# sourceMappingURL=index.cjs.map