idmission-web-sdk 2.3.170 → 2.3.171-feature-barcode-recapture-a8375e9

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.
@@ -528,8 +528,8 @@ var OverlayImageContainer = styled__default.default.div(templateObject_3$u || (t
528
528
  var OverlayImageRow = styled__default.default.div(templateObject_4$o || (templateObject_4$o = __makeTemplateObject(["\n display: flex;\n margin: auto;\n\n & > div {\n max-height: calc(100% - 320px);\n\n & > img {\n width: 100%;\n max-height: 100%;\n height: auto;\n object-fit: contain;\n }\n }\n"], ["\n display: flex;\n margin: auto;\n\n & > div {\n max-height: calc(100% - 320px);\n\n & > img {\n width: 100%;\n max-height: 100%;\n height: auto;\n object-fit: contain;\n }\n }\n"])));
529
529
  var GrayOverlayContainer = styled__default.default(OverlayContainer)(templateObject_5$g || (templateObject_5$g = __makeTemplateObject(["\n background: #f7f6fb;\n"], ["\n background: #f7f6fb;\n"])));
530
530
  var ButtonsColumn = styled__default.default.div(templateObject_6$a || (templateObject_6$a = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n gap: 15px 0;\n justify-content: center;\n margin-top: 24px;\n"], ["\n display: flex;\n flex-direction: column;\n gap: 15px 0;\n justify-content: center;\n margin-top: 24px;\n"])));
531
- var WideButton = styled__default.default(LoaderButton)(templateObject_7$6 || (templateObject_7$6 = __makeTemplateObject(["\n width: 100%;\n border-radius: 30px;\n"], ["\n width: 100%;\n border-radius: 30px;\n"])));
532
- var WideBorderButton = styled__default.default(WideButton)(templateObject_8$5 || (templateObject_8$5 = __makeTemplateObject(["\n color: ", ";\n background: ", ";\n border: 1px solid\n ", ";\n box-sizing: border-box;\n"], ["\n color: ", ";\n background: ", ";\n border: 1px solid\n ", ";\n box-sizing: border-box;\n"])), function (props) {
531
+ var WideButton = styled__default.default(LoaderButton)(templateObject_7$7 || (templateObject_7$7 = __makeTemplateObject(["\n width: 100%;\n border-radius: 30px;\n"], ["\n width: 100%;\n border-radius: 30px;\n"])));
532
+ var WideBorderButton = styled__default.default(WideButton)(templateObject_8$6 || (templateObject_8$6 = __makeTemplateObject(["\n color: ", ";\n background: ", ";\n border: 1px solid\n ", ";\n box-sizing: border-box;\n"], ["\n color: ", ";\n background: ", ";\n border: 1px solid\n ", ";\n box-sizing: border-box;\n"])), function (props) {
533
533
  var _a, _b;
534
534
  return (_b = (_a = props.colors) === null || _a === void 0 ? void 0 : _a.textColor) !== null && _b !== void 0 ? _b : 'black';
535
535
  }, function (props) {
@@ -539,34 +539,34 @@ var WideBorderButton = styled__default.default(WideButton)(templateObject_8$5 ||
539
539
  var _a, _b;
540
540
  return (_b = (_a = props.colors) === null || _a === void 0 ? void 0 : _a.borderColor) !== null && _b !== void 0 ? _b : 'var(--idm-color-secondary-500)';
541
541
  });
542
- var LoadingOverlayInner = styled__default.default(OverlayInner$2)(templateObject_9$3 || (templateObject_9$3 = __makeTemplateObject(["\n position: relative;\n height: 100%;\n display: flex;\n flex-direction: column;\n padding: 0;\n"], ["\n position: relative;\n height: 100%;\n display: flex;\n flex-direction: column;\n padding: 0;\n"])));
543
- var LoadingOverlayHeader = styled__default.default.div(templateObject_10$2 || (templateObject_10$2 = __makeTemplateObject(["\n text-align: ", ";\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n ", "\n padding-bottom: 0;\n"], ["\n text-align: ", ";\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n ", "\n padding-bottom: 0;\n"])), function (props) {
542
+ var LoadingOverlayInner = styled__default.default(OverlayInner$2)(templateObject_9$4 || (templateObject_9$4 = __makeTemplateObject(["\n position: relative;\n height: 100%;\n display: flex;\n flex-direction: column;\n padding: 0;\n"], ["\n position: relative;\n height: 100%;\n display: flex;\n flex-direction: column;\n padding: 0;\n"])));
543
+ var LoadingOverlayHeader = styled__default.default.div(templateObject_10$3 || (templateObject_10$3 = __makeTemplateObject(["\n text-align: ", ";\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n ", "\n padding-bottom: 0;\n"], ["\n text-align: ", ";\n display: flex;\n flex-direction: column;\n flex-wrap: nowrap;\n ", "\n padding-bottom: 0;\n"])), function (props) {
544
544
  var _a;
545
545
  return (_a = props.theme.textAlign) !== null && _a !== void 0 ? _a : 'center';
546
546
  }, function (props) {
547
547
  return props.theme.padding ? "box-sizing: border-box; padding: ".concat(props.theme.padding, ";") : "";
548
548
  });
549
- var LoadingOverlayGuidanceMessage = styled__default.default(GuidanceMessage)(templateObject_11$2 || (templateObject_11$2 = __makeTemplateObject(["\n padding: 16px 24px;\n margin-top: 16px;\n font-size: 18px;\n font-weight: bold;\n"], ["\n padding: 16px 24px;\n margin-top: 16px;\n font-size: 18px;\n font-weight: bold;\n"])));
550
- var LoadingOverlayImageContainer = styled__default.default(OverlayImageContainer)(templateObject_12$2 || (templateObject_12$2 = __makeTemplateObject(["\n padding: 0;\n max-height: 100%;\n pointer-events: none;\n"], ["\n padding: 0;\n max-height: 100%;\n pointer-events: none;\n"])));
549
+ var LoadingOverlayGuidanceMessage = styled__default.default(GuidanceMessage)(templateObject_11$3 || (templateObject_11$3 = __makeTemplateObject(["\n padding: 16px 24px;\n margin-top: 16px;\n font-size: 18px;\n font-weight: bold;\n"], ["\n padding: 16px 24px;\n margin-top: 16px;\n font-size: 18px;\n font-weight: bold;\n"])));
550
+ var LoadingOverlayImageContainer = styled__default.default(OverlayImageContainer)(templateObject_12$3 || (templateObject_12$3 = __makeTemplateObject(["\n padding: 0;\n max-height: 100%;\n pointer-events: none;\n"], ["\n padding: 0;\n max-height: 100%;\n pointer-events: none;\n"])));
551
551
  var LoadingOverlayProgressBarBackground = styled__default.default.div.attrs({
552
552
  className: 'loading-overlay-progress-bar-background'
553
- })(templateObject_13$2 || (templateObject_13$2 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"])));
553
+ })(templateObject_13$3 || (templateObject_13$3 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"])));
554
554
  var LoadingOverlayProgressBar = styled__default.default.span.attrs({
555
555
  className: 'loading-overlay-progress-bar'
556
- })(templateObject_14$1 || (templateObject_14$1 = __makeTemplateObject(["\n display: block;\n width: ", "%;\n height: 100%;\n left: 0;\n top: 0;\n position: absolute;\n"], ["\n display: block;\n width: ", "%;\n height: 100%;\n left: 0;\n top: 0;\n position: absolute;\n"])), function (props) {
556
+ })(templateObject_14$2 || (templateObject_14$2 = __makeTemplateObject(["\n display: block;\n width: ", "%;\n height: 100%;\n left: 0;\n top: 0;\n position: absolute;\n"], ["\n display: block;\n width: ", "%;\n height: 100%;\n left: 0;\n top: 0;\n position: absolute;\n"])), function (props) {
557
557
  return props.$progress;
558
558
  });
559
559
  var LoadingOverlayProgressIndicator = styled__default.default.span.attrs({
560
560
  className: 'loading-overlay-progress-indicator'
561
- })(templateObject_15$1 || (templateObject_15$1 = __makeTemplateObject(["\n display: block;\n height: 100%;\n animation: ", " 3s ease-in-out;\n animation-fill-mode: both;\n"], ["\n display: block;\n height: 100%;\n animation: ", " 3s ease-in-out;\n animation-fill-mode: both;\n"])), progressBarAnimation);
562
- var LoadingOverlayButtonsRow = styled__default.default(ButtonsRow$2)(templateObject_16$1 || (templateObject_16$1 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n padding: 15px 25px;\n min-height: 100px;\n width: 100%;\n box-sizing: border-box;\n position: relative;\n"], ["\n display: flex;\n flex-direction: row;\n padding: 15px 25px;\n min-height: 100px;\n width: 100%;\n box-sizing: border-box;\n position: relative;\n"])));
563
- var LoadingOverlayLoadingListContainer = styled__default.default.div(templateObject_17$1 || (templateObject_17$1 = __makeTemplateObject(["\n display: flex;\n position: relative;\n z-index: 2;\n"], ["\n display: flex;\n position: relative;\n z-index: 2;\n"])));
564
- var LoadingOverlayLoadingList = styled__default.default.ul(templateObject_18$1 || (templateObject_18$1 = __makeTemplateObject(["\n display: block;\n margin: auto;\n list-style: none;\n padding: 0;\n"], ["\n display: block;\n margin: auto;\n list-style: none;\n padding: 0;\n"])));
565
- var LoadingOverlayLoadingListItem = styled__default.default.li(templateObject_19$1 || (templateObject_19$1 = __makeTemplateObject(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n padding: 2px 1.25rem 2px 0;\n line-height: 1rem;\n"], ["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n padding: 2px 1.25rem 2px 0;\n line-height: 1rem;\n"])));
566
- var LoadingOverlayProgressContainer = styled__default.default.div(templateObject_20$1 || (templateObject_20$1 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"])));
567
- var LoadingOverlayCustomLoadingGraphic = styled__default.default.img(templateObject_21$1 || (templateObject_21$1 = __makeTemplateObject(["\n transform-style: preserve-3d;\n"], ["\n transform-style: preserve-3d;\n"])));
568
- var LoadingOverlayContinueButtonContainer = styled__default.default.div(templateObject_22$1 || (templateObject_22$1 = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
569
- var templateObject_1$N, templateObject_2$I, templateObject_3$u, templateObject_4$o, templateObject_5$g, templateObject_6$a, templateObject_7$6, templateObject_8$5, templateObject_9$3, templateObject_10$2, templateObject_11$2, templateObject_12$2, templateObject_13$2, templateObject_14$1, templateObject_15$1, templateObject_16$1, templateObject_17$1, templateObject_18$1, templateObject_19$1, templateObject_20$1, templateObject_21$1, templateObject_22$1;
561
+ })(templateObject_15$2 || (templateObject_15$2 = __makeTemplateObject(["\n display: block;\n height: 100%;\n animation: ", " 3s ease-in-out;\n animation-fill-mode: both;\n"], ["\n display: block;\n height: 100%;\n animation: ", " 3s ease-in-out;\n animation-fill-mode: both;\n"])), progressBarAnimation);
562
+ var LoadingOverlayButtonsRow = styled__default.default(ButtonsRow$2)(templateObject_16$2 || (templateObject_16$2 = __makeTemplateObject(["\n display: flex;\n flex-direction: row;\n padding: 15px 25px;\n min-height: 100px;\n width: 100%;\n box-sizing: border-box;\n position: relative;\n"], ["\n display: flex;\n flex-direction: row;\n padding: 15px 25px;\n min-height: 100px;\n width: 100%;\n box-sizing: border-box;\n position: relative;\n"])));
563
+ var LoadingOverlayLoadingListContainer = styled__default.default.div(templateObject_17$2 || (templateObject_17$2 = __makeTemplateObject(["\n display: flex;\n position: relative;\n z-index: 2;\n"], ["\n display: flex;\n position: relative;\n z-index: 2;\n"])));
564
+ var LoadingOverlayLoadingList = styled__default.default.ul(templateObject_18$2 || (templateObject_18$2 = __makeTemplateObject(["\n display: block;\n margin: auto;\n list-style: none;\n padding: 0;\n"], ["\n display: block;\n margin: auto;\n list-style: none;\n padding: 0;\n"])));
565
+ var LoadingOverlayLoadingListItem = styled__default.default.li(templateObject_19$2 || (templateObject_19$2 = __makeTemplateObject(["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n padding: 2px 1.25rem 2px 0;\n line-height: 1rem;\n"], ["\n display: inline-flex;\n justify-content: center;\n align-items: center;\n padding: 2px 1.25rem 2px 0;\n line-height: 1rem;\n"])));
566
+ var LoadingOverlayProgressContainer = styled__default.default.div(templateObject_20$2 || (templateObject_20$2 = __makeTemplateObject(["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"], ["\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n"])));
567
+ var LoadingOverlayCustomLoadingGraphic = styled__default.default.img(templateObject_21$2 || (templateObject_21$2 = __makeTemplateObject(["\n transform-style: preserve-3d;\n"], ["\n transform-style: preserve-3d;\n"])));
568
+ var LoadingOverlayContinueButtonContainer = styled__default.default.div(templateObject_22$2 || (templateObject_22$2 = __makeTemplateObject(["\n display: flex;\n"], ["\n display: flex;\n"])));
569
+ var templateObject_1$N, templateObject_2$I, templateObject_3$u, templateObject_4$o, templateObject_5$g, templateObject_6$a, templateObject_7$7, templateObject_8$6, templateObject_9$4, templateObject_10$3, templateObject_11$3, templateObject_12$3, templateObject_13$3, templateObject_14$2, templateObject_15$2, templateObject_16$2, templateObject_17$2, templateObject_18$2, templateObject_19$2, templateObject_20$2, templateObject_21$2, templateObject_22$2;
570
570
 
571
571
  var GeolocationAccessDeniedOverlay = function GeolocationAccessDeniedOverlay(_a) {
572
572
  var accessBlockedImageUrl = _a.accessBlockedImageUrl;
@@ -4684,8 +4684,13 @@ var createCameraStore = function createCameraStore(config) {
4684
4684
  if (!selectedVideoStreamId) return;
4685
4685
  var srcObject = e.currentTarget.srcObject;
4686
4686
  if (srcObject.id === selectedVideoStreamId) {
4687
+ var _a = e.currentTarget,
4688
+ videoWidth = _a.videoWidth,
4689
+ videoHeight = _a.videoHeight;
4687
4690
  set({
4688
- videoLoaded: true
4691
+ videoLoaded: true,
4692
+ videoWidth: videoWidth,
4693
+ videoHeight: videoHeight
4689
4694
  });
4690
4695
  } else {
4691
4696
  set({
@@ -4998,26 +5003,25 @@ var createCameraStore = function createCameraStore(config) {
4998
5003
  };
4999
5004
  var CameraStoreContext = /*#__PURE__*/React.createContext(undefined);
5000
5005
  function CameraStoreProvider(_a) {
5001
- var _b;
5002
5006
  var children = _a.children,
5003
- _c = _a.requestAccessAutomatically,
5004
- requestAccessAutomatically = _c === void 0 ? true : _c,
5005
- _d = _a.preferIphoneContinuityCamera,
5006
- preferIphoneContinuityCamera = _d === void 0 ? true : _d,
5007
- _e = _a.preferFrontFacingCamera,
5008
- preferFrontFacingCamera = _e === void 0 ? false : _e,
5009
- _f = _a.maxVideoWidth,
5010
- maxVideoWidth = _f === void 0 ? 1920 : _f,
5007
+ _b = _a.requestAccessAutomatically,
5008
+ requestAccessAutomatically = _b === void 0 ? true : _b,
5009
+ _c = _a.preferIphoneContinuityCamera,
5010
+ preferIphoneContinuityCamera = _c === void 0 ? true : _c,
5011
+ _d = _a.preferFrontFacingCamera,
5012
+ preferFrontFacingCamera = _d === void 0 ? false : _d,
5013
+ _e = _a.maxVideoWidth,
5014
+ maxVideoWidth = _e === void 0 ? 1920 : _e,
5011
5015
  maxFps = _a.maxFps,
5012
5016
  onCameraAccessDenied = _a.onCameraAccessDenied,
5013
5017
  onCameraTamperingDetected = _a.onCameraTamperingDetected,
5014
5018
  onMicrophoneAccessDenied = _a.onMicrophoneAccessDenied,
5015
- _g = _a.requireMicrophoneAccess,
5016
- requireMicrophoneAccess = _g === void 0 ? false : _g,
5017
- _h = _a.classNames,
5018
- classNames = _h === void 0 ? {} : _h,
5019
- _j = _a.verbiage,
5020
- verbiage = _j === void 0 ? {} : _j;
5019
+ _f = _a.requireMicrophoneAccess,
5020
+ requireMicrophoneAccess = _f === void 0 ? false : _f,
5021
+ _g = _a.classNames,
5022
+ classNames = _g === void 0 ? {} : _g,
5023
+ _h = _a.verbiage,
5024
+ verbiage = _h === void 0 ? {} : _h;
5021
5025
  var videoRef = React.useRef(null);
5022
5026
  var store = React.useRef(undefined);
5023
5027
  store.current || (store.current = createCameraStore({
@@ -5031,16 +5035,6 @@ function CameraStoreProvider(_a) {
5031
5035
  onMicrophoneAccessDenied: onMicrophoneAccessDenied,
5032
5036
  requireMicrophoneAccess: requireMicrophoneAccess
5033
5037
  }));
5034
- var _k = (_b = videoRef.current) !== null && _b !== void 0 ? _b : {},
5035
- videoWidth = _k.videoWidth,
5036
- videoHeight = _k.videoHeight;
5037
- React.useEffect(function () {
5038
- var _a;
5039
- (_a = store.current) === null || _a === void 0 ? void 0 : _a.setState({
5040
- videoWidth: videoWidth,
5041
- videoHeight: videoHeight
5042
- });
5043
- }, [videoWidth, videoHeight]);
5044
5038
  React.useEffect(function () {
5045
5039
  var _a, _b, _c;
5046
5040
  var state = (_a = store.current) === null || _a === void 0 ? void 0 : _a.getState();
@@ -6119,6 +6113,15 @@ var IdCaptureModelsContext = /*#__PURE__*/React.createContext({
6119
6113
  getBestBarcode: function getBestBarcode() {
6120
6114
  return null;
6121
6115
  },
6116
+ startBarcodeRecapturePhase: function startBarcodeRecapturePhase() {
6117
+ return null;
6118
+ },
6119
+ getInitialCaptureBestBarcode: function getInitialCaptureBestBarcode() {
6120
+ return null;
6121
+ },
6122
+ getRecaptureBestBarcode: function getRecaptureBestBarcode() {
6123
+ return null;
6124
+ },
6122
6125
  requiredDocumentType: 'none',
6123
6126
  setRequiredDocumentType: function setRequiredDocumentType() {
6124
6127
  return null;
@@ -6178,6 +6181,14 @@ function IdCaptureModelsProviderInner(_a) {
6178
6181
  var bestBarcodeScore = React.useRef(0);
6179
6182
  var stopDetection = React.useRef(0);
6180
6183
  var analyzeBarcodeReadability = useBarcodeReadabilityAnalysis();
6184
+ // Barcode recapture tracking - separate canvases for initial and recapture sequences
6185
+ var initialCaptureBarcodeCanvas = React.useRef(null);
6186
+ var initialCaptureBarcodeDetails = React.useRef(null);
6187
+ var initialCaptureBarcodeScore = React.useRef(0);
6188
+ var recaptureBarcodeCanvas = React.useRef(null);
6189
+ var recaptureBarcodeDetails = React.useRef(null);
6190
+ var recaptureBarcodeScore = React.useRef(0);
6191
+ var isRecapturePhase = React.useRef(false);
6181
6192
  var _h = React.useState('none'),
6182
6193
  requiredDocumentType = _h[0],
6183
6194
  setRequiredDocumentType = _h[1];
@@ -6202,10 +6213,10 @@ function IdCaptureModelsProviderInner(_a) {
6202
6213
  var _this = this;
6203
6214
  onDocumentDetected(function (prediction) {
6204
6215
  return __awaiter(_this, void 0, void 0, function () {
6205
- var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, pdf417PredictionTime, pdf417PredictionScore, pdf417PredictionThresholdMet, isSinglePage, isRequiredDocumentType, focusPrediction, focusThresholdSet, focusThreshold, barcodeAnalysisResult;
6206
- var _a, _b, _c, _d, _e, _f, _g;
6207
- return __generator(this, function (_h) {
6208
- switch (_h.label) {
6216
+ var stopDetectionAtStart, focusPredictionTime, focusScore, focusThresholdMet, pdf417PredictionTime, pdf417PredictionScore, pdf417PredictionThresholdMet, isSinglePage, isRequiredDocumentType, isInRecapturePhase, shouldRunBarcodeAnalysisDuringRecapture, focusPrediction, focusThresholdSet, focusThreshold, barcodeAnalysisResult, ctx, barcodeAnalysisResult, ctx;
6217
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6218
+ return __generator(this, function (_k) {
6219
+ switch (_k.label) {
6209
6220
  case 0:
6210
6221
  if (!lastPredictionCanvas.current) return [2 /*return*/];
6211
6222
  stopDetectionAtStart = stopDetection.current;
@@ -6219,7 +6230,9 @@ function IdCaptureModelsProviderInner(_a) {
6219
6230
  prediction.singlePageDetectionThresholdMet = false;
6220
6231
  }
6221
6232
  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'));
6222
- if (!(isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable)) return [3 /*break*/, 2];
6233
+ isInRecapturePhase = isRecapturePhase.current;
6234
+ shouldRunBarcodeAnalysisDuringRecapture = isInRecapturePhase && isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentIsStable && prediction.bestDocument && prediction.bestPDF417;
6235
+ if (!(isRequiredDocumentType && prediction.detectedDocumentType !== 'none' && prediction.detectionThresholdMet && prediction.documentInBounds && !prediction.documentTooClose && prediction.documentIsStable)) return [3 /*break*/, 3];
6223
6236
  focusPrediction = makeFocusPrediction(lastPredictionCanvas.current, (_c = prediction.bestDocument) === null || _c === void 0 ? void 0 : _c.box);
6224
6237
  if (focusPrediction) {
6225
6238
  focusScore = focusPrediction.score;
@@ -6242,7 +6255,7 @@ function IdCaptureModelsProviderInner(_a) {
6242
6255
  if (!(enableBarcodeReadabilityModel && prediction.bestDocument && prediction.bestPDF417 && croppedDocumentCanvas.current)) return [3 /*break*/, 2];
6243
6256
  return [4 /*yield*/, analyzeBarcodeReadability(prediction, lastPredictionCanvas.current, croppedDocumentCanvas.current, bestBarcodeCanvas.current, bestBarcodeScore.current)];
6244
6257
  case 1:
6245
- barcodeAnalysisResult = _h.sent();
6258
+ barcodeAnalysisResult = _k.sent();
6246
6259
  pdf417PredictionTime = barcodeAnalysisResult.pdf417PredictionTime;
6247
6260
  pdf417PredictionScore = barcodeAnalysisResult.pdf417PredictionScore;
6248
6261
  pdf417PredictionThresholdMet = barcodeAnalysisResult.pdf417PredictionThresholdMet;
@@ -6252,15 +6265,61 @@ function IdCaptureModelsProviderInner(_a) {
6252
6265
  if (barcodeAnalysisResult.newBestBarcodeDetails) {
6253
6266
  bestBarcodeDetails.current = barcodeAnalysisResult.newBestBarcodeDetails;
6254
6267
  }
6255
- _h.label = 2;
6268
+ // During recapture phase, also track best barcode separately for recapture sequence
6269
+ if (isRecapturePhase.current && recaptureBarcodeCanvas.current && pdf417PredictionScore > recaptureBarcodeScore.current) {
6270
+ recaptureBarcodeScore.current = pdf417PredictionScore;
6271
+ recaptureBarcodeDetails.current = (_g = barcodeAnalysisResult.newBestBarcodeDetails) !== null && _g !== void 0 ? _g : null;
6272
+ // Copy the current best barcode canvas to recapture canvas
6273
+ if (bestBarcodeCanvas.current) {
6274
+ ctx = recaptureBarcodeCanvas.current.getContext('2d');
6275
+ if (ctx) {
6276
+ recaptureBarcodeCanvas.current.width = bestBarcodeCanvas.current.width;
6277
+ recaptureBarcodeCanvas.current.height = bestBarcodeCanvas.current.height;
6278
+ ctx.drawImage(bestBarcodeCanvas.current, 0, 0);
6279
+ }
6280
+ }
6281
+ }
6282
+ _k.label = 2;
6256
6283
  case 2:
6284
+ return [3 /*break*/, 5];
6285
+ case 3:
6286
+ if (!shouldRunBarcodeAnalysisDuringRecapture) return [3 /*break*/, 5];
6287
+ if (!(enableBarcodeReadabilityModel && croppedDocumentCanvas.current && stopDetectionAtStart === stopDetection.current)) return [3 /*break*/, 5];
6288
+ return [4 /*yield*/, analyzeBarcodeReadability(prediction, lastPredictionCanvas.current, croppedDocumentCanvas.current, bestBarcodeCanvas.current, bestBarcodeScore.current)];
6289
+ case 4:
6290
+ barcodeAnalysisResult = _k.sent();
6291
+ pdf417PredictionTime = barcodeAnalysisResult.pdf417PredictionTime;
6292
+ pdf417PredictionScore = barcodeAnalysisResult.pdf417PredictionScore;
6293
+ pdf417PredictionThresholdMet = barcodeAnalysisResult.pdf417PredictionThresholdMet;
6294
+ if (barcodeAnalysisResult.newBestBarcodeScore) {
6295
+ bestBarcodeScore.current = barcodeAnalysisResult.newBestBarcodeScore;
6296
+ }
6297
+ if (barcodeAnalysisResult.newBestBarcodeDetails) {
6298
+ bestBarcodeDetails.current = barcodeAnalysisResult.newBestBarcodeDetails;
6299
+ }
6300
+ // Track best barcode separately for recapture sequence
6301
+ if (recaptureBarcodeCanvas.current && pdf417PredictionScore > recaptureBarcodeScore.current) {
6302
+ recaptureBarcodeScore.current = pdf417PredictionScore;
6303
+ recaptureBarcodeDetails.current = (_h = barcodeAnalysisResult.newBestBarcodeDetails) !== null && _h !== void 0 ? _h : null;
6304
+ // Copy the current best barcode canvas to recapture canvas
6305
+ if (bestBarcodeCanvas.current) {
6306
+ ctx = recaptureBarcodeCanvas.current.getContext('2d');
6307
+ if (ctx) {
6308
+ recaptureBarcodeCanvas.current.width = bestBarcodeCanvas.current.width;
6309
+ recaptureBarcodeCanvas.current.height = bestBarcodeCanvas.current.height;
6310
+ ctx.drawImage(bestBarcodeCanvas.current, 0, 0);
6311
+ }
6312
+ }
6313
+ }
6314
+ _k.label = 5;
6315
+ case 5:
6257
6316
  /**
6258
6317
  * @note
6259
6318
  * This should ALWAYS be called.
6260
6319
  * Do not return early from this function unless
6261
6320
  * lastPredictionCanvas.current is not set
6262
6321
  */
6263
- (_g = onPredictionHandler.current) === null || _g === void 0 ? void 0 : _g.call(onPredictionHandler, _assign(_assign({}, prediction), {
6322
+ (_j = onPredictionHandler.current) === null || _j === void 0 ? void 0 : _j.call(onPredictionHandler, _assign(_assign({}, prediction), {
6264
6323
  focusScore: focusScore,
6265
6324
  focusPredictionTime: focusPredictionTime,
6266
6325
  focusThresholdMet: focusThresholdMet,
@@ -6293,19 +6352,58 @@ function IdCaptureModelsProviderInner(_a) {
6293
6352
  canvas: bestBarcodeCanvas.current
6294
6353
  });
6295
6354
  }, []);
6355
+ var startBarcodeRecapturePhase = React.useCallback(function () {
6356
+ // Snapshot current best barcode to initial capture canvas
6357
+ if (bestBarcodeCanvas.current && initialCaptureBarcodeCanvas.current) {
6358
+ var ctx = initialCaptureBarcodeCanvas.current.getContext('2d');
6359
+ if (ctx) {
6360
+ initialCaptureBarcodeCanvas.current.width = bestBarcodeCanvas.current.width;
6361
+ initialCaptureBarcodeCanvas.current.height = bestBarcodeCanvas.current.height;
6362
+ ctx.drawImage(bestBarcodeCanvas.current, 0, 0);
6363
+ }
6364
+ }
6365
+ initialCaptureBarcodeDetails.current = bestBarcodeDetails.current ? _assign({}, bestBarcodeDetails.current) : null;
6366
+ initialCaptureBarcodeScore.current = bestBarcodeScore.current;
6367
+ // Reset recapture tracking
6368
+ recaptureBarcodeScore.current = 0;
6369
+ recaptureBarcodeDetails.current = null;
6370
+ // Enter recapture phase
6371
+ isRecapturePhase.current = true;
6372
+ }, []);
6373
+ var getInitialCaptureBestBarcode = React.useCallback(function () {
6374
+ if (!initialCaptureBarcodeDetails.current || !initialCaptureBarcodeCanvas.current) return null;
6375
+ return _assign(_assign({}, initialCaptureBarcodeDetails.current), {
6376
+ canvas: initialCaptureBarcodeCanvas.current
6377
+ });
6378
+ }, []);
6379
+ var getRecaptureBestBarcode = React.useCallback(function () {
6380
+ if (!recaptureBarcodeDetails.current || !recaptureBarcodeCanvas.current) return null;
6381
+ return _assign(_assign({}, recaptureBarcodeDetails.current), {
6382
+ canvas: recaptureBarcodeCanvas.current
6383
+ });
6384
+ }, []);
6296
6385
  var _j = React.useState(0),
6297
6386
  canvasKey = _j[0],
6298
6387
  setCanvasKey = _j[1];
6299
6388
  var resetBestFrame = React.useCallback(function () {
6389
+ // During recapture phase, preserve all canvas state to avoid race conditions
6390
+ // that could result in black/empty barcode images on slow devices
6391
+ if (isRecapturePhase.current) {
6392
+ return;
6393
+ }
6300
6394
  stopDetection.current += 1;
6301
- setCanvasKey(function (n) {
6302
- return n + 1;
6303
- });
6304
6395
  clearDocumentDetectionLastPredictionCanvas();
6305
6396
  bestFrameDetails.current = null;
6306
6397
  bestFocusScore.current = 0;
6307
6398
  bestBarcodeScore.current = 0;
6308
6399
  bestBarcodeDetails.current = null;
6400
+ setCanvasKey(function (n) {
6401
+ return n + 1;
6402
+ });
6403
+ initialCaptureBarcodeScore.current = 0;
6404
+ initialCaptureBarcodeDetails.current = null;
6405
+ recaptureBarcodeScore.current = 0;
6406
+ recaptureBarcodeDetails.current = null;
6309
6407
  }, [clearDocumentDetectionLastPredictionCanvas]);
6310
6408
  React.useEffect(function () {
6311
6409
  if (requiredDocumentType) resetBestFrame();
@@ -6371,10 +6469,13 @@ function IdCaptureModelsProviderInner(_a) {
6371
6469
  bestFrameDetails: bestFrameDetails,
6372
6470
  bestBarcodeDetails: bestBarcodeDetails,
6373
6471
  getBestBarcode: getBestBarcode,
6472
+ startBarcodeRecapturePhase: startBarcodeRecapturePhase,
6473
+ getInitialCaptureBestBarcode: getInitialCaptureBestBarcode,
6474
+ getRecaptureBestBarcode: getRecaptureBestBarcode,
6374
6475
  requiredDocumentType: requiredDocumentType,
6375
6476
  setRequiredDocumentType: setRequiredDocumentType
6376
6477
  };
6377
- }, [ready, modelDownloadProgress, modelLoadState, modelWarmingStartedAt, modelError, startDocumentDetection, stopDocumentDetection, load, thresholds, setThresholds, documentDetectionBoundaries, setDocumentDetectionBoundaries, onPredictionMade, detectionTime, focusPredictionTime, barcodeReadabilityPredictionTime, getBestFrame, resetBestFrame, getBestBarcode, requiredDocumentType]);
6478
+ }, [ready, modelDownloadProgress, modelLoadState, modelWarmingStartedAt, modelError, startDocumentDetection, stopDocumentDetection, load, thresholds, setThresholds, documentDetectionBoundaries, setDocumentDetectionBoundaries, onPredictionMade, detectionTime, focusPredictionTime, barcodeReadabilityPredictionTime, getBestFrame, resetBestFrame, getBestBarcode, startBarcodeRecapturePhase, getInitialCaptureBestBarcode, getRecaptureBestBarcode, requiredDocumentType]);
6378
6479
  return /*#__PURE__*/React__namespace.default.createElement(IdCaptureModelsContext.Provider, {
6379
6480
  value: value
6380
6481
  }, /*#__PURE__*/React__namespace.default.createElement(InvisibleCanvasContainer, null, /*#__PURE__*/React__namespace.default.createElement(InvisibleCanvas, {
@@ -6386,6 +6487,12 @@ function IdCaptureModelsProviderInner(_a) {
6386
6487
  }), /*#__PURE__*/React__namespace.default.createElement(InvisibleCanvas, {
6387
6488
  key: "cd-".concat(canvasKey),
6388
6489
  ref: croppedDocumentCanvas
6490
+ }), /*#__PURE__*/React__namespace.default.createElement(InvisibleCanvas, {
6491
+ key: "icb-".concat(canvasKey),
6492
+ ref: initialCaptureBarcodeCanvas
6493
+ }), /*#__PURE__*/React__namespace.default.createElement(InvisibleCanvas, {
6494
+ key: "rcb-".concat(canvasKey),
6495
+ ref: recaptureBarcodeCanvas
6389
6496
  })), children);
6390
6497
  }
6391
6498
  function IdCaptureModelsProvider(_a) {
@@ -6480,6 +6587,8 @@ var initialState$5 = {
6480
6587
  singlePageDetectionThresholdMet: false,
6481
6588
  focusScore: 0,
6482
6589
  focusThresholdMet: false,
6590
+ pdf417PredictionScore: 0,
6591
+ pdf417PredictionThresholdMet: false,
6483
6592
  isGoodFrame: false,
6484
6593
  goodFramesCount: 0,
6485
6594
  goodFramesThreshold: 3,
@@ -6501,30 +6610,42 @@ var initialState$5 = {
6501
6610
  uploadingDocumentsType: null,
6502
6611
  operationStartedAt: null,
6503
6612
  captureStartedAt: null,
6613
+ barcodeRecaptureStartedAt: null,
6614
+ initialBarcodeScore: 0,
6615
+ recaptureBarcodeScore: null,
6616
+ barcodeRecaptureThreshold: 0,
6617
+ barcodeRecaptureTimeoutMs: 5000,
6618
+ initialCaptureBarcodeImage: null,
6619
+ recaptureBarcodeImage: null,
6504
6620
  dispatch: function dispatch() {
6505
6621
  return null;
6506
6622
  }
6507
6623
  };
6508
6624
  var _reducer = function reducer(state, action) {
6509
6625
  var _a;
6626
+ var _b, _c;
6510
6627
  switch (action.type) {
6511
6628
  case 'configureWizard':
6512
6629
  {
6513
- var _b = action.payload,
6514
- captureRequirement = _b.captureRequirement,
6515
- precapturedDocuments = _b.precapturedDocuments,
6516
- allowSinglePageIdCapture = _b.allowSinglePageIdCapture,
6517
- allowIdCardBackToFrontCapture = _b.allowIdCardBackToFrontCapture,
6518
- enableOverrideWrongDocumentTypeDialog = _b.enableOverrideWrongDocumentTypeDialog,
6519
- allowOverrideWrongDocumentTypeAfterMs = _b.allowOverrideWrongDocumentTypeAfterMs,
6520
- allowUploadingDocumentsFromStorage = _b.allowUploadingDocumentsFromStorage;
6630
+ var _d = action.payload,
6631
+ captureRequirement = _d.captureRequirement,
6632
+ precapturedDocuments = _d.precapturedDocuments,
6633
+ allowSinglePageIdCapture = _d.allowSinglePageIdCapture,
6634
+ allowIdCardBackToFrontCapture = _d.allowIdCardBackToFrontCapture,
6635
+ enableOverrideWrongDocumentTypeDialog = _d.enableOverrideWrongDocumentTypeDialog,
6636
+ allowOverrideWrongDocumentTypeAfterMs = _d.allowOverrideWrongDocumentTypeAfterMs,
6637
+ allowUploadingDocumentsFromStorage = _d.allowUploadingDocumentsFromStorage,
6638
+ barcodeRecaptureThreshold = _d.barcodeRecaptureThreshold,
6639
+ barcodeRecaptureTimeoutMs = _d.barcodeRecaptureTimeoutMs;
6521
6640
  var newState = _assign(_assign({}, state), {
6522
6641
  captureRequirement: captureRequirement,
6523
6642
  allowSinglePageIdCapture: allowSinglePageIdCapture !== null && allowSinglePageIdCapture !== void 0 ? allowSinglePageIdCapture : false,
6524
6643
  allowIdCardBackToFrontCapture: allowIdCardBackToFrontCapture !== null && allowIdCardBackToFrontCapture !== void 0 ? allowIdCardBackToFrontCapture : false,
6525
6644
  enableOverrideWrongDocumentTypeDialog: enableOverrideWrongDocumentTypeDialog,
6526
6645
  allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs,
6527
- allowUploadingDocumentsFromStorage: allowUploadingDocumentsFromStorage
6646
+ allowUploadingDocumentsFromStorage: allowUploadingDocumentsFromStorage,
6647
+ barcodeRecaptureThreshold: barcodeRecaptureThreshold !== null && barcodeRecaptureThreshold !== void 0 ? barcodeRecaptureThreshold : 0,
6648
+ barcodeRecaptureTimeoutMs: barcodeRecaptureTimeoutMs !== null && barcodeRecaptureTimeoutMs !== void 0 ? barcodeRecaptureTimeoutMs : 5000
6528
6649
  });
6529
6650
  if (captureRequirement === 'idCardBack') newState.requestedDocumentType = 'idCardBack';
6530
6651
  if (captureRequirement === 'passport') newState.requestedDocumentType = 'passport';
@@ -6581,26 +6702,28 @@ var _reducer = function reducer(state, action) {
6581
6702
  });
6582
6703
  case 'objectsDetected':
6583
6704
  {
6584
- var _c = action.payload.prediction,
6585
- detectedObjects = _c.detectedObjects,
6586
- detectionThresholdMet = _c.detectionThresholdMet,
6587
- detectedDocumentType = _c.detectedDocumentType,
6588
- idCardFrontDetectionScore = _c.idCardFrontDetectionScore,
6589
- idCardFrontDetectionThresholdMet = _c.idCardFrontDetectionThresholdMet,
6590
- idCardBackDetectionScore = _c.idCardBackDetectionScore,
6591
- idCardBackDetectionThresholdMet = _c.idCardBackDetectionThresholdMet,
6592
- passportDetectionScore = _c.passportDetectionScore,
6593
- passportDetectionThresholdMet = _c.passportDetectionThresholdMet,
6594
- singlePageDetectionScore = _c.singlePageDetectionScore,
6595
- singlePageDetectionThresholdMet = _c.singlePageDetectionThresholdMet,
6596
- bestDocument = _c.bestDocument,
6597
- documentInBounds = _c.documentInBounds,
6598
- documentTooClose = _c.documentTooClose,
6599
- documentIsStable = _c.documentIsStable,
6600
- focusScore = _c.focusScore,
6601
- focusThresholdMet = _c.focusThresholdMet,
6602
- frameWidth = _c.frameWidth,
6603
- frameHeight = _c.frameHeight;
6705
+ var _e = action.payload.prediction,
6706
+ detectedObjects = _e.detectedObjects,
6707
+ detectionThresholdMet = _e.detectionThresholdMet,
6708
+ detectedDocumentType = _e.detectedDocumentType,
6709
+ idCardFrontDetectionScore = _e.idCardFrontDetectionScore,
6710
+ idCardFrontDetectionThresholdMet = _e.idCardFrontDetectionThresholdMet,
6711
+ idCardBackDetectionScore = _e.idCardBackDetectionScore,
6712
+ idCardBackDetectionThresholdMet = _e.idCardBackDetectionThresholdMet,
6713
+ passportDetectionScore = _e.passportDetectionScore,
6714
+ passportDetectionThresholdMet = _e.passportDetectionThresholdMet,
6715
+ singlePageDetectionScore = _e.singlePageDetectionScore,
6716
+ singlePageDetectionThresholdMet = _e.singlePageDetectionThresholdMet,
6717
+ bestDocument = _e.bestDocument,
6718
+ documentInBounds = _e.documentInBounds,
6719
+ documentTooClose = _e.documentTooClose,
6720
+ documentIsStable = _e.documentIsStable,
6721
+ focusScore = _e.focusScore,
6722
+ focusThresholdMet = _e.focusThresholdMet,
6723
+ pdf417PredictionScore = _e.pdf417PredictionScore,
6724
+ pdf417PredictionThresholdMet = _e.pdf417PredictionThresholdMet,
6725
+ frameWidth = _e.frameWidth,
6726
+ frameHeight = _e.frameHeight;
6604
6727
  var frameCapturedAt = new Date();
6605
6728
  var frameCaptureRate = 0;
6606
6729
  var goodFramesThreshold = state.goodFramesThreshold;
@@ -6680,6 +6803,8 @@ var _reducer = function reducer(state, action) {
6680
6803
  singlePageDetectionThresholdMet: singlePageDetectionThresholdMet,
6681
6804
  focusScore: focusScore,
6682
6805
  focusThresholdMet: focusThresholdMet,
6806
+ pdf417PredictionScore: pdf417PredictionScore,
6807
+ pdf417PredictionThresholdMet: pdf417PredictionThresholdMet,
6683
6808
  isGoodFrame: isGoodFrame,
6684
6809
  goodFramesCount: goodFramesCount,
6685
6810
  goodFramesThreshold: goodFramesThreshold,
@@ -6733,7 +6858,18 @@ var _reducer = function reducer(state, action) {
6733
6858
  });
6734
6859
  var remainingRequirements = remainingIdCaptureRequirements(state.captureRequirement, newState.capturedDocuments, state.requestedDocumentType);
6735
6860
  if (remainingRequirements.length === 0) {
6736
- newState.captureState = 'complete';
6861
+ // Check if we just captured ID back and need barcode recapture
6862
+ var justCapturedIdBack = action.payload.documentType === 'idCardBack';
6863
+ var barcodeScore = (_c = (_b = state.capturedDocuments.idBarcodeImage) === null || _b === void 0 ? void 0 : _b.barcodeReadabilityScore) !== null && _c !== void 0 ? _c : 0;
6864
+ var needsBarcodeRecapture = justCapturedIdBack && state.barcodeRecaptureThreshold > 0 && barcodeScore < state.barcodeRecaptureThreshold;
6865
+ if (needsBarcodeRecapture) {
6866
+ // Skip 'complete' and go directly to barcode recapture
6867
+ newState.captureState = 'requestingBetterBarcode';
6868
+ newState.barcodeRecaptureStartedAt = new Date();
6869
+ newState.initialBarcodeScore = barcodeScore;
6870
+ } else {
6871
+ newState.captureState = 'complete';
6872
+ }
6737
6873
  } else {
6738
6874
  newState.requestedDocumentType = remainingRequirements[0];
6739
6875
  if (state.requestedDocumentType === 'idCardFront' && newState.requestedDocumentType === 'idCardBack' || state.requestedDocumentType === 'idCardBack' && newState.requestedDocumentType === 'idCardFront') {
@@ -6760,8 +6896,8 @@ var _reducer = function reducer(state, action) {
6760
6896
  case 'documentsCaptured':
6761
6897
  {
6762
6898
  var newState = _assign({}, state);
6763
- for (var _d = 0, _e = action.payload; _d < _e.length; _d++) {
6764
- var doc = _e[_d];
6899
+ for (var _f = 0, _g = action.payload; _f < _g.length; _f++) {
6900
+ var doc = _g[_f];
6765
6901
  newState = _reducer(newState, {
6766
6902
  type: 'documentCaptured',
6767
6903
  payload: doc
@@ -6811,13 +6947,49 @@ var _reducer = function reducer(state, action) {
6811
6947
  requestedDocumentType: requestedDocumentType
6812
6948
  });
6813
6949
  }
6950
+ case 'barcodeRecaptureStarted':
6951
+ return _assign(_assign({}, state), {
6952
+ captureState: 'requestingBetterBarcode',
6953
+ barcodeRecaptureStartedAt: new Date(),
6954
+ initialBarcodeScore: action.payload.initialBarcodeScore,
6955
+ initialCaptureBarcodeImage: action.payload.initialCaptureBarcodeImage,
6956
+ recaptureBarcodeScore: null,
6957
+ recaptureBarcodeImage: null,
6958
+ goodFramesCount: 0,
6959
+ capturing: false
6960
+ });
6961
+ case 'barcodeRecaptureScoreUpdated':
6962
+ return _assign(_assign({}, state), {
6963
+ recaptureBarcodeScore: action.payload.recaptureBarcodeScore
6964
+ });
6965
+ case 'recaptureBarcodeImageCaptured':
6966
+ return _assign(_assign({}, state), {
6967
+ recaptureBarcodeImage: action.payload.recaptureBarcodeImage
6968
+ });
6969
+ case 'barcodeRecaptureCompleted':
6970
+ return _assign(_assign({}, state), {
6971
+ captureState: 'complete',
6972
+ barcodeRecaptureStartedAt: null
6973
+ });
6814
6974
  case 'resetWizard':
6815
6975
  return _assign(_assign({}, initialState$5), {
6816
6976
  dispatch: state.dispatch,
6977
+ // Preserve all configuration values
6978
+ captureRequirement: state.captureRequirement,
6979
+ allowSinglePageIdCapture: state.allowSinglePageIdCapture,
6980
+ allowIdCardBackToFrontCapture: state.allowIdCardBackToFrontCapture,
6981
+ enableOverrideWrongDocumentTypeDialog: state.enableOverrideWrongDocumentTypeDialog,
6982
+ allowOverrideWrongDocumentTypeAfterMs: state.allowOverrideWrongDocumentTypeAfterMs,
6817
6983
  allowUploadingDocumentsFromStorage: state.allowUploadingDocumentsFromStorage,
6984
+ barcodeRecaptureThreshold: state.barcodeRecaptureThreshold,
6985
+ barcodeRecaptureTimeoutMs: state.barcodeRecaptureTimeoutMs,
6986
+ // Reset capture-specific state
6818
6987
  captureState: state.allowUploadingDocumentsFromStorage ? 'initializing' : 'capturing',
6819
- captureRequirement: state.captureRequirement,
6820
- allowIdCardBackToFrontCapture: state.allowIdCardBackToFrontCapture
6988
+ barcodeRecaptureStartedAt: null,
6989
+ initialBarcodeScore: 0,
6990
+ recaptureBarcodeScore: null,
6991
+ initialCaptureBarcodeImage: null,
6992
+ recaptureBarcodeImage: null
6821
6993
  });
6822
6994
  default:
6823
6995
  return state;
@@ -7249,36 +7421,36 @@ function extractSize(entry, sizeType) {
7249
7421
  }
7250
7422
 
7251
7423
  var IdCapture = function IdCapture(_a) {
7252
- var _b, _c, _d, _e, _f, _g;
7424
+ var _b, _c, _d, _e, _f, _g, _h, _j;
7253
7425
  var requiredDocumentType = _a.requiredDocumentType,
7254
- _h = _a.thresholds,
7255
- thresholds = _h === void 0 ? defaultIdCaptureThresholds : _h,
7426
+ _k = _a.thresholds,
7427
+ thresholds = _k === void 0 ? defaultIdCaptureThresholds : _k,
7256
7428
  guidanceMessage = _a.guidanceMessage,
7257
7429
  guidanceSatisfied = _a.guidanceSatisfied,
7258
7430
  onCapture = _a.onCapture,
7259
- _j = _a.classNames,
7260
- classNames = _j === void 0 ? {} : _j,
7261
- _k = _a.colors,
7262
- colors = _k === void 0 ? {} : _k,
7263
- _l = _a.verbiage,
7264
- rawVerbiage = _l === void 0 ? {} : _l,
7265
- _m = _a.debugMode,
7266
- debugMode = _m === void 0 ? false : _m;
7267
- var _o = useResizeObserver(),
7268
- ref = _o.ref,
7269
- _p = _o.width,
7270
- width = _p === void 0 ? 1 : _p,
7271
- _q = _o.height,
7272
- height = _q === void 0 ? 1 : _q;
7431
+ _l = _a.classNames,
7432
+ classNames = _l === void 0 ? {} : _l,
7433
+ _m = _a.colors,
7434
+ colors = _m === void 0 ? {} : _m,
7435
+ _o = _a.verbiage,
7436
+ rawVerbiage = _o === void 0 ? {} : _o,
7437
+ _p = _a.debugMode,
7438
+ debugMode = _p === void 0 ? false : _p;
7439
+ var _q = useResizeObserver(),
7440
+ ref = _q.ref,
7441
+ _r = _q.width,
7442
+ width = _r === void 0 ? 1 : _r,
7443
+ _s = _q.height,
7444
+ height = _s === void 0 ? 1 : _s;
7273
7445
  var state = useIdCaptureStore();
7274
7446
  var isRearFacing = useCameraStore().isRearFacing;
7275
- var _r = useIdCaptureModelsContext(),
7276
- modelsReady = _r.ready,
7277
- setThresholds = _r.setThresholds,
7278
- detectionTime = _r.detectionTime,
7279
- focusPredictionTime = _r.focusPredictionTime,
7280
- getBestFrame = _r.getBestFrame,
7281
- getBestBarcode = _r.getBestBarcode;
7447
+ var _t = useIdCaptureModelsContext(),
7448
+ modelsReady = _t.ready,
7449
+ setThresholds = _t.setThresholds,
7450
+ detectionTime = _t.detectionTime,
7451
+ focusPredictionTime = _t.focusPredictionTime,
7452
+ getBestFrame = _t.getBestFrame,
7453
+ getBestBarcode = _t.getBestBarcode;
7282
7454
  React.useEffect(function () {
7283
7455
  return dispatchIdCaptureAction({
7284
7456
  type: 'captureInitialized'
@@ -7303,7 +7475,7 @@ var IdCapture = function IdCapture(_a) {
7303
7475
  }
7304
7476
  });
7305
7477
  }, [height, width]);
7306
- var shouldCapture = state.goodFramesThresholdMet && !state.capturing && timeSince(state.captureStartedAt) >= 3000;
7478
+ var shouldCapture = state.captureState === 'capturing' && state.goodFramesThresholdMet && !state.capturing && timeSince(state.captureStartedAt) >= 3000;
7307
7479
  React.useEffect(function () {
7308
7480
  if (!shouldCapture) return;
7309
7481
  dispatchIdCaptureAction({
@@ -7403,13 +7575,18 @@ var IdCapture = function IdCapture(_a) {
7403
7575
  "$flipX": !isRearFacing,
7404
7576
  scaling: debugScalingDetails
7405
7577
  }, state.detectedObjects.map(function (obj, i) {
7578
+ // During barcode recapture, render PDF417 barcodes with green color
7579
+ var isBarcodeRecapture = state.captureState === 'requestingBetterBarcode';
7580
+ var isBarcode = obj.label === 'PDF417';
7581
+ var color = isBarcodeRecapture && isBarcode ? 'green' : undefined;
7406
7582
  return /*#__PURE__*/React__namespace.default.createElement(IdCaptureDetectedObjectDebugBox, {
7407
7583
  key: i,
7408
7584
  obj: obj,
7409
7585
  scaling: debugScalingDetails,
7410
- flipX: !isRearFacing
7586
+ flipX: !isRearFacing,
7587
+ color: color
7411
7588
  });
7412
- }))), 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")))));
7589
+ }))), 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.pdf417PredictionThresholdMet ? '✅' : '❌', " Current Barcode Score: ", state.pdf417PredictionScore.toFixed(3), /*#__PURE__*/React__namespace.default.createElement("br", null), getBestBarcode() ? '✅' : '❌', " Best Barcode Score:", ' ', (_j = (_h = getBestBarcode()) === null || _h === void 0 ? void 0 : _h.score.toFixed(3)) !== null && _j !== void 0 ? _j : 'N/A', /*#__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")))));
7413
7590
  };
7414
7591
  var timeSince = function timeSince(t) {
7415
7592
  if (!t) return 0;
@@ -8289,11 +8466,11 @@ var ProgressBarBackground$1 = styled__default.default(LoadingOverlayProgressBarB
8289
8466
  var _a, _b, _c, _d;
8290
8467
  return (_d = (_c = (_b = (_a = props.theme) === null || _a === void 0 ? void 0 : _a.idCapture) === null || _b === void 0 ? void 0 : _b.loadingOverlay) === null || _c === void 0 ? void 0 : _c.progressBarBackgroundOpacity) !== null && _d !== void 0 ? _d : 0.75;
8291
8468
  });
8292
- var ProgressIndicator$1 = styled__default.default(LoadingOverlayProgressIndicator)(templateObject_7$5 || (templateObject_7$5 = __makeTemplateObject(["\n background: ", ";\n"], ["\n background: ", ";\n"])), function (props) {
8469
+ var ProgressIndicator$1 = styled__default.default(LoadingOverlayProgressIndicator)(templateObject_7$6 || (templateObject_7$6 = __makeTemplateObject(["\n background: ", ";\n"], ["\n background: ", ";\n"])), function (props) {
8293
8470
  var _a, _b, _c, _d;
8294
8471
  return (_d = (_c = (_b = (_a = props.theme) === null || _a === void 0 ? void 0 : _a.idCapture) === null || _b === void 0 ? void 0 : _b.loadingOverlay) === null || _c === void 0 ? void 0 : _c.progressBarIndicatorColor) !== null && _d !== void 0 ? _d : 'var(--idm-color-primary-500)';
8295
8472
  });
8296
- var ContinueButton$1 = styled__default.default(LoaderButton)(templateObject_8$4 || (templateObject_8$4 = __makeTemplateObject(["\n margin: auto;\n white-space: nowrap;\n ", "\n ", "\n \n &:focus-visible {\n ", "\n box-shadow: none;\n }\n\n &.disabled {\n background: ", ";\n color: ", ";\n border: ", ";\n }\n"], ["\n margin: auto;\n white-space: nowrap;\n ", "\n ", "\n \n &:focus-visible {\n ", "\n box-shadow: none;\n }\n\n &.disabled {\n background: ", ";\n color: ", ";\n border: ", ";\n }\n"])), function (props) {
8473
+ var ContinueButton$1 = styled__default.default(LoaderButton)(templateObject_8$5 || (templateObject_8$5 = __makeTemplateObject(["\n margin: auto;\n white-space: nowrap;\n ", "\n ", "\n \n &:focus-visible {\n ", "\n box-shadow: none;\n }\n\n &.disabled {\n background: ", ";\n color: ", ";\n border: ", ";\n }\n"], ["\n margin: auto;\n white-space: nowrap;\n ", "\n ", "\n \n &:focus-visible {\n ", "\n box-shadow: none;\n }\n\n &.disabled {\n background: ", ";\n color: ", ";\n border: ", ";\n }\n"])), function (props) {
8297
8474
  var _a, _b, _c, _d, _e, _f;
8298
8475
  return ((_c = (_b = (_a = props.theme) === null || _a === void 0 ? void 0 : _a.idCapture) === null || _b === void 0 ? void 0 : _b.loadingOverlay) === null || _c === void 0 ? void 0 : _c.progressBarFontSize) ? "font-size: ".concat((_f = (_e = (_d = props.theme) === null || _d === void 0 ? void 0 : _d.idCapture) === null || _e === void 0 ? void 0 : _e.loadingOverlay) === null || _f === void 0 ? void 0 : _f.progressBarFontSize, ";") : '';
8299
8476
  }, function (props) {
@@ -8312,7 +8489,7 @@ var ContinueButton$1 = styled__default.default(LoaderButton)(templateObject_8$4
8312
8489
  var _a, _b, _c, _d;
8313
8490
  return (_d = (_c = (_b = (_a = props.theme) === null || _a === void 0 ? void 0 : _a.idCapture) === null || _b === void 0 ? void 0 : _b.loadingOverlay) === null || _c === void 0 ? void 0 : _c.continueBtnDisabledBorder) !== null && _d !== void 0 ? _d : 'none';
8314
8491
  });
8315
- var templateObject_1$F, templateObject_2$B, templateObject_3$p, templateObject_4$j, templateObject_5$e, templateObject_6$9, templateObject_7$5, templateObject_8$4;
8492
+ var templateObject_1$F, templateObject_2$B, templateObject_3$p, templateObject_4$j, templateObject_5$e, templateObject_6$9, templateObject_7$6, templateObject_8$5;
8316
8493
 
8317
8494
  var ContinuityCameraCheckboxContainer = styled__default.default.div(templateObject_1$E || (templateObject_1$E = __makeTemplateObject(["\n margin-top: 15px;\n margin-bottom: 15px;\n"], ["\n margin-top: 15px;\n margin-bottom: 15px;\n"])));
8318
8495
  var ContinuityCameraCheckbox = styled__default.default.input(templateObject_2$A || (templateObject_2$A = __makeTemplateObject(["\n margin-right: 8px;\n"], ["\n margin-right: 8px;\n"])));
@@ -8499,6 +8676,14 @@ var FlexCard = styled__default.default(Card)(templateObject_2$z || (templateObje
8499
8676
  var templateObject_1$D, templateObject_2$z;
8500
8677
 
8501
8678
  var imageDisplayOrder = ['idCardFront', 'idCardBack', 'idBarcodeImage', 'passport', 'singlePage', 'idFrontIrImage', 'idBackIrImage', 'idFrontUvImage', 'idBackUvImage'];
8679
+ var downloadImage = function downloadImage(dataUrl, filename) {
8680
+ var link = document.createElement('a');
8681
+ link.href = dataUrl;
8682
+ link.download = filename;
8683
+ document.body.appendChild(link);
8684
+ link.click();
8685
+ document.body.removeChild(link);
8686
+ };
8502
8687
  var IdCaptureSuccess = function IdCaptureSuccess(_a) {
8503
8688
  var capturedDocuments = _a.capturedDocuments,
8504
8689
  onSubmitClick = _a.onSubmitClick,
@@ -8510,8 +8695,22 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
8510
8695
  _d = _a.verbiage,
8511
8696
  rawVerbiage = _d === void 0 ? {} : _d,
8512
8697
  _e = _a.debugMode,
8513
- debugMode = _e === void 0 ? false : _e;
8698
+ debugMode = _e === void 0 ? false : _e,
8699
+ initialBarcodeScore = _a.initialBarcodeScore,
8700
+ recaptureBarcodeScore = _a.recaptureBarcodeScore,
8701
+ initialCaptureBarcodeImage = _a.initialCaptureBarcodeImage,
8702
+ recaptureBarcodeImage = _a.recaptureBarcodeImage;
8514
8703
  var submissionStatus = React.useContext(SubmissionContext).submissionStatus;
8704
+ if (debugMode) {
8705
+ log('[IdCaptureSuccess] Debug info:', {
8706
+ debugMode: debugMode,
8707
+ initialBarcodeScore: initialBarcodeScore,
8708
+ recaptureBarcodeScore: recaptureBarcodeScore,
8709
+ shouldShow: debugMode && initialBarcodeScore !== undefined,
8710
+ condition1: debugMode,
8711
+ condition2: initialBarcodeScore !== undefined
8712
+ });
8713
+ }
8515
8714
  var verbiage = useTranslations(rawVerbiage, {
8516
8715
  headingText: 'ID Capture Successful',
8517
8716
  retryText: 'Retry',
@@ -8531,6 +8730,7 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
8531
8730
  }, /*#__PURE__*/React__namespace.default.createElement(ImageRow, {
8532
8731
  className: classNames.imageRow
8533
8732
  }, imageDisplayOrder.map(function (name) {
8733
+ var _a, _b, _c, _d, _e, _f;
8534
8734
  var doc = capturedDocuments[name];
8535
8735
  if (!doc) return null;
8536
8736
  return /*#__PURE__*/React__namespace.default.createElement(ImageCol$1, {
@@ -8540,7 +8740,57 @@ var IdCaptureSuccess = function IdCaptureSuccess(_a) {
8540
8740
  image: doc,
8541
8741
  className: classNames.image,
8542
8742
  alt: doc.documentType
8543
- }), debugMode && (/*#__PURE__*/React__namespace.default.createElement(DebugPre, null, name === 'idBarcodeImage' ? "Document Type: ".concat(doc.documentType, "\nReadability Score: ").concat(doc.barcodeReadabilityScore) : "Document Type: ".concat(doc.documentType, "\nDetection Score: ").concat(doc.detectionScore, "\nFocus Score: ").concat(doc.focusScore, "\nBounding Box: ").concat(JSON.stringify(doc.boundingBox)))));
8743
+ }), debugMode && (/*#__PURE__*/React__namespace.default.createElement(DebugInfoContainer, null, name === 'idBarcodeImage' ? (/*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, /*#__PURE__*/React__namespace.default.createElement(DebugSection, null, /*#__PURE__*/React__namespace.default.createElement(DebugLabel, null, "Document Type:"), /*#__PURE__*/React__namespace.default.createElement(DebugValue, null, doc.documentType)), /*#__PURE__*/React__namespace.default.createElement(DebugSection, null, /*#__PURE__*/React__namespace.default.createElement(DebugLabel, null, "Readability Score:"), /*#__PURE__*/React__namespace.default.createElement(ScoreBadge, {
8744
+ "$score": (_a = doc.barcodeReadabilityScore) !== null && _a !== void 0 ? _a : 0,
8745
+ "$type": "readability"
8746
+ }, ((_b = doc.barcodeReadabilityScore) !== null && _b !== void 0 ? _b : 0).toFixed(3))), initialBarcodeScore !== undefined && (recaptureBarcodeScore !== null && recaptureBarcodeScore !== undefined ? (/*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonCard, null, /*#__PURE__*/React__namespace.default.createElement(ComparisonHeader, null, "\uD83D\uDCCA Barcode Recapture Analysis"), /*#__PURE__*/React__namespace.default.createElement(ComparisonRow, null, /*#__PURE__*/React__namespace.default.createElement(ComparisonLabel, null, "Initial Capture:"), /*#__PURE__*/React__namespace.default.createElement(ComparisonScoreBadge, null, initialBarcodeScore.toFixed(3))), /*#__PURE__*/React__namespace.default.createElement(ComparisonRow, null, /*#__PURE__*/React__namespace.default.createElement(ComparisonLabel, null, "After Recapture:"), /*#__PURE__*/React__namespace.default.createElement(ComparisonScoreBadge, null, recaptureBarcodeScore.toFixed(3))), /*#__PURE__*/React__namespace.default.createElement(ComparisonDivider, null), /*#__PURE__*/React__namespace.default.createElement(ComparisonRow, null, /*#__PURE__*/React__namespace.default.createElement(ComparisonLabel, null, "Improvement:"), /*#__PURE__*/React__namespace.default.createElement(ImprovementBadge, {
8747
+ "$improved": recaptureBarcodeScore > initialBarcodeScore
8748
+ }, recaptureBarcodeScore > initialBarcodeScore ? '↑' : '→', ' ', Math.abs(recaptureBarcodeScore - initialBarcodeScore).toFixed(3), ' ', "(", recaptureBarcodeScore > initialBarcodeScore ? 'Better' : 'Same/Worse', ")")), (initialCaptureBarcodeImage || recaptureBarcodeImage) && (/*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, /*#__PURE__*/React__namespace.default.createElement(ComparisonDivider, null), /*#__PURE__*/React__namespace.default.createElement(ComparisonHeader, {
8749
+ style: {
8750
+ marginTop: '0.25rem'
8751
+ }
8752
+ }, "\uD83D\uDD0D Visual Comparison"), /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonImagesContainer, null, initialCaptureBarcodeImage && (/*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonImageWrapper, null, /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonImageLabel, null, "Initial Capture"), /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonImage, {
8753
+ src: initialCaptureBarcodeImage,
8754
+ alt: "Initial capture barcode",
8755
+ onDoubleClick: function onDoubleClick() {
8756
+ return downloadImage(initialCaptureBarcodeImage, "barcode-initial-".concat(initialBarcodeScore.toFixed(3), ".jpg"));
8757
+ },
8758
+ title: "Double-click to download"
8759
+ }), /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonScoreLabel, {
8760
+ "$isHigher": initialBarcodeScore >= recaptureBarcodeScore
8761
+ }, initialBarcodeScore.toFixed(3)))), recaptureBarcodeImage && (/*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonImageWrapper, null, /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonImageLabel, null, "Recapture"), /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonImage, {
8762
+ src: recaptureBarcodeImage,
8763
+ alt: "Recapture barcode",
8764
+ onDoubleClick: function onDoubleClick() {
8765
+ return downloadImage(recaptureBarcodeImage, "barcode-recapture-".concat(recaptureBarcodeScore.toFixed(3), ".jpg"));
8766
+ },
8767
+ title: "Double-click to download"
8768
+ }), /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonScoreLabel, {
8769
+ "$isHigher": recaptureBarcodeScore > initialBarcodeScore
8770
+ }, recaptureBarcodeScore.toFixed(3))))))))) : (/*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonCard, null, /*#__PURE__*/React__namespace.default.createElement(ComparisonHeader, null, "\u26A0\uFE0F Recapture Attempted"), /*#__PURE__*/React__namespace.default.createElement(ComparisonRow, null, /*#__PURE__*/React__namespace.default.createElement(ComparisonLabel, null, "Initial Score:"), /*#__PURE__*/React__namespace.default.createElement(ComparisonScoreBadge, null, initialBarcodeScore.toFixed(3))), /*#__PURE__*/React__namespace.default.createElement(ComparisonRow, null, /*#__PURE__*/React__namespace.default.createElement(ComparisonLabel, null, "Recapture Result:"), /*#__PURE__*/React__namespace.default.createElement(ComparisonValue, null, "No barcode found")), initialCaptureBarcodeImage && (/*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, /*#__PURE__*/React__namespace.default.createElement(ComparisonDivider, null), /*#__PURE__*/React__namespace.default.createElement(ComparisonHeader, {
8771
+ style: {
8772
+ marginTop: '0.25rem'
8773
+ }
8774
+ }, "\uD83D\uDD0D Barcode Image (kept)"), /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonImagesContainer, {
8775
+ style: {
8776
+ gridTemplateColumns: '1fr'
8777
+ }
8778
+ }, /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonImageWrapper, null, /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonImageLabel, null, "Initial Capture"), /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonImage, {
8779
+ src: initialCaptureBarcodeImage,
8780
+ alt: "Initial capture barcode",
8781
+ onDoubleClick: function onDoubleClick() {
8782
+ return downloadImage(initialCaptureBarcodeImage, "barcode-initial-".concat(initialBarcodeScore.toFixed(3), ".jpg"));
8783
+ },
8784
+ title: "Double-click to download"
8785
+ }), /*#__PURE__*/React__namespace.default.createElement(BarcodeComparisonScoreLabel, {
8786
+ "$isHigher": true
8787
+ }, initialBarcodeScore.toFixed(3))))))))))) : (/*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, /*#__PURE__*/React__namespace.default.createElement(DebugSection, null, /*#__PURE__*/React__namespace.default.createElement(DebugLabel, null, "Document Type:"), /*#__PURE__*/React__namespace.default.createElement(DebugValue, null, doc.documentType)), /*#__PURE__*/React__namespace.default.createElement(DebugSection, null, /*#__PURE__*/React__namespace.default.createElement(DebugLabel, null, "Detection Score:"), /*#__PURE__*/React__namespace.default.createElement(ScoreBadge, {
8788
+ "$score": (_c = doc.detectionScore) !== null && _c !== void 0 ? _c : 0,
8789
+ "$type": "detection"
8790
+ }, ((_d = doc.detectionScore) !== null && _d !== void 0 ? _d : 0).toFixed(3))), /*#__PURE__*/React__namespace.default.createElement(DebugSection, null, /*#__PURE__*/React__namespace.default.createElement(DebugLabel, null, "Focus Score:"), /*#__PURE__*/React__namespace.default.createElement(ScoreBadge, {
8791
+ "$score": (_e = doc.focusScore) !== null && _e !== void 0 ? _e : 0,
8792
+ "$type": "focus"
8793
+ }, ((_f = doc.focusScore) !== null && _f !== void 0 ? _f : 0).toFixed(3))), /*#__PURE__*/React__namespace.default.createElement(DebugSection, null, /*#__PURE__*/React__namespace.default.createElement(DebugLabel, null, "Bounding Box:"), /*#__PURE__*/React__namespace.default.createElement(DebugValue, null, JSON.stringify(doc.boundingBox, null, 2))))))));
8544
8794
  }))), /*#__PURE__*/React__namespace.default.createElement(ButtonsColumn, {
8545
8795
  className: classNames.buttonsRow
8546
8796
  }, /*#__PURE__*/React__namespace.default.createElement(WideButton, {
@@ -8563,8 +8813,91 @@ var ImagesContainer = styled__default.default(OverlayImageContainer)(templateObj
8563
8813
  var ImageRow = styled__default.default(OverlayImageRow)(templateObject_3$o || (templateObject_3$o = __makeTemplateObject(["\n max-width: 100%;\n flex-direction: column;\n position: relative;\n width: 100%;\n"], ["\n max-width: 100%;\n flex-direction: column;\n position: relative;\n width: 100%;\n"])));
8564
8814
  var ImageCol$1 = styled__default.default.div(templateObject_4$i || (templateObject_4$i = __makeTemplateObject(["\n width: 450px;\n max-width: 100%;\n max-height: none !important;\n"], ["\n width: 450px;\n max-width: 100%;\n max-height: none !important;\n"])));
8565
8815
  var StyledImage = styled__default.default(CapturedDocumentImg)(templateObject_5$d || (templateObject_5$d = __makeTemplateObject(["\n width: 100%;\n border-radius: 12px;\n"], ["\n width: 100%;\n border-radius: 12px;\n"])));
8566
- var DebugPre = styled__default.default.pre(templateObject_6$8 || (templateObject_6$8 = __makeTemplateObject(["\n display: block;\n text-align: left;\n width: 100%;\n max-width: 100%;\n overflow-x: auto;\n"], ["\n display: block;\n text-align: left;\n width: 100%;\n max-width: 100%;\n overflow-x: auto;\n"])));
8567
- var templateObject_1$C, templateObject_2$y, templateObject_3$o, templateObject_4$i, templateObject_5$d, templateObject_6$8;
8816
+ var DebugInfoContainer = styled__default.default.div(templateObject_6$8 || (templateObject_6$8 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n gap: 0.375rem;\n margin-top: 0.5rem;\n margin-bottom: 1rem;\n padding: 0.625rem;\n background: #f8f9fa;\n border-radius: 6px;\n border: 1px solid #e9ecef;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 0.8125rem;\n line-height: 1.35;\n text-align: left;\n"], ["\n display: flex;\n flex-direction: column;\n gap: 0.375rem;\n margin-top: 0.5rem;\n margin-bottom: 1rem;\n padding: 0.625rem;\n background: #f8f9fa;\n border-radius: 6px;\n border: 1px solid #e9ecef;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 0.8125rem;\n line-height: 1.35;\n text-align: left;\n"])));
8817
+ var DebugSection = styled__default.default.div(templateObject_7$5 || (templateObject_7$5 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n gap: 0.5rem;\n margin: 0;\n"], ["\n display: flex;\n align-items: center;\n gap: 0.5rem;\n margin: 0;\n"])));
8818
+ var DebugLabel = styled__default.default.span(templateObject_8$4 || (templateObject_8$4 = __makeTemplateObject(["\n font-weight: 600;\n color: #495057;\n font-size: 0.8125rem;\n flex-shrink: 0;\n width: 110px;\n"], ["\n font-weight: 600;\n color: #495057;\n font-size: 0.8125rem;\n flex-shrink: 0;\n width: 110px;\n"])));
8819
+ var DebugValue = styled__default.default.span(templateObject_9$3 || (templateObject_9$3 = __makeTemplateObject(["\n color: #212529;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 0.8125rem;\n"], ["\n color: #212529;\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n font-size: 0.8125rem;\n"])));
8820
+ var ScoreBadge = styled__default.default.span(templateObject_10$2 || (templateObject_10$2 = __makeTemplateObject(["\n display: inline-flex;\n align-items: center;\n padding: 0.1875rem 0.5rem;\n border-radius: 4px;\n font-weight: 600;\n font-size: 0.75rem;\n background: ", ";\n color: ", ";\n border: 1px solid\n ", ";\n"], ["\n display: inline-flex;\n align-items: center;\n padding: 0.1875rem 0.5rem;\n border-radius: 4px;\n font-weight: 600;\n font-size: 0.75rem;\n background: ", ";\n color: ", ";\n border: 1px solid\n ", ";\n"])), function (_a) {
8821
+ var $score = _a.$score,
8822
+ $type = _a.$type;
8823
+ var thresholds = $type === 'readability' ? {
8824
+ good: 0.5,
8825
+ medium: 0.2
8826
+ } : $type === 'detection' ? {
8827
+ good: 0.7,
8828
+ medium: 0.4
8829
+ } : {
8830
+ good: 0.7,
8831
+ medium: 0.4
8832
+ };
8833
+ if ($score >= thresholds.good) return '#d4edda';
8834
+ if ($score >= thresholds.medium) return '#fff3cd';
8835
+ return '#f8d7da';
8836
+ }, function (_a) {
8837
+ var $score = _a.$score,
8838
+ $type = _a.$type;
8839
+ var thresholds = $type === 'readability' ? {
8840
+ good: 0.5,
8841
+ medium: 0.2
8842
+ } : $type === 'detection' ? {
8843
+ good: 0.7,
8844
+ medium: 0.4
8845
+ } : {
8846
+ good: 0.7,
8847
+ medium: 0.4
8848
+ };
8849
+ if ($score >= thresholds.good) return '#155724';
8850
+ if ($score >= thresholds.medium) return '#856404';
8851
+ return '#721c24';
8852
+ }, function (_a) {
8853
+ var $score = _a.$score,
8854
+ $type = _a.$type;
8855
+ var thresholds = $type === 'readability' ? {
8856
+ good: 0.5,
8857
+ medium: 0.2
8858
+ } : $type === 'detection' ? {
8859
+ good: 0.7,
8860
+ medium: 0.4
8861
+ } : {
8862
+ good: 0.7,
8863
+ medium: 0.4
8864
+ };
8865
+ if ($score >= thresholds.good) return '#c3e6cb';
8866
+ if ($score >= thresholds.medium) return '#ffeaa7';
8867
+ return '#f5c6cb';
8868
+ });
8869
+ var BarcodeComparisonCard = styled__default.default.div(templateObject_11$2 || (templateObject_11$2 = __makeTemplateObject(["\n margin-top: 0.375rem;\n padding: 0.625rem;\n background: #e7f3ff;\n border-radius: 6px;\n border: 1px solid #b3d9ff;\n"], ["\n margin-top: 0.375rem;\n padding: 0.625rem;\n background: #e7f3ff;\n border-radius: 6px;\n border: 1px solid #b3d9ff;\n"])));
8870
+ var ComparisonHeader = styled__default.default.div(templateObject_12$2 || (templateObject_12$2 = __makeTemplateObject(["\n font-size: 0.8125rem;\n font-weight: 700;\n margin-bottom: 0.375rem;\n display: flex;\n align-items: center;\n gap: 0.375rem;\n color: #004085;\n"], ["\n font-size: 0.8125rem;\n font-weight: 700;\n margin-bottom: 0.375rem;\n display: flex;\n align-items: center;\n gap: 0.375rem;\n color: #004085;\n"])));
8871
+ var ComparisonRow = styled__default.default.div(templateObject_13$2 || (templateObject_13$2 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 0.25rem;\n gap: 0.75rem;\n font-size: 0.8125rem;\n\n &:last-child {\n margin-bottom: 0;\n }\n"], ["\n display: flex;\n align-items: center;\n justify-content: space-between;\n margin-bottom: 0.25rem;\n gap: 0.75rem;\n font-size: 0.8125rem;\n\n &:last-child {\n margin-bottom: 0;\n }\n"])));
8872
+ var ComparisonLabel = styled__default.default.span(templateObject_14$1 || (templateObject_14$1 = __makeTemplateObject(["\n font-weight: 500;\n color: #495057;\n"], ["\n font-weight: 500;\n color: #495057;\n"])));
8873
+ var ComparisonValue = styled__default.default.span(templateObject_15$1 || (templateObject_15$1 = __makeTemplateObject(["\n font-weight: 600;\n color: #212529;\n"], ["\n font-weight: 600;\n color: #212529;\n"])));
8874
+ var ComparisonDivider = styled__default.default.hr(templateObject_16$1 || (templateObject_16$1 = __makeTemplateObject(["\n border: none;\n border-top: 1px solid #b3d9ff;\n margin: 0.375rem 0;\n"], ["\n border: none;\n border-top: 1px solid #b3d9ff;\n margin: 0.375rem 0;\n"])));
8875
+ var ComparisonScoreBadge = styled__default.default.span(templateObject_17$1 || (templateObject_17$1 = __makeTemplateObject(["\n display: inline-flex;\n align-items: center;\n padding: 0.1875rem 0.5rem;\n border-radius: 4px;\n font-weight: 600;\n font-size: 0.75rem;\n background: white;\n color: #212529;\n border: 1px solid #dee2e6;\n"], ["\n display: inline-flex;\n align-items: center;\n padding: 0.1875rem 0.5rem;\n border-radius: 4px;\n font-weight: 600;\n font-size: 0.75rem;\n background: white;\n color: #212529;\n border: 1px solid #dee2e6;\n"])));
8876
+ var ImprovementBadge = styled__default.default.span(templateObject_18$1 || (templateObject_18$1 = __makeTemplateObject(["\n display: inline-flex;\n align-items: center;\n padding: 0.1875rem 0.5rem;\n border-radius: 4px;\n font-weight: 600;\n font-size: 0.75rem;\n background: ", ";\n color: ", ";\n border: 1px solid ", ";\n"], ["\n display: inline-flex;\n align-items: center;\n padding: 0.1875rem 0.5rem;\n border-radius: 4px;\n font-weight: 600;\n font-size: 0.75rem;\n background: ", ";\n color: ", ";\n border: 1px solid ", ";\n"])), function (_a) {
8877
+ var $improved = _a.$improved;
8878
+ return $improved ? '#d4edda' : '#e2e3e5';
8879
+ }, function (_a) {
8880
+ var $improved = _a.$improved;
8881
+ return $improved ? '#155724' : '#383d41';
8882
+ }, function (_a) {
8883
+ var $improved = _a.$improved;
8884
+ return $improved ? '#c3e6cb' : '#d6d8db';
8885
+ });
8886
+ var BarcodeComparisonImagesContainer = styled__default.default.div(templateObject_19$1 || (templateObject_19$1 = __makeTemplateObject(["\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 1rem;\n margin-top: 0.75rem;\n padding: 0.5rem;\n background: rgba(255, 255, 255, 0.5);\n border-radius: 6px;\n"], ["\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 1rem;\n margin-top: 0.75rem;\n padding: 0.5rem;\n background: rgba(255, 255, 255, 0.5);\n border-radius: 6px;\n"])));
8887
+ var BarcodeComparisonImageWrapper = styled__default.default.div(templateObject_20$1 || (templateObject_20$1 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 0.375rem;\n"], ["\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 0.375rem;\n"])));
8888
+ var BarcodeComparisonImageLabel = styled__default.default.span(templateObject_21$1 || (templateObject_21$1 = __makeTemplateObject(["\n font-size: 0.75rem;\n font-weight: 700;\n color: #004085;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n padding: 0.25rem 0.5rem;\n background: white;\n border-radius: 4px;\n border: 1px solid #b3d9ff;\n"], ["\n font-size: 0.75rem;\n font-weight: 700;\n color: #004085;\n text-transform: uppercase;\n letter-spacing: 0.05em;\n padding: 0.25rem 0.5rem;\n background: white;\n border-radius: 4px;\n border: 1px solid #b3d9ff;\n"])));
8889
+ var BarcodeComparisonImage = styled__default.default.img(templateObject_22$1 || (templateObject_22$1 = __makeTemplateObject(["\n width: 100%;\n height: auto;\n border-radius: 6px;\n border: 2px solid #dee2e6;\n background: white;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n cursor: pointer;\n transition:\n transform 0.15s ease,\n box-shadow 0.15s ease;\n\n &:hover {\n transform: scale(1.02);\n box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);\n }\n\n &:active {\n transform: scale(0.98);\n }\n"], ["\n width: 100%;\n height: auto;\n border-radius: 6px;\n border: 2px solid #dee2e6;\n background: white;\n box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);\n cursor: pointer;\n transition:\n transform 0.15s ease,\n box-shadow 0.15s ease;\n\n &:hover {\n transform: scale(1.02);\n box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);\n }\n\n &:active {\n transform: scale(0.98);\n }\n"])));
8890
+ var BarcodeComparisonScoreLabel = styled__default.default.span(templateObject_23$1 || (templateObject_23$1 = __makeTemplateObject(["\n font-size: 0.8125rem;\n font-weight: 700;\n color: ", ";\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n padding: 0.25rem 0.5rem;\n background: ", ";\n border-radius: 4px;\n border: 1px solid ", ";\n"], ["\n font-size: 0.8125rem;\n font-weight: 700;\n color: ", ";\n font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;\n padding: 0.25rem 0.5rem;\n background: ", ";\n border-radius: 4px;\n border: 1px solid ", ";\n"])), function (_a) {
8891
+ var $isHigher = _a.$isHigher;
8892
+ return $isHigher ? '#155724' : '#495057';
8893
+ }, function (_a) {
8894
+ var $isHigher = _a.$isHigher;
8895
+ return $isHigher ? '#d4edda' : 'white';
8896
+ }, function (_a) {
8897
+ var $isHigher = _a.$isHigher;
8898
+ return $isHigher ? '#c3e6cb' : '#dee2e6';
8899
+ });
8900
+ var templateObject_1$C, templateObject_2$y, templateObject_3$o, templateObject_4$i, templateObject_5$d, templateObject_6$8, templateObject_7$5, templateObject_8$4, templateObject_9$3, templateObject_10$2, templateObject_11$2, templateObject_12$2, templateObject_13$2, templateObject_14$1, templateObject_15$1, templateObject_16$1, templateObject_17$1, templateObject_18$1, templateObject_19$1, templateObject_20$1, templateObject_21$1, templateObject_22$1, templateObject_23$1;
8568
8901
 
8569
8902
  function useShowSuccessScreen(skipSuccessScreen, successScreenReady, onDoneCallback) {
8570
8903
  var _this = this;
@@ -11094,7 +11427,7 @@ var lastDocumentDetectedAtDefaults = {
11094
11427
  none: null
11095
11428
  };
11096
11429
  var IdCaptureWizard = function IdCaptureWizard(_a) {
11097
- var _b, _c, _d, _e, _f;
11430
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
11098
11431
  var onLoadingStarted = _a.onLoadingStarted,
11099
11432
  onLoadingProgress = _a.onLoadingProgress,
11100
11433
  onLoadingCompleted = _a.onLoadingCompleted,
@@ -11105,86 +11438,115 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11105
11438
  onLoadingOverlayDismissed = _a.onLoadingOverlayDismissed,
11106
11439
  onDocumentCaptured = _a.onDocumentCaptured,
11107
11440
  onDocumentDetected = _a.onDocumentDetected,
11108
- _g = _a.documentDetectionThrottleMs,
11109
- documentDetectionThrottleMs = _g === void 0 ? 0 : _g,
11110
- _h = _a.loadingOverlayMode,
11111
- loadingOverlayMode = _h === void 0 ? 'default' : _h,
11441
+ _m = _a.documentDetectionThrottleMs,
11442
+ documentDetectionThrottleMs = _m === void 0 ? 0 : _m,
11443
+ _o = _a.loadingOverlayMode,
11444
+ loadingOverlayMode = _o === void 0 ? 'default' : _o,
11112
11445
  customOverlayContent = _a.customOverlayContent,
11113
11446
  precapturedDocuments = _a.precapturedDocuments,
11114
- _j = _a.captureRequirement,
11115
- captureRequirement = _j === void 0 ? 'idCardOrPassport' : _j,
11116
- _k = _a.allowSinglePageIdCapture,
11117
- allowSinglePageIdCapture = _k === void 0 ? false : _k,
11118
- _l = _a.separateIdCardCaptureSequence,
11119
- separateIdCardCaptureSequence = _l === void 0 ? false : _l,
11120
- _m = _a.thresholds,
11121
- thresholds = _m === void 0 ? defaultIdCaptureThresholds : _m,
11122
- _o = _a.skipSuccessScreen,
11123
- skipSuccessScreen = _o === void 0 ? false : _o,
11447
+ _p = _a.captureRequirement,
11448
+ captureRequirement = _p === void 0 ? 'idCardOrPassport' : _p,
11449
+ _q = _a.allowSinglePageIdCapture,
11450
+ allowSinglePageIdCapture = _q === void 0 ? false : _q,
11451
+ _r = _a.separateIdCardCaptureSequence,
11452
+ separateIdCardCaptureSequence = _r === void 0 ? false : _r,
11453
+ _s = _a.thresholds,
11454
+ thresholds = _s === void 0 ? defaultIdCaptureThresholds : _s,
11455
+ _t = _a.skipSuccessScreen,
11456
+ skipSuccessScreen = _t === void 0 ? false : _t,
11124
11457
  instructions = _a.instructions,
11125
- _p = _a.releaseCameraAccessOnExit,
11126
- releaseCameraAccessOnExit = _p === void 0 ? true : _p,
11127
- _q = _a.guideType,
11128
- guideType = _q === void 0 ? 'fit' : _q,
11129
- _r = _a.portraitGuidesOnMobile,
11130
- portraitGuidesOnMobile = _r === void 0 ? true : _r,
11131
- _s = _a.rotateLoadingOverlayImageWhenPortrait,
11132
- rotateLoadingOverlayImageWhenPortrait = _s === void 0 ? true : _s,
11133
- _t = _a.silentFallback,
11134
- silentFallback = _t === void 0 ? false : _t,
11135
- _u = _a.forceFallbackMode,
11136
- forceFallbackMode = _u === void 0 ? false : _u,
11137
- _v = _a.allowIdCardBackToFrontCapture,
11138
- allowIdCardBackToFrontCapture = _v === void 0 ? false : _v,
11139
- _w = _a.enableOverrideWrongDocumentTypeDialog,
11140
- enableOverrideWrongDocumentTypeDialog = _w === void 0 ? false : _w,
11141
- _x = _a.allowOverrideWrongDocumentTypeAfterMs,
11142
- allowOverrideWrongDocumentTypeAfterMs = _x === void 0 ? 8000 : _x,
11143
- _y = _a.allowUploadingDocumentsFromStorage,
11144
- allowUploadingDocumentsFromStorage = _y === void 0 ? false : _y,
11145
- _z = _a.guideImages,
11146
- guideImages = _z === void 0 ? defaultIdCaptureGuideImages : _z,
11147
- _0 = _a.documentEdgeDistancePct,
11148
- documentEdgeDistancePct = _0 === void 0 ? 0 : _0,
11149
- _1 = _a.assets,
11150
- assets = _1 === void 0 ? {} : _1,
11151
- _2 = _a.classNames,
11152
- classNames = _2 === void 0 ? {} : _2,
11153
- _3 = _a.colors,
11154
- colors = _3 === void 0 ? {} : _3,
11155
- _4 = _a.verbiage,
11156
- verbiage = _4 === void 0 ? {} : _4,
11157
- _5 = _a.debugMode,
11158
- debugMode = _5 === void 0 ? false : _5;
11458
+ _u = _a.releaseCameraAccessOnExit,
11459
+ releaseCameraAccessOnExit = _u === void 0 ? true : _u,
11460
+ _v = _a.guideType,
11461
+ guideType = _v === void 0 ? 'fit' : _v,
11462
+ _w = _a.portraitGuidesOnMobile,
11463
+ portraitGuidesOnMobile = _w === void 0 ? true : _w,
11464
+ _x = _a.rotateLoadingOverlayImageWhenPortrait,
11465
+ rotateLoadingOverlayImageWhenPortrait = _x === void 0 ? true : _x,
11466
+ _y = _a.silentFallback,
11467
+ silentFallback = _y === void 0 ? false : _y,
11468
+ _z = _a.forceFallbackMode,
11469
+ forceFallbackMode = _z === void 0 ? false : _z,
11470
+ _0 = _a.allowIdCardBackToFrontCapture,
11471
+ allowIdCardBackToFrontCapture = _0 === void 0 ? false : _0,
11472
+ _1 = _a.enableOverrideWrongDocumentTypeDialog,
11473
+ enableOverrideWrongDocumentTypeDialog = _1 === void 0 ? false : _1,
11474
+ _2 = _a.allowOverrideWrongDocumentTypeAfterMs,
11475
+ allowOverrideWrongDocumentTypeAfterMs = _2 === void 0 ? 8000 : _2,
11476
+ _3 = _a.allowUploadingDocumentsFromStorage,
11477
+ allowUploadingDocumentsFromStorage = _3 === void 0 ? false : _3,
11478
+ _4 = _a.guideImages,
11479
+ guideImages = _4 === void 0 ? defaultIdCaptureGuideImages : _4,
11480
+ _5 = _a.barcodeRecaptureThreshold,
11481
+ barcodeRecaptureThreshold = _5 === void 0 ? 1 : _5,
11482
+ _6 = _a.barcodeRecaptureTimeoutMs,
11483
+ barcodeRecaptureTimeoutMs = _6 === void 0 ? 5000 : _6,
11484
+ _7 = _a.barcodeRecaptureMoveCloserTimeoutMs,
11485
+ barcodeRecaptureMoveCloserTimeoutMs = _7 === void 0 ? 10000 : _7,
11486
+ _8 = _a.barcodeRecaptureBboxGrowthPct,
11487
+ barcodeRecaptureBboxGrowthPct = _8 === void 0 ? 20 : _8,
11488
+ _9 = _a.documentEdgeDistancePct,
11489
+ documentEdgeDistancePct = _9 === void 0 ? 0 : _9,
11490
+ _10 = _a.assets,
11491
+ assets = _10 === void 0 ? {} : _10,
11492
+ _11 = _a.classNames,
11493
+ classNames = _11 === void 0 ? {} : _11,
11494
+ _12 = _a.colors,
11495
+ colors = _12 === void 0 ? {} : _12,
11496
+ _13 = _a.verbiage,
11497
+ verbiage = _13 === void 0 ? {} : _13,
11498
+ _14 = _a.debugMode,
11499
+ debugMode = _14 === void 0 ? false : _14;
11159
11500
  var state = useIdCaptureStore();
11160
- var _6 = useCameraStore(),
11161
- cameraAccessDenied = _6.cameraAccessDenied,
11162
- requestCameraAccess = _6.requestCameraAccess,
11163
- releaseCameraAccess = _6.releaseCameraAccess;
11164
- var _7 = React.useState(false),
11165
- overlayDismissed = _7[0],
11166
- setOverlayDismissed = _7[1];
11167
- var _8 = useSubmissionContext(),
11168
- submissionStatus = _8.submissionStatus,
11169
- setIdFrontImage = _8.setIdFrontImage,
11170
- setIdBackImage = _8.setIdBackImage,
11171
- setPassportImage = _8.setPassportImage,
11172
- setIdFrontIrImage = _8.setIdFrontIrImage,
11173
- setIdBackIrImage = _8.setIdBackIrImage,
11174
- setIdFrontUvImage = _8.setIdFrontUvImage,
11175
- setIdBackUvImage = _8.setIdBackUvImage,
11176
- setIdBarcodeImage = _8.setIdBarcodeImage,
11177
- logIdFrontCaptureAttempt = _8.logIdFrontCaptureAttempt,
11178
- logIdBackCaptureAttempt = _8.logIdBackCaptureAttempt;
11179
- var _9 = useIdCaptureModelsContext(),
11180
- start = _9.start,
11181
- stop = _9.stop,
11182
- onPredictionMade = _9.onPredictionMade,
11183
- setRequiredDocumentType = _9.setRequiredDocumentType,
11184
- modelError = _9.modelError,
11185
- resetBestFrame = _9.resetBestFrame,
11186
- documentDetectionBoundaries = _9.documentDetectionBoundaries,
11187
- setDocumentDetectionBoundaries = _9.setDocumentDetectionBoundaries;
11501
+ var isCapturing = state.captureState === 'capturing' || state.captureState === 'requestingBetterBarcode';
11502
+ var _15 = useCameraStore(),
11503
+ cameraAccessDenied = _15.cameraAccessDenied,
11504
+ requestCameraAccess = _15.requestCameraAccess,
11505
+ releaseCameraAccess = _15.releaseCameraAccess;
11506
+ var _16 = React.useState(false),
11507
+ overlayDismissed = _16[0],
11508
+ setOverlayDismissed = _16[1];
11509
+ var _17 = useSubmissionContext(),
11510
+ submissionStatus = _17.submissionStatus,
11511
+ setIdFrontImage = _17.setIdFrontImage,
11512
+ setIdBackImage = _17.setIdBackImage,
11513
+ setPassportImage = _17.setPassportImage,
11514
+ setIdFrontIrImage = _17.setIdFrontIrImage,
11515
+ setIdBackIrImage = _17.setIdBackIrImage,
11516
+ setIdFrontUvImage = _17.setIdFrontUvImage,
11517
+ setIdBackUvImage = _17.setIdBackUvImage,
11518
+ setIdBarcodeImage = _17.setIdBarcodeImage,
11519
+ logIdFrontCaptureAttempt = _17.logIdFrontCaptureAttempt,
11520
+ logIdBackCaptureAttempt = _17.logIdBackCaptureAttempt;
11521
+ var _18 = useIdCaptureModelsContext(),
11522
+ start = _18.start,
11523
+ stop = _18.stop,
11524
+ onPredictionMade = _18.onPredictionMade,
11525
+ setRequiredDocumentType = _18.setRequiredDocumentType,
11526
+ modelError = _18.modelError,
11527
+ resetBestFrame = _18.resetBestFrame,
11528
+ documentDetectionBoundaries = _18.documentDetectionBoundaries,
11529
+ setDocumentDetectionBoundaries = _18.setDocumentDetectionBoundaries,
11530
+ getBestBarcode = _18.getBestBarcode,
11531
+ startBarcodeRecapturePhase = _18.startBarcodeRecapturePhase,
11532
+ getRecaptureBestBarcode = _18.getRecaptureBestBarcode;
11533
+ var initialBarcodeBboxRef = React.useRef(null);
11534
+ var recapturePhaseStartedRef = React.useRef(false);
11535
+ var _19 = React.useState(false),
11536
+ barcodeRecaptureGrowthSatisfied = _19[0],
11537
+ setBarcodeRecaptureGrowthSatisfied = _19[1];
11538
+ React.useEffect(function () {
11539
+ // Reset recapture gating whenever we enter/exit the recapture flow
11540
+ if (state.captureState === 'requestingBetterBarcode') {
11541
+ initialBarcodeBboxRef.current = null;
11542
+ recapturePhaseStartedRef.current = false;
11543
+ setBarcodeRecaptureGrowthSatisfied(false);
11544
+ return;
11545
+ }
11546
+ initialBarcodeBboxRef.current = null;
11547
+ recapturePhaseStartedRef.current = false;
11548
+ setBarcodeRecaptureGrowthSatisfied(false);
11549
+ }, [state.captureState]);
11188
11550
  React.useEffect(function () {
11189
11551
  dispatchIdCaptureAction({
11190
11552
  type: 'configureWizard',
@@ -11195,10 +11557,12 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11195
11557
  allowIdCardBackToFrontCapture: allowIdCardBackToFrontCapture,
11196
11558
  enableOverrideWrongDocumentTypeDialog: enableOverrideWrongDocumentTypeDialog,
11197
11559
  allowOverrideWrongDocumentTypeAfterMs: allowOverrideWrongDocumentTypeAfterMs,
11198
- allowUploadingDocumentsFromStorage: allowUploadingDocumentsFromStorage
11560
+ allowUploadingDocumentsFromStorage: allowUploadingDocumentsFromStorage,
11561
+ barcodeRecaptureThreshold: barcodeRecaptureThreshold,
11562
+ barcodeRecaptureTimeoutMs: barcodeRecaptureTimeoutMs
11199
11563
  }
11200
11564
  });
11201
- }, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, allowSinglePageIdCapture, allowUploadingDocumentsFromStorage, captureRequirement, enableOverrideWrongDocumentTypeDialog, precapturedDocuments]);
11565
+ }, [allowIdCardBackToFrontCapture, allowOverrideWrongDocumentTypeAfterMs, allowSinglePageIdCapture, allowUploadingDocumentsFromStorage, barcodeRecaptureThreshold, barcodeRecaptureTimeoutMs, captureRequirement, enableOverrideWrongDocumentTypeDialog, precapturedDocuments]);
11202
11566
  React.useEffect(function () {
11203
11567
  var _a;
11204
11568
  var desiredEdgeDistance = documentEdgeDistancePct !== null && documentEdgeDistancePct !== void 0 ? documentEdgeDistancePct : 0;
@@ -11210,8 +11574,10 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11210
11574
  }, [documentDetectionBoundaries, documentEdgeDistancePct, setDocumentDetectionBoundaries]);
11211
11575
  var documentCount = Object.keys(state.capturedDocuments).length;
11212
11576
  React.useEffect(function () {
11577
+ // Skip reset during barcode recapture - the recapture flow manages its own canvas state
11578
+ if (state.captureState === 'requestingBetterBarcode') return;
11213
11579
  if (documentCount) resetBestFrame();
11214
- }, [documentCount, resetBestFrame]);
11580
+ }, [documentCount, resetBestFrame, state.captureState]);
11215
11581
  var isFallbackMode = forceFallbackMode || modelError;
11216
11582
  var lastDocumentDetectedAt = React.useRef(_assign({}, lastDocumentDetectedAtDefaults));
11217
11583
  var logCaptureMetadata = React.useCallback(function (metadata) {
@@ -11230,24 +11596,62 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11230
11596
  }
11231
11597
  }, [isFallbackMode, logIdBackCaptureAttempt, logIdFrontCaptureAttempt]);
11232
11598
  React.useEffect(function startModelsWhenCapturing() {
11233
- if (!overlayDismissed || state.captureState !== 'capturing') return;
11599
+ if (!overlayDismissed || !isCapturing) return;
11234
11600
  dispatchIdCaptureAction({
11235
11601
  type: 'captureStarted'
11236
11602
  });
11237
11603
  start();
11238
- }, [overlayDismissed, start, state.captureState]);
11604
+ }, [isCapturing, overlayDismissed, start]);
11239
11605
  React.useEffect(function () {
11240
11606
  onPredictionMade(function (prediction) {
11241
- var _a;
11242
- var _b = useIdCaptureStore.getState(),
11243
- captureState = _b.captureState,
11244
- requestedDocumentType = _b.requestedDocumentType;
11607
+ var _a, _b, _c, _d;
11608
+ var _e = useIdCaptureStore.getState(),
11609
+ captureState = _e.captureState,
11610
+ requestedDocumentType = _e.requestedDocumentType;
11245
11611
  var k = "".concat(requestedDocumentType, "DetectionThresholdMet");
11246
11612
  var thresholdMet = prediction[k];
11247
- if (captureState === 'capturing') {
11613
+ if (captureState === 'capturing' || captureState === 'requestingBetterBarcode') {
11614
+ // During barcode recapture, wait until the barcode bbox grows by a configurable %
11615
+ // (to confirm the user moved the camera closer) before we start recapture processing.
11616
+ if (captureState === 'requestingBetterBarcode') {
11617
+ var growthPct = Math.max(0, Math.min(barcodeRecaptureBboxGrowthPct, 200));
11618
+ var requiredMultiplier = 1 + growthPct / 100;
11619
+ if (!recapturePhaseStartedRef.current) {
11620
+ // If growth requirement is disabled, begin recapture immediately.
11621
+ if (requiredMultiplier === 1) {
11622
+ recapturePhaseStartedRef.current = true;
11623
+ setBarcodeRecaptureGrowthSatisfied(true);
11624
+ startBarcodeRecapturePhase();
11625
+ } else {
11626
+ var pdf417Box = (_a = prediction.bestPDF417) === null || _a === void 0 ? void 0 : _a.box;
11627
+ var frameWidth = (_b = prediction.frameWidth) !== null && _b !== void 0 ? _b : 0;
11628
+ var frameHeight = (_c = prediction.frameHeight) !== null && _c !== void 0 ? _c : 0;
11629
+ if (pdf417Box && frameWidth > 0 && frameHeight > 0) {
11630
+ var widthRatio = pdf417Box.width / frameWidth;
11631
+ var heightRatio = pdf417Box.height / frameHeight;
11632
+ if (!initialBarcodeBboxRef.current) {
11633
+ // First observed bbox when we enter recapture.
11634
+ initialBarcodeBboxRef.current = {
11635
+ widthRatio: widthRatio,
11636
+ heightRatio: heightRatio
11637
+ };
11638
+ } else {
11639
+ var baseline = initialBarcodeBboxRef.current;
11640
+ var widthSatisfied = widthRatio >= baseline.widthRatio * requiredMultiplier;
11641
+ var heightSatisfied = heightRatio >= baseline.heightRatio * requiredMultiplier;
11642
+ if (widthSatisfied && heightSatisfied) {
11643
+ recapturePhaseStartedRef.current = true;
11644
+ setBarcodeRecaptureGrowthSatisfied(true);
11645
+ startBarcodeRecapturePhase();
11646
+ }
11647
+ }
11648
+ }
11649
+ }
11650
+ }
11651
+ }
11248
11652
  if (prediction.detectedDocumentType !== 'none') {
11249
11653
  var now = Date.now();
11250
- if (!lastDocumentDetectedAt.current[prediction.detectedDocumentType] || documentDetectionThrottleMs && now - ((_a = lastDocumentDetectedAt.current[prediction.detectedDocumentType]) !== null && _a !== void 0 ? _a : 0) > documentDetectionThrottleMs) {
11654
+ if (!lastDocumentDetectedAt.current[prediction.detectedDocumentType] || documentDetectionThrottleMs && now - ((_d = lastDocumentDetectedAt.current[prediction.detectedDocumentType]) !== null && _d !== void 0 ? _d : 0) > documentDetectionThrottleMs) {
11251
11655
  lastDocumentDetectedAt.current[prediction.detectedDocumentType] = now;
11252
11656
  onDocumentDetected === null || onDocumentDetected === void 0 ? void 0 : onDocumentDetected(prediction.detectedDocumentType);
11253
11657
  }
@@ -11265,7 +11669,7 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11265
11669
  });
11266
11670
  }
11267
11671
  });
11268
- }, [documentDetectionThrottleMs, onDocumentDetected, onPredictionMade, resetBestFrame]);
11672
+ }, [barcodeRecaptureBboxGrowthPct, documentDetectionThrottleMs, onDocumentDetected, onPredictionMade, resetBestFrame, startBarcodeRecapturePhase]);
11269
11673
  React.useEffect(function () {
11270
11674
  if (state.captureState === 'complete') stop();
11271
11675
  }, [state.captureState, stop]);
@@ -11320,9 +11724,9 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11320
11724
  type: 'resetWizard'
11321
11725
  });
11322
11726
  }, []);
11323
- var _10 = React.useState(0),
11324
- attempt = _10[0],
11325
- setAttempt = _10[1];
11727
+ var _20 = React.useState(0),
11728
+ attempt = _20[0],
11729
+ setAttempt = _20[1];
11326
11730
  var onExit = React.useCallback(function () {
11327
11731
  releaseCameraAccess();
11328
11732
  setOverlayDismissed(false);
@@ -11348,20 +11752,25 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11348
11752
  });
11349
11753
  }
11350
11754
  }, [cameraAccessDenied]);
11755
+ var guidanceBarcodeRecaptureText = (_b = verbiage.guidanceBarcodeRecaptureText) !== null && _b !== void 0 ? _b : 'Please move the barcode closer to the camera';
11756
+ var guidanceBarcodeRecaptureInProgressText = (_c = verbiage.guidanceBarcodeRecaptureInProgressText) !== null && _c !== void 0 ? _c : 'Barcode capture in progress, please hold still';
11757
+ var barcodeRecaptureGuidanceMessage = barcodeRecaptureGrowthSatisfied ? guidanceBarcodeRecaptureInProgressText : guidanceBarcodeRecaptureText;
11351
11758
  var idCaptureVerbiages = {
11352
11759
  idCardFront: useTranslations(verbiage.idCardFront, {
11353
11760
  instructionText: 'Scan the front of ID',
11354
11761
  processingIdCardText: "ID card ".concat('idCardFront' in state.capturedDocuments ? 'front' : 'back', " captured.")
11355
11762
  }),
11356
11763
  idCardBack: useTranslations(verbiage.idCardBack, {
11357
- instructionText: 'Scan the back of ID'
11764
+ instructionText: state.captureState === 'requestingBetterBarcode' ? barcodeRecaptureGuidanceMessage : 'Scan the back of ID'
11358
11765
  }),
11359
11766
  passport: useTranslations(verbiage.passport, {
11360
11767
  instructionText: 'Scan the ID page of passport'
11361
11768
  })
11362
11769
  };
11363
11770
  var theme = styled.useTheme();
11364
- var idCaptureVerbiage = idCaptureVerbiages[state.requestedDocumentType];
11771
+ // During barcode recapture, use idCardBack verbiage to show barcode recapture message
11772
+ var verbiageKey = state.captureState === 'requestingBetterBarcode' ? 'idCardBack' : state.requestedDocumentType;
11773
+ var idCaptureVerbiage = idCaptureVerbiages[verbiageKey];
11365
11774
  React.useEffect(function () {
11366
11775
  if (separateIdCardCaptureSequence) return;
11367
11776
  if (state.captureState !== 'requestingFlip') return;
@@ -11375,6 +11784,130 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11375
11784
  clearTimeout(t);
11376
11785
  };
11377
11786
  }, [resetBestFrame, separateIdCardCaptureSequence, state.captureState]);
11787
+ // Handle barcode recapture start - snapshot initial barcode and initialize recapture state
11788
+ React.useEffect(function () {
11789
+ var _a, _b;
11790
+ if (state.captureState !== 'requestingBetterBarcode') return;
11791
+ if (state.initialCaptureBarcodeImage !== null) return; // Already initialized
11792
+ // Get the initial barcode image from capturedDocuments (since resetBestFrame clears the canvas)
11793
+ var initialBarcodeImage = (_b = (_a = state.capturedDocuments.idBarcodeImage) === null || _a === void 0 ? void 0 : _a.imageData) !== null && _b !== void 0 ? _b : null;
11794
+ dispatchIdCaptureAction({
11795
+ type: 'barcodeRecaptureStarted',
11796
+ payload: {
11797
+ initialBarcodeScore: state.initialBarcodeScore,
11798
+ initialCaptureBarcodeImage: initialBarcodeImage
11799
+ }
11800
+ });
11801
+ }, [state.captureState, (_d = state.capturedDocuments.idBarcodeImage) === null || _d === void 0 ? void 0 : _d.imageData, state.initialBarcodeScore, state.initialCaptureBarcodeImage]);
11802
+ // Handle barcode recapture timeout
11803
+ React.useEffect(function () {
11804
+ if (state.captureState !== 'requestingBetterBarcode') return;
11805
+ // Continue detection to try to get a better barcode
11806
+ setTimeout(start, 100);
11807
+ var t = setTimeout(function () {
11808
+ // Move-closer window expired before recapture began
11809
+ if (recapturePhaseStartedRef.current) return;
11810
+ var bestBarcode = getBestBarcode();
11811
+ var improved = !!bestBarcode && bestBarcode.score > state.initialBarcodeScore;
11812
+ if (improved) {
11813
+ log("[IdCaptureWizard] Barcode recapture move-closer window timed out. Found better barcode anyway: ".concat(bestBarcode.score.toFixed(3), " (was ").concat(state.initialBarcodeScore.toFixed(3), ")"));
11814
+ // Persist the "after" image for debug visual comparison, even if the
11815
+ // model-provider recapture tracker was never started.
11816
+ dispatchIdCaptureAction({
11817
+ type: 'recaptureBarcodeImageCaptured',
11818
+ payload: {
11819
+ recaptureBarcodeImage: bestBarcode.canvas.toDataURL('image/jpeg', 0.95)
11820
+ }
11821
+ });
11822
+ dispatchIdCaptureAction({
11823
+ type: 'barcodeCaptured',
11824
+ payload: {
11825
+ imageUrl: bestBarcode.canvas.toDataURL('image/jpeg', 0.95),
11826
+ barcodeReadabilityScore: bestBarcode.score
11827
+ }
11828
+ });
11829
+ } else {
11830
+ log("[IdCaptureWizard] Barcode recapture move-closer window timed out. No better barcode found. Initial score: ".concat(state.initialBarcodeScore.toFixed(3)));
11831
+ }
11832
+ // Record that recapture was attempted (for diagnostics)
11833
+ dispatchIdCaptureAction({
11834
+ type: 'barcodeRecaptureScoreUpdated',
11835
+ payload: {
11836
+ recaptureBarcodeScore: improved ? bestBarcode.score : state.initialBarcodeScore
11837
+ }
11838
+ });
11839
+ dispatchIdCaptureAction({
11840
+ type: 'barcodeRecaptureCompleted'
11841
+ });
11842
+ }, barcodeRecaptureMoveCloserTimeoutMs);
11843
+ return function () {
11844
+ return clearTimeout(t);
11845
+ };
11846
+ }, [barcodeRecaptureMoveCloserTimeoutMs, getBestBarcode, start, state.captureState, state.initialBarcodeScore]);
11847
+ React.useEffect(function () {
11848
+ if (state.captureState !== 'requestingBetterBarcode') return;
11849
+ if (!barcodeRecaptureGrowthSatisfied) return;
11850
+ var t = setTimeout(function () {
11851
+ var _a, _b;
11852
+ // Capture window expired - complete with whatever barcode we have
11853
+ var recaptureBarcode = getRecaptureBestBarcode();
11854
+ var bestBarcode = getBestBarcode();
11855
+ var recaptureScore = (_a = recaptureBarcode === null || recaptureBarcode === void 0 ? void 0 : recaptureBarcode.score) !== null && _a !== void 0 ? _a : null;
11856
+ var improved = !!bestBarcode && bestBarcode.score > state.initialBarcodeScore;
11857
+ // Store the recapture score for diagnostic purposes
11858
+ dispatchIdCaptureAction({
11859
+ type: 'barcodeRecaptureScoreUpdated',
11860
+ payload: {
11861
+ recaptureBarcodeScore: improved ? bestBarcode.score : recaptureScore !== null && recaptureScore !== void 0 ? recaptureScore : state.initialBarcodeScore
11862
+ }
11863
+ });
11864
+ // Store the recapture barcode image if we found one
11865
+ if (recaptureBarcode) {
11866
+ dispatchIdCaptureAction({
11867
+ type: 'recaptureBarcodeImageCaptured',
11868
+ payload: {
11869
+ recaptureBarcodeImage: recaptureBarcode.canvas.toDataURL('image/jpeg', 0.95)
11870
+ }
11871
+ });
11872
+ } else if (improved) {
11873
+ // If we improved but don't have a recapture-specific best tracked,
11874
+ // still persist the "after" image so debug visual comparison works.
11875
+ dispatchIdCaptureAction({
11876
+ type: 'recaptureBarcodeImageCaptured',
11877
+ payload: {
11878
+ recaptureBarcodeImage: bestBarcode.canvas.toDataURL('image/jpeg', 0.95)
11879
+ }
11880
+ });
11881
+ }
11882
+ if (improved) {
11883
+ log("[IdCaptureWizard] Barcode recapture completed. Found better barcode: ".concat(bestBarcode.score.toFixed(3), " (was ").concat(state.initialBarcodeScore.toFixed(3), ")"));
11884
+ dispatchIdCaptureAction({
11885
+ type: 'barcodeCaptured',
11886
+ payload: {
11887
+ imageUrl: bestBarcode.canvas.toDataURL('image/jpeg', 0.95),
11888
+ barcodeReadabilityScore: bestBarcode.score
11889
+ }
11890
+ });
11891
+ } else {
11892
+ log("[IdCaptureWizard] Barcode recapture completed. No better barcode found. Best recapture score: ".concat((_b = recaptureScore === null || recaptureScore === void 0 ? void 0 : recaptureScore.toFixed(3)) !== null && _b !== void 0 ? _b : 'none', ", initial score: ").concat(state.initialBarcodeScore.toFixed(3)));
11893
+ }
11894
+ dispatchIdCaptureAction({
11895
+ type: 'barcodeRecaptureCompleted'
11896
+ });
11897
+ }, barcodeRecaptureTimeoutMs);
11898
+ return function () {
11899
+ return clearTimeout(t);
11900
+ };
11901
+ }, [barcodeRecaptureGrowthSatisfied, barcodeRecaptureTimeoutMs, getBestBarcode, getRecaptureBestBarcode, state.captureState, state.initialBarcodeScore]);
11902
+ // Continue detection during barcode recapture and update barcode if better one found
11903
+ React.useEffect(function () {
11904
+ if (state.captureState !== 'requestingBetterBarcode') return;
11905
+ // Set required document type to idCardBack for barcode detection
11906
+ setRequiredDocumentType('idCardBack');
11907
+ return function () {
11908
+ setRequiredDocumentType('none');
11909
+ };
11910
+ }, [setRequiredDocumentType, state.captureState]);
11378
11911
  React.useEffect(function () {
11379
11912
  if (state.requestedDocumentType === 'idCardFront') {
11380
11913
  if (captureRequirement === 'idCardOrPassport') {
@@ -11413,9 +11946,9 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11413
11946
  });
11414
11947
  });
11415
11948
  }, []);
11416
- var _11 = React.useState(false),
11417
- progressStarted = _11[0],
11418
- setProgressStarted = _11[1];
11949
+ var _21 = React.useState(false),
11950
+ progressStarted = _21[0],
11951
+ setProgressStarted = _21[1];
11419
11952
  React.useEffect(function () {
11420
11953
  if (state.captureState === 'capturing') {
11421
11954
  setProgressStarted(false);
@@ -11443,9 +11976,9 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11443
11976
  verbiage: verbiage.uploadOrCaptureScreen
11444
11977
  });
11445
11978
  }
11446
- var requestedAction = state.captureState === 'requestingFlip' ? 'FLIP_ID' : state.requestedDocumentType === 'idCardBack' ? 'SHOW_ID_BACK' : state.requestedDocumentType === 'passport' ? 'SHOW_PASSPORT' : 'SHOW_ID_FRONT';
11979
+ var requestedAction = state.captureState === 'requestingFlip' ? 'FLIP_ID' : state.captureState === 'requestingBetterBarcode' ? 'SHOW_ID_BACK' : state.requestedDocumentType === 'idCardBack' ? 'SHOW_ID_BACK' : state.requestedDocumentType === 'passport' ? 'SHOW_PASSPORT' : 'SHOW_ID_FRONT';
11447
11980
  var guidesStatus = !overlayDismissed ? 'disabled' : state.isGoodFrame ? 'capturing' : 'ready';
11448
- return /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, /*#__PURE__*/React__namespace.default.createElement(ScalingCameraFeed, null), overlayDismissed && state.captureState === 'capturing' && (/*#__PURE__*/React__namespace.default.createElement(IdCapture, {
11981
+ return /*#__PURE__*/React__namespace.default.createElement(React__namespace.default.Fragment, null, /*#__PURE__*/React__namespace.default.createElement(ScalingCameraFeed, null), overlayDismissed && (state.captureState === 'capturing' || state.captureState === 'requestingBetterBarcode') && (/*#__PURE__*/React__namespace.default.createElement(IdCapture, {
11449
11982
  requiredDocumentType: state.requestedDocumentType,
11450
11983
  thresholds: thresholds,
11451
11984
  onCapture: onCapture,
@@ -11453,11 +11986,18 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11453
11986
  colors: colors,
11454
11987
  verbiage: idCaptureVerbiage,
11455
11988
  debugMode: debugMode
11456
- })), /*#__PURE__*/React__namespace.default.createElement(IdCaptureGuides, {
11989
+ })), overlayDismissed && state.captureState === 'requestingBetterBarcode' && (/*#__PURE__*/React__namespace.default.createElement(GuidanceMessageContainer, {
11990
+ "$top": "",
11991
+ "$bottom": "12.5%",
11992
+ className: (_e = classNames.capture) === null || _e === void 0 ? void 0 : _e.guidanceMessageContainer
11993
+ }, /*#__PURE__*/React__namespace.default.createElement(GuidanceMessage, {
11994
+ "$variant": "default",
11995
+ className: (_f = classNames.capture) === null || _f === void 0 ? void 0 : _f.guidanceMessage
11996
+ }, barcodeRecaptureGuidanceMessage))), /*#__PURE__*/React__namespace.default.createElement(IdCaptureGuides, {
11457
11997
  key: "guides".concat(attempt),
11458
11998
  guideType: guideType,
11459
11999
  status: guidesStatus,
11460
- progress: progressStarted && state.captureState === 'capturing' ? 1 : 0,
12000
+ progress: progressStarted && isCapturing ? 1 : 0,
11461
12001
  portraitGuidesOnMobile: portraitGuidesOnMobile,
11462
12002
  requestedAction: requestedAction,
11463
12003
  images: guideImages,
@@ -11465,15 +12005,15 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11465
12005
  colors: colors,
11466
12006
  verbiage: idCaptureVerbiage,
11467
12007
  isBackToFront: state.allowIdCardBackToFrontCapture && 'idCardBack' in state.capturedDocuments
11468
- }), debugMode && !((_c = (_b = theme.idCapture) === null || _b === void 0 ? void 0 : _b.capturePreview) === null || _c === void 0 ? void 0 : _c.disabled) && state.captureState === 'requestingFlip' && !separateIdCardCaptureSequence && state.imageUrl && (/*#__PURE__*/React__namespace.default.createElement(IdCaptureImagePreview, {
11469
- classNames: (_d = classNames.capture) === null || _d === void 0 ? void 0 : _d.imagePreview,
11470
- text: (_e = idCaptureVerbiages === null || idCaptureVerbiages === void 0 ? void 0 : idCaptureVerbiages.idCardFront) === null || _e === void 0 ? void 0 : _e.processingIdCardText,
12008
+ }), debugMode && !((_h = (_g = theme.idCapture) === null || _g === void 0 ? void 0 : _g.capturePreview) === null || _h === void 0 ? void 0 : _h.disabled) && state.captureState === 'requestingFlip' && !separateIdCardCaptureSequence && state.imageUrl && (/*#__PURE__*/React__namespace.default.createElement(IdCaptureImagePreview, {
12009
+ classNames: (_j = classNames.capture) === null || _j === void 0 ? void 0 : _j.imagePreview,
12010
+ text: (_k = idCaptureVerbiages === null || idCaptureVerbiages === void 0 ? void 0 : idCaptureVerbiages.idCardFront) === null || _k === void 0 ? void 0 : _k.processingIdCardText,
11471
12011
  imageUrl: state.imageUrl
11472
12012
  })), state.captureState !== 'complete' && (/*#__PURE__*/React__namespace.default.createElement("div", {
11473
12013
  id: "idmission-above-guides-content"
11474
12014
  })), (!customOverlayContent || !!customOverlayContent && overlayDismissed) && (/*#__PURE__*/React__namespace.default.createElement(ExitCaptureButton, {
11475
12015
  onClick: onExit,
11476
- className: (_f = classNames.capture) === null || _f === void 0 ? void 0 : _f.exitCaptureBtn
12016
+ className: (_l = classNames.capture) === null || _l === void 0 ? void 0 : _l.exitCaptureBtn
11477
12017
  })), !overlayDismissed && (/*#__PURE__*/React__namespace.default.createElement(IdCaptureLoadingOverlay, {
11478
12018
  key: "loading".concat(attempt),
11479
12019
  mode: loadingOverlayMode,
@@ -11511,7 +12051,14 @@ var IdCaptureWizard = function IdCaptureWizard(_a) {
11511
12051
  onRetryClick: onRetryClick,
11512
12052
  colors: colors.success,
11513
12053
  verbiage: verbiage.success,
11514
- debugMode: debugMode
12054
+ debugMode: debugMode,
12055
+ initialBarcodeScore:
12056
+ // Show diagnostic info if recapture occurred (indicated by recaptureBarcodeScore being set)
12057
+ // If recapture occurred, initialBarcodeScore was set (even if it's 0, which is valid)
12058
+ state.recaptureBarcodeScore !== null ? state.initialBarcodeScore : undefined,
12059
+ recaptureBarcodeScore: state.recaptureBarcodeScore,
12060
+ initialCaptureBarcodeImage: state.initialCaptureBarcodeImage,
12061
+ recaptureBarcodeImage: state.recaptureBarcodeImage
11515
12062
  })));
11516
12063
  };
11517
12064
  function IdCaptureWizardWithProviders(_a) {