@sekyro/web 0.0.0-stage → 0.1.0-rc.2

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 (68) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/LICENSE +20 -0
  3. package/README.md +92 -2
  4. package/dist/capture-constraints-BujkZcfb.d.cts +21 -0
  5. package/dist/capture-constraints-BujkZcfb.d.ts +21 -0
  6. package/dist/capture-session-v3-BJ8ciaWl.d.ts +457 -0
  7. package/dist/capture-session-v3-CAoWM8iT.d.cts +457 -0
  8. package/dist/chunk-BPYVZUJA.js +852 -0
  9. package/dist/chunk-BPYVZUJA.js.map +1 -0
  10. package/dist/chunk-LOTAJDRE.js +1094 -0
  11. package/dist/chunk-LOTAJDRE.js.map +1 -0
  12. package/dist/chunk-MWNFSNMP.js +52 -0
  13. package/dist/chunk-MWNFSNMP.js.map +1 -0
  14. package/dist/chunk-NILNKLK6.js +50 -0
  15. package/dist/chunk-NILNKLK6.js.map +1 -0
  16. package/dist/chunk-NWF46H7K.js +359 -0
  17. package/dist/chunk-NWF46H7K.js.map +1 -0
  18. package/dist/chunk-WY6U7AIK.js +193 -0
  19. package/dist/chunk-WY6U7AIK.js.map +1 -0
  20. package/dist/chunk-YVFF4Q4G.js +327 -0
  21. package/dist/chunk-YVFF4Q4G.js.map +1 -0
  22. package/dist/client/index.cjs +357 -0
  23. package/dist/client/index.cjs.map +1 -0
  24. package/dist/client/index.d.cts +39 -0
  25. package/dist/client/index.d.ts +39 -0
  26. package/dist/client/index.js +15 -0
  27. package/dist/client/index.js.map +1 -0
  28. package/dist/core/index.cjs +1605 -0
  29. package/dist/core/index.cjs.map +1 -0
  30. package/dist/core/index.d.cts +87 -0
  31. package/dist/core/index.d.ts +87 -0
  32. package/dist/core/index.js +139 -0
  33. package/dist/core/index.js.map +1 -0
  34. package/dist/core/v3/detect-worker.cjs +392 -0
  35. package/dist/core/v3/detect-worker.cjs.map +1 -0
  36. package/dist/core/v3/detect-worker.d.cts +1 -0
  37. package/dist/core/v3/detect-worker.d.ts +1 -0
  38. package/dist/core/v3/detect-worker.js +13 -0
  39. package/dist/core/v3/detect-worker.js.map +1 -0
  40. package/dist/create-verification-CjLnJ0w6.d.ts +348 -0
  41. package/dist/create-verification-EnZ13uY4.d.cts +348 -0
  42. package/dist/detect-worker-CKXHlXx9.d.cts +105 -0
  43. package/dist/detect-worker-CKXHlXx9.d.ts +105 -0
  44. package/dist/detector-scanic-4C6IEW2K.js +787 -0
  45. package/dist/detector-scanic-4C6IEW2K.js.map +1 -0
  46. package/dist/hosted-client-BpvBqu9f.d.cts +408 -0
  47. package/dist/hosted-client-BpvBqu9f.d.ts +408 -0
  48. package/dist/index.cjs +2636 -0
  49. package/dist/index.cjs.map +1 -0
  50. package/dist/index.d.cts +6 -0
  51. package/dist/index.d.ts +6 -0
  52. package/dist/index.js +28 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/internal/index.cjs +4166 -0
  55. package/dist/internal/index.cjs.map +1 -0
  56. package/dist/internal/index.d.cts +431 -0
  57. package/dist/internal/index.d.ts +431 -0
  58. package/dist/internal/index.js +647 -0
  59. package/dist/internal/index.js.map +1 -0
  60. package/dist/popup/index.cjs +76 -0
  61. package/dist/popup/index.cjs.map +1 -0
  62. package/dist/popup/index.d.cts +66 -0
  63. package/dist/popup/index.d.ts +66 -0
  64. package/dist/popup/index.js +11 -0
  65. package/dist/popup/index.js.map +1 -0
  66. package/dist/scanic-ml-stub-S2OZ6HEF.js +10 -0
  67. package/dist/scanic-ml-stub-S2OZ6HEF.js.map +1 -0
  68. package/package.json +118 -4
