@yenio-pld/blocks 1.2.0-rc.32 → 1.2.0-rc.33
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.
- package/dist/kyc.cjs +1580 -0
- package/dist/kyc.cjs.map +1 -0
- package/dist/kyc.d.cts +334 -0
- package/dist/kyc.d.ts +334 -0
- package/dist/kyc.js +1520 -0
- package/dist/kyc.js.map +1 -0
- package/dist/ui/button.d.ts +2 -2
- package/package.json +11 -1
package/dist/kyc.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/kyc/kyc-capture.ts","../src/components/kyc/bytes.ts","../src/components/kyc/capture-cues.ts","../src/components/kyc/capture-stage.tsx","../src/lib/utils.ts","../src/components/ProductIllustration.tsx","../src/components/kyc/id-capture.tsx"],"names":["jsx","useId","useRef","useEffect","Drawer","DrawerTrigger","Button","DrawerContent","jsxs","DrawerHeader","DrawerTitle","DrawerDescription","DrawerFooter","DrawerClose","VolumeX","Volume2","Check","twMerge","clsx","useState","useCallback","toast","Progress"],"mappings":";;;;;;;;;;;;;AAEO,IAAM,kBAAA,GAAqB;AAC3B,IAAM,YAAA,GAAe;AACrB,IAAM,iBAAA,GAAoB;AAC1B,IAAM,kBAAA,GAAqB;AAE3B,IAAM,iBAAA,GAAoB;AAE1B,IAAM,WAAA,GAAc;AACpB,IAAM,WAAA,GAAc;AAEpB,IAAM,SAAA,GAAY;AAElB,IAAM,aAAA,GAAgB;AACtB,IAAM,oBAAA,GAAuB;AAK7B,IAAM,iBAAA,GAAoB;AAC1B,IAAM,iBAAA,GAAoB;AAE1B,IAAM,oBAAA,GAAuB;AAM7B,IAAM,sBAAA,GAAyB;AAU/B,IAAM,iBAAA,GAAoB;AAE1B,IAAM,mBAAA,GAAsB;AAC5B,IAAM,oBAAA,GAAuB;AAC7B,IAAM,eAAA,GAAkB;AAExB,IAAM,yBAAA,GAA4B;AAClC,IAAM,sBAAA,GAAyB;A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AAAA,YAAA;AAAA,cACA,MAAA,EAAO,SAAA;AAAA,cACP,OAAA,EAAQ,aAAA;AAAA,cACR,SAAA,EAAU,SAAA;AAAA,cACV,QAAA,EAAU,IAAA;AAAA,cACV,EAAA,EAAI,YAAY,IAAI,CAAA,CAAA;AAAA,cACpB,QAAA,EAAU,MAAM,KAAK,YAAA,EAAa;AAAA,cAClC,GAAA,EAAK,OAAA;AAAA,cACL,QAAA,EAAU,EAAA;AAAA,cACV,IAAA,EAAK;AAAA;AAAA,WACN;AAAA,0BACAA,cAAAA;AAAA,YAACM,gBAAAA;AAAA,YAAA;AAAA,cACA,SAAA,EAAU,iBAAA;AAAA,cACV,QAAA,EAAU,IAAA;AAAA,cACV,OAAA,EAAS,MAAM,OAAA,CAAQ,OAAA,EAAS,KAAA,EAAM;AAAA,cACtC,IAAA,EAAK,QAAA;AAAA,cACL,OAAA,EAAQ,MAAA;AAAA,cAEP,QAAA,EAAA,YAAA,GAAe,MAAA,CAAO,YAAA,GAAe,MAAA,CAAO;AAAA;AAAA;AAC9C;AAAA;AAAA,KACD,GACG;AAAA,GAAA,EACL,CAAA;AAEF;AAGO,IAAM,YAAA,GAAe","file":"kyc.cjs","sourcesContent":["/** Client-side ID image prep for §25.8.1 portal capture. */\n\nexport const KYC_IMAGE_MAX_SIDE = 1600;\nexport const KYC_BLUR_MIN = 80;\nexport const KYC_DARK_MAX_MEAN = 40;\nexport const GUIDE_SAMPLE_WIDTH = 320;\n/** Extra crop around the guide (fraction of guide size) so edges just outside it still count. */\nexport const GUIDE_EDGE_MARGIN = 0.15;\n/** Edge search band half-width as a fraction of the guide width / height. */\nexport const EDGE_BAND_X = 0.08;\nexport const EDGE_BAND_Y = 0.1;\n/** Middle fraction of each side scanned (skips rounded corners and the INE notch). */\nexport const EDGE_SPAN = 0.6;\n/** Each side is split into short segments (tolerates ~3.5° tilt and a thumb on the edge). */\nexport const EDGE_SEGMENTS = 3;\nexport const EDGE_SEGMENTS_NEEDED = 2;\n/**\n * Calibrated on real + demo INE (front/back) over black, white paper, gray, wood and\n * gradient backgrounds vs. empty scenes, product photos and high-contrast texture.\n */\nexport const EDGE_MIN_STRENGTH = 50;\nexport const EDGE_MIN_CONTRAST = 4;\n/** Blur / darkness use the card interior only, away from the background at the edges. */\nexport const GUIDE_INTERIOR_INSET = 0.12;\n/**\n * Live sharpness samples the card interior with the guide at ≤ 800 px (native, never\n * upscaled). At 320 px a Gaussian σ = 2 px defocus on a 1080×1440 frame still scored up\n * to ~1050, so blurry IDs passed.\n */\nexport const SHARPNESS_SAMPLE_WIDTH = 800;\n/**\n * {@link assessSharpness} floor at {@link SHARPNESS_SAMPLE_WIDTH}. Only rejects clearly\n * defocused frames; {@link AutoCaptureController} focus-settle does the rest. Calibrated on\n * real + demo INE with the card at 518–776 px, iPhone-like ISP smoothing (Gaussian σ 0.8 /\n * bilateral / median), noise σ 2–5, contrast ×0.6 and JPEG q60–70: sharp video scores ≥ 27\n * on fronts, Gaussian defocus σ 2 px ≤ 13 on fronts and ≤ 18 on the real back. The old floor\n * of 120 rejected most real sharp video. Content-dependent: a dense synthetic QR back reaches\n * ~57 at σ 2 px.\n */\nexport const KYC_SHARPNESS_MIN = 20;\n/** Focus has settled when the last few aligned samples are all within this fraction of the best. */\nexport const FOCUS_PLATEAU_RATIO = 0.8;\nexport const FOCUS_SETTLE_SAMPLES = 3;\nexport const FOCUS_WINDOW_MS = 1200;\n/** Auto-capture saves the sharpest ready frame no older than this. */\nexport const SHARPEST_FRAME_MAX_AGE_MS = 500;\nexport const AUTO_CAPTURE_SAMPLE_HZ = 8;\nexport const AUTO_CAPTURE_READY_COUNT = 4;\n\nexport type ImageQuality = {\n\tblurScore: number;\n\tmeanLuma: number;\n\ttooBlurry: boolean;\n\ttooDark: boolean;\n};\n\nexport type GuideQuality = ImageQuality & {\n\t/** Card edges (0–4) found on the guide sides. */\n\tedgesFound: number;\n\taligned: boolean;\n\tready: boolean;\n};\n\n/** Normalized guide rect in video pixel space (not CSS). */\nexport type GuideRect = {\n\tx: number;\n\ty: number;\n\twidth: number;\n\theight: number;\n};\n\n/** Laplacian variance + mean luma on an 8-bit grayscale buffer (row-major). */\nexport function assessGrayPixels(\n\tgray: ArrayLike<number>,\n\twidth: number,\n\theight: number,\n\tblurMin: number = KYC_BLUR_MIN,\n): ImageQuality {\n\tif (width < 3 || height < 3 || gray.length < width * height) {\n\t\treturn { blurScore: 0, meanLuma: 0, tooBlurry: true, tooDark: true };\n\t}\n\tlet sum = 0;\n\tfor (let i = 0; i < width * height; i += 1) sum += gray[i] ?? 0;\n\tconst meanLuma = sum / (width * height);\n\n\tlet lapSum = 0;\n\tlet lapSq = 0;\n\tlet count = 0;\n\tfor (let y = 1; y < height - 1; y += 1) {\n\t\tfor (let x = 1; x < width - 1; x += 1) {\n\t\t\tconst i = y * width + x;\n\t\t\tconst value =\n\t\t\t\t-(gray[i - width] ?? 0) -\n\t\t\t\t(gray[i - 1] ?? 0) +\n\t\t\t\t4 * (gray[i] ?? 0) -\n\t\t\t\t(gray[i + 1] ?? 0) -\n\t\t\t\t(gray[i + width] ?? 0);\n\t\t\tlapSum += value;\n\t\t\tlapSq += value * value;\n\t\t\tcount += 1;\n\t\t}\n\t}\n\tconst mean = count === 0 ? 0 : lapSum / count;\n\tconst blurScore = count === 0 ? 0 : lapSq / count - mean * mean;\n\treturn {\n\t\tblurScore,\n\t\tmeanLuma,\n\t\ttooBlurry: blurScore < blurMin,\n\t\ttooDark: meanLuma < KYC_DARK_MAX_MEAN,\n\t};\n}\n\nexport function rgbaToGray(\n\trgba: ArrayLike<number>,\n\tpixelCount: number,\n): Float64Array {\n\tconst gray = new Float64Array(pixelCount);\n\tfor (let i = 0; i < pixelCount; i += 1) {\n\t\tconst o = i * 4;\n\t\tgray[i] =\n\t\t\t0.299 * (rgba[o] ?? 0) +\n\t\t\t0.587 * (rgba[o + 1] ?? 0) +\n\t\t\t0.114 * (rgba[o + 2] ?? 0);\n\t}\n\treturn gray;\n}\n\nexport function assessImageData(image: {\n\tdata: ArrayLike<number>;\n\twidth: number;\n\theight: number;\n}): ImageQuality {\n\treturn assessGrayPixels(\n\t\trgbaToGray(image.data, image.width * image.height),\n\t\timage.width,\n\t\timage.height,\n\t);\n}\n\n/**\n * Projection of the *signed* Sobel response across a band, averaged along one\n * segment of a guide side. A straight card edge is a same-sign step along its\n * length and adds up; text, QR codes and table texture cancel out.\n */\nfunction segmentHasEdge(\n\tgray: ArrayLike<number>,\n\twidth: number,\n\tvertical: boolean,\n\ta0: number,\n\ta1: number,\n\ts0: number,\n\ts1: number,\n): boolean {\n\tconst at = (x: number, y: number) => gray[y * width + x] ?? 0;\n\tconst profile: number[] = [];\n\tfor (let a = a0; a <= a1; a += 1) {\n\t\tlet sum = 0;\n\t\tfor (let s = s0; s <= s1; s += 1) {\n\t\t\tconst x = vertical ? a : s;\n\t\t\tconst y = vertical ? s : a;\n\t\t\tsum += vertical\n\t\t\t\t? at(x + 1, y - 1) +\n\t\t\t\t\t2 * at(x + 1, y) +\n\t\t\t\t\tat(x + 1, y + 1) -\n\t\t\t\t\tat(x - 1, y - 1) -\n\t\t\t\t\t2 * at(x - 1, y) -\n\t\t\t\t\tat(x - 1, y + 1)\n\t\t\t\t: at(x - 1, y + 1) +\n\t\t\t\t\t2 * at(x, y + 1) +\n\t\t\t\t\tat(x + 1, y + 1) -\n\t\t\t\t\tat(x - 1, y - 1) -\n\t\t\t\t\t2 * at(x, y - 1) -\n\t\t\t\t\tat(x + 1, y - 1);\n\t\t}\n\t\tprofile.push(Math.abs(sum / (s1 - s0 + 1)));\n\t}\n\tlet peak = 0;\n\tfor (let i = 0; i < profile.length; i += 1) {\n\t\tconst here = profile[i] ?? 0;\n\t\tpeak = Math.max(\n\t\t\tpeak,\n\t\t\t((profile[i - 1] ?? here) + here + (profile[i + 1] ?? here)) / 3,\n\t\t);\n\t}\n\tconst sorted = [...profile].sort((x, y) => x - y);\n\tconst median = sorted[Math.floor(sorted.length / 2)] ?? 0;\n\treturn (\n\t\tpeak >= EDGE_MIN_STRENGTH && peak >= EDGE_MIN_CONTRAST * Math.max(median, 4)\n\t);\n}\n\n/** Whether a straight card edge sits within `halfBand` of one guide side. */\nfunction hasEdgeOnSide(\n\tgray: ArrayLike<number>,\n\twidth: number,\n\theight: number,\n\tvertical: boolean,\n\tcenter: number,\n\thalfBand: number,\n\tspanFrom: number,\n\tspanTo: number,\n): boolean {\n\tconst acrossMax = vertical ? width - 2 : height - 2;\n\tconst alongMax = vertical ? height - 2 : width - 2;\n\tconst a0 = Math.max(1, Math.round(center - halfBand));\n\tconst a1 = Math.min(acrossMax, Math.round(center + halfBand));\n\tif (a1 - a0 < 2) return false;\n\tconst segment = (spanTo - spanFrom) / EDGE_SEGMENTS;\n\tlet passed = 0;\n\tfor (let i = 0; i < EDGE_SEGMENTS; i += 1) {\n\t\tconst s0 = Math.max(1, Math.round(spanFrom + i * segment));\n\t\tconst s1 = Math.min(alongMax, Math.round(spanFrom + (i + 1) * segment));\n\t\tif (s1 - s0 >= 2 && segmentHasEdge(gray, width, vertical, a0, a1, s0, s1))\n\t\t\tpassed += 1;\n\t}\n\treturn passed >= EDGE_SEGMENTS_NEEDED;\n}\n\n/** Count card edges (left, right, top, bottom) lying on `guide` (in buffer pixels). */\nexport function countGuideEdges(\n\tgray: ArrayLike<number>,\n\twidth: number,\n\theight: number,\n\tguide: GuideRect,\n): number {\n\tconst bandX = guide.width * EDGE_BAND_X;\n\tconst bandY = guide.height * EDGE_BAND_Y;\n\tconst vFrom = guide.y + (guide.height * (1 - EDGE_SPAN)) / 2;\n\tconst vTo = guide.y + (guide.height * (1 + EDGE_SPAN)) / 2;\n\tconst hFrom = guide.x + (guide.width * (1 - EDGE_SPAN)) / 2;\n\tconst hTo = guide.x + (guide.width * (1 + EDGE_SPAN)) / 2;\n\tconst sides = [\n\t\thasEdgeOnSide(gray, width, height, true, guide.x, bandX, vFrom, vTo),\n\t\thasEdgeOnSide(\n\t\t\tgray,\n\t\t\twidth,\n\t\t\theight,\n\t\t\ttrue,\n\t\t\tguide.x + guide.width,\n\t\t\tbandX,\n\t\t\tvFrom,\n\t\t\tvTo,\n\t\t),\n\t\thasEdgeOnSide(gray, width, height, false, guide.y, bandY, hFrom, hTo),\n\t\thasEdgeOnSide(\n\t\t\tgray,\n\t\t\twidth,\n\t\t\theight,\n\t\t\tfalse,\n\t\t\tguide.y + guide.height,\n\t\t\tbandY,\n\t\t\thFrom,\n\t\t\thTo,\n\t\t),\n\t];\n\treturn sides.filter(Boolean).length;\n}\n\n/**\n * ISO/IEC 7810 ID-1 (INE / CR80) aspect ratio: 85.60 × 53.98 mm ≈ 1.586.\n * Shared by the on-screen cutout and the quality sampler.\n */\nexport const ID_CARD_ASPECT = 85.6 / 53.98;\n\n/** Normalized guide layout (fractions of the frame, 0–1). */\nexport type IdGuideLayout = {\n\tleft: number;\n\ttop: number;\n\twidth: number;\n\theight: number;\n};\n\n/**\n * Digital zoom of the live preview (CSS scale around the stage center). Phone main cameras\n * cannot focus much closer than ~13 cm, where a card spans ~72% of the stage; zooming\n * 0.92 / 0.72 ≈ 1.28× lets the {@link idGuideLayout} guide fill ~92% at that same distance.\n */\nexport const ID_PREVIEW_ZOOM = 1.28;\n\n/**\n * Landscape ID-1 window centered in the frame, slightly above mid so the shutter\n * stays clear. Width-capped (92%) on portrait stages; height-capped on landscape ones.\n * Pair with {@link ID_PREVIEW_ZOOM} so the card does not have to come closer than the\n * camera can focus.\n */\nexport function idGuideLayout(\n\tframeWidth: number,\n\tframeHeight: number,\n): IdGuideLayout {\n\tconst fw = Math.max(1, frameWidth);\n\tconst fh = Math.max(1, frameHeight);\n\tconst maxW = fw * 0.92;\n\tconst maxH = fh * 0.5;\n\tlet width = maxW;\n\tlet height = width / ID_CARD_ASPECT;\n\tif (height > maxH) {\n\t\theight = maxH;\n\t\twidth = height * ID_CARD_ASPECT;\n\t}\n\tconst left = (fw - width) / 2 / fw;\n\t// Bias upward (~6% of frame) so the cutout sits above the shutter chrome.\n\tconst top = Math.max(0.08, (fh - height) / 2 / fh - 0.06);\n\treturn {\n\t\tleft,\n\t\ttop,\n\t\twidth: width / fw,\n\t\theight: height / fh,\n\t};\n}\n\n/** Pixel-space guide rect matching {@link idGuideLayout} (and the ID cutout mask). */\nexport function defaultIdGuideRect(\n\tvideoWidth: number,\n\tvideoHeight: number,\n): GuideRect {\n\tconst layout = idGuideLayout(videoWidth, videoHeight);\n\treturn {\n\t\tx: layout.left * videoWidth,\n\t\ty: layout.top * videoHeight,\n\t\twidth: Math.max(1, layout.width * videoWidth),\n\t\theight: Math.max(1, layout.height * videoHeight),\n\t};\n}\n\n/**\n * Visible video crop under CSS `object-cover` (center-cropped), optionally scaled by\n * `zoom` around the stage center. Returns the region of the video shown in the stage box.\n */\nexport function objectCoverVisibleRect(\n\tvideoWidth: number,\n\tvideoHeight: number,\n\tstageWidth: number,\n\tstageHeight: number,\n\tzoom: number = 1,\n): GuideRect {\n\tconst vw = Math.max(1, videoWidth);\n\tconst vh = Math.max(1, videoHeight);\n\tconst sw = Math.max(1, stageWidth);\n\tconst sh = Math.max(1, stageHeight);\n\tconst scale = Math.max(sw / vw, sh / vh) * Math.max(1, zoom);\n\tconst width = sw / scale;\n\tconst height = sh / scale;\n\treturn { x: (vw - width) / 2, y: (vh - height) / 2, width, height };\n}\n\n/**\n * Guide rect in video pixels aligned with the on-screen CR80 cutout when the\n * video is shown with `object-cover` (and `zoom`) in a stage of `stageWidth`×`stageHeight`.\n */\nexport function idGuideRectForCoveredStage(\n\tvideoWidth: number,\n\tvideoHeight: number,\n\tstageWidth: number,\n\tstageHeight: number,\n\tzoom: number = 1,\n): GuideRect {\n\tconst visible = objectCoverVisibleRect(\n\t\tvideoWidth,\n\t\tvideoHeight,\n\t\tstageWidth,\n\t\tstageHeight,\n\t\tzoom,\n\t);\n\tconst layout = idGuideLayout(stageWidth, stageHeight);\n\treturn {\n\t\tx: visible.x + layout.left * visible.width,\n\t\ty: visible.y + layout.top * visible.height,\n\t\twidth: Math.max(1, layout.width * visible.width),\n\t\theight: Math.max(1, layout.height * visible.height),\n\t};\n}\n\nconst UNUSABLE_IMAGE: ImageQuality = {\n\tblurScore: 0,\n\tmeanLuma: 0,\n\ttooBlurry: true,\n\ttooDark: true,\n};\n\nconst UNUSABLE_GUIDE: GuideQuality = {\n\t...UNUSABLE_IMAGE,\n\tedgesFound: 0,\n\taligned: false,\n\tready: false,\n};\n\n/** A live video or a canvas holding a native-size copy of one of its frames. */\nexport type FrameSource = HTMLVideoElement | HTMLCanvasElement;\n\nfunction frameSize(source: FrameSource): { width: number; height: number } {\n\treturn \"videoWidth\" in source\n\t\t? { width: source.videoWidth, height: source.videoHeight }\n\t\t: { width: source.width, height: source.height };\n}\n\n/** Draw a source region scaled to `dw`×`dh` and read it back as grayscale. */\nfunction grabGray(\n\tsource: FrameSource,\n\tsx: number,\n\tsy: number,\n\tsw: number,\n\tsh: number,\n\tdw: number,\n\tdh: number,\n): { gray: Float64Array; width: number; height: number } | null {\n\tconst canvas = document.createElement(\"canvas\");\n\tcanvas.width = dw;\n\tcanvas.height = dh;\n\tconst ctx = canvas.getContext(\"2d\", { willReadFrequently: true });\n\tif (!ctx) return null;\n\tctx.drawImage(source, sx, sy, sw, sh, 0, 0, dw, dh);\n\tconst sample = ctx.getImageData(0, 0, dw, dh);\n\t// iOS Safari frees canvas memory lazily; at 8 Hz release the backing store right away.\n\tcanvas.width = 0;\n\tcanvas.height = 0;\n\treturn {\n\t\tgray: rgbaToGray(sample.data, sample.width * sample.height),\n\t\twidth: sample.width,\n\t\theight: sample.height,\n\t};\n}\n\n/**\n * Live sharpness: Laplacian variance after a 2×2 box average. The box suppresses\n * sensor/codec pixel noise, which otherwise lifts a defocused card above the floor.\n */\nexport function assessSharpness(\n\tgray: ArrayLike<number>,\n\twidth: number,\n\theight: number,\n): ImageQuality {\n\tconst w = Math.max(0, width - 1);\n\tconst h = Math.max(0, height - 1);\n\tconst smooth = new Float64Array(w * h);\n\tfor (let y = 0; y < h; y += 1) {\n\t\tfor (let x = 0; x < w; x += 1) {\n\t\t\tconst i = y * width + x;\n\t\t\tsmooth[y * w + x] =\n\t\t\t\t((gray[i] ?? 0) +\n\t\t\t\t\t(gray[i + 1] ?? 0) +\n\t\t\t\t\t(gray[i + width] ?? 0) +\n\t\t\t\t\t(gray[i + width + 1] ?? 0)) /\n\t\t\t\t4;\n\t\t}\n\t}\n\treturn assessGrayPixels(smooth, w, h, KYC_SHARPNESS_MIN);\n}\n\n/**\n * Blur / darkness of the card interior (guide inset), sampled with the guide at\n * ≤ {@link SHARPNESS_SAMPLE_WIDTH} px so camera defocus is not hidden by downscaling.\n * The crop is pixel-aligned so a fractional offset does not add interpolation blur.\n */\nexport function sampleGuideSharpness(\n\tsource: FrameSource,\n\tguideRect: GuideRect,\n): ImageQuality {\n\tconst { width: fw, height: fh } = frameSize(source);\n\tif (fw < 1 || fh < 1 || guideRect.width < 1 || guideRect.height < 1)\n\t\treturn UNUSABLE_IMAGE;\n\tconst x0 = Math.max(\n\t\t0,\n\t\tMath.round(guideRect.x + guideRect.width * GUIDE_INTERIOR_INSET),\n\t);\n\tconst y0 = Math.max(\n\t\t0,\n\t\tMath.round(guideRect.y + guideRect.height * GUIDE_INTERIOR_INSET),\n\t);\n\tconst x1 = Math.min(\n\t\tfw,\n\t\tMath.round(guideRect.x + guideRect.width * (1 - GUIDE_INTERIOR_INSET)),\n\t);\n\tconst y1 = Math.min(\n\t\tfh,\n\t\tMath.round(guideRect.y + guideRect.height * (1 - GUIDE_INTERIOR_INSET)),\n\t);\n\tif (x1 - x0 < 1 || y1 - y0 < 1) return UNUSABLE_IMAGE;\n\tconst scale = Math.min(1, SHARPNESS_SAMPLE_WIDTH / guideRect.width);\n\tconst sample = grabGray(\n\t\tsource,\n\t\tx0,\n\t\ty0,\n\t\tx1 - x0,\n\t\ty1 - y0,\n\t\tMath.max(1, Math.round((x1 - x0) * scale)),\n\t\tMath.max(1, Math.round((y1 - y0) * scale)),\n\t);\n\tif (!sample) return UNUSABLE_IMAGE;\n\treturn assessSharpness(sample.gray, sample.width, sample.height);\n}\n\n/**\n * Score the guide on a live video frame. Edges use a cheap sample (guide plus a margin,\n * guide scaled to `sampleWidth` px); blur/darkness use {@link sampleGuideSharpness}.\n * Ready only when all four card edges line up and the interior is sharp and lit.\n */\nexport function sampleVideoQuality(\n\tvideo: HTMLVideoElement,\n\tguideRect: GuideRect,\n\tsampleWidth: number = GUIDE_SAMPLE_WIDTH,\n): GuideQuality {\n\tconst vw = video.videoWidth;\n\tconst vh = video.videoHeight;\n\tif (vw < 1 || vh < 1 || guideRect.width < 1 || guideRect.height < 1)\n\t\treturn UNUSABLE_GUIDE;\n\tconst mx = guideRect.width * GUIDE_EDGE_MARGIN;\n\tconst my = guideRect.height * GUIDE_EDGE_MARGIN;\n\tconst sx = Math.max(0, guideRect.x - mx);\n\tconst sy = Math.max(0, guideRect.y - my);\n\tconst sw = Math.max(1, Math.min(vw, guideRect.x + guideRect.width + mx) - sx);\n\tconst sh = Math.max(\n\t\t1,\n\t\tMath.min(vh, guideRect.y + guideRect.height + my) - sy,\n\t);\n\tconst scale = Math.min(1, sampleWidth / guideRect.width);\n\tconst sample = grabGray(\n\t\tvideo,\n\t\tsx,\n\t\tsy,\n\t\tsw,\n\t\tsh,\n\t\tMath.max(1, Math.round(sw * scale)),\n\t\tMath.max(1, Math.round(sh * scale)),\n\t);\n\tif (!sample) return UNUSABLE_GUIDE;\n\tconst edgesFound = countGuideEdges(sample.gray, sample.width, sample.height, {\n\t\tx: (guideRect.x - sx) * scale,\n\t\ty: (guideRect.y - sy) * scale,\n\t\twidth: guideRect.width * scale,\n\t\theight: guideRect.height * scale,\n\t});\n\tconst interior = sampleGuideSharpness(video, guideRect);\n\tconst aligned = edgesFound === 4;\n\treturn {\n\t\t...interior,\n\t\tedgesFound,\n\t\taligned,\n\t\tready: aligned && !interior.tooBlurry && !interior.tooDark,\n\t};\n}\n\n/**\n * Native-size copy of the sharpest ready frame from the last\n * {@link SHARPEST_FRAME_MAX_AGE_MS}, so auto-capture saves the crispest recent frame\n * instead of whatever is on screen when it fires. One canvas, reused; call `release`.\n */\nexport class SharpestFrame {\n\tprivate canvas: HTMLCanvasElement | null = null;\n\tprivate score = 0;\n\tprivate at = Number.NEGATIVE_INFINITY;\n\n\toffer(video: HTMLVideoElement, score: number, now: number): void {\n\t\tconst { videoWidth: width, videoHeight: height } = video;\n\t\tif (width < 1 || height < 1) return;\n\t\tif (score <= this.score && now - this.at <= SHARPEST_FRAME_MAX_AGE_MS)\n\t\t\treturn;\n\t\tconst canvas = this.canvas ?? document.createElement(\"canvas\");\n\t\tif (canvas.width !== width || canvas.height !== height) {\n\t\t\tcanvas.width = width;\n\t\t\tcanvas.height = height;\n\t\t}\n\t\tconst ctx = canvas.getContext(\"2d\");\n\t\tif (!ctx) return;\n\t\tctx.drawImage(video, 0, 0, width, height);\n\t\tthis.canvas = canvas;\n\t\tthis.score = score;\n\t\tthis.at = now;\n\t}\n\n\ttake(now: number): HTMLCanvasElement | null {\n\t\treturn this.canvas && now - this.at <= SHARPEST_FRAME_MAX_AGE_MS\n\t\t\t? this.canvas\n\t\t\t: null;\n\t}\n\n\trelease(): void {\n\t\tif (this.canvas) {\n\t\t\tthis.canvas.width = 0;\n\t\t\tthis.canvas.height = 0;\n\t\t}\n\t\tthis.canvas = null;\n\t\tthis.score = 0;\n\t\tthis.at = Number.NEGATIVE_INFINITY;\n\t}\n}\n\ntype FocusConstraintSet = MediaTrackConstraintSet & { focusMode?: string };\n\n/** Best-effort continuous autofocus (Android Chrome). iOS Safari exposes no focus controls. */\nexport async function requestContinuousFocus(\n\ttrack: MediaStreamTrack | undefined,\n): Promise<void> {\n\ttry {\n\t\tconst caps = track?.getCapabilities() as\n\t\t\t{ focusMode?: string[] } | undefined;\n\t\tif (!track || !caps?.focusMode?.includes(\"continuous\")) return;\n\t\tconst advanced: FocusConstraintSet[] = [{ focusMode: \"continuous\" }];\n\t\tawait track.applyConstraints({ advanced });\n\t} catch {\n\t\t// Unsupported constraint or camera busy: keep the browser's default focus.\n\t}\n}\n\ntype AutoCaptureSample = Pick<GuideQuality, \"aligned\" | \"ready\" | \"blurScore\">;\n\n/**\n * Require ~4 ready samples at ~8 Hz (~500 ms) before firing once. Call `observe`\n * from a rAF/timer loop; a bad sample only steps the streak back by one, so a\n * single noisy frame (hand shake) does not restart the wait. A sample only counts\n * as ready once focus has settled: the last {@link FOCUS_SETTLE_SAMPLES} aligned\n * sharpness scores are all ≥ {@link FOCUS_PLATEAU_RATIO} × the best in the last\n * {@link FOCUS_WINDOW_MS} (browsers expose no autofocus-locked event).\n */\nexport class AutoCaptureController {\n\tprivate readyStreak = 0;\n\tprivate fired = false;\n\tprivate lastSampleAt = 0;\n\tprivate focus: { at: number; score: number }[] = [];\n\tprivate readonly intervalMs: number;\n\tprivate readonly needed: number;\n\n\tconstructor(opts?: { hz?: number; readyCount?: number }) {\n\t\tconst hz = opts?.hz ?? AUTO_CAPTURE_SAMPLE_HZ;\n\t\tthis.intervalMs = 1000 / Math.max(1, hz);\n\t\tthis.needed = opts?.readyCount ?? AUTO_CAPTURE_READY_COUNT;\n\t}\n\n\treset(): void {\n\t\tthis.readyStreak = 0;\n\t\tthis.fired = false;\n\t\tthis.lastSampleAt = 0;\n\t\tthis.focus = [];\n\t}\n\n\tprivate focusSettled(sample: AutoCaptureSample, now: number): boolean {\n\t\tif (!sample.aligned) {\n\t\t\tthis.focus = [];\n\t\t\treturn false;\n\t\t}\n\t\tthis.focus = this.focus.filter(\n\t\t\t(entry) => now - entry.at <= FOCUS_WINDOW_MS,\n\t\t);\n\t\tthis.focus.push({ at: now, score: sample.blurScore });\n\t\treturn (\n\t\t\tthis.focus.length >= FOCUS_SETTLE_SAMPLES &&\n\t\t\tthis.focusStats.settleRatio >= FOCUS_PLATEAU_RATIO\n\t\t);\n\t}\n\n\t/** Best score in the focus window and the weakest of the last settle samples as a fraction of it. */\n\tget focusStats(): { best: number; settleRatio: number } {\n\t\tif (this.focus.length === 0) return { best: 0, settleRatio: 0 };\n\t\tconst best = Math.max(...this.focus.map((entry) => entry.score));\n\t\tconst weakest = Math.min(\n\t\t\t...this.focus.slice(-FOCUS_SETTLE_SAMPLES).map((entry) => entry.score),\n\t\t);\n\t\treturn { best, settleRatio: best > 0 ? weakest / best : 0 };\n\t}\n\n\tget progress(): number {\n\t\treturn Math.min(1, this.readyStreak / this.needed);\n\t}\n\n\tget hasFired(): boolean {\n\t\treturn this.fired;\n\t}\n\n\tobserve(\n\t\tsample: AutoCaptureSample,\n\t\tnow: number = typeof performance !== \"undefined\"\n\t\t\t? performance.now()\n\t\t\t: Date.now(),\n\t): { progress: number; shouldCapture: boolean } {\n\t\tif (this.fired) {\n\t\t\treturn { progress: 1, shouldCapture: false };\n\t\t}\n\t\tif (this.lastSampleAt > 0 && now - this.lastSampleAt < this.intervalMs) {\n\t\t\treturn { progress: this.progress, shouldCapture: false };\n\t\t}\n\t\tthis.lastSampleAt = now;\n\t\tconst settled = this.focusSettled(sample, now);\n\t\tif (!sample.ready || !settled) {\n\t\t\tthis.readyStreak = Math.max(0, this.readyStreak - 1);\n\t\t\treturn { progress: this.progress, shouldCapture: false };\n\t\t}\n\t\tthis.readyStreak += 1;\n\t\tconst progress = Math.min(1, this.readyStreak / this.needed);\n\t\tif (this.readyStreak >= this.needed) {\n\t\t\tthis.fired = true;\n\t\t\treturn { progress: 1, shouldCapture: true };\n\t\t}\n\t\treturn { progress, shouldCapture: false };\n\t}\n}\n\nexport function pickRecorderMime(): string | null {\n\tif (typeof MediaRecorder === \"undefined\") return null;\n\tconst candidates = [\n\t\t\"video/webm;codecs=vp8,opus\",\n\t\t\"video/webm;codecs=vp8\",\n\t\t\"video/webm\",\n\t\t\"video/mp4\",\n\t];\n\tfor (const mime of candidates) {\n\t\tif (MediaRecorder.isTypeSupported(mime)) return mime;\n\t}\n\treturn null;\n}\n\nexport function recorderExtension(mime: string): \"webm\" | \"mp4\" {\n\treturn mime.includes(\"mp4\") ? \"mp4\" : \"webm\";\n}\n\nexport function prefersReducedMotion(\n\tmatchMediaImpl?: typeof matchMedia,\n): boolean {\n\tconst impl =\n\t\tmatchMediaImpl ??\n\t\t(typeof globalThis.matchMedia === \"function\"\n\t\t\t? globalThis.matchMedia\n\t\t\t: undefined);\n\tif (!impl) return false;\n\treturn impl(\"(prefers-reduced-motion: reduce)\").matches;\n}\n\n/** Draw `crop` of `source` into a new canvas, downscaled to ≤ maxSide (never upscaled). */\nfunction drawScaled(\n\tsource: CanvasImageSource,\n\tcrop: GuideRect,\n\tmaxSide: number,\n): HTMLCanvasElement {\n\tconst scale = Math.min(1, maxSide / Math.max(crop.width, crop.height));\n\tconst width = Math.max(1, Math.round(crop.width * scale));\n\tconst height = Math.max(1, Math.round(crop.height * scale));\n\tconst canvas = document.createElement(\"canvas\");\n\tcanvas.width = width;\n\tcanvas.height = height;\n\tconst ctx = canvas.getContext(\"2d\");\n\tif (!ctx) throw new Error(\"canvas\");\n\tctx.drawImage(\n\t\tsource,\n\t\tcrop.x,\n\t\tcrop.y,\n\t\tcrop.width,\n\t\tcrop.height,\n\t\t0,\n\t\t0,\n\t\twidth,\n\t\theight,\n\t);\n\treturn canvas;\n}\n\n/** Downscale to ≤ maxSide JPEG and run blur/darkness checks. */\nexport async function prepareIdJpeg(\n\tsource: Blob,\n\tmaxSide: number = KYC_IMAGE_MAX_SIDE,\n): Promise<{ blob: Blob; quality: ImageQuality }> {\n\tconst bitmap = await createImageBitmap(source);\n\ttry {\n\t\tconst canvas = drawScaled(\n\t\t\tbitmap,\n\t\t\t{ x: 0, y: 0, width: bitmap.width, height: bitmap.height },\n\t\t\tmaxSide,\n\t\t);\n\t\tconst ctx = canvas.getContext(\"2d\");\n\t\tif (!ctx) throw new Error(\"canvas\");\n\t\tconst sample = ctx.getImageData(0, 0, canvas.width, canvas.height);\n\t\tconst quality = assessImageData(sample);\n\t\tconst blob = await new Promise<Blob>((resolve, reject) => {\n\t\t\tcanvas.toBlob(\n\t\t\t\t(next) => (next ? resolve(next) : reject(new Error(\"jpeg\"))),\n\t\t\t\t\"image/jpeg\",\n\t\t\t\t0.92,\n\t\t\t);\n\t\t});\n\t\treturn { blob, quality };\n\t} finally {\n\t\tbitmap.close();\n\t}\n}\n\n/**\n * Capture a video frame (or a kept {@link SharpestFrame} canvas) as a JPEG blob (≤ maxSide).\n * When `qualityRect` is set, blur/dark checks use the live sharpness measure on that\n * crop (the ID cutout) so dark surroundings outside the card do not falsely reject the shot.\n * `cropRect` (e.g. the zoomed visible region) limits the JPEG to what the user saw.\n */\nexport async function captureVideoFrame(\n\tsource: FrameSource,\n\tmaxSide: number = KYC_IMAGE_MAX_SIDE,\n\tqualityRect?: GuideRect,\n\tcropRect?: GuideRect,\n): Promise<{ blob: Blob; quality: ImageQuality }> {\n\tconst { width, height } = frameSize(source);\n\tif (width < 1 || height < 1) throw new Error(\"video\");\n\tconst x0 = cropRect ? Math.max(0, Math.round(cropRect.x)) : 0;\n\tconst y0 = cropRect ? Math.max(0, Math.round(cropRect.y)) : 0;\n\tconst x1 = cropRect\n\t\t? Math.min(width, Math.round(cropRect.x + cropRect.width))\n\t\t: width;\n\tconst y1 = cropRect\n\t\t? Math.min(height, Math.round(cropRect.y + cropRect.height))\n\t\t: height;\n\tconst crop =\n\t\tx1 - x0 >= 1 && y1 - y0 >= 1\n\t\t\t? { x: x0, y: y0, width: x1 - x0, height: y1 - y0 }\n\t\t\t: { x: 0, y: 0, width, height };\n\tconst canvas = drawScaled(source, crop, maxSide);\n\tconst ctx = canvas.getContext(\"2d\");\n\tif (!ctx) throw new Error(\"canvas\");\n\tconst quality =\n\t\tqualityRect && qualityRect.width >= 1 && qualityRect.height >= 1\n\t\t\t? sampleGuideSharpness(source, qualityRect)\n\t\t\t: assessImageData(ctx.getImageData(0, 0, canvas.width, canvas.height));\n\tconst blob = await new Promise<Blob>((resolve, reject) => {\n\t\tcanvas.toBlob(\n\t\t\t(next) => (next ? resolve(next) : reject(new Error(\"jpeg\"))),\n\t\t\t\"image/jpeg\",\n\t\t\t0.92,\n\t\t);\n\t});\n\treturn { blob, quality };\n}\n","/** Encode bytes for WAV data-URI / document upload helpers. */\nexport function bytesToBase64(bytes: Uint8Array): string {\n\tlet binary = \"\";\n\tfor (const byte of bytes) binary += String.fromCharCode(byte);\n\treturn btoa(binary);\n}\n","/** Capture \"done\" cue + session mute for KYC stages. */\n\nimport { bytesToBase64 } from \"./bytes\";\n\nexport const CAPTURE_MUTE_KEY = \"kyc-capture-muted\";\n\nexport function isCaptureMuted(storage?: Storage | null): boolean {\n\tconst store =\n\t\tstorage ?? (typeof sessionStorage !== \"undefined\" ? sessionStorage : null);\n\tif (!store) return false;\n\ttry {\n\t\treturn store.getItem(CAPTURE_MUTE_KEY) === \"1\";\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function setCaptureMuted(\n\tmuted: boolean,\n\tstorage?: Storage | null,\n): void {\n\tconst store =\n\t\tstorage ?? (typeof sessionStorage !== \"undefined\" ? sessionStorage : null);\n\tif (!store) return;\n\ttry {\n\t\tstore.setItem(CAPTURE_MUTE_KEY, muted ? \"1\" : \"0\");\n\t} catch {\n\t\t/* private mode / quota — mute still applies for this call site via state */\n\t}\n}\n\nconst SAMPLE_RATE = 22_050;\n\n/** 16-bit mono PCM WAV of a decaying sine (silence when `amplitude` is 0). */\nexport function toneWavDataUri(\n\tfrequency: number,\n\tdurationSec: number,\n\tamplitude: number,\n): string {\n\tconst samples = Math.round(SAMPLE_RATE * durationSec);\n\tconst bytes = new Uint8Array(44 + samples * 2);\n\tconst view = new DataView(bytes.buffer);\n\tconst ascii = (offset: number, text: string) => {\n\t\tfor (let i = 0; i < text.length; i++)\n\t\t\tview.setUint8(offset + i, text.charCodeAt(i));\n\t};\n\tascii(0, \"RIFF\");\n\tview.setUint32(4, 36 + samples * 2, true);\n\tascii(8, \"WAVE\");\n\tascii(12, \"fmt \");\n\tview.setUint32(16, 16, true);\n\tview.setUint16(20, 1, true);\n\tview.setUint16(22, 1, true);\n\tview.setUint32(24, SAMPLE_RATE, true);\n\tview.setUint32(28, SAMPLE_RATE * 2, true);\n\tview.setUint16(32, 2, true);\n\tview.setUint16(34, 16, true);\n\tascii(36, \"data\");\n\tview.setUint32(40, samples * 2, true);\n\tconst attack = SAMPLE_RATE * 0.004;\n\tfor (let i = 0; i < samples; i++) {\n\t\tconst envelope = Math.min(1, i / attack) * Math.exp((-5 * i) / samples);\n\t\tconst value =\n\t\t\tMath.sin((2 * Math.PI * frequency * i) / SAMPLE_RATE) *\n\t\t\tenvelope *\n\t\t\tamplitude;\n\t\tview.setInt16(44 + i * 2, Math.round(value * 32_767), true);\n\t}\n\treturn `data:audio/wav;base64,${bytesToBase64(bytes)}`;\n}\n\nlet beepUri: string | null = null;\nlet silenceUri: string | null = null;\nlet cueAudio: HTMLAudioElement | null = null;\n\nfunction audioElement(): HTMLAudioElement | null {\n\tif (cueAudio) return cueAudio;\n\tif (typeof Audio === \"undefined\") return null;\n\ttry {\n\t\tcueAudio = new Audio();\n\t\tcueAudio.preload = \"auto\";\n\t\treturn cueAudio;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\nfunction playSource(audio: HTMLAudioElement, src: string): void {\n\ttry {\n\t\tif (audio.getAttribute(\"src\") !== src) audio.src = src;\n\t\telse audio.currentTime = 0;\n\t\tvoid Promise.resolve(audio.play()).catch(() => undefined);\n\t} catch {\n\t\t/* a cue must never break capture */\n\t}\n}\n\n/**\n * Call synchronously inside a Start tap. iOS only lets a media element play without a gesture\n * after it played once inside one, and Web Audio is muted by the silent switch while media\n * elements are not — so the cue is one `<audio>` element unlocked here with a silent clip.\n */\nexport function primeCaptureAudio(): void {\n\tconst audio = audioElement();\n\tif (!audio) return;\n\tsilenceUri ??= toneWavDataUri(0, 0.05, 0);\n\tplaySource(audio, silenceUri);\n}\n\n/** Short success beep. No-op when muted or when media playback is unavailable. */\nexport function playCaptureBeep(options: { muted?: boolean } = {}): void {\n\tif (options.muted ?? isCaptureMuted()) return;\n\tconst audio = audioElement();\n\tif (!audio) return;\n\tbeepUri ??= toneWavDataUri(880, 0.15, 0.5);\n\tplaySource(audio, beepUri);\n}\n\n/** Test helper — drop the shared element between suites. */\nexport function resetCaptureAudioForTests(): void {\n\tcueAudio = null;\n}\n","\"use client\";\n\nimport { Check, Volume2, VolumeX } from \"lucide-react\";\nimport { useEffect, useId, useRef, type ReactNode } from \"react\";\nimport { Button } from \"../../ui/button\";\nimport {\n\tDrawer,\n\tDrawerClose,\n\tDrawerContent,\n\tDrawerDescription,\n\tDrawerFooter,\n\tDrawerHeader,\n\tDrawerTitle,\n\tDrawerTrigger,\n} from \"../../ui/drawer\";\nimport { isCaptureMuted, setCaptureMuted } from \"./capture-cues\";\n\ntype CaptureStageProps = {\n\t/** Visible step label, e.g. \"Front of ID\". */\n\tstepLabel: string;\n\t/** Pill overlay label for full-bleed capture (e.g. \"Frente de tu INE\"). */\n\tpillLabel?: string;\n\t/** Simple progress like \"1 / 2\". */\n\tprogressLabel?: string;\n\t/** Live status for screen readers + status strip. */\n\tstatusText: string;\n\t/** assertive after capture, polite while guiding. */\n\tstatusPoliteness?: \"polite\" | \"assertive\";\n\tmuted: boolean;\n\tonMutedChange: (muted: boolean) => void;\n\tmuteLabel: string;\n\tunmuteLabel: string;\n\thelpLabel?: string;\n\thelpTitle?: string;\n\thelpTips?: string[];\n\thelpIllustrationSrc?: string;\n\tchildren: ReactNode;\n\t/** Focus the status region when the step mounts. */\n\tautoFocusStatus?: boolean;\n\t/** Full-bleed dark chrome (hides surrounding card chrome). */\n\tfullBleed?: boolean;\n\tclassName?: string;\n};\n\nexport function readInitialCaptureMute(): boolean {\n\treturn isCaptureMuted();\n}\n\nexport function persistCaptureMute(muted: boolean): void {\n\tsetCaptureMuted(muted);\n}\n\n/** `?kycDebug=1` on `/kyc`: live capture numbers for tuning on real phones. */\nexport function readCaptureDebugFlag(): boolean {\n\treturn new URLSearchParams(window.location.search).get(\"kycDebug\") === \"1\";\n}\n\n/** Small monospace overlay for `?kycDebug=1`; English only, never shown without the flag. */\nexport function CaptureDebugReadout({ lines }: { lines: string[] }) {\n\treturn (\n\t\t<pre\n\t\t\tclassName=\"pointer-events-none absolute left-2 top-12 z-10 rounded bg-black/70 px-2 py-1 font-mono text-[10px] leading-tight text-white\"\n\t\t\tdata-testid=\"kyc-debug\"\n\t\t>\n\t\t\t{lines.join(\"\\n\")}\n\t\t</pre>\n\t);\n}\n\n/** Full-bleed dark capture chrome with status strip, mute toggle, and step label. */\nexport function CaptureStage({\n\tstepLabel,\n\tpillLabel,\n\tprogressLabel,\n\tstatusText,\n\tstatusPoliteness = \"polite\",\n\tmuted,\n\tonMutedChange,\n\tmuteLabel,\n\tunmuteLabel,\n\thelpLabel,\n\thelpTitle,\n\thelpTips,\n\thelpIllustrationSrc,\n\tchildren,\n\tautoFocusStatus = true,\n\tfullBleed = false,\n\tclassName,\n}: CaptureStageProps) {\n\tconst statusId = useId();\n\tconst statusRef = useRef<HTMLParagraphElement>(null);\n\n\tuseEffect(() => {\n\t\tif (!autoFocusStatus) return;\n\t\tstatusRef.current?.focus({ preventScroll: true });\n\t}, [autoFocusStatus, stepLabel]);\n\n\tconst help =\n\t\thelpLabel && helpTitle && helpTips && helpTips.length > 0 ? (\n\t\t\t<Drawer>\n\t\t\t\t<DrawerTrigger asChild>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName={\n\t\t\t\t\t\t\tfullBleed\n\t\t\t\t\t\t\t\t? \"min-h-11 shrink-0 border-white/30 bg-black/40 text-white hover:bg-black/60\"\n\t\t\t\t\t\t\t\t: \"min-h-11 shrink-0\"\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsize=\"sm\"\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{helpLabel}\n\t\t\t\t\t</Button>\n\t\t\t\t</DrawerTrigger>\n\t\t\t\t<DrawerContent>\n\t\t\t\t\t<DrawerHeader>\n\t\t\t\t\t\t<DrawerTitle>{helpTitle}</DrawerTitle>\n\t\t\t\t\t\t<DrawerDescription>{helpTitle}</DrawerDescription>\n\t\t\t\t\t</DrawerHeader>\n\t\t\t\t\t{helpIllustrationSrc ? (\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\tsrc={helpIllustrationSrc}\n\t\t\t\t\t\t\talt=\"\"\n\t\t\t\t\t\t\tclassName=\"mx-auto w-full max-w-[200px] object-contain px-4\"\n\t\t\t\t\t\t\tloading=\"lazy\"\n\t\t\t\t\t\t\tdecoding=\"async\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : null}\n\t\t\t\t\t<ul className=\"list-disc space-y-2 px-4 pb-2 pl-8 text-left text-sm text-muted-foreground\">\n\t\t\t\t\t\t{helpTips.map((tip) => (\n\t\t\t\t\t\t\t<li key={tip}>{tip}</li>\n\t\t\t\t\t\t))}\n\t\t\t\t\t</ul>\n\t\t\t\t\t<DrawerFooter>\n\t\t\t\t\t\t<DrawerClose asChild>\n\t\t\t\t\t\t\t<Button type=\"button\" variant=\"outline\">\n\t\t\t\t\t\t\t\t{helpLabel}\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</DrawerClose>\n\t\t\t\t\t</DrawerFooter>\n\t\t\t\t</DrawerContent>\n\t\t\t</Drawer>\n\t\t) : null;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={`flex flex-col gap-3 ${fullBleed ? \"min-h-dvh gap-0\" : \"\"} ${className ?? \"\"}`.trim()}\n\t\t>\n\t\t\t{fullBleed ? null : (\n\t\t\t\t<div className=\"flex items-center justify-between gap-3\">\n\t\t\t\t\t<div className=\"min-w-0\">\n\t\t\t\t\t\t<p className=\"truncate text-sm font-medium text-foreground\">\n\t\t\t\t\t\t\t{stepLabel}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t{progressLabel ? (\n\t\t\t\t\t\t\t<p className=\"text-xs text-muted-foreground\">{progressLabel}</p>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t\t{help}\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\taria-label={muted ? unmuteLabel : muteLabel}\n\t\t\t\t\t\t\taria-pressed={muted}\n\t\t\t\t\t\t\tclassName=\"min-h-11 min-w-11 shrink-0\"\n\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\tconst next = !muted;\n\t\t\t\t\t\t\t\tpersistCaptureMute(next);\n\t\t\t\t\t\t\t\tonMutedChange(next);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tsize=\"icon\"\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{muted ? (\n\t\t\t\t\t\t\t\t<VolumeX aria-hidden className=\"size-4\" />\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Volume2 aria-hidden className=\"size-4\" />\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t\t<div\n\t\t\t\tclassName={\n\t\t\t\t\tfullBleed\n\t\t\t\t\t\t? \"relative flex min-h-dvh flex-1 flex-col overflow-hidden bg-neutral-950 text-white\"\n\t\t\t\t\t\t: \"relative overflow-hidden rounded-xl bg-neutral-950 text-white\"\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{fullBleed ? (\n\t\t\t\t\t<div className=\"absolute inset-x-0 top-0 z-30 flex items-center justify-between gap-2 bg-gradient-to-b from-black/80 to-transparent px-3 pb-10 pt-3\">\n\t\t\t\t\t\t{pillLabel ? (\n\t\t\t\t\t\t\t<span className=\"rounded-full bg-black/55 px-3 py-1 text-xs font-medium text-white\">\n\t\t\t\t\t\t\t\t{pillLabel}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<span className=\"text-sm font-medium\">{stepLabel}</span>\n\t\t\t\t\t\t)}\n\t\t\t\t\t\t<div className=\"flex items-center gap-2\">\n\t\t\t\t\t\t\t{help}\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\taria-label={muted ? unmuteLabel : muteLabel}\n\t\t\t\t\t\t\t\taria-pressed={muted}\n\t\t\t\t\t\t\t\tclassName=\"min-h-11 min-w-11 shrink-0 border-white/30 bg-black/40 text-white hover:bg-black/60\"\n\t\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\t\tconst next = !muted;\n\t\t\t\t\t\t\t\t\tpersistCaptureMute(next);\n\t\t\t\t\t\t\t\t\tonMutedChange(next);\n\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\tsize=\"icon\"\n\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{muted ? (\n\t\t\t\t\t\t\t\t\t<VolumeX aria-hidden className=\"size-4\" />\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<Volume2 aria-hidden className=\"size-4\" />\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t) : null}\n\t\t\t\t{children}\n\t\t\t\t<div\n\t\t\t\t\tclassName={`pointer-events-none absolute inset-x-0 ${fullBleed ? \"top-14\" : \"top-0\"} bg-gradient-to-b from-black/70 to-transparent px-3 pb-8 pt-3`}\n\t\t\t\t>\n\t\t\t\t\t<p\n\t\t\t\t\t\taria-live={statusPoliteness}\n\t\t\t\t\t\tclassName=\"text-center text-sm font-medium drop-shadow outline-none\"\n\t\t\t\t\t\tid={statusId}\n\t\t\t\t\t\tref={statusRef}\n\t\t\t\t\t\trole=\"status\"\n\t\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\t>\n\t\t\t\t\t\t{statusText}\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n\n/** \"Done\" badge over the stage so a completed capture reads even with the sound off. */\nexport function CaptureCheck({ reduceMotion }: { reduceMotion: boolean }) {\n\treturn (\n\t\t<div\n\t\t\taria-hidden\n\t\t\tclassName={`pointer-events-none absolute inset-0 z-10 flex items-center justify-center ${\n\t\t\t\treduceMotion ? \"\" : \"animate-pulse\"\n\t\t\t}`}\n\t\t\tdata-testid=\"capture-check\"\n\t\t>\n\t\t\t<span className=\"flex size-16 items-center justify-center rounded-full bg-emerald-500 text-white shadow-lg\">\n\t\t\t\t<Check className=\"size-8\" strokeWidth={3} />\n\t\t\t</span>\n\t\t</div>\n\t);\n}\n\ntype ProgressRingProps = {\n\tprogress: number;\n\tsize?: number;\n\tstroke?: number;\n\tchildren?: ReactNode;\n\tclassName?: string;\n};\n\n/** Circular progress around the shutter (0..1). */\nexport function CaptureProgressRing({\n\tprogress,\n\tsize = 72,\n\tstroke = 4,\n\tchildren,\n\tclassName,\n}: ProgressRingProps) {\n\tconst radius = (size - stroke) / 2;\n\tconst circumference = 2 * Math.PI * radius;\n\tconst clamped = Math.max(0, Math.min(1, progress));\n\tconst offset = circumference * (1 - clamped);\n\treturn (\n\t\t<div\n\t\t\tclassName={`relative inline-flex items-center justify-center ${className ?? \"\"}`.trim()}\n\t\t\tstyle={{ width: size, height: size }}\n\t\t>\n\t\t\t{/* Absolute, so it paints over the in-flow child: it must not take its taps. */}\n\t\t\t<svg\n\t\t\t\taria-hidden\n\t\t\t\tclassName=\"pointer-events-none absolute inset-0 -rotate-90\"\n\t\t\t\theight={size}\n\t\t\t\twidth={size}\n\t\t\t>\n\t\t\t\t<circle\n\t\t\t\t\tcx={size / 2}\n\t\t\t\t\tcy={size / 2}\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tr={radius}\n\t\t\t\t\tstroke=\"rgba(255,255,255,0.25)\"\n\t\t\t\t\tstrokeWidth={stroke}\n\t\t\t\t/>\n\t\t\t\t<circle\n\t\t\t\t\tcx={size / 2}\n\t\t\t\t\tcy={size / 2}\n\t\t\t\t\tfill=\"none\"\n\t\t\t\t\tr={radius}\n\t\t\t\t\tstroke=\"white\"\n\t\t\t\t\tstrokeDasharray={circumference}\n\t\t\t\t\tstrokeDashoffset={offset}\n\t\t\t\t\tstrokeLinecap=\"round\"\n\t\t\t\t\tstrokeWidth={stroke}\n\t\t\t\t/>\n\t\t\t</svg>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n","import { clsx, type ClassValue } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","import { cn } from \"../lib/utils\";\n\nexport type ProductIllustrationProps = {\n\tsrc: string;\n\t/** Decorative product art: default empty alt. */\n\talt?: string;\n\tclassName?: string;\n\tsize?: \"sm\" | \"md\" | \"lg\";\n};\n\nconst SIZE_CLASS = {\n\tsm: \"max-w-[140px]\",\n\tmd: \"max-w-[220px]\",\n\tlg: \"max-w-[280px]\",\n} as const;\n\n/** Transparent PNG product illustration sized for empty states and intro panels. */\nexport function ProductIllustration({\n\tsrc,\n\talt = \"\",\n\tclassName,\n\tsize = \"md\",\n}: ProductIllustrationProps) {\n\treturn (\n\t\t<img\n\t\t\tsrc={src}\n\t\t\talt={alt}\n\t\t\tloading=\"lazy\"\n\t\t\tdecoding=\"async\"\n\t\t\tclassName={cn(\n\t\t\t\t\"mx-auto h-auto w-full object-contain\",\n\t\t\t\tSIZE_CLASS[size],\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t/>\n\t);\n}\n","\"use client\";\n\nimport {\n\tuseCallback,\n\tuseEffect,\n\tuseRef,\n\tuseState,\n\ttype KeyboardEvent,\n} from \"react\";\nimport { ProductIllustration } from \"../ProductIllustration\";\nimport { Button } from \"../../ui/button\";\nimport { Progress } from \"../../ui/progress\";\nimport { toast } from \"../../ui/sonner\";\nimport { playCaptureBeep, primeCaptureAudio } from \"./capture-cues\";\nimport {\n\tCaptureCheck,\n\tCaptureDebugReadout,\n\tCaptureProgressRing,\n\tCaptureStage,\n\treadCaptureDebugFlag,\n\treadInitialCaptureMute,\n} from \"./capture-stage\";\nimport {\n\tAUTO_CAPTURE_SAMPLE_HZ,\n\tAutoCaptureController,\n\tcaptureVideoFrame,\n\tFOCUS_PLATEAU_RATIO,\n\tID_PREVIEW_ZOOM,\n\tidGuideLayout,\n\tidGuideRectForCoveredStage,\n\tKYC_SHARPNESS_MIN,\n\tobjectCoverVisibleRect,\n\tprepareIdJpeg,\n\tprefersReducedMotion,\n\trequestContinuousFocus,\n\tsampleVideoQuality,\n\tSharpestFrame,\n\ttype GuideQuality,\n\ttype GuideRect,\n\ttype IdGuideLayout,\n} from \"./kyc-capture\";\n\n/** All user-facing strings for ID capture (injected by portal/app i18n). */\nexport type IdCaptureLabels = {\n\tstepFront: string;\n\tstepBack: string;\n\tfrontHint: string;\n\tbackHint: string;\n\tbriefingTip: string;\n\tstartCamera: string;\n\tcameraOpening: string;\n\tconfirmPhoto: string;\n\tacceptPhoto: string;\n\tdiscardPhoto: string;\n\tpreviewAlt: string;\n\tfrontCameraLabel: string;\n\tbackCameraLabel: string;\n\tshutter: string;\n\tfileFallback: string;\n\tfileFallbackAlt: string;\n\tretakeClearer: string;\n\tcaptureFailed: string;\n\tsoftPhotoWarning: string;\n\tuploadingSecurely: string;\n\tcaptureHelp: string;\n\tcaptureHelpTitle: string;\n\tcaptureHelpFlat: string;\n\tcaptureHelpLight: string;\n\tcaptureHelpEdges: string;\n\tcaptureHelpGlare: string;\n\tmuteSound: string;\n\tunmuteSound: string;\n\tholdStill: string;\n\tfocusing: string;\n\talignCard: string;\n\ttooDark: string;\n\tcapturing: string;\n\tphotoCaptured: string;\n\tautoCaptureHint: string;\n};\n\nexport type IdCaptureProps = {\n\tslot: \"id_front\" | \"id_back\";\n\tlabels: IdCaptureLabels;\n\tonCaptured: (blob: Blob, fileName: string) => void;\n\tonBusyChange?: (busy: boolean) => void;\n\t/** Notify host chrome when full-bleed live/confirm starts or ends. */\n\tonFullBleedChange?: (fullBleed: boolean) => void;\n\t/** Tip illustration URL (e.g. `/illustrations/kyc-id-front-tips.png`). */\n\tillustrationSrc: string;\n\t/** Server upload in flight after Accept. */\n\tuploading?: boolean;\n\t/** Pill label for full-bleed capture (e.g. Frente de tu INE). */\n\tpillLabel?: string;\n\t/** Injected sampler for tests. */\n\tsampleQuality?: typeof sampleVideoQuality;\n};\n\ntype GuideTone = \"bad\" | \"warming\" | \"ready\";\ntype CapturePhase = \"briefing\" | \"live\" | \"confirm\";\ntype DebugStats = {\n\tbest: number;\n\tsettleRatio: number;\n\tvideoWidth: number;\n\tvideoHeight: number;\n};\n\nfunction DebugReadout({\n\tquality,\n\tprogress,\n\tstats,\n}: {\n\tquality: GuideQuality | null;\n\tprogress: number;\n\tstats: DebugStats | null;\n}) {\n\tconst yesNo = (value: boolean | undefined) => (value ? \"yes\" : \"no\");\n\tconst lines = [\n\t\t`edges ${quality?.edgesFound ?? 0}/4 aligned ${yesNo(quality?.aligned)}`,\n\t\t`sharp ${(quality?.blurScore ?? 0).toFixed(1)} (min ${KYC_SHARPNESS_MIN}) best ${(stats?.best ?? 0).toFixed(1)}`,\n\t\t`settle ${(stats?.settleRatio ?? 0).toFixed(2)} (need ${FOCUS_PLATEAU_RATIO}) ready ${yesNo(quality?.ready)}`,\n\t\t`luma ${(quality?.meanLuma ?? 0).toFixed(0)} progress ${progress.toFixed(2)}`,\n\t\t`video ${stats?.videoWidth ?? 0}x${stats?.videoHeight ?? 0} zoom ${ID_PREVIEW_ZOOM}`,\n\t];\n\treturn <CaptureDebugReadout lines={lines} />;\n}\n\nfunction guideTone(quality: GuideQuality | null, progress: number): GuideTone {\n\tif (!quality) return \"bad\";\n\tif (quality.ready && progress > 0) return \"ready\";\n\tif (quality.aligned && !quality.tooDark) return \"warming\";\n\treturn \"bad\";\n}\n\nfunction statusForQuality(\n\tquality: GuideQuality | null,\n\tprogress: number,\n\tlabels: IdCaptureLabels,\n): string {\n\tif (!quality) return labels.autoCaptureHint;\n\tif (quality.tooDark) return labels.tooDark;\n\tif (!quality.aligned) return labels.alignCard;\n\tif (quality.tooBlurry) return labels.focusing;\n\tif (quality.ready && progress >= 1) return labels.capturing;\n\tif (quality.ready) return labels.holdStill;\n\treturn labels.autoCaptureHint;\n}\n\nconst TONE_STROKE: Record<GuideTone, string> = {\n\tbad: \"border-red-400/95\",\n\twarming: \"border-amber-300/95\",\n\tready: \"border-emerald-400/95\",\n};\n\nconst TONE_CORNER: Record<GuideTone, string> = {\n\tbad: \"border-red-300\",\n\twarming: \"border-amber-200\",\n\tready: \"border-emerald-300\",\n};\n\n/** CR80 cutout + corner brackets so the physical INE has a clear target to match. */\nfunction IdCardGuideOverlay({\n\tlayout,\n\ttone,\n\treduceMotion,\n}: {\n\tlayout: IdGuideLayout;\n\ttone: GuideTone;\n\treduceMotion: boolean;\n}) {\n\tconst style = {\n\t\tleft: `${layout.left * 100}%`,\n\t\ttop: `${layout.top * 100}%`,\n\t\twidth: `${layout.width * 100}%`,\n\t\theight: `${layout.height * 100}%`,\n\t\tboxShadow: \"0 0 0 9999px rgba(0,0,0,0.62)\",\n\t} as const;\n\tconst corner = `pointer-events-none absolute size-[14%] max-h-10 max-w-10 border-[3px] ${TONE_CORNER[tone]} ${\n\t\treduceMotion ? \"\" : \"transition-colors duration-200\"\n\t}`;\n\treturn (\n\t\t<div\n\t\t\taria-hidden\n\t\t\tclassName={`pointer-events-none absolute rounded-md border-2 ${TONE_STROKE[tone]} ${\n\t\t\t\treduceMotion ? \"\" : \"transition-colors duration-200\"\n\t\t\t}`}\n\t\t\tstyle={style}\n\t\t>\n\t\t\t{/* Inner dashed outline hints edge alignment without competing with corners. */}\n\t\t\t<div className=\"absolute inset-[6px] rounded-sm border border-dashed border-white/35\" />\n\t\t\t<span\n\t\t\t\tclassName={`${corner} left-[-2px] top-[-2px] rounded-tl-md border-b-0 border-r-0`}\n\t\t\t/>\n\t\t\t<span\n\t\t\t\tclassName={`${corner} right-[-2px] top-[-2px] rounded-tr-md border-b-0 border-l-0`}\n\t\t\t/>\n\t\t\t<span\n\t\t\t\tclassName={`${corner} bottom-[-2px] left-[-2px] rounded-bl-md border-r-0 border-t-0`}\n\t\t\t/>\n\t\t\t<span\n\t\t\t\tclassName={`${corner} bottom-[-2px] right-[-2px] rounded-br-md border-l-0 border-t-0`}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport function IdCapture({\n\tslot,\n\tlabels,\n\tonCaptured,\n\tonBusyChange,\n\tonFullBleedChange,\n\tillustrationSrc,\n\tuploading = false,\n\tpillLabel,\n\tsampleQuality,\n}: IdCaptureProps) {\n\tconst videoRef = useRef<HTMLVideoElement>(null);\n\tconst stageRef = useRef<HTMLDivElement>(null);\n\tconst fileRef = useRef<HTMLInputElement>(null);\n\tconst streamRef = useRef<MediaStream | null>(null);\n\tconst previewUrlRef = useRef<string | null>(null);\n\tconst controllerRef = useRef(new AutoCaptureController());\n\tconst sharpestRef = useRef(new SharpestFrame());\n\tconst capturingRef = useRef(false);\n\tconst sampleFn = sampleQuality ?? sampleVideoQuality;\n\n\tconst [phase, setPhase] = useState<CapturePhase>(\"briefing\");\n\tconst [pendingCapture, setPendingCapture] = useState<{\n\t\tblob: Blob;\n\t\tfileName: string;\n\t} | null>(null);\n\tconst [previewUrl, setPreviewUrl] = useState<string | null>(null);\n\tconst [cameraReady, setCameraReady] = useState(false);\n\tconst [cameraFailed, setCameraFailed] = useState(false);\n\tconst [busy, setBusy] = useState(false);\n\tconst [justCaptured, setJustCaptured] = useState(false);\n\tconst [progress, setProgress] = useState(0);\n\tconst [quality, setQuality] = useState<GuideQuality | null>(null);\n\tconst [statusOverride, setStatusOverride] = useState<string | null>(null);\n\tconst [statusPoliteness, setStatusPoliteness] = useState<\n\t\t\"polite\" | \"assertive\"\n\t>(\"polite\");\n\tconst [muted, setMuted] = useState(false);\n\tconst [debug, setDebug] = useState(false);\n\tconst [debugStats, setDebugStats] = useState<DebugStats | null>(null);\n\tconst reduceMotion = prefersReducedMotion();\n\n\tuseEffect(() => {\n\t\tsetMuted(readInitialCaptureMute());\n\t\tsetDebug(readCaptureDebugFlag());\n\t}, []);\n\n\tconst fullBleed = phase === \"live\" || phase === \"confirm\";\n\tuseEffect(() => {\n\t\tonFullBleedChange?.(fullBleed);\n\t\treturn () => onFullBleedChange?.(false);\n\t}, [fullBleed, onFullBleedChange]);\n\n\tuseEffect(() => {\n\t\treturn () => {\n\t\t\tif (previewUrlRef.current) {\n\t\t\t\tURL.revokeObjectURL(previewUrlRef.current);\n\t\t\t\tpreviewUrlRef.current = null;\n\t\t\t}\n\t\t};\n\t}, []);\n\n\tuseEffect(() => {\n\t\tif (phase !== \"live\") {\n\t\t\tsetCameraReady(false);\n\t\t\treturn;\n\t\t}\n\t\tlet cancelled = false;\n\t\tasync function openCamera() {\n\t\t\tif (!navigator.mediaDevices?.getUserMedia) {\n\t\t\t\tsetCameraFailed(true);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttry {\n\t\t\t\t// Without a size hint browsers open 640×480, too soft for blur checks and OCR.\n\t\t\t\tconst stream = await navigator.mediaDevices.getUserMedia({\n\t\t\t\t\taudio: false,\n\t\t\t\t\tvideo: {\n\t\t\t\t\t\tfacingMode: { ideal: \"environment\" },\n\t\t\t\t\t\twidth: { ideal: 1920 },\n\t\t\t\t\t\theight: { ideal: 1080 },\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t\tif (cancelled) {\n\t\t\t\t\tfor (const track of stream.getTracks()) track.stop();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tstreamRef.current = stream;\n\t\t\t\tvoid requestContinuousFocus(stream.getTracks()[0]);\n\t\t\t\tconst video = videoRef.current;\n\t\t\t\tif (video) {\n\t\t\t\t\tvideo.srcObject = stream;\n\t\t\t\t\tawait video.play();\n\t\t\t\t}\n\t\t\t\tsetCameraReady(true);\n\t\t\t\tsetCameraFailed(false);\n\t\t\t} catch {\n\t\t\t\tif (!cancelled) setCameraFailed(true);\n\t\t\t}\n\t\t}\n\t\tvoid openCamera();\n\t\treturn () => {\n\t\t\tcancelled = true;\n\t\t\tconst stream = streamRef.current;\n\t\t\tstreamRef.current = null;\n\t\t\tif (stream) for (const track of stream.getTracks()) track.stop();\n\t\t\tconst video = videoRef.current;\n\t\t\tif (video) video.srcObject = null;\n\t\t\tsharpestRef.current.release();\n\t\t\tsetCameraReady(false);\n\t\t};\n\t}, [phase]);\n\n\tfunction setPending(next: boolean) {\n\t\tsetBusy(next);\n\t\tonBusyChange?.(next);\n\t}\n\n\tconst clearPreview = useCallback(() => {\n\t\tif (previewUrlRef.current) {\n\t\t\tURL.revokeObjectURL(previewUrlRef.current);\n\t\t\tpreviewUrlRef.current = null;\n\t\t}\n\t\tsetPreviewUrl(null);\n\t\tsetPendingCapture(null);\n\t}, []);\n\n\tconst announceCaptured = useCallback(() => {\n\t\tsetStatusPoliteness(\"assertive\");\n\t\tsetStatusOverride(labels.photoCaptured);\n\t\tplayCaptureBeep({ muted });\n\t\tsetJustCaptured(true);\n\t\twindow.setTimeout(() => setJustCaptured(false), 700);\n\t}, [labels.photoCaptured, muted]);\n\n\tconst enterConfirm = useCallback(\n\t\t(blob: Blob, fileName: string) => {\n\t\t\tif (previewUrlRef.current) URL.revokeObjectURL(previewUrlRef.current);\n\t\t\tconst url = URL.createObjectURL(blob);\n\t\t\tpreviewUrlRef.current = url;\n\t\t\tsetPreviewUrl(url);\n\t\t\tsetPendingCapture({ blob, fileName });\n\t\t\tannounceCaptured();\n\t\t\tsetPhase(\"confirm\");\n\t\t\tcontrollerRef.current.reset();\n\t\t\tsetProgress(0);\n\t\t\tsetQuality(null);\n\t\t},\n\t\t[announceCaptured],\n\t);\n\n\tconst finishPrepared = useCallback(\n\t\tasync (blob: Blob, fileName: string) => {\n\t\t\tsetPending(true);\n\t\t\ttry {\n\t\t\t\tconst prepared = await prepareIdJpeg(blob);\n\t\t\t\tif (prepared.quality.tooBlurry || prepared.quality.tooDark) {\n\t\t\t\t\ttoast.error(labels.retakeClearer);\n\t\t\t\t\tcontrollerRef.current.reset();\n\t\t\t\t\tsetProgress(0);\n\t\t\t\t\tcapturingRef.current = false;\n\t\t\t\t\tsetPending(false);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tenterConfirm(prepared.blob, fileName);\n\t\t\t} catch {\n\t\t\t\ttoast.error(labels.captureFailed);\n\t\t\t\tcontrollerRef.current.reset();\n\t\t\t\tcapturingRef.current = false;\n\t\t\t} finally {\n\t\t\t\tsetPending(false);\n\t\t\t}\n\t\t},\n\t\t[enterConfirm, labels.captureFailed, labels.retakeClearer],\n\t);\n\n\t/** Guide and zoomed visible region in video pixels, matching what the stage shows. */\n\tconst resolveStageRects = useCallback((): {\n\t\tguide: GuideRect;\n\t\tvisible: GuideRect;\n\t} | null => {\n\t\tconst video = videoRef.current;\n\t\tconst stage = stageRef.current;\n\t\tif (!video || video.videoWidth < 1 || video.videoHeight < 1) return null;\n\t\tconst args = [\n\t\t\tvideo.videoWidth,\n\t\t\tvideo.videoHeight,\n\t\t\tstage?.clientWidth || 3,\n\t\t\tstage?.clientHeight || 4,\n\t\t\tID_PREVIEW_ZOOM,\n\t\t] as const;\n\t\treturn {\n\t\t\tguide: idGuideRectForCoveredStage(...args),\n\t\t\tvisible: objectCoverVisibleRect(...args),\n\t\t};\n\t}, []);\n\n\t/** The user judges the shot on confirm: a soft frame only warns, it never blocks. */\n\tconst shutterFromVideo = useCallback(\n\t\tasync (sharpest?: HTMLCanvasElement | null) => {\n\t\t\tconst video = videoRef.current;\n\t\t\tif (!video || !cameraReady || capturingRef.current || phase !== \"live\")\n\t\t\t\treturn;\n\t\t\tcapturingRef.current = true;\n\t\t\tsetPending(true);\n\t\t\ttry {\n\t\t\t\tconst rects = resolveStageRects();\n\t\t\t\tconst prepared = await captureVideoFrame(\n\t\t\t\t\tsharpest ?? video,\n\t\t\t\t\tundefined,\n\t\t\t\t\trects?.guide,\n\t\t\t\t\trects?.visible,\n\t\t\t\t);\n\t\t\t\tenterConfirm(\n\t\t\t\t\tprepared.blob,\n\t\t\t\t\tslot === \"id_front\" ? \"id-front.jpg\" : \"id-back.jpg\",\n\t\t\t\t);\n\t\t\t\tif (prepared.quality.tooBlurry || prepared.quality.tooDark) {\n\t\t\t\t\ttoast.warning(labels.softPhotoWarning);\n\t\t\t\t}\n\t\t\t} catch {\n\t\t\t\ttoast.error(labels.captureFailed);\n\t\t\t\tcontrollerRef.current.reset();\n\t\t\t\tsetProgress(0);\n\t\t\t} finally {\n\t\t\t\tsharpestRef.current.release();\n\t\t\t\tcapturingRef.current = false;\n\t\t\t\tsetPending(false);\n\t\t\t}\n\t\t},\n\t\t[\n\t\t\tcameraReady,\n\t\t\tenterConfirm,\n\t\t\tlabels.captureFailed,\n\t\t\tlabels.softPhotoWarning,\n\t\t\tphase,\n\t\t\tresolveStageRects,\n\t\t\tslot,\n\t\t],\n\t);\n\n\tuseEffect(() => {\n\t\tif (sampleQuality) {\n\t\t\tcontrollerRef.current = new AutoCaptureController({\n\t\t\t\thz: 1000,\n\t\t\t\treadyCount: 4,\n\t\t\t});\n\t\t}\n\t}, [sampleQuality]);\n\n\tuseEffect(() => {\n\t\tif (phase !== \"live\" || !cameraReady || busy || cameraFailed) return;\n\t\tlet raf = 0;\n\t\tlet alive = true;\n\t\tlet lastSampleAt = Number.NEGATIVE_INFINITY;\n\t\tconst tick = () => {\n\t\t\tif (!alive || capturingRef.current) {\n\t\t\t\tif (alive) raf = window.requestAnimationFrame(tick);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst now = performance.now();\n\t\t\tif (now - lastSampleAt < 1000 / AUTO_CAPTURE_SAMPLE_HZ) {\n\t\t\t\traf = window.requestAnimationFrame(tick);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst video = videoRef.current;\n\t\t\tif (!video) {\n\t\t\t\traf = window.requestAnimationFrame(tick);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst hasPixels = video.videoWidth >= 1 && video.videoHeight >= 1;\n\t\t\tif (!hasPixels && !sampleQuality) {\n\t\t\t\traf = window.requestAnimationFrame(tick);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst guide =\n\t\t\t\tresolveStageRects()?.guide ??\n\t\t\t\t({\n\t\t\t\t\tx: 0,\n\t\t\t\t\ty: 0,\n\t\t\t\t\twidth: Math.max(1, video.videoWidth),\n\t\t\t\t\theight: Math.max(1, video.videoHeight),\n\t\t\t\t} satisfies GuideRect);\n\t\t\tlastSampleAt = now;\n\t\t\tconst nextQuality = sampleFn(video, guide);\n\t\t\tsetQuality(nextQuality);\n\t\t\tif (nextQuality.ready)\n\t\t\t\tsharpestRef.current.offer(video, nextQuality.blurScore, now);\n\t\t\tconst result = controllerRef.current.observe(nextQuality, now);\n\t\t\tsetProgress(result.progress);\n\t\t\tif (debug) {\n\t\t\t\tsetDebugStats({\n\t\t\t\t\t...controllerRef.current.focusStats,\n\t\t\t\t\tvideoWidth: video.videoWidth,\n\t\t\t\t\tvideoHeight: video.videoHeight,\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (result.shouldCapture) {\n\t\t\t\tvoid shutterFromVideo(sharpestRef.current.take(now));\n\t\t\t}\n\t\t\traf = window.requestAnimationFrame(tick);\n\t\t};\n\t\traf = window.requestAnimationFrame(tick);\n\t\treturn () => {\n\t\t\talive = false;\n\t\t\twindow.cancelAnimationFrame(raf);\n\t\t};\n\t}, [\n\t\tbusy,\n\t\tcameraFailed,\n\t\tcameraReady,\n\t\tdebug,\n\t\tphase,\n\t\tresolveStageRects,\n\t\tsampleFn,\n\t\tsampleQuality,\n\t\tshutterFromVideo,\n\t]);\n\n\tasync function onFileChange() {\n\t\tconst file = fileRef.current?.files?.[0];\n\t\tif (!file) return;\n\t\tawait finishPrepared(\n\t\t\tfile,\n\t\t\tfile.name || (slot === \"id_front\" ? \"id-front.jpg\" : \"id-back.jpg\"),\n\t\t);\n\t\tif (fileRef.current) fileRef.current.value = \"\";\n\t}\n\n\tfunction onStageKeyDown(event: KeyboardEvent<HTMLDivElement>) {\n\t\tif (event.key !== \" \" && event.key !== \"Enter\") return;\n\t\tevent.preventDefault();\n\t\tvoid shutterFromVideo();\n\t}\n\n\tfunction onAcceptPhoto() {\n\t\tif (!pendingCapture || busy) return;\n\t\tconst { blob, fileName } = pendingCapture;\n\t\tclearPreview();\n\t\tonCaptured(blob, fileName);\n\t}\n\n\tfunction onDiscardPhoto() {\n\t\tclearPreview();\n\t\tsetStatusOverride(null);\n\t\tsetStatusPoliteness(\"polite\");\n\t\tsetJustCaptured(false);\n\t\tcapturingRef.current = false;\n\t\tcontrollerRef.current.reset();\n\t\tsetProgress(0);\n\t\tsetQuality(null);\n\t\tsetPhase(cameraFailed ? \"briefing\" : \"live\");\n\t}\n\n\tconst tone = guideTone(quality, progress);\n\tconst liveStatus =\n\t\tstatusOverride ?? statusForQuality(quality, progress, labels);\n\tconst stepLabel = slot === \"id_front\" ? labels.stepFront : labels.stepBack;\n\tconst progressLabel = slot === \"id_front\" ? \"1 / 2\" : \"2 / 2\";\n\t// Stage is aspect-[3/4]; keep the cutout on the same CR80 geometry as the sampler\n\t// (which also applies ID_PREVIEW_ZOOM to map it onto video pixels).\n\tconst guideLayout = idGuideLayout(3, 4);\n\tconst showFilePicker = phase !== \"confirm\" && !uploading;\n\tconst sideHint = slot === \"id_front\" ? labels.frontHint : labels.backHint;\n\tconst helpTips = [\n\t\tlabels.captureHelpFlat,\n\t\tlabels.captureHelpLight,\n\t\tlabels.captureHelpEdges,\n\t\tlabels.captureHelpGlare,\n\t];\n\n\tif (uploading) {\n\t\treturn (\n\t\t\t<div\n\t\t\t\taria-busy\n\t\t\t\taria-live=\"polite\"\n\t\t\t\tclassName=\"flex flex-col items-center gap-4 rounded-xl border border-border bg-muted/30 p-8 text-center\"\n\t\t\t>\n\t\t\t\t<p className=\"text-sm font-medium\">{labels.uploadingSecurely}</p>\n\t\t\t\t<Progress\n\t\t\t\t\tclassName=\"w-full max-w-xs\"\n\t\t\t\t\tlabel={labels.uploadingSecurely}\n\t\t\t\t\tvalue={66}\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"flex flex-col gap-4\">\n\t\t\t{phase === \"briefing\" ? (\n\t\t\t\t<div className=\"flex flex-col gap-4 rounded-xl border border-border bg-muted/30 p-5\">\n\t\t\t\t\t<ProductIllustration alt=\"\" size=\"md\" src={illustrationSrc} />\n\t\t\t\t\t<div className=\"flex flex-col gap-1.5\">\n\t\t\t\t\t\t<p className=\"text-sm font-medium text-foreground\">{stepLabel}</p>\n\t\t\t\t\t\t<p className=\"text-xs text-muted-foreground\">{progressLabel}</p>\n\t\t\t\t\t\t<p className=\"text-sm text-muted-foreground\">{sideHint}</p>\n\t\t\t\t\t\t<p className=\"text-sm text-muted-foreground\">\n\t\t\t\t\t\t\t{labels.briefingTip}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</div>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"self-start\"\n\t\t\t\t\t\tdisabled={busy}\n\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\tprimeCaptureAudio();\n\t\t\t\t\t\t\tsetCameraFailed(false);\n\t\t\t\t\t\t\tsetPhase(\"live\");\n\t\t\t\t\t\t}}\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{labels.startCamera}\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) : null}\n\n\t\t\t{phase === \"live\" && !cameraFailed ? (\n\t\t\t\t<CaptureStage\n\t\t\t\t\tfullBleed\n\t\t\t\t\thelpIllustrationSrc={illustrationSrc}\n\t\t\t\t\thelpLabel={labels.captureHelp}\n\t\t\t\t\thelpTips={helpTips}\n\t\t\t\t\thelpTitle={labels.captureHelpTitle}\n\t\t\t\t\tmuteLabel={labels.muteSound}\n\t\t\t\t\tmuted={muted}\n\t\t\t\t\tonMutedChange={setMuted}\n\t\t\t\t\tpillLabel={pillLabel ?? stepLabel}\n\t\t\t\t\tprogressLabel={progressLabel}\n\t\t\t\t\tstatusPoliteness={statusPoliteness}\n\t\t\t\t\tstatusText={liveStatus}\n\t\t\t\t\tstepLabel={stepLabel}\n\t\t\t\t\tunmuteLabel={labels.unmuteSound}\n\t\t\t\t>\n\t\t\t\t\t<div\n\t\t\t\t\t\taria-label={\n\t\t\t\t\t\t\tslot === \"id_front\"\n\t\t\t\t\t\t\t\t? labels.frontCameraLabel\n\t\t\t\t\t\t\t\t: labels.backCameraLabel\n\t\t\t\t\t\t}\n\t\t\t\t\t\tclassName=\"relative aspect-[3/4] max-h-[min(70vh,100dvh)] w-full flex-1 outline-none sm:mx-auto sm:max-w-md\"\n\t\t\t\t\t\tonKeyDown={onStageKeyDown}\n\t\t\t\t\t\tref={stageRef}\n\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\ttabIndex={0}\n\t\t\t\t\t>\n\t\t\t\t\t\t<video\n\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\tautoPlay\n\t\t\t\t\t\t\tclassName={`h-full w-full object-cover ${cameraReady ? \"\" : \"opacity-0\"}`}\n\t\t\t\t\t\t\tmuted\n\t\t\t\t\t\t\tplaysInline\n\t\t\t\t\t\t\tref={videoRef}\n\t\t\t\t\t\t\tstyle={{ transform: `scale(${ID_PREVIEW_ZOOM})` }}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{!cameraReady ? (\n\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\taria-busy\n\t\t\t\t\t\t\t\taria-label={labels.cameraOpening}\n\t\t\t\t\t\t\t\tclassName={`absolute inset-0 bg-neutral-900 ${reduceMotion ? \"\" : \"animate-pulse\"}`}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t<IdCardGuideOverlay\n\t\t\t\t\t\t\tlayout={guideLayout}\n\t\t\t\t\t\t\treduceMotion={reduceMotion}\n\t\t\t\t\t\t\ttone={tone}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{debug ? (\n\t\t\t\t\t\t\t<DebugReadout\n\t\t\t\t\t\t\t\tprogress={progress}\n\t\t\t\t\t\t\t\tquality={quality}\n\t\t\t\t\t\t\t\tstats={debugStats}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t<div className=\"absolute inset-x-0 bottom-0 z-20 flex justify-center bg-gradient-to-t from-black/80 to-transparent p-5\">\n\t\t\t\t\t\t\t<CaptureProgressRing progress={progress}>\n\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\taria-busy={busy}\n\t\t\t\t\t\t\t\t\taria-label={labels.shutter}\n\t\t\t\t\t\t\t\t\tclassName=\"flex size-14 items-center justify-center rounded-full bg-white text-black shadow focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white disabled:opacity-50\"\n\t\t\t\t\t\t\t\t\tdisabled={!cameraReady || busy}\n\t\t\t\t\t\t\t\t\tonClick={(event) => {\n\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\tvoid shutterFromVideo();\n\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<span className=\"pointer-events-none size-10 rounded-full border-2 border-neutral-900/80\" />\n\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t</CaptureProgressRing>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</CaptureStage>\n\t\t\t) : null}\n\n\t\t\t{phase === \"confirm\" && previewUrl ? (\n\t\t\t\t<CaptureStage\n\t\t\t\t\tfullBleed\n\t\t\t\t\thelpIllustrationSrc={illustrationSrc}\n\t\t\t\t\thelpLabel={labels.captureHelp}\n\t\t\t\t\thelpTips={helpTips}\n\t\t\t\t\thelpTitle={labels.captureHelpTitle}\n\t\t\t\t\tmuteLabel={labels.muteSound}\n\t\t\t\t\tmuted={muted}\n\t\t\t\t\tonMutedChange={setMuted}\n\t\t\t\t\tpillLabel={pillLabel ?? stepLabel}\n\t\t\t\t\tprogressLabel={progressLabel}\n\t\t\t\t\tstatusPoliteness=\"assertive\"\n\t\t\t\t\tstatusText={labels.confirmPhoto}\n\t\t\t\t\tstepLabel={stepLabel}\n\t\t\t\t\tunmuteLabel={labels.unmuteSound}\n\t\t\t\t>\n\t\t\t\t\t<div className=\"relative mx-auto aspect-[3/4] max-h-[min(70vh,100dvh)] w-full sm:max-w-md\">\n\t\t\t\t\t\t<img\n\t\t\t\t\t\t\talt={labels.previewAlt}\n\t\t\t\t\t\t\tclassName={`h-full w-full object-contain ${reduceMotion ? \"\" : \"transition-opacity duration-200\"}`}\n\t\t\t\t\t\t\tsrc={previewUrl}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{justCaptured ? <CaptureCheck reduceMotion={reduceMotion} /> : null}\n\t\t\t\t\t</div>\n\t\t\t\t\t<div className=\"absolute inset-x-0 bottom-0 z-30 flex flex-wrap justify-center gap-2 bg-gradient-to-t from-black/80 to-transparent p-5\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdisabled={busy || !pendingCapture}\n\t\t\t\t\t\t\tonClick={onAcceptPhoto}\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{labels.acceptPhoto}\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tdisabled={busy}\n\t\t\t\t\t\t\tonClick={onDiscardPhoto}\n\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\tvariant=\"outline\"\n\t\t\t\t\t\t\tclassName=\"border-white/30 bg-black/40 text-white hover:bg-black/60\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{labels.discardPhoto}\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</div>\n\t\t\t\t</CaptureStage>\n\t\t\t) : null}\n\n\t\t\t{showFilePicker ? (\n\t\t\t\t<div\n\t\t\t\t\tclassName={`flex flex-col gap-1.5 ${fullBleed ? \"px-4 pb-6\" : \"\"}`}\n\t\t\t\t>\n\t\t\t\t\t{cameraFailed ? (\n\t\t\t\t\t\t<p className=\"text-sm text-muted-foreground\">\n\t\t\t\t\t\t\t{labels.fileFallback}\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) : null}\n\t\t\t\t\t<input\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tcapture=\"environment\"\n\t\t\t\t\t\tclassName=\"sr-only\"\n\t\t\t\t\t\tdisabled={busy}\n\t\t\t\t\t\tid={`kyc-file-${slot}`}\n\t\t\t\t\t\tonChange={() => void onFileChange()}\n\t\t\t\t\t\tref={fileRef}\n\t\t\t\t\t\ttabIndex={-1}\n\t\t\t\t\t\ttype=\"file\"\n\t\t\t\t\t/>\n\t\t\t\t\t<Button\n\t\t\t\t\t\tclassName=\"self-start px-0\"\n\t\t\t\t\t\tdisabled={busy}\n\t\t\t\t\t\tonClick={() => fileRef.current?.click()}\n\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\tvariant=\"link\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{cameraFailed ? labels.fileFallback : labels.fileFallbackAlt}\n\t\t\t\t\t</Button>\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t);\n}\n\n/** @deprecated Prefer {@link IdCapture}; kept as alias for gradual migration. */\nexport const KycIdCapture = IdCapture;\n"]}
|
package/dist/kyc.d.cts
ADDED
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/** Client-side ID image prep for §25.8.1 portal capture. */
|
|
5
|
+
declare const KYC_IMAGE_MAX_SIDE = 1600;
|
|
6
|
+
declare const KYC_BLUR_MIN = 80;
|
|
7
|
+
declare const KYC_DARK_MAX_MEAN = 40;
|
|
8
|
+
declare const GUIDE_SAMPLE_WIDTH = 320;
|
|
9
|
+
/** Extra crop around the guide (fraction of guide size) so edges just outside it still count. */
|
|
10
|
+
declare const GUIDE_EDGE_MARGIN = 0.15;
|
|
11
|
+
/** Edge search band half-width as a fraction of the guide width / height. */
|
|
12
|
+
declare const EDGE_BAND_X = 0.08;
|
|
13
|
+
declare const EDGE_BAND_Y = 0.1;
|
|
14
|
+
/** Middle fraction of each side scanned (skips rounded corners and the INE notch). */
|
|
15
|
+
declare const EDGE_SPAN = 0.6;
|
|
16
|
+
/** Each side is split into short segments (tolerates ~3.5° tilt and a thumb on the edge). */
|
|
17
|
+
declare const EDGE_SEGMENTS = 3;
|
|
18
|
+
declare const EDGE_SEGMENTS_NEEDED = 2;
|
|
19
|
+
/**
|
|
20
|
+
* Calibrated on real + demo INE (front/back) over black, white paper, gray, wood and
|
|
21
|
+
* gradient backgrounds vs. empty scenes, product photos and high-contrast texture.
|
|
22
|
+
*/
|
|
23
|
+
declare const EDGE_MIN_STRENGTH = 50;
|
|
24
|
+
declare const EDGE_MIN_CONTRAST = 4;
|
|
25
|
+
/** Blur / darkness use the card interior only, away from the background at the edges. */
|
|
26
|
+
declare const GUIDE_INTERIOR_INSET = 0.12;
|
|
27
|
+
/**
|
|
28
|
+
* Live sharpness samples the card interior with the guide at ≤ 800 px (native, never
|
|
29
|
+
* upscaled). At 320 px a Gaussian σ = 2 px defocus on a 1080×1440 frame still scored up
|
|
30
|
+
* to ~1050, so blurry IDs passed.
|
|
31
|
+
*/
|
|
32
|
+
declare const SHARPNESS_SAMPLE_WIDTH = 800;
|
|
33
|
+
/**
|
|
34
|
+
* {@link assessSharpness} floor at {@link SHARPNESS_SAMPLE_WIDTH}. Only rejects clearly
|
|
35
|
+
* defocused frames; {@link AutoCaptureController} focus-settle does the rest. Calibrated on
|
|
36
|
+
* real + demo INE with the card at 518–776 px, iPhone-like ISP smoothing (Gaussian σ 0.8 /
|
|
37
|
+
* bilateral / median), noise σ 2–5, contrast ×0.6 and JPEG q60–70: sharp video scores ≥ 27
|
|
38
|
+
* on fronts, Gaussian defocus σ 2 px ≤ 13 on fronts and ≤ 18 on the real back. The old floor
|
|
39
|
+
* of 120 rejected most real sharp video. Content-dependent: a dense synthetic QR back reaches
|
|
40
|
+
* ~57 at σ 2 px.
|
|
41
|
+
*/
|
|
42
|
+
declare const KYC_SHARPNESS_MIN = 20;
|
|
43
|
+
/** Focus has settled when the last few aligned samples are all within this fraction of the best. */
|
|
44
|
+
declare const FOCUS_PLATEAU_RATIO = 0.8;
|
|
45
|
+
declare const FOCUS_SETTLE_SAMPLES = 3;
|
|
46
|
+
declare const FOCUS_WINDOW_MS = 1200;
|
|
47
|
+
/** Auto-capture saves the sharpest ready frame no older than this. */
|
|
48
|
+
declare const SHARPEST_FRAME_MAX_AGE_MS = 500;
|
|
49
|
+
declare const AUTO_CAPTURE_SAMPLE_HZ = 8;
|
|
50
|
+
declare const AUTO_CAPTURE_READY_COUNT = 4;
|
|
51
|
+
type ImageQuality = {
|
|
52
|
+
blurScore: number;
|
|
53
|
+
meanLuma: number;
|
|
54
|
+
tooBlurry: boolean;
|
|
55
|
+
tooDark: boolean;
|
|
56
|
+
};
|
|
57
|
+
type GuideQuality = ImageQuality & {
|
|
58
|
+
/** Card edges (0–4) found on the guide sides. */
|
|
59
|
+
edgesFound: number;
|
|
60
|
+
aligned: boolean;
|
|
61
|
+
ready: boolean;
|
|
62
|
+
};
|
|
63
|
+
/** Normalized guide rect in video pixel space (not CSS). */
|
|
64
|
+
type GuideRect = {
|
|
65
|
+
x: number;
|
|
66
|
+
y: number;
|
|
67
|
+
width: number;
|
|
68
|
+
height: number;
|
|
69
|
+
};
|
|
70
|
+
/** Laplacian variance + mean luma on an 8-bit grayscale buffer (row-major). */
|
|
71
|
+
declare function assessGrayPixels(gray: ArrayLike<number>, width: number, height: number, blurMin?: number): ImageQuality;
|
|
72
|
+
declare function rgbaToGray(rgba: ArrayLike<number>, pixelCount: number): Float64Array;
|
|
73
|
+
declare function assessImageData(image: {
|
|
74
|
+
data: ArrayLike<number>;
|
|
75
|
+
width: number;
|
|
76
|
+
height: number;
|
|
77
|
+
}): ImageQuality;
|
|
78
|
+
/** Count card edges (left, right, top, bottom) lying on `guide` (in buffer pixels). */
|
|
79
|
+
declare function countGuideEdges(gray: ArrayLike<number>, width: number, height: number, guide: GuideRect): number;
|
|
80
|
+
/**
|
|
81
|
+
* ISO/IEC 7810 ID-1 (INE / CR80) aspect ratio: 85.60 × 53.98 mm ≈ 1.586.
|
|
82
|
+
* Shared by the on-screen cutout and the quality sampler.
|
|
83
|
+
*/
|
|
84
|
+
declare const ID_CARD_ASPECT: number;
|
|
85
|
+
/** Normalized guide layout (fractions of the frame, 0–1). */
|
|
86
|
+
type IdGuideLayout = {
|
|
87
|
+
left: number;
|
|
88
|
+
top: number;
|
|
89
|
+
width: number;
|
|
90
|
+
height: number;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Digital zoom of the live preview (CSS scale around the stage center). Phone main cameras
|
|
94
|
+
* cannot focus much closer than ~13 cm, where a card spans ~72% of the stage; zooming
|
|
95
|
+
* 0.92 / 0.72 ≈ 1.28× lets the {@link idGuideLayout} guide fill ~92% at that same distance.
|
|
96
|
+
*/
|
|
97
|
+
declare const ID_PREVIEW_ZOOM = 1.28;
|
|
98
|
+
/**
|
|
99
|
+
* Landscape ID-1 window centered in the frame, slightly above mid so the shutter
|
|
100
|
+
* stays clear. Width-capped (92%) on portrait stages; height-capped on landscape ones.
|
|
101
|
+
* Pair with {@link ID_PREVIEW_ZOOM} so the card does not have to come closer than the
|
|
102
|
+
* camera can focus.
|
|
103
|
+
*/
|
|
104
|
+
declare function idGuideLayout(frameWidth: number, frameHeight: number): IdGuideLayout;
|
|
105
|
+
/** Pixel-space guide rect matching {@link idGuideLayout} (and the ID cutout mask). */
|
|
106
|
+
declare function defaultIdGuideRect(videoWidth: number, videoHeight: number): GuideRect;
|
|
107
|
+
/**
|
|
108
|
+
* Visible video crop under CSS `object-cover` (center-cropped), optionally scaled by
|
|
109
|
+
* `zoom` around the stage center. Returns the region of the video shown in the stage box.
|
|
110
|
+
*/
|
|
111
|
+
declare function objectCoverVisibleRect(videoWidth: number, videoHeight: number, stageWidth: number, stageHeight: number, zoom?: number): GuideRect;
|
|
112
|
+
/**
|
|
113
|
+
* Guide rect in video pixels aligned with the on-screen CR80 cutout when the
|
|
114
|
+
* video is shown with `object-cover` (and `zoom`) in a stage of `stageWidth`×`stageHeight`.
|
|
115
|
+
*/
|
|
116
|
+
declare function idGuideRectForCoveredStage(videoWidth: number, videoHeight: number, stageWidth: number, stageHeight: number, zoom?: number): GuideRect;
|
|
117
|
+
/** A live video or a canvas holding a native-size copy of one of its frames. */
|
|
118
|
+
type FrameSource = HTMLVideoElement | HTMLCanvasElement;
|
|
119
|
+
/**
|
|
120
|
+
* Live sharpness: Laplacian variance after a 2×2 box average. The box suppresses
|
|
121
|
+
* sensor/codec pixel noise, which otherwise lifts a defocused card above the floor.
|
|
122
|
+
*/
|
|
123
|
+
declare function assessSharpness(gray: ArrayLike<number>, width: number, height: number): ImageQuality;
|
|
124
|
+
/**
|
|
125
|
+
* Blur / darkness of the card interior (guide inset), sampled with the guide at
|
|
126
|
+
* ≤ {@link SHARPNESS_SAMPLE_WIDTH} px so camera defocus is not hidden by downscaling.
|
|
127
|
+
* The crop is pixel-aligned so a fractional offset does not add interpolation blur.
|
|
128
|
+
*/
|
|
129
|
+
declare function sampleGuideSharpness(source: FrameSource, guideRect: GuideRect): ImageQuality;
|
|
130
|
+
/**
|
|
131
|
+
* Score the guide on a live video frame. Edges use a cheap sample (guide plus a margin,
|
|
132
|
+
* guide scaled to `sampleWidth` px); blur/darkness use {@link sampleGuideSharpness}.
|
|
133
|
+
* Ready only when all four card edges line up and the interior is sharp and lit.
|
|
134
|
+
*/
|
|
135
|
+
declare function sampleVideoQuality(video: HTMLVideoElement, guideRect: GuideRect, sampleWidth?: number): GuideQuality;
|
|
136
|
+
/**
|
|
137
|
+
* Native-size copy of the sharpest ready frame from the last
|
|
138
|
+
* {@link SHARPEST_FRAME_MAX_AGE_MS}, so auto-capture saves the crispest recent frame
|
|
139
|
+
* instead of whatever is on screen when it fires. One canvas, reused; call `release`.
|
|
140
|
+
*/
|
|
141
|
+
declare class SharpestFrame {
|
|
142
|
+
private canvas;
|
|
143
|
+
private score;
|
|
144
|
+
private at;
|
|
145
|
+
offer(video: HTMLVideoElement, score: number, now: number): void;
|
|
146
|
+
take(now: number): HTMLCanvasElement | null;
|
|
147
|
+
release(): void;
|
|
148
|
+
}
|
|
149
|
+
/** Best-effort continuous autofocus (Android Chrome). iOS Safari exposes no focus controls. */
|
|
150
|
+
declare function requestContinuousFocus(track: MediaStreamTrack | undefined): Promise<void>;
|
|
151
|
+
type AutoCaptureSample = Pick<GuideQuality, "aligned" | "ready" | "blurScore">;
|
|
152
|
+
/**
|
|
153
|
+
* Require ~4 ready samples at ~8 Hz (~500 ms) before firing once. Call `observe`
|
|
154
|
+
* from a rAF/timer loop; a bad sample only steps the streak back by one, so a
|
|
155
|
+
* single noisy frame (hand shake) does not restart the wait. A sample only counts
|
|
156
|
+
* as ready once focus has settled: the last {@link FOCUS_SETTLE_SAMPLES} aligned
|
|
157
|
+
* sharpness scores are all ≥ {@link FOCUS_PLATEAU_RATIO} × the best in the last
|
|
158
|
+
* {@link FOCUS_WINDOW_MS} (browsers expose no autofocus-locked event).
|
|
159
|
+
*/
|
|
160
|
+
declare class AutoCaptureController {
|
|
161
|
+
private readyStreak;
|
|
162
|
+
private fired;
|
|
163
|
+
private lastSampleAt;
|
|
164
|
+
private focus;
|
|
165
|
+
private readonly intervalMs;
|
|
166
|
+
private readonly needed;
|
|
167
|
+
constructor(opts?: {
|
|
168
|
+
hz?: number;
|
|
169
|
+
readyCount?: number;
|
|
170
|
+
});
|
|
171
|
+
reset(): void;
|
|
172
|
+
private focusSettled;
|
|
173
|
+
/** Best score in the focus window and the weakest of the last settle samples as a fraction of it. */
|
|
174
|
+
get focusStats(): {
|
|
175
|
+
best: number;
|
|
176
|
+
settleRatio: number;
|
|
177
|
+
};
|
|
178
|
+
get progress(): number;
|
|
179
|
+
get hasFired(): boolean;
|
|
180
|
+
observe(sample: AutoCaptureSample, now?: number): {
|
|
181
|
+
progress: number;
|
|
182
|
+
shouldCapture: boolean;
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
declare function pickRecorderMime(): string | null;
|
|
186
|
+
declare function recorderExtension(mime: string): "webm" | "mp4";
|
|
187
|
+
declare function prefersReducedMotion(matchMediaImpl?: typeof matchMedia): boolean;
|
|
188
|
+
/** Downscale to ≤ maxSide JPEG and run blur/darkness checks. */
|
|
189
|
+
declare function prepareIdJpeg(source: Blob, maxSide?: number): Promise<{
|
|
190
|
+
blob: Blob;
|
|
191
|
+
quality: ImageQuality;
|
|
192
|
+
}>;
|
|
193
|
+
/**
|
|
194
|
+
* Capture a video frame (or a kept {@link SharpestFrame} canvas) as a JPEG blob (≤ maxSide).
|
|
195
|
+
* When `qualityRect` is set, blur/dark checks use the live sharpness measure on that
|
|
196
|
+
* crop (the ID cutout) so dark surroundings outside the card do not falsely reject the shot.
|
|
197
|
+
* `cropRect` (e.g. the zoomed visible region) limits the JPEG to what the user saw.
|
|
198
|
+
*/
|
|
199
|
+
declare function captureVideoFrame(source: FrameSource, maxSide?: number, qualityRect?: GuideRect, cropRect?: GuideRect): Promise<{
|
|
200
|
+
blob: Blob;
|
|
201
|
+
quality: ImageQuality;
|
|
202
|
+
}>;
|
|
203
|
+
|
|
204
|
+
/** Capture "done" cue + session mute for KYC stages. */
|
|
205
|
+
declare const CAPTURE_MUTE_KEY = "kyc-capture-muted";
|
|
206
|
+
declare function isCaptureMuted(storage?: Storage | null): boolean;
|
|
207
|
+
declare function setCaptureMuted(muted: boolean, storage?: Storage | null): void;
|
|
208
|
+
/** 16-bit mono PCM WAV of a decaying sine (silence when `amplitude` is 0). */
|
|
209
|
+
declare function toneWavDataUri(frequency: number, durationSec: number, amplitude: number): string;
|
|
210
|
+
/**
|
|
211
|
+
* Call synchronously inside a Start tap. iOS only lets a media element play without a gesture
|
|
212
|
+
* after it played once inside one, and Web Audio is muted by the silent switch while media
|
|
213
|
+
* elements are not — so the cue is one `<audio>` element unlocked here with a silent clip.
|
|
214
|
+
*/
|
|
215
|
+
declare function primeCaptureAudio(): void;
|
|
216
|
+
/** Short success beep. No-op when muted or when media playback is unavailable. */
|
|
217
|
+
declare function playCaptureBeep(options?: {
|
|
218
|
+
muted?: boolean;
|
|
219
|
+
}): void;
|
|
220
|
+
/** Test helper — drop the shared element between suites. */
|
|
221
|
+
declare function resetCaptureAudioForTests(): void;
|
|
222
|
+
|
|
223
|
+
type CaptureStageProps = {
|
|
224
|
+
/** Visible step label, e.g. "Front of ID". */
|
|
225
|
+
stepLabel: string;
|
|
226
|
+
/** Pill overlay label for full-bleed capture (e.g. "Frente de tu INE"). */
|
|
227
|
+
pillLabel?: string;
|
|
228
|
+
/** Simple progress like "1 / 2". */
|
|
229
|
+
progressLabel?: string;
|
|
230
|
+
/** Live status for screen readers + status strip. */
|
|
231
|
+
statusText: string;
|
|
232
|
+
/** assertive after capture, polite while guiding. */
|
|
233
|
+
statusPoliteness?: "polite" | "assertive";
|
|
234
|
+
muted: boolean;
|
|
235
|
+
onMutedChange: (muted: boolean) => void;
|
|
236
|
+
muteLabel: string;
|
|
237
|
+
unmuteLabel: string;
|
|
238
|
+
helpLabel?: string;
|
|
239
|
+
helpTitle?: string;
|
|
240
|
+
helpTips?: string[];
|
|
241
|
+
helpIllustrationSrc?: string;
|
|
242
|
+
children: ReactNode;
|
|
243
|
+
/** Focus the status region when the step mounts. */
|
|
244
|
+
autoFocusStatus?: boolean;
|
|
245
|
+
/** Full-bleed dark chrome (hides surrounding card chrome). */
|
|
246
|
+
fullBleed?: boolean;
|
|
247
|
+
className?: string;
|
|
248
|
+
};
|
|
249
|
+
declare function readInitialCaptureMute(): boolean;
|
|
250
|
+
declare function persistCaptureMute(muted: boolean): void;
|
|
251
|
+
/** `?kycDebug=1` on `/kyc`: live capture numbers for tuning on real phones. */
|
|
252
|
+
declare function readCaptureDebugFlag(): boolean;
|
|
253
|
+
/** Small monospace overlay for `?kycDebug=1`; English only, never shown without the flag. */
|
|
254
|
+
declare function CaptureDebugReadout({ lines }: {
|
|
255
|
+
lines: string[];
|
|
256
|
+
}): react.JSX.Element;
|
|
257
|
+
/** Full-bleed dark capture chrome with status strip, mute toggle, and step label. */
|
|
258
|
+
declare function CaptureStage({ stepLabel, pillLabel, progressLabel, statusText, statusPoliteness, muted, onMutedChange, muteLabel, unmuteLabel, helpLabel, helpTitle, helpTips, helpIllustrationSrc, children, autoFocusStatus, fullBleed, className, }: CaptureStageProps): react.JSX.Element;
|
|
259
|
+
/** "Done" badge over the stage so a completed capture reads even with the sound off. */
|
|
260
|
+
declare function CaptureCheck({ reduceMotion }: {
|
|
261
|
+
reduceMotion: boolean;
|
|
262
|
+
}): react.JSX.Element;
|
|
263
|
+
type ProgressRingProps = {
|
|
264
|
+
progress: number;
|
|
265
|
+
size?: number;
|
|
266
|
+
stroke?: number;
|
|
267
|
+
children?: ReactNode;
|
|
268
|
+
className?: string;
|
|
269
|
+
};
|
|
270
|
+
/** Circular progress around the shutter (0..1). */
|
|
271
|
+
declare function CaptureProgressRing({ progress, size, stroke, children, className, }: ProgressRingProps): react.JSX.Element;
|
|
272
|
+
|
|
273
|
+
/** All user-facing strings for ID capture (injected by portal/app i18n). */
|
|
274
|
+
type IdCaptureLabels = {
|
|
275
|
+
stepFront: string;
|
|
276
|
+
stepBack: string;
|
|
277
|
+
frontHint: string;
|
|
278
|
+
backHint: string;
|
|
279
|
+
briefingTip: string;
|
|
280
|
+
startCamera: string;
|
|
281
|
+
cameraOpening: string;
|
|
282
|
+
confirmPhoto: string;
|
|
283
|
+
acceptPhoto: string;
|
|
284
|
+
discardPhoto: string;
|
|
285
|
+
previewAlt: string;
|
|
286
|
+
frontCameraLabel: string;
|
|
287
|
+
backCameraLabel: string;
|
|
288
|
+
shutter: string;
|
|
289
|
+
fileFallback: string;
|
|
290
|
+
fileFallbackAlt: string;
|
|
291
|
+
retakeClearer: string;
|
|
292
|
+
captureFailed: string;
|
|
293
|
+
softPhotoWarning: string;
|
|
294
|
+
uploadingSecurely: string;
|
|
295
|
+
captureHelp: string;
|
|
296
|
+
captureHelpTitle: string;
|
|
297
|
+
captureHelpFlat: string;
|
|
298
|
+
captureHelpLight: string;
|
|
299
|
+
captureHelpEdges: string;
|
|
300
|
+
captureHelpGlare: string;
|
|
301
|
+
muteSound: string;
|
|
302
|
+
unmuteSound: string;
|
|
303
|
+
holdStill: string;
|
|
304
|
+
focusing: string;
|
|
305
|
+
alignCard: string;
|
|
306
|
+
tooDark: string;
|
|
307
|
+
capturing: string;
|
|
308
|
+
photoCaptured: string;
|
|
309
|
+
autoCaptureHint: string;
|
|
310
|
+
};
|
|
311
|
+
type IdCaptureProps = {
|
|
312
|
+
slot: "id_front" | "id_back";
|
|
313
|
+
labels: IdCaptureLabels;
|
|
314
|
+
onCaptured: (blob: Blob, fileName: string) => void;
|
|
315
|
+
onBusyChange?: (busy: boolean) => void;
|
|
316
|
+
/** Notify host chrome when full-bleed live/confirm starts or ends. */
|
|
317
|
+
onFullBleedChange?: (fullBleed: boolean) => void;
|
|
318
|
+
/** Tip illustration URL (e.g. `/illustrations/kyc-id-front-tips.png`). */
|
|
319
|
+
illustrationSrc: string;
|
|
320
|
+
/** Server upload in flight after Accept. */
|
|
321
|
+
uploading?: boolean;
|
|
322
|
+
/** Pill label for full-bleed capture (e.g. Frente de tu INE). */
|
|
323
|
+
pillLabel?: string;
|
|
324
|
+
/** Injected sampler for tests. */
|
|
325
|
+
sampleQuality?: typeof sampleVideoQuality;
|
|
326
|
+
};
|
|
327
|
+
declare function IdCapture({ slot, labels, onCaptured, onBusyChange, onFullBleedChange, illustrationSrc, uploading, pillLabel, sampleQuality, }: IdCaptureProps): react.JSX.Element;
|
|
328
|
+
/** @deprecated Prefer {@link IdCapture}; kept as alias for gradual migration. */
|
|
329
|
+
declare const KycIdCapture: typeof IdCapture;
|
|
330
|
+
|
|
331
|
+
/** Encode bytes for WAV data-URI / document upload helpers. */
|
|
332
|
+
declare function bytesToBase64(bytes: Uint8Array): string;
|
|
333
|
+
|
|
334
|
+
export { AUTO_CAPTURE_READY_COUNT, AUTO_CAPTURE_SAMPLE_HZ, AutoCaptureController, CAPTURE_MUTE_KEY, CaptureCheck, CaptureDebugReadout, CaptureProgressRing, CaptureStage, EDGE_BAND_X, EDGE_BAND_Y, EDGE_MIN_CONTRAST, EDGE_MIN_STRENGTH, EDGE_SEGMENTS, EDGE_SEGMENTS_NEEDED, EDGE_SPAN, FOCUS_PLATEAU_RATIO, FOCUS_SETTLE_SAMPLES, FOCUS_WINDOW_MS, type FrameSource, GUIDE_EDGE_MARGIN, GUIDE_INTERIOR_INSET, GUIDE_SAMPLE_WIDTH, type GuideQuality, type GuideRect, ID_CARD_ASPECT, ID_PREVIEW_ZOOM, IdCapture, type IdCaptureLabels, type IdCaptureProps, type IdGuideLayout, type ImageQuality, KYC_BLUR_MIN, KYC_DARK_MAX_MEAN, KYC_IMAGE_MAX_SIDE, KYC_SHARPNESS_MIN, KycIdCapture, SHARPEST_FRAME_MAX_AGE_MS, SHARPNESS_SAMPLE_WIDTH, SharpestFrame, assessGrayPixels, assessImageData, assessSharpness, bytesToBase64, captureVideoFrame, countGuideEdges, defaultIdGuideRect, idGuideLayout, idGuideRectForCoveredStage, isCaptureMuted, objectCoverVisibleRect, persistCaptureMute, pickRecorderMime, playCaptureBeep, prefersReducedMotion, prepareIdJpeg, primeCaptureAudio, readCaptureDebugFlag, readInitialCaptureMute, recorderExtension, requestContinuousFocus, resetCaptureAudioForTests, rgbaToGray, sampleGuideSharpness, sampleVideoQuality, setCaptureMuted, toneWavDataUri };
|