vesant-sdk 1.7.0-dev.e0ee6d5 → 1.7.0-next.a744d2e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/react.mjs CHANGED
@@ -882,7 +882,6 @@ function useCustomerProfile(client, customerId, options = {}) {
882
882
  var Camera = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCg0KPCFET0NUWVBFIHN2ZyBQVUJMSUMgIi0vL1czQy8vRFREIFNWRyAxLjAvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvVFIvMjAwMS9SRUMtU1ZHLTIwMDEwOTA0L0RURC9zdmcxMC5kdGQiPg0KPCEtLSBVcGxvYWRlZCB0bzogU1ZHIFJlcG8sIHd3dy5zdmdyZXBvLmNvbSwgR2VuZXJhdG9yOiBTVkcgUmVwbyBNaXhlciBUb29scyAtLT4NCjxzdmcgdmVyc2lvbj0iMS4wIiBpZD0iTGF5ZXJfMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgDQoJIHdpZHRoPSI4MDBweCIgaGVpZ2h0PSI4MDBweCIgdmlld0JveD0iMCAwIDY0IDY0IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCA2NCA2NCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8Zz4NCgk8cGF0aCBmaWxsPSIjMjMxRjIwIiBkPSJNNjAsMTBINDkuNjU2bC02LjgyOC02LjgyOEM0Mi4wNzgsMi40MjIsNDEuMDYyLDIsNDAsMkgyNGMtMS4wNjIsMC0yLjA3OCwwLjQyMi0yLjgyOCwxLjE3MkwxNC4zNDQsMTBINA0KCQljLTIuMjExLDAtNCwxLjc4OS00LDR2NDRjMCwyLjIxMSwxLjc4OSw0LDQsNGg1NmMyLjIxMSwwLDQtMS43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yNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4NCjxwYXRoIGQ9Ik0xNyAxN0gxNy4wMU0xNS42IDE0SDE4QzE4LjkzMTkgMTQgMTkuMzk3OCAxNCAxOS43NjU0IDE0LjE1MjJDMjAuMjU1NCAxNC4zNTUyIDIwLjY0NDggMTQuNzQ0NiAyMC44NDc4IDE1LjIzNDZDMjEgMTUuNjAyMiAyMSAxNi4wNjgxIDIxIDE3QzIxIDE3LjkzMTkgMjEgMTguMzk3OCAyMC44NDc4IDE4Ljc2NTRDMjAuNjQ0OCAxOS4yNTU0IDIwLjI1NTQgMTkuNjQ0OCAxOS43NjU0IDE5Ljg0NzhDMTkuMzk3OCAyMCAxOC45MzE5IDIwIDE4IDIwSDZDNS4wNjgxMiAyMCA0LjYwMjE4IDIwIDQuMjM0NjMgMTkuODQ3OEMzLjc0NDU4IDE5LjY0NDggMy4zNTUyMyAxOS4yNTU0IDMuMTUyMjQgMTguNzY1NEMzIDE4LjM5NzggMyAxNy45MzE5IDMgMTdDMyAxNi4wNjgxIDMgMTUuNjAyMiAzLjE1MjI0IDE1LjIzNDZDMy4zNTUyMyAxNC43NDQ2IDMuNzQ0NTggMTQuMzU1MiA0LjIzNDYzIDE0LjE1MjJDNC42MDIxOCAxNCA1LjA2ODEyIDE0IDYgMTRIOC40TTEyIDE1VjRNMTIgNEwxNSA3TTEyIDRMOSA3IiBzdHJva2U9IiMwMDAwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIi8+DQo8L3N2Zz4=";
886
885
 
887
886
  // src/kyc/FaceCaptureModal.tsx
888
887
  var MOBILE_UA = /Mobi|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i;
@@ -899,9 +898,9 @@ function headerSubtitle(stageKind) {
899
898
  case "accepted":
900
899
  return "All set";
901
900
  case "declined":
902
- return "Verification didn't match, try once more";
901
+ return "Verification Declined";
903
902
  case "max_attempts":
904
- return "We couldn't verify you";
903
+ return "We couldn't verify your identity";
905
904
  default:
906
905
  return "Please capture a clear photo of your face";
907
906
  }
@@ -914,16 +913,18 @@ function FaceCaptureModal({
914
913
  client,
915
914
  session,
916
915
  onComplete,
916
+ onCancel,
917
917
  defaultDevice,
918
918
  renderQR
919
919
  }) {
920
920
  const isMobile = typeof navigator !== "undefined" && MOBILE_UA.test(navigator.userAgent);
921
+ const initialChoice = defaultDevice ?? (isMobile ? "this" : "ask");
921
922
  const initialStage = (() => {
922
- const choice = defaultDevice ?? (isMobile ? "this" : "ask");
923
- if (choice === "this") return { kind: "capture" };
924
- if (choice === "mobile") return { kind: "qr", mobileConnected: false };
923
+ if (initialChoice === "this") return { kind: "capture" };
924
+ if (initialChoice === "mobile") return { kind: "qr", mobileConnected: false };
925
925
  return { kind: "choose" };
926
926
  })();
927
+ const hasMethodChoice = initialChoice === "ask";
927
928
  const [stage, setStage] = useState(initialStage);
928
929
  const [attempts, setAttempts] = useState(session.attempts);
929
930
  const maxAttempts = session.max_attempts || 1;
@@ -1104,6 +1105,9 @@ function FaceCaptureModal({
1104
1105
  }, [captureMode]);
1105
1106
  const close = (result) => {
1106
1107
  cancelledRef.current = true;
1108
+ if (result === null && onCancel) {
1109
+ onCancel();
1110
+ }
1107
1111
  onComplete(result);
1108
1112
  };
1109
1113
  const renderChoose = () => /* @__PURE__ */ React.createElement("div", { style: contentStyle }, /* @__PURE__ */ React.createElement("div", { style: visualGuideContainerStyle }, /* @__PURE__ */ React.createElement("div", { style: visualGuideStyle }, /* @__PURE__ */ React.createElement("div", { style: circleStyle }, /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 48, height: 48 })))), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, "How would you like to verify?"), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement(
@@ -1112,7 +1116,7 @@ function FaceCaptureModal({
1112
1116
  style: primaryButtonStyle,
1113
1117
  onClick: () => setStage({ kind: "capture" })
1114
1118
  },
1115
- /* @__PURE__ */ React.createElement("img", { src: isMobile ? Camera : Upload, alt: "", width: 20, height: 20 }),
1119
+ /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 20, height: 20 }),
1116
1120
  /* @__PURE__ */ React.createElement("span", null, "Continue on this device")
