idmission-web-sdk 2.2.64 → 2.2.65

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 (38) hide show
  1. package/dist/components/CompositeWizard.d.ts.map +1 -1
  2. package/dist/components/customer_flows/IdValidation.d.ts +3 -1
  3. package/dist/components/customer_flows/IdValidation.d.ts.map +1 -1
  4. package/dist/components/fallback_flows/IdCapture.d.ts.map +1 -1
  5. package/dist/components/id_capture/CapturedDocuments.d.ts +1 -1
  6. package/dist/components/id_capture/CapturedDocuments.d.ts.map +1 -1
  7. package/dist/components/id_capture/IdCapture.d.ts +2 -2
  8. package/dist/components/id_capture/IdCapture.d.ts.map +1 -1
  9. package/dist/components/id_capture/IdCaptureModelsProvider.d.ts +2 -1
  10. package/dist/components/id_capture/IdCaptureModelsProvider.d.ts.map +1 -1
  11. package/dist/components/id_capture/IdCaptureRequirementOption.d.ts +7 -5
  12. package/dist/components/id_capture/IdCaptureRequirementOption.d.ts.map +1 -1
  13. package/dist/components/id_capture/IdCaptureStateProvider.d.ts +4 -0
  14. package/dist/components/id_capture/IdCaptureStateProvider.d.ts.map +1 -1
  15. package/dist/components/id_capture/IdCaptureSuccess.d.ts +0 -4
  16. package/dist/components/id_capture/IdCaptureSuccess.d.ts.map +1 -1
  17. package/dist/components/id_capture/IdCaptureWizard.d.ts +2 -1
  18. package/dist/components/id_capture/IdCaptureWizard.d.ts.map +1 -1
  19. package/dist/components/video_id/IdVideoCapture.d.ts +2 -0
  20. package/dist/components/video_id/IdVideoCapture.d.ts.map +1 -1
  21. package/dist/components/video_id/IdVideoCaptureWizard.d.ts.map +1 -1
  22. package/dist/lib/models/DocumentDetection.d.ts +6 -2
  23. package/dist/lib/models/DocumentDetection.d.ts.map +1 -1
  24. package/dist/lib/models/Focus.d.ts +4 -0
  25. package/dist/lib/models/Focus.d.ts.map +1 -1
  26. package/dist/lib/models/defaults/DocumentDetector.d.ts +1 -1
  27. package/dist/sdk2.cjs.development.js +357 -327
  28. package/dist/sdk2.cjs.development.js.map +1 -1
  29. package/dist/sdk2.cjs.production.js +1 -1
  30. package/dist/sdk2.cjs.production.js.map +1 -1
  31. package/dist/sdk2.esm.js +357 -327
  32. package/dist/sdk2.esm.js.map +1 -1
  33. package/dist/sdk2.umd.development.js +357 -327
  34. package/dist/sdk2.umd.development.js.map +1 -1
  35. package/dist/sdk2.umd.production.js +1 -1
  36. package/dist/sdk2.umd.production.js.map +1 -1
  37. package/dist/version.d.ts +1 -1
  38. package/package.json +3 -3
@@ -234,7 +234,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
234
234
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
235
235
  };
236
236
 
237
- var webSdkVersion = '2.2.64';
237
+ var webSdkVersion = '2.2.65';
238
238
 
