gbc-kyc-kit 2.3.7 → 2.3.9

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.
@@ -18075,6 +18075,7 @@ function ErrorHandler(error) {
18075
18075
  } else if (status === "429") {
18076
18076
  console.log(error.response.data);
18077
18077
  }
18078
+ console.log(code, "code", message, "message");
18078
18079
  Q.error(message, {
18079
18080
  position: "top-center",
18080
18081
  autoClose: 5e3,
@@ -32835,7 +32836,6 @@ function getDividerUtilityClass(slot) {
32835
32836
  return generateUtilityClass("MuiDivider", slot);
32836
32837
  }
32837
32838
  const dividerClasses = generateUtilityClasses("MuiDivider", ["root", "absolute", "fullWidth", "inset", "middle", "flexItem", "light", "vertical", "withChildren", "withChildrenVertical", "textAlignRight", "textAlignLeft", "wrapper", "wrapperVertical"]);
32838
- var dividerClasses$1 = dividerClasses;
32839
32839
  const _excluded$1m = ["absolute", "children", "className", "component", "flexItem", "light", "orientation", "role", "textAlign", "variant"];
32840
32840
  const useUtilityClasses$13 = (ownerState) => {
32841
32841
  const {
@@ -35469,11 +35469,11 @@ const MenuItemRoot = styled$1(ButtonBase$1, {
35469
35469
  [`&.${menuItemClasses$1.disabled}`]: {
35470
35470
  opacity: (theme.vars || theme).palette.action.disabledOpacity
35471
35471
  },
35472
- [`& + .${dividerClasses$1.root}`]: {
35472
+ [`& + .${dividerClasses.root}`]: {
35473
35473
  marginTop: theme.spacing(1),
35474
35474
  marginBottom: theme.spacing(1)
35475
35475
  },
35476
- [`& + .${dividerClasses$1.inset}`]: {
35476
+ [`& + .${dividerClasses.inset}`]: {
35477
35477
  marginLeft: 52
35478
35478
  },
35479
35479
  [`& .${listItemTextClasses$1.root}`]: {
@@ -39308,12 +39308,12 @@ const DocumentReaderController = (dataDocument, clientId, authorize, eventId, so
39308
39308
  clientId,
39309
39309
  geolocation
39310
39310
  });
39311
- if (data2.count_try >= 4)
39312
- setUploadDocumentByPhone(true);
39313
39311
  await dataDocument({
39314
39312
  ...error,
39315
39313
  countAttempts: data2.count_try
39316
39314
  });
39315
+ if (error.response.data.code === "020")
39316
+ setUploadDocumentByPhone(true);
39317
39317
  if ((_a = error.response.data) == null ? void 0 : _a.message) {
39318
39318
  message2 = error.response.data.message;
39319
39319
  } else if (status2 === 500) {
@@ -39366,10 +39366,10 @@ const DocumentReaderController = (dataDocument, clientId, authorize, eventId, so
39366
39366
  const isPortrait = usePortrait();
39367
39367
  const videoConstraints = useMemo(() => ({
39368
39368
  width: {
39369
- ideal: isPortrait ? 400 : 640
39369
+ ideal: isPortrait ? 1080 : 1920
39370
39370
  },
39371
39371
  height: {
39372
- ideal: isPortrait ? 640 : 400
39372
+ ideal: isPortrait ? 1920 : 1080
39373
39373
  },
39374
39374
  aspectRatio: {
39375
39375
  ideal: 4 / 5
@@ -39414,106 +39414,40 @@ const DocumentReaderController = (dataDocument, clientId, authorize, eventId, so
39414
39414
  const validateErrorMessageOCR = (message) => {
39415
39415
  return message === "Tipo de documento no v\xE1lido" || message === "Datos de la imagen no reconocidas" || message === "Dato no reconocido(Primer Nombre)" || message == "Dato no reconocido(Primer Apellido)" || message == "";
39416
39416
  };
39417
- const DocumentGuide = ({
39418
- documentType = "id"
39417
+ const InstructionsComponent = ({
39418
+ title,
39419
+ subtitle
39419
39420
  }) => {
39420
- const getGuideDimensions = () => {
39421
- switch (documentType) {
39422
- case "passport":
39423
- return {
39424
- width: "85%",
39425
- height: "60%",
39426
- aspectRatio: "1.4"
39427
- };
39428
- case "driverLicense":
39429
- return {
39430
- width: "85%",
39431
- height: "55%",
39432
- aspectRatio: "1.6"
39433
- };
39434
- case "id":
39435
- default:
39436
- return {
39437
- width: "77%",
39438
- height: "90%",
39439
- aspectRatio: "1.6"
39440
- };
39441
- }
39442
- };
39443
- const dimensions = getGuideDimensions();
39444
39421
  return /* @__PURE__ */ jsxs(Box$1, {
39445
- sx: {
39446
- position: "absolute",
39447
- top: "50%",
39448
- left: "50%",
39449
- transform: "translate(-50%, -50%)",
39450
- width: dimensions.width,
39451
- height: dimensions.height,
39452
- border: "2px dashed rgba(255, 255, 255, 0.7)",
39453
- borderRadius: "8px",
39454
- display: "flex",
39455
- flexDirection: "column",
39456
- justifyContent: "center",
39457
- alignItems: "center",
39458
- zIndex: 5,
39459
- pointerEvents: "none"
39460
- },
39461
- children: [/* @__PURE__ */ jsx$1(Box$1, {
39462
- sx: {
39463
- position: "absolute",
39464
- top: 0,
39465
- left: 0,
39466
- width: "20px",
39467
- height: "20px",
39468
- borderTop: "3px solid #4CAF50",
39469
- borderLeft: "3px solid #4CAF50",
39470
- borderTopLeftRadius: "8px"
39471
- }
39472
- }), /* @__PURE__ */ jsx$1(Box$1, {
39473
- sx: {
39474
- position: "absolute",
39475
- top: 0,
39476
- right: 0,
39477
- width: "20px",
39478
- height: "20px",
39479
- borderTop: "3px solid #4CAF50",
39480
- borderRight: "3px solid #4CAF50",
39481
- borderTopRightRadius: "8px"
39482
- }
39483
- }), /* @__PURE__ */ jsx$1(Box$1, {
39484
- sx: {
39485
- position: "absolute",
39486
- bottom: 0,
39487
- left: 0,
39488
- width: "20px",
39489
- height: "20px",
39490
- borderBottom: "3px solid #4CAF50",
39491
- borderLeft: "3px solid #4CAF50",
39492
- borderBottomLeftRadius: "8px"
39493
- }
39494
- }), /* @__PURE__ */ jsx$1(Box$1, {
39495
- sx: {
39496
- position: "absolute",
39497
- bottom: 0,
39498
- right: 0,
39499
- width: "20px",
39500
- height: "20px",
39501
- borderBottom: "3px solid #4CAF50",
39502
- borderRight: "3px solid #4CAF50",
39503
- borderBottomRightRadius: "8px"
39504
- }
39422
+ children: [/* @__PURE__ */ jsx$1(Typography$1, {
39423
+ variant: "h6",
39424
+ className: "title",
39425
+ mt: 2,
39426
+ children: title
39505
39427
  }), /* @__PURE__ */ jsx$1(Typography$1, {
39506
39428
  variant: "body2",
39507
- sx: {
39508
- color: "white",
39509
- textShadow: "0px 0px 3px rgba(0,0,0,0.8)",
39510
- textAlign: "center",
39511
- padding: "0 10px",
39512
- backgroundColor: "rgba(0,0,0,0.5)",
39513
- borderRadius: "4px",
39514
- marginTop: "10px"
39515
- },
39516
- children: "Coloca el documento dentro del marco"
39429
+ children: subtitle
39430
+ }), /* @__PURE__ */ jsxs(List$1, {
39431
+ dense: true,
39432
+ children: [/* @__PURE__ */ jsxs(ListItem$1, {
39433
+ children: [/* @__PURE__ */ jsx$1(ListItemIcon$1, {
39434
+ children: /* @__PURE__ */ jsx$1(LightMode, {})
39435
+ }), /* @__PURE__ */ jsx$1(ListItemText$1, {
39436
+ primary: "Procura tener buena iluminaci\xF3n"
39437
+ })]
39438
+ }), /* @__PURE__ */ jsxs(ListItem$1, {
39439
+ children: [/* @__PURE__ */ jsx$1(ListItemIcon$1, {
39440
+ children: /* @__PURE__ */ jsx$1(SettingsBrightness, {})
39441
+ }), /* @__PURE__ */ jsx$1(ListItemText$1, {
39442
+ primary: "Evita reflejos en el documento de identidad"
39443
+ })]
39444
+ }), /* @__PURE__ */ jsxs(ListItem$1, {
39445
+ children: [/* @__PURE__ */ jsx$1(ListItemIcon$1, {
39446
+ children: /* @__PURE__ */ jsx$1(Spellcheck, {})
39447
+ }), /* @__PURE__ */ jsx$1(ListItemText$1, {
39448
+ primary: "Procura que el texto en el documento sea legible"
39449
+ })]
39450
+ })]
39517
39451
  })]
39518
39452
  });
39519
39453
  };
@@ -39521,29 +39455,17 @@ function UploadDocument2({
39521
39455
  setActivateCamera,
39522
39456
  activateCamera,
39523
39457
  videoConstraints,
39524
- detail,
39525
39458
  videoRef,
39526
39459
  streamRef,
39527
39460
  onTapToFocus,
39528
39461
  title,
39529
- documentType = "id"
39462
+ subtitle
39530
39463
  }) {
39531
- const [focusing, setFocusing] = useState(false);
39532
- const [focusIndicator, setFocusIndicator] = useState(false);
39533
39464
  useEffect(() => {
39534
39465
  if (activateCamera && videoRef.current) {
39535
39466
  navigator.mediaDevices.getUserMedia({
39536
- video: {
39537
- ...videoConstraints || {
39538
- facingMode: "environment"
39539
- },
39540
- advanced: [{
39541
- focusMode: "continuous"
39542
- }, {
39543
- exposureMode: "continuous"
39544
- }, {
39545
- whiteBalanceMode: "continuous"
39546
- }]
39467
+ video: videoConstraints || {
39468
+ facingMode: "environment"
39547
39469
  },
39548
39470
  audio: false
39549
39471
  }).then((stream) => {
@@ -39563,20 +39485,6 @@ function UploadDocument2({
39563
39485
  }
39564
39486
  };
39565
39487
  }, [activateCamera, videoConstraints]);
39566
- const handleTapToFocus = async (e2) => {
39567
- setFocusing(true);
39568
- setFocusIndicator(true);
39569
- const rect = e2.currentTarget.getBoundingClientRect();
39570
- (e2.clientX - rect.left) / rect.width;
39571
- (e2.clientY - rect.top) / rect.height;
39572
- await onTapToFocus();
39573
- setTimeout(() => {
39574
- setFocusing(false);
39575
- setTimeout(() => {
39576
- setFocusIndicator(false);
39577
- }, 500);
39578
- }, 1e3);
39579
- };
39580
39488
  return /* @__PURE__ */ jsx$1("div", {
39581
39489
  className: "drag-zone",
39582
39490
  children: /* @__PURE__ */ jsx$1(Box$1, {
@@ -39591,11 +39499,8 @@ function UploadDocument2({
39591
39499
  display: "flex",
39592
39500
  justifyContent: "center",
39593
39501
  alignItems: "center",
39594
- children: activateCamera ? /* @__PURE__ */ jsxs(Box$1, {
39595
- position: "relative",
39596
- width: "100%",
39597
- height: "100%",
39598
- children: [/* @__PURE__ */ jsx$1("video", {
39502
+ children: activateCamera ? /* @__PURE__ */ jsx$1(Box$1, {
39503
+ children: /* @__PURE__ */ jsx$1("video", {
39599
39504
  ref: videoRef,
39600
39505
  style: {
39601
39506
  width: "100%",
@@ -39607,71 +39512,14 @@ function UploadDocument2({
39607
39512
  transform: "translate(-50%, -50%)",
39608
39513
  borderRadius: "5px"
39609
39514
  },
39610
- onClick: handleTapToFocus,
39515
+ onClick: onTapToFocus,
39611
39516
  playsInline: true,
39612
39517
  muted: true,
39613
39518
  autoPlay: true
39614
- }), /* @__PURE__ */ jsx$1(DocumentGuide, {
39615
- documentType
39616
- }), focusIndicator && /* @__PURE__ */ jsx$1(Box$1, {
39617
- sx: {
39618
- position: "absolute",
39619
- top: "50%",
39620
- left: "50%",
39621
- transform: "translate(-50%, -50%)",
39622
- width: "80px",
39623
- height: "80px",
39624
- border: "2px solid white",
39625
- borderRadius: "50%",
39626
- display: "flex",
39627
- justifyContent: "center",
39628
- alignItems: "center",
39629
- zIndex: 10,
39630
- animation: focusing ? "pulse 1s" : "none",
39631
- "@keyframes pulse": {
39632
- "0%": {
39633
- transform: "translate(-50%, -50%) scale(1)",
39634
- opacity: 1
39635
- },
39636
- "50%": {
39637
- transform: "translate(-50%, -50%) scale(1.2)",
39638
- opacity: 0.7
39639
- },
39640
- "100%": {
39641
- transform: "translate(-50%, -50%) scale(1)",
39642
- opacity: 1
39643
- }
39644
- }
39645
- },
39646
- children: focusing && /* @__PURE__ */ jsx$1(CircularProgress$1, {
39647
- size: 40,
39648
- color: "primary"
39649
- })
39650
- }), /* @__PURE__ */ jsx$1(Box$1, {
39651
- sx: {
39652
- position: "absolute",
39653
- bottom: "10px",
39654
- left: "50%",
39655
- transform: "translateX(-50%)",
39656
- backgroundColor: "rgba(0, 0, 0, 0.6)",
39657
- color: "white",
39658
- padding: "8px 16px",
39659
- borderRadius: "20px",
39660
- fontSize: "14px",
39661
- zIndex: 10
39662
- },
39663
- children: "Toca la pantalla para enfocar en el documento"
39664
- })]
39665
- }) : /* @__PURE__ */ jsxs(Box$1, {
39666
- children: [/* @__PURE__ */ jsx$1(CloudUploadIcon, {}), /* @__PURE__ */ jsx$1(Typography$1, {
39667
- variant: "h6",
39668
- className: "title",
39669
- mt: 2,
39670
- children: title
39671
- }), /* @__PURE__ */ jsx$1(Typography$1, {
39672
- variant: "body2",
39673
- children: detail
39674
- })]
39519
+ })
39520
+ }) : /* @__PURE__ */ jsx$1(InstructionsComponent, {
39521
+ title,
39522
+ subtitle
39675
39523
  })
39676
39524
  })
39677
39525
  })
@@ -39683,65 +39531,28 @@ function UploadByGallery({
39683
39531
  side,
39684
39532
  title,
39685
39533
  subtitle,
39686
- startUpload,
39687
- onClickToContinue
39534
+ startUpload
39688
39535
  }) {
39689
39536
  const handleClick = () => {
39690
39537
  var _a;
39691
39538
  (_a = fileInputRef.current) == null ? void 0 : _a.click();
39692
39539
  };
39693
- return /* @__PURE__ */ jsx$1(Box$1, {
39694
- className: "upload-by-gallery-container",
39695
- children: !startUpload ? /* @__PURE__ */ jsxs(Box$1, {
39696
- children: [/* @__PURE__ */ jsx$1(Typography$1, {
39697
- variant: "h6",
39698
- className: "title",
39699
- mt: 2,
39700
- children: title
39701
- }), /* @__PURE__ */ jsx$1(Typography$1, {
39702
- variant: "body2",
39703
- children: subtitle
39704
- }), /* @__PURE__ */ jsxs(List$1, {
39705
- dense: true,
39706
- children: [/* @__PURE__ */ jsxs(ListItem$1, {
39707
- children: [/* @__PURE__ */ jsx$1(ListItemIcon$1, {
39708
- children: /* @__PURE__ */ jsx$1(LightMode, {})
39709
- }), /* @__PURE__ */ jsx$1(ListItemText$1, {
39710
- primary: "Procura tener buena iluminaci\xF3n"
39711
- })]
39712
- }), /* @__PURE__ */ jsxs(ListItem$1, {
39713
- children: [/* @__PURE__ */ jsx$1(ListItemIcon$1, {
39714
- children: /* @__PURE__ */ jsx$1(SettingsBrightness, {})
39715
- }), /* @__PURE__ */ jsx$1(ListItemText$1, {
39716
- primary: "Evita reflejos en el documento de identidad"
39717
- })]
39718
- }), /* @__PURE__ */ jsxs(ListItem$1, {
39719
- children: [/* @__PURE__ */ jsx$1(ListItemIcon$1, {
39720
- children: /* @__PURE__ */ jsx$1(Spellcheck, {})
39721
- }), /* @__PURE__ */ jsx$1(ListItemText$1, {
39722
- primary: "Procura que el texto en el documento sea legible"
39723
- })]
39724
- })]
39725
- }), /* @__PURE__ */ jsx$1(CustomButton, {
39726
- type: "button",
39727
- onClick: onClickToContinue,
39728
- children: "Continuar"
39729
- })]
39730
- }) : /* @__PURE__ */ jsx$1("div", {
39731
- className: "drag-zone",
39540
+ return /* @__PURE__ */ jsx$1("div", {
39541
+ className: "drag-zone",
39542
+ children: /* @__PURE__ */ jsx$1(Box$1, {
39543
+ className: "drag-and-drop-container",
39732
39544
  children: /* @__PURE__ */ jsx$1(Box$1, {
39733
- className: "drag-and-drop-container",
39734
- children: /* @__PURE__ */ jsxs(Box$1, {
39735
- onClick: () => handleClick(),
39736
- position: "relative",
39737
- zIndex: 1,
39738
- width: "100%",
39739
- height: "100%",
39740
- overflow: "hidden",
39741
- display: "flex",
39742
- justifyContent: "center",
39743
- alignItems: "center",
39744
- padding: 2,
39545
+ onClick: () => handleClick(),
39546
+ position: "relative",
39547
+ zIndex: 1,
39548
+ width: "100%",
39549
+ height: "100%",
39550
+ overflow: "hidden",
39551
+ display: "flex",
39552
+ justifyContent: "center",
39553
+ alignItems: "center",
39554
+ padding: 2,
39555
+ children: startUpload ? /* @__PURE__ */ jsxs(Fragment, {
39745
39556
  children: [/* @__PURE__ */ jsxs("div", {
39746
39557
  style: {
39747
39558
  display: "flex",
@@ -39749,7 +39560,7 @@ function UploadByGallery({
39749
39560
  alignItems: "center",
39750
39561
  justifyContent: "center"
39751
39562
  },
39752
- children: [/* @__PURE__ */ jsx$1(CloudUploadIcon, {}), /* @__PURE__ */ jsxs(Typography$1, {
39563
+ children: [/* @__PURE__ */ jsx$1(CloudUploadIcon, {}), /* @__PURE__ */ jsx$1(Typography$1, {
39753
39564
  variant: "body2",
39754
39565
  style: {
39755
39566
  textAlign: "center",
@@ -39757,9 +39568,7 @@ function UploadByGallery({
39757
39568
  whiteSpace: "none",
39758
39569
  margin: "auto"
39759
39570
  },
39760
- children: [/* @__PURE__ */ jsx$1("strong", {
39761
- children: "Haz clic aqu\xED"
39762
- }), " para subir una foto desde tu dispositivo"]
39571
+ children: "Haz clic aqu\xED para subir una foto desde tu dispositivo"
39763
39572
  })]
39764
39573
  }), /* @__PURE__ */ jsx$1("input", {
39765
39574
  ref: fileInputRef,
@@ -39772,6 +39581,9 @@ function UploadByGallery({
39772
39581
  display: "none"
39773
39582
  }
39774
39583
  })]
39584
+ }) : /* @__PURE__ */ jsx$1(InstructionsComponent, {
39585
+ title,
39586
+ subtitle
39775
39587
  })
39776
39588
  })
39777
39589
  })
@@ -39800,46 +39612,6 @@ const createCanvasFromSource = (source2) => {
39800
39612
  ctx == null ? void 0 : ctx.drawImage(source2, 0, 0, width2, height2);
39801
39613
  return { canvas, ctx };
39802
39614
  };
39803
- const analyzeFocusQuality = async (imageData) => {
39804
- return new Promise((resolve) => {
39805
- if (typeof imageData === "string") {
39806
- const img = new Image();
39807
- img.onload = () => {
39808
- const { canvas, ctx } = createCanvasFromSource(img);
39809
- const result = calculateSharpness(canvas, ctx);
39810
- resolve(result);
39811
- };
39812
- img.src = imageData;
39813
- } else {
39814
- const result = calculateSharpness(imageData, imageData.getContext("2d"));
39815
- resolve(result);
39816
- }
39817
- });
39818
- };
39819
- const calculateSharpness = (canvas, ctx) => {
39820
- if (!ctx) {
39821
- return { isFocused: false, sharpness: 0 };
39822
- }
39823
- const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
39824
- const data2 = imageData.data;
39825
- let sum = 0;
39826
- let sumSquared = 0;
39827
- let count = 0;
39828
- for (let i = 0; i < data2.length; i += 4) {
39829
- const luminance = (data2[i] + data2[i + 1] + data2[i + 2]) / 3;
39830
- sum += luminance;
39831
- sumSquared += luminance * luminance;
39832
- count++;
39833
- }
39834
- const mean = sum / count;
39835
- const variance = sumSquared / count - mean * mean;
39836
- const normalizedVariance = Math.min(variance / 1e3, 1);
39837
- const isFocused = normalizedVariance > 0.3;
39838
- return {
39839
- isFocused,
39840
- sharpness: normalizedVariance
39841
- };
39842
- };
39843
39615
  const isLowEndDevice = () => {
39844
39616
  const cores = navigator.hardwareConcurrency || 2;
39845
39617
  const memory = navigator.deviceMemory || 2;
@@ -39863,7 +39635,6 @@ function CustomTabPanel(props) {
39863
39635
  dualModeRequired,
39864
39636
  status,
39865
39637
  onUploadImage2,
39866
- uploadByGallery,
39867
39638
  ...other
39868
39639
  } = props;
39869
39640
  return /* @__PURE__ */ jsx$1("div", {
@@ -39872,7 +39643,9 @@ function CustomTabPanel(props) {
39872
39643
  id: `simple-tabpanel-${index}`,
39873
39644
  "aria-labelledby": `simple-tab-${index}`,
39874
39645
  ...other,
39646
+ className: "tabpanel",
39875
39647
  children: value === index && /* @__PURE__ */ jsx$1(Box$1, {
39648
+ height: "100%",
39876
39649
  children
39877
39650
  })
39878
39651
  });
@@ -39901,16 +39674,11 @@ function SideDocsSelector({
39901
39674
  status,
39902
39675
  onUploadImage2,
39903
39676
  uploadDocumentByPhone,
39904
- uploadByGallery,
39905
- setUploadDocumentByPhone,
39906
- onSendSubmitDocument,
39907
- documentType = "id"
39677
+ onSendSubmitDocument
39908
39678
  }) {
39909
39679
  const [value, setValue] = React$2.useState(0);
39910
39680
  const [showZoom, setShowZoom] = React$2.useState(false);
39911
- const [countAnalyzedImage, setCountAnalyzedImage] = useState(0);
39912
39681
  const [hideCaptureButton, setHideCaptureButton] = useState(false);
39913
- const [startUpload, setStartUpload] = useState(false);
39914
39682
  const handleChange = (event, newValue) => {
39915
39683
  setValue(newValue);
39916
39684
  };
@@ -39926,6 +39694,17 @@ function SideDocsSelector({
39926
39694
  };
39927
39695
  const videoRef = useRef(null);
39928
39696
  const streamRef = useRef(null);
39697
+ const takeScreenshot = async (side) => {
39698
+ const video = videoRef.current;
39699
+ if (!video)
39700
+ return;
39701
+ const {
39702
+ canvas
39703
+ } = createCanvasFromSource(video);
39704
+ const imageData = canvas.toDataURL("image/jpeg");
39705
+ onUploadImage2(side, imageData);
39706
+ processImage();
39707
+ };
39929
39708
  const handleTapToFocus = async () => {
39930
39709
  var _a, _b;
39931
39710
  if (!streamRef.current)
@@ -39935,12 +39714,12 @@ function SideDocsSelector({
39935
39714
  const settings = (_b = track.getSettings) == null ? void 0 : _b.call(track);
39936
39715
  console.log("focus capabilities:", capabilities);
39937
39716
  console.log("focus settings:", settings);
39938
- if (!capabilities) {
39939
- console.warn("No se puede acceder a las capacidades de la c\xE1mara");
39717
+ if (!capabilities || !capabilities.focusMode) {
39718
+ console.warn("No se puede acceder a las capacidades de enfoque");
39940
39719
  return;
39941
39720
  }
39942
39721
  try {
39943
- if (capabilities.focusMode && capabilities.focusMode.includes("continuous")) {
39722
+ if (capabilities.focusMode.includes("continuous")) {
39944
39723
  await track.applyConstraints({
39945
39724
  frameRate: {
39946
39725
  ideal: 30
@@ -39949,8 +39728,7 @@ function SideDocsSelector({
39949
39728
  focusMode: "continuous"
39950
39729
  }]
39951
39730
  });
39952
- console.log("Enfoque continuo aplicado");
39953
- } else if (capabilities.focusMode && capabilities.focusMode.includes("single-shot")) {
39731
+ } else if (capabilities.focusMode.includes("single-shot")) {
39954
39732
  await track.applyConstraints({
39955
39733
  frameRate: {
39956
39734
  ideal: 30
@@ -39959,97 +39737,45 @@ function SideDocsSelector({
39959
39737
  focusMode: "single-shot"
39960
39738
  }]
39961
39739
  });
39962
- console.log("Enfoque de disparo \xFAnico aplicado");
39963
- } else if (capabilities.focusMode && capabilities.focusMode.includes("manual") && capabilities.focusDistance) {
39964
- const midDistance = (capabilities.focusDistance.min + capabilities.focusDistance.max) / 2;
39740
+ } else if (capabilities.focusMode.includes("manual") && capabilities.focusDistance) {
39965
39741
  await track.applyConstraints({
39966
39742
  frameRate: {
39967
39743
  ideal: 30
39968
39744
  },
39969
39745
  advanced: [{
39970
39746
  focusMode: "manual",
39971
- focusDistance: midDistance
39747
+ focusDistance: capabilities.focusDistance.min
39972
39748
  }]
39973
39749
  });
39974
- console.log("Enfoque manual aplicado a distancia media");
39975
39750
  } else {
39976
39751
  console.warn("No hay modo de enfoque compatible");
39977
39752
  }
39978
- if (capabilities.exposureMode && capabilities.exposureMode.includes("continuous")) {
39979
- await track.applyConstraints({
39980
- advanced: [{
39981
- exposureMode: "continuous"
39982
- }]
39983
- });
39984
- console.log("Exposici\xF3n continua aplicada");
39985
- }
39986
- if (capabilities.whiteBalanceMode && capabilities.whiteBalanceMode.includes("continuous")) {
39987
- await track.applyConstraints({
39988
- advanced: [{
39989
- whiteBalanceMode: "continuous"
39990
- }]
39991
- });
39992
- console.log("Balance de blancos continuo aplicado");
39993
- }
39994
- setTimeout(async () => {
39995
- var _a2;
39996
- const newSettings = (_a2 = track.getSettings) == null ? void 0 : _a2.call(track);
39997
- console.log("Nuevos ajustes despu\xE9s del enfoque:", newSettings);
39998
- }, 1e3);
39999
39753
  } catch (err) {
40000
39754
  console.error("Error al aplicar constraints de enfoque:", err);
40001
39755
  }
40002
39756
  };
40003
- const checkFocusQuality = async (imageData) => {
40004
- return await analyzeFocusQuality(imageData);
40005
- };
40006
- const takeScreenshot = async (side) => {
40007
- const video = videoRef.current;
40008
- if (!video)
40009
- return;
40010
- const {
40011
- canvas
40012
- } = createCanvasFromSource(video);
40013
- const imageData = canvas.toDataURL("image/jpeg");
40014
- const {
40015
- isFocused,
40016
- sharpness
40017
- } = await checkFocusQuality(imageData);
40018
- if (isFocused && sharpness > 0.3) {
40019
- onUploadImage2(side, imageData);
40020
- } else {
40021
- setCountAnalyzedImage((prevState) => {
40022
- return prevState + 1;
40023
- });
40024
- if (countAnalyzedImage >= 1) {
40025
- setUploadDocumentByPhone(true);
40026
- setHideCaptureButton(true);
40027
- setCountAnalyzedImage(0);
40028
- } else {
40029
- alert("La imagen no est\xE1 bien enfocada. Por favor, toca la pantalla para enfocar en el documento y vuelve a intentarlo.");
40030
- }
40031
- }
40032
- };
40033
39757
  const fileInputRef = useRef(null);
40034
39758
  const handleFileChange = async (e2) => {
40035
39759
  const imageData = e2.target.files[0];
40036
39760
  const image = await fileToBase64(imageData);
40037
39761
  const side = e2.target.name;
40038
39762
  onUploadImage2(side, image);
40039
- if (side === "firstImage") {
40040
- handleChange((e22) => e22, 1);
40041
- } else {
39763
+ processImage();
39764
+ };
39765
+ const processImage = () => {
39766
+ if (base64.firstImage && dualModeRequired)
39767
+ handleChange((e2) => e2, 1);
39768
+ if (base64.firstImage && base64.secondImage)
40042
39769
  onSendSubmitDocument();
40043
- }
40044
39770
  };
40045
39771
  const onClickToContinue = () => {
40046
39772
  setHideCaptureButton(false);
40047
- setStartUpload(true);
39773
+ setActivateCamera(true);
40048
39774
  };
40049
- console.log(activateCamera);
40050
39775
  return /* @__PURE__ */ jsxs(Box$1, {
40051
39776
  sx: {
40052
- width: "100%"
39777
+ width: "100%",
39778
+ height: "100%"
40053
39779
  },
40054
39780
  children: [/* @__PURE__ */ jsx$1(Box$1, {
40055
39781
  sx: {
@@ -40081,7 +39807,7 @@ function SideDocsSelector({
40081
39807
  justifyContent: "flex-start",
40082
39808
  alignItems: "flex-start",
40083
39809
  width: "100%",
40084
- children: [base64.firstImage ? /* @__PURE__ */ jsxs("div", {
39810
+ children: [base64.firstImage ? /* @__PURE__ */ jsx$1("div", {
40085
39811
  className: "img-container",
40086
39812
  style: {
40087
39813
  transition: "transform 0.3s ease-in-out, width 0.3s ease-in-out",
@@ -40089,7 +39815,7 @@ function SideDocsSelector({
40089
39815
  position: "relative",
40090
39816
  zIndex: 1
40091
39817
  },
40092
- children: [/* @__PURE__ */ jsx$1("img", {
39818
+ children: /* @__PURE__ */ jsx$1("img", {
40093
39819
  src: base64.firstImage,
40094
39820
  onClick: toggleZoom,
40095
39821
  alt: "thumbnail",
@@ -40098,27 +39824,30 @@ function SideDocsSelector({
40098
39824
  height: "100%",
40099
39825
  objectFit: "cover"
40100
39826
  }
40101
- }), /* @__PURE__ */ jsxs(Box$1, {
40102
- style: {
40103
- position: "absolute",
40104
- top: 0,
40105
- right: 0,
40106
- display: "flex",
40107
- gap: "8px",
40108
- zIndex: 20
40109
- },
39827
+ })
39828
+ }) : uploadDocumentByPhone || isLowEndDevice() ? /* @__PURE__ */ jsx$1(UploadByGallery, {
39829
+ handleFileChange,
39830
+ side: "firstImage",
39831
+ fileInputRef,
39832
+ title: "Cargar documeto",
39833
+ subtitle: "Vamos a cargar el documento desde tu dispositivo. \xA1Ten en cuenta lo siguiente!",
39834
+ startUpload: activateCamera
39835
+ }) : /* @__PURE__ */ jsx$1(UploadDocument2, {
39836
+ videoRef,
39837
+ streamRef,
39838
+ setActivateCamera,
39839
+ activateCamera,
39840
+ videoConstraints,
39841
+ onTapToFocus: handleTapToFocus,
39842
+ title: "Cargar documento",
39843
+ subtitle: "Subir frontal del documento"
39844
+ }), /* @__PURE__ */ jsxs(Box$1, {
39845
+ width: "100%",
39846
+ children: [base64.firstImage && /* @__PURE__ */ jsxs(Box$1, {
39847
+ className: "toolbox-container",
40110
39848
  children: [/* @__PURE__ */ jsx$1(Box$1, {
40111
39849
  className: "zoom-button",
40112
39850
  onClick: toggleZoom,
40113
- sx: {
40114
- backgroundColor: "rgba(255, 255, 255, 0.7)",
40115
- borderRadius: "50%",
40116
- padding: "4px",
40117
- cursor: "pointer",
40118
- display: "flex",
40119
- alignItems: "center",
40120
- justifyContent: "center"
40121
- },
40122
39851
  children: /* @__PURE__ */ jsx$1(MUITooltip, {
40123
39852
  title: "Ampliar",
40124
39853
  placement: "right",
@@ -40132,15 +39861,6 @@ function SideDocsSelector({
40132
39861
  }), /* @__PURE__ */ jsx$1(Box$1, {
40133
39862
  className: "delete-button",
40134
39863
  onClick: () => deleteImage("firstImage"),
40135
- sx: {
40136
- backgroundColor: "rgba(255, 255, 255, 0.7)",
40137
- borderRadius: "50%",
40138
- padding: "4px",
40139
- cursor: "pointer",
40140
- display: "flex",
40141
- alignItems: "center",
40142
- justifyContent: "center"
40143
- },
40144
39864
  children: /* @__PURE__ */ jsx$1(MUITooltip, {
40145
39865
  title: "Vaciar",
40146
39866
  placement: "right",
@@ -40151,34 +39871,25 @@ function SideDocsSelector({
40151
39871
  })
40152
39872
  })
40153
39873
  })]
40154
- })]
40155
- }) : uploadDocumentByPhone || uploadByGallery || isLowEndDevice() ? /* @__PURE__ */ jsx$1(UploadByGallery, {
40156
- handleFileChange,
40157
- side: "firstImage",
40158
- fileInputRef,
40159
- title: "Cargar documeto",
40160
- subtitle: "Vamos a cargar el documento desde tu dispositivo. \xA1Ten en cuenta lo siguiente!",
40161
- onClickToContinue,
40162
- startUpload
40163
- }) : /* @__PURE__ */ jsx$1(UploadDocument2, {
40164
- videoRef,
40165
- streamRef,
40166
- setActivateCamera,
40167
- activateCamera,
40168
- videoConstraints,
40169
- detail: "Subir frontal del documento",
40170
- onTapToFocus: handleTapToFocus,
40171
- title: "Cargar documento",
40172
- documentType
40173
- }), /* @__PURE__ */ jsxs(Box$1, {
40174
- width: "100%",
40175
- children: [activateCamera && !hideCaptureButton && /* @__PURE__ */ jsx$1(CustomButton, {
39874
+ }), !activateCamera && !base64.firstImage && /* @__PURE__ */ jsx$1(CustomButton, {
39875
+ type: "button",
39876
+ onClick: onClickToContinue,
39877
+ children: "Continuar"
39878
+ }), !activateCamera && base64.firstImage && /* @__PURE__ */ jsx$1(CustomButton, {
39879
+ type: "button",
39880
+ onClick: (e2) => handleChange(e2, 1),
39881
+ children: "Cargar reverso del documento"
39882
+ }), activateCamera && !hideCaptureButton && !uploadDocumentByPhone && /* @__PURE__ */ jsx$1(CustomButton, {
40176
39883
  type: "button",
40177
39884
  onClick: () => takeScreenshot("firstImage"),
40178
39885
  children: "Capturar"
40179
- }), !status && Object.keys(base64).length > 0 && !activateCamera && lib$1(status) && (!dualModeRequired && base64.firstImage || dualModeRequired && base64.firstImage && base64.secondImage) && /* @__PURE__ */ jsx$1(CustomButton, {
40180
- type: "submit",
40181
- children: "Procesar"
39886
+ }), !status && Object.keys(base64).length > 0 && !activateCamera && lib$1(status) && (!dualModeRequired && base64.firstImage || dualModeRequired && base64.firstImage && base64.secondImage) && /* @__PURE__ */ jsxs(Box$1, {
39887
+ children: [/* @__PURE__ */ jsx$1(Divider$1, {
39888
+ children: "O"
39889
+ }), /* @__PURE__ */ jsx$1(CustomButton, {
39890
+ type: "submit",
39891
+ children: "Procesar"
39892
+ })]
40182
39893
  })]
40183
39894
  })]
40184
39895
  })
@@ -40197,7 +39908,7 @@ function SideDocsSelector({
40197
39908
  justifyContent: "flex-start",
40198
39909
  alignItems: "flex-start",
40199
39910
  width: "100%",
40200
- children: [base64.secondImage ? /* @__PURE__ */ jsxs("div", {
39911
+ children: [base64.secondImage ? /* @__PURE__ */ jsx$1("div", {
40201
39912
  className: "img-container",
40202
39913
  style: {
40203
39914
  transition: "transform 0.3s ease-in-out, width 0.3s ease-in-out",
@@ -40205,7 +39916,7 @@ function SideDocsSelector({
40205
39916
  position: "relative",
40206
39917
  zIndex: 1
40207
39918
  },
40208
- children: [/* @__PURE__ */ jsx$1("img", {
39919
+ children: /* @__PURE__ */ jsx$1("img", {
40209
39920
  src: base64.secondImage,
40210
39921
  onClick: toggleZoom,
40211
39922
  alt: "thumbnail",
@@ -40214,29 +39925,32 @@ function SideDocsSelector({
40214
39925
  height: "100%",
40215
39926
  objectFit: "cover"
40216
39927
  }
40217
- }), /* @__PURE__ */ jsxs(Box$1, {
40218
- style: {
40219
- position: "absolute",
40220
- top: 0,
40221
- right: 0,
40222
- display: "flex",
40223
- gap: "8px",
40224
- zIndex: 20
40225
- },
39928
+ })
39929
+ }) : uploadDocumentByPhone || isLowEndDevice() ? /* @__PURE__ */ jsx$1(UploadByGallery, {
39930
+ handleFileChange,
39931
+ side: "secondImage",
39932
+ fileInputRef,
39933
+ title: "Bien ahora vamos por el reverso",
39934
+ subtitle: "\xA1Recuerda tener en cuenta lo siguiente!",
39935
+ startUpload: activateCamera
39936
+ }) : /* @__PURE__ */ jsx$1(UploadDocument2, {
39937
+ videoRef,
39938
+ streamRef,
39939
+ setActivateCamera,
39940
+ activateCamera,
39941
+ videoConstraints,
39942
+ title: "Bien ahora carguemos el reverso",
39943
+ subtitle: "Asegurate de que sea legible",
39944
+ onTapToFocus: handleTapToFocus
39945
+ }), /* @__PURE__ */ jsxs(Box$1, {
39946
+ width: "100%",
39947
+ children: [base64.secondImage && /* @__PURE__ */ jsxs(Box$1, {
39948
+ className: "toolbox-container",
40226
39949
  children: [/* @__PURE__ */ jsx$1(Box$1, {
40227
39950
  className: "zoom-button",
40228
39951
  onClick: toggleZoom,
40229
- sx: {
40230
- backgroundColor: "rgba(255, 255, 255, 0.7)",
40231
- borderRadius: "50%",
40232
- padding: "4px",
40233
- cursor: "pointer",
40234
- display: "flex",
40235
- alignItems: "center",
40236
- justifyContent: "center"
40237
- },
40238
39952
  children: /* @__PURE__ */ jsx$1(MUITooltip, {
40239
- title: "Girar",
39953
+ title: "Ampliar",
40240
39954
  placement: "right",
40241
39955
  arrow: true,
40242
39956
  children: /* @__PURE__ */ jsx$1(ZoomInTwoTone, {
@@ -40248,15 +39962,6 @@ function SideDocsSelector({
40248
39962
  }), /* @__PURE__ */ jsx$1(Box$1, {
40249
39963
  className: "delete-button",
40250
39964
  onClick: () => deleteImage("secondImage"),
40251
- sx: {
40252
- backgroundColor: "rgba(255, 255, 255, 0.7)",
40253
- borderRadius: "50%",
40254
- padding: "4px",
40255
- cursor: "pointer",
40256
- display: "flex",
40257
- alignItems: "center",
40258
- justifyContent: "center"
40259
- },
40260
39965
  children: /* @__PURE__ */ jsx$1(MUITooltip, {
40261
39966
  title: "Vaciar",
40262
39967
  placement: "right",
@@ -40267,28 +39972,11 @@ function SideDocsSelector({
40267
39972
  })
40268
39973
  })
40269
39974
  })]
40270
- })]
40271
- }) : uploadDocumentByPhone || uploadByGallery || isLowEndDevice() ? /* @__PURE__ */ jsx$1(UploadByGallery, {
40272
- handleFileChange,
40273
- side: "secondImage",
40274
- fileInputRef,
40275
- title: "Bien ahora vamos por el reverso",
40276
- subtitle: "\xA1Recuerda tener en cuenta lo siguiente!",
40277
- onClickToContinue,
40278
- startUpload
40279
- }) : /* @__PURE__ */ jsx$1(UploadDocument2, {
40280
- videoRef,
40281
- streamRef,
40282
- setActivateCamera,
40283
- activateCamera,
40284
- videoConstraints,
40285
- title: "Bien ahora carguemos el reverso",
40286
- detail: "Asegurate de que sea legible",
40287
- onTapToFocus: handleTapToFocus,
40288
- documentType
40289
- }), /* @__PURE__ */ jsxs(Box$1, {
40290
- width: "100%",
40291
- children: [activateCamera && !hideCaptureButton && /* @__PURE__ */ jsx$1(CustomButton, {
39975
+ }), !activateCamera && !base64.secondImage && /* @__PURE__ */ jsx$1(CustomButton, {
39976
+ type: "button",
39977
+ onClick: onClickToContinue,
39978
+ children: "Continuar"
39979
+ }), activateCamera && !hideCaptureButton && !uploadDocumentByPhone && /* @__PURE__ */ jsx$1(CustomButton, {
40292
39980
  type: "button",
40293
39981
  onClick: () => takeScreenshot("secondImage"),
40294
39982
  children: "Capturar"
@@ -40741,8 +40429,7 @@ function DocumentReader({
40741
40429
  countryCodeAllowed = null,
40742
40430
  validateVpn = false,
40743
40431
  successMessage,
40744
- dualModeRequired = false,
40745
- uploadByGallery = false
40432
+ dualModeRequired = false
40746
40433
  }) {
40747
40434
  const {
40748
40435
  onSendSubmitDocument,
@@ -40764,7 +40451,7 @@ function DocumentReader({
40764
40451
  setUploadDocumentByPhone
40765
40452
  } = DocumentReaderController(dataDocument, clientId, authorize, eventId, source2, inProduction, countryCodeAllowed, validateVpn, successMessage, dualModeRequired);
40766
40453
  return /* @__PURE__ */ jsxs("div", {
40767
- className: `kit-gbc ${mode} without-shadow`,
40454
+ className: `kit-gbc ${mode} without-shadow ocr`,
40768
40455
  children: [/* @__PURE__ */ jsx$1(k$2, {
40769
40456
  position: "top-center",
40770
40457
  autoClose: 5e3,
@@ -40805,7 +40492,6 @@ function DocumentReader({
40805
40492
  status,
40806
40493
  onUploadImage2,
40807
40494
  uploadDocumentByPhone,
40808
- uploadByGallery,
40809
40495
  setUploadDocumentByPhone,
40810
40496
  onSendSubmitDocument
40811
40497
  })]
@@ -40824,8 +40510,7 @@ DocumentReader.propTypes = {
40824
40510
  eventId: propTypes.exports.PropTypes.string,
40825
40511
  validateVpn: propTypes.exports.PropTypes.bool,
40826
40512
  dualModeRequired: propTypes.exports.PropTypes.bool,
40827
- successMessage: propTypes.exports.PropTypes.string,
40828
- uploadByGallery: propTypes.exports.PropTypes.bool
40513
+ successMessage: propTypes.exports.PropTypes.string
40829
40514
  };
40830
40515
  const fetchFaceMatch = async (faceMatch, selfie, inProduction, customHeaders) => {
40831
40516
  const parseReq = {