idmission-web-sdk 2.3.113 → 2.3.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/components/common/debug.d.ts +1 -1
  2. package/dist/components/common/debug.d.ts.map +1 -1
  3. package/dist/components/selfie_capture/SelfieGuidanceModelsProvider.d.ts.map +1 -1
  4. package/dist/components/video_id/IdVideoCaptureWizard.d.ts.map +1 -1
  5. package/dist/components/video_signature_capture/VideoSignatureCapture.d.ts.map +1 -1
  6. package/dist/components/video_signature_capture/VideoSignatureContext.d.ts +2 -0
  7. package/dist/components/video_signature_capture/VideoSignatureContext.d.ts.map +1 -1
  8. package/dist/components/video_signature_capture/VideoSignatureGuides.d.ts.map +1 -1
  9. package/dist/components/video_signature_capture/VideoSignatureWizard.d.ts.map +1 -1
  10. package/dist/lib/camera/useVideoRecorder.d.ts.map +1 -1
  11. package/dist/lib/models/DocumentDetection.d.ts +2 -1
  12. package/dist/lib/models/DocumentDetection.d.ts.map +1 -1
  13. package/dist/lib/models/FaceDetection.d.ts +5 -4
  14. package/dist/lib/models/FaceDetection.d.ts.map +1 -1
  15. package/dist/lib/models/defaults/DocumentDetector.d.ts +2 -2
  16. package/dist/sdk2.cjs.development.js +142 -212
  17. package/dist/sdk2.cjs.development.js.map +1 -1
  18. package/dist/sdk2.cjs.production.js +1 -1
  19. package/dist/sdk2.cjs.production.js.map +1 -1
  20. package/dist/sdk2.esm.js +143 -213
  21. package/dist/sdk2.esm.js.map +1 -1
  22. package/dist/sdk2.umd.development.js +142 -212
  23. package/dist/sdk2.umd.development.js.map +1 -1
  24. package/dist/sdk2.umd.production.js +1 -1
  25. package/dist/sdk2.umd.production.js.map +1 -1
  26. package/dist/version.d.ts +1 -1
  27. package/package.json +3 -3
@@ -236,7 +236,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
236
236
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
237
237
  };
238
238
 
239
- var webSdkVersion = '2.3.113';
239
+ var webSdkVersion = '2.3.115';
240
240
 
241
241
  function getPlatform() {
242
242
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2379,8 +2379,8 @@ function giveUpAfter(maxTime) {
2379
2379
 
2380
2380
  var DEFAULT_CDN_URL = 'https://websdk-cdn-dev.idmission.com/assets';
2381
2381
 
2382
- var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20250815_115859.tflite");
2383
- var defaultDocumentDetectorModelHash = '64LSaO2ctQsTkGJoZ6Et4v2KH28Fz1ettgkxD+qFg6frxY7ufL9l/lkjw2ljX2cR';
2382
+ var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20251018_121234.tflite");
2383
+ var defaultDocumentDetectorModelHash = 'cTLjb4g6H+a+RHnLaYrvVF8050qv/Ox04rMtxFXBDR6Xv8Pv+X//hsaO3K3jNPog';
2384
2384
 
2385
2385
  var defaultFocusModelPath = "".concat(DEFAULT_CDN_URL, "/models/Focus/Focus-20241008_102708.tflite");
2386
2386
  var defaultFocusModelHash = 'HTJNLB7QybtPXIIyUI9oNqW40vE5bgSV5V24R1wXLQHknNEVOSyDQDo/QzRgJ8jb';
@@ -2697,8 +2697,8 @@ var documentTypeDisplayNames = {
2697
2697
  singlePage: 'Single page',
2698
2698
  none: 'None'
2699
2699
  };
2700
- var detector$1 = null;
2701
- var detectorSettings$1 = null;
2700
+ var detector = null;
2701
+ var detectorSettings = null;
2702
2702
  function loadDocumentDetector() {
2703
2703
  return __awaiter(this, arguments, void 0, function (modelAssetPath, scoreThreshold) {
2704
2704
  var _a, _b;
@@ -2711,7 +2711,7 @@ function loadDocumentDetector() {
2711
2711
  return __generator(this, function (_c) {
2712
2712
  switch (_c.label) {
2713
2713
  case 0:
2714
- if (detector$1 && (detectorSettings$1 === null || detectorSettings$1 === void 0 ? void 0 : detectorSettings$1.modelAssetPath) === modelAssetPath && (detectorSettings$1 === null || detectorSettings$1 === void 0 ? void 0 : detectorSettings$1.scoreThreshold) === scoreThreshold) return [2 /*return*/, detector$1];
2714
+ if (detector && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.modelAssetPath) === modelAssetPath && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.scoreThreshold) === scoreThreshold) return [2 /*return*/, detector];
2715
2715
  closeDocumentDetector();
2716
2716
  return [4 /*yield*/, preloadDocumentDetectorDependencies()];
2717
2717
  case 1:
@@ -2732,20 +2732,20 @@ function loadDocumentDetector() {
2732
2732
  runningMode: 'VIDEO'
2733
2733
  }])];
2734
2734
  case 3:
2735
- detector$1 = _c.sent();
2736
- detectorSettings$1 = {
2735
+ detector = _c.sent();
2736
+ detectorSettings = {
2737
2737
  modelAssetPath: modelAssetPath,
2738
2738
  scoreThreshold: scoreThreshold
2739
2739
  };
2740
- return [2 /*return*/, detector$1];
2740
+ return [2 /*return*/, detector];
2741
2741
  }
2742
2742
  });
2743
2743
  });