1117
1121
  ), /* @__PURE__ */ React.createElement(
1118
1122
  "button",
@@ -1129,6 +1133,13 @@ function FaceCaptureModal({
1129
1133
  onClick: () => setStage({ kind: "capture" })
1130
1134
  },
1131
1135
  "Use this device instead"
1136
+ ), hasMethodChoice && /* @__PURE__ */ React.createElement(
1137
+ "button",
1138
+ {
1139
+ style: secondaryButtonStyle,
1140
+ onClick: () => setStage({ kind: "choose" })
1141
+ },
1142
+ "Change verification method"
1132
1143
  ), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(null) }, "Cancel")));
1133
1144
  const renderCapture = (declinedReason) => {
1134
1145
  if (captureMode === "live") {
@@ -1144,13 +1155,23 @@ function FaceCaptureModal({
1144
1155
  if (captureMode === "preview" && capturedPreview) {
1145
1156
  return /* @__PURE__ */ React.createElement("div", { style: contentStyle }, declinedReason && /* @__PURE__ */ React.createElement("div", { style: alertBoxStyle }, /* @__PURE__ */ React.createElement("strong", null, "Verification declined."), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, declinedReason)), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, "Looks good? Submit this selfie or retake it."), /* @__PURE__ */ React.createElement("div", { style: previewBoxStyle }, /* @__PURE__ */ React.createElement("img", { src: capturedPreview, alt: "Captured selfie preview", style: previewImgStyle })), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: handleConfirmSubmit }, /* @__PURE__ */ React.createElement("img", { src: Done, alt: "", width: 20, height: 20 }), /* @__PURE__ */ React.createElement("span", null, "Submit")), /* @__PURE__ */ React.createElement("button", { style: secondaryButtonStyle, onClick: handleRetake }, "Retake"), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(null) }, "Cancel")), /* @__PURE__ */ React.createElement("p", { style: attemptsTextStyle }, "Attempt ", attempts + 1, " of ", maxAttempts));
