@sekyro/web 0.1.0-rc.3 → 0.1.0-rc.31

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 (137) hide show
  1. package/CHANGELOG.md +433 -0
  2. package/LICENSE +25 -16
  3. package/README.md +157 -62
  4. package/THIRD-PARTY-NOTICES.txt +154 -0
  5. package/dist/background-monitor-A7FKJOAG.js +1 -0
  6. package/dist/barcode-detect-C5IOXMKI.js +1 -0
  7. package/dist/camera-trait-V4UAOPIQ.js +1 -0
  8. package/dist/capture-constraints-CVqpMNGA.d.cts +48 -0
  9. package/dist/capture-constraints-CVqpMNGA.d.ts +48 -0
  10. package/dist/capture-session-doc-2LIRRKFX.js +1 -0
  11. package/dist/{capture-session-v3-COIO_F2w.d.cts → capture-session-v3-Fbj-X2Ij.d.ts} +259 -13
  12. package/dist/{capture-session-v3-CvIfcwST.d.ts → capture-session-v3-XtBrXpoW.d.cts} +259 -13
  13. package/dist/challenge-frame-YAQJ5YMB.js +1 -0
  14. package/dist/chunk-2LDOXGY3.js +1 -0
  15. package/dist/chunk-2MX4J26D.js +3 -0
  16. package/dist/chunk-33KKMPJ5.js +1 -0
  17. package/dist/chunk-3K3A7O7J.js +1 -0
  18. package/dist/chunk-53POX7U4.js +1 -0
  19. package/dist/chunk-6ERQTXMY.js +1 -0
  20. package/dist/chunk-6Z4MIKGF.js +1 -0
  21. package/dist/chunk-7QZWBDI5.js +1 -0
  22. package/dist/chunk-CJHMFPL6.js +1 -0
  23. package/dist/chunk-CMXN4SOZ.js +1 -0
  24. package/dist/chunk-CPUECYAJ.js +1 -0
  25. package/dist/chunk-DFTCAWMP.js +1 -0
  26. package/dist/chunk-DK5YPBDQ.js +1 -0
  27. package/dist/chunk-FPXL63KZ.js +1 -0
  28. package/dist/chunk-FSSMUAKC.js +1 -0
  29. package/dist/chunk-G6LKLN4U.js +1 -0
  30. package/dist/chunk-GFJATPUR.js +1 -0
  31. package/dist/chunk-GI3UFGRQ.js +1 -0
  32. package/dist/chunk-GXL6ZD4I.js +1 -0
  33. package/dist/chunk-JLVZ35QK.js +2 -0
  34. package/dist/chunk-MD4YXLPK.js +1 -0
  35. package/dist/chunk-OUC57KMS.js +1 -0
  36. package/dist/chunk-POIQGEZM.js +1 -0
  37. package/dist/chunk-R3JMNYW5.js +1 -0
  38. package/dist/chunk-RI3E7GBN.js +1 -0
  39. package/dist/chunk-SMKCBUJL.js +1 -0
  40. package/dist/chunk-SUANHBF4.js +1 -0
  41. package/dist/chunk-SX7TUC3V.js +1 -0
  42. package/dist/chunk-TN4JWBFJ.js +1 -0
  43. package/dist/chunk-TSA6GHUG.js +1 -0
  44. package/dist/chunk-VWGKUQ3C.js +1 -0
  45. package/dist/chunk-XFDWFJLY.js +1 -0
  46. package/dist/chunk-ZKF2XMNX.js +1 -0
  47. package/dist/client/index.cjs +1 -357
  48. package/dist/client/index.d.cts +6 -37
  49. package/dist/client/index.d.ts +6 -37
  50. package/dist/client/index.js +1 -15
  51. package/dist/clip-inspect-DLJXVKV6.js +1 -0
  52. package/dist/core/index.cjs +1 -1606
  53. package/dist/core/index.d.cts +5 -4
  54. package/dist/core/index.d.ts +5 -4
  55. package/dist/core/index.js +1 -139
  56. package/dist/core/ocr/worker.bundle.js +42 -0
  57. package/dist/core/ocr/worker.cjs +42 -0
  58. package/dist/core/ocr/worker.d.cts +84 -0
  59. package/dist/core/ocr/worker.d.ts +84 -0
  60. package/dist/core/ocr/worker.js +41 -0
  61. package/dist/core/v3/detect-worker.cjs +1 -392
  62. package/dist/core/v3/detect-worker.d.cts +1 -1
  63. package/dist/core/v3/detect-worker.d.ts +1 -1
  64. package/dist/core/v3/detect-worker.js +1 -13
  65. package/dist/create-document-capture-X35M4UAK.js +1 -0
  66. package/dist/create-portrait-capture-5VGYZUOK.js +1 -0
  67. package/dist/create-verification-RdG6qv51.d.ts +3732 -0
  68. package/dist/create-verification-lXGU3ac4.d.cts +3732 -0
  69. package/dist/{detect-worker-CKXHlXx9.d.ts → detect-worker-CHqsPJoM.d.cts} +25 -2
  70. package/dist/{detect-worker-CKXHlXx9.d.cts → detect-worker-CHqsPJoM.d.ts} +25 -2
  71. package/dist/detector-scanic-KMAVOHGF.js +1 -0
  72. package/dist/icao-gate-Cp1C4IEZ.d.ts +578 -0
  73. package/dist/icao-gate-DVNkPclI.d.cts +578 -0
  74. package/dist/icao-gate-T3BTOKFJ.js +1 -0
  75. package/dist/icao-policy-CcrwfsVr.d.ts +80 -0
  76. package/dist/icao-policy-c2Ykm9r2.d.cts +80 -0
  77. package/dist/icao-tuning-4ETMF53W.js +1 -0
  78. package/dist/index.cjs +3 -2649
  79. package/dist/index.d.cts +138 -5
  80. package/dist/index.d.ts +138 -5
  81. package/dist/index.js +1 -28
  82. package/dist/internal/index.cjs +3 -4179
  83. package/dist/internal/index.d.cts +390 -371
  84. package/dist/internal/index.d.ts +390 -371
  85. package/dist/internal/index.js +1 -647
  86. package/dist/keyframe-rank-YAJLYJYF.js +1 -0
  87. package/dist/landmarker-KB7LVXAU.js +1 -0
  88. package/dist/mrz-band-VYHOTDHY.js +1 -0
  89. package/dist/plan-runner-T2ZTSBI4.js +1 -0
  90. package/dist/popup/index.cjs +1 -76
  91. package/dist/popup/index.d.cts +9 -3
  92. package/dist/popup/index.d.ts +9 -3
  93. package/dist/popup/index.js +1 -11
  94. package/dist/print-SEWS3VHQ.js +1 -0
  95. package/dist/scanic-ml-stub-KW7IZHUT.js +1 -0
  96. package/dist/segmenter-USLNBX65.js +1 -0
  97. package/dist/types-B47mZ5TT.d.cts +2107 -0
  98. package/dist/types-B47mZ5TT.d.ts +2107 -0
  99. package/dist/upload-file-EGXXM6TQ.js +1 -0
  100. package/package.json +30 -11
  101. package/sbom.cdx.json +349 -0
  102. package/dist/capture-constraints-BujkZcfb.d.cts +0 -21
  103. package/dist/capture-constraints-BujkZcfb.d.ts +0 -21
  104. package/dist/chunk-7TC6TOZ4.js +0 -1095
  105. package/dist/chunk-7TC6TOZ4.js.map +0 -1
  106. package/dist/chunk-FIXX2AXC.js +0 -864
  107. package/dist/chunk-FIXX2AXC.js.map +0 -1
  108. package/dist/chunk-MWNFSNMP.js +0 -52
  109. package/dist/chunk-MWNFSNMP.js.map +0 -1
  110. package/dist/chunk-NILNKLK6.js +0 -50
  111. package/dist/chunk-NILNKLK6.js.map +0 -1
  112. package/dist/chunk-NWF46H7K.js +0 -359
  113. package/dist/chunk-NWF46H7K.js.map +0 -1
  114. package/dist/chunk-WY6U7AIK.js +0 -193
  115. package/dist/chunk-WY6U7AIK.js.map +0 -1
  116. package/dist/chunk-YVFF4Q4G.js +0 -327
  117. package/dist/chunk-YVFF4Q4G.js.map +0 -1
  118. package/dist/client/index.cjs.map +0 -1
  119. package/dist/client/index.js.map +0 -1
  120. package/dist/core/index.cjs.map +0 -1
  121. package/dist/core/index.js.map +0 -1
  122. package/dist/core/v3/detect-worker.cjs.map +0 -1
  123. package/dist/core/v3/detect-worker.js.map +0 -1
  124. package/dist/create-verification-CP18eq1Q.d.cts +0 -348
  125. package/dist/create-verification-CswF2As-.d.ts +0 -348
  126. package/dist/detector-scanic-4C6IEW2K.js +0 -787
  127. package/dist/detector-scanic-4C6IEW2K.js.map +0 -1
  128. package/dist/hosted-client-BpvBqu9f.d.cts +0 -408
  129. package/dist/hosted-client-BpvBqu9f.d.ts +0 -408
  130. package/dist/index.cjs.map +0 -1
  131. package/dist/index.js.map +0 -1
  132. package/dist/internal/index.cjs.map +0 -1
  133. package/dist/internal/index.js.map +0 -1
  134. package/dist/popup/index.cjs.map +0 -1
  135. package/dist/popup/index.js.map +0 -1
  136. package/dist/scanic-ml-stub-S2OZ6HEF.js +0 -10
  137. package/dist/scanic-ml-stub-S2OZ6HEF.js.map +0 -1