@@ -0,0 +1,1605 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/core/index.ts
31
+ var core_exports = {};
32
+ __export(core_exports, {
33
+ CENTERED_FACTOR: () => CENTERED_FACTOR,
34
+ CIRCLE_RADIUS_FACTOR: () => CIRCLE_RADIUS_FACTOR,
35
+ CLIP_MS: () => CLIP_MS,
36
+ CaptureSessionV3: () => CaptureSessionV3,
37
+ ClipError: () => ClipError,
38
+ ClipRecorder: () => ClipRecorder,
39
+ DEFAULT_CLIP_MIME: () => DEFAULT_CLIP_MIME,
40
+ DEFAULT_TIER_ORDER: () => DEFAULT_TIER_ORDER,
41
+ DEFAULT_V3_ASSET_BASE_URL: () => DEFAULT_V3_ASSET_BASE_URL,
42
+ DEVICE_PROFILES: () => DEVICE_PROFILES,
43
+ DetectScheduler: () => DetectScheduler,
44
+ DetectorLadderError: () => DetectorLadderError,
45
+ DeviceProfiler: () => DeviceProfiler,
46
+ EXPOSURE_BAND: () => EXPOSURE_BAND,
47
+ FaceGateV3: () => FaceGateV3,
48
+ IN_CIRCLE_FACTOR: () => IN_CIRCLE_FACTOR,
49
+ KEYFRAME_CANDIDATES: () => KEYFRAME_CANDIDATES,
50
+ KEYFRAME_WINDOW_MS: () => KEYFRAME_WINDOW_MS,
51
+ MAX_CLIP_BYTES: () => MAX_CLIP_BYTES,
52
+ MIME_CANDIDATES: () => MIME_CANDIDATES,
53
+ SHARP_REF: () => SHARP_REF,
54
+ STOP_GRACE_MS: () => STOP_GRACE_MS,
55
+ TIMESLICE_MS: () => TIMESLICE_MS,
56
+ V3_GATE_DEFAULTS: () => V3_GATE_DEFAULTS,
57
+ VIDEO_BPS: () => VIDEO_BPS,
58
+ buildCaptureConstraints: () => buildCaptureConstraints,
59
+ buildLivenessV2FormData: () => buildLivenessV2FormData,
60
+ cameraPreflight: () => cameraPreflight,
61
+ captureMirroredKeyframe: () => captureMirroredKeyframe,
62
+ classifyDevice: () => classifyDevice,
63
+ createDetector: () => createDetector,
64
+ detectIsMobile: () => detectIsMobile,
65
+ errorCopy: () => errorCopy,
66
+ exposure: () => exposure,
67
+ extForMime: () => extForMime,
68
+ intrinsicSize: () => intrinsicSize,
69
+ isClipTooLarge: () => isClipTooLarge,
70
+ isMediaRecorderSupported: () => isMediaRecorderSupported,
71
+ mapGetUserMediaError: () => mapGetUserMediaError,
72
+ meanLuma: () => meanLuma,
73
+ pickMimeType: () => pickMimeType,
74
+ probeDevice: () => probeDevice,
75
+ sharpness: () => sharpness,
76
+ toStreamPixels: () => toStreamPixels,
77
+ uiCopy: () => uiCopy
78
+ });
79
+ module.exports = __toCommonJS(core_exports);
80
+
81
+ // src/core/media.ts
82
+ var MIME_CANDIDATES = [
83
+ "video/mp4;codecs=avc1.42E01E,mp4a.40.2",
84
+ "video/mp4;codecs=avc1.42E01E",
85
+ "video/mp4",
86
+ "video/webm;codecs=vp9,opus",
87
+ "video/webm;codecs=vp9",
88
+ "video/webm;codecs=vp8,opus",
89
+ "video/webm;codecs=vp8",
90
+ "video/webm"
91
+ ];
92
+ function pickMimeType() {
93
+ const MR = globalThis.MediaRecorder;
94
+ if (!MR || typeof MR.isTypeSupported !== "function") return "";
95
+ return MIME_CANDIDATES.find((t) => MR.isTypeSupported(t)) ?? "";
96
+ }
97
+ var DEFAULT_CLIP_MIME = "video/webm";
98
+ function mapGetUserMediaError(err) {
99
+ if (err instanceof TypeError) return "insecure";
100
+ const name = err?.name ?? "";
101
+ switch (name) {
102
+ case "NotAllowedError":
103
+ case "PermissionDeniedError":
104
+ return "permission";
105
+ case "NotFoundError":
106
+ case "DevicesNotFoundError":
107
+ return "notfound";
108
+ case "NotReadableError":
109
+ case "TrackStartError":
110
+ return "inuse";
111
+ case "OverconstrainedError":
112
+ case "ConstraintNotSatisfiedError":
113
+ return "overconstrained";
114
+ default:
115
+ return "generic";
116
+ }
117
+ }
118
+ function cameraPreflight() {
119
+ const w = globalThis;
120
+ if (typeof w.window !== "undefined" && w.window.isSecureContext === false)
121
+ return "INSECURE_CONTEXT";
122
+ const md = w.navigator?.mediaDevices;
123
+ if (!md || typeof md.getUserMedia !== "function") return "UNSUPPORTED";
124
+ return "OK";
125
+ }
126
+ function isMediaRecorderSupported() {
127
+ const MR = globalThis.MediaRecorder;
128
+ return typeof MR !== "undefined" && typeof MR.isTypeSupported === "function";
129
+ }
130
+ var MAX_CLIP_BYTES = 8 * 1024 * 1024;
131
+ function isClipTooLarge(blob) {
132
+ return blob.size > MAX_CLIP_BYTES;
133
+ }
134
+ function extForMime(mime) {
135
+ const m = (mime || "").toLowerCase();
136
+ if (m.startsWith("image/jpeg")) return "jpg";
137
+ if (m.startsWith("video/mp4")) return "mp4";
138
+ if (m.startsWith("video/webm")) return "webm";
139
+ return "webm";
140
+ }
141
+ function buildLivenessV2FormData(args) {
142
+ const { token, clip, keyframe } = args;
143
+ const ts = args.ts ?? Date.now();
144
+ const clipType = clip.type || DEFAULT_CLIP_MIME;
145
+ const kfType = keyframe.type || "image/jpeg";
146
+ const fd = new FormData();
147
+ fd.append("token", token);
148
+ fd.append("clip", new File([clip], `liveness-${ts}.${extForMime(clipType)}`, { type: clipType }));
149
+ fd.append("keyframe", new File([keyframe], `keyframe-${ts}.${extForMime(kfType)}`, { type: kfType }));
150
+ return fd;
151
+ }
152
+
153
+ // src/core/keyframe.ts
154
+ function captureMirroredKeyframe(video, canvas, quality = 0.92) {
155
+ return new Promise((resolve, reject) => {
156
+ const w = video.videoWidth;
157
+ const h = video.videoHeight;
158
+ if (!w || !h) {
159
+ reject(new Error("video-not-ready"));
160
+ return;
161
+ }
162
+ const ctx = canvas.getContext("2d");
163
+ if (!ctx) {
164
+ reject(new Error("no-2d-context"));
165
+ return;
166
+ }
167
+ canvas.width = w;
168
+ canvas.height = h;
169
+ ctx.scale(-1, 1);
170
+ ctx.drawImage(video, -w, 0);
171
+ canvas.toBlob(
172
+ (blob) => blob ? resolve(blob) : reject(new Error("empty-keyframe")),
173
+ "image/jpeg",
174
+ quality
175
+ );
176
+ });
177
+ }
178
+
179
+ // src/core/messages.ts
180
+ var errorCopy = {
181
+ permission: {
182
+ key: "fcv2.err.permission",
183
+ fr: "Autorisez la cam\xE9ra dans les r\xE9glages du navigateur (ic\xF4ne cam\xE9ra dans la barre d\u2019adresse), puis r\xE9essayez."
184
+ },
185
+ notfound: {
186
+ key: "fcv2.err.notfound",
187
+ fr: "Aucune cam\xE9ra d\xE9tect\xE9e. Branchez ou activez une cam\xE9ra, puis r\xE9essayez."
188
+ },
189
+ inuse: {
190
+ key: "fcv2.err.inuse",
191
+ fr: "La cam\xE9ra est utilis\xE9e par une autre application. Fermez-la puis r\xE9essayez."
192
+ },
193
+ overconstrained: {
194
+ key: "fcv2.err.overconstrained",
195
+ fr: "La cam\xE9ra ne prend pas en charge les r\xE9glages demand\xE9s. Nouvel essai en cours\u2026"
196
+ },
197
+ insecure: {
198
+ key: "fcv2.err.insecure",
199
+ fr: "La cam\xE9ra n\xE9cessite une connexion s\xE9curis\xE9e (HTTPS). Ouvrez la page en HTTPS."
200
+ },
201
+ unsupported: {
202
+ key: "fcv2.err.unsupported",
203
+ fr: "Votre navigateur ne prend pas en charge l\u2019enregistrement vid\xE9o. Utilisez un navigateur r\xE9cent."
204
+ },
205
+ generic: {
206
+ key: "fcv2.err.generic",
207
+ fr: "Cam\xE9ra indisponible. R\xE9essayez ou contactez le support."
208
+ }
209
+ };
210
+ var uiCopy = {
211
+ recording: { key: "fcv2.recording", fr: "Enregistrement en cours\u2026" },
212
+ uploading: { key: "fcv2.uploading", fr: "Envoi en cours\u2026" },
213
+ clipTooLarge: {
214
+ key: "fcv2.err.cliptoolarge",
215
+ fr: "La vid\xE9o est trop volumineuse. R\xE9essayez dans un endroit mieux \xE9clair\xE9."
216
+ },
217
+ retry: { key: "fcv2.retry", fr: "R\xE9essayer" },
218
+ listen: { key: "fcv2.listen", fr: "\xC9couter" }
219
+ };
220
+
221
+ // src/core/clip-recorder.ts
222
+ var CLIP_MS = 2500;
223
+ var TIMESLICE_MS = 1e3;
224
+ var STOP_GRACE_MS = 1500;
225
+ var VIDEO_BPS = 25e5;
226
+ var ClipError = class extends Error {
227
+ constructor(kind, msg) {
228
+ super(msg ?? kind);
229
+ this.kind = kind;
230
+ }
231
+ };
232
+ var ClipRecorder = class {
233
+ constructor() {
234
+ this.recorder = null;
235
+ this.stream = null;
236
+ // own field so teardown can stop tracks (REVIEW FIX 8)
237
+ this.chunks = [];
238
+ this.bytes = 0;
239
+ this.hardStopTimer = null;
240
+ this.graceTimer = null;
241
+ this.settled = false;
242
+ }
243
+ clearTimers() {
244
+ if (this.hardStopTimer) clearTimeout(this.hardStopTimer);
245
+ if (this.graceTimer) clearTimeout(this.graceTimer);
246
+ this.hardStopTimer = null;
247
+ this.graceTimer = null;
248
+ }
249
+ /** Records CLIP_MS of the stream. Resolves with the clip blob + its container mime;
250
+ * rejects with ClipError. Behavior contract is the v1 hook's `start`, verbatim
251
+ * (iOS workarounds included).
252
+ *
253
+ * ONE RECORDING AT A TIME: chunk/byte/timer state is shared per instance, so a
254
+ * second record() while one is in flight rejects ClipError("generic") instead of
255
+ * corrupting the in-flight clip. (v2 guard — v1's hook was gated by its owning
256
+ * component; a class API invites reuse. Zero impact on clip bytes.)
257
+ *
258
+ * `onStopped` (optional) fires ONCE the moment the CLIP_MS recording window
259
+ * elapses (the hard-stop), BEFORE finalize — which on iOS can lag up to
260
+ * STOP_GRACE_MS while onstop flushes the last chunk. It lets the host freeze
261
+ * the display on the already-captured keyframe the instant recording ends,
262
+ * instead of waiting for the blob. PURE NOTIFICATION — it does not touch
263
+ * timers, chunks, or the finalize path, so it is calibration-neutral (no
264
+ * effect on clip bytes). Never fires on a rejected capture (error /
265
+ * cliptoolarge settle before the hard-stop and clear the timer). */
266
+ record(stream, onStopped) {
267
+ if (this.recorder && !this.settled) {
268
+ return Promise.reject(
269
+ new ClipError(
270
+ "generic",
271
+ "record() called while a recording is in flight \u2014 ClipRecorder handles one recording at a time"
272
+ )
273
+ );
274
+ }
275
+ this.recorder = null;
276
+ this.clearTimers();
277
+ this.chunks = [];
278
+ this.bytes = 0;
279
+ this.settled = false;
280
+ this.stream = stream;
281
+ const picked = pickMimeType();
282
+ return new Promise((resolve, reject) => {
283
+ let recorder;
284
+ try {
285
+ recorder = new MediaRecorder(
286
+ stream,
287
+ picked ? { mimeType: picked, videoBitsPerSecond: VIDEO_BPS } : { videoBitsPerSecond: VIDEO_BPS }
288
+ );
289
+ } catch {
290
+ try {
291
+ recorder = new MediaRecorder(stream);
292
+ } catch {
293
+ reject(new ClipError("unsupported"));
294
+ return;
295
+ }
296
+ }
297
+ this.recorder = recorder;
298
+ const settle = (fn) => {
299
+ if (this.settled) return;
300
+ this.settled = true;
301
+ this.clearTimers();
302
+ fn();
303
+ };
304
+ const finalize = () => settle(() => {
305
+ const type = recorder.mimeType || picked || DEFAULT_CLIP_MIME;
306
+ const blob = new Blob(this.chunks, { type });
307
+ if (isClipTooLarge(blob)) {
308
+ reject(new ClipError("cliptoolarge"));
309
+ return;
310
+ }
311
+ resolve({ blob, mimeType: type });
312
+ });
313
+ recorder.ondataavailable = (e) => {
314
+ if (e.data && e.data.size) {
315
+ this.chunks.push(e.data);
316
+ this.bytes += e.data.size;
317
+ if (this.bytes > MAX_CLIP_BYTES) {
318
+ settle(() => {
319
+ try {
320
+ if (recorder.state !== "inactive") recorder.stop();
321
+ } catch {
322
+ }
323
+ reject(new ClipError("cliptoolarge"));
324
+ });
325
+ }
326
+ }
327
+ };
328
+ recorder.onstop = finalize;
329
+ recorder.onerror = () => settle(() => reject(new ClipError("generic")));
330
+ try {
331
+ recorder.start(TIMESLICE_MS);
332
+ } catch {
333
+ settle(() => reject(new ClipError("generic")));
334
+ return;
335
+ }
336
+ this.hardStopTimer = setTimeout(() => {
337
+ if (!this.settled) onStopped?.();
338
+ if (recorder.state !== "inactive") {
339
+ try {
340
+ recorder.stop();
341
+ } catch {
342
+ finalize();
343
+ }
344
+ this.graceTimer = setTimeout(finalize, STOP_GRACE_MS);
345
+ } else {
346
+ finalize();
347
+ }
348
+ }, CLIP_MS);
349
+ });
350
+ }
351
+ /** Idempotent teardown: stop recorder + ALL tracks (v1 `stopAndCleanup` + the unmount
352
+ * effect). Optional `stream` override mirrors v1's `stopAndCleanup(stream?)`.
353
+ *
354
+ * MID-RECORDING SEMANTICS (verbatim v1): calling stop() while a record() is in
355
+ * flight may LATER resolve the pending promise with a TRUNCATED clip (recorder.stop()
356
+ * fires onstop → finalize from whatever chunks arrived so far), or — because this
357
+ * method clears the hard-stop/grace timers — never settle it at all if onstop never
358
+ * fires (the iOS grace path has been torn down). Callers MUST NOT treat a resolution
359
+ * arriving after stop() as a full CLIP_MS clip, and must not await a record()
360
+ * promise past stop() without their own timeout. (Task 4's CaptureSession owns
361
+ * sequencing on top of this contract.) */
362
+ stop(stream) {
363
+ this.clearTimers();
364
+ const rec = this.recorder;
365
+ if (rec && rec.state !== "inactive") {
366
+ try {
367
+ rec.stop();
368
+ } catch {
369
+ }
370
+ }
371
+ this.recorder = null;
372
+ const s = stream ?? this.stream;
373
+ s?.getTracks().forEach((t) => t.stop());
374
+ this.stream = null;
375
+ }
376
+ };
377
+
378
+ // src/core/capture-constraints.ts
379
+ function buildCaptureConstraints(isMobile, facingMode) {
380
+ void isMobile;
381
+ return {
382
+ video: {
383
+ width: { ideal: 1280, max: 1280 },
384
+ height: { ideal: 720, max: 720 },
385
+ facingMode,
386
+ frameRate: { ideal: 24, max: 30 }
387
+ },
388
+ audio: false
389
+ };
390
+ }
391
+ function detectIsMobile() {
392
+ if (typeof window === "undefined" || typeof navigator === "undefined") return false;
393
+ return window.innerWidth <= 768 || /Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
394
+ String(navigator.userAgent ?? "")
395
+ );
396
+ }
397
+ var CIRCLE_RADIUS_FACTOR = 0.45;
398
+ var IN_CIRCLE_FACTOR = 0.9;
399
+ var CENTERED_FACTOR = 0.4;
400
+
401
+ // src/core/v3/detector-blaze.ts
402
+ var BLAZE_INIT_TIMEOUT_MS = 1e4;
403
+ var BlazeDetector = class _BlazeDetector {
404
+ constructor(inner, fallbackReason) {
405
+ this.tier = "blaze";
406
+ this.inner = inner;
407
+ if (fallbackReason !== void 0) this.fallbackReason = fallbackReason;
408
+ }
409
+ static async create(assetBaseUrl, fallbackReason) {
410
+ const vision = await import("@mediapipe/tasks-vision");
411
+ const fileset = await vision.FilesetResolver.forVisionTasks(assetBaseUrl);
412
+ const inner = await vision.FaceDetector.createFromOptions(fileset, {
413
+ baseOptions: {
414
+ modelAssetPath: `${assetBaseUrl}/blaze_face_short_range.tflite`,
415
+ // CPU delegate — the iOS-Safari-safe path (see header). NEVER 'GPU'.
416
+ delegate: "CPU"
417
+ },
418
+ runningMode: "IMAGE"
419
+ });
420
+ return new _BlazeDetector(inner, fallbackReason);
421
+ }
422
+ async detect(source, sourceWidth, sourceHeight) {
423
+ let detections;
424
+ try {
425
+ detections = this.inner.detect(source).detections;
426
+ } catch {
427
+ return null;
428
+ }
429
+ const best = pickMostConfident(detections);
430
+ if (best?.boundingBox === void 0) return null;
431
+ const size = intrinsicSize(source);
432
+ const eyes = extractEyes(best.keypoints, size);
433
+ const observation = {
434
+ box: {
435
+ x: best.boundingBox.originX,
436
+ y: best.boundingBox.originY,
437
+ width: best.boundingBox.width,
438
+ height: best.boundingBox.height
439
+ },
440
+ ...eyes !== void 0 ? { eyes } : {},
441
+ score: best.categories[0]?.score ?? 0
442
+ };
443
+ return toStreamPixels(observation, source, sourceWidth, sourceHeight);
444
+ }
445
+ destroy() {
446
+ try {
447
+ this.inner.close();
448
+ } catch {
449
+ }
450
+ }
451
+ };
452
+ function pickMostConfident(detections) {
453
+ let best;
454
+ let bestScore = -1;
455
+ for (const detection of detections) {
456
+ const score = detection.categories[0]?.score ?? 0;
457
+ if (score > bestScore) {
458
+ best = detection;
459
+ bestScore = score;
460
+ }
461
+ }
462
+ return best;
463
+ }
464
+ function extractEyes(keypoints, size) {
465
+ const a = keypoints?.[0];
466
+ const b = keypoints?.[1];
467
+ if (a === void 0 || b === void 0) return void 0;
468
+ const toSource = (p) => ({ x: p.x * size.width, y: p.y * size.height });
469
+ const [pa, pb] = [toSource(a), toSource(b)];
470
+ return pa.x <= pb.x ? { left: pa, right: pb } : { left: pb, right: pa };
471
+ }
472
+
473
+ // src/core/v3/detector-native.ts
474
+ function smokeSource() {
475
+ if (typeof OffscreenCanvas === "function") return new OffscreenCanvas(2, 2);
476
+ const canvas = document.createElement("canvas");
477
+ canvas.width = 2;
478
+ canvas.height = 2;
479
+ return canvas;
480
+ }
481
+ async function probeNativeDetector() {
482
+ const ctor = globalThis.FaceDetector;
483
+ if (typeof ctor !== "function") return { ok: false, reason: "unsupported" };
484
+ try {
485
+ const instance = new ctor({ fastMode: true, maxDetectedFaces: 1 });
486
+ await instance.detect(smokeSource());
487
+ return { ok: true, instance };
488
+ } catch (err) {
489
+ return { ok: false, reason: `smoke_failed:${err instanceof Error ? err.message : String(err)}` };
490
+ }
491
+ }
492
+ var NativeDetector = class {
493
+ constructor(inner, fallbackReason) {
494
+ this.tier = "native";
495
+ this.inner = inner;
496
+ if (fallbackReason !== void 0) this.fallbackReason = fallbackReason;
497
+ }
498
+ async detect(source, sourceWidth, sourceHeight) {
499
+ let faces;
500
+ try {
501
+ faces = await this.inner.detect(source);
502
+ } catch {
503
+ return null;
504
+ }
505
+ const face = faces[0];
506
+ if (face === void 0) return null;
507
+ const eyes = extractEyes2(face.landmarks);
508
+ const observation = {
509
+ box: {
510
+ x: face.boundingBox.x,
511
+ y: face.boundingBox.y,
512
+ width: face.boundingBox.width,
513
+ height: face.boundingBox.height
514
+ },
515
+ ...eyes !== void 0 ? { eyes } : {},
516
+ // The Shape Detection API exposes no confidence — the smoke-tested
517
+ // native tier treats any detection as confident.
518
+ score: 1
519
+ };
520
+ return toStreamPixels(observation, source, sourceWidth, sourceHeight);
521
+ }
522
+ destroy() {
523
+ }
524
+ };
525
+ function extractEyes2(landmarks) {
526
+ if (landmarks === void 0) return void 0;
527
+ const eyePoints = landmarks.filter((landmark) => landmark.type === "eye").map((landmark) => landmark.locations[0]).filter((point) => point !== void 0);
528
+ const [a, b] = eyePoints;
529
+ if (a === void 0 || b === void 0) return void 0;
530
+ return a.x <= b.x ? { left: a, right: b } : { left: b, right: a };
531
+ }
532
+
533
+ // src/core/v3/detector.ts
534
+ var DEFAULT_V3_ASSET_BASE_URL = "/models-v3";
535
+ var DEFAULT_TIER_ORDER = ["native", "blaze"];
536
+ var DetectorLadderError = class extends Error {
537
+ constructor(fallbackReason) {
538
+ super(`no detector tier available (${fallbackReason})`);
539
+ this.name = "DetectorLadderError";
540
+ this.fallbackReason = fallbackReason;
541
+ }
542
+ };
543
+ function intrinsicSize(source) {
544
+ const candidate = source;
545
+ if (typeof candidate.videoWidth === "number" && candidate.videoWidth > 0) {
546
+ return { width: candidate.videoWidth, height: candidate.videoHeight ?? 0 };
547
+ }
548
+ if (typeof candidate.naturalWidth === "number" && candidate.naturalWidth > 0) {
549
+ return { width: candidate.naturalWidth, height: candidate.naturalHeight ?? 0 };
550
+ }
551
+ const width = typeof candidate.width === "number" ? candidate.width : 0;
552
+ const height = typeof candidate.height === "number" ? candidate.height : 0;
553
+ return { width, height };
554
+ }
555
+ function toStreamPixels(observation, source, streamWidth, streamHeight) {
556
+ const size = intrinsicSize(source);
557
+ const scaleX = size.width > 0 ? streamWidth / size.width : 1;
558
+ const scaleY = size.height > 0 ? streamHeight / size.height : 1;
559
+ const scalePoint = (p) => ({ x: p.x * scaleX, y: p.y * scaleY });
560
+ return {
561
+ box: {
562
+ x: observation.box.x * scaleX,
563
+ y: observation.box.y * scaleY,
564
+ width: observation.box.width * scaleX,
565
+ height: observation.box.height * scaleY
566
+ },
567
+ ...observation.eyes !== void 0 ? { eyes: { left: scalePoint(observation.eyes.left), right: scalePoint(observation.eyes.right) } } : {},
568
+ score: observation.score
569
+ };
570
+ }
571
+ function describeError(err) {
572
+ return err instanceof Error ? err.message : String(err);
573
+ }
574
+ async function createDetector(options) {
575
+ const order = options.preferred ?? DEFAULT_TIER_ORDER;
576
+ const reasons = [];
577
+ for (const tier of order) {
578
+ if (tier === "native") {
579
+ const probed = await probeNativeDetector();
580
+ if (probed.ok) {
581
+ return new NativeDetector(probed.instance, reasonOf(reasons));
582
+ }
583
+ reasons.push(`native:${probed.reason}`);
584
+ continue;
585
+ }
586
+ try {
587
+ return await withTimeout(
588
+ BlazeDetector.create(
589
+ options.v3AssetBaseUrl ?? DEFAULT_V3_ASSET_BASE_URL,
590
+ reasonOf(reasons)
591
+ ),
592
+ options.blazeInitTimeoutMs ?? BLAZE_INIT_TIMEOUT_MS
593
+ );
594
+ } catch (err) {
595
+ reasons.push(
596
+ err instanceof InitTimeoutError ? "blaze:blaze_init_timeout" : `blaze:${describeError(err)}`
597
+ );
598
+ }
599
+ }
600
+ throw new DetectorLadderError(reasonOf(reasons) ?? "no_tier_available");
601
+ }
602
+ function reasonOf(reasons) {
603
+ return reasons.length > 0 ? reasons.join("; ") : void 0;
604
+ }
605
+ var InitTimeoutError = class extends Error {
606
+ };
607
+ function withTimeout(promise, deadlineMs) {
608
+ return new Promise((resolvePromise, rejectPromise) => {
609
+ const timer = setTimeout(() => {
610
+ rejectPromise(new InitTimeoutError(`init exceeded ${deadlineMs}ms`));
611
+ promise.then(
612
+ (value) => value.destroy(),
613
+ () => void 0
614
+ );
615
+ }, deadlineMs);
616
+ promise.then(
617
+ (value) => {
618
+ clearTimeout(timer);
619
+ resolvePromise(value);
620
+ },
621
+ (err) => {
622
+ clearTimeout(timer);
623
+ rejectPromise(err);
624
+ }
625
+ );
626
+ });
627
+ }
628
+
629
+ // src/core/v3/frame-quality.ts
630
+ var SHARP_REF = 180;
631
+ var EXPOSURE_BAND = [100, 190];
632
+ var EXPOSURE_FALLOFF = 64;
633
+ function lumaAt(data, index) {
634
+ return 0.299 * (data[index] ?? 0) + 0.587 * (data[index + 1] ?? 0) + 0.114 * (data[index + 2] ?? 0);
635
+ }
636
+ function meanLuma(image) {
637
+ const { data, width, height } = image;
638
+ const pixels = width * height;
639
+ if (pixels === 0) return 0;
640
+ let sum = 0;
641
+ for (let i = 0; i < pixels; i += 1) sum += lumaAt(data, i * 4);
642
+ return sum / pixels;
643
+ }
644
+ function sharpness(image) {
645
+ const { data, width, height } = image;
646
+ if (width < 3 || height < 3) return 0;
647
+ const gray = new Float32Array(width * height);
648
+ for (let i = 0; i < gray.length; i += 1) gray[i] = lumaAt(data, i * 4);
649
+ let sum = 0;
650
+ let sumSquares = 0;
651
+ let count = 0;
652
+ for (let y = 1; y < height - 1; y += 1) {
653
+ for (let x = 1; x < width - 1; x += 1) {
654
+ const i = y * width + x;
655
+ const response = (gray[i - width] ?? 0) + (gray[i - 1] ?? 0) + (gray[i + 1] ?? 0) + (gray[i + width] ?? 0) - 4 * (gray[i] ?? 0);
656
+ sum += response;
657
+ sumSquares += response * response;
658
+ count += 1;
659
+ }
660
+ }
661
+ if (count === 0) return 0;
662
+ const mean = sum / count;
663
+ const variance = sumSquares / count - mean * mean;
664
+ return Math.min(1, Math.max(0, variance) / SHARP_REF);
665
+ }
666
+ function exposure(image) {
667
+ const mean = meanLuma(image);
668
+ const [low, high] = EXPOSURE_BAND;
669
+ const distance = mean < low ? low - mean : mean > high ? mean - high : 0;
670
+ return Math.max(0, 1 - distance / EXPOSURE_FALLOFF);
671
+ }
672
+
673
+ // src/core/v3/face-gate-v3.ts
674
+ var V3_GATE_DEFAULTS = Object.freeze({
675
+ Q_GOOD: 0.6,
676
+ RISE_PER_S: 0.9,
677
+ FALL_PER_S: 0.25,
678
+ CENTER_FALLOFF_IOD_MULTIPLE: 1.35,
679
+ BOX_EYE_OFFSET_FACTOR: 0.12,
680
+ IOD_BOX_PROXY_FACTOR: 0.42,
681
+ SIZE_IDEAL_MIN: 0.12,
682
+ SIZE_IDEAL_MAX: 0.3,
683
+ SIZE_HARD_MIN: 0.08,
684
+ SIZE_HARD_MAX: 0.45,
685
+ ROLL_MAX_DEG: 25,
686
+ MOTION_VELOCITY_IOD_PER_S: 0.5,
687
+ MOTION_TAU_S: 0.4,
688
+ MOTION_DEADBAND_IOD_PER_S: 0.1,
689
+ READY_WINDOW_MS: 500,
690
+ // 0.7→0.75 with the trimmed window: trimming forgives exactly ONE flaky
691
+ // tick; the raised mean keeps a SECOND bad tick (a real sustained wobble)
692
+ // from diluting through at 10 Hz cadences.
693
+ READY_MEAN_Q: 0.75,
694
+ GUIDE_SIZE: 0.6,
695
+ GUIDE_CENTERING: 0.6,
696
+ GUIDE_POSE: 0.6,
697
+ GUIDE_EXPOSURE: 0.6,
698
+ GUIDE_SHARPNESS: 0.35,
699
+ GUIDE_MOTION: 0.5
700
+ });
701
+ var clamp01 = (value) => Math.min(1, Math.max(0, value));
702
+ var FaceGateV3 = class {
703
+ constructor(overrides = {}) {
704
+ this.p = 0;
705
+ this.lastTickAt = null;
706
+ this.lastCenter = null;
707
+ this.velocityEma = 0;
708
+ this.qWindow = [];
709
+ /** Which side of the ideal band the last size measurement fell on. */
710
+ this.lastSizeDirection = "ideal";
711
+ this.t = { ...V3_GATE_DEFAULTS, ...overrides };
712
+ }
713
+ reset() {
714
+ this.p = 0;
715
+ this.lastTickAt = null;
716
+ this.lastCenter = null;
717
+ this.velocityEma = 0;
718
+ this.qWindow = [];
719
+ this.lastSizeDirection = "ideal";
720
+ }
721
+ tick(input) {
722
+ const { observation, quality, timestampMs } = input;
723
+ const dtSeconds = this.lastTickAt === null ? 0 : Math.max(0, (timestampMs - this.lastTickAt) / 1e3);
724
+ this.lastTickAt = timestampMs;
725
+ const factors = {
726
+ presence: 0,
727
+ centering: 0,
728
+ size: 0,
729
+ pose: 0,
730
+ sharpness: clamp01(quality.sharpness),
731
+ exposure: clamp01(quality.exposure),
732
+ motion: 1
733
+ };
734
+ if (observation !== null) {
735
+ factors.presence = 1;
736
+ const geometry = this.geometryOf(observation, input);
737
+ factors.centering = geometry.centering;
738
+ factors.size = geometry.size;
739
+ factors.pose = geometry.pose;
740
+ factors.motion = this.motionOf(
741
+ geometry.center,
742
+ geometry.iod,
743
+ timestampMs
744
+ );
745
+ } else {
746
+ this.lastCenter = null;
747
+ this.velocityEma = 0;
748
+ }
749
+ const q = Math.min(
750
+ factors.presence,
751
+ factors.centering,
752
+ factors.size,
753
+ factors.pose,
754
+ factors.sharpness,
755
+ factors.exposure,
756
+ factors.motion
757
+ );
758
+ this.p = clamp01(
759
+ this.p + (q >= this.t.Q_GOOD ? this.t.RISE_PER_S * q : -this.t.FALL_PER_S * (1 - q)) * dtSeconds
760
+ );
761
+ this.qWindow.push({ at: timestampMs, q });
762
+ this.qWindow = this.qWindow.filter(
763
+ (entry) => entry.at >= timestampMs - this.t.READY_WINDOW_MS
764
+ );
765
+ let windowSamples = this.qWindow.map((entry) => entry.q);
766
+ if (windowSamples.length >= 3) {
767
+ const worst = Math.min(...windowSamples);
768
+ const worstIndex = windowSamples.indexOf(worst);
769
+ windowSamples = windowSamples.filter((_, index) => index !== worstIndex);
770
+ }
771
+ const windowMean = windowSamples.reduce((sum, value) => sum + value, 0) / Math.max(1, windowSamples.length);
772
+ const ready = this.p >= 1 && windowMean >= this.t.READY_MEAN_Q;
773
+ return {
774
+ at: timestampMs,
775
+ q,
776
+ p: this.p,
777
+ factors,
778
+ guidanceKey: this.guidanceOf(factors, quality, q),
779
+ ready
780
+ };
781
+ }
782
+ geometryOf(observation, input) {
783
+ const { box, eyes } = observation;
784
+ const frameCenter = { x: input.frameWidth / 2, y: input.frameHeight / 2 };
785
+ const shortSide = Math.min(input.frameWidth, input.frameHeight);
786
+ const center = eyes !== void 0 ? {
787
+ x: (eyes.left.x + eyes.right.x) / 2,
788
+ y: (eyes.left.y + eyes.right.y) / 2
789
+ } : {
790
+ x: box.x + box.width / 2,
791
+ y: box.y + box.height / 2 - this.t.BOX_EYE_OFFSET_FACTOR * box.height
792
+ };
793
+ const iod = eyes !== void 0 ? Math.hypot(eyes.right.x - eyes.left.x, eyes.right.y - eyes.left.y) : this.t.IOD_BOX_PROXY_FACTOR * box.width;
794
+ const distance = Math.hypot(
795
+ center.x - frameCenter.x,
796
+ center.y - frameCenter.y
797
+ );
798
+ const centering = iod <= 0 ? 0 : 1 - clamp01(distance / (this.t.CENTER_FALLOFF_IOD_MULTIPLE * iod));
799
+ const ratio = shortSide > 0 ? iod / shortSide : 0;
800
+ this.lastSizeDirection = ratio < this.t.SIZE_IDEAL_MIN ? "far" : ratio > this.t.SIZE_IDEAL_MAX ? "close" : "ideal";
801
+ let size;
802
+ if (ratio < this.t.SIZE_HARD_MIN || ratio > this.t.SIZE_HARD_MAX) {
803
+ size = 0;
804
+ } else if (ratio < this.t.SIZE_IDEAL_MIN) {
805
+ size = (ratio - this.t.SIZE_HARD_MIN) / (this.t.SIZE_IDEAL_MIN - this.t.SIZE_HARD_MIN);
806
+ } else if (ratio > this.t.SIZE_IDEAL_MAX) {
807
+ size = (this.t.SIZE_HARD_MAX - ratio) / (this.t.SIZE_HARD_MAX - this.t.SIZE_IDEAL_MAX);
808
+ } else {
809
+ size = 1;
810
+ }
811
+ let pose = 1;
812
+ if (eyes !== void 0) {
813
+ const rollDeg = Math.abs(
814
+ Math.atan2(eyes.right.y - eyes.left.y, eyes.right.x - eyes.left.x)
815
+ ) * 180 / Math.PI;
816
+ pose = 1 - clamp01(rollDeg / this.t.ROLL_MAX_DEG);
817
+ }
818
+ return { center, iod, centering, size, pose };
819
+ }
820
+ motionOf(center, iod, at) {
821
+ const previous = this.lastCenter;
822
+ this.lastCenter = { ...center, at };
823
+ if (previous === null || iod <= 0) return 1;
824
+ const dtSeconds = (at - previous.at) / 1e3;
825
+ if (dtSeconds <= 0) return 1;
826
+ let velocityIodPerS = Math.hypot(center.x - previous.x, center.y - previous.y) / iod / dtSeconds;
827
+ if (velocityIodPerS <= this.t.MOTION_DEADBAND_IOD_PER_S)
828
+ velocityIodPerS = 0;
829
+ const alpha = 1 - Math.exp(-dtSeconds / this.t.MOTION_TAU_S);
830
+ this.velocityEma = alpha * velocityIodPerS + (1 - alpha) * this.velocityEma;
831
+ return 1 - clamp01(this.velocityEma / this.t.MOTION_VELOCITY_IOD_PER_S);
832
+ }
833
+ /** Lowest failing factor speaks — fixed priority (diagnostic, incl. light):
834
+ * presence → size → centering → pose → exposure → sharpness → hold.
835
+ *
836
+ * HONESTY FALLBACK (operator ruling 2026-07-12): when every factor clears
837
+ * its guide threshold but q (= min factor) is still below Q_GOOD — i.e.
838
+ * progress is DRAINING — "hold still" would be a lie ("Perfect" while
839
+ * nothing advances; the field symptom was users discovering by accident
840
+ * that only leaning in fires the gate). In that state the WORST factor
841
+ * speaks even though it passed its guide level, so the user always hears
842
+ * the change that actually unblocks recording. */
843
+ guidanceOf(factors, quality, q) {
844
+ if (factors.presence <= 0) return "fcv3.no_face";
845
+ if (factors.size < this.t.GUIDE_SIZE) return this.sizeGuidance();
846
+ if (factors.centering < this.t.GUIDE_CENTERING) return "fcv3.center_face";
847
+ if (factors.pose < this.t.GUIDE_POSE) return "fcv3.straighten";
848
+ if (factors.exposure < this.t.GUIDE_EXPOSURE)
849
+ return this.exposureGuidance(quality);
850
+ if (factors.sharpness < this.t.GUIDE_SHARPNESS) return "fcv3.steady_camera";
851
+ if (factors.motion < this.t.GUIDE_MOTION) return "fcv3.hold_still";
852
+ if (q < this.t.Q_GOOD) {
853
+ const coachable = [
854
+ ["size", this.sizeGuidance()],
855
+ ["centering", "fcv3.center_face"],
856
+ ["pose", "fcv3.straighten"],
857
+ ["exposure", this.exposureGuidance(quality)],
858
+ ["sharpness", "fcv3.steady_camera"],
859
+ ["motion", "fcv3.hold_still"]
860
+ ];
861
+ let worst = coachable[0];
862
+ for (const entry of coachable) {
863
+ if (factors[entry[0]] < factors[worst[0]]) worst = entry;
864
+ }
865
+ return worst[1];
866
+ }
867
+ return "fcv3.hold_still";
868
+ }
869
+ /** Direction from the size band set THIS tick (never inverted at the hard
870
+ * limits: past SIZE_HARD_MAX the direction is 'close' → move_back). */
871
+ sizeGuidance() {
872
+ return this.lastSizeDirection === "far" ? "fcv3.come_closer" : "fcv3.move_back";
873
+ }
874
+ /** Band midpoint — direction only (tracks EXPOSURE_BAND automatically). */
875
+ exposureGuidance(quality) {
876
+ const bandMid = (EXPOSURE_BAND[0] + EXPOSURE_BAND[1]) / 2;
877
+ return quality.meanLuma < bandMid ? "fcv3.more_light" : "fcv3.too_bright";
878
+ }
879
+ };
880
+
881
+ // src/core/v3/device-profile.ts
882
+ var DEVICE_PROFILES = Object.freeze({
883
+ LOW: Object.freeze({ cadenceHz: 5, inputWidth: 128, animations: "reduced" }),
884
+ MID: Object.freeze({ cadenceHz: 8, inputWidth: 160, animations: "full" }),
885
+ HIGH: Object.freeze({ cadenceHz: 10, inputWidth: 192, animations: "full" })
886
+ });
887
+ var SIMD_TEST_BYTES = new Uint8Array([
888
+ 0,
889
+ 97,
890
+ 115,
891
+ 109,
892
+ 1,
893
+ 0,
894
+ 0,
895
+ 0,
896
+ 1,
897
+ 5,
898
+ 1,
899
+ 96,
900
+ 0,
901
+ 1,
902
+ 123,
903
+ 3,
904
+ 2,
905
+ 1,
906
+ 0,
907
+ 10,
908
+ 10,
909
+ 1,
910
+ 8,
911
+ 0,
912
+ 65,
913
+ 0,
914
+ 253,
915
+ 15,
916
+ 253,
917
+ 98,
918
+ 11
919
+ ]);
920
+ function probeDevice() {
921
+ const nav = typeof navigator === "undefined" ? void 0 : navigator;
922
+ let simd = false;
923
+ try {
924
+ simd = typeof WebAssembly !== "undefined" && WebAssembly.validate(SIMD_TEST_BYTES);
925
+ } catch {
926
+ simd = false;
927
+ }
928
+ return {
929
+ cores: nav?.hardwareConcurrency ?? 2,
930
+ memGB: nav?.deviceMemory ?? null,
931
+ simd
932
+ };
933
+ }
934
+ function classifyDevice(probe) {
935
+ const memGB = probe.memGB ?? 4;
936
+ if (probe.cores < 4 || memGB < 3) return "LOW";
937
+ if (probe.cores >= 8 && memGB >= 6) return "HIGH";
938
+ return "MID";
939
+ }
940
+ var ORDER = ["LOW", "MID", "HIGH"];
941
+ var DeviceProfiler = class {
942
+ constructor(initial) {
943
+ this.samples = [];
944
+ this.adjusted = false;
945
+ this.current = initial;
946
+ }
947
+ get deviceClass() {
948
+ return this.current;
949
+ }
950
+ get profile() {
951
+ return DEVICE_PROFILES[this.current];
952
+ }
953
+ record(detectMs) {
954
+ if (this.adjusted || this.samples.length >= 10) return this.current;
955
+ this.samples.push(detectMs);
956
+ if (this.samples.length < 10) return this.current;
957
+ this.adjusted = true;
958
+ const mean = this.samples.reduce((sum, value) => sum + value, 0) / this.samples.length;
959
+ if (mean > 70) {
960
+ this.current = "LOW";
961
+ } else if (mean < 25) {
962
+ const index = ORDER.indexOf(this.current);
963
+ this.current = ORDER[Math.min(ORDER.length - 1, index + 1)] ?? this.current;
964
+ }
965
+ return this.current;
966
+ }
967
+ };
968
+
969
+ // src/core/v3/detect-scheduler.ts
970
+ var STATS_WINDOW = 20;
971
+ var DetectScheduler = class {
972
+ constructor(options) {
973
+ this.timer = null;
974
+ this.frameCallbackId = null;
975
+ this.running = false;
976
+ this.busy = false;
977
+ this.lastRunAt = Number.NEGATIVE_INFINITY;
978
+ this.degradeCount = 0;
979
+ this.durations = [];
980
+ this.options = options;
981
+ this.periodMs = 1e3 / options.cadenceHz;
982
+ }
983
+ start() {
984
+ if (this.running) return;
985
+ this.running = true;
986
+ const video = this.options.video;
987
+ if (typeof video?.requestVideoFrameCallback === "function") {
988
+ const loop = () => {
989
+ if (!this.running) return;
990
+ this.frameCallbackId = video.requestVideoFrameCallback?.(() => {
991
+ this.frameCallbackId = null;
992
+ if (this.now() - this.lastRunAt >= this.periodMs) this.tick();
993
+ loop();
994
+ });
995
+ };
996
+ loop();
997
+ return;
998
+ }
999
+ this.timer = setInterval(() => this.tick(), this.periodMs);
1000
+ }
1001
+ stop() {
1002
+ this.running = false;
1003
+ if (this.timer !== null) {
1004
+ clearInterval(this.timer);
1005
+ this.timer = null;
1006
+ }
1007
+ if (this.frameCallbackId !== null) {
1008
+ this.options.video?.cancelVideoFrameCallback?.(
1009
+ this.frameCallbackId
1010
+ );
1011
+ this.frameCallbackId = null;
1012
+ }
1013
+ }
1014
+ stats() {
1015
+ const meanDetectMs = this.durations.length === 0 ? 0 : this.durations.reduce((sum, value) => sum + value, 0) / this.durations.length;
1016
+ return { degradeCount: this.degradeCount, meanDetectMs };
1017
+ }
1018
+ now() {
1019
+ return this.options.now?.() ?? performance.now();
1020
+ }
1021
+ tick() {
1022
+ if (!this.running) return;
1023
+ if (this.busy) {
1024
+ this.degradeCount += 1;
1025
+ return;
1026
+ }
1027
+ this.busy = true;
1028
+ this.lastRunAt = this.now();
1029
+ const startedAt = this.now();
1030
+ this.options.run().catch(() => void 0).finally(() => {
1031
+ this.busy = false;
1032
+ this.durations.push(this.now() - startedAt);
1033
+ if (this.durations.length > STATS_WINDOW) this.durations.shift();
1034
+ });
1035
+ }
1036
+ };
1037
+
1038
+ // src/core/v3/detect-worker.ts
1039
+ var WORKER_PROTOCOL_VERSION = 1;
1040
+ function workerOffloadSupported() {
1041
+ return typeof OffscreenCanvas === "function" && typeof createImageBitmap === "function" && typeof Worker === "function";
1042
+ }
1043
+ function installWorkerDetectorHost(scope, deps = {}) {
1044
+ const create = deps.createDetector ?? createDetector;
1045
+ let detector = null;
1046
+ scope.onmessage = (event) => {
1047
+ const message = event.data;
1048
+ if (message.v !== WORKER_PROTOCOL_VERSION) {
1049
+ message.bitmap?.close?.();
1050
+ return;
1051
+ }
1052
+ if (message.type === "init") {
1053
+ void create(message.options).then((created) => {
1054
+ detector = created;
1055
+ const ready = {
1056
+ v: WORKER_PROTOCOL_VERSION,
1057
+ type: "ready",
1058
+ tier: created.tier,
1059
+ ...created.fallbackReason !== void 0 ? { fallbackReason: created.fallbackReason } : {}
1060
+ };
1061
+ scope.postMessage(ready);
1062
+ });
1063
+ return;
1064
+ }
1065
+ if (message.type === "detect") {
1066
+ const respond = (observation) => {
1067
+ const result = {
1068
+ v: WORKER_PROTOCOL_VERSION,
1069
+ type: "result",
1070
+ id: message.id,
1071
+ observation
1072
+ };
1073
+ scope.postMessage(result);
1074
+ message.bitmap.close?.();
1075
+ };
1076
+ if (detector === null) {
1077
+ respond(null);
1078
+ return;
1079
+ }
1080
+ void detector.detect(message.bitmap, message.streamWidth, message.streamHeight).then(respond, () => respond(null));
1081
+ }
1082
+ };
1083
+ }
1084
+ if (typeof self !== "undefined" && typeof self.importScripts === "function") {
1085
+ installWorkerDetectorHost(self);
1086
+ }
1087
+ var WorkerDetectorProxy = class _WorkerDetectorProxy {
1088
+ constructor(worker, ready) {
1089
+ this.pending = /* @__PURE__ */ new Map();
1090
+ this.nextId = 1;
1091
+ this.worker = worker;
1092
+ this.tier = ready.tier;
1093
+ if (ready.fallbackReason !== void 0) this.fallbackReason = ready.fallbackReason;
1094
+ worker.addEventListener("message", (event) => {
1095
+ const message = event.data;
1096
+ if (message.v !== WORKER_PROTOCOL_VERSION || message.type !== "result") return;
1097
+ const resolve = this.pending.get(message.id);
1098
+ this.pending.delete(message.id);
1099
+ resolve?.(message.observation);
1100
+ });
1101
+ }
1102
+ static create(worker, options, readyTimeoutMs = 1e4) {
1103
+ return new Promise((resolve, reject) => {
1104
+ const timer = setTimeout(() => {
1105
+ worker.removeEventListener("message", onReady);
1106
+ worker.terminate();
1107
+ reject(new Error(`worker detector not ready within ${readyTimeoutMs}ms`));
1108
+ }, readyTimeoutMs);
1109
+ const onReady = (event) => {
1110
+ const message = event.data;
1111
+ if (message.v !== WORKER_PROTOCOL_VERSION || message.type !== "ready") return;
1112
+ clearTimeout(timer);
1113
+ worker.removeEventListener("message", onReady);
1114
+ resolve(new _WorkerDetectorProxy(worker, message));
1115
+ };
1116
+ worker.addEventListener("message", onReady);
1117
+ const init = { v: WORKER_PROTOCOL_VERSION, type: "init", options };
1118
+ worker.postMessage(init);
1119
+ });
1120
+ }
1121
+ async detect(source, sourceWidth, sourceHeight) {
1122
+ let bitmap;
1123
+ try {
1124
+ if (typeof ImageBitmap !== "undefined" && source instanceof ImageBitmap) {
1125
+ bitmap = source;
1126
+ } else if (typeof createImageBitmap === "function") {
1127
+ bitmap = await createImageBitmap(source);
1128
+ } else {
1129
+ bitmap = source;
1130
+ }
1131
+ } catch {
1132
+ return null;
1133
+ }
1134
+ const id = this.nextId;
1135
+ this.nextId += 1;
1136
+ return new Promise((resolve) => {
1137
+ this.pending.set(id, resolve);
1138
+ const message = {
1139
+ v: WORKER_PROTOCOL_VERSION,
1140
+ type: "detect",
1141
+ id,
1142
+ bitmap,
1143
+ streamWidth: sourceWidth,
1144
+ streamHeight: sourceHeight
1145
+ };
1146
+ this.worker.postMessage(message, [bitmap]);
1147
+ });
1148
+ }
1149
+ destroy() {
1150
+ for (const resolve of this.pending.values()) resolve(null);
1151
+ this.pending.clear();
1152
+ this.worker.terminate();
1153
+ }
1154
+ };
1155
+
1156
+ // src/core/v3/capture-session-v3.ts
1157
+ var KEYFRAME_CANDIDATES = 4;
1158
+ var KEYFRAME_WINDOW_MS = 600;
1159
+ var NEUTRAL_QUALITY = { sharpness: 1, exposure: 1, meanLuma: 128 };
1160
+ var CaptureSessionV3 = class {
1161
+ constructor(options) {
1162
+ this.handlers = /* @__PURE__ */ new Map();
1163
+ this.stateValue = "idle";
1164
+ this.attempt = 0;
1165
+ this.stream = null;
1166
+ this.detector = null;
1167
+ this.scheduler = null;
1168
+ this.gate = null;
1169
+ this.profiler = null;
1170
+ this.lastGuidanceKey = null;
1171
+ this.positioningStartedAt = 0;
1172
+ this.fired = false;
1173
+ this.carriedDegrade = 0;
1174
+ this.carriedMeans = [];
1175
+ /** Reused downscale canvas — falls back to the raw video where canvas 2D
1176
+ * is unavailable (jsdom) so tests and exotic hosts keep detecting. */
1177
+ this.snapshotCanvas = null;
1178
+ this.options = options;
1179
+ this.facing = options.facingMode ?? "user";
1180
+ }
1181
+ get state() {
1182
+ return this.stateValue;
1183
+ }
1184
+ on(event, handler) {
1185
+ let set = this.handlers.get(event);
1186
+ if (!set) {
1187
+ set = /* @__PURE__ */ new Set();
1188
+ this.handlers.set(event, set);
1189
+ }
1190
+ set.add(handler);
1191
+ return () => set?.delete(handler);
1192
+ }
1193
+ emit(event, payload) {
1194
+ for (const handler of [...this.handlers.get(event) ?? []]) {
1195
+ handler(payload);
1196
+ }
1197
+ }
1198
+ async start() {
1199
+ this.attempt += 1;
1200
+ await this.run(this.attempt);
1201
+ }
1202
+ /** Full reset + camera restart — the documented recovery path (v1 parity). */
1203
+ retry() {
1204
+ this.teardownAttempt();
1205
+ void this.start();
1206
+ }
1207
+ switchCamera() {
1208
+ this.facing = this.facing === "user" ? "environment" : "user";
1209
+ this.teardownAttempt();
1210
+ void this.start();
1211
+ }
1212
+ destroy() {
1213
+ this.attempt += 1;
1214
+ this.teardownAttempt();
1215
+ this.detector?.destroy();
1216
+ this.detector = null;
1217
+ this.options.video.srcObject = null;
1218
+ }
1219
+ // ── attempt lifecycle ──────────────────────────────────────────────────────
1220
+ async run(attempt) {
1221
+ const { options } = this;
1222
+ this.fired = false;
1223
+ this.lastGuidanceKey = null;
1224
+ this.carriedDegrade = 0;
1225
+ this.carriedMeans = [];
1226
+ this.setState("preflight");
1227
+ const preflight = cameraPreflight();
1228
+ if (preflight !== "OK") {
1229
+ this.fail(preflight === "INSECURE_CONTEXT" ? "insecure" : "unsupported");
1230
+ return;
1231
+ }
1232
+ this.setState("acquiring");
1233
+ const getUserMedia = options.getUserMedia ?? ((constraints) => navigator.mediaDevices.getUserMedia(constraints));
1234
+ let stream;
1235
+ try {
1236
+ stream = await getUserMedia(buildCaptureConstraints(detectIsMobile(), this.facing));
1237
+ } catch (err) {
1238
+ if (attempt !== this.attempt) return;
1239
+ this.fail(mapGetUserMediaError(err));
1240
+ return;
1241
+ }
1242
+ if (attempt !== this.attempt) {
1243
+ for (const track of stream.getTracks()) track.stop();
1244
+ return;
1245
+ }
1246
+ this.stream = stream;
1247
+ options.video.srcObject = stream;
1248
+ await options.video.play().catch(() => void 0);
1249
+ if (attempt !== this.attempt) return;
1250
+ if (this.detector === null) {
1251
+ const ladderOptions = {
1252
+ ...options.v3AssetBaseUrl !== void 0 ? { v3AssetBaseUrl: options.v3AssetBaseUrl } : {}
1253
+ };
1254
+ const create = options.createDetector ?? (options.createWorker !== void 0 && workerOffloadSupported() ? async () => {
1255
+ try {
1256
+ return await WorkerDetectorProxy.create(
1257
+ options.createWorker(),
1258
+ ladderOptions
1259
+ );
1260
+ } catch {
1261
+ return createDetector(ladderOptions);
1262
+ }
1263
+ } : () => createDetector(ladderOptions));
1264
+ let created;
1265
+ try {
1266
+ created = await create();
1267
+ } catch (err) {
1268
+ if (attempt === this.attempt) {
1269
+ this.fail(
1270
+ "models",
1271
+ err instanceof DetectorLadderError ? err.fallbackReason : describeError2(err)
1272
+ );
1273
+ }
1274
+ return;
1275
+ }
1276
+ if (attempt !== this.attempt) {
1277
+ created.destroy();
1278
+ return;
1279
+ }
1280
+ this.detector = created;
1281
+ this.options.telemetry?.({
1282
+ type: "detector",
1283
+ tier: created.tier,
1284
+ ...created.fallbackReason !== void 0 ? { fallbackReason: created.fallbackReason } : {}
1285
+ });
1286
+ }
1287
+ const probe = probeDevice();
1288
+ const staticClass = options.deviceClass ?? classifyDevice(probe);
1289
+ this.profiler = new DeviceProfiler(staticClass);
1290
+ this.options.telemetry?.({
1291
+ type: "profile",
1292
+ staticClass,
1293
+ activeClass: this.profiler.deviceClass,
1294
+ simd: probe.simd
1295
+ });
1296
+ this.gate = new FaceGateV3(options.thresholds ?? {});
1297
+ this.setState("positioning");
1298
+ this.positioningStartedAt = this.now();
1299
+ this.startScheduler(attempt);
1300
+ }
1301
+ /** Chrome hint (Task 11): 'reduced' on LOW even without the media query. */
1302
+ get animations() {
1303
+ return this.profiler?.profile.animations ?? "full";
1304
+ }
1305
+ startScheduler(attempt) {
1306
+ const profiler = this.profiler;
1307
+ if (profiler === null) return;
1308
+ if (this.scheduler !== null) {
1309
+ const stats = this.scheduler.stats();
1310
+ this.carriedDegrade += stats.degradeCount;
1311
+ if (stats.meanDetectMs > 0) this.carriedMeans.push(stats.meanDetectMs);
1312
+ this.scheduler.stop();
1313
+ }
1314
+ const scheduler = new DetectScheduler({
1315
+ cadenceHz: profiler.profile.cadenceHz,
1316
+ video: this.options.video,
1317
+ ...this.options.now !== void 0 ? { now: this.options.now } : {},
1318
+ run: () => this.detectTick(attempt)
1319
+ });
1320
+ this.scheduler = scheduler;
1321
+ scheduler.start();
1322
+ }
1323
+ async detectTick(attempt) {
1324
+ const { detector, gate, profiler } = this;
1325
+ const video = this.options.video;
1326
+ if (attempt !== this.attempt || detector === null || gate === null || profiler === null)
1327
+ return;
1328
+ if (this.fired || video.videoWidth === 0) return;
1329
+ const before = profiler.deviceClass;
1330
+ const t0 = this.now();
1331
+ const source = this.options.makeSnapshot?.(video, profiler.profile.inputWidth) ?? this.defaultSnapshot(video, profiler.profile.inputWidth);
1332
+ let observation = null;
1333
+ try {
1334
+ observation = await detector.detect(source, video.videoWidth, video.videoHeight);
1335
+ } catch {
1336
+ observation = null;
1337
+ }
1338
+ if (attempt !== this.attempt || this.fired) return;
1339
+ profiler.record(this.now() - t0);
1340
+ if (profiler.deviceClass !== before) this.startScheduler(attempt);
1341
+ const quality = observation === null ? NEUTRAL_QUALITY : this.options.measureQuality?.(video, observation.box) ?? this.defaultQuality(video, observation.box);
1342
+ const tick = gate.tick({
1343
+ timestampMs: this.now(),
1344
+ observation,
1345
+ quality,
1346
+ frameWidth: video.videoWidth,
1347
+ frameHeight: video.videoHeight
1348
+ });
1349
+ this.emit("checks", {
1350
+ engine: "v3",
1351
+ progress: tick.p,
1352
+ q: tick.q,
1353
+ factors: tick.factors,
1354
+ attempt
1355
+ });
1356
+ if (tick.guidanceKey !== this.lastGuidanceKey) {
1357
+ this.lastGuidanceKey = tick.guidanceKey;
1358
+ this.emit("guidance", { key: tick.guidanceKey });
1359
+ }
1360
+ if (tick.ready && this.stateValue === "positioning") {
1361
+ this.fired = true;
1362
+ void this.fire(attempt);
1363
+ }
1364
+ }
1365
+ async fire(attempt) {
1366
+ const { options } = this;
1367
+ const scheduler = this.scheduler;
1368
+ scheduler?.stop();
1369
+ const stats = scheduler?.stats() ?? { degradeCount: 0, meanDetectMs: 0 };
1370
+ const means = [...this.carriedMeans, ...stats.meanDetectMs > 0 ? [stats.meanDetectMs] : []];
1371
+ options.telemetry?.({
1372
+ type: "fired",
1373
+ timeToGateMs: this.now() - this.positioningStartedAt,
1374
+ degradeCount: this.carriedDegrade + stats.degradeCount,
1375
+ meanDetectMs: means.length === 0 ? 0 : means.reduce((sum, value) => sum + value, 0) / means.length
1376
+ });
1377
+ const mode = options.mode ?? "clip";
1378
+ const bestOf = this.collectKeyframes(attempt);
1379
+ if (mode === "photo") {
1380
+ const best2 = await bestOf;
1381
+ if (attempt !== this.attempt) return;
1382
+ if (best2 === null) {
1383
+ this.fail("generic");
1384
+ return;
1385
+ }
1386
+ this.finishCapture({ keyframe: best2.blob, previewDataUrl: best2.previewDataUrl });
1387
+ return;
1388
+ }
1389
+ this.setState("recording");
1390
+ const recorder = options.createRecorder?.() ?? new ClipRecorder();
1391
+ const stream = this.stream;
1392
+ if (stream === null) {
1393
+ this.fail("generic");
1394
+ return;
1395
+ }
1396
+ let frozenBest = null;
1397
+ void bestOf.then(
1398
+ (candidate) => {
1399
+ frozenBest = candidate;
1400
+ },
1401
+ () => {
1402
+ }
1403
+ );
1404
+ const onRecordingStopped = () => {
1405
+ if (attempt !== this.attempt) return;
1406
+ if (frozenBest !== null) {
1407
+ this.emit("frozen", { previewDataUrl: frozenBest.previewDataUrl });
1408
+ }
1409
+ };
1410
+ let clip;
1411
+ let best;
1412
+ try {
1413
+ [clip, best] = await Promise.all([recorder.record(stream, onRecordingStopped), bestOf]);
1414
+ } catch (err) {
1415
+ if (attempt !== this.attempt) return;
1416
+ const kind = err.kind;
1417
+ this.fail(kind === "cliptoolarge" ? "cliptoolarge" : "recorder");
1418
+ return;
1419
+ }
1420
+ if (attempt !== this.attempt) return;
1421
+ if (isClipTooLarge(clip.blob)) {
1422
+ this.fail("cliptoolarge");
1423
+ return;
1424
+ }
1425
+ if (best === null) {
1426
+ this.fail("generic");
1427
+ return;
1428
+ }
1429
+ this.finishCapture({
1430
+ clip: clip.blob,
1431
+ clipMimeType: clip.mimeType,
1432
+ keyframe: best.blob,
1433
+ previewDataUrl: best.previewDataUrl
1434
+ });
1435
+ }
1436
+ /** Up to KEYFRAME_CANDIDATES mirrored frames over KEYFRAME_WINDOW_MS —
1437
+ * sharpest wins (reuses frame-quality.sharpness via the capture seam). */
1438
+ async collectKeyframes(attempt) {
1439
+ const capture = this.options.captureKeyframe ?? ((video) => this.defaultKeyframe(video));
1440
+ const stepMs = KEYFRAME_WINDOW_MS / (KEYFRAME_CANDIDATES - 1);
1441
+ let best = null;
1442
+ for (let i = 0; i < KEYFRAME_CANDIDATES; i += 1) {
1443
+ if (attempt !== this.attempt) return best;
1444
+ try {
1445
+ const candidate = await capture(this.options.video);
1446
+ if (best === null || candidate.sharpness > best.sharpness) best = candidate;
1447
+ } catch {
1448
+ }
1449
+ if (i < KEYFRAME_CANDIDATES - 1) await delay(stepMs);
1450
+ }
1451
+ return best;
1452
+ }
1453
+ finishCapture(artifacts) {
1454
+ this.stopTracks();
1455
+ this.setState("captured");
1456
+ this.emit("artifacts", artifacts);
1457
+ }
1458
+ // ── defaults for the canvas-bound seams ────────────────────────────────────
1459
+ async defaultKeyframe(video) {
1460
+ const canvas = document.createElement("canvas");
1461
+ const blob = await captureMirroredKeyframe(video, canvas);
1462
+ const previewDataUrl = canvas.toDataURL("image/jpeg", 0.92);
1463
+ return { blob, previewDataUrl, sharpness: this.centerSharpness(video) };
1464
+ }
1465
+ defaultSnapshot(video, targetWidth) {
1466
+ try {
1467
+ const canvas = this.snapshotCanvas ?? document.createElement("canvas");
1468
+ const scale = targetWidth / Math.max(1, video.videoWidth);
1469
+ const width = Math.max(1, Math.round(video.videoWidth * scale));
1470
+ const height = Math.max(1, Math.round(video.videoHeight * scale));
1471
+ const ctx = canvas.getContext("2d");
1472
+ if (ctx === null) return video;
1473
+ if (canvas.width !== width) canvas.width = width;
1474
+ if (canvas.height !== height) canvas.height = height;
1475
+ ctx.drawImage(video, 0, 0, width, height);
1476
+ this.snapshotCanvas = canvas;
1477
+ return canvas;
1478
+ } catch {
1479
+ return video;
1480
+ }
1481
+ }
1482
+ defaultQuality(video, box) {
1483
+ const crop = cropImageData(video, box, 96);
1484
+ if (crop === null) return NEUTRAL_QUALITY;
1485
+ return { sharpness: sharpness(crop), exposure: exposure(crop), meanLuma: meanLuma(crop) };
1486
+ }
1487
+ centerSharpness(video) {
1488
+ const size = intrinsicSize(video);
1489
+ const crop = cropImageData(
1490
+ video,
1491
+ { x: size.width * 0.25, y: size.height * 0.25, width: size.width * 0.5, height: size.height * 0.5 },
1492
+ 96
1493
+ );
1494
+ return crop === null ? 0 : sharpness(crop);
1495
+ }
1496
+ // ── teardown ──────────────────────────────────────────────────────────────
1497
+ teardownAttempt() {
1498
+ this.scheduler?.stop();
1499
+ this.scheduler = null;
1500
+ this.gate = null;
1501
+ this.stopTracks();
1502
+ }
1503
+ stopTracks() {
1504
+ if (this.stream === null) return;
1505
+ for (const track of this.stream.getTracks()) track.stop();
1506
+ this.stream = null;
1507
+ }
1508
+ fail(kind, fallbackReason) {
1509
+ this.scheduler?.stop();
1510
+ this.stopTracks();
1511
+ this.setState("error");
1512
+ this.options.telemetry?.({
1513
+ type: "error",
1514
+ kind,
1515
+ ...fallbackReason !== void 0 ? { fallbackReason } : {}
1516
+ });
1517
+ this.emit("error", { kind, retryable: kind !== "insecure" && kind !== "unsupported" });
1518
+ }
1519
+ setState(state) {
1520
+ this.stateValue = state;
1521
+ this.emit("statechange", { state });
1522
+ }
1523
+ now() {
1524
+ return this.options.now?.() ?? performance.now();
1525
+ }
1526
+ };
1527
+ function delay(ms) {
1528
+ return new Promise((resolve) => setTimeout(resolve, ms));
1529
+ }
1530
+ function describeError2(err) {
1531
+ return err instanceof Error ? err.message : String(err);
1532
+ }
1533
+ function cropImageData(video, box, targetWidth) {
1534
+ try {
1535
+ const canvas = document.createElement("canvas");
1536
+ const scale = targetWidth / Math.max(1, box.width);
1537
+ canvas.width = Math.max(1, Math.round(box.width * scale));
1538
+ canvas.height = Math.max(1, Math.round(box.height * scale));
1539
+ const ctx = canvas.getContext("2d");
1540
+ if (ctx === null) return null;
1541
+ ctx.drawImage(
1542
+ video,
1543
+ box.x,
1544
+ box.y,
1545
+ box.width,
1546
+ box.height,
1547
+ 0,
1548
+ 0,
1549
+ canvas.width,
1550
+ canvas.height
1551
+ );
1552
+ return ctx.getImageData(0, 0, canvas.width, canvas.height);
1553
+ } catch {
1554
+ return null;
1555
+ }
1556
+ }
1557
+ // Annotate the CommonJS export names for ESM import in node:
1558
+ 0 && (module.exports = {
1559
+ CENTERED_FACTOR,
1560
+ CIRCLE_RADIUS_FACTOR,
1561
+ CLIP_MS,
1562
+ CaptureSessionV3,
1563
+ ClipError,
1564
+ ClipRecorder,
1565
+ DEFAULT_CLIP_MIME,
1566
+ DEFAULT_TIER_ORDER,
1567
+ DEFAULT_V3_ASSET_BASE_URL,
1568
+ DEVICE_PROFILES,
1569
+ DetectScheduler,
1570
+ DetectorLadderError,
1571
+ DeviceProfiler,
1572
+ EXPOSURE_BAND,
1573
+ FaceGateV3,
1574
+ IN_CIRCLE_FACTOR,
1575
+ KEYFRAME_CANDIDATES,
1576
+ KEYFRAME_WINDOW_MS,
1577
+ MAX_CLIP_BYTES,
1578
+ MIME_CANDIDATES,
1579
+ SHARP_REF,
1580
+ STOP_GRACE_MS,
1581
+ TIMESLICE_MS,
1582
+ V3_GATE_DEFAULTS,
1583
+ VIDEO_BPS,
1584
+ buildCaptureConstraints,
1585
+ buildLivenessV2FormData,
1586
+ cameraPreflight,
1587
+ captureMirroredKeyframe,
1588
+ classifyDevice,
1589
+ createDetector,
1590
+ detectIsMobile,
1591
+ errorCopy,
1592
+ exposure,
1593
+ extForMime,
1594
+ intrinsicSize,
1595
+ isClipTooLarge,
1596
+ isMediaRecorderSupported,
1597
+ mapGetUserMediaError,
1598
+ meanLuma,
1599
+ pickMimeType,
1600
+ probeDevice,
1601
+ sharpness,
1602
+ toStreamPixels,
1603
+ uiCopy
1604
+ });
1605
+ //# sourceMappingURL=index.cjs.map