1146
1157
  }
1147
- return /* @__PURE__ */ React.createElement("div", { style: contentStyle }, /* @__PURE__ */ React.createElement("div", { style: visualGuideContainerStyle }, /* @__PURE__ */ React.createElement("div", { style: visualGuideStyle }, /* @__PURE__ */ React.createElement("div", { style: circleStyle }, /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 48, height: 48 })), /* @__PURE__ */ React.createElement("div", { style: badgeStyle }, /* @__PURE__ */ React.createElement("img", { src: Done, alt: "", width: 16, height: 16 })))), declinedReason && /* @__PURE__ */ React.createElement("div", { style: alertBoxStyle }, /* @__PURE__ */ React.createElement("strong", null, "Verification declined."), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, declinedReason)), /* @__PURE__ */ React.createElement("div", { style: instructionsBoxStyle }, /* @__PURE__ */ React.createElement("h3", { style: instructionsTitleStyle }, "Tips for best results:"), /* @__PURE__ */ React.createElement("ul", { style: instructionsListStyle }, /* @__PURE__ */ React.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React.createElement("span", null, "Ensure good lighting on your face")), /* @__PURE__ */ React.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React.createElement("span", null, "Remove glasses or accessories if possible")), /* @__PURE__ */ React.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React.createElement("span", null, "Look directly at the camera")))), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: handleOpenCamera }, /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 20, height: 20 }), /* @__PURE__ */ React.createElement("span", null, declinedReason ? "Try again" : "Open Camera")), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(null) }, "Cancel")), /* @__PURE__ */ React.createElement("p", { style: attemptsTextStyle }, "Attempt ", attempts + 1, " of ", maxAttempts));
1158
+ return /* @__PURE__ */ React.createElement("div", { style: contentStyle }, /* @__PURE__ */ React.createElement("div", { style: visualGuideContainerStyle }, /* @__PURE__ */ React.createElement("div", { style: visualGuideStyle }, /* @__PURE__ */ React.createElement("div", { style: circleStyle }, /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 48, height: 48 })), /* @__PURE__ */ React.createElement("div", { style: badgeStyle }, /* @__PURE__ */ React.createElement("img", { src: Done, alt: "", width: 16, height: 16 })))), declinedReason && /* @__PURE__ */ React.createElement("div", { style: alertBoxStyle }, /* @__PURE__ */ React.createElement("strong", null, "Verification declined."), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, declinedReason)), /* @__PURE__ */ React.createElement("div", { style: instructionsBoxStyle }, /* @__PURE__ */ React.createElement("h3", { style: instructionsTitleStyle }, "Tips for best results:"), /* @__PURE__ */ React.createElement("ul", { style: instructionsListStyle }, /* @__PURE__ */ React.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React.createElement("span", null, "Ensure good lighting on your face")), /* @__PURE__ */ React.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React.createElement("span", null, "Remove glasses or accessories if possible")), /* @__PURE__ */ React.createElement("li", { style: instructionItemStyle }, /* @__PURE__ */ React.createElement("span", { style: bulletStyle }, "\u2022"), /* @__PURE__ */ React.createElement("span", null, "Look directly at the camera")))), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: handleOpenCamera }, /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 20, height: 20 }), /* @__PURE__ */ React.createElement("span", null, declinedReason ? "Try again" : "Open Camera")), hasMethodChoice && /* @__PURE__ */ React.createElement(
1159
+ "button",
1160
+ {
1161
+ style: secondaryButtonStyle,
1162
+ onClick: () => setStage({ kind: "choose" })
1163
+ },
1164
+ "Change verification method"
1165
+ ), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(null) }, "Cancel")), /* @__PURE__ */ React.createElement("p", { style: attemptsTextStyle }, "Attempt ", attempts + 1, " of ", maxAttempts));
1148
1166
  };
