import { a as MLProviderConfig, i as IMLProviderCapability, o as IncodeCanvas } from "./IStorageCapability-ORkQfK3F.js"; //#region ../infra/src/wasm/apiUtilities.d.ts /** * Shared WASM module loader. * * The pinned `webLib.wasm` (see `wasmDefaults.ts`) bundles BOTH the ML pipeline * APIs (used by `mlWasmJSApi.ts`) AND a C++ `WebClient` HTTP client (used by * `wasmWebClient.ts`). Both consumers must share a single instantiated * `wasmModule` — calling the glue `Module()` factory twice would re-instantiate * the WASM heap and produce divergent state. * * This module memoizes the load: the first caller (whichever arrives first — * ML init or HTTP init) triggers the fetch + glue load, and subsequent callers * await the same promise. Idempotent on success; on failure, the singleton is * cleared so the next caller retries. * * SIMD fallback mirrors the legacy behavior: try the SIMD binary + SIMD glue * (`webLibSimd.js` + `webLibSimd.wasm`) first, fall back to the non-SIMD pair * (`webLib.js` + `webLib.wasm`) on instantiation failure. Each binary MUST be * paired with its matching glue — the CDN ships them as paired artifacts and * mixing them produces an unusable module. */ declare global { interface Window { Module?: WasmGlueFactory; wasmArrayBuffer: Uint8Array | null; } } /** Opaque handle for the loaded WASM module instance. */ type WasmModule = Record; type WasmGlueFactory = () => Promise; //#endregion //#region ../infra/src/wasm/mlWasmBridgeTypes.d.ts /** * Decoded PDF417 barcode surfaced from the WASM ID-capture pipeline during * US Smart Capture. Mirrors SDK 1's `Pdf417DecodeResult`. */ type Pdf417DecodeResult = { text: string; ecLevel: string; rowNumber: number; columnNumber: number; codewordLengthInPixelsMin: number; codewordLengthInPixelsMax: number; correctedErrorsCount: number; }; //#endregion //#region ../infra/src/capabilities/IIdCaptureCapability.d.ts /** * Configuration for ID capture provider. * Extends base ML provider config with ID-capture specific options. */ interface IdCaptureConfig extends MLProviderConfig { /** * Load the video-selfie ID workflow (`IdVideoSelfiePipeline`, the simplified * ID-capture pipeline without a capturing-manager timer, used by the * video-selfie flow) instead of the default blur/glare ID pipeline. */ videoSelfie?: boolean; } interface IdCaptureThresholds { blurThreshold: number; blurChangeThreshold: number; glareThreshold: number; clsThreshold: number; sideThreshold: number; iouThreshold: number; idDetectedTimeout: number; autocaptureTimeout: number; framesAggregationInterval: number; } interface IdCaptureGeometry { areaDown: number; areaUp: number; areaIOSPassportUp: number; areaIOSPassportDown: number; widthIOSUp: number; widthIOSDown: number; widthDown: number; widthUp: number; windowOuterWidth: number; windowOuterHeight: number; windowInnerWidth: number; windowInnerHeight: number; } interface IdCaptureSettings { isFixedMask: boolean; isIPhone14OrHigher: boolean; idType: string; blurCheckEnabled: boolean; glareCheckEnabled: boolean; faceQualityCheckEnabled: boolean; iouCheckEnabled: boolean; fpsLimitEnabled: boolean; } type IdCaptureModelType = 'v1' | 'v2' | 'v3'; type DetectionOrientation = 'horizontal' | 'vertical'; interface IdCaptureCallbacks { onFarAway?: () => void; onDetectionStarted?: () => void; onMaskChange?: (show: boolean, mask: boolean, top: number, orientation: DetectionOrientation) => void; onBlur?: () => void; onGlare?: () => void; onCapturing?: () => void; onCapture?: () => void; onBestFrame?: (blur: number, glare: number, orientation: string) => void; onIdNotDetected?: () => void; onSwitchToManualCapture?: () => void; onIdTypeChange?: (idType: string) => void; onIdSideChange?: (side: string) => void; onCapturingCounterValueChange?: (value: number) => void; /** * Fires when the WASM pipeline decodes a PDF417 barcode from the back of the * ID during US Smart Capture. Only fires when barcode capture is enabled via * `setBarcodeCaptureEnabled(true)`. */ onBarcodeDecoded?: (decoded: Pdf417DecodeResult) => void; } /** * WASM array type for quad coordinates. * Use .get(index) instead of [index] to access elements. */ interface QuadArray { get(index: number): { x: number; y: number; }; size?(): number; length?: number; } interface IdCaptureProcessResult { cls: number; blur: number; glare: number; quad: QuadArray; barQuad: QuadArray; side: string; size: number; idType: string; networkInferenceTime: number; } /** * Capability interface for ID document capture. * Extends the base ML provider capability with ID-capture specific methods. */ interface IIdCaptureCapability extends IMLProviderCapability { /** * Sets callbacks for ID capture events. * @param callbacks - Object containing callback functions for various capture events */ setCallbacks(callbacks: IdCaptureCallbacks): void; /** * Sets detection thresholds for quality checks. * @param thresholds - Threshold values for blur, glare, and other quality metrics */ setThresholds(thresholds: IdCaptureThresholds): void; /** * Sets geometry constraints for ID detection. * @param geometry - Geometry parameters for ID positioning */ setGeometry(geometry: IdCaptureGeometry): void; /** * Sets capture settings. * @param settings - Configuration for capture behavior */ setSettings(settings: IdCaptureSettings): void; /** * Sets the ML model type to use for ID detection. * @param modelType - Model version ('v1', 'v2', or 'v3') */ setModelType(modelType: IdCaptureModelType): void; /** * Gets the last process result from the most recent frame processing. * Returns null if no frame has been processed yet. * @returns The last process result with quad coordinates, or null if not available */ getLastProcessResult(): IdCaptureProcessResult | null; /** * Transforms the canvas using perspective correction based on frame coordinates. * @param canvas - The canvas to transform * @param frameRect - Frame rectangle in canvas coordinates (x, y, w, h) * @returns The transformed canvas */ transformPerspective(canvas: IncodeCanvas, frameRect: { x: number; y: number; w: number; h: number; }): IncodeCanvas; /** * Gets the captured canvas (transformed for preview). * @returns The captured canvas, or null if not available */ getCapturedCanvas(): IncodeCanvas | null; /** * Gets the original captured canvas (full frame for upload). * @returns The original captured canvas, or null if not available */ getOriginalCapturedCanvas(): IncodeCanvas | null; /** * Sets the captured canvases (original and transformed). * Called by the state machine after capture and transformation. * @param original - The original full-frame canvas (for upload) * @param transformed - The transformed canvas (for preview) */ setCapturedCanvases(original: IncodeCanvas, transformed: IncodeCanvas): void; /** * Resets WASM detection state while preserving the captured canvases. * Use `reset()` when starting a new capture attempt and the captured result * must also be discarded. */ resetDetectionState(): void; /** * Enables/disables on-device PDF417 barcode capture on the detection loop. * Used by US Smart Capture (enabled only on the back side). */ setBarcodeCaptureEnabled(enabled: boolean): void; /** * When true, the WASM pipeline auto-captures the frame on barcode decode. The * Flow keeps this false so the JS layer owns the submit decision. */ setBarcodeAutoCaptureOnDecode(enabled: boolean): void; /** * Lazily loads the PDF417 enhancement model, resolved from the active WASM * config's models base path (so self-hosted deployments resolve it too). * Resolves to whether the model was applied — best-effort; decode still works * without it. Loaded at most once per provider instance. */ setBarcodeEnhancementModel(): Promise; /** * The most recently decoded PDF417 barcode, or null if none decoded since the * last reset. Complements the `onBarcodeDecoded` callback. */ getLastDecodedBarcode(): Pdf417DecodeResult | null; } //#endregion export { Pdf417DecodeResult as i, IIdCaptureCapability as n, IdCaptureSettings as r, DetectionOrientation as t };