import { ThemeColors } from "./theme"; import { BackSideMode } from "../utils/documentRules"; /** * Document capture UI — camera-based or file-upload for ID documents. * * Supports: * - Camera capture (rear camera preferred on mobile) * - File upload fallback * - Preview with retake/confirm * - Front and back document capture for documents requiring both sides */ export interface DocumentCaptureResult { front: Blob; back?: Blob; viaCamera: boolean; } export declare class DocumentCapture { private root; private videoEl; private videoWrapEl; private cameraManager; private orientationHandler; private resolveCapture; private rejectCapture; private frontViaCamera; private frontBlob; private backBlob; private currentSide; private requiresBackOverride; /** * Mount the document capture UI and return a promise that resolves * with the captured document image(s). */ capture(container: HTMLElement, theme: ThemeColors, documentType: string, requiresBack?: BackSideMode): Promise; destroy(): void; private getBackSideMode; /** Whether a back-side step should be shown at all (required OR optional). */ private shouldCaptureBackSide; /** Whether the back-side step, once shown, can be skipped by the user. */ private isBackSideOptional; private renderChoiceScreen; /** Returns the icon name matching the document type. */ private _docIcon; private renderCameraView; /** * Matches the video box's aspect-ratio CSS to the stream's actual * negotiated dimensions instead of a single hardcoded ratio — a stream * that's natively 16:9 no longer gets force-cropped into a 4:3 box. * Clamped to a sane document-shaped range so a degenerate/unusual stream * can't produce a sliver-thin or absurdly tall box. */ private _fitToStream; /** * Re-fits the video box when the device rotates mid-capture. Does not * re-request getUserMedia (disruptive/slow) — the stream's dimensions * don't change on rotation, only the viewport does, so re-reading the * already-known videoWidth/videoHeight is enough to keep the box sane. */ private _watchOrientation; private _unwatchOrientation; private openCamera; private captureFrame; private showPreview; /** * Runs the shared client-side quality heuristic (blur/glare/contrast/ * brightness — see utils/ImageQuality.ts) against the just-captured photo * and, if it scores poorly, shows a plain-language nudge on the preview * screen. Fails silently on decode error — this is an advisory extra, not * a required step, so a browser that can't run it must not block capture. */ private _checkPhotoQuality; /** Decodes to a canvas, optionally downscaled to maxDim on the long edge (never upscales). */ private _blobToCanvas; /** * Rotate an image blob by a multiple of 90° and re-encode it — used by the * preview screen's rotate control for a document photographed or uploaded * sideways/upside-down. EXIF auto-rotation (see compressImage) only fixes * phone photos that embed correct orientation metadata; it can't help a * document whose actual pixel content is sideways (e.g. the phone itself * was held rotated relative to the document, or a pre-cropped/scanned * upload with no EXIF at all) — that needs the user to say so directly. */ private _rotateImage; private handleCaptureComplete; private handleFileUploadComplete; private validateFile; /** * Only shrinks/re-encodes when the file exceeds the backend's real upload * ceiling — otherwise returns the original bytes completely untouched. * Document photos become the face-comparison reference image later * (see backend _crop_and_save_face), so any avoidable re-encode is a * quality loss with no upside; compression here exists solely to keep * oversized captures under MAX_DOCUMENT_BYTES, not to "optimize" images * that already fit. */ private ensureUnderUploadLimit; private handleFileUpload; private stopCamera; private showLoadingState; private showError; private createButton; private compressImage; /** * Read JPEG EXIF orientation tag (1–8) from a Blob/File. * Returns 1 (no rotation) if EXIF is absent or unreadable. */ private _readExifOrientation; private getDocumentLabel; } //# sourceMappingURL=DocumentCapture.d.ts.map