1149
1167
  const renderSubmitting = () => /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: { ...spinnerStyle, margin: "24px auto", width: 32, height: 32 } }), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, "Verifying your photo\u2026"), /* @__PURE__ */ React.createElement("p", { style: { ...attemptsTextStyle, marginTop: 8 } }, "This usually takes a few seconds."));
1150
1168
  const renderAccepted = (result) => /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: successCircleStyle }, /* @__PURE__ */ React.createElement("img", { src: Done, alt: "", width: 48, height: 48 })), /* @__PURE__ */ React.createElement("h3", { style: titleStyle }, "Verified"), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, "Your identity has been confirmed. You can continue."), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: () => close(result) }, "Continue")));
1151
- const renderDeclined = (result) => /* @__PURE__ */ React.createElement("div", { style: contentStyle }, /* @__PURE__ */ React.createElement("div", { style: alertBoxStyle }, /* @__PURE__ */ React.createElement("strong", null, "Verification declined."), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, result.declined_reason ?? "We couldn't match your selfie. Please take a new one.")), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: handleRetakeAfterDecline }, /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 20, height: 20 }), /* @__PURE__ */ React.createElement("span", null, "Retake")), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(result) }, "Cancel")), /* @__PURE__ */ React.createElement("p", { style: attemptsTextStyle }, "Attempt ", Math.min(attempts + 1, maxAttempts), " of ", maxAttempts));
1152
- const renderMaxAttempts = (result) => /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: errorCircleStyle }, "!"), /* @__PURE__ */ React.createElement("h3", { style: titleStyle }, "Maximum attempts reached"), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, result.declined_reason ?? "We couldn't verify your identity after several attempts."), result.data?.freeze_account && /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, "For your security, your account has been temporarily restricted", result.data.freeze_duration_minutes ? ` for ${result.data.freeze_duration_minutes} minutes` : "", ". Please contact support if you need immediate help."), result.data?.enforce_logout && /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, "You will be signed out of your session."), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: () => close(result) }, "Close")));
1153
- const renderError = (message) => /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: errorCircleStyle }, "!"), /* @__PURE__ */ React.createElement("h3", { style: titleStyle }, "Something went wrong"), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, message), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: () => setStage({ kind: "capture" }) }, "Try again"), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(null) }, "Cancel")));
1169
+ const renderDeclined = (result) => /* @__PURE__ */ React.createElement("div", { style: contentStyle }, /* @__PURE__ */ React.createElement("div", { style: alertBoxStyle }, /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, result.declined_reason ?? "We couldn't match your selfie. Please take a new one.")), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: handleRetakeAfterDecline }, /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 20, height: 20 }), /* @__PURE__ */ React.createElement("span", null, "Retake")), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(result) }, "Cancel")), /* @__PURE__ */ React.createElement("p", { style: attemptsTextStyle }, "Attempt ", Math.min(attempts + 1, maxAttempts), " of ", maxAttempts));
1170
+ const renderMaxAttempts = (result) => /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: errorCircleStyle }, "!"), /* @__PURE__ */ React.createElement("h3", { style: titleStyle }, "Maximum Attempts Reached"), /* @__PURE__ */ React.createElement("p", { style: subtitleStyle }, result.declined_reason ?? "We couldn't verify your identity after several attempts."), result.data?.freeze_account && /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, "For your security, your account has been temporarily restricted", result.data.freeze_duration_minutes ? ` for ${result.data.freeze_duration_minutes} minutes` : "", ". Please contact support if you need immediate help."), result.data?.enforce_logout && /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, "You will be signed out of your session."), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: () => close(result) }, "Close")));
1171
+ const renderError = (message) => {
1172
+ const sessionExpired = /session\s+expired/i.test(message);
1173
+ return /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center" } }, /* @__PURE__ */ React.createElement("div", { style: errorCircleStyle }, "!"), /* @__PURE__ */ React.createElement("h3", { style: titleStyle }, sessionExpired ? "Session expired" : "Something went wrong"), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, sessionExpired ? "Your verification session is no longer valid. Please start a new verification from the beginning." : message), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, !sessionExpired && /* @__PURE__ */ React.createElement("button", { style: primaryButtonStyle, onClick: () => setStage({ kind: "capture" }) }, "Try again"), /* @__PURE__ */ React.createElement("button", { style: cancelButtonStyle, onClick: () => close(null) }, sessionExpired ? "Close" : "Cancel")));
1174
+ };
1154
1175
  const body = (() => {
1155
1176
  switch (stage.kind) {
1156
1177
  case "choose":
@@ -1358,11 +1379,63 @@ var attemptsTextStyle = {
1358
1379
  };
1359
1380
  var footerStyle = { padding: "12px 24px 16px", borderTop: "1px solid #f3f4f6" };
1360
1381
  var footerTextStyle = { margin: 0, fontSize: 12, color: "#9ca3af", textAlign: "center" };
1382
+ var FACE_MESSAGES = {
1383
+ idle: "Initializing camera...",
1384
+ loading: "Loading face detection...",
1385
+ scanning: "Position your face in the circle",
1386
+ too_far: "Face too far. Please move closer to the camera",
1387
+ too_close: "Too close. Please move back a little",
1388
+ off_center: "Center your face in the circle",
1389
+ ok: "Looking great! Tap the button to capture"
1390
+ };
1391
+ var FACE_COLORS = {
1392
+ idle: "#9ca3af",
1393
+ loading: "#3b82f6",
1394
+ scanning: "#3b82f6",
1395
+ too_far: "#ef4444",
1396
+ too_close: "#f59e0b",
1397
+ off_center: "#f59e0b",
1398
+ ok: "#10b981"
1399
+ };
1400
+ var MEDIAPIPE_BASE = "https://cdn.jsdelivr.net/npm/@mediapipe/face_detection";
1401
+ var mediapipeLoaderPromise = null;
1402
+ function loadMediaPipeFaceDetection() {
1403
+ if (typeof window === "undefined" || typeof document === "undefined") {
1404
+ return Promise.reject(new Error("MediaPipe requires a browser environment"));
1405
+ }
1406
+ const w = window;
1407
+ if (w.FaceDetection) {
1408
+ return Promise.resolve(w.FaceDetection);
1409
+ }
1410
+ if (mediapipeLoaderPromise) return mediapipeLoaderPromise;
1411
+ mediapipeLoaderPromise = new Promise((resolve, reject) => {
1412
+ const script = document.createElement("script");
1413
+ script.src = `${MEDIAPIPE_BASE}/face_detection.js`;
1414
+ script.async = true;
1415
+ script.crossOrigin = "anonymous";
1416
+ script.onload = () => {
1417
+ if (w.FaceDetection) {
1418
+ resolve(w.FaceDetection);
1419
+ } else {
1420
+ mediapipeLoaderPromise = null;
1421
+ reject(new Error("MediaPipe loaded but FaceDetection global is missing"));
1422
+ }
1423
+ };
1424
+ script.onerror = () => {
1425
+ mediapipeLoaderPromise = null;
1426
+ reject(new Error("Failed to load MediaPipe face_detection script"));
1427
+ };
1428
+ document.head.appendChild(script);
1429
+ });
1430
+ return mediapipeLoaderPromise;
1431
+ }
1361
1432
  function LiveCamera({ onCapture, onCancel, message }) {
1362
1433
  const videoRef = useRef(null);
1363
1434
  const streamRef = useRef(null);
1364
1435
  const [ready, setReady] = useState(false);
1365
1436
  const [error, setError] = useState(null);
1437
+ const [faceStatus, setFaceStatus] = useState("idle");
1438
+ const [faceDetectionFailed, setFaceDetectionFailed] = useState(false);
1366
1439
  useEffect(() => {
1367
1440
  let cancelled = false;
1368
1441
  async function init() {
@@ -1403,6 +1476,77 @@ function LiveCamera({ onCapture, onCancel, message }) {
1403
1476
  streamRef.current = null;
1404
1477
  };
1405
1478
  }, []);
1479
+ useEffect(() => {
1480
+ if (!ready) {
1481
+ setFaceStatus("idle");
1482
+ return;
1483
+ }
1484
+ let cancelled = false;
1485
+ let rafId = null;
1486
+ let detector = null;
1487
+ setFaceStatus("loading");
1488
+ setFaceDetectionFailed(false);
1489
+ (async () => {
1490
+ try {
1491
+ const FaceDetection = await loadMediaPipeFaceDetection();
1492
+ if (cancelled) return;
1493
+ const d = new FaceDetection({
1494
+ locateFile: (f) => `${MEDIAPIPE_BASE}/${f}`
1495
+ });
1496
+ d.setOptions({ model: "short", minDetectionConfidence: 0.5 });
1497
+ d.onResults((results) => {
1498
+ if (cancelled) return;
1499
+ const detections = results.detections ?? [];
1500
+ let next;
1501
+ if (detections.length === 0) {
1502
+ next = "scanning";
1503
+ } else {
1504
+ const bb = detections[0].boundingBox;
1505
+ if (bb.width < 0.18) next = "too_far";
1506
+ else if (bb.width > 0.72) next = "too_close";
1507
+ else if (bb.xCenter < 0.28 || bb.xCenter > 0.72 || bb.yCenter < 0.28 || bb.yCenter > 0.72) {
1508
+ next = "off_center";
1509
+ } else {
1510
+ next = "ok";
1511
+ }
1512
+ }
1513
+ setFaceStatus(next);
1514
+ });
1515
+ await d.initialize();
1516
+ if (cancelled) return;
1517
+ detector = d;
1518
+ setFaceStatus("scanning");
1519
+ const tick = async () => {
1520
+ if (cancelled) return;
1521
+ const v = videoRef.current;
1522
+ if (v?.readyState === 4 && detector) {
1523
+ try {
1524
+ await detector.send({ image: v });
1525
+ } catch {
1526
+ }
1527
+ }
1528
+ if (!cancelled) {
1529
+ rafId = requestAnimationFrame(tick);
1530
+ }
1531
+ };
1532
+ tick();
1533
+ } catch (err) {
1534
+ console.error("Face detection failed to initialize:", err);
1535
+ if (!cancelled) {
1536
+ setFaceDetectionFailed(true);
1537
+ setFaceStatus("scanning");
1538
+ }
1539
+ }
1540
+ })();
1541
+ return () => {
1542
+ cancelled = true;
1543
+ if (rafId !== null) cancelAnimationFrame(rafId);
1544
+ try {
1545
+ detector?.close?.();
1546
+ } catch {
1547
+ }
1548
+ };
1549
+ }, [ready]);
1406
1550
  const capture = () => {
1407
1551
  const video = videoRef.current;
1408
1552
  if (!video || !video.videoWidth) return;
@@ -1424,7 +1568,17 @@ function LiveCamera({ onCapture, onCancel, message }) {
1424
1568
  if (error) {
1425
1569
  return /* @__PURE__ */ React.createElement("div", { style: { ...contentStyle, alignItems: "center", textAlign: "center", padding: 0 } }, /* @__PURE__ */ React.createElement("div", { style: errorCircleStyle }, "!"), /* @__PURE__ */ React.createElement("h3", { style: titleStyle }, "Camera unavailable"), /* @__PURE__ */ React.createElement("p", { style: alertTextStyle }, error), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement("button", { style: secondaryButtonStyle, onClick: onCancel }, "Back")));
1426
1570
  }
1427
- return /* @__PURE__ */ React.createElement("div", { style: { display: "flex", flexDirection: "column", gap: 12 } }, /* @__PURE__ */ React.createElement("div", { style: videoFrameStyle }, /* @__PURE__ */ React.createElement(
1571
+ const detectionActive = ready && !faceDetectionFailed;
1572
+ const liveMessage = detectionActive ? FACE_MESSAGES[faceStatus] : message;
1573
+ const liveFaceColor = detectionActive ? FACE_COLORS[faceStatus] : void 0;
1574
+ const captureDisabled = !ready || detectionActive && faceStatus !== "ok";
1575
+ const ringPulse = detectionActive && (faceStatus === "too_far" || faceStatus === "too_close") ? "pulse 1.5s ease-in-out infinite" : void 0;
1576
+ const dynamicCircleStyle = {
1577
+ ...faceCircleStyle,
1578
+ ...liveFaceColor ? { borderColor: liveFaceColor } : null,
1579
+ ...ringPulse ? { animation: ringPulse } : null
1580
+ };
1581
+ return /* @__PURE__ */ React.createElement("div", { style: videoFrameStyle }, /* @__PURE__ */ React.createElement(
1428
1582
  "video",
1429
1583
  {
1430
1584
  ref: videoRef,
@@ -1433,24 +1587,87 @@ function LiveCamera({ onCapture, onCancel, message }) {
1433
1587
  autoPlay: true,
1434
1588
  style: videoStyle
1435
1589
  }
1436
- ), /* @__PURE__ */ React.createElement("div", { style: faceOverlayContainerStyle, "aria-hidden": "true" }, /* @__PURE__ */ React.createElement("div", { style: faceRingWrapStyle }, /* @__PURE__ */ React.createElement("div", { style: faceDashedRingStyle }), /* @__PURE__ */ React.createElement("div", { style: faceCircleStyle }))), message && /* @__PURE__ */ React.createElement("div", { style: liveMessagePillContainerStyle }, /* @__PURE__ */ React.createElement("div", { style: liveMessagePillStyle }, /* @__PURE__ */ React.createElement("span", { style: liveMessagePillTextStyle }, message))), !ready && /* @__PURE__ */ React.createElement("div", { style: videoLoadingStyle }, "Starting camera\u2026")), /* @__PURE__ */ React.createElement("div", { style: buttonsContainerStyle }, /* @__PURE__ */ React.createElement(
1590
+ ), /* @__PURE__ */ React.createElement("div", { style: faceOverlayContainerStyle, "aria-hidden": "true" }, /* @__PURE__ */ React.createElement("div", { style: faceRingWrapStyle }, /* @__PURE__ */ React.createElement("div", { style: faceDashedRingStyle }), /* @__PURE__ */ React.createElement("div", { style: dynamicCircleStyle }))), liveMessage && /* @__PURE__ */ React.createElement("div", { style: liveMessagePillContainerStyle }, /* @__PURE__ */ React.createElement("div", { style: liveMessagePillStyle }, /* @__PURE__ */ React.createElement("span", { style: liveMessagePillTextStyle }, liveMessage))), /* @__PURE__ */ React.createElement(
1437
1591
  "button",
1438
1592
  {
1439
- style: ready ? primaryButtonStyle : { ...primaryButtonStyle, opacity: 0.5, cursor: "not-allowed" },
1593
+ type: "button",
1594
+ onClick: onCancel,
1595
+ "aria-label": "Close camera",
1596
+ style: overlayCloseButtonStyle
1597
+ },
1598
+ /* @__PURE__ */ React.createElement("img", { src: Close, alt: "", width: 16, height: 16 })
1599
+ ), !ready && /* @__PURE__ */ React.createElement("div", { style: videoLoadingStyle }, "Starting camera\u2026"), /* @__PURE__ */ React.createElement("div", { style: bottomGradientStyle }, /* @__PURE__ */ React.createElement(
1600
+ "button",
1601
+ {
1602
+ type: "button",
1440
1603
  onClick: capture,
1441
- disabled: !ready
1604
+ disabled: captureDisabled,
1605
+ "aria-label": "Capture",
1606
+ style: captureDisabled ? { ...shutterButtonStyle, opacity: 0.5, cursor: "not-allowed" } : shutterButtonStyle
1442
1607
  },
1443
- /* @__PURE__ */ React.createElement("img", { src: Camera, alt: "", width: 20, height: 20 }),
1444
- /* @__PURE__ */ React.createElement("span", null, "Capture")
1445
- ), /* @__PURE__ */ React.createElement("button", { style: secondaryButtonStyle, onClick: onCancel }, "Cancel")));
1608
+ /* @__PURE__ */ React.createElement("span", { style: shutterInnerStyle })
1609
+ )));
1446
1610
  }
1447
1611
  var videoFrameStyle = {
1448
1612
  position: "relative",
1449
1613
  width: "100%",
1450
- aspectRatio: "1 / 1",
1451
- borderRadius: 12,
1614
+ aspectRatio: "3 / 4",
1615
+ borderRadius: 24,
1452
1616
  overflow: "hidden",
1453
- background: "#0f172a"
1617
+ background: "#000000",
1618
+ border: "4px solid rgba(255, 255, 255, 0.08)",
1619
+ boxShadow: "0 25px 50px -12px rgba(0, 0, 0, 0.5)"
1620
+ };
1621
+ var overlayCloseButtonStyle = {
1622
+ position: "absolute",
1623
+ top: 12,
1624
+ right: 12,
1625
+ width: 32,
1626
+ height: 32,
1627
+ display: "inline-flex",
1628
+ alignItems: "center",
1629
+ justifyContent: "center",
1630
+ padding: 0,
1631
+ border: "none",
1632
+ borderRadius: "50%",
1633
+ background: "rgba(0, 0, 0, 0.4)",
1634
+ backdropFilter: "blur(6px)",
1635
+ color: "#ffffff",
1636
+ cursor: "pointer",
1637
+ zIndex: 10
1638
+ };
1639
+ var bottomGradientStyle = {
1640
+ position: "absolute",
1641
+ bottom: 0,
1642
+ left: 0,
1643
+ right: 0,
1644
+ padding: "16px",
1645
+ background: "linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%)",
1646
+ display: "flex",
1647
+ alignItems: "center",
1648
+ justifyContent: "center",
1649
+ zIndex: 10
1650
+ };
1651
+ var shutterButtonStyle = {
1652
+ width: 64,
1653
+ height: 64,
1654
+ borderRadius: "50%",
1655
+ background: "rgba(255, 255, 255, 0.15)",
1656
+ backdropFilter: "blur(6px)",
1657
+ border: "2px solid rgba(255, 255, 255, 0.7)",
1658
+ display: "inline-flex",
1659
+ alignItems: "center",
1660
+ justifyContent: "center",
1661
+ cursor: "pointer",
1662
+ padding: 0,
1663
+ transition: "transform 120ms ease-out, background 120ms"
1664
+ };
1665
+ var shutterInnerStyle = {
1666
+ display: "block",
1667
+ width: 44,
1668
+ height: 44,
1669
+ borderRadius: "50%",
1670
+ background: "rgba(255, 255, 255, 0.85)"
1454
1671
  };
1455
1672
  var videoStyle = {
1456
1673
  width: "100%",
@@ -1494,7 +1711,9 @@ var videoLoadingStyle = {
1494
1711
  justifyContent: "center",
1495
1712
  color: "#e5e7eb",
1496
1713
  fontSize: 14,
1497
- fontWeight: 500
1714
+ fontWeight: 500,
1715
+ background: "rgba(0, 0, 0, 0.4)",
1716
+ zIndex: 5
1498
1717
  };
1499
1718
  var liveMessagePillContainerStyle = {
1500
1719
  position: "absolute",
@@ -1878,6 +2097,7 @@ function useReuseKYCSubmission(client) {
1878
2097
  session,
1879
2098
  defaultDevice: opts.defaultDevice,
1880
2099
  renderQR: opts.renderQR,
2100
+ onCancel: opts.onCancel,
1881
2101
  onComplete: (result) => {
1882
2102
  cleanup();
1883
2103
  resolve(result);