239
239
  function getPlatform() {
240
240
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -2269,7 +2269,7 @@ function average(arr) {
2269
2269
 
2270
2270
  var DEFAULT_CDN_URL = 'https://websdk-cdn-dev.idmission.com/assets';
2271
2271
 
2272
- var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20241018_093000.tflite");
2272
+ var defaultDocumentDetectorModelPath = "".concat(DEFAULT_CDN_URL, "/models/DocumentDetector/DocumentDetector-20241212_131026.tflite");
2273
2273
 
2274
2274
  var defaultFocusModelPath = "".concat(DEFAULT_CDN_URL, "/models/Focus/Focus-20241008_102708.tflite");
2275
2275
 
@@ -2288,6 +2288,10 @@ var defaultFocusThresholds = {
2288
2288
  passport: {
2289
2289
  desktop: 0,
2290
2290
  mobile: 0.3
2291
+ },
2292
+ singlePage: {
2293
+ desktop: 0,
2294
+ mobile: 0.3
2291
2295
  }
2292
2296
  };
2293
2297
  var classifier = null;
@@ -2913,16 +2917,19 @@ var defaultDocumentDetectionThresholds = {
2913
2917
  idCardFront: 0.6,
2914
2918
  idCardBack: 0.6,
2915
2919
  passport: 0.4,
2920
+ singlePage: 0.4,
2916
2921
  stability: {
2917
2922
  idCardFront: 0.85,
2918
2923
  idCardBack: 0.85,
2919
- passport: 0.5
2924
+ passport: 0.5,
2925
+ singlePage: 0.5
2920
2926
  }
2921
2927
  };
2922
2928
  var documentTypeDisplayNames = {
2923
2929
  idCardFront: 'ID card front',
2924
2930
  idCardBack: 'ID card back',
2925
2931
  passport: 'Passport',
2932
+ singlePage: 'Single page',
2926
2933
  none: 'None'
2927
2934
  };
2928
2935
  var detector = null;
@@ -3111,7 +3118,7 @@ var defaultDocumentDetectionBoundaries = {
3111
3118
  right: 20
3112
3119
  };
3113
3120
  function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3114
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
3121
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
3115
3122
  if (boundaries === void 0) {
3116
3123
  boundaries = defaultDocumentDetectionBoundaries;
3117
3124
  }
@@ -3162,18 +3169,25 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3162
3169
  var bestPassportPage = detectedObjects.find(function (obj) {
3163
3170
  return obj.label === 'Passport page';
3164
3171
  });
3172
+ var bestSinglePage = detectedObjects.find(function (obj) {
3173
+ return obj.label === 'Single page';
3174
+ });
3165
3175
  var idCardFrontDetectionScore = (_e = bestIdCardFront === null || bestIdCardFront === void 0 ? void 0 : bestIdCardFront.score) !== null && _e !== void 0 ? _e : 0;
3166
3176
  var idCardBackDetectionScore = (_f = bestIdCardBack === null || bestIdCardBack === void 0 ? void 0 : bestIdCardBack.score) !== null && _f !== void 0 ? _f : 0;
3167
3177
  var passportDetectionScore = (_g = bestPassportPage === null || bestPassportPage === void 0 ? void 0 : bestPassportPage.score) !== null && _g !== void 0 ? _g : 0;
3168
- var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_h = thresholds.idCardFront) !== null && _h !== void 0 ? _h : 0);
3169
- var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_j = thresholds.idCardBack) !== null && _j !== void 0 ? _j : 0);
3170
- var passportDetectionThresholdMet = passportDetectionScore >= ((_k = thresholds.passport) !== null && _k !== void 0 ? _k : 0);
3171
- var bestDocument = passportDetectionThresholdMet ? bestPassportPage : idCardBackDetectionThresholdMet ? bestIdCardBack : bestIdCardFront;
3172
- var detectionThreshold = passportDetectionThresholdMet ? thresholds.passport : idCardBackDetectionThresholdMet ? thresholds.idCardBack : thresholds.idCardFront;
3173
- var detectionScore = (_l = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _l !== void 0 ? _l : 0;
3178
+ var singlePageDetectionScore = (_h = bestSinglePage === null || bestSinglePage === void 0 ? void 0 : bestSinglePage.score) !== null && _h !== void 0 ? _h : 0;
3179
+ var idCardFrontDetectionThresholdMet = idCardFrontDetectionScore >= ((_j = thresholds.idCardFront) !== null && _j !== void 0 ? _j : 0);
3180
+ var idCardBackDetectionThresholdMet = idCardBackDetectionScore >= ((_k = thresholds.idCardBack) !== null && _k !== void 0 ? _k : 0);
3181
+ var passportDetectionThresholdMet = passportDetectionScore >= ((_l = thresholds.passport) !== null && _l !== void 0 ? _l : 0);
3182
+ var singlePageDetectionThresholdMet = singlePageDetectionScore >= ((_m = thresholds.singlePage) !== null && _m !== void 0 ? _m : 0);
3183
+ var bestDocument = singlePageDetectionThresholdMet ? bestSinglePage : passportDetectionThresholdMet ? bestPassportPage : idCardBackDetectionThresholdMet ? bestIdCardBack : bestIdCardFront;
3184
+ var detectionThreshold = singlePageDetectionThresholdMet ? thresholds.singlePage : passportDetectionThresholdMet ? thresholds.passport : idCardBackDetectionThresholdMet ? thresholds.idCardBack : thresholds.idCardFront;
3185
+ var detectionScore = (_o = bestDocument === null || bestDocument === void 0 ? void 0 : bestDocument.score) !== null && _o !== void 0 ? _o : 0;
3174
3186
  var detectionThresholdMet = detectionScore >= (detectionThreshold !== null && detectionThreshold !== void 0 ? detectionThreshold : 0);
3175
3187
  var detectedDocumentType = 'none';
3176
- if (passportDetectionThresholdMet) {
3188
+ if (singlePageDetectionThresholdMet) {
3189
+ detectedDocumentType = 'singlePage';
3190
+ } else if (passportDetectionThresholdMet) {
3177
3191
  detectedDocumentType = 'passport';
3178
3192
  } else if (idCardBackDetectionThresholdMet) {
3179
3193
  detectedDocumentType = 'idCardBack';
@@ -3187,12 +3201,12 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3187
3201
  var documentIsStable = false;
3188
3202
  var documentTooClose = false;
3189
3203
  if (bestDocument) {
3190
- var _o = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
3191
- docWidth = _o[0],
3192
- docHeight = _o[1];
3204
+ var _q = [bestDocument.box.width / frameWidth, bestDocument.box.height / frameHeight],
3205
+ docWidth = _q[0],
3206
+ docHeight = _q[1];
3193
3207
  documentTooClose = docWidth > 0.85 || docHeight > 0.85;
3194
3208
  if (detectionThresholdMet && documentInBounds && !documentTooClose) {
3195
- var thresholdSet = (_m = thresholds.stability) !== null && _m !== void 0 ? _m : defaultDocumentDetectionThresholds.stability;
3209
+ var thresholdSet = (_p = thresholds.stability) !== null && _p !== void 0 ? _p : defaultDocumentDetectionThresholds.stability;
3196
3210
  var threshold_1 = thresholdSet[detectedDocumentType];
3197
3211
  var framesNeeded = Math.ceil(average(framesNeededSamples));
3198
3212
  trackBox(bestDocument.box, framesNeeded);
@@ -3214,6 +3228,8 @@ function processDocumentDetectorPrediction(prediction, thresholds, boundaries) {
3214
3228
  idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
3215
3229
  passportDetectionScore: passportDetectionScore,
3216
3230
  passportDetectionThresholdMet: passportDetectionThresholdMet,
3231
+ singlePageDetectionScore: singlePageDetectionScore,
3232
+ singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
3217
3233
  bestDocument: bestDocument,
3218
3234
  documentInBounds: documentInBounds,
3219
3235
  documentTooClose: documentTooClose,
@@ -4107,37 +4123,39 @@ var IdCaptureModelsContext = /*#__PURE__*/React.createContext({
4107
4123
  });
4108
4124
  function IdCaptureModelsProviderInner(_a) {
4109
4125
  var children = _a.children,
4110
- onModelError = _a.onModelError;
4111
- var _b = React.useContext(DocumentDetectionModelContext),
4112
- documentDetectionModelReady = _b.documentDetectionModelReady,
4113
- documentDetectionModelDownloadProgress = _b.documentDetectionModelDownloadProgress,
4114
- startDocumentDetection = _b.startDocumentDetection,
4115
- stopDocumentDetection = _b.stopDocumentDetection,
4116
- lastPredictionCanvas = _b.documentDetectionLastPredictionCanvas,
4117
- clearDocumentDetectionLastPredictionCanvas = _b.clearDocumentDetectionLastPredictionCanvas,
4118
- onDocumentDetected = _b.onDocumentDetected,
4119
- detectionTime = _b.detectionTime,
4120
- documentDetectionThresholds = _b.documentDetectionThresholds,
4121
- setDocumentDetectionThresholds = _b.setDocumentDetectionThresholds,
4122
- documentDetectionBoundaries = _b.documentDetectionBoundaries,
4123
- setDocumentDetectionBoundaries = _b.setDocumentDetectionBoundaries,
4124
- documentDetectionModelError = _b.documentDetectionModelError;
4125
- var _c = React.useContext(FocusModelContext),
4126
- focusModelReady = _c.focusModelReady,
4127
- focusModelDownloadProgress = _c.focusModelDownloadProgress,
4128
- makeFocusPrediction = _c.makeFocusPrediction,
4129
- focusThresholds = _c.focusThresholds,
4130
- setFocusThresholds = _c.setFocusThresholds,
4131
- focusPredictionTime = _c.focusPredictionTime,
4132
- focusModelError = _c.focusModelError;
4126
+ onModelError = _a.onModelError,
4127
+ _b = _a.allowSinglePageIdCapture,
4128
+ allowSinglePageIdCapture = _b === void 0 ? false : _b;
4129
+ var _c = React.useContext(DocumentDetectionModelContext),
4130
+ documentDetectionModelReady = _c.documentDetectionModelReady,
4131
+ documentDetectionModelDownloadProgress = _c.documentDetectionModelDownloadProgress,
4132
+ startDocumentDetection = _c.startDocumentDetection,
4133
+ stopDocumentDetection = _c.stopDocumentDetection,
4134
+ lastPredictionCanvas = _c.documentDetectionLastPredictionCanvas,
4135
+ clearDocumentDetectionLastPredictionCanvas = _c.clearDocumentDetectionLastPredictionCanvas,
4136
+ onDocumentDetected = _c.onDocumentDetected,
4137
+ detectionTime = _c.detectionTime,
4138
+ documentDetectionThresholds = _c.documentDetectionThresholds,
4139
+ setDocumentDetectionThresholds = _c.setDocumentDetectionThresholds,
4140
+ documentDetectionBoundaries = _c.documentDetectionBoundaries,
4141
+ setDocumentDetectionBoundaries = _c.setDocumentDetectionBoundaries,
4142
+ documentDetectionModelError = _c.documentDetectionModelError;
4143
+ var _d = React.useContext(FocusModelContext),
4144
+ focusModelReady = _d.focusModelReady,
4145
+ focusModelDownloadProgress = _d.focusModelDownloadProgress,
4146
+ makeFocusPrediction = _d.makeFocusPrediction,
4147
+ focusThresholds = _d.focusThresholds,
4148
+ setFocusThresholds = _d.setFocusThresholds,
4149
+ focusPredictionTime = _d.focusPredictionTime,
4150
+ focusModelError = _d.focusModelError;
4133
4151
  var onPredictionHandler = React.useRef();
4134
4152
  var bestFrameDetails = React.useRef(null);
4135
4153
  var bestPredictionCanvas = React.useRef(null);
4136
4154
  var bestFocusScore = React.useRef(0);
4137
4155
  var stopDetection = React.useRef(0);
4138
- var _d = React.useState('none'),
4139
- requiredDocumentType = _d[0],
4140
- setRequiredDocumentType = _d[1];
4156
+ var _e = React.useState('none'),
4157
+ requiredDocumentType = _e[0],
4158
+ setRequiredDocumentType = _e[1];
4141
4159
  var thresholds = React.useMemo(function () {
4142
4160
  return _assign(_assign({}, documentDetectionThresholds), {
4143
4161
  focus: focusThresholds
@@ -4155,34 +4173,42 @@ function IdCaptureModelsProviderInner(_a) {
4155
4173
  var _this = this;
4156
4174
  onDocumentDetected(function (prediction) {
4157
4175
  return __awaiter(_this, void 0, void 0, function () {
4158
- var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, isRequiredDocumentType, focusPrediction, focusThresholdSet, focusThreshold;
4159
- var _a, _b, _c, _d, _e, _f;
4160
- return __generator(this, function (_g) {
4176
+ var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, isSinglePage, isRequiredDocumentType, focusPrediction, focusThresholdSet, focusThreshold;
4177
+ var _a, _b, _c, _d, _e, _f, _g;
4178
+ return __generator(this, function (_h) {
4161
4179
  if (!lastPredictionCanvas.current) return [2 /*return*/];
4162
4180
  stopDetectionAtStart = stopDetection.current;
4163
4181
  focusPredictionTime = 0, focusScore = 0, focusThresholdMet = false;
4164
- isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType));
4182
+ isSinglePage = prediction.detectedDocumentType === 'singlePage';
4183
+ if (!allowSinglePageIdCapture && isSinglePage) {
4184
+ prediction.detectedDocumentType = 'passport';
4185
+ prediction.passportDetectionScore = prediction.singlePageDetectionScore;
4186
+ prediction.passportDetectionThresholdMet = prediction.singlePageDetectionThresholdMet;
4187
+ prediction.singlePageDetectionScore = 0;
4188
+ prediction.singlePageDetectionThresholdMet = false;
4189
+ }
4190
+ isRequiredDocumentType = requiredDocumentType === 'none' || prediction.detectedDocumentType === requiredDocumentType || ((_a = requiredDocumentType.includes) === null || _a === void 0 ? void 0 : _a.call(requiredDocumentType, prediction.detectedDocumentType)) || allowSinglePageIdCapture && isSinglePage && ((_b = requiredDocumentType.includes) === null || _b === void 0 ? void 0 : _b.call(requiredDocumentType, 'idCardFront'));
4165
4191
  if (isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable) {
4166
- focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_b = prediction.bestDocument) === null || _b === void 0 ? void 0 : _b.box);
4192
+ focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_c = prediction.bestDocument) === null || _c === void 0 ? void 0 : _c.box);
4167
4193
  if (focusPrediction) {
4168
4194
  focusScore = focusPrediction.score;
4169
4195
  focusPredictionTime = focusPrediction.predictionTime;
4170
4196
  }
4171
- focusThresholdSet = (_c = thresholds.focus) === null || _c === void 0 ? void 0 : _c[prediction.detectedDocumentType];
4172
- focusThreshold = (_d = onMobile ? focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.mobile : focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.desktop) !== null && _d !== void 0 ? _d : 0;
4197
+ focusThresholdSet = (_d = thresholds.focus) === null || _d === void 0 ? void 0 : _d[prediction.detectedDocumentType];
4198
+ focusThreshold = (_e = onMobile ? focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.mobile : focusThresholdSet === null || focusThresholdSet === void 0 ? void 0 : focusThresholdSet.desktop) !== null && _e !== void 0 ? _e : 0;
4173
4199
  focusThresholdMet = focusScore >= focusThreshold;
4174
4200
  if (bestFocusScore.current <= focusScore && stopDetectionAtStart === stopDetection.current) {
4175
4201
  bestFocusScore.current = focusScore;
4176
4202
  drawToCanvas(bestPredictionCanvas.current, lastPredictionCanvas.current);
4177
4203
  bestFrameDetails.current = {
4178
- boundingBox: (_e = prediction.bestDocument) === null || _e === void 0 ? void 0 : _e.box,
4204
+ boundingBox: (_f = prediction.bestDocument) === null || _f === void 0 ? void 0 : _f.box,
4179
4205
  documentType: prediction.detectedDocumentType,
4180
4206
  detectionScore: prediction.detectionScore,
4181
4207
  focusScore: focusScore
4182
4208
  };
4183
4209
  }
4184
4210
  }
4185
- (_f = onPredictionHandler.current) === null || _f === void 0 ? void 0 : _f.call(onPredictionHandler, _assign(_assign({}, prediction), {
4211
+ (_g = onPredictionHandler.current) === null || _g === void 0 ? void 0 : _g.call(onPredictionHandler, _assign(_assign({}, prediction), {
4186
4212
  focusScore: focusScore,
4187
4213
  focusPredictionTime: focusPredictionTime,
4188
4214
  focusThresholdMet: focusThresholdMet
@@ -4191,7 +4217,7 @@ function IdCaptureModelsProviderInner(_a) {
4191
4217
  });
4192
4218
  });
4193
4219
  });
4194
- }, [lastPredictionCanvas, makeFocusPrediction, onDocumentDetected, requiredDocumentType, thresholds.focus]);
4220
+ }, [allowSinglePageIdCapture, lastPredictionCanvas, makeFocusPrediction, onDocumentDetected, requiredDocumentType, thresholds.focus]);
4195
4221
  var modelError = documentDetectionModelError !== null && documentDetectionModelError !== void 0 ? documentDetectionModelError : focusModelError;
4196
4222
  React.useEffect(function handleModelErrors() {
4197
4223
  modelError && (onModelError === null || onModelError === void 0 ? void 0 : onModelError(modelError));
@@ -4205,9 +4231,9 @@ function IdCaptureModelsProviderInner(_a) {
4205
4231
  canvas: bestPredictionCanvas.current
4206
4232
  });
4207
4233
  }, []);
4208
- var _e = React.useState(0),
4209
- canvasKey = _e[0],
4210
- setCanvasKey = _e[1];
4234
+ var _f = React.useState(0),
4235
+ canvasKey = _f[0],
4236
+ setCanvasKey = _f[1];
4211
4237
  var resetBestFrame = React.useCallback(function () {
4212
4238
  stopDetection.current += 1;
4213
4239
  setCanvasKey(function (n) {
@@ -4254,9 +4280,9 @@ function IdCaptureModelsProvider(_a) {
4254
4280
  return /*#__PURE__*/React__namespace.default.createElement(DocumentDetectionModelProvider, _assign({}, props), /*#__PURE__*/React__namespace.default.createElement(FocusModelProvider, _assign({}, props), /*#__PURE__*/React__namespace.default.createElement(IdCaptureModelsProviderInner, _assign({}, props), children)));
4255
4281
  }
4256
4282
 
4257
- var CapturedDocumentTypeValues = ['idCardFront', 'idCardBack', 'passport', 'selfie'];
4283
+ var CapturedDocumentTypeValues = ['idCardFront', 'idCardBack', 'passport', 'singlePage', 'selfie'];
4258
4284
 
4259
- var requiredDocumentsForOption = {
4285
+ var acceptedDocumentTypesForIdCaptureRequirementOption = {
4260
4286
  idCardFront: ['idCardFront'],
4261
4287
  idCardBack: ['idCardBack'],
4262
4288
  passport: ['passport'],
@@ -4264,13 +4290,35 @@ var requiredDocumentsForOption = {
4264
4290
  idCardAndPassport: ['idCardFront', 'idCardBack', 'passport'],
4265
4291
  idCardOrPassport: ['idCardFront', 'idCardBack', 'passport'] // this one is so weird
4266
4292
  };
4267
- function requiredImageCountForOption(idCaptureRequirement) {
4293
+ function minImageCountForIdCaptureRequirementOption(idCaptureRequirement) {
4268
4294
  if (idCaptureRequirement === 'idCardOrPassport') return 1;
4269
- return requiredDocumentsForOption[idCaptureRequirement].length;
4295
+ return acceptedDocumentTypesForIdCaptureRequirementOption[idCaptureRequirement].length;
4270
4296
  }
4271
- function allowedImageCountForOption(idCaptureRequirement) {
4297
+ function maxImageCountForIdCaptureRequirementOption(idCaptureRequirement) {
4272
4298
  if (idCaptureRequirement === 'idCardOrPassport') return 2;
4273
- return requiredImageCountForOption(idCaptureRequirement);
4299
+ return minImageCountForIdCaptureRequirementOption(idCaptureRequirement);
4300
+ }
4301
+ function remainingIdCaptureRequirements(captureRequirement, capturedDocuments, requestedDocumentType) {
4302
+ var isIdCardOrPassport = captureRequirement === 'idCardOrPassport';
4303
+ if (isIdCardOrPassport && requestedDocumentType === 'passport') return [];
4304
+ var acceptedTypes = acceptedDocumentTypesForIdCaptureRequirementOption[captureRequirement];
4305
+ console.log({
4306
+ capturedDocuments: capturedDocuments,
4307
+ captureRequirement: captureRequirement
4308
+ });
4309
+ if (captureRequirement.includes('idCard') && 'singlePage' in capturedDocuments) {
4310
+ acceptedTypes = acceptedTypes.filter(function (v) {
4311
+ return !v.includes('idCard');
4312
+ });
4313
+ }
4314
+ if (isIdCardOrPassport) {
4315
+ acceptedTypes = acceptedTypes.filter(function (v) {
4316
+ return v !== 'passport';
4317
+ });
4318
+ }
4319
+ return acceptedTypes.filter(function (v) {
4320
+ return !(v in capturedDocuments);
4321
+ });
4274
4322
  }
4275
4323
 
4276
4324
  var initialState$4 = {
@@ -4309,6 +4357,8 @@ var initialState$4 = {
4309
4357
  idCardBackDetectionThresholdMet: false,
4310
4358
  passportDetectionScore: 0,
4311
4359
  passportDetectionThresholdMet: false,
4360
+ singlePageDetectionScore: 0,
4361
+ singlePageDetectionThresholdMet: false,
4312
4362
  focusScore: 0,
4313
4363
  focusThresholdMet: false,
4314
4364
  isGoodFrame: false,
@@ -4324,6 +4374,7 @@ var initialState$4 = {
4324
4374
  capturedDocuments: {},
4325
4375
  captureRequirement: 'idCardOrPassport',
4326
4376
  requestedDocumentType: 'idCardFront',
4377
+ allowSinglePageIdCapture: false,
4327
4378
  allowIdCardBackToFrontCapture: false,
4328
4379
  operationStartedAt: null,
4329
4380
  captureStartedAt: null
@@ -4338,11 +4389,13 @@ var _reducer = function reducer(state, action) {
4338
4389
  var _c = action.payload,
4339
4390
  captureRequirement = _c.captureRequirement,
4340
4391
  precapturedDocuments = _c.precapturedDocuments,
4392
+ allowSinglePageIdCapture = _c.allowSinglePageIdCapture,
4341
4393
  allowIdCardBackToFrontCapture = _c.allowIdCardBackToFrontCapture,
4342
4394
  enableOverrideWrongDocumentTypeDialog = _c.enableOverrideWrongDocumentTypeDialog,
4343
4395
  allowOverrideWrongDocumentTypeAfterMs = _c.allowOverrideWrongDocumentTypeAfterMs;
4344
4396
  var newState = _assign(_assign({}, state), {
4345
4397
  captureRequirement: captureRequirement,
4398
+ allowSinglePageIdCapture: allowSinglePageIdCapture !== null && allowSinglePageIdCapture !== void 0 ? allowSinglePageIdCapture : false,
4346
4399
  allowIdCardBackToFrontCapture: allowIdCardBackToFrontCapture !== null && allowIdCardBackToFrontCapture !== void 0 ? allowIdCardBackToFrontCapture : false,
4347
4400
  enableOverrideWrongDocumentTypeDialog: enableOverrideWrongDocumentTypeDialog,
4348
4401
  allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs
@@ -4410,6 +4463,8 @@ var _reducer = function reducer(state, action) {
4410
4463
  idCardBackDetectionThresholdMet = _d.idCardBackDetectionThresholdMet,
4411
4464
  passportDetectionScore = _d.passportDetectionScore,
4412
4465
  passportDetectionThresholdMet = _d.passportDetectionThresholdMet,
4466
+ singlePageDetectionScore = _d.singlePageDetectionScore,
4467
+ singlePageDetectionThresholdMet = _d.singlePageDetectionThresholdMet,
4413
4468
  bestDocument = _d.bestDocument,
4414
4469
  documentInBounds = _d.documentInBounds,
4415
4470
  documentTooClose = _d.documentTooClose,
@@ -4430,7 +4485,8 @@ var _reducer = function reducer(state, action) {
4430
4485
  }
4431
4486
  }
4432
4487
  }
4433
- var idCardDetectedButNotAllowed = detectedDocumentType.includes('idCard') && !state.captureRequirement.includes('idCard');
4488
+ var idCardDetected = detectedDocumentType.includes('idCard') || detectedDocumentType === 'singlePage';
4489
+ var idCardDetectedButNotAllowed = idCardDetected && !state.captureRequirement.includes('idCard');
4434
4490
  var passportNotAllowed = !state.captureRequirement.toLowerCase().includes('passport');
4435
4491
  var idCardFrontWasCaptured = 'idCardFront' in state.capturedDocuments;
4436
4492
  var idCardBackWasCaptured = 'idCardBack' in state.capturedDocuments;
@@ -4490,6 +4546,8 @@ var _reducer = function reducer(state, action) {
4490
4546
  idCardBackDetectionThresholdMet: idCardBackDetectionThresholdMet,
4491
4547
  passportDetectionScore: passportDetectionScore,
4492
4548
  passportDetectionThresholdMet: passportDetectionThresholdMet,
4549
+ singlePageDetectionScore: singlePageDetectionScore,
4550
+ singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
4493
4551
  focusScore: focusScore,
4494
4552
  focusThresholdMet: focusThresholdMet,
4495
4553
  isGoodFrame: isGoodFrame,
@@ -4527,7 +4585,7 @@ var _reducer = function reducer(state, action) {
4527
4585
  });
4528
4586
  case 'documentCaptured':
4529
4587
  {
4530
- var newState_1 = _assign(_assign({}, state), {
4588
+ var newState = _assign(_assign({}, state), {
4531
4589
  capturing: false,
4532
4590
  captureFailed: false,
4533
4591
  allowOverrideFlipRequirement: false,
@@ -4536,64 +4594,42 @@ var _reducer = function reducer(state, action) {
4536
4594
  wrongDocumentTypePredictions: 0,
4537
4595
  capturedDocuments: _assign(_assign({}, state.capturedDocuments), (_a = {}, _a[action.payload.documentType] = action.payload, _a))
4538
4596
  });
4539
- var remainingRequirements = requiredDocumentsForOption[state.captureRequirement].filter(function (v) {
4540
- return !(v in newState_1.capturedDocuments);
4541
- });
4542
- if (state.captureRequirement === 'idCardOrPassport') {
4543
- if (state.requestedDocumentType === 'passport') {
4544
- remainingRequirements = [];
4545
- } else {
4546
- remainingRequirements = remainingRequirements.filter(function (v) {
4547
- return v !== 'passport';
4548
- });
4549
- }
4550
- }
4597
+ var remainingRequirements = remainingIdCaptureRequirements(state.captureRequirement, newState.capturedDocuments, state.requestedDocumentType);
4551
4598
  if (remainingRequirements.length === 0) {
4552
- newState_1.captureState = 'complete';
4599
+ newState.captureState = 'complete';
4553
4600
  } else {
4554
- newState_1.requestedDocumentType = remainingRequirements[0];
4555
- if (state.requestedDocumentType === 'idCardFront' && newState_1.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState_1.requestedDocumentType === 'idCardFront') {
4556
- newState_1.captureState = 'requestingFlip';
4557
- newState_1.idCardFrontDetectionThresholdMet = false;
4558
- newState_1.idCardBackDetectionThresholdMet = false;
4559
- newState_1.passportDetectionThresholdMet = false;
4560
- newState_1.wrongDocumentTypePredictions = 0;
4601
+ newState.requestedDocumentType = remainingRequirements[0];
4602
+ if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
4603
+ newState.captureState = 'requestingFlip';
4604
+ newState.idCardFrontDetectionThresholdMet = false;
4605
+ newState.idCardBackDetectionThresholdMet = false;
4606
+ newState.passportDetectionThresholdMet = false;
4607
+ newState.wrongDocumentTypePredictions = 0;
4561
4608
  }
4562
4609
  }
4563
- return newState_1;
4610
+ return newState;
4564
4611
  }
4565
4612
  case 'documentCapturedManually':
4566
4613
  {
4567
- var newState_2 = _assign(_assign({}, state), {
4614
+ var newState = _assign(_assign({}, state), {
4568
4615
  capturedDocuments: _assign(_assign({}, state.capturedDocuments), (_b = {}, _b[state.requestedDocumentType] = _assign(_assign({}, action.payload), {
4569
4616
  width: 0,
4570
4617
  height: 0
4571
4618
  }), _b))
4572
4619
  });
4573
- var remainingRequirements = requiredDocumentsForOption[state.captureRequirement].filter(function (v) {
4574
- return !(v in newState_2.capturedDocuments);
4575
- });
4576
- if (state.captureRequirement === 'idCardOrPassport') {
4577
- if (state.requestedDocumentType === 'passport') {
4578
- remainingRequirements = [];
4579
- } else {
4580
- remainingRequirements = remainingRequirements.filter(function (v) {
4581
- return v !== 'passport';
4582
- });
4583
- }
4584
- }
4620
+ var remainingRequirements = remainingIdCaptureRequirements(state.captureRequirement, newState.capturedDocuments, state.requestedDocumentType);
4585
4621
  if (remainingRequirements.length === 0) {
4586
- newState_2.captureState = 'complete';
4622
+ newState.captureState = 'complete';
4587
4623
  } else {
4588
- newState_2.requestedDocumentType = remainingRequirements[0];
4589
- if (state.requestedDocumentType === 'idCardFront' && newState_2.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState_2.requestedDocumentType === 'idCardFront') {
4590
- newState_2.captureState = 'requestingFlip';
4591
- newState_2.idCardFrontDetectionThresholdMet = false;
4592
- newState_2.idCardBackDetectionThresholdMet = false;
4593
- newState_2.passportDetectionThresholdMet = false;
4624
+ newState.requestedDocumentType = remainingRequirements[0];
4625
+ if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
4626
+ newState.captureState = 'requestingFlip';
4627
+ newState.idCardFrontDetectionThresholdMet = false;
4628
+ newState.idCardBackDetectionThresholdMet = false;
4629
+ newState.passportDetectionThresholdMet = false;
4594
4630
  }
4595
4631
  }
4596
- return newState_2;
4632
+ return newState;
4597
4633
  }
4598
4634
  case 'flipRequestCompleted':
4599
4635
  return _assign(_assign({}, state), {
@@ -5194,7 +5230,7 @@ var IdCapture = function IdCapture(_a) {
5194
5230
  imageUrl: imageUrl
5195
5231
  }
5196
5232
  });
5197
- var capturedDocumentType = documentType === 'passport' ? 'passport' : state.requestedDocumentType;
5233
+ var capturedDocumentType = documentType;
5198
5234
  setTimeout(function () {
5199
5235
  var _a;
5200
5236
  var captureTime = new Date().getTime() - ((_a = state.captureStartedAt) !== null && _a !== void 0 ? _a : new Date()).getTime();
@@ -5261,7 +5297,7 @@ var IdCapture = function IdCapture(_a) {
5261
5297
  scaling: debugScalingDetails,
5262
5298
  flipX: !isRearFacing
5263
5299
  });
5264
- }))), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__namespace.default.createElement("br", null), state.frameCaptureRate > 0.75 ? '✅' : '👎', " Frame Rate:", ' ', Math.round((state.frameCaptureRate + Number.EPSILON) * 1000) / 1000, ' ', "fps (", detectionTime, "ms doc detect, ", focusPredictionTime, "ms focus)", /*#__PURE__*/React__namespace.default.createElement("br", null), modelsReady ? ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React__namespace.default.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__namespace.default.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React__namespace.default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, "\u274C Models not ready")))));
5300
+ }))), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugStatsPane, null, camera ? ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, "\u2705 Camera: ", camera.label, " (", camera.width, "x", camera.height, ")")) : '❌ Camera not ready', /*#__PURE__*/React__namespace.default.createElement("br", null), state.frameCaptureRate > 0.75 ? '✅' : '👎', " Frame Rate:", ' ', Math.round((state.frameCaptureRate + Number.EPSILON) * 1000) / 1000, ' ', "fps (", detectionTime, "ms doc detect, ", focusPredictionTime, "ms focus)", /*#__PURE__*/React__namespace.default.createElement("br", null), modelsReady ? ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, state.detectionThresholdMet ? '✅' : '❌', " Detected Document Type: ", state.detectedDocumentType, /*#__PURE__*/React__namespace.default.createElement("br", null), state.idCardFrontDetectionThresholdMet ? '✅' : '❌', " ID Card Front Score: ", state.idCardFrontDetectionScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.idCardBackDetectionThresholdMet ? '✅' : '❌', " ID Card Back Score: ", state.idCardBackDetectionScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.passportDetectionThresholdMet ? '✅' : '❌', " Passport Score: ", state.passportDetectionScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.singlePageDetectionThresholdMet ? '✅' : '❌', " Single Page Score: ", state.singlePageDetectionScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.focusThresholdMet ? '✅' : '❌', " Focus Score:", ' ', state.focusScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), state.documentInBounds ? '✅' : '❌', " Document In Bounds", /*#__PURE__*/React__namespace.default.createElement("br", null), state.documentIsStable ? '✅' : '❌', " Document Is Stable", /*#__PURE__*/React__namespace.default.createElement("br", null), state.goodFramesThresholdMet ? '✅' : '❌', " Good Frame Count:", ' ', state.goodFramesCount, "/", state.goodFramesThreshold)) : ( /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, "\u274C Models not ready")))));
5265
5301
  };
5266
5302
  var timeSince = function timeSince(t) {
5267
5303
  if (!t) return 0;
@@ -6300,15 +6336,8 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
6300
6336
  _e = _a.debugMode,
6301
6337
  debugMode = _e === void 0 ? false : _e;
6302
6338
  var submissionStatus = React.useContext(SubmissionContext).submissionStatus;
6303
- var idCardFront = capturedDocuments.idCardFront,
6304
- idCardBack = capturedDocuments.idCardBack,
6305
- passport = capturedDocuments.passport;
6306
6339
  var verbiage = useTranslations(rawVerbiage, {
6307
6340
  headingText: 'ID Capture Successful',
6308
- idCardFrontText: 'ID Card Front',
6309
- idCardBackText: 'ID Card Back',
6310
- passportText: 'Passport',
6311
- instructionText: 'Verify the entire ID was captured clearly with no glare.',
6312
6341
  retryText: 'Retry',
6313
6342
  submittingText: 'Submitting...',
6314
6343
  submitText: 'Done'
@@ -6325,25 +6354,16 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
6325
6354
  className: classNames.imageContainer
6326
6355
  }, /*#__PURE__*/React__namespace.default.createElement(ImageRow, {
6327
6356
  className: classNames.imageRow
6328
- }, idCardFront && ( /*#__PURE__*/React__namespace.default.createElement(ImageCol$1, {
6329
- className: classNames.imageCol
6330
- }, /*#__PURE__*/React__namespace.default.createElement(StyledImage, {
6331
- image: idCardFront,
6332
- className: classNames.image,
6333
- alt: verbiage.idCardFrontText
6334
- }), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugPre, null, "Detection Score: ".concat(idCardFront.detectionScore, "\nFocus Score: ").concat(idCardFront.focusScore, "\nBounding Box: ").concat(JSON.stringify(idCardFront.boundingBox)))))), idCardBack && ( /*#__PURE__*/React__namespace.default.createElement(ImageCol$1, {
6335
- className: classNames.imageCol
6336
- }, /*#__PURE__*/React__namespace.default.createElement(StyledImage, {
6337
- image: idCardBack,
6338
- className: classNames.image,
6339
- alt: verbiage.idCardBackText
6340
- }), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugPre, null, "Detection Score: ".concat(idCardBack.detectionScore, "\nFocus Score: ").concat(idCardBack.focusScore, "\nBounding Box: ").concat(JSON.stringify(idCardBack.boundingBox)))))), passport && ( /*#__PURE__*/React__namespace.default.createElement(ImageCol$1, {
6341
- className: classNames.imageCol
6342
- }, /*#__PURE__*/React__namespace.default.createElement(StyledImage, {
6343
- image: passport,
6344
- className: classNames.image,
6345
- alt: verbiage.passportText
6346
- }), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugPre, null, "Detection Score: ".concat(passport.detectionScore, "\nFocus Score: ").concat(passport.focusScore, "\nBounding Box: ").concat(JSON.stringify(passport.boundingBox)))))))), /*#__PURE__*/React__namespace.default.createElement(ButtonsColumn, {
6357
+ }, Object.values(capturedDocuments).map(function (doc) {
6358
+ return /*#__PURE__*/React__namespace.default.createElement(ImageCol$1, {
6359
+ className: classNames.imageCol,
6360
+ key: doc.imageData
6361
+ }, /*#__PURE__*/React__namespace.default.createElement(StyledImage, {
6362
+ image: doc,
6363
+ className: classNames.image,
6364
+ alt: doc.documentType
6365
+ }), debugMode && ( /*#__PURE__*/React__namespace.default.createElement(DebugPre, null, "Document Type: ".concat(doc.documentType, "\nDetection Score: ").concat(doc.detectionScore, "\nFocus Score: ").concat(doc.focusScore, "\nBounding Box: ").concat(JSON.stringify(doc.boundingBox)))));
6366
+ }))), /*#__PURE__*/React__namespace.default.createElement(ButtonsColumn, {
6347
6367
  className: classNames.buttonsRow
6348
6368
  }, /*#__PURE__*/React__namespace.default.createElement(WideButton, {
6349
6369
  className: classNames.submitBtn,
@@ -6362,7 +6382,7 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
6362
6382
  };
6363
6383
  var Heading$a = styled__default.default.h1(templateObject_1$v || (templateObject_1$v = __makeTemplateObject(["\n font-size: 1.5rem;\n margin-top: 0;\n margin-bottom: 1.5rem;\n"], ["\n font-size: 1.5rem;\n margin-top: 0;\n margin-bottom: 1.5rem;\n"])));
6364
6384
  var ImagesContainer = styled__default.default(OverlayImageContainer)(templateObject_2$q || (templateObject_2$q = __makeTemplateObject(["\n flex-grow: 1;\n overflow-y: auto;\n padding-bottom: 0;\n max-width: 100%;\n"], ["\n flex-grow: 1;\n overflow-y: auto;\n padding-bottom: 0;\n max-width: 100%;\n"])));
6365
- var ImageRow = styled__default.default(OverlayImageRow)(templateObject_3$k || (templateObject_3$k = __makeTemplateObject(["\n max-width: 100%;\n flex-direction: column;\n display: grid;\n grid-gap: 12px;\n //grid-template-columns: 1fr 1fr;\n"], ["\n max-width: 100%;\n flex-direction: column;\n display: grid;\n grid-gap: 12px;\n //grid-template-columns: 1fr 1fr;\n"])));
6385
+ var ImageRow = styled__default.default(OverlayImageRow)(templateObject_3$k || (templateObject_3$k = __makeTemplateObject(["\n max-width: 100%;\n flex-direction: column;\n display: grid;\n grid-gap: 12px;\n"], ["\n max-width: 100%;\n flex-direction: column;\n display: grid;\n grid-gap: 12px;\n"])));
6366
6386
  var ImageCol$1 = styled__default.default.div(templateObject_4$e || (templateObject_4$e = __makeTemplateObject(["\n width: 100%;\n max-height: none !important;\n"], ["\n width: 100%;\n max-height: none !important;\n"])));
6367
6387
  var StyledImage = styled__default.default(CapturedDocumentImg)(templateObject_5$9 || (templateObject_5$9 = __makeTemplateObject(["\n width: 100%;\n border-radius: 12px;\n"], ["\n width: 100%;\n border-radius: 12px;\n"])));
6368
6388
  var DebugPre = styled__default.default.pre(templateObject_6$7 || (templateObject_6$7 = __makeTemplateObject(["\n text-align: left;\n max-width: min(450px, 100dvw - 100px);\n overflow-x: auto;\n"], ["\n text-align: left;\n max-width: min(450px, 100dvw - 100px);\n overflow-x: auto;\n"])));
@@ -8070,8 +8090,8 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
8070
8090
  var _j = React.useState(silentFallback),
8071
8091
  useFallback = _j[0],
8072
8092
  setUseFallback = _j[1];
8073
- var allowedImageCount = allowedImageCountForOption(idCaptureRequirement);
8074
- var requiredImageCount = requiredImageCountForOption(idCaptureRequirement);
8093
+ var minImageCount = minImageCountForIdCaptureRequirementOption(idCaptureRequirement);
8094
+ var maxImageCount = maxImageCountForIdCaptureRequirementOption(idCaptureRequirement);
8075
8095
  var _k = useFileState(),
8076
8096
  rawFile = _k.rawFile,
8077
8097
  fileInputOnChange = _k.fileInputOnChange;
@@ -8084,7 +8104,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
8084
8104
  var whatToCapture = idCaptureRequirement === 'idCard' ? 'ID card' : idCaptureRequirement === 'passport' ? 'passport' : idCaptureRequirement === 'idCardOrPassport' ? 'ID card or passport' : 'ID card and passport';
8085
8105
  var firstInstructionText = idCaptureRequirement === 'idCard' || idCaptureRequirement === 'idCardAndPassport' ? 'Please capture the front of your ID card.' : idCaptureRequirement === 'passport' ? 'Please capture the ID page of your passport.' : 'Please capture the front of your ID card, or the ID page of your passport.';
8086
8106
  var secondInstructionText = idCaptureRequirement === 'idCardOrPassport' ? 'Please capture the back of your ID card, or click Done if submitting a passport.' : 'Please capture the back of your ID card.';
8087
- var descriptionText = "On-device capture guidance failed, please capture ".concat(requiredImageCount > 1 ? 'photos' : ' a photo', " of your ").concat(whatToCapture, " manually.");
8107
+ var descriptionText = "On-device capture guidance failed, please capture ".concat(minImageCount > 1 ? 'photos' : ' a photo', " of your ").concat(whatToCapture, " manually.");
8088
8108
  var verbiage = useTranslations(rawVerbiage, {
8089
8109
  headingText: "We're having some trouble.",
8090
8110
  descriptionText: descriptionText,
@@ -8158,7 +8178,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
8158
8178
  alt: "",
8159
8179
  className: classNames.image
8160
8180
  }));
8161
- }))), images.length < requiredImageCount && ( /*#__PURE__*/React__namespace.default.createElement(Instruction, {
8181
+ }))), images.length < minImageCount && ( /*#__PURE__*/React__namespace.default.createElement(Instruction, {
8162
8182
  className: classNames.instruction
8163
8183
  }, instructionText)), /*#__PURE__*/React__namespace.default.createElement("input", {
8164
8184
  ref: fileInput,
@@ -8169,7 +8189,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
8169
8189
  hidden: true
8170
8190
  }), /*#__PURE__*/React__namespace.default.createElement(StyledButtonsRow$8, {
8171
8191
  className: classNames.buttonsRow
8172
- }, images.length < allowedImageCount && ( /*#__PURE__*/React__namespace.default.createElement(LoaderButton, {
8192
+ }, images.length < maxImageCount && ( /*#__PURE__*/React__namespace.default.createElement(LoaderButton, {
8173
8193
  variant: images.length > 0 ? 'secondary' : 'positive',
8174
8194
  className: images.length > 0 ? classNames.captureMoreBtn : classNames.captureBtn,
8175
8195
  colors: images.length > 0 ? colors.captureMoreBtn : colors.captureBtn,
@@ -8182,7 +8202,7 @@ var IdCaptureFallback = function IdCaptureFallback(_a) {
8182
8202
  setDocumentToCapture(instructionText);
8183
8203
  }
8184
8204
  }
8185
- }, images.length > 0 ? verbiage.captureMoreBtnText : verbiage.captureBtnText)), images.length >= requiredImageCount && ( /*#__PURE__*/React__namespace.default.createElement(LoaderButton, {
8205
+ }, images.length > 0 ? verbiage.captureMoreBtnText : verbiage.captureBtnText)), images.length >= minImageCount && ( /*#__PURE__*/React__namespace.default.createElement(LoaderButton, {
8186
8206
  variant: "positive",
8187
8207
  className: classNames.doneBtn,
8188
8208
  colors: colors.doneBtn,
@@ -8229,79 +8249,82 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
8229
8249
  precapturedDocuments = _a.precapturedDocuments,
8230
8250
  _j = _a.captureRequirement,
8231
8251
  captureRequirement = _j === void 0 ? 'idCardOrPassport' : _j,
8232
- _k = _a.separateIdCardCaptureSequence,
8233
- separateIdCardCaptureSequence = _k === void 0 ? false : _k,
8234
- _l = _a.thresholds,
8235
- thresholds = _l === void 0 ? defaultIdCaptureThresholds : _l,
8236
- _m = _a.skipSuccessScreen,
8237
- skipSuccessScreen = _m === void 0 ? false : _m,
8252
+ _k = _a.allowSinglePageIdCapture,
8253
+ allowSinglePageIdCapture = _k === void 0 ? false : _k,
8254
+ _l = _a.separateIdCardCaptureSequence,
8255
+ separateIdCardCaptureSequence = _l === void 0 ? false : _l,
8256
+ _m = _a.thresholds,
8257
+ thresholds = _m === void 0 ? defaultIdCaptureThresholds : _m,
8258
+ _o = _a.skipSuccessScreen,
8259
+ skipSuccessScreen = _o === void 0 ? false : _o,
8238
8260
  instructions = _a.instructions,
8239
- _o = _a.releaseCameraAccessOnExit,
8240
- releaseCameraAccessOnExit = _o === void 0 ? true : _o,
8241
- _p = _a.guideType,
8242
- guideType = _p === void 0 ? 'fit' : _p,
8243
- _q = _a.portraitGuidesOnMobile,
8244
- portraitGuidesOnMobile = _q === void 0 ? true : _q,
8245
- _r = _a.rotateLoadingOverlayImageWhenPortrait,
8246
- rotateLoadingOverlayImageWhenPortrait = _r === void 0 ? true : _r,
8247
- _s = _a.silentFallback,
8248
- silentFallback = _s === void 0 ? false : _s,
8249
- _t = _a.forceFallbackMode,
8250
- forceFallbackMode = _t === void 0 ? false : _t,
8251
- _u = _a.allowIdCardBackToFrontCapture,
8252
- allowIdCardBackToFrontCapture = _u === void 0 ? false : _u,
8253
- _v = _a.enableOverrideWrongDocumentTypeDialog,
8254
- enableOverrideWrongDocumentTypeDialog = _v === void 0 ? false : _v,
8255
- _w = _a.allowOverrideWrongDocumentTypeAfterMs,
8256
- allowOverrideWrongDocumentTypeAfterMs = _w === void 0 ? 8000 : _w,
8257
- _x = _a.guideImages,
8258
- guideImages = _x === void 0 ? defaultIdCaptureGuideImages : _x,
8259
- _y = _a.assets,
8260
- assets = _y === void 0 ? {} : _y,
8261
- _z = _a.classNames,
8262
- classNames = _z === void 0 ? {} : _z,
8263
- _0 = _a.colors,
8264
- colors = _0 === void 0 ? {} : _0,
8265
- _1 = _a.verbiage,
8266
- verbiage = _1 === void 0 ? {} : _1,
8267
- _2 = _a.debugMode,
8268
- debugMode = _2 === void 0 ? false : _2;
8269
- var _3 = useIdCaptureState(),
8270
- state = _3[0],
8271
- dispatch = _3[1];
8272
- var _4 = useCameraStore(),
8273
- cameraAccessDenied = _4.cameraAccessDenied,
8274
- requestCameraAccess = _4.requestCameraAccess,
8275
- releaseCameraAccess = _4.releaseCameraAccess;
8276
- var _5 = React.useState(false),
8277
- overlayDismissed = _5[0],
8278
- setOverlayDismissed = _5[1];
8279
- var _6 = React.useContext(SubmissionContext),
8280
- submissionStatus = _6.submissionStatus,
8281
- setIdFrontImage = _6.setIdFrontImage,
8282
- setIdBackImage = _6.setIdBackImage,
8283
- setPassportImage = _6.setPassportImage,
8284
- logIdFrontCaptureAttempt = _6.logIdFrontCaptureAttempt,
8285
- logIdBackCaptureAttempt = _6.logIdBackCaptureAttempt;
8286
- var _7 = React.useContext(IdCaptureModelsContext),
8287
- start = _7.start,
8288
- stop = _7.stop,
8289
- onPredictionMade = _7.onPredictionMade,
8290
- setRequiredDocumentType = _7.setRequiredDocumentType,
8291
- modelError = _7.modelError,
8292
- resetBestFrame = _7.resetBestFrame;
8261
+ _p = _a.releaseCameraAccessOnExit,
8262
+ releaseCameraAccessOnExit = _p === void 0 ? true : _p,
8263
+ _q = _a.guideType,
8264
+ guideType = _q === void 0 ? 'fit' : _q,
8265
+ _r = _a.portraitGuidesOnMobile,
8266
+ portraitGuidesOnMobile = _r === void 0 ? true : _r,
8267
+ _s = _a.rotateLoadingOverlayImageWhenPortrait,
8268
+ rotateLoadingOverlayImageWhenPortrait = _s === void 0 ? true : _s,
8269
+ _t = _a.silentFallback,
8270
+ silentFallback = _t === void 0 ? false : _t,
8271
+ _u = _a.forceFallbackMode,
8272
+ forceFallbackMode = _u === void 0 ? false : _u,
8273
+ _v = _a.allowIdCardBackToFrontCapture,
8274
+ allowIdCardBackToFrontCapture = _v === void 0 ? false : _v,
8275
+ _w = _a.enableOverrideWrongDocumentTypeDialog,
8276
+ enableOverrideWrongDocumentTypeDialog = _w === void 0 ? false : _w,
8277
+ _x = _a.allowOverrideWrongDocumentTypeAfterMs,
8278
+ allowOverrideWrongDocumentTypeAfterMs = _x === void 0 ? 8000 : _x,
8279
+ _y = _a.guideImages,
8280
+ guideImages = _y === void 0 ? defaultIdCaptureGuideImages : _y,
8281
+ _z = _a.assets,
8282
+ assets = _z === void 0 ? {} : _z,
8283
+ _0 = _a.classNames,
8284
+ classNames = _0 === void 0 ? {} : _0,
8285
+ _1 = _a.colors,
8286
+ colors = _1 === void 0 ? {} : _1,
8287
+ _2 = _a.verbiage,
8288
+ verbiage = _2 === void 0 ? {} : _2,
8289
+ _3 = _a.debugMode,
8290
+ debugMode = _3 === void 0 ? false : _3;
8291
+ var _4 = useIdCaptureState(),
8292
+ state = _4[0],
8293
+ dispatch = _4[1];
8294
+ var _5 = useCameraStore(),
8295
+ cameraAccessDenied = _5.cameraAccessDenied,
8296
+ requestCameraAccess = _5.requestCameraAccess,
8297
+ releaseCameraAccess = _5.releaseCameraAccess;
8298
+ var _6 = React.useState(false),
8299
+ overlayDismissed = _6[0],
8300
+ setOverlayDismissed = _6[1];
8301
+ var _7 = React.useContext(SubmissionContext),
8302
+ submissionStatus = _7.submissionStatus,
8303
+ setIdFrontImage = _7.setIdFrontImage,
8304
+ setIdBackImage = _7.setIdBackImage,
8305
+ setPassportImage = _7.setPassportImage,
8306
+ logIdFrontCaptureAttempt = _7.logIdFrontCaptureAttempt,
8307
+ logIdBackCaptureAttempt = _7.logIdBackCaptureAttempt;
8308
+ var _8 = React.useContext(IdCaptureModelsContext),
8309
+ start = _8.start,
8310
+ stop = _8.stop,
8311
+ onPredictionMade = _8.onPredictionMade,
8312
+ setRequiredDocumentType = _8.setRequiredDocumentType,
8313
+ modelError = _8.modelError,
8314
+ resetBestFrame = _8.resetBestFrame;
8293
8315
  React.useEffect(function () {
8294
8316
  dispatch({
8295
8317
  type: 'configureWizard',
8296
8318
  payload: {
8297
8319
  captureRequirement: captureRequirement,
8298
8320
  precapturedDocuments: precapturedDocuments,
8321
+ allowSinglePageIdCapture: allowSinglePageIdCapture,
8299
8322
  allowIdCardBackToFrontCapture: allowIdCardBackToFrontCapture,
8300
8323
  enableOverrideWrongDocumentTypeDialog: enableOverrideWrongDocumentTypeDialog,
8301
8324
  allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs
8302
8325
  }
8303
8326
  });
8304
- }, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, captureRequirement, dispatch, enableOverrideWrongDocumentTypeDialog, precapturedDocuments]);
8327
+ }, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, allowSinglePageIdCapture, captureRequirement, dispatch, enableOverrideWrongDocumentTypeDialog, precapturedDocuments]);
8305
8328
  var documentCount = Object.keys(state.capturedDocuments).length;
8306
8329
  React.useEffect(function () {
8307
8330
  documentCount && resetBestFrame();
@@ -8359,13 +8382,16 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
8359
8382
  var _a = state.capturedDocuments,
8360
8383
  idCardFront = _a.idCardFront,
8361
8384
  idCardBack = _a.idCardBack,
8362
- passport = _a.passport;
8385
+ passport = _a.passport,
8386
+ singlePage = _a.singlePage;
8363
8387
  var idFrontImage = idCardFront && dataUrlToBase64Sync(idCardFront.imageData);
8364
8388
  var idBackImage = idCardBack && dataUrlToBase64Sync(idCardBack.imageData);
8365
8389
  var passportImage = passport && dataUrlToBase64Sync(passport.imageData);
8390
+ var singlePageImage = singlePage && dataUrlToBase64Sync(singlePage.imageData);
8366
8391
  idFrontImage && setIdFrontImage(idFrontImage);
8367
8392
  idBackImage && setIdBackImage(idBackImage);
8368
8393
  passportImage && setPassportImage(passportImage);
8394
+ singlePageImage && setIdFrontImage(singlePageImage);
8369
8395
  releaseCameraAccessOnExit && releaseCameraAccess();
8370
8396
  setTimeout(function () {
8371
8397
  onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess({
@@ -8381,9 +8407,9 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
8381
8407
  type: 'resetWizard'
8382
8408
  });
8383
8409
  }, [dispatch]);
8384
- var _8 = React.useState(0),
8385
- attempt = _8[0],
8386
- setAttempt = _8[1];
8410
+ var _9 = React.useState(0),
8411
+ attempt = _9[0],
8412
+ setAttempt = _9[1];
8387
8413
  var onExit = React.useCallback(function () {
8388
8414
  releaseCameraAccess();
8389
8415
  setOverlayDismissed(false);
@@ -8474,9 +8500,9 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
8474
8500
  });
8475
8501
  });
8476
8502
  }, [dispatch]);