@@ -1,647 +1 @@
1
- import {
2
- AttestationError,
3
- CLIP_MIME_ALLOWLIST,
4
- PROCESSING_POLL_DELAY_MS,
5
- PROCESSING_POLL_MAX,
6
- REGISTRY_RETRY_DELAY_MS,
7
- RETRYABLE_REASONS,
8
- TRANSPORT_REPLAY_ATTEMPTS,
9
- TRANSPORT_REPLAY_DELAY_MS,
10
- TURNSTILE_EXECUTE_TIMEOUT_MS,
11
- TURNSTILE_SCRIPT_SRC,
12
- createLivenessCaptureInternal,
13
- createVerificationInternal,
14
- executeTurnstile,
15
- frontierStep,
16
- isExecutable,
17
- isTerminalView,
18
- loadTurnstile,
19
- mapEngineState,
20
- mapErrorKind,
21
- mapGuidanceHint,
22
- mapSessionResult,
23
- mergeSessionView,
24
- randomUuid,
25
- resetTurnstileForTests,
26
- runLivenessFlow,
27
- runSubmission,
28
- stepOf
29
- } from "../chunk-FIXX2AXC.js";
30
- import {
31
- CENTERED_FACTOR,
32
- CIRCLE_RADIUS_FACTOR,
33
- IN_CIRCLE_FACTOR,
34
- classifyDevice,
35
- mapGetUserMediaError,
36
- probeDevice
37
- } from "../chunk-7TC6TOZ4.js";
38
- import "../chunk-YVFF4Q4G.js";
39
- import "../chunk-NWF46H7K.js";
40
- import {
41
- ASPECT_BANDS,
42
- DOC_DETECT_WIDTH,
43
- DOC_GATE_V1_DEFAULTS,
44
- DocGateV1,
45
- MR_DOC_CATALOG,
46
- aspectBand,
47
- quadAreaFrac,
48
- quadBounds,
49
- quadIou
50
- } from "../chunk-WY6U7AIK.js";
51
- import {
52
- EXPOSURE_BAND,
53
- exposure,
54
- meanLuma,
55
- sharpness
56
- } from "../chunk-MWNFSNMP.js";
57
-
58
- // src/core/doc/mrz-band.ts
59
- var MRZ_BAND_DEFAULTS = Object.freeze({
60
- EDGE_LUMA_DELTA: 40,
61
- MIN_ROW_DENSITY: 0.08,
62
- MIN_COLUMN_COVERAGE: 0.6,
63
- MIN_WIDTH_FRAC: 0.55,
64
- MIN_HEIGHT_FRAC: 0.02,
65
- MAX_HEIGHT_FRAC: 0.16,
66
- ROW_MERGE_GAP: 18
67
- });
68
- var COLUMN_BUCKETS = 12;
69
- function detectMrzBand(frame, overrides = {}) {
70
- const t = { ...MRZ_BAND_DEFAULTS, ...overrides };
71
- const { data, width, height } = frame;
72
- if (width < 32 || height < 32) return null;
73
- const qualifies = new Array(height).fill(false);
74
- const density = new Float32Array(height);
75
- const minX = new Int32Array(height).fill(width);
76
- const maxX = new Int32Array(height).fill(-1);
77
- const bucketWidth = width / COLUMN_BUCKETS;
78
- const buckets = new Array(COLUMN_BUCKETS);
79
- for (let y = 0; y < height; y++) {
80
- let edges = 0;
81
- buckets.fill(false);
82
- const rowOffset = y * width * 4;
83
- let previousLuma = 0.299 * (data[rowOffset] ?? 0) + 0.587 * (data[rowOffset + 1] ?? 0) + 0.114 * (data[rowOffset + 2] ?? 0);
84
- for (let x = 1; x < width; x++) {
85
- const i = rowOffset + x * 4;
86
- const luma = 0.299 * (data[i] ?? 0) + 0.587 * (data[i + 1] ?? 0) + 0.114 * (data[i + 2] ?? 0);
87
- if (Math.abs(luma - previousLuma) >= t.EDGE_LUMA_DELTA) {
88
- edges += 1;
89
- buckets[Math.min(COLUMN_BUCKETS - 1, Math.floor(x / bucketWidth))] = true;
90
- if (x < minX[y]) minX[y] = x;
91
- if (x > maxX[y]) maxX[y] = x;
92
- }
93
- previousLuma = luma;
94
- }
95
- density[y] = edges / width;
96
- const coverage = buckets.filter(Boolean).length / COLUMN_BUCKETS;
97
- qualifies[y] = density[y] >= t.MIN_ROW_DENSITY && coverage >= t.MIN_COLUMN_COVERAGE && maxX[y] - minX[y] >= t.MIN_WIDTH_FRAC * width;
98
- }
99
- let best = null;
100
- let runTop = -1;
101
- let lastQualifying = -1;
102
- let runRows = 0;
103
- const flush = (bottom) => {
104
- if (runTop < 0) return;
105
- const bandHeight = bottom - runTop + 1;
106
- if (bandHeight >= t.MIN_HEIGHT_FRAC * height && bandHeight <= t.MAX_HEIGHT_FRAC * height && runRows >= 4 && // at least a few real stroke rows, not a lone edge
107
- (best === null || runRows > best.rows)) {
108
- best = { top: runTop, bottom, rows: runRows };
109
- }
110
- runTop = -1;
111
- runRows = 0;
112
- };
113
- for (let y = 0; y < height; y++) {
114
- if (qualifies[y]) {
115
- if (runTop < 0) runTop = y;
116
- else if (y - lastQualifying > t.ROW_MERGE_GAP) {
117
- flush(lastQualifying);
118
- runTop = y;
119
- }
120
- lastQualifying = y;
121
- runRows += 1;
122
- }
123
- }
124
- flush(lastQualifying);
125
- if (best === null) return null;
126
- const band = best;
127
- let x1 = width;
128
- let x2 = -1;
129
- let densitySum = 0;
130
- let densityRows = 0;
131
- for (let y = band.top; y <= band.bottom; y++) {
132
- if (!qualifies[y]) continue;
133
- if (minX[y] < x1) x1 = minX[y];
134
- if (maxX[y] > x2) x2 = maxX[y];
135
- densitySum += density[y];
136
- densityRows += 1;
137
- }
138
- if (x2 - x1 < t.MIN_WIDTH_FRAC * width) return null;
139
- return {
140
- x: x1,
141
- y: band.top,
142
- width: x2 - x1,
143
- height: band.bottom - band.top + 1,
144
- density: densityRows > 0 ? densitySum / densityRows : 0
145
- };
146
- }
147
-
148
- // src/core/doc/frame-analysis.ts
149
- var DOC_ANALYSIS_DEFAULTS = Object.freeze({
150
- /** Doc area fraction above which the camera is too close (capture would crop). */
151
- MAX_AREA_FRAC: 0.92,
152
- /** Opposite-side length ratio beyond which the view is too oblique. */
153
- TILT_MAX_SIDE_RATIO: 1.3,
154
- /** Specular-pixel fraction at/above which the frame reads as glare. */
155
- GLARE_MAX_SPECULAR_FRAC: 0.025
156
- });
157
- function specularFraction(crop) {
158
- const { data, width, height } = crop;
159
- const pixels = width * height;
160
- if (pixels === 0) return 0;
161
- let hot = 0;
162
- for (let i = 0; i < pixels; i++) {
163
- const o = i * 4;
164
- const luma = 0.299 * (data[o] ?? 0) + 0.587 * (data[o + 1] ?? 0) + 0.114 * (data[o + 2] ?? 0);
165
- if (luma >= 252) hot++;
166
- }
167
- return hot / pixels;
168
- }
169
- function quadTiltRatio(quad) {
170
- const len = (a, b) => Math.hypot(b.x - a.x, b.y - a.y);
171
- const top = len(quad.topLeft, quad.topRight);
172
- const bottom = len(quad.bottomLeft, quad.bottomRight);
173
- const left = len(quad.topLeft, quad.bottomLeft);
174
- const right = len(quad.topRight, quad.bottomRight);
175
- const h = Math.max(top, bottom) / Math.max(1e-6, Math.min(top, bottom));
176
- const v = Math.max(left, right) / Math.max(1e-6, Math.min(left, right));
177
- return Math.max(h, v);
178
- }
179
- function analyzeDocFrame(input) {
180
- const t = { ...DOC_GATE_V1_DEFAULTS, ...input.thresholds };
181
- const a = DOC_ANALYSIS_DEFAULTS;
182
- const { quad, frameWidth, frameHeight, measures } = input;
183
- const bandMode = input.format === "ID-3";
184
- let framing = "ok";
185
- if (quad === null) {
186
- framing = "no_document";
187
- } else if (bandMode) {
188
- const bounds = quadBounds(quad);
189
- const widthFrac = frameWidth > 0 ? bounds.width / frameWidth : 0;
190
- const aspect = bounds.height > 0 ? bounds.width / bounds.height : 0;
191
- if (widthFrac < t.ID3_BAND_MIN_WIDTH_FRAC) framing = "too_far";
192
- else if (edgeClipped(quad, frameWidth, frameHeight, t.EDGE_CLIP_MARGIN_PX)) {
193
- framing = "edge_clipped";
194
- } else if (aspect < t.ID3_BAND_ASPECT_MIN || aspect > t.ID3_BAND_ASPECT_MAX) {
195
- framing = "wrong_shape";
196
- }
197
- } else {
198
- const areaFrac = quadAreaFrac(quad, frameWidth, frameHeight);
199
- const band = aspectBand(input.format);
200
- const bounds = quadBounds(quad);
201
- const aspect = Math.max(bounds.width, bounds.height) / Math.max(1e-6, Math.min(bounds.width, bounds.height));
202
- if (areaFrac < t.MIN_AREA_FRAC) framing = "too_far";
203
- else if (areaFrac > a.MAX_AREA_FRAC) framing = "too_close";
204
- else if (edgeClipped(quad, frameWidth, frameHeight, t.EDGE_CLIP_MARGIN_PX)) {
205
- framing = "edge_clipped";
206
- } else if (Math.abs(aspect - band.center) > band.tolerance) framing = "wrong_shape";
207
- else if (quadTiltRatio(quad) > a.TILT_MAX_SIDE_RATIO) framing = "tilted";
208
- }
209
- const lighting = measures.exposure >= t.GUIDE_EXPOSURE ? "ok" : measures.meanLuma < (EXPOSURE_BAND[0] + EXPOSURE_BAND[1]) / 2 ? "too_dark" : "too_bright";
210
- const blur = measures.sharpness >= t.GUIDE_SHARPNESS ? "ok" : "blurry";
211
- const glare = measures.specularFraction >= a.GLARE_MAX_SPECULAR_FRAC ? "glare" : "ok";
212
- return {
213
- framing,
214
- lighting,
215
- blur,
216
- glare,
217
- acceptable: framing === "ok" && lighting === "ok" && blur === "ok" && glare === "ok"
218
- };
219
- }
220
- function edgeClipped(quad, frameWidth, frameHeight, margin) {
221
- const pts = [quad.topLeft, quad.topRight, quad.bottomRight, quad.bottomLeft];
222
- return pts.some(
223
- (p) => p.x <= margin || p.y <= margin || p.x >= frameWidth - margin || p.y >= frameHeight - margin
224
- );
225
- }
226
-
227
- // src/core/doc/feedback-aggregator.ts
228
- var DOC_FEEDBACK_STATES = Object.freeze({
229
- sensing: { key: "sensing", reticle: "searching", minDurationMs: 900 },
230
- too_far: { key: "too_far", reticle: "coaching", minDurationMs: 1400 },
231
- too_close: { key: "too_close", reticle: "coaching", minDurationMs: 1400 },
232
- edge_clipped: { key: "edge_clipped", reticle: "coaching", minDurationMs: 1400 },
233
- wrong_shape: { key: "wrong_shape", reticle: "coaching", minDurationMs: 1400 },
234
- tilted: { key: "tilted", reticle: "coaching", minDurationMs: 1400 },
235
- too_dark: { key: "too_dark", reticle: "coaching", minDurationMs: 1400 },
236
- too_bright: { key: "too_bright", reticle: "coaching", minDurationMs: 1400 },
237
- blurry: { key: "blurry", reticle: "coaching", minDurationMs: 1400 },
238
- glare: { key: "glare", reticle: "coaching", minDurationMs: 1400 },
239
- hold_still: { key: "hold_still", reticle: "locking", minDurationMs: 900 },
240
- processing: { key: "processing", reticle: "processing", minDurationMs: 800 },
241
- side_captured: { key: "side_captured", reticle: "flip", minDurationMs: 2600 },
242
- captured: { key: "captured", reticle: "done", minDurationMs: 800 }
243
- });
244
- function feedbackVoteOf(analysis) {
245
- if (analysis.framing === "no_document") return "sensing";
246
- if (analysis.framing === "too_far") return "too_far";
247
- if (analysis.framing === "too_close") return "too_close";
248
- if (analysis.framing === "edge_clipped") return "edge_clipped";
249
- if (analysis.framing === "wrong_shape") return "wrong_shape";
250
- if (analysis.framing === "tilted") return "tilted";
251
- if (analysis.lighting === "too_dark") return "too_dark";
252
- if (analysis.lighting === "too_bright") return "too_bright";
253
- if (analysis.glare === "glare") return "glare";
254
- if (analysis.blur === "blurry") return "blurry";
255
- return "hold_still";
256
- }
257
- var DocFeedbackAggregator = class {
258
- constructor(windowMs = 2600, decayPerSecond = 0.35) {
259
- this.windowMs = windowMs;
260
- this.decayPerSecond = decayPerSecond;
261
- this.votes = [];
262
- this.current = DOC_FEEDBACK_STATES.sensing;
263
- this.currentSinceMs = null;
264
- }
265
- reset() {
266
- this.votes = [];
267
- this.current = DOC_FEEDBACK_STATES.sensing;
268
- this.currentSinceMs = null;
269
- }
270
- /** Force a terminal/choreography state (capture fired, side flip, upload). */
271
- force(key, nowMs) {
272
- this.votes = [];
273
- this.current = DOC_FEEDBACK_STATES[key];
274
- this.currentSinceMs = nowMs;
275
- return this.current;
276
- }
277
- /** Cast this frame's vote and return the (possibly held) winning state. */
278
- tick(vote, nowMs) {
279
- if (this.currentSinceMs === null) this.currentSinceMs = nowMs;
280
- this.votes.push({ key: vote, atMs: nowMs });
281
- this.votes = this.votes.filter((v) => nowMs - v.atMs <= this.windowMs);
282
- if (nowMs - this.currentSinceMs < this.current.minDurationMs) return this.current;
283
- const scores = /* @__PURE__ */ new Map();
284
- for (const v of this.votes) {
285
- const ageSeconds = (nowMs - v.atMs) / 1e3;
286
- const weight = this.decayPerSecond ** ageSeconds;
287
- scores.set(v.key, (scores.get(v.key) ?? 0) + weight);
288
- }
289
- let winner = this.current.key;
290
- let best = -1;
291
- for (const [key, score] of scores) {
292
- if (score > best) {
293
- best = score;
294
- winner = key;
295
- }
296
- }
297
- if (winner !== this.current.key) {
298
- this.current = DOC_FEEDBACK_STATES[winner];
299
- this.currentSinceMs = nowMs;
300
- }
301
- return this.current;
302
- }
303
- };
304
-
305
- // src/core/doc/capture-session-doc.ts
306
- var scanicDetect = null;
307
- async function lazyScanicDetect(image) {
308
- if (scanicDetect === null) {
309
- const module_ = await import("../detector-scanic-4C6IEW2K.js");
310
- scanicDetect = module_.detectQuad;
311
- }
312
- return scanicDetect(image);
313
- }
314
- async function mrzBandDetect(image) {
315
- const band = detectMrzBand(image);
316
- if (band === null) return null;
317
- return {
318
- topLeft: { x: band.x, y: band.y },
319
- topRight: { x: band.x + band.width, y: band.y },
320
- bottomRight: { x: band.x + band.width, y: band.y + band.height },
321
- bottomLeft: { x: band.x, y: band.y + band.height }
322
- };
323
- }
324
- function warmDocDetector() {
325
- if (scanicDetect !== null) return;
326
- void import("../detector-scanic-4C6IEW2K.js").then((module_) => {
327
- scanicDetect = module_.detectQuad;
328
- }).catch(() => void 0);
329
- }
330
- var DOC_CADENCE_HZ = Object.freeze({
331
- LOW: 3,
332
- MID: 5,
333
- HIGH: 6
334
- });
335
- var CaptureSessionDoc = class {
336
- constructor(opts) {
337
- this.handlers = /* @__PURE__ */ new Map();
338
- this.stream = null;
339
- this.timer = null;
340
- this.state = "idle";
341
- this.lastGuidance = null;
342
- this.attempt = 0;
343
- this.capturing = false;
344
- this.feedback = new DocFeedbackAggregator();
345
- this.lastFeedbackKey = null;
346
- this.opts = opts;
347
- this.gate = new DocGateV1(opts.format ?? "ID-1", opts.thresholds);
348
- const deviceClass = opts.deviceClass ?? classifyDevice(probeDevice());
349
- this.cadenceMs = 1e3 / DOC_CADENCE_HZ[deviceClass];
350
- }
351
- on(event, handler) {
352
- let set = this.handlers.get(event);
353
- if (!set) {
354
- set = /* @__PURE__ */ new Set();
355
- this.handlers.set(event, set);
356
- }
357
- set.add(handler);
358
- return () => set?.delete(handler);
359
- }
360
- emit(event, payload) {
361
- for (const handler of [...this.handlers.get(event) ?? []]) {
362
- handler(payload);
363
- }
364
- }
365
- async start() {
366
- const attempt = ++this.attempt;
367
- this.gate.reset();
368
- this.feedback.reset();
369
- this.lastFeedbackKey = null;
370
- this.lastGuidance = null;
371
- this.capturing = false;
372
- this.setState("preflight");
373
- try {
374
- const getUserMedia = this.opts.getUserMedia ?? ((constraints) => navigator.mediaDevices.getUserMedia(constraints));
375
- this.setState("acquiring");
376
- this.stream = await getUserMedia({
377
- audio: false,
378
- video: {
379
- facingMode: { ideal: "environment" },
380
- width: { ideal: 1920 },
381
- height: { ideal: 1080 }
382
- }
383
- });
384
- if (attempt !== this.attempt) {
385
- for (const track of this.stream.getTracks()) track.stop();
386
- return;
387
- }
388
- this.opts.video.srcObject = this.stream;
389
- await this.opts.video.play().catch(() => void 0);
390
- this.setState("positioning");
391
- this.scheduleTick(attempt);
392
- } catch (err) {
393
- const kind = mapGetUserMediaError(err);
394
- this.setState("error");
395
- this.emit("error", { kind, retryable: true });
396
- }
397
- }
398
- /** Restart the gate for another side / a retake (same stream). */
399
- rearm(side) {
400
- if (side !== void 0) this.opts.side = side;
401
- this.gate.reset();
402
- this.feedback.reset();
403
- this.lastFeedbackKey = null;
404
- this.lastGuidance = null;
405
- this.capturing = false;
406
- if (this.state === "captured") {
407
- this.setState("positioning");
408
- this.scheduleTick(this.attempt);
409
- }
410
- }
411
- destroy() {
412
- this.attempt += 1;
413
- if (this.timer !== null) (this.opts.clearTimer ?? clearTimeout)(this.timer);
414
- this.timer = null;
415
- if (this.stream) for (const track of this.stream.getTracks()) track.stop();
416
- this.stream = null;
417
- this.opts.video.srcObject = null;
418
- }
419
- setState(state) {
420
- this.state = state;
421
- this.emit("statechange", { state });
422
- }
423
- scheduleTick(attempt) {
424
- const setTimer = this.opts.setTimer ?? setTimeout;
425
- this.timer = setTimer(() => void this.tick(attempt), this.cadenceMs);
426
- }
427
- async tick(attempt) {
428
- if (attempt !== this.attempt || this.state !== "positioning" || this.capturing) return;
429
- const now = this.opts.now ?? (() => performance.now());
430
- const grab = this.opts.grabDetectFrame ?? defaultGrabDetectFrame;
431
- const detect = this.opts.detect ?? ((this.opts.format ?? "ID-1") === "ID-3" ? mrzBandDetect : lazyScanicDetect);
432
- const frame = grab(this.opts.video, DOC_DETECT_WIDTH);
433
- if (frame === null) {
434
- this.scheduleTick(attempt);
435
- return;
436
- }
437
- let quad = null;
438
- try {
439
- quad = await detect(frame);
440
- } catch {
441
- quad = null;
442
- }
443
- if (attempt !== this.attempt) return;
444
- const crop = quad !== null ? cropQuadRegion(frame, quad) : frame;
445
- const atMs = now();
446
- const measures = {
447
- sharpness: sharpness(crop),
448
- exposure: exposure(crop),
449
- meanLuma: meanLuma(crop),
450
- specularFraction: specularFraction(crop)
451
- };
452
- const analysis = analyzeDocFrame({
453
- format: this.opts.format ?? "ID-1",
454
- quad,
455
- frameWidth: frame.width,
456
- frameHeight: frame.height,
457
- measures,
458
- ...this.opts.thresholds !== void 0 ? { thresholds: this.opts.thresholds } : {}
459
- });
460
- const tick = this.gate.tick({
461
- timestampMs: atMs,
462
- quad,
463
- quality: measures,
464
- frameWidth: frame.width,
465
- frameHeight: frame.height
466
- });
467
- this.emit("checks", {
468
- engine: "docv1",
469
- p: tick.p,
470
- plausible: tick.plausible,
471
- stableTicks: tick.stableTicks,
472
- quad: tick.quad,
473
- frameWidth: frame.width,
474
- frameHeight: frame.height,
475
- analysis
476
- });
477
- const feedbackState = this.feedback.tick(feedbackVoteOf(analysis), atMs);
478
- if (feedbackState.key !== this.lastFeedbackKey) {
479
- this.lastFeedbackKey = feedbackState.key;
480
- this.emit("feedback", feedbackState);
481
- }
482
- if (tick.guidanceKey !== this.lastGuidance) {
483
- this.lastGuidance = tick.guidanceKey;
484
- this.emit("guidance", { key: tick.guidanceKey });
485
- }
486
- if (tick.ready && quad !== null) {
487
- const processing = this.feedback.force("processing", atMs);
488
- this.lastFeedbackKey = processing.key;
489
- this.emit("feedback", processing);
490
- await this.fire(attempt, quad, {
491
- width: frame.width,
492
- height: frame.height,
493
- tickSharpness: measures.sharpness
494
- });
495
- return;
496
- }
497
- this.scheduleTick(attempt);
498
- }
499
- /**
500
- * BEST-FRAME capture window (capture-v2): the first ready tick captures a
501
- * candidate immediately, then up to CAPTURE_EXTRA_CANDIDATES more stills are
502
- * taken at CAPTURE_CANDIDATE_SPACING_MS while the user holds — each scored
503
- * by the live detect-tick sharpness at its capture moment — and the SHARPEST
504
- * wins. Beats first-acceptable-frame capture without decoding stills.
505
- */
506
- async fire(attempt, quad, detectSize) {
507
- this.capturing = true;
508
- const capture = this.opts.captureStill ?? defaultCaptureStill;
509
- const grab = this.opts.grabDetectFrame ?? defaultGrabDetectFrame;
510
- const setTimer = this.opts.setTimer ?? setTimeout;
511
- const size = { width: detectSize.width, height: detectSize.height };
512
- try {
513
- let best = {
514
- still: await capture(this.opts.video, quad, size),
515
- sharpness: detectSize.tickSharpness
516
- };
517
- for (let i = 0; i < CAPTURE_EXTRA_CANDIDATES; i++) {
518
- await new Promise((resolve) => {
519
- setTimer(() => resolve(), CAPTURE_CANDIDATE_SPACING_MS);
520
- });
521
- if (attempt !== this.attempt) return;
522
- const frame = grab(this.opts.video, DOC_DETECT_WIDTH);
523
- if (frame === null) continue;
524
- const candidateSharpness = sharpness(cropQuadRegion(frame, quad));
525
- if (candidateSharpness > best.sharpness * CAPTURE_IMPROVEMENT_MIN_RATIO) {
526
- const still = await capture(this.opts.video, quad, size);
527
- if (attempt !== this.attempt) return;
528
- best = { still, sharpness: candidateSharpness };
529
- }
530
- }
531
- if (attempt !== this.attempt) return;
532
- this.setState("captured");
533
- this.emit("artifacts", {
534
- keyframe: best.still.blob,
535
- previewDataUrl: best.still.previewDataUrl,
536
- ...this.opts.side !== void 0 ? { side: this.opts.side } : {}
537
- });
538
- } catch {
539
- if (attempt !== this.attempt) return;
540
- this.capturing = false;
541
- this.gate.reset();
542
- this.scheduleTick(attempt);
543
- }
544
- }
545
- };
546
- var CAPTURE_EXTRA_CANDIDATES = 2;
547
- var CAPTURE_CANDIDATE_SPACING_MS = 260;
548
- var CAPTURE_IMPROVEMENT_MIN_RATIO = 1.08;
549
- function defaultGrabDetectFrame(video, targetWidth) {
550
- const vw = video.videoWidth;
551
- const vh = video.videoHeight;
552
- if (vw === 0 || vh === 0) return null;
553
- const scale = Math.min(1, targetWidth / vw);
554
- const width = Math.round(vw * scale);
555
- const height = Math.round(vh * scale);
556
- const canvas = document.createElement("canvas");
557
- canvas.width = width;
558
- canvas.height = height;
559
- const context = canvas.getContext("2d", { willReadFrequently: true });
560
- if (context === null) return null;
561
- context.drawImage(video, 0, 0, width, height);
562
- return context.getImageData(0, 0, width, height);
563
- }
564
- async function defaultCaptureStill(video, _quad, _detectSize) {
565
- const canvas = document.createElement("canvas");
566
- canvas.width = Math.max(1, video.videoWidth);
567
- canvas.height = Math.max(1, video.videoHeight);
568
- const context = canvas.getContext("2d");
569
- if (context === null) throw new Error("2d context unavailable");
570
- context.drawImage(video, 0, 0, canvas.width, canvas.height);
571
- const blob = await new Promise((resolve, reject) => {
572
- canvas.toBlob((b) => b ? resolve(b) : reject(new Error("toBlob failed")), "image/jpeg", 0.92);
573
- });
574
- return { blob, previewDataUrl: canvas.toDataURL("image/jpeg", 0.85) };
575
- }
576
- function cropQuadRegion(frame, quad) {
577
- const xs = [quad.topLeft.x, quad.topRight.x, quad.bottomRight.x, quad.bottomLeft.x];
578
- const ys = [quad.topLeft.y, quad.topRight.y, quad.bottomRight.y, quad.bottomLeft.y];
579
- const x1 = Math.max(0, Math.floor(Math.min(...xs)));
580
- const y1 = Math.max(0, Math.floor(Math.min(...ys)));
581
- const x2 = Math.min(frame.width, Math.ceil(Math.max(...xs)));
582
- const y2 = Math.min(frame.height, Math.ceil(Math.max(...ys)));
583
- const width = Math.max(1, x2 - x1);
584
- const height = Math.max(1, y2 - y1);
585
- const data = new Uint8ClampedArray(width * height * 4);
586
- for (let row = 0; row < height; row++) {
587
- const src = ((y1 + row) * frame.width + x1) * 4;
588
- data.set(frame.data.subarray(src, src + width * 4), row * width * 4);
589
- }
590
- return { data, width, height, colorSpace: frame.colorSpace };
591
- }
592
- export {
593
- ASPECT_BANDS,
594
- AttestationError,
595
- CAPTURE_CANDIDATE_SPACING_MS,
596
- CAPTURE_EXTRA_CANDIDATES,
597
- CENTERED_FACTOR,
598
- CIRCLE_RADIUS_FACTOR,
599
- CLIP_MIME_ALLOWLIST,
600
- CaptureSessionDoc,
601
- DOC_ANALYSIS_DEFAULTS,
602
- DOC_CADENCE_HZ,
603
- DOC_DETECT_WIDTH,
604
- DOC_FEEDBACK_STATES,
605
- DOC_GATE_V1_DEFAULTS,
606
- DocFeedbackAggregator,
607
- DocGateV1,
608
- IN_CIRCLE_FACTOR,
609
- MRZ_BAND_DEFAULTS,
610
- MR_DOC_CATALOG,
611
- PROCESSING_POLL_DELAY_MS,
612
- PROCESSING_POLL_MAX,
613
- REGISTRY_RETRY_DELAY_MS,
614
- RETRYABLE_REASONS,
615
- TRANSPORT_REPLAY_ATTEMPTS,
616
- TRANSPORT_REPLAY_DELAY_MS,
617
- TURNSTILE_EXECUTE_TIMEOUT_MS,
618
- TURNSTILE_SCRIPT_SRC,
619
- analyzeDocFrame,
620
- aspectBand,
621
- createLivenessCaptureInternal,
622
- createVerificationInternal,
623
- detectMrzBand,
624
- executeTurnstile,
625
- feedbackVoteOf,
626
- frontierStep,
627
- isExecutable,
628
- isTerminalView,
629
- loadTurnstile,
630
- mapEngineState,
631
- mapErrorKind,
632
- mapGuidanceHint,
633
- mapSessionResult,
634
- mergeSessionView,
635
- quadAreaFrac,
636
- quadBounds,
637
- quadIou,
638
- quadTiltRatio,
639
- randomUuid,
640
- resetTurnstileForTests,
641
- runLivenessFlow,
642
- runSubmission,
643
- specularFraction,
644
- stepOf,
645
- warmDocDetector
646
- };
647
- //# sourceMappingURL=index.js.map
1
+ import{c as me,d as _e,e as Le,h as le,i as ce,j as Se}from"../chunk-3K3A7O7J.js";import{a as W,b as ve,c as ge,d as he,e as Ge,f as be,g as He,h as Ye,i as Ue,j as k,k as K,l as w,m as X,n as Z,o as J,p as Q,q as j,r as q,s as $,t as ee,u as te,x as re}from"../chunk-6Z4MIKGF.js";import{a as Bt,b as Vt,c as Xt,d as Zt,e as Jt,f as Qt,g as jt,h as qt,i as $t,j as ne,k as ie,m as se,n as Ee}from"../chunk-VWGKUQ3C.js";import{a as Ft,b as Nt,c as vt,d as gt,e as ht,f as Gt,g as bt,h as Ht,i as Yt,j as Ut,k as Wt,l as kt,m as Kt}from"../chunk-53POX7U4.js";import{a as wt,b as zt}from"../chunk-33KKMPJ5.js";import{b as oe,c as pe,d as ae}from"../chunk-CJHMFPL6.js";import"../chunk-RI3E7GBN.js";import"../chunk-GI3UFGRQ.js";import{a as P,b as d,c as M,d as F,e as N}from"../chunk-CMXN4SOZ.js";import{A as Ct,B as At,C as Ot,D as xt,E as It,F as ut,G as Dt,H as Pt,I as dt,J as Mt,a as Ke,b as we,c as ze,d as je,e as qe,f as $e,g as et,h as tt,i as rt,j as ot,k as pt,l as at,m as nt,n as it,o as st,p as Et,q as mt,r as _t,s as Lt,t as lt,u as ct,v as St,w as Rt,x as yt,y as Tt,z as ft}from"../chunk-XFDWFJLY.js";import{a as v,b as g,c as h,d as G,e as b,f as H,g as Y,h as U,i as z,j as B,l as V}from"../chunk-G6LKLN4U.js";import{a as We,b as ke}from"../chunk-SMKCBUJL.js";import{a as Be,b as Ve,c as Xe,d as Ze,e as Je,f as Qe}from"../chunk-GXL6ZD4I.js";import{b as De,c as Pe,d as de,e as Me,f as Fe,g as Ne}from"../chunk-R3JMNYW5.js";import{b as ye,c as Te,d as fe,e as Ce,g as Ae,h as er,i as tr,j as rr,k as or,l as pr,m as ar,z as Oe}from"../chunk-2MX4J26D.js";import{A as I,C as u,D,i as c,j as S,k as R,l as y,o as T,v as f,w as C,x as A,y as O,z as x}from"../chunk-SUANHBF4.js";import{a,b as n,c as i,d as s,i as E,j as m,k as _,l as L,n as l}from"../chunk-6ERQTXMY.js";import"../chunk-7QZWBDI5.js";import"../chunk-TN4JWBFJ.js";import"../chunk-SX7TUC3V.js";import"../chunk-POIQGEZM.js";import{p as xe,q as Ie,r as ue}from"../chunk-CPUECYAJ.js";import"../chunk-FPXL63KZ.js";import"../chunk-OUC57KMS.js";import{c as e,d as t,f as r,g as o,h as p}from"../chunk-TSA6GHUG.js";import"../chunk-MD4YXLPK.js";import"../chunk-FSSMUAKC.js";import{a as Re}from"../chunk-DFTCAWMP.js";import"../chunk-DK5YPBDQ.js";export{ne as ANALYSIS_LONG_EDGE,De as ASPECT_BANDS,I as AttestationError,He as BLUR_REFUSE_SHARPNESS_MAX,Mt as CAPTURE_CANDIDATE_SPACING_MS,dt as CAPTURE_EXTRA_CANDIDATES,p as CENTERED_FACTOR,M as CHALLENGE_EXECUTE_TIMEOUT_MS,d as CHALLENGE_READY_TIMEOUT_MS,r as CIRCLE_RADIUS_FACTOR,Bt as CLIPPED_LUMA,f as CLIP_MIME_ALLOWLIST,Dt as CaptureSessionDoc,P as ChallengeError,tr as DOCUMENT_TYPE_ORDER,je as DOC_ANALYSIS_DEFAULTS,At as DOC_BLACK_FRAME_LUMA,Ot as DOC_BLACK_FRAME_TICKS,xt as DOC_CADENCE_HZ,tt as DOC_CAMERA_TUNING_DEFAULTS,Me as DOC_CATALOG,Be as DOC_DETECT_WIDTH,Ke as DOC_FEEDBACK_STATES,Ct as DOC_FIRST_FRAME_MS,Ve as DOC_GATE_V1_DEFAULTS,It as DOC_SHUTTER_DEFAULTS,V as DocAssist,ze as DocFeedbackAggregator,Qe as DocGateV1,Lt as EMPTY_GUIDE_METRICS,ge as FLIP_FILL_MIN,ve as FLIP_GAP_MS,he as FLIP_TIMEOUT_MS,Rt as GUIDE_LOCK_DEFAULTS,Tt as GuideLock,gt as ICAO_CANVAS,wt as ICAO_FALLBACK,Ht as ICAO_GATE_CRITERIA,Vt as ICAO_SHARP_REF,O as INFERENCE_RETRY_ATTEMPTS,x as INFERENCE_RETRY_DEFAULT_S,o as IN_CIRCLE_FACTOR,er as ISSUER_CODES,oe as LANDMARKER_MODEL,ot as LENS_STORAGE_KEY,xe as LENS_TRY_MAX,B as LIVE_MRZ_DEFAULTS,_e as LIVE_PHOTO_IDLE_MS,me as LIVE_PHOTO_MAX_HZ,Ge as MANUAL_SHUTTER_MS,We as MRZ_BAND_DEFAULTS,Fe as MR_DOC_CATALOG,be as NO_REPORT_MS,Re as OCR_ASSET_SET,ce as OTP_RESEND_COOLDOWN_MS,ie as PORTRAIT_JPEG_QUALITY,a as PRELOAD_BLAZE_INIT_TIMEOUT_MS,n as PRELOAD_BUDGET_MS,le as PROCESSING_BACKOFF_MS,Te as PROCESSING_POLL_DELAY_MS,fe as PROCESSING_POLL_MAX,h as REGION_PAD,ye as REGISTRY_RETRY_DELAY_MS,te as SAME_FACE_MAX_DROPS,v as SHARPNESS_LONG_EDGE,z as TEXT_LOCK_DEFAULTS,C as TRANSPORT_REPLAY_ATTEMPTS,A as TRANSPORT_REPLAY_DELAY_MS,J as WEB_OCR_ENGINE,or as acceptedIssuers,rr as acceptedTypesFor,et as analyzeDocFrame,ct as analyzeGuide,Pe as aspectBand,de as aspectFits,jt as backgroundStats,q as browserFamily,X as buildDeviceReadHint,K as classifyCardSide,k as classifyCardSideWith,st as coverPointToVideo,re as createDocumentCaptureInternal,ae as createFaceLandmarker,Kt as createIcaoGate,Le as createLivePhotoKit,l as createLivenessCaptureInternal,Ee as createPortraitCaptureInternal,Se as createStepRunner,Ae as createVerificationInternal,b as cropImage,e as detectFormFactor,t as detectIsMobile,ke as detectMrzBand,Et as docZoomFor,W as encodeDocumentImage,N as executeChallenge,vt as eyeLineRoll,Ut as eyeOpenness,Qt as eyeSpecular,Ft as faceGeometry,Jt as faceLighting,qt as faceSharpness,pe as facesOf,we as feedbackVoteOf,ar as flagOf,mt as focusOk,ee as formatMismatch,R as frontierStep,St as guideQuad,lt as guideRegionInFrame,$t as icaoPixelStats,ht as icaoWindow,Ye as initialScanState,c as isExecutable,S as isTerminalView,Yt as judgeIcao,Ie as lensKindOf,$ as liveMrzWireReport,Xt as lumaPlane,_ as mapEngineState,L as mapErrorKind,m as mapGuidanceHint,T as mapSessionResult,U as measureBitmapSharpness,Y as measureRegionSharpness,Ue as nextScanState,se as observePortraitFrame,_t as openDocCamera,Pt as passportBandOf,Wt as percentile,g as photoSharpness,bt as portraitCropRegion,Oe as portraitMatchStep,Nt as poseFromMatrix,E as preloadedDetectorFactory,Xe as quadAreaFrac,Je as quadBounds,Ze as quadIou,$e as quadTiltRatio,Ce as randomUuid,ue as rankBackCameras,pt as readStoredLens,Zt as regionStats,F as resetChallengeFrameForTests,s as resetLivenessAssetsForTests,H as resizeLongEdge,pr as resolveAcceptedDocuments,rt as resolveDocCameraTuning,ut as resolveDocShutterTuning,yt as resolveGuideLockTuning,zt as resolveIcaoTuning,Q as resolveWebOcrPlan,D as runLivenessFlow,u as runSubmission,Ne as scannerFormatFor,kt as scoreFrame,i as setPreloadLoaderForTests,Z as settledHint,it as singleShotFocusAt,qe as specularFraction,j as startWebOcr,y as stepOf,G as stillRegionOf,w as stillToImageData,nt as supportsFocusMode,ft as warmDocDetector,Gt as windowOverflow,at as writeStoredLens};
@@ -0,0 +1 @@
1
+ var C=4,P=600,k=.5,W=30,A={frontal:.1,eyes:.1,score:.05},_=e=>e<0?0:e>1?1:e;function w(e){let r=e.eyes;if(r===void 0)return{frontal:1,yaw:null,roll:null};let a=r.right.x-r.left.x,n=r.right.y-r.left.y,t=a*a+n*n;if(t===0)return{frontal:1,yaw:null,roll:null};let s=Math.abs(Math.atan2(n,Math.abs(a))*180/Math.PI),u=_(1-s/30),o=null,l=e.nose;if(l!==void 0){let m=(r.left.x+r.right.x)/2,f=(r.left.y+r.right.y)/2;o=Math.abs(((l.x-m)*a+(l.y-f)*n)/t),u*=_(1-o/.5)}return{frontal:u,yaw:o,roll:s}}function F(e,r){return e===null?{face:!1,frontal:0,yaw:null,roll:null,eyes:null,score:0,sharpness:r}:{face:!0,...w(e),eyes:null,score:e.score,sharpness:r}}function v(e){let r=e.map((t,s)=>s),a=(t,s)=>{let u=Number.NEGATIVE_INFINITY;for(let o of r)u=Math.max(u,t(e[o]));r=r.filter(o=>t(e[o])>=u-s)};a(t=>t.frontal,A.frontal),a(t=>t.eyes??1,A.eyes),a(t=>t.score,A.score);let n=-1;for(let t of r)(n===-1||e[t].sharpness>e[n].sharpness)&&(n=t);return n}var i=e=>Number.isFinite(e)?Math.round(e*1e3)/1e3:0,D=99,S=999999;function T(e){return{face:e.face,frontal:i(e.frontal),...e.yaw!==null?{yaw:Math.min(i(e.yaw),D)}:{},...e.roll!==null?{roll:i(e.roll)}:{},...e.eyes!==null?{eyes:i(e.eyes)}:{},score:i(e.score),sharpness:Math.min(i(e.sharpness),S)}}var g=I;async function I(e,r){let{options:a}=e,n=a.video,t=a.now??(()=>performance.now()),s=a.captureKeyframe??(c=>e.defaultKeyframe(c)),u=600/3,o=[],l=[],m=0;for(let c=0;c<4;c+=1){if(r!==e.attempt)return null;let d=e.detector,E=Promise.resolve(null),p,y=0;try{if(d!==null){let b=e.profiler?.profile.inputWidth??160,R=a.makeSnapshot?.(n,b)??e.defaultSnapshot(n,b);p=s(n).then(K=>(y=t(),K));let N=t();E=d.detect(R,n.videoWidth,n.videoHeight).then(K=>(m+=t()-N,K),()=>null)}else p=s(n).then(b=>(y=t(),b));let[h,O]=await Promise.all([p,E]);o.push(h),l.push(F(O,h.sharpness))}catch{p?.catch(()=>{})}let M=y>0?Math.max(0,t()-y):0;c<3&&await new Promise(h=>setTimeout(h,Math.max(0,u-M)))}if(r!==e.attempt)return null;let f=v(l);if(f===-1)return null;let x=0;l.forEach((c,d)=>{c.sharpness>l[x].sharpness&&(x=d)});try{a.telemetry?.({type:"keyframe",tier:e.detector?.tier??null,chosen:f,sharpest:x,detectMs:Math.round(m),candidates:l.map(T)})}catch{}return o[f]??null}export{C as RANK_CANDIDATES,A as RANK_TOLERANCE,P as RANK_WINDOW_MS,W as ROLL_ZERO_DEG,S as SHARPNESS_REPORT_MAX,D as YAW_REPORT_MAX,k as YAW_ZERO_IOD,I as collectRankedKeyframes,g as default,F as featuresOf,w as frontalOf,v as rankKeyframes};
@@ -0,0 +1 @@
1
+ import{a,b,c,d}from"./chunk-CJHMFPL6.js";export{a as LANDMARKER_INIT_TIMEOUT_MS,b as LANDMARKER_MODEL,d as createFaceLandmarker,c as facesOf};
@@ -0,0 +1 @@
1
+ import{a,b}from"./chunk-SMKCBUJL.js";export{a as MRZ_BAND_DEFAULTS,b as detectMrzBand};