@arkyc/widget 1.0.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 (59) hide show
  1. package/README.md +85 -0
  2. package/dist/ArkycWidget.d.mts +50 -0
  3. package/dist/ArkycWidget.d.mts.map +1 -0
  4. package/dist/ArkycWidget.mjs +80 -0
  5. package/dist/ArkycWidget.mjs.map +1 -0
  6. package/dist/WidgetHandler.d.mts +24 -0
  7. package/dist/WidgetHandler.d.mts.map +1 -0
  8. package/dist/WidgetHandler.mjs +28 -0
  9. package/dist/WidgetHandler.mjs.map +1 -0
  10. package/dist/_virtual/_virtual_arkyc-theme-css.mjs +4 -0
  11. package/dist/arkyc-widget.iife.global.js +670 -0
  12. package/dist/arkyc-widget.iife.global.js.map +1 -0
  13. package/dist/capture.d.mts +73 -0
  14. package/dist/capture.d.mts.map +1 -0
  15. package/dist/capture.mjs +126 -0
  16. package/dist/capture.mjs.map +1 -0
  17. package/dist/client.d.mts +152 -0
  18. package/dist/client.d.mts.map +1 -0
  19. package/dist/client.mjs +120 -0
  20. package/dist/client.mjs.map +1 -0
  21. package/dist/controller.d.mts +126 -0
  22. package/dist/controller.d.mts.map +1 -0
  23. package/dist/controller.mjs +582 -0
  24. package/dist/controller.mjs.map +1 -0
  25. package/dist/countries.mjs +967 -0
  26. package/dist/countries.mjs.map +1 -0
  27. package/dist/device.mjs +17 -0
  28. package/dist/device.mjs.map +1 -0
  29. package/dist/document.d.mts +108 -0
  30. package/dist/document.d.mts.map +1 -0
  31. package/dist/document.mjs +227 -0
  32. package/dist/document.mjs.map +1 -0
  33. package/dist/face.d.mts +82 -0
  34. package/dist/face.d.mts.map +1 -0
  35. package/dist/face.mjs +230 -0
  36. package/dist/face.mjs.map +1 -0
  37. package/dist/flow.d.mts +74 -0
  38. package/dist/flow.d.mts.map +1 -0
  39. package/dist/flow.mjs +132 -0
  40. package/dist/flow.mjs.map +1 -0
  41. package/dist/index.d.mts +19 -0
  42. package/dist/index.d.mts.map +1 -0
  43. package/dist/index.mjs +16 -0
  44. package/dist/index.mjs.map +1 -0
  45. package/dist/qr.mjs +22 -0
  46. package/dist/qr.mjs.map +1 -0
  47. package/dist/realtime.d.mts +29 -0
  48. package/dist/realtime.d.mts.map +1 -0
  49. package/dist/realtime.mjs +107 -0
  50. package/dist/realtime.mjs.map +1 -0
  51. package/dist/theme.d.mts +42 -0
  52. package/dist/theme.d.mts.map +1 -0
  53. package/dist/theme.mjs +77 -0
  54. package/dist/theme.mjs.map +1 -0
  55. package/dist/types.d.mts +153 -0
  56. package/dist/types.d.mts.map +1 -0
  57. package/dist/ui.mjs +931 -0
  58. package/dist/ui.mjs.map +1 -0
  59. package/package.json +43 -0