8477
- var _9 = React.useState(false),
8478
- progressStarted = _9[0],
8479
- setProgressStarted = _9[1];
8503
+ var _10 = React.useState(false),
8504
+ progressStarted = _10[0],
8505
+ setProgressStarted = _10[1];
8480
8506
  React.useEffect(function () {
8481
8507
  if (state.captureState === 'capturing') {
8482
8508
  setProgressStarted(false);
@@ -12000,7 +12026,8 @@ var defaultVideoIdCaptureThresholds = {
12000
12026
  detection: {
12001
12027
  idCardFront: 0.4,
12002
12028
  idCardBack: 0.5,
12003
- passport: 0.3
12029
+ passport: 0.3,
12030
+ singlePage: 0.3
12004
12031
  },
12005
12032
  focus: {
12006
12033
  idCardFront: {
@@ -12014,12 +12041,17 @@ var defaultVideoIdCaptureThresholds = {
12014
12041
  passport: {
12015
12042
  desktop: 0,
12016
12043
  mobile: 0
12044
+ },
12045
+ singlePage: {
12046
+ desktop: 0,
12047
+ mobile: 0
12017
12048
  }
12018
12049
  },
12019
12050
  goodFrames: {
12020
12051
  idCardFront: 1,
12021
12052
  idCardBack: 1,
12022
- passport: 1
12053
+ passport: 1,
12054
+ singlePage: 1
12023
12055
  },
12024
12056
  flipShortcutThreshold: 0.7
12025
12057
  };
@@ -12091,6 +12123,7 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12091
12123
  stopIdModels = _18.stop,
12092
12124
  onIdPredictionMade = _18.onPredictionMade,
12093
12125
  setThresholds = _18.setThresholds,
12126
+ setRequiredDocumentType = _18.setRequiredDocumentType,
12094
12127
  setDocumentDetectionBoundaries = _18.setDocumentDetectionBoundaries,
12095
12128
  bestFrameDetails = _18.bestFrameDetails,
12096
12129
  resetBestFrame = _18.resetBestFrame,
@@ -12169,6 +12202,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12169
12202
  React.useEffect(function () {
12170
12203
  setThresholds(adjustedThresholds);
12171
12204
  }, [requestedAction, setThresholds, adjustedThresholds]);
12205
+ React.useEffect(function () {
12206
+ setRequiredDocumentType(requestedAction === 'SHOW_PASSPORT' ? 'passport' : requestedAction === 'SHOW_ID_BACK' ? 'idCardBack' : 'idCardFront');
12207
+ }, [requestedAction, setRequiredDocumentType]);
12172
12208
  React.useEffect(function () {
12173
12209
  setDocumentDetectionBoundaries({
12174
12210
  top: 20,
@@ -12191,6 +12227,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12191
12227
  setGoodFramesCount = _28[1];
12192
12228
  var goodFramesThreshold = requestedAction === 'SHOW_PASSPORT' ? adjustedThresholds.goodFrames.passport : requestedAction === 'SHOW_ID_FRONT' ? adjustedThresholds.goodFrames.idCardFront : adjustedThresholds.goodFrames.idCardBack;
12193
12229
  var goodFramesThresholdMet = goodFramesCount >= goodFramesThreshold;
12230
+ var _29 = React.useState(false),
12231
+ isSinglePage = _29[0],
12232
+ setIsSinglePage = _29[1];
12194
12233
  React.useEffect(function () {
12195
12234
  if (!idCaptureModelsEnabled || idModelError) return;
12196
12235
  onIdPredictionMade(function (prediction) {
@@ -12198,7 +12237,8 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12198
12237
  setCurrentDetectionScore(prediction.detectionScore);
12199
12238
  setCurrentDetectedDocumentType(prediction.detectedDocumentType);
12200
12239
  setCurrentFocusScore(prediction.focusScore);
12201
- var detectionThresholdMet = requestedAction === 'SHOW_PASSPORT' ? prediction.passportDetectionThresholdMet : requestedAction === 'SHOW_ID_FRONT' ? prediction.idCardFrontDetectionThresholdMet : prediction.idCardBackDetectionThresholdMet;
12240
+ setIsSinglePage(prediction.singlePageDetectionThresholdMet);
12241
+ var detectionThresholdMet = requestedAction === 'SHOW_PASSPORT' ? prediction.passportDetectionThresholdMet : requestedAction === 'SHOW_ID_BACK' ? prediction.idCardBackDetectionThresholdMet : prediction.idCardFrontDetectionThresholdMet || prediction.singlePageDetectionThresholdMet;
12202
12242
  var isGoodFrame = detectionThresholdMet && prediction.focusThresholdMet;
12203
12243
  var shouldShortcutFlipAnimation = requestedAction === 'FLIP_ID' && isGoodFrame && prediction.idCardBackDetectionScore >= adjustedThresholds.flipShortcutThreshold;
12204
12244
  if (shouldShortcutFlipAnimation) {
@@ -12209,9 +12249,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12209
12249
  } : 0);
12210
12250
  });
12211
12251
  }, [idCaptureModelsEnabled, onIdPredictionMade, idModelError, requestedAction, adjustedThresholds.flipShortcutThreshold]);
12212
- var _29 = React.useState(null),
12213
- idFrontCaptureStartedAt = _29[0],
12214
- setFirstGoodFrameTime = _29[1];
12252
+ var _30 = React.useState(null),
12253
+ idFrontCaptureStartedAt = _30[0],
12254
+ setFirstGoodFrameTime = _30[1];
12215
12255
  React.useEffect(function () {
12216
12256
  if (goodFramesCount === 1) setFirstGoodFrameTime(new Date().getTime());
12217
12257
  }, [goodFramesCount]);
@@ -12232,80 +12272,60 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12232
12272
  var frameHeight = (_e = (_d = videoRef.current) === null || _d === void 0 ? void 0 : _d.videoHeight) !== null && _e !== void 0 ? _e : 0;
12233
12273
  var faceBox = face === null || face === void 0 ? void 0 : face.box;
12234
12274
  var faceCentered = !faceBox || !frameWidth || faceBox.xMin > frameWidth * edgeBoundary && faceBox.yMin > frameHeight * edgeBoundary && faceBox.xMax < frameWidth * (1 - edgeBoundary) && faceBox.yMax < frameHeight * (1 - edgeBoundary);
12235
- var _30 = React.useState(),
12236
- countdownStartedAt = _30[0],
12237
- setCountdownStartedAt = _30[1];
12275
+ var _31 = React.useState(),
12276
+ countdownStartedAt = _31[0],
12277
+ setCountdownStartedAt = _31[1];
12238
12278
  var photoCanvas = React.useRef(null);
12239
12279
  var frameLock = React.useRef(false);
12240
12280
  var captureFrame = React.useCallback(function () {
12241
12281
  return __awaiter(void 0, void 0, void 0, function () {
12242
- var frameBase64, _a;
12243
- return __generator(this, function (_b) {
12244
- switch (_b.label) {
12245
- case 0:
12246
- if (frameLock.current) return [2 /*return*/];
12247
- frameLock.current = true;
12248
- drawToCanvas(photoCanvas.current, videoRef.current);
12249
- frameBase64 = photoCanvas.current.toDataURL('image/jpeg');
12250
- if (!frameBase64) {
12251
- frameLock.current = false;
12252
- return [2 /*return*/];
12253
- }
12254
- _b.label = 1;
12255
- case 1:
12256
- _b.trys.push([1,, 7, 8]);
12257
- if (!(requestedAction == 'SHOW_ID_FRONT')) return [3 /*break*/, 5];
12282
+ var frameBase64;
12283
+ return __generator(this, function (_a) {
12284
+ if (frameLock.current) return [2 /*return*/];
12285
+ frameLock.current = true;
12286
+ drawToCanvas(photoCanvas.current, videoRef.current);
12287
+ frameBase64 = photoCanvas.current.toDataURL('image/jpeg');
12288
+ if (!frameBase64) {
12289
+ frameLock.current = false;
12290
+ return [2 /*return*/];
12291
+ }
12292
+ try {
12293
+ if (requestedAction == 'SHOW_ID_FRONT') {
12258
12294
  if (onIdFrontImageCaptured) {
12259
12295
  onIdFrontImageCaptured(frameBase64);
12260
12296
  }
12261
- if (!skipShowIdCardBack) return [3 /*break*/, 4];
12262
- _a = skipShowIdCardBack === true;
12263
- if (_a) return [3 /*break*/, 3];
12264
- return [4 /*yield*/, skipShowIdCardBack()];
12265
- case 2:
12266
- _a = _b.sent();
12267
- _b.label = 3;
12268
- case 3:
12269
- if (_a) {
12297
+ if (isSinglePage || evaluateShouldSkip(skipShowIdCardBack)) {
12270
12298
  return [2 /*return*/, onIdCaptureComplete()];
12271
12299
  }
12272
- _b.label = 4;
12273
- case 4:
12274
12300
  setRequestedAction('FLIP_ID');
12275
- return [3 /*break*/, 6];
12276
- case 5:
12277
- if (requestedAction == 'SHOW_ID_BACK') {
12278
- if (onIdBackImageCaptured) {
12279
- onIdBackImageCaptured(frameBase64);
12280
- }
12281
- onIdCaptureComplete();
12282
- } else if (requestedAction == 'SHOW_PASSPORT') {
12283
- if (onIdFrontImageCaptured) {
12284
- onIdFrontImageCaptured(frameBase64);
12285
- }
12286
- onIdCaptureComplete();
12301
+ } else if (requestedAction == 'SHOW_ID_BACK') {
12302
+ if (onIdBackImageCaptured) {
12303
+ onIdBackImageCaptured(frameBase64);
12287
12304
  }
12288
- _b.label = 6;
12289
- case 6:
12290
- return [3 /*break*/, 8];
12291
- case 7:
12292
- setDetectedObjects([]);
12293
- setCurrentDetectionScore(0);
12294
- setCurrentFocusScore(0);
12295
- setGoodFramesCount(0);
12296
- setCountdownStartedAt(undefined);
12297
- resetBestFrame();
12298
- frameLock.current = false;
12299
- if (countdownTimeoutRef.current) {
12300
- clearTimeout(countdownTimeoutRef.current);
12305
+ onIdCaptureComplete();
12306
+ } else if (requestedAction == 'SHOW_PASSPORT') {
12307
+ if (onIdFrontImageCaptured) {
12308
+ onIdFrontImageCaptured(frameBase64);
12301
12309
  }
12302
- return [7 /*endfinally*/];
12303
- case 8:
12304
- return [2 /*return*/];
12310
+ onIdCaptureComplete();
12311
+ }
12312
+ } finally {
12313
+ setDetectedObjects([]);
12314
+ setCurrentDetectionScore(0);
12315
+ setCurrentFocusScore(0);
12316
+ setGoodFramesCount(0);
12317
+ setCountdownStartedAt(undefined);
12318
+ setIsSinglePage(false);
12319
+ resetBestFrame();
12320
+ frameLock.current = false;
12321
+ if (countdownTimeoutRef.current) {
12322
+ clearTimeout(countdownTimeoutRef.current);
12323
+ }
12305
12324
  }
12325
+ return [2 /*return*/];
12306
12326
  });
12307
12327
  });
12308
- }, [onIdCaptureComplete, onIdBackImageCaptured, onIdFrontImageCaptured, requestedAction, resetBestFrame, skipShowIdCardBack, videoRef]);
12328
+ }, [videoRef, requestedAction, onIdFrontImageCaptured, isSinglePage, skipShowIdCardBack, onIdCaptureComplete, onIdBackImageCaptured, resetBestFrame]);
12309
12329
  var isFlipping = requestedAction === 'FLIP_ID';
12310
12330
  React.useEffect(function () {
12311
12331
  if (!isFlipping) return;
@@ -12364,9 +12384,9 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12364
12384
  stopSelfieGuidance();
12365
12385
  };
12366
12386
  }, [startSelfieGuidance, stopSelfieGuidance]);
12367
- var _31 = React.useState(0),
12368
- numFramesWithoutFaces = _31[0],
12369
- setNumFramesWithoutFaces = _31[1];
12387
+ var _32 = React.useState(0),
12388
+ numFramesWithoutFaces = _32[0],
12389
+ setNumFramesWithoutFaces = _32[1];
12370
12390
  onSelfiePredictionMade(useDebounce.useThrottledCallback(React.useCallback(function (_a) {
12371
12391
  var face = _a.face;
12372
12392
  if (selfieModelError) return;
@@ -12382,12 +12402,12 @@ var IdVideoCapture = function IdVideoCapture(_a) {
12382
12402
  }
12383
12403
  }, [disableFaceDetectionWhileAudioCapture, disableFaceDetectionWhileAudioCaptureMsDelay, numFramesWithoutFaces, onFaceNotDetected, timeoutStartedAt]);
12384
12404
  var theme = styled.useTheme();
12385
- var _32 = useTranslations(rawVerbiage, {
12405
+ var _33 = useTranslations(rawVerbiage, {
12386
12406
  faceNotCenteredText: 'Please move your face to the center...',
12387
12407
  captureBtnText: 'Capture'
12388
12408
  }),
12389
- captureBtnText = _32.captureBtnText,
12390
- faceNotCenteredText = _32.faceNotCenteredText;
12409
+ captureBtnText = _33.captureBtnText,
12410
+ faceNotCenteredText = _33.faceNotCenteredText;
12391
12411
  var debugScalingDetails = useDebugScalingDetails({
12392
12412
  enabled: debugMode,
12393
12413
  pageWidth: width,
@@ -12462,6 +12482,11 @@ var CountdownContainer = styled__default.default.div(templateObject_1$5 || (temp
12462
12482
  var Countdown = styled__default.default.div(templateObject_2$5 || (templateObject_2$5 = __makeTemplateObject(["\n color: white;\n font-size: 64px;\n font-weight: bold;\n margin: auto;\n"], ["\n color: white;\n font-size: 64px;\n font-weight: bold;\n margin: auto;\n"])));
12463
12483
  var CaptureButtonContainer = styled__default.default.div(templateObject_3$5 || (templateObject_3$5 = __makeTemplateObject(["\n position: fixed;\n bottom: 0;\n width: 100dvw;\n display: flex;\n z-index: 100000;\n"], ["\n position: fixed;\n bottom: 0;\n width: 100dvw;\n display: flex;\n z-index: 100000;\n"])));
12464
12484
  var CaptureButton = styled__default.default(LoaderButton)(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin: 0 auto 25px;\n"], ["\n margin: 0 auto 25px;\n"])));
12485
+ function evaluateShouldSkip(value) {
12486
+ if (value === true) return true;
12487
+ if (typeof value === 'function') return value();
12488
+ return false;
12489
+ }
12465
12490
  var templateObject_1$5, templateObject_2$5, templateObject_3$5, templateObject_4;
12466
12491
 
12467
12492
  var IdVideoCaptureSuccess = function IdVideoCaptureSuccess(_a) {
@@ -12755,7 +12780,8 @@ var VideoIdWizard = function VideoIdWizard(_a) {
12755
12780
  documentDetectionModelUrl: (_g = (_f = idCaptureProps.assets) === null || _f === void 0 ? void 0 : _f.documentDetectionModelUrl) !== null && _g !== void 0 ? _g : '',
12756
12781
  focusModelUrl: (_j = (_h = idCaptureProps.assets) === null || _h === void 0 ? void 0 : _h.focusModelUrl) !== null && _j !== void 0 ? _j : '',
12757
12782
  onModelError: onIdCaptureModelError,
12758
- modelLoadTimeoutMs: idCaptureModelLoadTimeoutMs
12783
+ modelLoadTimeoutMs: idCaptureModelLoadTimeoutMs,
12784
+ allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
12759
12785
  }, /*#__PURE__*/React__namespace.default.createElement(SelfieGuidanceModelsProvider, {
12760
12786
  autoStart: false,
12761
12787
  onModelError: faceLivenessProps === null || faceLivenessProps === void 0 ? void 0 : faceLivenessProps.onModelError,
@@ -13005,7 +13031,8 @@ function CompositeWizard(_a) {
13005
13031
  documentDetectionModelUrl: (_d = (_c = idCaptureProps.assets) === null || _c === void 0 ? void 0 : _c.documentDetectionModelUrl) !== null && _d !== void 0 ? _d : '',
13006
13032
  focusModelUrl: (_f = (_e = idCaptureProps.assets) === null || _e === void 0 ? void 0 : _e.focusModelUrl) !== null && _f !== void 0 ? _f : '',
13007
13033
  onModelError: idCaptureProps.onModelError,
13008
- modelLoadTimeoutMs: idCaptureProps.modelLoadTimeoutMs
13034
+ modelLoadTimeoutMs: idCaptureProps.modelLoadTimeoutMs,
13035
+ allowSinglePageIdCapture: idCaptureProps.allowSinglePageIdCapture
13009
13036
  }, /*#__PURE__*/React__namespace.default.createElement(IdCaptureStateProvider, null, /*#__PURE__*/React__namespace.default.createElement(GuideOrientationContextProvider, null, /*#__PURE__*/React__namespace.default.createElement(IdCaptureWizard, _assign({}, idCaptureProps, {
13010
13037
  onSuccess: onIdCaptureSuccess
13011
13038
  }))))));
@@ -13327,31 +13354,33 @@ var IdValidation = function IdValidation(_a) {
13327
13354
  onLoadingOverlayDismissed = _a.onLoadingOverlayDismissed,
13328
13355
  _d = _a.idCaptureRequirement,
13329
13356
  idCaptureRequirement = _d === void 0 ? 'idCardOrPassport' : _d,
13330
- _e = _a.separateIdCardCaptureSequence,
13331
- separateIdCardCaptureSequence = _e === void 0 ? false : _e,
13332
- _f = _a.idCaptureThresholds,
13333
- idCaptureThresholds = _f === void 0 ? defaultIdCaptureThresholds : _f,
13334
- _g = _a.skipSuccessScreen,
13335
- skipSuccessScreen = _g === void 0 ? false : _g,
13357
+ _e = _a.allowSinglePageIdCapture,
13358
+ allowSinglePageIdCapture = _e === void 0 ? false : _e,
13359
+ _f = _a.separateIdCardCaptureSequence,
13360
+ separateIdCardCaptureSequence = _f === void 0 ? false : _f,
13361
+ _g = _a.idCaptureThresholds,
13362
+ idCaptureThresholds = _g === void 0 ? defaultIdCaptureThresholds : _g,
13363
+ _h = _a.skipSuccessScreen,
13364
+ skipSuccessScreen = _h === void 0 ? false : _h,
13336
13365
  instructions = _a.instructions,
13337
- _h = _a.guideType,
13338
- guideType = _h === void 0 ? 'fit' : _h,
13339
- _j = _a.guideImages,
13340
- guideImages = _j === void 0 ? defaultIdCaptureGuideImages : _j,
13341
- _k = _a.portraitGuidesOnMobile,
13342
- portraitGuidesOnMobile = _k === void 0 ? true : _k,
13343
- _l = _a.rotateLoadingOverlayImageWhenPortrait,
13344
- rotateLoadingOverlayImageWhenPortrait = _l === void 0 ? true : _l,
13345
- _m = _a.modelLoadTimeoutMs,
13346
- modelLoadTimeoutMs = _m === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _m,
13347
- _o = _a.forceFallbackMode,
13348
- forceFallbackMode = _o === void 0 ? false : _o,
13349
- _p = _a.allowIdCardBackToFrontCapture,
13350
- allowIdCardBackToFrontCapture = _p === void 0 ? false : _p,
13351
- _q = _a.enableOverrideWrongDocumentTypeDialog,
13352
- enableOverrideWrongDocumentTypeDialog = _q === void 0 ? false : _q,
13353
- _r = _a.allowOverrideWrongDocumentTypeAfterMs,
13354
- allowOverrideWrongDocumentTypeAfterMs = _r === void 0 ? 8000 : _r,
13366
+ _j = _a.guideType,
13367
+ guideType = _j === void 0 ? 'fit' : _j,
13368
+ _k = _a.guideImages,
13369
+ guideImages = _k === void 0 ? defaultIdCaptureGuideImages : _k,
13370
+ _l = _a.portraitGuidesOnMobile,
13371
+ portraitGuidesOnMobile = _l === void 0 ? true : _l,
13372
+ _m = _a.rotateLoadingOverlayImageWhenPortrait,
13373
+ rotateLoadingOverlayImageWhenPortrait = _m === void 0 ? true : _m,
13374
+ _o = _a.modelLoadTimeoutMs,
13375
+ modelLoadTimeoutMs = _o === void 0 ? defaultDocumentDetectionModelLoadTimeoutMs : _o,
13376
+ _p = _a.forceFallbackMode,
13377
+ forceFallbackMode = _p === void 0 ? false : _p,
13378
+ _q = _a.allowIdCardBackToFrontCapture,
13379
+ allowIdCardBackToFrontCapture = _q === void 0 ? false : _q,
13380
+ _r = _a.enableOverrideWrongDocumentTypeDialog,
13381
+ enableOverrideWrongDocumentTypeDialog = _r === void 0 ? false : _r,
13382
+ _s = _a.allowOverrideWrongDocumentTypeAfterMs,
13383
+ allowOverrideWrongDocumentTypeAfterMs = _s === void 0 ? 8000 : _s,
13355
13384
  onBeforeSubmit = _a.onBeforeSubmit,
13356
13385
  onBeforeDocumentUpload = _a.onBeforeDocumentUpload,
13357
13386
  onDocumentUploadProgress = _a.onDocumentUploadProgress,
@@ -13365,28 +13394,28 @@ var IdValidation = function IdValidation(_a) {
13365
13394
  onUserCancel = _a.onUserCancel,
13366
13395
  onModelError = _a.onModelError,
13367
13396
  onCameraAccessDenied = _a.onCameraAccessDenied,
13368
- _s = _a.theme,
13369
- theme = _s === void 0 ? 'default' : _s,
13370
- _t = _a.assets,
13371
- assets = _t === void 0 ? {} : _t,
13372
- _u = _a.classNames,
13373
- classNames = _u === void 0 ? {} : _u,
13374
- _v = _a.colors,
13375
- colors = _v === void 0 ? {} : _v,
13376
- _w = _a.verbiage,
13377
- verbiage = _w === void 0 ? {} : _w,
13378
- _x = _a.captureSignature,
13379
- captureSignature = _x === void 0 ? false : _x,
13380
- _y = _a.captureSignatureVideo,
13381
- captureSignatureVideo = _y === void 0 ? false : _y,
13382
- _z = _a.captureAdditionalDocuments,
13383
- captureAdditionalDocuments = _z === void 0 ? [] : _z,
13384
- _0 = _a.geolocationEnabled,
13385
- geolocationEnabled = _0 === void 0 ? true : _0,
13386
- _1 = _a.geolocationRequired,
13387
- geolocationRequired = _1 === void 0 ? false : _1,
13388
- _2 = _a.debugMode,
13389
- debugMode = _2 === void 0 ? false : _2;
13397
+ _t = _a.theme,
13398
+ theme = _t === void 0 ? 'default' : _t,
13399
+ _u = _a.assets,
13400
+ assets = _u === void 0 ? {} : _u,
13401
+ _v = _a.classNames,
13402
+ classNames = _v === void 0 ? {} : _v,
13403
+ _w = _a.colors,
13404
+ colors = _w === void 0 ? {} : _w,
13405
+ _x = _a.verbiage,
13406
+ verbiage = _x === void 0 ? {} : _x,
13407
+ _y = _a.captureSignature,
13408
+ captureSignature = _y === void 0 ? false : _y,
13409
+ _z = _a.captureSignatureVideo,
13410
+ captureSignatureVideo = _z === void 0 ? false : _z,
13411
+ _0 = _a.captureAdditionalDocuments,
13412
+ captureAdditionalDocuments = _0 === void 0 ? [] : _0,
13413
+ _1 = _a.geolocationEnabled,
13414
+ geolocationEnabled = _1 === void 0 ? true : _1,
13415
+ _2 = _a.geolocationRequired,
13416
+ geolocationRequired = _2 === void 0 ? false : _2,
13417
+ _3 = _a.debugMode,
13418
+ debugMode = _3 === void 0 ? false : _3;
13390
13419
  useLanguage(lang);
13391
13420
  useDebugLogging(debugMode);
13392
13421
  var idCaptureProps = React.useMemo(function () {
@@ -13396,6 +13425,7 @@ var IdValidation = function IdValidation(_a) {
13396
13425
  onModelError: onModelError,
13397
13426
  precapturedDocuments: precapturedDocuments,
13398
13427
  captureRequirement: idCaptureRequirement,
13428
+ allowSinglePageIdCapture: allowSinglePageIdCapture,
13399
13429
  separateIdCardCaptureSequence: separateIdCardCaptureSequence,
13400
13430
  thresholds: idCaptureThresholds,
13401
13431
  skipSuccessScreen: skipSuccessScreen,
@@ -13418,7 +13448,7 @@ var IdValidation = function IdValidation(_a) {
13418
13448
  verbiage: verbiage,
13419
13449
  debugMode: debugMode
13420
13450
  };
13421
- }, [onExitCapture, onUserCancel, onModelError, precapturedDocuments, idCaptureRequirement, separateIdCardCaptureSequence, idCaptureThresholds, skipSuccessScreen, loadingOverlayMode, customOverlayContent, onLoadingOverlayDismissed, forceFallbackMode, allowIdCardBackToFrontCapture, instructions, guideType, guideImages, portraitGuidesOnMobile, rotateLoadingOverlayImageWhenPortrait, modelLoadTimeoutMs, enableOverrideWrongDocumentTypeDialog, allowOverrideWrongDocumentTypeAfterMs, assets, classNames, colors, verbiage, debugMode]);
13451
+ }, [onExitCapture, onUserCancel, onModelError, precapturedDocuments, idCaptureRequirement, allowSinglePageIdCapture, separateIdCardCaptureSequence, idCaptureThresholds, skipSuccessScreen, loadingOverlayMode, customOverlayContent, onLoadingOverlayDismissed, forceFallbackMode, allowIdCardBackToFrontCapture, instructions, guideType, guideImages, portraitGuidesOnMobile, rotateLoadingOverlayImageWhenPortrait, modelLoadTimeoutMs, enableOverrideWrongDocumentTypeDialog, allowOverrideWrongDocumentTypeAfterMs, assets, classNames, colors, verbiage, debugMode]);
13422
13452
  var additionalDocumentCaptureProps = React.useMemo(function () {
13423
13453
  return {
13424
13454
  documents: captureAdditionalDocuments,