2744
2744
  }
2745
2745
  function closeDocumentDetector() {
2746
- detector$1 === null || detector$1 === void 0 ? void 0 : detector$1.close();
2747
- detector$1 = null;
2748
- detectorSettings$1 = null;
2746
+ detector === null || detector === void 0 ? void 0 : detector.close();
2747
+ detector = null;
2748
+ detectorSettings = null;
2749
2749
  }
2750
2750
  function useLoadDocumentDetector(_a) {
2751
2751
  var _b = _a.shouldLoadModels,
@@ -2846,12 +2846,12 @@ function makeDocumentDetectorPrediction(frame) {
2846
2846
  return __awaiter(this, void 0, void 0, function () {
2847
2847
  var startedAt, prediction, time, frameWidth, frameHeight;
2848
2848
  return __generator(this, function (_a) {
2849
- if (!detector$1) return [2 /*return*/, null];
2849
+ if (!detector) return [2 /*return*/, null];
2850
2850
  startedAt = performance.now();
2851
2851
  // Detectors can throw errors, for example when using custom URLs that
2852
2852
  // contain a model that doesn't provide the expected output.
2853
2853
  try {
2854
- prediction = detector$1.detectForVideo(frame, performance.now());
2854
+ prediction = detector.detectForVideo(frame, performance.now());
2855
2855
  time = performance.now() - startedAt;
2856
2856
  frameWidth = frame.width;
2857
2857
  frameHeight = frame.height;
@@ -6831,6 +6831,7 @@ function SelfieCaptureFaceKeypoint(_a) {
6831
6831
  scaledHeight = _c.scaledHeight,
6832
6832
  xOffset = _c.xOffset,
6833
6833
  yOffset = _c.yOffset;
6834
+ if (!point) return /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null);
6834
6835
  var left, top;
6835
6836
  if (horizontal) {
6836
6837
  left = point.x / videoWidth * scaledWidth - xOffset;
@@ -11905,136 +11906,6 @@ var FaceCaptureGuideOverlay = function FaceCaptureGuideOverlay(_a) {
11905
11906
  var templateObject_1$n, templateObject_2$l;
11906
11907
 
11907
11908
  var defaultSelfieCaptureModelLoadTimeoutMs = 45000;
11908
- var detector = null;
11909
- var detectorSettings = null;
11910
- function loadFaceDetector() {
11911
- return __awaiter(this, arguments, void 0, function (modelAssetPath) {
11912
- var _a, _b;
11913
- if (modelAssetPath === void 0) {
11914
- modelAssetPath = defaultFaceDetectorModelPath;
11915
- }
11916
- return __generator(this, function (_c) {
11917
- switch (_c.label) {
11918
- case 0:
11919
- if (detector && (detectorSettings === null || detectorSettings === void 0 ? void 0 : detectorSettings.modelAssetPath) === modelAssetPath) return [2 /*return*/, detector];
11920
- closeFaceDetector();
11921
- return [4 /*yield*/, preloadFaceDetectorDependencies()];
11922
- case 1:
11923
- _c.sent();
11924
- if (modelCapabilities.delegate === 'NONE') {
11925
- throw new Error('No available delegate for face detector.');
11926
- }
11927
- _b = (_a = tasksVision.FaceDetector).createFromOptions;
11928
- return [4 /*yield*/, tasksVision.FilesetResolver.forVisionTasks(visionTasksBasePath)];
11929
- case 2:
11930
- return [4 /*yield*/, _b.apply(_a, [_c.sent(), {
11931
- // canvas: document.createElement('canvas'),
11932
- baseOptions: {
11933
- modelAssetPath: modelAssetPath,
11934
- delegate: modelCapabilities.delegate
11935
- },
11936
- runningMode: 'VIDEO'
11937
- }])];
11938
- case 3:
11939
- detector = _c.sent();
11940
- detectorSettings = {
11941
- modelAssetPath: modelAssetPath
11942
- };
11943
- return [2 /*return*/, detector];
11944
- }
11945
- });
11946
- });
11947
- }
11948
- function closeFaceDetector() {
11949
- detector === null || detector === void 0 ? void 0 : detector.close();
11950
- detector = null;
11951
- detectorSettings = null;
11952
- }
11953
- function useLoadFaceDetector(_a) {
11954
- var onModelError = _a.onModelError,
11955
- _b = _a.modelLoadTimeoutMs,
11956
- modelLoadTimeoutMs = _b === void 0 ? defaultSelfieCaptureModelLoadTimeoutMs : _b,
11957
- videoRef = _a.videoRef;
11958
- var _c = React.useState('not-started'),
11959
- modelLoadState = _c[0],
11960
- setModelLoadState = _c[1];
11961
- var _d = React.useState(0),
11962
- modelDownloadProgress = _d[0],
11963
- setModelDownloadProgress = _d[1];
11964
- var _e = React.useState(null),
11965
- modelWarmingStartedAt = _e[0],
11966
- setModelWarmingStartedAt = _e[1];
11967
- var _f = React.useState(null),
11968
- modelError = _f[0],
11969
- setModelError = _f[1];
11970
- React.useEffect(function loadModel() {
11971
- var _this = this;
11972
- setModelLoadState('downloading');
11973
- setModelWarmingStartedAt(null);
11974
- var modelLoadTimeout = setTimeout(function () {
11975
- setModelError(new Error('Model loading time limit exceeded.'));
11976
- }, modelLoadTimeoutMs);
11977
- function handleDownloadProgress(event) {
11978
- setModelDownloadProgress(progressToPercentage(event.detail));
11979
- }
11980
- document.addEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
11981
- var cancelVideoReady = function cancelVideoReady() {};
11982
- loadFaceDetector().then(function (model) {
11983
- return __awaiter(_this, void 0, void 0, function () {
11984
- var _a, videoReady, cancel, cancelled;
11985
- return __generator(this, function (_b) {
11986
- switch (_b.label) {
11987
- case 0:
11988
- setModelDownloadProgress(100);
11989
- clearTimeout(modelLoadTimeout);
11990
- setModelLoadState('warming');
11991
- setModelWarmingStartedAt(performance.now());
11992
- return [4 /*yield*/, testFaceDetectionAgainstKnownImage(model)];
11993
- case 1:
11994
- _b.sent();
11995
- _a = waitForVideoReady(videoRef), videoReady = _a[0], cancel = _a[1];
11996
- cancelled = false;
11997
- cancelVideoReady = function cancelVideoReady() {
11998
- cancelled = true;
11999
- cancel();
12000
- };
12001
- return [4 /*yield*/, videoReady];
12002
- case 2:
12003
- _b.sent();
12004
- if (cancelled) return [2 /*return*/];
12005
- model.detectForVideo(videoRef.current, performance.now());
12006
- setModelLoadState('ready');
12007
- return [2 /*return*/];
12008
- }
12009
- });
12010
- });
12011
- })["catch"](function (e) {
12012
- setModelError(e);
12013
- setModelLoadState('error');
12014
- })["finally"](function () {
12015
- clearTimeout(modelLoadTimeout);
12016
- });
12017
- return function () {
12018
- log('unloading face detection model');
12019
- cancelVideoReady();
12020
- closeFaceDetector();
12021
- clearTimeout(modelLoadTimeout);
12022
- document.removeEventListener('idmission.preloadProgress.faceDetection', handleDownloadProgress);
12023
- };
12024
- }, [modelLoadTimeoutMs, videoRef]);
12025
- React.useEffect(function handleModelError() {
12026
- if (modelError) onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError);
12027
- }, [modelError, onModelError]);
12028
- return React.useMemo(function () {
12029
- return {
12030
- ready: modelLoadState === 'ready',
12031
- modelLoadState: modelLoadState,
12032
- modelDownloadProgress: modelDownloadProgress,
12033
- modelWarmingStartedAt: modelWarmingStartedAt,
12034
- modelError: modelError
12035
- };
12036
- }, [modelLoadState, modelDownloadProgress, modelWarmingStartedAt, modelError]);
12037
- }
12038
11909
  var lastFaceDetectionAt = 0;
12039
11910
  var lastFaceDetectionTime = 0;
12040
11911
  function setLastFaceDetectionAt(time) {
@@ -12084,24 +11955,68 @@ function trackFace(face, framesNeeded, frameWidth, frameHeight) {
12084
11955
  if (lastNNosePairs.length > framesNeeded - 1) lastNNosePairs.length = framesNeeded - 1;
12085
11956
  }
12086
11957
  }
12087
- function makeFaceDetectorPrediction(imageData) {
12088
- if (!detector) return null;
12089
- var prediction = detector.detectForVideo(imageData, performance.now());
12090
- var faces = prediction.detections.map(function (d) {
12091
- return {
12092
- box: convertBoundingBox(d.boundingBox),
12093
- keypoints: d.keypoints.map(function (k) {
12094
- var _a;
12095
- return _assign(_assign({}, k), {
12096
- x: k.x * imageData.width,
12097
- y: k.y * imageData.height,
12098
- name: (_a = k.label) !== null && _a !== void 0 ? _a : ''
12099
- });
12100
- })
12101
- };
11958
+ function isFaceDetection(detection) {
11959
+ return detection.boundingBox && detection.categories.some(function (c) {
11960
+ return c.categoryName === 'Primary face' || c.categoryName === 'Secondary face';
12102
11961
  });
12103
- return _assign(_assign({}, prediction), {
12104
- faces: faces
11962
+ }
11963
+ function isNoseDetection(detection) {
11964
+ return detection.categories.some(function (c) {
11965
+ return c.categoryName === 'Nose';
11966
+ });
11967
+ }
11968
+ function makeFacePredictionWithDocumentDetector(frame) {
11969
+ return __awaiter(this, void 0, void 0, function () {
11970
+ var prediction, faceDetections, noseDetections, _i, _a, detection, faces, _b, faceDetections_1, d, faceBox, nose, _c, noseDetections_1, n, noseBox, cX, cY;
11971
+ return __generator(this, function (_d) {
11972
+ switch (_d.label) {
11973
+ case 0:
11974
+ return [4 /*yield*/, makeDocumentDetectorPrediction(frame)];
11975
+ case 1:
11976
+ prediction = _d.sent();
11977
+ if (!prediction) return [2 /*return*/, null];
11978
+ faceDetections = [];
11979
+ noseDetections = [];
11980
+ for (_i = 0, _a = prediction.detections; _i < _a.length; _i++) {
11981
+ detection = _a[_i];
11982
+ if (isNoseDetection(detection)) {
11983
+ noseDetections.push(detection);
11984
+ } else if (isFaceDetection(detection)) {
11985
+ faceDetections.push(detection);
11986
+ }
11987
+ }
11988
+ faces = [];
11989
+ for (_b = 0, faceDetections_1 = faceDetections; _b < faceDetections_1.length; _b++) {
11990
+ d = faceDetections_1[_b];
11991
+ faceBox = d.boundingBox;
11992
+ if (!faceBox) continue;
11993
+ nose = null;
11994
+ for (_c = 0, noseDetections_1 = noseDetections; _c < noseDetections_1.length; _c++) {
11995
+ n = noseDetections_1[_c];
11996
+ noseBox = n.boundingBox;
11997
+ if (!noseBox) continue;
11998
+ cX = noseBox.originX + noseBox.width / 2;
11999
+ cY = noseBox.originY + noseBox.height / 2;
12000
+ if (cX >= faceBox.originX && cX <= faceBox.originX + faceBox.width && cY >= faceBox.originY && cY <= faceBox.originY + faceBox.height) {
12001
+ nose = {
12002
+ x: cX,
12003
+ y: cY,
12004
+ name: 'nose'
12005
+ };
12006
+ break;
12007
+ }
12008
+ }
12009
+ faces.push({
12010
+ box: convertBoundingBox(d.boundingBox),
12011
+ keypoints: [null, null, nose, null, null]
12012
+ });
12013
+ }
12014
+ debug('faces', faces);
12015
+ return [2 /*return*/, _assign(_assign({}, prediction), {
12016
+ faces: faces
12017
+ })];
12018
+ }
12019
+ });
12105
12020
  });
12106
12021
  }
12107
12022
  function processFaceDetectorPrediction(_a) {
@@ -12129,13 +12044,9 @@ function processFaceDetectorPrediction(_a) {
12129
12044
  // this represents the edge that the centroid of the face should not cross -- 12.5% of video width
12130
12045
  yCentroidBoundary = _h === void 0 ? 0.125 : _h,
12131
12046
  // this represents the edge that the centroid of the face should not cross -- 12.5% of video height
12132
- _j = _a.foreheadRatio,
12047
+ _j = _a.noseTrackingThreshold,
12133
12048
  // this represents the edge that the centroid of the face should not cross -- 12.5% of video height
12134
- foreheadRatio = _j === void 0 ? 0.275 : _j,
12135
- // we found that the bounding box ends at the brow and misses the forehead. this ratio represents how much we should extend the box to include the forehead.
12136
- _k = _a.noseTrackingThreshold,
12137
- // we found that the bounding box ends at the brow and misses the forehead. this ratio represents how much we should extend the box to include the forehead.
12138
- noseTrackingThreshold = _k === void 0 ? 0.2 : _k,
12049
+ noseTrackingThreshold = _j === void 0 ? 0.2 : _j,
12139
12050
  // this represents the maximum distance that the nose can be from the center of the face box -- 20% of the face box width or height
12140
12051
  minCaptureBrightnessThreshold = _a.minCaptureBrightnessThreshold,
12141
12052
  minCaptureRangeThreshold = _a.minCaptureRangeThreshold,
@@ -12162,10 +12073,10 @@ function processFaceDetectorPrediction(_a) {
12162
12073
  var frameCX = videoWidth / 2;
12163
12074
  var frameCY = videoHeight / 2;
12164
12075
  // calculate head bounding box, with forehead extension
12165
- var foreheadSize = face.box.height * foreheadRatio;
12076
+ // const foreheadSize = face.box.height * foreheadRatio
12166
12077
  var headXMin = face.box.xMin;
12167
12078
  var headXMax = face.box.xMax;
12168
- var headYMin = face.box.yMin - foreheadSize;
12079
+ var headYMin = face.box.yMin; // - foreheadSize
12169
12080
  var headYMax = face.box.yMax;
12170
12081
  // calculate head centroids
12171
12082
  var headCX = (headXMin + headXMax) / 2;
@@ -12221,26 +12132,6 @@ function processFaceDetectorPrediction(_a) {
12221
12132
  faceVisibilityTooLow: faceVisibilityTooLow
12222
12133
  };
12223
12134
  }
12224
- function testFaceDetectionAgainstKnownImage(detector) {
12225
- return new Promise(function (resolve, reject) {
12226
- var img = new Image();
12227
- img.crossOrigin = 'anonymous';
12228
- img.onload = function () {
12229
- var prediction = detector.detectForVideo(img, performance.now());
12230
- if (prediction.detections.length > 0) {
12231
- debug('face detection test result', prediction.detections);
12232
- resolve(void 0);
12233
- } else {
12234
- warn('face detection test failed');
12235
- reject(new Error('testFaceDetectionAgainstKnownImage failed to predict'));
12236
- }
12237
- };
12238
- img.onerror = function () {
12239
- return reject(new Error('testFaceDetectionAgainstKnownImage failed to load image'));
12240
- };
12241
- img.src = "".concat(DEFAULT_CDN_URL, "/head-test.jpg");
12242
- });
12243
- }
12244
12135
 
12245
12136
  function detectBrightnessAndContrast(frame, brightnessAverager) {
12246
12137
  var ctx = frame.getContext('2d');
@@ -12392,16 +12283,27 @@ function SelfieGuidanceModelsProvider(_a) {
12392
12283
  var canvasRef = React.useRef(null);
12393
12284
  var onPredictionHandler = React.useRef();
12394
12285
  var addToAverage = useRunningAvg(5).addToAverage;
12395
- var _f = useLoadFaceDetector({
12286
+ var _f = useLoadDocumentDetector({
12287
+ videoRef: videoRef,
12396
12288
  onModelError: onModelError,
12397
- modelLoadTimeoutMs: modelLoadTimeoutMs,
12398
- videoRef: videoRef
12289
+ modelLoadTimeoutMs: modelLoadTimeoutMs
12399
12290
  }),
12400
12291
  ready = _f.ready,
12401
12292
  modelLoadState = _f.modelLoadState,
12402
12293
  modelDownloadProgress = _f.modelDownloadProgress,
12403
12294
  modelWarmingStartedAt = _f.modelWarmingStartedAt,
12404
12295
  modelError = _f.modelError;
12296
+ // const {
12297
+ // ready,
12298
+ // modelLoadState,
12299
+ // modelDownloadProgress,
12300
+ // modelWarmingStartedAt,
12301
+ // modelError,
12302
+ // } = useLoadFaceDetector({
12303
+ // onModelError,
12304
+ // modelLoadTimeoutMs,
12305
+ // videoRef,
12306
+ // })
12405
12307
  var _g = useFrameLoop(React.useCallback(function () {
12406
12308
  return __awaiter(_this, void 0, void 0, function () {
12407
12309
  var vw, vh, ctx, thresholdsProvided, brightnessResults, brightness, range, variance, prediction, processed, e_1;
@@ -12415,19 +12317,21 @@ function SelfieGuidanceModelsProvider(_a) {
12415
12317
  ctx = canvasRef.current.getContext('2d');
12416
12318
  canvasRef.current.width = vw;
12417
12319
  canvasRef.current.height = vh;
12418
- if (!(ctx && videoRef.current.readyState === 4)) return [3 /*break*/, 4];
12320
+ if (!(ctx && videoRef.current.readyState === 4)) return [3 /*break*/, 5];
12419
12321
  ctx.translate(vw, 0);
12420
12322
  ctx.scale(-1, 1);
12421
12323
  ctx.drawImage(videoRef.current, 0, 0, vw, vh);
12422
12324
  _c.label = 1;
12423
12325
  case 1:
12424
- _c.trys.push([1, 3,, 4]);
12326
+ _c.trys.push([1, 4,, 5]);
12425
12327
  thresholdsProvided = minCaptureBrightnessThreshold !== undefined || minCaptureRangeThreshold !== undefined || minCaptureVarianceThreshold !== undefined;
12426
12328
  brightnessResults = thresholdsProvided ? detectBrightnessAndContrast(canvasRef.current, addToAverage) : undefined;
12427
12329
  brightness = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.brightness;
12428
12330
  range = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.range;
12429
12331
  variance = brightnessResults === null || brightnessResults === void 0 ? void 0 : brightnessResults.variance;
12430
- prediction = makeFaceDetectorPrediction(canvasRef.current);
12332
+ return [4 /*yield*/, makeFacePredictionWithDocumentDetector(canvasRef.current)];
12333
+ case 2:
12334
+ prediction = _c.sent();
12431
12335
  processed = processFaceDetectorPrediction({
12432
12336
  faces: (_a = prediction === null || prediction === void 0 ? void 0 : prediction.faces) !== null && _a !== void 0 ? _a : [],
12433
12337
  videoWidth: vw,
@@ -12443,15 +12347,15 @@ function SelfieGuidanceModelsProvider(_a) {
12443
12347
  setLastFaceDetectionAt(new Date().getTime());
12444
12348
  // setLastPrediction(processed)
12445
12349
  return [4 /*yield*/, (_b = onPredictionHandler.current) === null || _b === void 0 ? void 0 : _b.call(onPredictionHandler, processed)];
12446
- case 2:
12350
+ case 3:
12447
12351
  // setLastPrediction(processed)
12448
12352
  _c.sent();
12449
- return [3 /*break*/, 4];
12450
- case 3:
12353
+ return [3 /*break*/, 5];
12354
+ case 4:
12451
12355
  e_1 = _c.sent();
12452
12356
  error('caught face detection error', e_1);
12453
- return [3 /*break*/, 4];
12454
- case 4:
12357
+ return [3 /*break*/, 5];
12358
+ case 5:
12455
12359
  return [2 /*return*/];
12456
12360
  }
12457
12361
  });
@@ -14489,7 +14393,7 @@ var useVideoSignatureStore = zustand.create()(middleware.devtools(function (set,
14489
14393
  _a.sent();
14490
14394
  signatureRecorder.onstop = function () {
14491
14395
  return __awaiter(_this, void 0, void 0, function () {
14492
- var recordingStoppedAt, mimeType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, recordingStopRequestedAt, lastChunkReceivedAt, supportsRequestVideoFrameCallback, supportsRoundRect;
14396
+ var recordingStoppedAt, mimeType, blob, _a, onSignatureVideoCaptured, recordingStartRequestedAt, recordingStartedAt, firstChunkReceivedAt, signatureStartedAt, signatureEndedAt, acceptClickedAt, recordingStopRequestedAt, lastChunkReceivedAt, supportsRequestVideoFrameCallback, supportsRoundRect;
14493
14397
  return __generator(this, function (_b) {
14494
14398
  recordingStoppedAt = performance.now();
14495
14399
  set({
@@ -14501,7 +14405,7 @@ var useVideoSignatureStore = zustand.create()(middleware.devtools(function (set,
14501
14405
  });
14502
14406
  signatureChunks = [];
14503
14407
  signatureRecorder = null;
14504
- _a = get(), onSignatureVideoCaptured = _a.onSignatureVideoCaptured, recordingStartRequestedAt = _a.recordingStartRequestedAt, recordingStartedAt = _a.recordingStartedAt, firstChunkReceivedAt = _a.firstChunkReceivedAt, signatureStartedAt = _a.signatureStartedAt, signatureEndedAt = _a.signatureEndedAt, recordingStopRequestedAt = _a.recordingStopRequestedAt, lastChunkReceivedAt = _a.lastChunkReceivedAt, supportsRequestVideoFrameCallback = _a.supportsRequestVideoFrameCallback, supportsRoundRect = _a.supportsRoundRect;
14408
+ _a = get(), onSignatureVideoCaptured = _a.onSignatureVideoCaptured, recordingStartRequestedAt = _a.recordingStartRequestedAt, recordingStartedAt = _a.recordingStartedAt, firstChunkReceivedAt = _a.firstChunkReceivedAt, signatureStartedAt = _a.signatureStartedAt, signatureEndedAt = _a.signatureEndedAt, acceptClickedAt = _a.acceptClickedAt, recordingStopRequestedAt = _a.recordingStopRequestedAt, lastChunkReceivedAt = _a.lastChunkReceivedAt, supportsRequestVideoFrameCallback = _a.supportsRequestVideoFrameCallback, supportsRoundRect = _a.supportsRoundRect;
14505
14409
  onSignatureVideoCaptured(blob, signatureData !== null && signatureData !== void 0 ? signatureData : null, imageUrl !== null && imageUrl !== void 0 ? imageUrl : null, {
14506
14410
  mimeType: mimeType,
14507
14411
  browserFeatures: {
@@ -14514,6 +14418,7 @@ var useVideoSignatureStore = zustand.create()(middleware.devtools(function (set,
14514
14418
  firstChunkReceivedAt: firstChunkReceivedAt ? Math.ceil(firstChunkReceivedAt) : 0,
14515
14419
  signatureStartedAt: signatureStartedAt ? Math.ceil(signatureStartedAt) : 0,
14516
14420
  signatureEndedAt: signatureEndedAt ? Math.ceil(signatureEndedAt) : 0,
14421
+ acceptClickedAt: acceptClickedAt ? Math.ceil(acceptClickedAt) : 0,
14517
14422
  recordingStopRequestedAt: recordingStopRequestedAt ? Math.ceil(recordingStopRequestedAt) : 0,
14518
14423
  recordingStoppedAt: Math.ceil(recordingStoppedAt),
14519
14424
  lastChunkReceivedAt: lastChunkReceivedAt ? Math.ceil(lastChunkReceivedAt) : 0
@@ -14544,6 +14449,7 @@ var useVideoSignatureStore = zustand.create()(middleware.devtools(function (set,
14544
14449
  signatureValid: false,
14545
14450
  signatureStartedAt: undefined,
14546
14451
  signatureEndedAt: undefined,
14452
+ acceptClickedAt: undefined,
14547
14453
  supportsRequestVideoFrameCallback: undefined,
14548
14454
  supportsRoundRect: undefined
14549
14455
  });
@@ -14851,12 +14757,15 @@ function VideoSignatureGuides(_a) {
14851
14757
  React.useEffect(function () {
14852
14758
  if (guideToDisplay) setMode(guideToDisplay);
14853
14759
  }, [guideToDisplay]);
14854
- var firstChunkReceivedAt = useVideoSignatureStore(shallow.useShallow(function (state) {
14855
- return {
14856
- firstChunkReceivedAt: state.firstChunkReceivedAt
14857
- };
14858
- })).firstChunkReceivedAt;
14859
- var signaturePadDisabled = requestedAction !== 'CAPTURE_SIGNATURE' || !firstChunkReceivedAt;
14760
+ var _h = useVideoSignatureStore(shallow.useShallow(function (state) {
14761
+ return {
14762
+ firstChunkReceivedAt: state.firstChunkReceivedAt,
14763
+ acceptClickedAt: state.acceptClickedAt
14764
+ };
14765
+ })),
14766
+ firstChunkReceivedAt = _h.firstChunkReceivedAt,
14767
+ acceptClickedAt = _h.acceptClickedAt;
14768
+ var signaturePadDisabled = requestedAction !== 'CAPTURE_SIGNATURE' || !firstChunkReceivedAt || !!acceptClickedAt;
14860
14769
  return /*#__PURE__*/React__namespace.default.createElement(Container$3, {
14861
14770
  className: classNames.container
14862
14771
  }, /*#__PURE__*/React__namespace.default.createElement(Inner$1, {
@@ -14983,7 +14892,8 @@ function VideoSignatureCaptureComponent(_a, ref) {
14983
14892
  var rightEdge = videoWidth * (1 - headTrackingBoundaryPercentage);
14984
14893
  var topEdge = videoHeight * headTrackingBoundaryPercentage;
14985
14894
  var bottomEdge = videoHeight * (1 - headTrackingBoundaryPercentage);
14986
- var nearBoundary = !!face && (headTrackingBoundaryType === 'nose' ? face.keypoints[2].x < leftEdge || face.keypoints[2].x > rightEdge || face.keypoints[2].y < topEdge || face.keypoints[2].y > bottomEdge : (face === null || face === void 0 ? void 0 : face.box.xMin) < leftEdge || (face === null || face === void 0 ? void 0 : face.box.xMax) > rightEdge || (face === null || face === void 0 ? void 0 : face.box.yMin) < topEdge || (face === null || face === void 0 ? void 0 : face.box.yMax) > bottomEdge);
14895
+ var nose = face === null || face === void 0 ? void 0 : face.keypoints[2];
14896
+ var nearBoundary = !!face && !!nose && (headTrackingBoundaryType === 'nose' ? nose.x < leftEdge || nose.x > rightEdge || nose.y < topEdge || nose.y > bottomEdge : (face === null || face === void 0 ? void 0 : face.box.xMin) < leftEdge || (face === null || face === void 0 ? void 0 : face.box.xMax) > rightEdge || (face === null || face === void 0 ? void 0 : face.box.yMin) < topEdge || (face === null || face === void 0 ? void 0 : face.box.yMax) > bottomEdge);
14987
14897
  setLastFace(face);
14988
14898
  setHeadTrackingSatisfied(!!face && !nearBoundary);
14989
14899
  setNumFramesWithoutFaces(face ? 0 : function (n) {
@@ -15464,6 +15374,7 @@ function VideoSignatureWizardComponent(_a, ref) {
15464
15374
  return n + 1;
15465
15375
  });
15466
15376
  setCaptureState(skipLivenessValidation ? 'CAPTURING_SELFIE' : 'CHECKING_LIVENESS');
15377
+ useVideoSignatureStore.getState().clearRecordedData();
15467
15378
  }, [onRetryClicked, skipLivenessValidation]);
15468
15379
  var onExitSignatureCapture = React.useCallback(function () {
15469
15380
  setAttempt(function (n) {
@@ -15606,6 +15517,9 @@ function VideoSignatureWizardGuides(_a) {
15606
15517
  props = __rest(_a, ["status", "restartVideoOnSignaturePadCleared", "captureAudio", "component", "showFaceGuideThenSignaturePad"]);
15607
15518
  var Component = component !== null && component !== void 0 ? component : VideoSignatureGuides;
15608
15519
  var onAcceptBtnClicked = React.useCallback(function () {
15520
+ useVideoSignatureStore.setState({
15521
+ acceptClickedAt: performance.now()
15522
+ });
15609
15523
  var signaturePad = useVideoSignatureStore.getState().signaturePad;
15610
15524
  if (!signaturePad.current) throw new Error('Signature pad not found');
15611
15525
  var signatureData = buildSignatureData(signaturePad.current);
@@ -15928,6 +15842,16 @@ var useVideoRecorderStore = zustand.create()(middleware.devtools(function (set,
15928
15842
  clearRecordedData: function clearRecordedData() {
15929
15843
  clearVideoChunks();
15930
15844
  clearAudioChunks();
15845
+ set({
15846
+ videoUrl: null,
15847
+ audioUrl: null,
15848
+ isRecordingVideo: false,
15849
+ isRecordingAudio: false,
15850
+ videoRecordingStopped: false,
15851
+ audioRecordingStopped: false,
15852
+ videoRecordingIntentionallyStopped: false,
15853
+ audioRecordingIntentionallyStopped: false
15854
+ });
15931
15855
  }
15932
15856
  });
15933
15857
  }));
@@ -16210,10 +16134,10 @@ var IdVideoCapture = function IdVideoCapture(_a) {
16210
16134
  var _14 = React.useState(null),
16211
16135
  videoStartsAt = _14[0],
16212
16136
  setVideoStartsAt = _14[1];
16213
- var _15 = React.useContext(SubmissionContext),
16137
+ var _15 = useSubmissionContext(),
16214
16138
  setIdCaptureVideoAudioStartsAt = _15.setIdCaptureVideoAudioStartsAt,
16215
16139
  setExpectedAudioText = _15.setExpectedAudioText;
16216
- var _16 = React.useContext(SelfieGuidanceModelsContext),
16140
+ var _16 = useSelfieGuidanceModelsContext(),
16217
16141
  startSelfieGuidance = _16.start,
16218
16142
  stopSelfieGuidance = _16.stop,
16219
16143
  onSelfiePredictionMade = _16.onPredictionMade,
@@ -16810,6 +16734,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
16810
16734
  return n + 1;
16811
16735
  });
16812
16736
  setCaptureState('CAPTURING_ID');
16737
+ useVideoRecorderStore.getState().clearRecordedData();
16813
16738
  }, []);
16814
16739
  var isCapturingId = !skipIdCapture && ['LOADING', 'CAPTURING_ID'].includes(captureState);
16815
16740
  React.useEffect(function () {
@@ -16844,6 +16769,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
16844
16769
  });
16845
16770
  }, [capturedIdDocumentType, (_b = classNames.idVideoCapture) === null || _b === void 0 ? void 0 : _b.guides, (_c = colors.idVideoCapture) === null || _c === void 0 ? void 0 : _c.guidesSatisfiedColor, (_d = colors.idVideoCapture) === null || _d === void 0 ? void 0 : _d.guidesUnsatisfiedColor, idCaptureGuideImages, (_e = verbiage.idVideoCapture) === null || _e === void 0 ? void 0 : _e.guides]);
16846
16771
  return /*#__PURE__*/React__namespace.default.createElement(CameraStoreProvider, {
16772
+ key: "camera-store-".concat(attempt),
16847
16773
  preferIphoneContinuityCamera: isCapturingId,
16848
16774
  preferFrontFacingCamera: !isCapturingId,
16849
16775
  requireMicrophoneAccess: !isCapturingId && !!readTextPrompt,
@@ -16855,6 +16781,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
16855
16781
  classNames: classNames === null || classNames === void 0 ? void 0 : classNames.cameraStoreProvider,
16856
16782
  verbiage: verbiage === null || verbiage === void 0 ? void 0 : verbiage.cameraStoreProvider
16857
16783
  }, /*#__PURE__*/React__namespace.default.createElement(IdCaptureModelsProvider, {
16784
+ key: "id-capture-models-".concat(attempt),
16858
16785
  autoStart: false,
16859
16786
  documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
16860
16787
  focusModelUrl: (_j = (_h = idCaptureProps.assets) === null || _h === void 0 ? void 0 : _h.focusModelUrl) !== null && _j !== void 0 ? _j : '',
@@ -16862,6 +16789,7 @@ var VideoIdWizard = function VideoIdWizard(_a) {
16862
16789
  modelLoadTimeoutMs: idCaptureModelLoadTimeoutMs,
16863
16790
  allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
16864
16791
  }, /*#__PURE__*/React__namespace.default.createElement(SelfieGuidanceModelsProvider, {
16792
+ key: "selfie-guidance-models-".concat(attempt),
16865
16793
  autoStart: false,
16866
16794
  onModelError: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onModelError,
16867
16795
  modelLoadTimeoutMs: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.modelLoadTimeoutMs,
@@ -16871,7 +16799,9 @@ var VideoIdWizard = function VideoIdWizard(_a) {
16871
16799
  })), function () {
16872
16800
  switch (captureState) {
16873
16801
  case 'CAPTURING_ID':
16874
- return /*#__PURE__*/React__namespace.default.createElement(IdCaptureStateProvider, null, /*#__PURE__*/React__namespace.default.createElement(GuideOrientationContextProvider, null, /*#__PURE__*/React__namespace.default.createElement(IdCaptureWizard, _assign({
16802
+ return /*#__PURE__*/React__namespace.default.createElement(IdCaptureStateProvider, {
16803
+ key: "id-capture-state-".concat(attempt)
16804
+ }, /*#__PURE__*/React__namespace.default.createElement(GuideOrientationContextProvider, null, /*#__PURE__*/React__namespace.default.createElement(IdCaptureWizard, _assign({
16875
16805
  key: "id-capture-".concat(attempt),
16876
16806
  loadingOverlayMode: idCaptureLoadingOverlayMode,
16877
16807
  customOverlayContent: customOverlayContent,