@@ -0,0 +1,670 @@
1
+ var Arkyc=(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.create,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,s=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),c=(e,t,a,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var c=i(t),l=0,u=c.length,d;l<u;l++)d=c[l],!o.call(e,d)&&d!==a&&n(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(s=r(t,d))||s.enumerable});return e},l=(e,r,i)=>(i=e==null?{}:t(a(e)),c(r||!e||!e.__esModule?n(i,`default`,{value:e,enumerable:!0}):i,e));function u(e){"@babel/helpers - typeof";return u=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},u(e)}function d(e,t){if(u(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(u(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function f(e){var t=d(e,`string`);return u(t)==`symbol`?t:t+``}function p(e,t,n){return(t=f(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var m=class extends Error{constructor(e,t,n){super(e),p(this,`status`,void 0),p(this,`code`,void 0),this.name=`WidgetApiError`,this.status=t,this.code=n}};function h(e,t){if(t)for(let[n,r]of Object.entries(t))r!=null&&e.append(n,String(r))}var g=class{constructor(e){if(p(this,`token`,void 0),p(this,`baseUrl`,void 0),p(this,`fetchImpl`,void 0),!e.token)throw Error("ArkycClient requires a client `token`.");this.token=e.token,this.baseUrl=(e.baseUrl??``).replace(/\/$/,``);let t=e.fetch??globalThis.fetch;if(!t)throw Error("No `fetch` implementation available.");this.fetchImpl=t.bind(globalThis)}getSession(){return this.request(`GET`,`/v1/client/session`)}submitDocumentFront(e){let t=new FormData;return e.image&&t.append(`image`,e.image,`document-front.jpg`),e.country&&t.append(`country`,e.country),e.documentType&&t.append(`document_type`,e.documentType),h(t,e.signals),this.request(`POST`,`/v1/client/document/front`,t)}submitDocumentBack(e){let t=new FormData;return e.image&&t.append(`image`,e.image,`document-back.jpg`),e.country&&t.append(`country`,e.country),e.documentType&&t.append(`document_type`,e.documentType),this.request(`POST`,`/v1/client/document/back`,t)}submitLiveness(e){let t=new FormData;return e.selfie&&t.append(`selfie`,e.selfie,`selfie.jpg`),e.video&&t.append(`video`,e.video,`liveness.webm`),e.mode&&t.append(`mode`,e.mode),e.challenges&&t.append(`challenges`,JSON.stringify(e.challenges)),h(t,e.signals),this.request(`POST`,`/v1/client/liveness`,t)}complete(e={}){return this.request(`POST`,`/v1/client/complete`,e.signals??{})}async request(e,t,n){let r={"X-Client-Token":this.token},i;n instanceof FormData?i=n:n&&(r[`Content-Type`]=`application/json`,i=JSON.stringify(n));let a=await this.fetchImpl(`${this.baseUrl}${t}`,{method:e,headers:r,body:i}),o=await a.text(),s=o?JSON.parse(o):{};if(!a.ok)throw new m(s.message??`Request failed (${a.status})`,a.status);return s.data}};async function _(e,t){try{return await import(e)}catch{return await import(`https://cdn.jsdelivr.net/npm/${t}`)}}async function v(e,t){try{if(e.transport===`pusher`)return await y(e,t);if(e.transport===`firebase`)return await b(e)}catch{return null}return null}async function y(e,t){let n=(await _(`pusher-js`,`pusher-js@8/+esm`)).default,r=new n(String(e.key??``),{cluster:String(e.cluster??`mt1`),forceTLS:!!(e.forceTLS??!1),...e.wsHost?{wsHost:String(e.wsHost),wsPort:Number(e.wsPort),wssPort:Number(e.wssPort??e.wsPort),enabledTransports:e.enabledTransports??[`ws`,`wss`]}:{},channelAuthorization:{transport:`ajax`,endpoint:t.authEndpoint,headers:{"X-Client-Token":t.token}}});return{subscribe(e,t){let n=r.subscribe(e),i=(e,n)=>t(e,n);return n.bind_global(i),()=>{n.unbind_global(i),r.unsubscribe(e)}},disconnect(){r.disconnect()}}}async function b(e){let[t,n,r]=await Promise.all([_(`firebase/app`,`firebase@11/app/+esm`),_(`firebase/auth`,`firebase@11/auth/+esm`),_(`firebase/database`,`firebase@11/database/+esm`)]),i=`arkyc-widget-realtime`,a=t.getApps().some(e=>e.name===i)?t.getApp(i):t.initializeApp({apiKey:String(e.apiKey??``),authDomain:String(e.authDomain??``),projectId:String(e.projectId??``),databaseURL:String(e.databaseURL??``)},i);e.token&&await n.signInWithCustomToken(n.getAuth(a),e.token);let o=r.getDatabase(a),s=Date.now();return{subscribe(e,t){let n=r.query(r.ref(o,`realtime/${e}`),r.orderByChild(`at`),r.startAt(s)),i=r.onChildAdded(n,e=>{let n=e.val();n&&t(n.event,n.payload)});return()=>i()},disconnect(){}}}var x=`.arkyc-root {
2
+ /* {variables} */
3
+
4
+ color: var(--arkyc-fg);
5
+ font-family:
6
+ system-ui,
7
+ -apple-system,
8
+ Segoe UI,
9
+ Roboto,
10
+ sans-serif;
11
+ box-sizing: border-box;
12
+ }
13
+
14
+ .arkyc-text-center {
15
+ text-align: center;
16
+ }
17
+
18
+ .arkyc-root * {
19
+ box-sizing: border-box;
20
+ }
21
+
22
+ .arkyc-card {
23
+ background: var(--arkyc-bg);
24
+ border-radius: var(--arkyc-radius);
25
+ width: 100vw;
26
+ max-width: 480px;
27
+ height: 100%;
28
+ max-height: 720px;
29
+ display: flex;
30
+ flex-direction: column;
31
+ overflow: hidden;
32
+ }
33
+
34
+ .arkyc-root.arkyc-fullscreen .arkyc-card {
35
+ max-width: none;
36
+ max-height: none;
37
+ height: 100vh;
38
+ height: 100dvh;
39
+ border-radius: 0;
40
+ }
41
+
42
+ /* On a wider (desktop) viewport, "fullscreen" is a large centred dialog rather than edge-to-edge. */
43
+ @media (min-width: 700px) {
44
+ .arkyc-root.arkyc-fullscreen .arkyc-card {
45
+ max-width: 560px;
46
+ min-width: 400px;
47
+ width: 100%;
48
+ height: auto;
49
+ min-height: min(620px, 92vh);
50
+ max-height: 92vh;
51
+ border-radius: var(--arkyc-radius);
52
+ }
53
+ }
54
+
55
+ /* Handoff (QR) takes over the whole viewport โ€” but only in overlay (open) mode,
56
+ so an inline mount() stays within its container instead of escaping fullscreen.
57
+ The close affordance is hidden either way: there's nothing to dismiss while
58
+ awaiting the phone. */
59
+ .arkyc-root.arkyc-overlay.arkyc-handoff .arkyc-card {
60
+ position: fixed;
61
+ inset: 0;
62
+ width: 100vw;
63
+ height: 100vh;
64
+ height: 100dvh;
65
+ max-width: none;
66
+ max-height: none;
67
+ min-width: 0;
68
+ min-height: 0;
69
+ border-radius: 0;
70
+ z-index: 2147483646;
71
+ }
72
+
73
+ .arkyc-root.arkyc-handoff .arkyc-close {
74
+ display: none;
75
+ }
76
+
77
+ .arkyc-header {
78
+ display: flex;
79
+ align-items: center;
80
+ justify-content: space-between;
81
+ padding: 16px 20px;
82
+ /* border-bottom: 1px solid var(--arkyc-border); */
83
+ }
84
+
85
+ .arkyc-logo {
86
+ height: 24px;
87
+ width: auto;
88
+ }
89
+
90
+ .arkyc-title {
91
+ font-size: 15px;
92
+ font-weight: 600;
93
+ margin: 0;
94
+ }
95
+
96
+ .arkyc-brand {
97
+ display: flex;
98
+ align-items: center;
99
+ gap: 10px;
100
+ min-width: 0;
101
+ }
102
+
103
+ .arkyc-brand-name {
104
+ font-size: 15px;
105
+ font-weight: 600;
106
+ white-space: nowrap;
107
+ overflow: hidden;
108
+ text-overflow: ellipsis;
109
+ }
110
+
111
+ .arkyc-close {
112
+ background: none;
113
+ border: 0;
114
+ color: var(--arkyc-muted);
115
+ font-size: 20px;
116
+ line-height: 1;
117
+ cursor: pointer;
118
+ }
119
+
120
+ .arkyc-body {
121
+ flex: 1;
122
+ display: flex;
123
+ flex-direction: column;
124
+ align-items: center;
125
+ justify-content: center;
126
+ text-align: center;
127
+ gap: 14px;
128
+ padding: 24px;
129
+ overflow-y: auto;
130
+ }
131
+
132
+ .arkyc-h {
133
+ font-size: 20px;
134
+ font-weight: 600;
135
+ margin: 0;
136
+ }
137
+
138
+ .arkyc-p {
139
+ font-size: 14px;
140
+ color: var(--arkyc-muted);
141
+ margin: 0;
142
+ max-width: 340px;
143
+ }
144
+
145
+ .arkyc-footer {
146
+ padding: 16px 20px;
147
+ /* border-top: 1px solid var(--arkyc-border); */
148
+ }
149
+
150
+ .arkyc-btn {
151
+ appearance: none;
152
+ border: 0;
153
+ border-radius: var(--arkyc-radius);
154
+ background: var(--arkyc-primary);
155
+ color: #fff;
156
+ font-size: 15px;
157
+ font-weight: 600;
158
+ padding: 12px 18px;
159
+ width: 100%;
160
+ cursor: pointer;
161
+ }
162
+
163
+ .arkyc-btn[disabled] {
164
+ opacity: 0.6;
165
+ cursor: not-allowed;
166
+ }
167
+
168
+ /* Busy: hide the label and show an inline spinner while the handler runs. */
169
+ .arkyc-btn.arkyc-busy {
170
+ position: relative;
171
+ color: transparent;
172
+ pointer-events: none;
173
+ opacity: 1;
174
+ }
175
+
176
+ .arkyc-btn.arkyc-busy::after {
177
+ content: '';
178
+ position: absolute;
179
+ inset: 0;
180
+ margin: auto;
181
+ width: 16px;
182
+ height: 16px;
183
+ border-radius: 50%;
184
+ border: 2px solid rgba(255, 255, 255, 0.5);
185
+ border-top-color: #fff;
186
+ animation: arkyc-spin 0.8s linear infinite;
187
+ }
188
+
189
+ .arkyc-btn-ghost.arkyc-busy::after {
190
+ border-color: color-mix(in srgb, var(--arkyc-primary) 35%, transparent);
191
+ border-top-color: var(--arkyc-primary);
192
+ }
193
+
194
+ .arkyc-btn-ghost {
195
+ background: transparent;
196
+ color: var(--arkyc-primary);
197
+ border: 1px solid var(--arkyc-border);
198
+ }
199
+
200
+ .arkyc-choices {
201
+ display: flex;
202
+ flex-direction: column;
203
+ gap: 8px;
204
+ width: 100%;
205
+ max-width: 340px;
206
+ }
207
+
208
+ .arkyc-preview {
209
+ width: 100%;
210
+ max-width: 360px;
211
+ border-radius: var(--arkyc-radius);
212
+ background: #000;
213
+ aspect-ratio: 3/2;
214
+ object-fit: cover;
215
+ }
216
+
217
+ .arkyc-preview.selfie {
218
+ aspect-ratio: 1/1;
219
+ max-width: 280px;
220
+ border-radius: 50%;
221
+ transform: scaleX(-1);
222
+ }
223
+
224
+ .arkyc-spinner {
225
+ width: 42px;
226
+ height: 42px;
227
+ border-radius: 50%;
228
+ border: 4px solid var(--arkyc-border);
229
+ border-top-color: var(--arkyc-primary);
230
+ animation: arkyc-spin 1s linear infinite;
231
+ }
232
+
233
+ .arkyc-spinner.sm {
234
+ width: 18px;
235
+ height: 18px;
236
+ border-width: 3px;
237
+ }
238
+
239
+ @keyframes arkyc-spin {
240
+ to {
241
+ transform: rotate(360deg);
242
+ }
243
+ }
244
+
245
+ .arkyc-qr {
246
+ width: 200px;
247
+ height: 200px;
248
+ padding: 12px;
249
+ margin: 4px auto;
250
+ background: #fff;
251
+ border-radius: var(--arkyc-radius);
252
+ border: 1px solid var(--arkyc-border);
253
+ }
254
+
255
+ .arkyc-qr svg {
256
+ display: block;
257
+ width: 100%;
258
+ height: 100%;
259
+ }
260
+
261
+ .arkyc-handoff-wait {
262
+ display: flex;
263
+ align-items: center;
264
+ justify-content: center;
265
+ gap: 10px;
266
+ color: var(--arkyc-muted);
267
+ font-size: 14px;
268
+ margin-top: 6px;
269
+ }
270
+
271
+ /* Decorative line-art illustration on the welcome / instruction screens: a soft
272
+ tinted disc in the primary colour with a halo, holding a stroked icon. */
273
+ .arkyc-illus {
274
+ width: 104px;
275
+ height: 104px;
276
+ border-radius: 50%;
277
+ display: flex;
278
+ align-items: center;
279
+ justify-content: center;
280
+ margin: 0 auto 2px;
281
+ color: var(--arkyc-primary);
282
+ background: color-mix(in srgb, var(--arkyc-primary) 12%, transparent);
283
+ box-shadow: 0 0 0 8px color-mix(in srgb, var(--arkyc-primary) 5%, transparent);
284
+ }
285
+
286
+ .arkyc-illus svg {
287
+ width: 58px;
288
+ height: 58px;
289
+ }
290
+
291
+ .arkyc-badge {
292
+ width: 64px;
293
+ height: 64px;
294
+ border-radius: 50%;
295
+ display: flex;
296
+ align-items: center;
297
+ justify-content: center;
298
+ font-size: 32px;
299
+ color: #fff;
300
+ }
301
+
302
+ .arkyc-badge.ok {
303
+ background: #16a34a;
304
+ }
305
+
306
+ .arkyc-badge.warn {
307
+ background: #d97706;
308
+ }
309
+
310
+ .arkyc-badge.err {
311
+ background: #dc2626;
312
+ }
313
+
314
+ /* --- Animated capture overlays --- */
315
+ .arkyc-stage {
316
+ position: relative;
317
+ width: 100%;
318
+ max-width: 280px;
319
+ margin: 0 auto;
320
+ }
321
+
322
+ .arkyc-stage .arkyc-preview {
323
+ display: block;
324
+ width: 100%;
325
+ max-width: 100%;
326
+ }
327
+
328
+ .arkyc-ring {
329
+ position: absolute;
330
+ inset: 0;
331
+ pointer-events: none;
332
+ }
333
+
334
+ .arkyc-ring svg {
335
+ width: 100%;
336
+ height: 100%;
337
+ transform: rotate(-90deg);
338
+ overflow: visible;
339
+ }
340
+
341
+ .arkyc-ring-track {
342
+ fill: none;
343
+ stroke: rgba(125, 130, 150, 0.3);
344
+ stroke-width: 3;
345
+ }
346
+
347
+ .arkyc-ring-arc {
348
+ fill: none;
349
+ stroke: var(--arkyc-primary);
350
+ stroke-width: 4;
351
+ stroke-linecap: round;
352
+ transition:
353
+ stroke-dashoffset 0.15s linear,
354
+ stroke 0.25s;
355
+ }
356
+
357
+ .arkyc-stage[data-state='wait'] .arkyc-ring-track {
358
+ animation: arkyc-pulse 1.5s ease-in-out infinite;
359
+ }
360
+
361
+ .arkyc-stage[data-state='good'] .arkyc-ring-arc,
362
+ .arkyc-stage[data-state='done'] .arkyc-ring-arc,
363
+ .arkyc-stage[data-state='done'] .arkyc-ring-track {
364
+ stroke: #16a34a;
365
+ }
366
+
367
+ .arkyc-cue {
368
+ position: absolute;
369
+ left: 0;
370
+ right: 0;
371
+ bottom: 7%;
372
+ display: flex;
373
+ justify-content: center;
374
+ align-items: center;
375
+ pointer-events: none;
376
+ opacity: 0;
377
+ transition: opacity 0.25s;
378
+ }
379
+
380
+ .arkyc-cue.show {
381
+ opacity: 1;
382
+ }
383
+
384
+ .arkyc-cue svg {
385
+ width: 36px;
386
+ height: 36px;
387
+ color: #fff;
388
+ filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
389
+ }
390
+
391
+ .arkyc-cue-turn_right svg {
392
+ animation: arkyc-nudge-r 1.1s ease-in-out infinite;
393
+ }
394
+
395
+ .arkyc-cue-turn_left svg {
396
+ animation: arkyc-nudge-l 1.1s ease-in-out infinite;
397
+ }
398
+
399
+ .arkyc-cue-nod svg {
400
+ animation: arkyc-nudge-d 1.1s ease-in-out infinite;
401
+ }
402
+
403
+ .arkyc-cue-move_closer svg {
404
+ animation: arkyc-zoom 1.2s ease-in-out infinite;
405
+ }
406
+
407
+ .arkyc-cue-blink svg,
408
+ .arkyc-cue-smile svg {
409
+ animation: arkyc-soft 1.3s ease-in-out infinite;
410
+ }
411
+
412
+ .arkyc-check {
413
+ position: absolute;
414
+ inset: 0;
415
+ display: flex;
416
+ align-items: center;
417
+ justify-content: center;
418
+ opacity: 0;
419
+ transform: scale(0.5);
420
+ transition:
421
+ opacity 0.25s,
422
+ transform 0.25s;
423
+ pointer-events: none;
424
+ }
425
+
426
+ .arkyc-check svg {
427
+ width: 56px;
428
+ height: 56px;
429
+ color: #16a34a;
430
+ background: rgba(255, 255, 255, 0.92);
431
+ border-radius: 50%;
432
+ padding: 10px;
433
+ box-sizing: border-box;
434
+ }
435
+
436
+ .arkyc-stage[data-state='done'] .arkyc-check {
437
+ opacity: 1;
438
+ transform: scale(1);
439
+ }
440
+
441
+ .arkyc-stage[data-state='done'] .arkyc-cue {
442
+ opacity: 0;
443
+ }
444
+
445
+ .arkyc-dots {
446
+ display: flex;
447
+ gap: 8px;
448
+ justify-content: center;
449
+ margin: 0 0 14px;
450
+ }
451
+
452
+ .arkyc-dot {
453
+ width: 8px;
454
+ height: 8px;
455
+ border-radius: 50%;
456
+ background: var(--arkyc-border);
457
+ transition:
458
+ background 0.3s,
459
+ transform 0.3s;
460
+ }
461
+
462
+ .arkyc-dot.active {
463
+ background: var(--arkyc-primary);
464
+ transform: scale(1.4);
465
+ animation: arkyc-pulse 1.2s ease-in-out infinite;
466
+ }
467
+
468
+ .arkyc-dot.done {
469
+ background: #16a34a;
470
+ }
471
+
472
+ .arkyc-doc {
473
+ position: relative;
474
+ width: 100%;
475
+ max-width: 360px;
476
+ margin: 0 auto;
477
+ }
478
+
479
+ .arkyc-doc .arkyc-preview {
480
+ display: block;
481
+ width: 100%;
482
+ max-width: 100%;
483
+ }
484
+
485
+ .arkyc-doc-frame {
486
+ position: absolute;
487
+ /* Fixed, always-visible alignment target at the ID-1 card aspect ratio
488
+ (85.6 ร— 54 mm โ‰ˆ 1.585:1), centred in the preview. */
489
+ top: 50%;
490
+ left: 50%;
491
+ width: 86%;
492
+ aspect-ratio: 1.585 / 1;
493
+ transform: translate(-50%, -50%);
494
+ pointer-events: none;
495
+ border: 2px solid rgba(255, 255, 255, 0.5);
496
+ border-radius: 10px;
497
+ transition: border-color 0.3s;
498
+ }
499
+
500
+ .arkyc-corner {
501
+ position: absolute;
502
+ width: 24px;
503
+ height: 24px;
504
+ border: 3px solid rgba(255, 255, 255, 0.9);
505
+ transition: border-color 0.3s;
506
+ }
507
+
508
+ .arkyc-corner.tl {
509
+ top: 0;
510
+ left: 0;
511
+ border-right: none;
512
+ border-bottom: none;
513
+ border-top-left-radius: 6px;
514
+ }
515
+
516
+ .arkyc-corner.tr {
517
+ top: 0;
518
+ right: 0;
519
+ border-left: none;
520
+ border-bottom: none;
521
+ border-top-right-radius: 6px;
522
+ }
523
+
524
+ .arkyc-corner.bl {
525
+ bottom: 0;
526
+ left: 0;
527
+ border-right: none;
528
+ border-top: none;
529
+ border-bottom-left-radius: 6px;
530
+ }
531
+
532
+ .arkyc-corner.br {
533
+ bottom: 0;
534
+ right: 0;
535
+ border-left: none;
536
+ border-top: none;
537
+ border-bottom-right-radius: 6px;
538
+ }
539
+
540
+ .arkyc-scan {
541
+ position: absolute;
542
+ /* Animates within the fixed guide (its parent), sweeping the card area. */
543
+ left: 6%;
544
+ right: 6%;
545
+ top: 6%;
546
+ height: 2px;
547
+ background: linear-gradient(90deg, transparent, var(--arkyc-primary), transparent);
548
+ box-shadow: 0 0 8px var(--arkyc-primary);
549
+ animation: arkyc-scan 2.4s ease-in-out infinite;
550
+ }
551
+
552
+ /* A document is in view: brighten the guide (quality tints still override). */
553
+ .arkyc-doc[data-detected='true'] .arkyc-doc-frame {
554
+ border-color: rgba(255, 255, 255, 0.85);
555
+ }
556
+
557
+ .arkyc-doc[data-q='good'] .arkyc-corner,
558
+ .arkyc-doc[data-q='good'] .arkyc-doc-frame {
559
+ border-color: #16a34a;
560
+ }
561
+
562
+ .arkyc-doc[data-q='good'] .arkyc-scan {
563
+ background: linear-gradient(90deg, transparent, #16a34a, transparent);
564
+ box-shadow: 0 0 8px #16a34a;
565
+ }
566
+
567
+ .arkyc-doc[data-q='bad'] .arkyc-corner,
568
+ .arkyc-doc[data-q='bad'] .arkyc-doc-frame {
569
+ border-color: #f59e0b;
570
+ }
571
+
572
+ @keyframes arkyc-pulse {
573
+ 0%,
574
+ 100% {
575
+ opacity: 1;
576
+ }
577
+
578
+ 50% {
579
+ opacity: 0.4;
580
+ }
581
+ }
582
+
583
+ @keyframes arkyc-nudge-r {
584
+ 0%,
585
+ 100% {
586
+ transform: translateX(-7px);
587
+ }
588
+
589
+ 50% {
590
+ transform: translateX(7px);
591
+ }
592
+ }
593
+
594
+ @keyframes arkyc-nudge-l {
595
+ 0%,
596
+ 100% {
597
+ transform: translateX(7px);
598
+ }
599
+
600
+ 50% {
601
+ transform: translateX(-7px);
602
+ }
603
+ }
604
+
605
+ @keyframes arkyc-nudge-d {
606
+ 0%,
607
+ 100% {
608
+ transform: translateY(-6px);
609
+ }
610
+
611
+ 50% {
612
+ transform: translateY(6px);
613
+ }
614
+ }
615
+
616
+ @keyframes arkyc-zoom {
617
+ 0%,
618
+ 100% {
619
+ transform: scale(0.8);
620
+ }
621
+
622
+ 50% {
623
+ transform: scale(1.15);
624
+ }
625
+ }
626
+
627
+ @keyframes arkyc-soft {
628
+ 0%,
629
+ 100% {
630
+ opacity: 0.35;
631
+ }
632
+
633
+ 50% {
634
+ opacity: 1;
635
+ }
636
+ }
637
+
638
+ @keyframes arkyc-scan {
639
+ 0%,
640
+ 100% {
641
+ top: 6%;
642
+ }
643
+
644
+ 50% {
645
+ top: 90%;
646
+ }
647
+ }
648
+
649
+ @media (prefers-reduced-motion: reduce) {
650
+ .arkyc-ring-track,
651
+ .arkyc-cue svg,
652
+ .arkyc-scan,
653
+ .arkyc-dot,
654
+ .arkyc-spinner {
655
+ animation: none !important;
656
+ }
657
+
658
+ .arkyc-ring-arc {
659
+ transition: none !important;
660
+ }
661
+ }
662
+
663
+ .arkyc-hidden {
664
+ display: none;
665
+ }
666
+ `;let S={background:`#ffffff`,foreground:`#0f172a`,muted:`#64748b`,border:`#e2e8f0`},C={background:`#0f172a`,foreground:`#f8fafc`,muted:`#94a3b8`,border:`#1e293b`};var w=class{constructor(e){p(this,`primaryColor`,void 0),p(this,`borderRadius`,void 0),p(this,`mode`,void 0),p(this,`logoUrl`,void 0),p(this,`name`,void 0),p(this,`showBranding`,void 0),p(this,`background`,void 0),p(this,`foreground`,void 0),p(this,`muted`,void 0),p(this,`border`,void 0),this.mode=e?.theme===`dark`?`dark`:`light`;let t=this.mode===`dark`?C:S;this.primaryColor=e?.primary_color??`#b8860b`,this.borderRadius=e?.border_radius??12,this.logoUrl=e?.logo_url??null,this.name=e?.name??null,this.showBranding=e?.show_branding!==!1,this.background=t.background,this.foreground=t.foreground,this.muted=t.muted,this.border=t.border}variables(){return[`--arkyc-primary:${this.primaryColor}`,`--arkyc-radius:${this.borderRadius}px`,`--arkyc-bg:${this.background}`,`--arkyc-fg:${this.foreground}`,`--arkyc-muted:${this.muted}`,`--arkyc-border:${this.border}`].join(`;`)}stylesheet(){return x.replace(`/* {variables} */`,`${this.variables()};`).trim()}},T=class{constructor(e=globalThis.document,t=globalThis.navigator){this.doc=e,this.nav=t,p(this,`stream`,null)}get supported(){return!!this.nav?.mediaDevices?.getUserMedia}async start(e,t){let n=await this.nav.mediaDevices.getUserMedia({video:{facingMode:t},audio:!1});return this.stream=n,e.srcObject=n,e.setAttribute(`playsinline`,`true`),e.muted=!0,await e.play().catch(()=>void 0),n}stop(){this.stream?.getTracks().forEach(e=>e.stop()),this.stream=null}get canRecord(){return globalThis.MediaRecorder!==void 0}recordStart(e){let t=[],n=new MediaRecorder(e,{mimeType:`video/webm`});return n.ondataavailable=e=>{e.data&&e.data.size>0&&t.push(e.data)},n.start(),{stop:()=>new Promise(e=>{n.onstop=()=>e(new Blob(t,{type:`video/webm`})),n.stop()})}}sampleQuality(e){let t=this.doc.createElement(`canvas`);t.width=32,t.height=32;let n=t.getContext(`2d`);if(!n||!e.videoWidth)return null;n.drawImage(e,0,0,t.width,t.height);let{data:r}=n.getImageData(0,0,t.width,t.height),i=0,a=0,o=r.length/4;for(let e=0;e<r.length;e+=4){let t=(.299*r[e]+.587*r[e+1]+.114*r[e+2])/255;i+=t,t>.92&&(a+=1)}let s=i/o;return{brightness:s,tooDark:s<.25,glare:a/o>.15}}grabFrame(e,t=.92){let n=this.doc.createElement(`canvas`);n.width=e.videoWidth||1280,n.height=e.videoHeight||720;let r=n.getContext(`2d`);return r?(r.drawImage(e,0,0,n.width,n.height),new Promise((e,r)=>{n.toBlob(t=>t?e(t):r(Error(`Failed to capture frame.`)),`image/jpeg`,t)})):Promise.reject(Error(`Canvas 2D context unavailable.`))}static fileFromInput(e){return e.files?.[0]??null}};let E={sessionTransition:`session.transition`,reviewAction:`review.action`},D=[`document`,`liveness`,`face_match`];function O(e,t){return e?e.steps.some(e=>e.key===t&&e.enabled):!0}function k(e){return e?O(e,`document`)&&!e.options.skip_ocr:!0}function A(e){return e?e.steps.filter(e=>e.enabled).map(e=>e.key):[...D]}let j={document:[`document_selection`,`front_capture`,`back_capture`,`ocr_processing`],liveness:[`active_liveness`,`selfie_capture`,`passive_liveness`],face_match:[`face_match`]};var M=class e{static documentHasBack(e){return e!=null&&e!==`passport`}static stepOrder(e={}){return[`welcome`,...A(e.workflow).flatMap(e=>j[e]),`processing`,`result`]}static isStepEnabled(t,n={}){return t===`back_capture`?e.documentHasBack(n.documentType):t===`ocr_processing`?k(n.workflow):t===`active_liveness`?n.livenessMode===`active`:t===`selfie_capture`||t===`passive_liveness`?n.livenessMode!==`active`:!0}static nextStep(t,n={}){let r=e.stepOrder(n),i=r.indexOf(t);if(i<0)return t;for(let t=i+1;t<r.length;t+=1){let i=r[t];if(e.isStepEnabled(i,n))return i}return t}static isTerminal(t){return e.TERMINAL_STATUSES.includes(t)}static statusToDecision(e){switch(e){case`approved`:return`approved`;case`rejected`:return`rejected`;case`requires_review`:return`requires_review`;default:return null}}};p(M,`STEP_ORDER`,[`welcome`,`document_selection`,`front_capture`,`back_capture`,`ocr_processing`,`active_liveness`,`selfie_capture`,`passive_liveness`,`face_match`,`processing`,`result`]),p(M,`TERMINAL_STATUSES`,[`approved`,`rejected`,`requires_review`,`expired`,`cancelled`]);let N=`0.10.20`,P=e=>`https://cdn.jsdelivr.net/npm/`+e;function F(e,t){return e?.find(e=>e.categoryName===t)?.score??0}function I(){let e=globalThis.performance;return e?.now?e.now():0}var ee=class{constructor(){p(this,`landmarker`,null),p(this,`state`,`idle`),p(this,`loading`,null)}async ready(){return this.state===`ready`?!0:this.state===`failed`?!1:(this.loading||(this.loading=this.load()),this.loading)}async load(){this.state=`loading`;try{if(typeof document>`u`)throw Error(`no document`);if(!document.createElement(`canvas`).getContext(`webgl2`))throw Error(`no webgl2`);let e=await import(P(`@mediapipe/tasks-vision@${N}/vision_bundle.mjs`)),t=await e.FilesetResolver.forVisionTasks(P(`@mediapipe/tasks-vision@${N}/wasm`));return this.landmarker=await e.FaceLandmarker.createFromOptions(t,{baseOptions:{modelAssetPath:`https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task`,delegate:`GPU`},outputFaceBlendshapes:!0,runningMode:`VIDEO`,numFaces:1}),this.state=`ready`,!0}catch{return this.state=`failed`,!1}}analyze(e){if(this.state!==`ready`||!this.landmarker||!e.videoWidth)return null;let t;try{t=this.landmarker.detectForVideo(e,I())}catch{return null}let n=t.faceLandmarks?.[0];if(!n||n.length===0)return{present:!1,centerX:.5,centerY:.5,scale:0,turn:0,pitch:0,blink:0,smile:0};let r=1,i=0,a=1,o=0;for(let e of n)e.x<r&&(r=e.x),e.x>i&&(i=e.x),e.y<a&&(a=e.y),e.y>o&&(o=e.y);let s=Math.max(.001,o-a),c=n[1],l=n[33],u=n[263],d=n[234],f=n[454],p=n[152],m=c.x-d.x,h=f.x-c.x,g=(h-m)/Math.max(.001,m+h),_=(l.y+u.y)/2,v=(c.y-_)/Math.max(.001,p.y-_),y=t.faceBlendshapes?.[0]?.categories,b=Math.max(F(y,`eyeBlinkLeft`),F(y,`eyeBlinkRight`)),x=(F(y,`mouthSmileLeft`)+F(y,`mouthSmileRight`))/2;return{present:!0,centerX:(r+i)/2,centerY:(a+o)/2,scale:s,turn:g,pitch:v,blink:b,smile:x}}close(){try{this.landmarker?.close()}catch{}this.landmarker=null,this.state=`failed`}};function L(){return new ee}let R={turn:.18,smile:.5,blinkClosed:.55,blinkOpen:.25,hold:3,nodDown:.06,nodReturn:.02,closerFactor:1.22,selfieCenterTol:.2,selfieCenterYTol:.25,selfieMinScale:.28,selfieMaxScale:.85};function z(e,t=R){let n=e=>{let n=0;return{feed(r){return n=r.present&&e(r)?n+1:0,n>=t.hold},get progress(){return Math.min(1,n/Math.max(1,t.hold))}}},r=(e,t,n)=>{let r=null,i=!1,a=!1;return{feed(o){if(!o.present)return!1;let s=e(o);if(r===null)return r=s,!1;if(t(s,r))i=!0;else if(i&&n(s,r))return a=!0,!0;return!1},get progress(){return a?1:i?.6:0}}};switch(e){case`blink`:{let e=!1,n=!1;return{feed(r){if(!r.present)return!1;if(r.blink>t.blinkClosed)e=!0;else if(e&&r.blink<t.blinkOpen)return n=!0,!0;return!1},get progress(){return n?1:e?.6:0}}}case`smile`:return n(e=>e.smile>t.smile);case`turn_left`:return n(e=>e.turn<-t.turn);case`turn_right`:return n(e=>e.turn>t.turn);case`nod`:return r(e=>e.pitch,(e,n)=>e>n+t.nodDown,(e,n)=>e<n+t.nodReturn);case`move_closer`:{let e=null,n=0;return{feed(r){return r.present?e===null?(e=r.scale,!1):(n=r.scale>e*t.closerFactor?n+1:0,n>=t.hold):!1},get progress(){return Math.min(1,n/Math.max(1,t.hold))}}}}}function B(e,t=R){return e.present&&Math.abs(e.centerX-.5)<t.selfieCenterTol&&Math.abs(e.centerY-.5)<t.selfieCenterYTol&&e.scale>t.selfieMinScale&&e.scale<t.selfieMaxScale}let V={sampleWidth:320,minFill:.18,maxFill:.97,centerTol:.22,minEdgeStrength:.1,minSharpness:8,borderMargin:.012,minBrightness:.18,hold:5};function te(e){return[e.y,1-(e.x+e.w),1-(e.y+e.h),e.x]}function H(e,t,n){let r=t,i=-1;for(let a=t;a<n;a+=1){let t=e[a];t>i&&(i=t,r=a)}return{i:r,v:i}}function U(e,t,n){let r={present:!1,rect:{x:0,y:0,w:0,h:0},fill:0,centerX:.5,centerY:.5,edgeStrength:0,sharpness:0,brightness:0};if(t<8||n<8||e.length<t*n)return r;let i=new Float64Array(n),a=new Float64Array(t),o=0,s=0,c=0,l=0;for(let r=0;r<t*n;r+=1)l+=e[r];let u=l/(t*n*255);for(let r=1;r<n-1;r+=1)for(let n=1;n<t-1;n+=1){let l=r*t+n,u=e[l-t-1],d=e[l-t],f=e[l-t+1],p=e[l-1],m=e[l],h=e[l+1],g=e[l+t-1],_=e[l+t],v=e[l+t+1],y=f+2*h+v-(u+2*p+g),b=g+2*_+v-(u+2*d+f);i[r]+=Math.abs(b),a[n]+=Math.abs(y);let x=4*m-p-h-d-_;o+=x,s+=x*x,c+=1}let d=c?s/c-(o/c)**2:0,f=Math.max(1,Math.floor(n*.05)),p=Math.max(1,Math.floor(t*.05)),m=Math.floor(n/2),h=Math.floor(t/2),g=H(i,f,m),_=H(i,m,n-f),v=H(a,p,h),y=H(a,h,t-p),b=v.i/t,x=y.i/t,S=g.i/n,C=_.i/n,w={x:b,y:S,w:Math.max(0,x-b),h:Math.max(0,C-S)},T=Math.max(1,w.w*t),E=Math.max(1,w.h*n),D=Math.min(g.v/(T*1020),_.v/(T*1020),v.v/(E*1020),y.v/(E*1020));return{present:w.w>.12&&w.h>.12&&D>.04,rect:w,fill:w.w*w.h,centerX:(b+x)/2,centerY:(S+C)/2,edgeStrength:D,sharpness:d,brightness:u}}function W(e,t=V){return e.brightness<t.minBrightness?{ready:!1,hint:`Too dark โ€” find better lighting`}:!e.present||e.edgeStrength<t.minEdgeStrength?{ready:!1,hint:`Fit your document inside the frame`}:e.fill>t.maxFill||Math.min(...te(e.rect))<t.borderMargin?{ready:!1,hint:`Move back a little โ€” fit the whole document`}:e.fill<t.minFill?{ready:!1,hint:`Move closer`}:Math.abs(e.centerX-.5)>t.centerTol||Math.abs(e.centerY-.5)>t.centerTol?{ready:!1,hint:`Center the document`}:e.sharpness<t.minSharpness?{ready:!1,hint:`Hold steady to focus`}:{ready:!0,hint:`Looks good โ€” hold steady`}}function ne(e,t=V){return W(e,t).ready}var re=class{constructor(e){this.tuning=e,p(this,`canvas`,null),p(this,`ctx`,null)}ready(){try{if(typeof document>`u`)return Promise.resolve(!1);let e=document.createElement(`canvas`),t=e.getContext(`2d`,{willReadFrequently:!0});return t?(this.canvas=e,this.ctx=t,Promise.resolve(!0)):Promise.resolve(!1)}catch{return Promise.resolve(!1)}}analyze(e){if(!this.ctx||!this.canvas||!e.videoWidth)return null;let t=this.tuning.sampleWidth,n=Math.max(1,Math.round(t*e.videoHeight/e.videoWidth));this.canvas.width=t,this.canvas.height=n;let r;try{this.ctx.drawImage(e,0,0,t,n),r=this.ctx.getImageData(0,0,t,n).data}catch{return null}let i=new Float32Array(t*n);for(let e=0,t=0;e<i.length;e+=1,t+=4)i[e]=.299*r[t]+.587*r[t+1]+.114*r[t+2];return U(i,t,n)}close(){this.canvas=null,this.ctx=null}};function G(e=V){return new re(e)}let ie=[{name:`United States`,iso2:`US`,flag:`๐Ÿ‡บ๐Ÿ‡ธ`},{name:`Canada`,iso2:`CA`,flag:`๐Ÿ‡จ๐Ÿ‡ฆ`},{name:`Brazil`,iso2:`BR`,flag:`๐Ÿ‡ง๐Ÿ‡ท`},{name:`United Kingdom`,iso2:`GB`,flag:`๐Ÿ‡ฌ๐Ÿ‡ง`},{name:`Germany`,iso2:`DE`,flag:`๐Ÿ‡ฉ๐Ÿ‡ช`},{name:`France`,iso2:`FR`,flag:`๐Ÿ‡ซ๐Ÿ‡ท`},{name:`China`,iso2:`CN`,flag:`๐Ÿ‡จ๐Ÿ‡ณ`},{name:`Japan`,iso2:`JP`,flag:`๐Ÿ‡ฏ๐Ÿ‡ต`},{name:`India`,iso2:`IN`,flag:`๐Ÿ‡ฎ๐Ÿ‡ณ`},{name:`Australia`,iso2:`AU`,flag:`๐Ÿ‡ฆ๐Ÿ‡บ`},{name:`South Africa`,iso2:`ZA`,flag:`๐Ÿ‡ฟ๐Ÿ‡ฆ`},{name:`Russia`,iso2:`RU`,flag:`๐Ÿ‡ท๐Ÿ‡บ`},{name:`Saudi Arabia`,iso2:`SA`,flag:`๐Ÿ‡ธ๐Ÿ‡ฆ`},{name:`Afghanistan`,iso2:`AF`,flag:`๐Ÿ‡ฆ๐Ÿ‡ซ`},{name:`Albania`,iso2:`AL`,flag:`๐Ÿ‡ฆ๐Ÿ‡ฑ`},{name:`Algeria`,iso2:`DZ`,flag:`๐Ÿ‡ฉ๐Ÿ‡ฟ`},{name:`Andorra`,iso2:`AD`,flag:`๐Ÿ‡ฆ๐Ÿ‡ฉ`},{name:`Angola`,iso2:`AO`,flag:`๐Ÿ‡ฆ๐Ÿ‡ด`},{name:`Antigua and Barbuda`,iso2:`AG`,flag:`๐Ÿ‡ฆ๐Ÿ‡ฌ`},{name:`Argentina`,iso2:`AR`,flag:`๐Ÿ‡ฆ๐Ÿ‡ท`},{name:`Armenia`,iso2:`AM`,flag:`๐Ÿ‡ฆ๐Ÿ‡ฒ`},{name:`Austria`,iso2:`AT`,flag:`๐Ÿ‡ฆ๐Ÿ‡น`},{name:`Azerbaijan`,iso2:`AZ`,flag:`๐Ÿ‡ฆ๐Ÿ‡ฟ`},{name:`Bahamas`,iso2:`BS`,flag:`๐Ÿ‡ง๐Ÿ‡ธ`},{name:`Bahrain`,iso2:`BH`,flag:`๐Ÿ‡ง๐Ÿ‡ญ`},{name:`Bangladesh`,iso2:`BD`,flag:`๐Ÿ‡ง๐Ÿ‡ฉ`},{name:`Barbados`,iso2:`BB`,flag:`๐Ÿ‡ง๐Ÿ‡ง`},{name:`Belarus`,iso2:`BY`,flag:`๐Ÿ‡ง๐Ÿ‡พ`},{name:`Belgium`,iso2:`BE`,flag:`๐Ÿ‡ง๐Ÿ‡ช`},{name:`Belize`,iso2:`BZ`,flag:`๐Ÿ‡ง๐Ÿ‡ฟ`},{name:`Benin`,iso2:`BJ`,flag:`๐Ÿ‡ง๐Ÿ‡ฏ`},{name:`Bhutan`,iso2:`BT`,flag:`๐Ÿ‡ง๐Ÿ‡น`},{name:`Bolivia`,iso2:`BO`,flag:`๐Ÿ‡ง๐Ÿ‡ด`},{name:`Bosnia and Herzegovina`,iso2:`BA`,flag:`๐Ÿ‡ง๐Ÿ‡ฆ`},{name:`Botswana`,iso2:`BW`,flag:`๐Ÿ‡ง๐Ÿ‡ผ`},{name:`Brunei`,iso2:`BN`,flag:`๐Ÿ‡ง๐Ÿ‡ณ`},{name:`Bulgaria`,iso2:`BG`,flag:`๐Ÿ‡ง๐Ÿ‡ฌ`},{name:`Burkina Faso`,iso2:`BF`,flag:`๐Ÿ‡ง๐Ÿ‡ซ`},{name:`Burundi`,iso2:`BI`,flag:`๐Ÿ‡ง๐Ÿ‡ฎ`},{name:`Cabo Verde`,iso2:`CV`,flag:`๐Ÿ‡จ๐Ÿ‡ป`},{name:`Cambodia`,iso2:`KH`,flag:`๐Ÿ‡ฐ๐Ÿ‡ญ`},{name:`Cameroon`,iso2:`CM`,flag:`๐Ÿ‡จ๐Ÿ‡ฒ`},{name:`Central African Republic`,iso2:`CF`,flag:`๐Ÿ‡จ๐Ÿ‡ซ`},{name:`Chad`,iso2:`TD`,flag:`๐Ÿ‡น๐Ÿ‡ฉ`},{name:`Chile`,iso2:`CL`,flag:`๐Ÿ‡จ๐Ÿ‡ฑ`},{name:`Colombia`,iso2:`CO`,flag:`๐Ÿ‡จ๐Ÿ‡ด`},{name:`Comoros`,iso2:`KM`,flag:`๐Ÿ‡ฐ๐Ÿ‡ฒ`},{name:`Congo (Congo-Brazzaville)`,iso2:`CG`,flag:`๐Ÿ‡จ๐Ÿ‡ฌ`},{name:`Congo (Congo-Kinshasa)`,iso2:`CD`,flag:`๐Ÿ‡จ๐Ÿ‡ฉ`},{name:`Costa Rica`,iso2:`CR`,flag:`๐Ÿ‡จ๐Ÿ‡ท`},{name:`Croatia`,iso2:`HR`,flag:`๐Ÿ‡ญ๐Ÿ‡ท`},{name:`Cuba`,iso2:`CU`,flag:`๐Ÿ‡จ๐Ÿ‡บ`},{name:`Cyprus`,iso2:`CY`,flag:`๐Ÿ‡จ๐Ÿ‡พ`},{name:`Czech Republic`,iso2:`CZ`,flag:`๐Ÿ‡จ๐Ÿ‡ฟ`},{name:`Denmark`,iso2:`DK`,flag:`๐Ÿ‡ฉ๐Ÿ‡ฐ`},{name:`Djibouti`,iso2:`DJ`,flag:`๐Ÿ‡ฉ๐Ÿ‡ฏ`},{name:`Dominica`,iso2:`DM`,flag:`๐Ÿ‡ฉ๐Ÿ‡ฒ`},{name:`Dominican Republic`,iso2:`DO`,flag:`๐Ÿ‡ฉ๐Ÿ‡ด`},{name:`Ecuador`,iso2:`EC`,flag:`๐Ÿ‡ช๐Ÿ‡จ`},{name:`Egypt`,iso2:`EG`,flag:`๐Ÿ‡ช๐Ÿ‡ฌ`},{name:`El Salvador`,iso2:`SV`,flag:`๐Ÿ‡ธ๐Ÿ‡ป`},{name:`Equatorial Guinea`,iso2:`GQ`,flag:`๐Ÿ‡ฌ๐Ÿ‡ถ`},{name:`Eritrea`,iso2:`ER`,flag:`๐Ÿ‡ช๐Ÿ‡ท`},{name:`Estonia`,iso2:`EE`,flag:`๐Ÿ‡ช๐Ÿ‡ช`},{name:`Eswatini`,iso2:`SZ`,flag:`๐Ÿ‡ธ๐Ÿ‡ฟ`},{name:`Ethiopia`,iso2:`ET`,flag:`๐Ÿ‡ช๐Ÿ‡น`},{name:`Fiji`,iso2:`FJ`,flag:`๐Ÿ‡ซ๐Ÿ‡ฏ`},{name:`Finland`,iso2:`FI`,flag:`๐Ÿ‡ซ๐Ÿ‡ฎ`},{name:`Gabon`,iso2:`GA`,flag:`๐Ÿ‡ฌ๐Ÿ‡ฆ`},{name:`Gambia`,iso2:`GM`,flag:`๐Ÿ‡ฌ๐Ÿ‡ฒ`},{name:`Georgia`,iso2:`GE`,flag:`๐Ÿ‡ฌ๐Ÿ‡ช`},{name:`Ghana`,iso2:`GH`,flag:`๐Ÿ‡ฌ๐Ÿ‡ญ`},{name:`Greece`,iso2:`GR`,flag:`๐Ÿ‡ฌ๐Ÿ‡ท`},{name:`Grenada`,iso2:`GD`,flag:`๐Ÿ‡ฌ๐Ÿ‡ฉ`},{name:`Guatemala`,iso2:`GT`,flag:`๐Ÿ‡ฌ๐Ÿ‡น`},{name:`Guinea`,iso2:`GN`,flag:`๐Ÿ‡ฌ๐Ÿ‡ณ`},{name:`Guinea-Bissau`,iso2:`GW`,flag:`๐Ÿ‡ฌ๐Ÿ‡ผ`},{name:`Guyana`,iso2:`GY`,flag:`๐Ÿ‡ฌ๐Ÿ‡พ`},{name:`Haiti`,iso2:`HT`,flag:`๐Ÿ‡ญ๐Ÿ‡น`},{name:`Honduras`,iso2:`HN`,flag:`๐Ÿ‡ญ๐Ÿ‡ณ`},{name:`Hungary`,iso2:`HU`,flag:`๐Ÿ‡ญ๐Ÿ‡บ`},{name:`Iceland`,iso2:`IS`,flag:`๐Ÿ‡ฎ๐Ÿ‡ธ`},{name:`Indonesia`,iso2:`ID`,flag:`๐Ÿ‡ฎ๐Ÿ‡ฉ`},{name:`Iran`,iso2:`IR`,flag:`๐Ÿ‡ฎ๐Ÿ‡ท`},{name:`Iraq`,iso2:`IQ`,flag:`๐Ÿ‡ฎ๐Ÿ‡ถ`},{name:`Ireland`,iso2:`IE`,flag:`๐Ÿ‡ฎ๐Ÿ‡ช`},{name:`Israel`,iso2:`IL`,flag:`๐Ÿ‡ฎ๐Ÿ‡ฑ`},{name:`Italy`,iso2:`IT`,flag:`๐Ÿ‡ฎ๐Ÿ‡น`},{name:`Jamaica`,iso2:`JM`,flag:`๐Ÿ‡ฏ๐Ÿ‡ฒ`},{name:`Jordan`,iso2:`JO`,flag:`๐Ÿ‡ฏ๐Ÿ‡ด`},{name:`Kazakhstan`,iso2:`KZ`,flag:`๐Ÿ‡ฐ๐Ÿ‡ฟ`},{name:`Kenya`,iso2:`KE`,flag:`๐Ÿ‡ฐ๐Ÿ‡ช`},{name:`Kiribati`,iso2:`KI`,flag:`๐Ÿ‡ฐ๐Ÿ‡ฎ`},{name:`Kuwait`,iso2:`KW`,flag:`๐Ÿ‡ฐ๐Ÿ‡ผ`},{name:`Kyrgyzstan`,iso2:`KG`,flag:`๐Ÿ‡ฐ๐Ÿ‡ฌ`},{name:`Laos`,iso2:`LA`,flag:`๐Ÿ‡ฑ๐Ÿ‡ฆ`},{name:`Latvia`,iso2:`LV`,flag:`๐Ÿ‡ฑ๐Ÿ‡ป`},{name:`Lebanon`,iso2:`LB`,flag:`๐Ÿ‡ฑ๐Ÿ‡ง`},{name:`Lesotho`,iso2:`LS`,flag:`๐Ÿ‡ฑ๐Ÿ‡ธ`},{name:`Liberia`,iso2:`LR`,flag:`๐Ÿ‡ฑ๐Ÿ‡ท`},{name:`Libya`,iso2:`LY`,flag:`๐Ÿ‡ฑ๐Ÿ‡พ`},{name:`Liechtenstein`,iso2:`LI`,flag:`๐Ÿ‡ฑ๐Ÿ‡ฎ`},{name:`Lithuania`,iso2:`LT`,flag:`๐Ÿ‡ฑ๐Ÿ‡น`},{name:`Luxembourg`,iso2:`LU`,flag:`๐Ÿ‡ฑ๐Ÿ‡บ`},{name:`Madagascar`,iso2:`MG`,flag:`๐Ÿ‡ฒ๐Ÿ‡ฌ`},{name:`Malawi`,iso2:`MW`,flag:`๐Ÿ‡ฒ๐Ÿ‡ผ`},{name:`Malaysia`,iso2:`MY`,flag:`๐Ÿ‡ฒ๐Ÿ‡พ`},{name:`Maldives`,iso2:`MV`,flag:`๐Ÿ‡ฒ๐Ÿ‡ป`},{name:`Mali`,iso2:`ML`,flag:`๐Ÿ‡ฒ๐Ÿ‡ฑ`},{name:`Malta`,iso2:`MT`,flag:`๐Ÿ‡ฒ๐Ÿ‡น`},{name:`Marshall Islands`,iso2:`MH`,flag:`๐Ÿ‡ฒ๐Ÿ‡ญ`},{name:`Mauritania`,iso2:`MR`,flag:`๐Ÿ‡ฒ๐Ÿ‡ท`},{name:`Mauritius`,iso2:`MU`,flag:`๐Ÿ‡ฒ๐Ÿ‡บ`},{name:`Mexico`,iso2:`MX`,flag:`๐Ÿ‡ฒ๐Ÿ‡ฝ`},{name:`Micronesia`,iso2:`FM`,flag:`๐Ÿ‡ซ๐Ÿ‡ฒ`},{name:`Moldova`,iso2:`MD`,flag:`๐Ÿ‡ฒ๐Ÿ‡ฉ`},{name:`Monaco`,iso2:`MC`,flag:`๐Ÿ‡ฒ๐Ÿ‡จ`},{name:`Mongolia`,iso2:`MN`,flag:`๐Ÿ‡ฒ๐Ÿ‡ณ`},{name:`Montenegro`,iso2:`ME`,flag:`๐Ÿ‡ฒ๐Ÿ‡ช`},{name:`Morocco`,iso2:`MA`,flag:`๐Ÿ‡ฒ๐Ÿ‡ฆ`},{name:`Mozambique`,iso2:`MZ`,flag:`๐Ÿ‡ฒ๐Ÿ‡ฟ`},{name:`Myanmar`,iso2:`MM`,flag:`๐Ÿ‡ฒ๐Ÿ‡ฒ`},{name:`Namibia`,iso2:`NA`,flag:`๐Ÿ‡ณ๐Ÿ‡ฆ`},{name:`Nauru`,iso2:`NR`,flag:`๐Ÿ‡ณ๐Ÿ‡ท`},{name:`Nepal`,iso2:`NP`,flag:`๐Ÿ‡ณ๐Ÿ‡ต`},{name:`Netherlands`,iso2:`NL`,flag:`๐Ÿ‡ณ๐Ÿ‡ฑ`},{name:`New Zealand`,iso2:`NZ`,flag:`๐Ÿ‡ณ๐Ÿ‡ฟ`},{name:`Nicaragua`,iso2:`NI`,flag:`๐Ÿ‡ณ๐Ÿ‡ฎ`},{name:`Niger`,iso2:`NE`,flag:`๐Ÿ‡ณ๐Ÿ‡ช`},{name:`Nigeria`,iso2:`NG`,flag:`๐Ÿ‡ณ๐Ÿ‡ฌ`},{name:`North Korea`,iso2:`KP`,flag:`๐Ÿ‡ฐ๐Ÿ‡ต`},{name:`North Macedonia`,iso2:`MK`,flag:`๐Ÿ‡ฒ๐Ÿ‡ฐ`},{name:`Norway`,iso2:`NO`,flag:`๐Ÿ‡ณ๐Ÿ‡ด`},{name:`Oman`,iso2:`OM`,flag:`๐Ÿ‡ด๐Ÿ‡ฒ`},{name:`Pakistan`,iso2:`PK`,flag:`๐Ÿ‡ต๐Ÿ‡ฐ`},{name:`Palau`,iso2:`PW`,flag:`๐Ÿ‡ต๐Ÿ‡ผ`},{name:`Panama`,iso2:`PA`,flag:`๐Ÿ‡ต๐Ÿ‡ฆ`},{name:`Papua New Guinea`,iso2:`PG`,flag:`๐Ÿ‡ต๐Ÿ‡ฌ`},{name:`Paraguay`,iso2:`PY`,flag:`๐Ÿ‡ต๐Ÿ‡พ`},{name:`Peru`,iso2:`PE`,flag:`๐Ÿ‡ต๐Ÿ‡ช`},{name:`Philippines`,iso2:`PH`,flag:`๐Ÿ‡ต๐Ÿ‡ญ`},{name:`Poland`,iso2:`PL`,flag:`๐Ÿ‡ต๐Ÿ‡ฑ`},{name:`Portugal`,iso2:`PT`,flag:`๐Ÿ‡ต๐Ÿ‡น`},{name:`Qatar`,iso2:`QA`,flag:`๐Ÿ‡ถ๐Ÿ‡ฆ`},{name:`Romania`,iso2:`RO`,flag:`๐Ÿ‡ท๐Ÿ‡ด`},{name:`Rwanda`,iso2:`RW`,flag:`๐Ÿ‡ท๐Ÿ‡ผ`},{name:`Saint Kitts and Nevis`,iso2:`KN`,flag:`๐Ÿ‡ฐ๐Ÿ‡ณ`},{name:`Saint Lucia`,iso2:`LC`,flag:`๐Ÿ‡ฑ๐Ÿ‡จ`},{name:`Saint Vincent and the Grenadines`,iso2:`VC`,flag:`๐Ÿ‡ป๐Ÿ‡จ`},{name:`Samoa`,iso2:`WS`,flag:`๐Ÿ‡ผ๐Ÿ‡ธ`},{name:`San Marino`,iso2:`SM`,flag:`๐Ÿ‡ธ๐Ÿ‡ฒ`},{name:`Sao Tome and Principe`,iso2:`ST`,flag:`๐Ÿ‡ธ๐Ÿ‡น`},{name:`Senegal`,iso2:`SN`,flag:`๐Ÿ‡ธ๐Ÿ‡ณ`},{name:`Serbia`,iso2:`RS`,flag:`๐Ÿ‡ท๐Ÿ‡ธ`},{name:`Seychelles`,iso2:`SC`,flag:`๐Ÿ‡ธ๐Ÿ‡จ`},{name:`Sierra Leone`,iso2:`SL`,flag:`๐Ÿ‡ธ๐Ÿ‡ฑ`},{name:`Singapore`,iso2:`SG`,flag:`๐Ÿ‡ธ๐Ÿ‡ฌ`},{name:`Slovakia`,iso2:`SK`,flag:`๐Ÿ‡ธ๐Ÿ‡ฐ`},{name:`Slovenia`,iso2:`SI`,flag:`๐Ÿ‡ธ๐Ÿ‡ฎ`},{name:`Solomon Islands`,iso2:`SB`,flag:`๐Ÿ‡ธ๐Ÿ‡ง`},{name:`Somalia`,iso2:`SO`,flag:`๐Ÿ‡ธ๐Ÿ‡ด`},{name:`South Korea`,iso2:`KR`,flag:`๐Ÿ‡ฐ๐Ÿ‡ท`},{name:`South Sudan`,iso2:`SS`,flag:`๐Ÿ‡ธ๐Ÿ‡ธ`},{name:`Spain`,iso2:`ES`,flag:`๐Ÿ‡ช๐Ÿ‡ธ`},{name:`Sri Lanka`,iso2:`LK`,flag:`๐Ÿ‡ฑ๐Ÿ‡ฐ`},{name:`Sudan`,iso2:`SD`,flag:`๐Ÿ‡ธ๐Ÿ‡ฉ`},{name:`Suriname`,iso2:`SR`,flag:`๐Ÿ‡ธ๐Ÿ‡ท`},{name:`Sweden`,iso2:`SE`,flag:`๐Ÿ‡ธ๐Ÿ‡ช`},{name:`Switzerland`,iso2:`CH`,flag:`๐Ÿ‡จ๐Ÿ‡ญ`},{name:`Syria`,iso2:`SY`,flag:`๐Ÿ‡ธ๐Ÿ‡พ`},{name:`Tajikistan`,iso2:`TJ`,flag:`๐Ÿ‡น๐Ÿ‡ฏ`},{name:`Tanzania`,iso2:`TZ`,flag:`๐Ÿ‡น๐Ÿ‡ฟ`},{name:`Thailand`,iso2:`TH`,flag:`๐Ÿ‡น๐Ÿ‡ญ`},{name:`Togo`,iso2:`TG`,flag:`๐Ÿ‡น๐Ÿ‡ฌ`},{name:`Tonga`,iso2:`TO`,flag:`๐Ÿ‡น๐Ÿ‡ด`},{name:`Trinidad and Tobago`,iso2:`TT`,flag:`๐Ÿ‡น๐Ÿ‡น`},{name:`Tunisia`,iso2:`TN`,flag:`๐Ÿ‡น๐Ÿ‡ณ`},{name:`Turkey`,iso2:`TR`,flag:`๐Ÿ‡น๐Ÿ‡ท`},{name:`Turkmenistan`,iso2:`TM`,flag:`๐Ÿ‡น๐Ÿ‡ฒ`},{name:`Tuvalu`,iso2:`TV`,flag:`๐Ÿ‡น๐Ÿ‡ป`},{name:`Uganda`,iso2:`UG`,flag:`๐Ÿ‡บ๐Ÿ‡ฌ`},{name:`Ukraine`,iso2:`UA`,flag:`๐Ÿ‡บ๐Ÿ‡ฆ`},{name:`United Arab Emirates`,iso2:`AE`,flag:`๐Ÿ‡ฆ๐Ÿ‡ช`},{name:`Uruguay`,iso2:`UY`,flag:`๐Ÿ‡บ๐Ÿ‡พ`},{name:`Uzbekistan`,iso2:`UZ`,flag:`๐Ÿ‡บ๐Ÿ‡ฟ`},{name:`Vanuatu`,iso2:`VU`,flag:`๐Ÿ‡ป๐Ÿ‡บ`},{name:`Venezuela`,iso2:`VE`,flag:`๐Ÿ‡ป๐Ÿ‡ช`},{name:`Vietnam`,iso2:`VN`,flag:`๐Ÿ‡ป๐Ÿ‡ณ`},{name:`Yemen`,iso2:`YE`,flag:`๐Ÿ‡พ๐Ÿ‡ช`},{name:`Zambia`,iso2:`ZM`,flag:`๐Ÿ‡ฟ๐Ÿ‡ฒ`},{name:`Zimbabwe`,iso2:`ZW`,flag:`๐Ÿ‡ฟ๐Ÿ‡ผ`},{name:`Timor-Leste`,iso2:`TL`,flag:`๐Ÿ‡น๐Ÿ‡ฑ`}],K={passport:`Passport`,id_card:`ID Card`,drivers_license:`Driver's License`,residence_permit:`Residence Permit`},q={turn_left:`Slowly turn your head to the left, and hold`,turn_right:`Slowly turn your head to the right, and hold`,blink:`Blink slowly`,smile:`Smile, and hold it`,nod:`Slowly nod your head`,move_closer:`Slowly move closer to the camera`},J={cls:`warn`,icon:`โณ`,title:`Link expired`,copy:`This verification link has expired.`},ae={approved:{cls:`ok`,icon:`โœ“`,title:`Already complete`,copy:`This verification has already been completed.`},rejected:{cls:`ok`,icon:`โœ“`,title:`Already complete`,copy:`This verification has already been completed.`},requires_review:{cls:`ok`,icon:`โœ“`,title:`Already complete`,copy:`This verification has already been submitted and is being reviewed.`},expired:J,cancelled:{cls:`warn`,icon:`โณ`,title:`Cancelled`,copy:`This verification was cancelled.`}},Y=e=>`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">${e}</svg>`,oe={turn_right:Y(`<path d="M5 12h14M13 6l6 6-6 6"/>`),turn_left:Y(`<path d="M19 12H5M11 6l-6 6 6 6"/>`),nod:Y(`<path d="M12 5v14M6 13l6 6 6-6"/>`),move_closer:Y(`<circle cx="12" cy="12" r="4"/><path d="M12 2v3M12 19v3M2 12h3M19 12h3"/>`),blink:Y(`<path d="M2 12s4-7 10-7 10 7 10 7-4 7-10 7S2 12 2 12z"/><circle cx="12" cy="12" r="3"/>`),smile:Y(`<path d="M8 14s1.5 2 4 2 4-2 4-2"/><path d="M9 9h.01M15 9h.01"/>`)},se=Y(`<path d="M20 6 9 17l-5-5"/>`),X=e=>`<svg viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">${e}</svg>`,ce={welcome:X(`<path d="M32 7 52 14v14c0 12.5-8.2 21.6-20 25.6C20.2 49.6 12 40.5 12 28V14z"/><path d="M23 30.5l6.2 6.2L41 24.5"/>`),front_capture:X(`<rect x="7" y="15" width="50" height="34" rx="5"/><circle cx="22" cy="28" r="5"/><path d="M14 42c1-5 5-7 8-7s7 2 8 7"/><path d="M38 27h12M38 34h12M38 41h8"/>`),back_capture:X(`<rect x="7" y="15" width="50" height="34" rx="5"/><rect x="7" y="20" width="50" height="6" fill="currentColor" stroke="none" opacity=".18"/><path d="M14 34h36M14 41h24"/>`),selfie_capture:X(`<path d="M10 20v-6a4 4 0 0 1 4-4h6"/><path d="M44 10h6a4 4 0 0 1 4 4v6"/><path d="M54 44v6a4 4 0 0 1-4 4h-6"/><path d="M20 54h-6a4 4 0 0 1-4-4v-6"/><circle cx="32" cy="27" r="8"/><path d="M19 50c0-7 6-11 13-11s13 4 13 11"/>`),active_liveness:X(`<circle cx="32" cy="30" r="13"/><circle cx="27" cy="27" r="1.2" fill="currentColor" stroke="none"/><circle cx="37" cy="27" r="1.2" fill="currentColor" stroke="none"/><path d="M26 34c2 2.5 10 2.5 12 0"/><path d="M13 30H6M10 26l-4 4 4 4"/><path d="M51 30h7M54 26l4 4-4 4"/>`)};var le=class{constructor(e,t,n,r=globalThis.navigator,i=L(),a=R,o=G(),s=V){this.doc=e,this.theme=t,this.handlers=n,p(this,`root`,void 0),p(this,`body`,void 0),p(this,`footer`,void 0),p(this,`styleEl`,void 0),p(this,`brandEl`,void 0),p(this,`camera`,void 0),p(this,`analyzer`,void 0),p(this,`tuning`,void 0),p(this,`docAnalyzer`,void 0),p(this,`docTuning`,void 0),p(this,`timers`,[]),p(this,`cleanups`,[]),this.camera=new T(e,r),this.analyzer=i,this.tuning=a,this.docAnalyzer=o,this.docTuning=s,this.root=this.el(`div`,{class:`arkyc-root`}),this.styleEl=this.el(`style`,{text:t.stylesheet()}),this.root.appendChild(this.styleEl);let c=this.el(`div`,{class:`arkyc-card`}),l=this.el(`div`,{class:`arkyc-header`});this.brandEl=this.el(`div`,{class:`arkyc-brand`}),this.fillBrand(),l.appendChild(this.brandEl);let u=this.el(`button`,{class:`arkyc-close`,html:`&times;`,"aria-label":`Close`});u.addEventListener(`click`,()=>this.handlers.onClose()),l.appendChild(u),this.body=this.el(`div`,{class:`arkyc-body`}),this.footer=this.el(`div`,{class:`arkyc-footer`}),c.appendChild(l),c.appendChild(this.body),c.appendChild(this.footer),this.root.appendChild(c)}fillBrand(){this.clear(this.brandEl);let e=Date.now()-Math.floor(600*1e3*Math.random());this.theme.showBranding&&(this.theme.logoUrl||this.theme.name)?(this.theme.logoUrl&&this.brandEl.appendChild(this.el(`img`,{class:`arkyc-logo`,src:this.theme.logoUrl+`?stamp=`+e})),this.theme.name&&this.brandEl.appendChild(this.el(`span`,{class:`arkyc-brand-name`,text:this.theme.name}))):this.brandEl.appendChild(this.el(`p`,{class:`arkyc-title`,text:`Verify your identity`}))}applyBranding(e){this.theme=new w(e),this.styleEl.textContent=this.theme.stylesheet(),this.fillBrand()}get element(){return this.root}get cameraSupported(){return this.camera.supported}destroy(){this.timers.forEach(e=>clearInterval(e)),this.timers=[],this.cleanups.forEach(e=>e()),this.cleanups=[],this.camera.stop()}render(e){switch(this.destroy(),this.clear(this.body),this.clear(this.footer),this.root.classList.remove(`arkyc-handoff`),e.step){case`welcome`:return this.renderWelcome(e.handoffAvailable);case`document_selection`:return this.renderDocumentSelection();case`front_capture`:return this.renderCapture(`Front of document`,`environment`,e.allowSkip,!1,e.strictCapture);case`back_capture`:return this.renderCapture(`Back of document`,`environment`,e.allowSkip,!1,e.strictCapture);case`selfie_capture`:return this.renderCapture(`Take a selfie`,`user`,e.allowSkip,!0,e.strictCapture);case`active_liveness`:return this.renderActiveLiveness(e.livenessChallenges??[],e.allowSkip,e.requireLiveCamera);case`ocr_processing`:return this.renderProcessing(`Reading your documentโ€ฆ`);case`passive_liveness`:return this.renderProcessing(`Checking livenessโ€ฆ`);case`face_match`:return this.renderProcessing(`Matching your faceโ€ฆ`);case`processing`:return this.renderProcessing(e.statusLabel??`Finalising verificationโ€ฆ`);case`result`:return this.renderResult(e.decision??null,e.errorMessage,{terminal:e.terminalNotice,status:e.status})}}appendArt(e){let t=ce[e];t&&this.body.appendChild(this.el(`div`,{class:`arkyc-illus`,html:t}))}renderWelcome(e){this.appendArt(`welcome`),this.body.appendChild(this.el(`h2`,{class:`arkyc-h`,text:`Verify your identity`})),this.body.appendChild(this.el(`p`,{class:`arkyc-p`,text:`You will need a government-issued ID and a moment to take a selfie. Your data is processed securely.`})),this.footer.appendChild(this.button(`Get started`,()=>this.handlers.onStart())),e&&this.footer.appendChild(this.button(`Continue on your phone`,()=>this.handlers.onUsePhone(),`arkyc-btn-ghost`))}renderLoading(e=`Loadingโ€ฆ`){this.destroy(),this.clear(this.body),this.clear(this.footer),this.root.classList.remove(`arkyc-handoff`),this.renderProcessing(e)}renderInstruction(e,t,n,r,i){this.destroy(),this.clear(this.body),this.clear(this.footer),this.root.classList.remove(`arkyc-handoff`),this.appendArt(e),this.body.appendChild(this.el(`h2`,{class:`arkyc-h`,text:t})),this.body.appendChild(this.el(`p`,{class:`arkyc-p`,text:n})),this.footer.appendChild(this.button(r,i))}renderHandoff(e,t){this.destroy(),this.clear(this.body),this.clear(this.footer),this.root.classList.add(`arkyc-handoff`),this.body.appendChild(this.el(`h2`,{class:`arkyc-h`,text:`Continue on your phone`})),this.body.appendChild(this.el(`p`,{class:`arkyc-p`,text:`Scan this code with your phone camera to finish verifying there.`})),this.body.appendChild(this.el(`div`,{class:`arkyc-qr`,html:e}));let n=this.el(`div`,{class:`arkyc-handoff-wait`});n.appendChild(this.el(`div`,{class:`arkyc-spinner sm`})),n.appendChild(this.el(`span`,{text:`Waiting for your phoneโ€ฆ`})),this.body.appendChild(n),t&&this.footer.appendChild(this.button(`Continue on this device`,()=>this.handlers.onContinueHere(),`arkyc-btn-ghost`))}renderDocumentSelection(){this.body.appendChild(this.el(`h2`,{class:`arkyc-h`,text:`Select your document`}));let e=this.el(`select`,{class:`arkyc-btn arkyc-btn-ghost arkyc-text-center`,name:`country`,autocomplete:`country`,"aria-label":`Country`}),t=this.el(`option`,{value:``,selected:`selected`});t.textContent=`Country`,e.appendChild(t),ie.forEach(({name:t,iso2:n,flag:r})=>{let i=this.el(`option`,{value:n});i.textContent=`${r} ${t}`,e.appendChild(i)});let n=this.el(`div`,{class:`arkyc-choices`});n.appendChild(e),Object.keys(K).forEach(t=>{let r=this.button(K[t],()=>this.handlers.onDocumentSelected(t,(e.value||``).trim().toUpperCase()));r.classList.add(`arkyc-btn-ghost`),n.appendChild(r)}),this.body.appendChild(n)}renderCapture(e,t,n,r=!1,i=!1){let a=i&&!r;this.body.appendChild(this.el(`h2`,{class:`arkyc-h`,text:e})),this.body.appendChild(this.el(`p`,{class:`arkyc-p`,text:`Position it clearly in frame, then capture.`}));let o=this.el(`input`,{type:`file`,accept:`image/*`,class:`arkyc-hidden`});if(o.addEventListener(`change`,()=>this.handlers.onImage(T.fileFromInput(o))),this.body.appendChild(o),this.camera.supported){let s=this.el(`video`,{class:`arkyc-preview${r?` selfie`:``}`}),c=r?this.buildFaceStage(s):null,l=r?null:this.buildDocStage(s),u=c?.stage??l.stage;this.body.appendChild(u);let d=this.el(`p`,{class:`arkyc-p arkyc-hint`});this.body.appendChild(d);let f=a=>{if(this.destroy(),a){let e=URL.createObjectURL(a),t=this.el(`img`,{class:`arkyc-preview${r?` selfie`:``}`,src:e});u.replaceWith(t),this.cleanups.push(()=>URL.revokeObjectURL(e))}else u.classList.add(`arkyc-hidden`);this.clear(this.footer),d.textContent=`โœ“ Captured`,this.footer.appendChild(this.button(`Continue`,()=>this.handlers.onImage(a)));let o=this.button(`Retake`,()=>{this.destroy(),this.clear(this.body),this.clear(this.footer),this.renderCapture(e,t,n,r,i)});o.classList.add(`arkyc-btn-ghost`),this.footer.appendChild(o)},p=()=>void this.camera.grabFrame(s).then(f);this.camera.start(s,t).catch(()=>{if(u.classList.add(`arkyc-hidden`),a){d.textContent=`Camera access is required to scan your document. Please allow access and try again.`;return}o.click()}),r?this.runSelfieAutoCapture(s,d,p,c):(this.runDocumentAutoCapture(s,d,l,a,p),a||this.footer.appendChild(this.button(`Capture`,p)))}else if(a)this.body.appendChild(this.el(`div`,{class:`arkyc-badge err`,html:`!`})),this.body.appendChild(this.el(`p`,{class:`arkyc-p`,text:`This step needs a working camera to scan your document. Please retry on a device with a camera.`}));else{let e=this.button(`Upload photo`,()=>o.click());this.footer.appendChild(e)}if(n){let e=this.button(`Skip (demo)`,()=>this.handlers.onImage(null));e.classList.add(`arkyc-btn-ghost`),this.footer.appendChild(e)}}onCameraLive(e,t){if((e.readyState??0)>=2){t();return}e.addEventListener(`playing`,t,{once:!0})}runDocumentAutoCapture(e,t,n,r,i){let a=()=>{if(r){t.textContent=`Document scanning isnโ€™t available on this device.`;return}this.runDocumentBrightnessCapture(e,t,n,i)},o=this.docAnalyzer;if(!o)return a();t.textContent=`Starting cameraโ€ฆ`;let s=!1,c=!1;this.cleanups.push(()=>{s=!0}),this.onCameraLive(e,()=>{!s&&!c&&(t.textContent=`Getting readyโ€ฆ`)}),o.ready().then(r=>{if(c=!0,s)return;if(!r){a();return}let l=0,u=null,d=null,f=(e,t)=>e==null?t:e*.6+t*.4,p=setInterval(()=>{let r=o.analyze(e);if(!r)return;u=f(u,r.fill),d=f(d,r.edgeStrength);let{ready:a,hint:s}=W({...r,fill:u,edgeStrength:d},this.docTuning);t.textContent=s,n.setFrame(r.present?r.rect:null),n.setQuality(a?`good`:r.present?`wait`:`bad`),l=a?l+1:Math.max(0,l-1),l>=this.docTuning.hold&&(clearInterval(p),n.setQuality(`good`),i())},250);this.timers.push(p)})}runDocumentBrightnessCapture(e,t,n,r){let i=0,a=setInterval(()=>{let o=this.camera.sampleQuality(e);o&&(o.tooDark?(t.textContent=`Too dark โ€” find better lighting`,i=0,n.setQuality(`bad`)):o.glare?(t.textContent=`Reduce glare on the document`,i=0,n.setQuality(`bad`)):(t.textContent=`Looks good โ€” hold steady`,i+=1,n.setQuality(`good`)),i>=5&&(clearInterval(a),r()))},300);this.timers.push(a)}runSelfieAutoCapture(e,t,n,r){let i=this.analyzer,a=()=>this.footer.appendChild(this.button(`Capture`,n));if(!i){t.textContent=`Center your face, then capture`,a();return}t.textContent=`Starting cameraโ€ฆ`;let o=!1,s=!1;this.cleanups.push(()=>{o=!0}),this.onCameraLive(e,()=>{!o&&!s&&(t.textContent=`Getting readyโ€ฆ`)}),i.ready().then(c=>{if(s=!0,o)return;if(!c){t.textContent=`Center your face, then capture`,a();return}let l=0,u=setInterval(()=>{let a=i.analyze(e);if(!a||!a.present){t.textContent=`Position your face in the circle`,l=0,r.setState(`wait`),r.setProgress(0);return}B(a,this.tuning)?(t.textContent=`Hold stillโ€ฆ`,l+=1,r.setState(`good`),r.setProgress(l/4)):(t.textContent=a.scale<=this.tuning.selfieMinScale?`Move a little closer`:`Center your face`,l=0,r.setState(`wait`),r.setProgress(0)),l>=4&&(clearInterval(u),r.setState(`done`),r.setProgress(1),n())},180);this.timers.push(u)})}renderActiveLiveness(e,t,n){this.body.appendChild(this.el(`h2`,{class:`arkyc-h`,text:`Liveness check`}));let r=this.el(`p`,{class:`arkyc-p`,text:`Follow the on-screen prompts. Keep your face centred in the circle.`});if(this.body.appendChild(r),!this.camera.supported||!this.camera.canRecord){if(n){if(this.body.appendChild(this.el(`div`,{class:`arkyc-badge err`,html:`!`})),r.textContent=`This check needs camera access on a supported device. Please retry on a device with a working camera.`,t){let t=this.button(`Skip (demo)`,()=>this.handlers.onActiveLiveness(null,e));t.classList.add(`arkyc-btn-ghost`),this.footer.appendChild(t)}return}let i=this.button(`I performed the steps`,()=>this.handlers.onActiveLiveness(null,e));if(this.footer.appendChild(i),t){let t=this.button(`Skip (demo)`,()=>this.handlers.onActiveLiveness(null,e));t.classList.add(`arkyc-btn-ghost`),this.footer.appendChild(t)}return}let i=this.el(`video`,{class:`arkyc-preview selfie`}),a=this.buildFaceStage(i),o=this.buildDots(e.length);e.length>1&&this.body.appendChild(o.el),this.body.appendChild(a.stage);let s=null,c=0,l=[],u=z(e[0]??`blink`,this.tuning),d=(t=!1)=>{let n=e[c];if(!n){r.textContent=`Hold stillโ€ฆ`;return}r.textContent=t?`โœ“ ${q[n]}`:`Step ${c+1} of ${e.length}: ${q[n]}`},f=()=>{a.setCue(e[c]??null),a.setState(`wait`),a.setProgress(0),o.setActive(c)},p=()=>{h.setAttribute(`disabled`,`true`),this.camera.grabFrame(i).then(e=>Promise.resolve(s?.stop()??Promise.resolve(null)).then(t=>this.handlers.onActiveLiveness(t,l,e)))},m=()=>{if(c>=e.length)return;let t=e[c];if(t&&l.push(t),o.markDone(c),c+=1,c>=e.length){p();return}u=z(e[c],this.tuning),d(),f(),c===e.length-1&&(h.textContent=`Finish`)},h=this.button(`Next`,()=>m());e.length<=1&&(h.textContent=`Finish`);let g=!1,_=()=>{g||(g=!0,this.footer.appendChild(h))};if(this.camera.start(i,`user`).then(t=>{s=this.camera.recordStart(t),d(),f();let n=this.analyzer;if(!n){_();return}let r=!1;this.cleanups.push(()=>{r=!0}),n.ready().then(t=>{if(r)return;if(!t){_();return}let o=!1,s=setInterval(()=>{if(c>=e.length){clearInterval(s);return}if(o)return;let t=n.analyze(i);if(!t)return;let r=u.feed(t);if(a.setProgress(u.progress),r){a.setState(`done`),d(!0),o=!0;let e=setTimeout(()=>{o=!1,m()},650);this.cleanups.push(()=>clearTimeout(e))}else a.setState(u.progress>0?`good`:`wait`)},160);this.timers.push(s)})}).catch(()=>{if(a.stage.classList.add(`arkyc-hidden`),n){r.textContent=`Camera access is required to continue. Please allow access and try again.`;return}this.handlers.onActiveLiveness(null,e)}),t){let t=this.button(`Skip (demo)`,()=>this.handlers.onActiveLiveness(null,e));t.classList.add(`arkyc-btn-ghost`),this.footer.appendChild(t)}}buildFaceStage(e){let t=this.el(`div`,{class:`arkyc-stage`});t.setAttribute(`data-state`,`wait`),t.appendChild(e);let n=this.el(`div`,{class:`arkyc-ring`,html:`<svg viewBox="0 0 100 100"><circle class="arkyc-ring-track" cx="50" cy="50" r="46"/><circle class="arkyc-ring-arc" cx="50" cy="50" r="46"/></svg>`});t.appendChild(n);let r=this.el(`div`,{class:`arkyc-cue`});t.appendChild(r),t.appendChild(this.el(`div`,{class:`arkyc-check`,html:se}));let i=n.querySelector(`.arkyc-ring-arc`),a=2*Math.PI*46;return i&&(i.style.strokeDasharray=String(a),i.style.strokeDashoffset=String(a)),{stage:t,setProgress:e=>{i&&(i.style.strokeDashoffset=String(a*(1-Math.max(0,Math.min(1,e)))))},setState:e=>t.setAttribute(`data-state`,e),setCue:e=>{r.className=`arkyc-cue`+(e?` show arkyc-cue-${e}`:``),r.innerHTML=e?oe[e]:``}}}buildDots(e){let t=this.el(`div`,{class:`arkyc-dots`}),n=[];for(let r=0;r<e;r+=1){let e=this.el(`div`,{class:`arkyc-dot`});n.push(e),t.appendChild(e)}return{el:t,setActive:e=>n.forEach((t,n)=>t.classList.toggle(`active`,n===e&&!t.classList.contains(`done`))),markDone:e=>{let t=n[e];t&&(t.classList.remove(`active`),t.classList.add(`done`))}}}buildDocStage(e){let t=this.el(`div`,{class:`arkyc-doc`});t.setAttribute(`data-q`,`wait`),t.appendChild(e);let n=this.el(`div`,{class:`arkyc-doc-frame`});for(let e of[`tl`,`tr`,`bl`,`br`])n.appendChild(this.el(`span`,{class:`arkyc-corner ${e}`}));return n.appendChild(this.el(`div`,{class:`arkyc-scan`})),t.appendChild(n),{stage:t,setQuality:e=>t.setAttribute(`data-q`,e),setFrame:e=>t.setAttribute(`data-detected`,e?`true`:`false`)}}renderProcessing(e){this.body.appendChild(this.el(`div`,{class:`arkyc-spinner`})),this.body.appendChild(this.el(`p`,{class:`arkyc-p`,text:e}))}renderResult(e,t,n={}){if(t)this.body.appendChild(this.el(`div`,{class:`arkyc-badge err`,html:`!`})),this.body.appendChild(this.el(`h2`,{class:`arkyc-h`,text:`Something went wrong`})),this.body.appendChild(this.el(`p`,{class:`arkyc-p`,text:t}));else if(n.terminal){let e=ae[n.status??`expired`]??J;this.body.appendChild(this.el(`div`,{class:`arkyc-badge ${e.cls}`,text:e.icon})),this.body.appendChild(this.el(`h2`,{class:`arkyc-h`,text:e.title})),this.body.appendChild(this.el(`p`,{class:`arkyc-p`,text:e.copy})),this.footer.appendChild(this.button(`Close`,()=>this.handlers.onClose()));return}else{let t={approved:{cls:`ok`,icon:`โœ“`,title:`Verified`,copy:`Your identity has been verified.`},requires_review:{cls:`warn`,icon:`โณ`,title:`Under review`,copy:`Your verification is being reviewed. We will be in touch shortly.`},rejected:{cls:`err`,icon:`โœ•`,title:`Not verified`,copy:`We could not verify your identity. Please try again.`}},n=t[e??`requires_review`]??t.requires_review;this.body.appendChild(this.el(`div`,{class:`arkyc-badge ${n.cls}`,text:n.icon})),this.body.appendChild(this.el(`h2`,{class:`arkyc-h`,text:n.title})),this.body.appendChild(this.el(`p`,{class:`arkyc-p`,text:n.copy}))}this.footer.appendChild(this.button(`Done`,()=>this.handlers.onAcknowledge()))}button(e,t,n){let r=n?`arkyc-btn ${n}`:`arkyc-btn`,i=this.el(`button`,{class:r,text:e}),a=!1;return i.addEventListener(`click`,()=>{a||(a=!0,i.setAttribute(`disabled`,`true`),i.classList.add(`arkyc-busy`),t())}),i}clear(e){for(;e.firstChild;)e.removeChild(e.firstChild)}el(e,t={}){let n=this.doc.createElement(e);for(let[e,r]of Object.entries(t))r!=null&&(e===`class`?n.className=r:e===`text`?n.textContent=r:e===`html`?n.innerHTML=r:e===`value`||e===`src`||e===`type`||e===`accept`||e===`placeholder`?n[e]=r:n.setAttribute(e,r));return n}};function ue(e){let t=e.userAgent||``;if(!t)return!1;let n=/Android|iPhone|iPad|iPod|Opera Mini|IEMobile|Mobile|BlackBerry|Windows Phone/i.test(t),r=e.platform===`MacIntel`&&(e.maxTouchPoints??0)>1;return!n&&!r}var de=l(s(((e,t)=>{var n=function(){var e=function(e,t){var r=e,a=n[t],p=null,m=0,h=null,g=[],v={},y=function(e,t){m=r*4+17,p=function(e){for(var t=Array(e),n=0;n<e;n+=1){t[n]=Array(e);for(var r=0;r<e;r+=1)t[n][r]=null}return t}(m),b(0,0),b(m-7,0),b(0,m-7),C(),S(),T(e,t),r>=7&&w(e),h??(h=O(r,a,g)),E(h,t)},b=function(e,t){for(var n=-1;n<=7;n+=1)if(!(e+n<=-1||m<=e+n))for(var r=-1;r<=7;r+=1)t+r<=-1||m<=t+r||(0<=n&&n<=6&&(r==0||r==6)||0<=r&&r<=6&&(n==0||n==6)||2<=n&&n<=4&&2<=r&&r<=4?p[e+n][t+r]=!0:p[e+n][t+r]=!1)},x=function(){for(var e=0,t=0,n=0;n<8;n+=1){y(!0,n);var r=i.getLostPoint(v);(n==0||e>r)&&(e=r,t=n)}return t},S=function(){for(var e=8;e<m-8;e+=1)p[e][6]??(p[e][6]=e%2==0);for(var t=8;t<m-8;t+=1)p[6][t]??(p[6][t]=t%2==0)},C=function(){for(var e=i.getPatternPosition(r),t=0;t<e.length;t+=1)for(var n=0;n<e.length;n+=1){var a=e[t],o=e[n];if(p[a][o]==null)for(var s=-2;s<=2;s+=1)for(var c=-2;c<=2;c+=1)s==-2||s==2||c==-2||c==2||s==0&&c==0?p[a+s][o+c]=!0:p[a+s][o+c]=!1}},w=function(e){for(var t=i.getBCHTypeNumber(r),n=0;n<18;n+=1){var a=!e&&(t>>n&1)==1;p[Math.floor(n/3)][n%3+m-8-3]=a}for(var n=0;n<18;n+=1){var a=!e&&(t>>n&1)==1;p[n%3+m-8-3][Math.floor(n/3)]=a}},T=function(e,t){for(var n=a<<3|t,r=i.getBCHTypeInfo(n),o=0;o<15;o+=1){var s=!e&&(r>>o&1)==1;o<6?p[o][8]=s:o<8?p[o+1][8]=s:p[m-15+o][8]=s}for(var o=0;o<15;o+=1){var s=!e&&(r>>o&1)==1;o<8?p[8][m-o-1]=s:o<9?p[8][15-o-1+1]=s:p[8][15-o-1]=s}p[m-8][8]=!e},E=function(e,t){for(var n=-1,r=m-1,a=7,o=0,s=i.getMaskFunction(t),c=m-1;c>0;c-=2)for(c==6&&--c;;){for(var l=0;l<2;l+=1)if(p[r][c-l]==null){var u=!1;o<e.length&&(u=(e[o]>>>a&1)==1),s(r,c-l)&&(u=!u),p[r][c-l]=u,--a,a==-1&&(o+=1,a=7)}if(r+=n,r<0||m<=r){r-=n,n=-n;break}}},D=function(e,t){for(var n=0,r=0,a=0,s=Array(t.length),c=Array(t.length),l=0;l<t.length;l+=1){var u=t[l].dataCount,d=t[l].totalCount-u;r=Math.max(r,u),a=Math.max(a,d),s[l]=Array(u);for(var f=0;f<s[l].length;f+=1)s[l][f]=255&e.getBuffer()[f+n];n+=u;var p=i.getErrorCorrectPolynomial(d),m=o(s[l],p.getLength()-1).mod(p);c[l]=Array(p.getLength()-1);for(var f=0;f<c[l].length;f+=1){var h=f+m.getLength()-c[l].length;c[l][f]=h>=0?m.getAt(h):0}}for(var g=0,f=0;f<t.length;f+=1)g+=t[f].totalCount;for(var _=Array(g),v=0,f=0;f<r;f+=1)for(var l=0;l<t.length;l+=1)f<s[l].length&&(_[v]=s[l][f],v+=1);for(var f=0;f<a;f+=1)for(var l=0;l<t.length;l+=1)f<c[l].length&&(_[v]=c[l][f],v+=1);return _},O=function(e,t,n){for(var r=s.getRSBlocks(e,t),a=c(),o=0;o<n.length;o+=1){var l=n[o];a.put(l.getMode(),4),a.put(l.getLength(),i.getLengthInBits(l.getMode(),e)),l.write(a)}for(var u=0,o=0;o<r.length;o+=1)u+=r[o].dataCount;if(a.getLengthInBits()>u*8)throw`code length overflow. (`+a.getLengthInBits()+`>`+u*8+`)`;for(a.getLengthInBits()+4<=u*8&&a.put(0,4);a.getLengthInBits()%8!=0;)a.putBit(!1);for(;!(a.getLengthInBits()>=u*8||(a.put(236,8),a.getLengthInBits()>=u*8));)a.put(17,8);return D(a,r)};v.addData=function(e,t){t=t||`Byte`;var n=null;switch(t){case`Numeric`:n=l(e);break;case`Alphanumeric`:n=u(e);break;case`Byte`:n=d(e);break;case`Kanji`:n=f(e);break;default:throw`mode:`+t}g.push(n),h=null},v.isDark=function(e,t){if(e<0||m<=e||t<0||m<=t)throw e+`,`+t;return p[e][t]},v.getModuleCount=function(){return m},v.make=function(){if(r<1){for(var e=1;e<40;e++){for(var t=s.getRSBlocks(e,a),n=c(),o=0;o<g.length;o++){var l=g[o];n.put(l.getMode(),4),n.put(l.getLength(),i.getLengthInBits(l.getMode(),e)),l.write(n)}for(var u=0,o=0;o<t.length;o++)u+=t[o].dataCount;if(n.getLengthInBits()<=u*8)break}r=e}y(!1,x())},v.createTableTag=function(e,t){e=e||2,t=t===void 0?e*4:t;var n=``;n+=`<table style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: `+t+`px;`,n+=`">`,n+=`<tbody>`;for(var r=0;r<v.getModuleCount();r+=1){n+=`<tr>`;for(var i=0;i<v.getModuleCount();i+=1)n+=`<td style="`,n+=` border-width: 0px; border-style: none;`,n+=` border-collapse: collapse;`,n+=` padding: 0px; margin: 0px;`,n+=` width: `+e+`px;`,n+=` height: `+e+`px;`,n+=` background-color: `,n+=v.isDark(r,i)?`#000000`:`#ffffff`,n+=`;`,n+=`"/>`;n+=`</tr>`}return n+=`</tbody>`,n+=`</table>`,n},v.createSvgTag=function(e,t,n,r){var i={};typeof arguments[0]==`object`&&(i=arguments[0],e=i.cellSize,t=i.margin,n=i.alt,r=i.title),e=e||2,t=t===void 0?e*4:t,n=typeof n==`string`?{text:n}:n||{},n.text=n.text||null,n.id=n.text?n.id||`qrcode-description`:null,r=typeof r==`string`?{text:r}:r||{},r.text=r.text||null,r.id=r.text?r.id||`qrcode-title`:null;var a=v.getModuleCount()*e+t*2,o,s,c,l,u=``,d=`l`+e+`,0 0,`+e+` -`+e+`,0 0,-`+e+`z `;for(u+=`<svg version="1.1" xmlns="http://www.w3.org/2000/svg"`,u+=i.scalable?``:` width="`+a+`px" height="`+a+`px"`,u+=` viewBox="0 0 `+a+` `+a+`" `,u+=` preserveAspectRatio="xMinYMin meet"`,u+=r.text||n.text?` role="img" aria-labelledby="`+k([r.id,n.id].join(` `).trim())+`"`:``,u+=`>`,u+=r.text?`<title id="`+k(r.id)+`">`+k(r.text)+`</title>`:``,u+=n.text?`<description id="`+k(n.id)+`">`+k(n.text)+`</description>`:``,u+=`<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>`,u+=`<path d="`,c=0;c<v.getModuleCount();c+=1)for(l=c*e+t,o=0;o<v.getModuleCount();o+=1)v.isDark(c,o)&&(s=o*e+t,u+=`M`+s+`,`+l+d);return u+=`" stroke="transparent" fill="black"/>`,u+=`</svg>`,u},v.createDataURL=function(e,t){e=e||2,t=t===void 0?e*4:t;var n=v.getModuleCount()*e+t*2,r=t,i=n-t;return _(n,n,function(t,n){if(r<=t&&t<i&&r<=n&&n<i){var a=Math.floor((t-r)/e),o=Math.floor((n-r)/e);return+!v.isDark(o,a)}else return 1})},v.createImgTag=function(e,t,n){e=e||2,t=t===void 0?e*4:t;var r=v.getModuleCount()*e+t*2,i=``;return i+=`<img`,i+=` src="`,i+=v.createDataURL(e,t),i+=`"`,i+=` width="`,i+=r,i+=`"`,i+=` height="`,i+=r,i+=`"`,n&&(i+=` alt="`,i+=k(n),i+=`"`),i+=`/>`,i};var k=function(e){for(var t=``,n=0;n<e.length;n+=1){var r=e.charAt(n);switch(r){case`<`:t+=`&lt;`;break;case`>`:t+=`&gt;`;break;case`&`:t+=`&amp;`;break;case`"`:t+=`&quot;`;break;default:t+=r;break}}return t},A=function(e){var t=1;e=e===void 0?t*2:e;var n=v.getModuleCount()*t+e*2,r=e,i=n-e,a,o,s,c,l,u={"โ–ˆโ–ˆ":`โ–ˆ`,"โ–ˆ ":`โ–€`," โ–ˆ":`โ–„`," ":` `},d={"โ–ˆโ–ˆ":`โ–€`,"โ–ˆ ":`โ–€`," โ–ˆ":` `," ":` `},f=``;for(a=0;a<n;a+=2){for(s=Math.floor((a-r)/t),c=Math.floor((a+1-r)/t),o=0;o<n;o+=1)l=`โ–ˆ`,r<=o&&o<i&&r<=a&&a<i&&v.isDark(s,Math.floor((o-r)/t))&&(l=` `),r<=o&&o<i&&r<=a+1&&a+1<i&&v.isDark(c,Math.floor((o-r)/t))?l+=` `:l+=`โ–ˆ`,f+=e<1&&a+1>=i?d[l]:u[l];f+=`
667
+ `}return n%2&&e>0?f.substring(0,f.length-n-1)+Array(n+1).join(`โ–€`):f.substring(0,f.length-1)};return v.createASCII=function(e,t){if(e=e||1,e<2)return A(t);--e,t=t===void 0?e*2:t;var n=v.getModuleCount()*e+t*2,r=t,i=n-t,a,o,s,c,l=Array(e+1).join(`โ–ˆโ–ˆ`),u=Array(e+1).join(` `),d=``,f=``;for(a=0;a<n;a+=1){for(s=Math.floor((a-r)/e),f=``,o=0;o<n;o+=1)c=1,r<=o&&o<i&&r<=a&&a<i&&v.isDark(s,Math.floor((o-r)/e))&&(c=0),f+=c?l:u;for(s=0;s<e;s+=1)d+=f+`
668
+ `}return d.substring(0,d.length-1)},v.renderTo2dContext=function(e,t){t=t||2;for(var n=v.getModuleCount(),r=0;r<n;r++)for(var i=0;i<n;i++)e.fillStyle=v.isDark(r,i)?`black`:`white`,e.fillRect(r*t,i*t,t,t)},v};e.stringToBytesFuncs={default:function(e){for(var t=[],n=0;n<e.length;n+=1){var r=e.charCodeAt(n);t.push(r&255)}return t}},e.stringToBytes=e.stringToBytesFuncs.default,e.createStringToBytes=function(e,t){var n=function(){for(var n=h(e),r=function(){var e=n.read();if(e==-1)throw`eof`;return e},i=0,a={};;){var o=n.read();if(o==-1)break;var s=r(),c=r(),l=r(),u=String.fromCharCode(o<<8|s);a[u]=c<<8|l,i+=1}if(i!=t)throw i+` != `+t;return a}(),r=63;return function(e){for(var t=[],i=0;i<e.length;i+=1){var a=e.charCodeAt(i);if(a<128)t.push(a);else{var o=n[e.charAt(i)];typeof o==`number`?(o&255)==o?t.push(o):(t.push(o>>>8),t.push(o&255)):t.push(r)}}return t}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={L:1,M:0,Q:3,H:2},r={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},i=function(){var e=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],n=1335,i=7973,s=21522,c={},l=function(e){for(var t=0;e!=0;)t+=1,e>>>=1;return t};return c.getBCHTypeInfo=function(e){for(var t=e<<10;l(t)-l(n)>=0;)t^=n<<l(t)-l(n);return(e<<10|t)^s},c.getBCHTypeNumber=function(e){for(var t=e<<12;l(t)-l(i)>=0;)t^=i<<l(t)-l(i);return e<<12|t},c.getPatternPosition=function(t){return e[t-1]},c.getMaskFunction=function(e){switch(e){case r.PATTERN000:return function(e,t){return(e+t)%2==0};case r.PATTERN001:return function(e,t){return e%2==0};case r.PATTERN010:return function(e,t){return t%3==0};case r.PATTERN011:return function(e,t){return(e+t)%3==0};case r.PATTERN100:return function(e,t){return(Math.floor(e/2)+Math.floor(t/3))%2==0};case r.PATTERN101:return function(e,t){return e*t%2+e*t%3==0};case r.PATTERN110:return function(e,t){return(e*t%2+e*t%3)%2==0};case r.PATTERN111:return function(e,t){return(e*t%3+(e+t)%2)%2==0};default:throw`bad maskPattern:`+e}},c.getErrorCorrectPolynomial=function(e){for(var t=o([1],0),n=0;n<e;n+=1)t=t.multiply(o([1,a.gexp(n)],0));return t},c.getLengthInBits=function(e,n){if(1<=n&&n<10)switch(e){case t.MODE_NUMBER:return 10;case t.MODE_ALPHA_NUM:return 9;case t.MODE_8BIT_BYTE:return 8;case t.MODE_KANJI:return 8;default:throw`mode:`+e}else if(n<27)switch(e){case t.MODE_NUMBER:return 12;case t.MODE_ALPHA_NUM:return 11;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 10;default:throw`mode:`+e}else if(n<41)switch(e){case t.MODE_NUMBER:return 14;case t.MODE_ALPHA_NUM:return 13;case t.MODE_8BIT_BYTE:return 16;case t.MODE_KANJI:return 12;default:throw`mode:`+e}else throw`type:`+n},c.getLostPoint=function(e){for(var t=e.getModuleCount(),n=0,r=0;r<t;r+=1)for(var i=0;i<t;i+=1){for(var a=0,o=e.isDark(r,i),s=-1;s<=1;s+=1)if(!(r+s<0||t<=r+s))for(var c=-1;c<=1;c+=1)i+c<0||t<=i+c||s==0&&c==0||o==e.isDark(r+s,i+c)&&(a+=1);a>5&&(n+=3+a-5)}for(var r=0;r<t-1;r+=1)for(var i=0;i<t-1;i+=1){var l=0;e.isDark(r,i)&&(l+=1),e.isDark(r+1,i)&&(l+=1),e.isDark(r,i+1)&&(l+=1),e.isDark(r+1,i+1)&&(l+=1),(l==0||l==4)&&(n+=3)}for(var r=0;r<t;r+=1)for(var i=0;i<t-6;i+=1)e.isDark(r,i)&&!e.isDark(r,i+1)&&e.isDark(r,i+2)&&e.isDark(r,i+3)&&e.isDark(r,i+4)&&!e.isDark(r,i+5)&&e.isDark(r,i+6)&&(n+=40);for(var i=0;i<t;i+=1)for(var r=0;r<t-6;r+=1)e.isDark(r,i)&&!e.isDark(r+1,i)&&e.isDark(r+2,i)&&e.isDark(r+3,i)&&e.isDark(r+4,i)&&!e.isDark(r+5,i)&&e.isDark(r+6,i)&&(n+=40);for(var u=0,i=0;i<t;i+=1)for(var r=0;r<t;r+=1)e.isDark(r,i)&&(u+=1);var d=Math.abs(100*u/t/t-50)/5;return n+=d*10,n},c}(),a=function(){for(var e=Array(256),t=Array(256),n=0;n<8;n+=1)e[n]=1<<n;for(var n=8;n<256;n+=1)e[n]=e[n-4]^e[n-5]^e[n-6]^e[n-8];for(var n=0;n<255;n+=1)t[e[n]]=n;var r={};return r.glog=function(e){if(e<1)throw`glog(`+e+`)`;return t[e]},r.gexp=function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return e[t]},r}();function o(e,t){if(e.length===void 0)throw e.length+`/`+t;var n=function(){for(var n=0;n<e.length&&e[n]==0;)n+=1;for(var r=Array(e.length-n+t),i=0;i<e.length-n;i+=1)r[i]=e[i+n];return r}(),r={};return r.getAt=function(e){return n[e]},r.getLength=function(){return n.length},r.multiply=function(e){for(var t=Array(r.getLength()+e.getLength()-1),n=0;n<r.getLength();n+=1)for(var i=0;i<e.getLength();i+=1)t[n+i]^=a.gexp(a.glog(r.getAt(n))+a.glog(e.getAt(i)));return o(t,0)},r.mod=function(e){if(r.getLength()-e.getLength()<0)return r;for(var t=a.glog(r.getAt(0))-a.glog(e.getAt(0)),n=Array(r.getLength()),i=0;i<r.getLength();i+=1)n[i]=r.getAt(i);for(var i=0;i<e.getLength();i+=1)n[i]^=a.gexp(a.glog(e.getAt(i))+t);return o(n,0).mod(e)},r}var s=function(){var e=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],t=function(e,t){var n={};return n.totalCount=e,n.dataCount=t,n},r={},i=function(t,r){switch(r){case n.L:return e[(t-1)*4+0];case n.M:return e[(t-1)*4+1];case n.Q:return e[(t-1)*4+2];case n.H:return e[(t-1)*4+3];default:return}};return r.getRSBlocks=function(e,n){var r=i(e,n);if(r===void 0)throw`bad rs block @ typeNumber:`+e+`/errorCorrectionLevel:`+n;for(var a=r.length/3,o=[],s=0;s<a;s+=1)for(var c=r[s*3+0],l=r[s*3+1],u=r[s*3+2],d=0;d<c;d+=1)o.push(t(l,u));return o},r}(),c=function(){var e=[],t=0,n={};return n.getBuffer=function(){return e},n.getAt=function(t){return(e[Math.floor(t/8)]>>>7-t%8&1)==1},n.put=function(e,t){for(var r=0;r<t;r+=1)n.putBit((e>>>t-r-1&1)==1)},n.getLengthInBits=function(){return t},n.putBit=function(n){var r=Math.floor(t/8);e.length<=r&&e.push(0),n&&(e[r]|=128>>>t%8),t+=1},n},l=function(e){var n=t.MODE_NUMBER,r=e,i={};i.getMode=function(){return n},i.getLength=function(e){return r.length},i.write=function(e){for(var t=r,n=0;n+2<t.length;)e.put(a(t.substring(n,n+3)),10),n+=3;n<t.length&&(t.length-n==1?e.put(a(t.substring(n,n+1)),4):t.length-n==2&&e.put(a(t.substring(n,n+2)),7))};var a=function(e){for(var t=0,n=0;n<e.length;n+=1)t=t*10+o(e.charAt(n));return t},o=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;throw`illegal char :`+e};return i},u=function(e){var n=t.MODE_ALPHA_NUM,r=e,i={};i.getMode=function(){return n},i.getLength=function(e){return r.length},i.write=function(e){for(var t=r,n=0;n+1<t.length;)e.put(a(t.charAt(n))*45+a(t.charAt(n+1)),11),n+=2;n<t.length&&e.put(a(t.charAt(n)),6)};var a=function(e){if(`0`<=e&&e<=`9`)return e.charCodeAt(0)-48;if(`A`<=e&&e<=`Z`)return e.charCodeAt(0)-65+10;switch(e){case` `:return 36;case`$`:return 37;case`%`:return 38;case`*`:return 39;case`+`:return 40;case`-`:return 41;case`.`:return 42;case`/`:return 43;case`:`:return 44;default:throw`illegal char :`+e}};return i},d=function(n){var r=t.MODE_8BIT_BYTE,i=e.stringToBytes(n),a={};return a.getMode=function(){return r},a.getLength=function(e){return i.length},a.write=function(e){for(var t=0;t<i.length;t+=1)e.put(i[t],8)},a},f=function(n){var r=t.MODE_KANJI,i=e.stringToBytesFuncs.SJIS;if(!i)throw`sjis not supported.`;(function(e,t){var n=i(e);if(n.length!=2||(n[0]<<8|n[1])!=t)throw`sjis not supported.`})(`ๅ‹`,38726);var a=i(n),o={};return o.getMode=function(){return r},o.getLength=function(e){return~~(a.length/2)},o.write=function(e){for(var t=a,n=0;n+1<t.length;){var r=(255&t[n])<<8|255&t[n+1];if(33088<=r&&r<=40956)r-=33088;else if(57408<=r&&r<=60351)r-=49472;else throw`illegal char at `+(n+1)+`/`+r;r=(r>>>8&255)*192+(r&255),e.put(r,13),n+=2}if(n<t.length)throw`illegal char at `+(n+1)},o},p=function(){var e=[],t={};return t.writeByte=function(t){e.push(t&255)},t.writeShort=function(e){t.writeByte(e),t.writeByte(e>>>8)},t.writeBytes=function(e,n,r){n=n||0,r=r||e.length;for(var i=0;i<r;i+=1)t.writeByte(e[i+n])},t.writeString=function(e){for(var n=0;n<e.length;n+=1)t.writeByte(e.charCodeAt(n))},t.toByteArray=function(){return e},t.toString=function(){var t=``;t+=`[`;for(var n=0;n<e.length;n+=1)n>0&&(t+=`,`),t+=e[n];return t+=`]`,t},t},m=function(){var e=0,t=0,n=0,r=``,i={},a=function(e){r+=String.fromCharCode(o(e&63))},o=function(e){if(!(e<0)){if(e<26)return 65+e;if(e<52)return 97+(e-26);if(e<62)return 48+(e-52);if(e==62)return 43;if(e==63)return 47}throw`n:`+e};return i.writeByte=function(r){for(e=e<<8|r&255,t+=8,n+=1;t>=6;)a(e>>>t-6),t-=6},i.flush=function(){if(t>0&&(a(e<<6-t),e=0,t=0),n%3!=0)for(var i=3-n%3,o=0;o<i;o+=1)r+=`=`},i.toString=function(){return r},i},h=function(e){var t=e,n=0,r=0,i=0,a={};a.read=function(){for(;i<8;){if(n>=t.length){if(i==0)return-1;throw`unexpected end of file./`+i}var e=t.charAt(n);if(n+=1,e==`=`)return i=0,-1;e.match(/^\s$/)||(r=r<<6|o(e.charCodeAt(0)),i+=6)}var a=r>>>i-8&255;return i-=8,a};var o=function(e){if(65<=e&&e<=90)return e-65;if(97<=e&&e<=122)return e-97+26;if(48<=e&&e<=57)return e-48+52;if(e==43)return 62;if(e==47)return 63;throw`c:`+e};return a},g=function(e,t){var n=e,r=t,i=Array(e*t),a={};a.setPixel=function(e,t,r){i[t*n+e]=r},a.write=function(e){e.writeString(`GIF87a`),e.writeShort(n),e.writeShort(r),e.writeByte(128),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(0),e.writeByte(255),e.writeByte(255),e.writeByte(255),e.writeString(`,`),e.writeShort(0),e.writeShort(0),e.writeShort(n),e.writeShort(r),e.writeByte(0);var t=2,i=s(t);e.writeByte(t);for(var a=0;i.length-a>255;)e.writeByte(255),e.writeBytes(i,a,255),a+=255;e.writeByte(i.length-a),e.writeBytes(i,a,i.length-a),e.writeByte(0),e.writeString(`;`)};var o=function(e){var t=e,n=0,r=0,i={};return i.write=function(e,i){if(e>>>i)throw`length over`;for(;n+i>=8;)t.writeByte(255&(e<<n|r)),i-=8-n,e>>>=8-n,r=0,n=0;r=e<<n|r,n+=i},i.flush=function(){n>0&&t.writeByte(r)},i},s=function(e){for(var t=1<<e,n=(1<<e)+1,r=e+1,a=c(),s=0;s<t;s+=1)a.add(String.fromCharCode(s));a.add(String.fromCharCode(t)),a.add(String.fromCharCode(n));var l=p(),u=o(l);u.write(t,r);var d=0,f=String.fromCharCode(i[d]);for(d+=1;d<i.length;){var m=String.fromCharCode(i[d]);d+=1,a.contains(f+m)?f+=m:(u.write(a.indexOf(f),r),a.size()<4095&&(a.size()==1<<r&&(r+=1),a.add(f+m)),f=m)}return u.write(a.indexOf(f),r),u.write(n,r),u.flush(),l.toByteArray()},c=function(){var e={},t=0,n={};return n.add=function(r){if(n.contains(r))throw`dup key:`+r;e[r]=t,t+=1},n.size=function(){return t},n.indexOf=function(t){return e[t]},n.contains=function(t){return e[t]!==void 0},n};return a},_=function(e,t,n){for(var r=g(e,t),i=0;i<t;i+=1)for(var a=0;a<e;a+=1)r.setPixel(a,i,n(a,i));var o=p();r.write(o);for(var s=m(),c=o.toByteArray(),l=0;l<c.length;l+=1)s.writeByte(c[l]);return s.flush(),`data:image/gif;base64,`+s};return e}();(function(){n.stringToBytesFuncs[`UTF-8`]=function(e){function t(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t.push(r):r<2048?t.push(192|r>>6,128|r&63):r<55296||r>=57344?t.push(224|r>>12,128|r>>6&63,128|r&63):(n++,r=65536+((r&1023)<<10|e.charCodeAt(n)&1023),t.push(240|r>>18,128|r>>12&63,128|r>>6&63,128|r&63))}return t}return t(e)}})(),(function(n){typeof define==`function`&&define.amd?define([],n):typeof e==`object`&&(t.exports=n())})(function(){return n})}))(),1);function fe(e){let t=(0,de.default)(0,`M`);return t.addData(e),t.make(),t.createSvgTag({cellSize:6,margin:4,scalable:!0})}let pe={front_capture:{title:`Front of your document`,body:`Place the front of your ID flat and fully inside the frame. Weโ€™ll capture it automatically.`},back_capture:{title:`Back of your document`,body:`Now turn your ID over and show the back, fully inside the frame.`},selfie_capture:{title:`Take a selfie`,body:`Look straight at the camera in good light and hold still โ€” weโ€™ll capture it automatically.`},active_liveness:{title:`Quick liveness check`,body:`Follow the on-screen prompts (such as turn your head, blink or smile). This confirms youโ€™re really here.`}};function me(e,t){let n=e.logo_url;if(!n||!t||!/^https?:\/\//i.test(t))return e;try{let r=new URL(t),i=new URL(n,r);return i.origin===r.origin?e:{...e,logo_url:`${r.origin}${i.pathname}${i.search}${i.hash}`}}catch{return e}}var he=class{constructor(e){this.config=e,p(this,`client`,void 0),p(this,`view`,void 0),p(this,`win`,void 0),p(this,`nav`,void 0),p(this,`postToParent`,void 0),p(this,`scheduler`,void 0),p(this,`transientMs`,void 0),p(this,`pollMs`,void 0),p(this,`maxPolls`,void 0),p(this,`maxHandoffPolls`,void 0),p(this,`handoffConfig`,{enabled:!1,allow_desktop:!0,url:``}),p(this,`handoffReady`,!1),p(this,`handoffActive`,!1),p(this,`sessionId`,``),p(this,`realtimeConfig`,null),p(this,`rtClient`,null),p(this,`rtResolved`,!1),p(this,`lastStatus`,null),p(this,`listeners`,new Map),p(this,`stopWatch`,void 0),p(this,`step`,`welcome`),p(this,`documentType`,null),p(this,`country`,null),p(this,`selfie`,null),p(this,`livenessMode`,`passive`),p(this,`captureModel`,`passive`),p(this,`livenessChallenges`,[]),p(this,`workflow`,null),p(this,`result`,null),p(this,`terminalOnLoad`,!1),p(this,`instructionAcked`,!1),p(this,`pendingError`,null),p(this,`settled`,!1);let t=e.doc??globalThis.document,n=e.win??globalThis.window;if(!t||!n)throw Error(`The Arkyc widget must run in a browser environment.`);this.win=n,this.nav=e.nav??globalThis.navigator,this.client=new g({token:e.token,baseUrl:e.baseUrl,fetch:e.fetch});let r=new w(e.branding);this.view=new le(t,r,this.handlers(),e.nav??globalThis.navigator,e.faceAnalyzer,e.faceTuning,e.documentAnalyzer,e.documentTuning),this.postToParent=e.postToParent??(!!n.parent&&n.parent!==n),this.scheduler=e.scheduler??((e,t)=>setTimeout(e,t)),this.transientMs=e.transientMs??700,this.pollMs=e.pollMs??1500,this.maxPolls=e.maxPolls??40,this.maxHandoffPolls=e.maxHandoffPolls??600}get element(){return this.view.element}start(){this.view.renderLoading(),this.run(()=>this.bootstrap())}destroy(){this.view.destroy()}close(){this.finishClose()}on(e,t){let n=this.listeners.get(e)??new Set;return n.add(t),this.listeners.set(e,n),()=>n.delete(t)}hasListener(e){if(this.config.onEvent)return!0;let t=this.listeners.get(e);return!!t&&t.size>0}dispatch(e,t){this.emit(e,t),this.post(`arkyc:event`,{name:e,data:t})}emit(e,t){if(!this.hasListener(e))return;try{this.config.onEvent?.({name:e,data:t})}catch{}let n=this.listeners.get(e);if(n)for(let e of[...n])try{e(t)}catch{}}observe(e){if(e===this.lastStatus)return;let t=this.lastStatus;this.lastStatus=e,this.dispatch(E.sessionTransition,{session_id:this.sessionId,status:e,previous_status:t})}async resolveRealtime(){if(this.rtResolved)return this.rtClient;this.rtResolved=!0;let e=this.realtimeConfig;if(!e||e.transport===`polling`||e.transport===`off`||e.transport===`memory`)return null;let t=this.config.realtimeFactory??v,n=(this.config.baseUrl??``).replace(/\/$/,``);try{this.rtClient=await t(e,{authEndpoint:`${n}/v1/client/realtime/auth`,token:this.config.token})}catch{this.rtClient=null}return this.rtClient}handlers(){return{onClose:()=>this.finishClose(),onStart:()=>void this.run(()=>this.enter(this.next())),onDocumentSelected:(e,t)=>{this.documentType=e,this.country=t||null,this.run(()=>this.enter(`front_capture`))},onImage:e=>void this.run(()=>this.onImage(e)),onActiveLiveness:(e,t,n)=>void this.run(async()=>{await this.client.submitLiveness({selfie:n,video:e,mode:`active`,challenges:t,signals:this.config.signals}),await this.enter(this.next())}),onAcknowledge:()=>this.finishResult(),onUsePhone:()=>void this.run(()=>this.startHandoff()),onContinueHere:()=>{this.handoffActive=!1,this.stopWatch?.(),this.step=`welcome`,this.render()}}}async bootstrap(){if(this.settled)return;let e=await this.client.getSession();if(!this.settled){if(this.sessionId=e.id,this.realtimeConfig=e.realtime??null,this.workflow=e.workflow??null,this.config.branding==null&&e.branding&&this.view.applyBranding(me(e.branding,this.config.baseUrl)),this.observe(e.status),M.isTerminal(e.status))return this.showTerminal(e.status);this.resolveLiveness(e),e.handoff&&(this.handoffConfig=e.handoff),this.config.handoff!==!1&&ue(this.nav)&&this.handoffConfig.enabled&&this.handoffTarget()?(this.handoffReady=!0,await this.startHandoff()):(this.step=`welcome`,this.render())}}handoffTarget(){return(this.config.handoffUrl??this.handoffConfig.url??``).trim()}async startHandoff(){let e=this.handoffTarget();e&&(this.handoffActive=!0,this.view.renderHandoff(fe(this.buildHandoffUrl(e)),this.handoffConfig.allow_desktop),await this.pollHandoff())}buildHandoffUrl(e){let t=`${e}${e.includes(`?`)?`&`:`?`}token=${encodeURIComponent(this.config.token)}`,n=(this.config.baseUrl??``).trim();return/^https?:\/\//i.test(n)&&(t+=`&baseUrl=${encodeURIComponent(n)}`),t}async pollHandoff(){let e=await this.resolveRealtime();if(e){let t=await this.pushWatch(e,this.maxHandoffPolls,()=>this.handoffActive&&!this.settled);return t?(this.handoffActive=!1,this.showResult(t)):void 0}let t=0;for(let e=0;e<this.maxHandoffPolls&&this.handoffActive&&!this.settled;e++){if(await this.delay(this.pollMs),!this.handoffActive||this.settled)return;try{let e=await this.client.getSession();if(t=0,this.observe(e.status),M.isTerminal(e.status))return this.handoffActive=!1,this.showResult(e.status)}catch(e){if(e instanceof m&&e.status===401)return this.handoffActive=!1,this.showResult(`expired`);if(++t>=5)return}}}pushWatch(e,t,n){return new Promise(r=>{let i=!1,a=e=>{i||(i=!0,this.stopWatch=void 0,s(),r(e))},o=this.realtimeConfig.channel,s=e.subscribe(o,(e,t)=>{if(e!==E.sessionTransition)return;let n=t.status;this.observe(n),M.isTerminal(n)&&a(n)});this.stopWatch=()=>a(null),this.client.getSession().then(e=>{this.observe(e.status),M.isTerminal(e.status)&&a(e.status)}).catch(e=>{e instanceof m&&e.status===401&&a(`expired`)});let c=async e=>{if(!i){if(!n()||e>=t)return a(null);await this.delay(this.pollMs),c(e+1)}};c(0)})}resolveLiveness(e){this.livenessChallenges=e.liveness_challenges??[];let t=e.capture_model??`passive`;this.captureModel=t;let n=t===`active`||t===`both`;this.livenessMode=n&&(t===`active`||this.view.cameraSupported)?`active`:`passive`}async onImage(e){let t=this.config.signals;switch(this.step){case`front_capture`:return await this.client.submitDocumentFront({image:e,country:this.country,documentType:this.documentType,signals:t}),this.enter(this.next());case`back_capture`:return await this.client.submitDocumentBack({image:e,country:this.country,documentType:this.documentType}),this.enter(`ocr_processing`);case`selfie_capture`:return this.selfie=e,this.enter(`passive_liveness`)}}async enter(e){if(this.settled)return;this.step=e;let t=pe[e];if(t&&!this.instructionAcked){this.view.renderInstruction(e,t.title,t.body,t.cta??`Continue`,()=>{this.instructionAcked=!0,this.run(()=>this.enter(e))});return}switch(this.instructionAcked=!1,this.render(),e){case`ocr_processing`:return await this.delay(this.transientMs),this.enter(this.next());case`passive_liveness`:return await this.client.submitLiveness({selfie:this.selfie,signals:this.config.signals}),this.enter(this.next());case`face_match`:return await this.client.complete({signals:this.config.signals}),this.enter(this.next());case`processing`:return this.poll()}}async poll(){let e=await this.resolveRealtime();if(e){let t=await this.pushWatch(e,this.maxPolls,()=>!this.settled);return this.showResult(t??`requires_review`)}for(let e=0;e<this.maxPolls&&!this.settled;e++){let e=await this.client.getSession();if(this.observe(e.status),M.isTerminal(e.status))return this.showResult(e.status);await this.delay(this.pollMs)}this.showResult(`requires_review`)}showResult(e){this.result={status:e,decision:M.statusToDecision(e)},this.step=`result`,this.render()}showTerminal(e){this.result={status:e,decision:M.statusToDecision(e)},this.step=`result`,this.terminalOnLoad=!0,this.render()}render(){this.view.render({step:this.step,documentType:this.documentType,decision:this.result?.decision,status:this.result?.status,terminalNotice:this.terminalOnLoad,allowSkip:!!this.config.signals,livenessChallenges:this.livenessChallenges,requireLiveCamera:this.captureModel===`active`,strictCapture:this.livenessMode===`active`,handoffAvailable:this.handoffReady})}next(){return M.nextStep(this.step,{documentType:this.documentType,livenessMode:this.livenessMode,workflow:this.workflow})}delay(e){return new Promise(t=>this.scheduler(t,e))}async run(e){try{await e()}catch(e){this.fail(e)}}fail(e){if(this.settled)return;let t=e instanceof Error?e:Error(String(e));this.step=`result`,this.view.render({step:`result`,documentType:this.documentType,errorMessage:t.message}),this.pendingError=t}finishResult(){this.settled||(this.settled=!0,this.teardownRealtime(),this.pendingError?(this.post(`arkyc:error`,{error:Z(this.pendingError)}),this.dispatch(`error`,{message:this.pendingError.message}),this.config.onError?.(this.pendingError)):this.result&&(this.post(`arkyc:complete`,{payload:this.result}),this.dispatch(`complete`,this.result),this.config.onComplete?.(this.result)),this.destroy(),this.config.onSettle?.())}finishClose(){this.settled||(this.settled=!0,this.teardownRealtime(),this.post(`arkyc:close`,{}),this.dispatch(`close`),this.config.onClose?.(),this.destroy(),this.config.onSettle?.())}teardownRealtime(){this.stopWatch?.(),this.rtClient?.disconnect(),this.rtClient=null}post(e,t){if(this.postToParent)try{this.win.parent?.postMessage({type:e,...t},`*`)}catch{}}};function Z(e){return{message:e.message,name:e.name}}let ge=(e,t)=>{let n=typeof e==`string`?t.querySelector(e):e;if(!n)throw Error(`ArkycWidget.mount: container "${String(e)}" not found.`);return n},Q=(e,t)=>{if(!e.token)throw Error("ArkycWidget requires a client `token`.");return new he({token:e.token,baseUrl:e.baseUrl,handoff:e.handoff,handoffUrl:e.handoffUrl,branding:e.branding,signals:e.signals,onComplete:e.onComplete,onError:e.onError,onClose:e.onClose,onEvent:e.onEvent,onSettle:t,fetch:e.fetch,doc:e.doc,win:e.win,nav:e.nav,faceAnalyzer:e.faceAnalyzer,faceTuning:e.faceTuning,documentAnalyzer:e.documentAnalyzer,documentTuning:e.documentTuning})};var $=class{constructor(e){this.controller=e}close(){return this.controller.close()}on(e,t){return this.controller.on(e,t)}},_e=class e{static open(e){let t=e.doc??globalThis.document,n=t.createElement(`div`);n.setAttribute(`data-arkyc-widget`,``),n.style.cssText=e.fullscreen?`position:fixed;inset:0;z-index:2147483647;background:rgba(0,0,0,0.55);display:flex;align-items:center;justify-content:center;padding:0;`:`position:fixed;inset:0;z-index:2147483647;background:rgba(0,0,0,0.6);display:flex;align-items:center;justify-content:center;padding:16px;`;let r=Q(e,()=>n.remove());return r.element.classList.add(`arkyc-overlay`),e.fullscreen&&r.element.classList.add(`arkyc-fullscreen`),n.appendChild(r.element),(t.body??t.documentElement).appendChild(n),r.start(),new $(r)}static mount(e){let t=e.doc??globalThis.document,n=ge(e.container,t),r=Q(e,()=>r.element.remove());return n.appendChild(r.element),r.start(),new $(r)}static hosted(t={}){let n=t.win??globalThis.window,r=new URLSearchParams(n.location.search),i=t.token??r.get(`token`)??``,a=t.baseUrl??r.get(`baseUrl`)??void 0;return e.open({...t,token:i,baseUrl:a})}};return e.ArkycClient=g,e.ArkycWidget=_e,e.Camera=T,e.DEFAULT_DOCUMENT_TUNING=V,e.DEFAULT_TUNING=R,e.Flow=M,e.PACKAGE_NAME=`@arkyc/widget`,e.Theme=w,e.VERSION=`0.1.0`,e.WidgetApiError=m,e.WidgetHandler=$,e.analyzeDocumentGray=U,e.createDefaultDocumentAnalyzer=G,e.createDefaultFaceAnalyzer=L,e.createWidgetRealtimeClient=v,e.documentGuidance=W,e.isDocumentReady=ne,e.isSelfieReady=B,e.makeChallengeDetector=z,e})({});
669
+ var ArkycWidget=Arkyc.ArkycWidget;var ArkycClient=Arkyc.ArkycClient;
670
+ //# sourceMappingURL=arkyc-widget.iife.global.js.map