"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }"use client";




var _chunkYINJ5YZ5js = require('./chunk-YINJ5YZ5.js');

// src/types/verification.ts
var KYCError = class _KYCError extends Error {
  constructor(code, message, details) {
    super(message);
    this.name = "KYCError";
    this.code = code;
    this.details = details;
    Object.setPrototypeOf(this, _KYCError.prototype);
  }
};

// src/context/KYCConfigContext.tsx
var _react = require('react'); var React2 = _interopRequireWildcard(_react); var React3 = _interopRequireWildcard(_react);

// src/utils/device-metadata.ts
var SDK_TYPE = "web";
var SDK_VERSION = "2.1.1";
function parseBrowser(ua) {
  const tests = [
    [/Edg\/([\d.]+)/, "Edge", "Blink"],
    [/OPR\/([\d.]+)/, "Opera", "Blink"],
    [/Chrome\/([\d.]+)/, "Chrome", "Blink"],
    [/CriOS\/([\d.]+)/, "Chrome iOS", "WebKit"],
    [/FxiOS\/([\d.]+)/, "Firefox iOS", "WebKit"],
    [/Firefox\/([\d.]+)/, "Firefox", "Gecko"],
    [/Version\/([\d.]+).*Safari/, "Safari", "WebKit"],
    [/MSIE ([\d.]+)/, "Internet Explorer", "Trident"],
    [/Trident\/.*rv:([\d.]+)/, "Internet Explorer", "Trident"]
  ];
  for (const [re, name, engine] of tests) {
    const m = ua.match(re);
    if (m) return { name, version: m[1], engine };
  }
  return { name: "Unknown" };
}
function parseOS(ua) {
  if (/Windows NT 10\.0/.test(ua)) return { name: "Windows", version: "10/11" };
  if (/Windows NT 6\.3/.test(ua)) return { name: "Windows", version: "8.1" };
  if (/Windows NT 6\.2/.test(ua)) return { name: "Windows", version: "8" };
  if (/Windows NT 6\.1/.test(ua)) return { name: "Windows", version: "7" };
  if (/Windows NT/.test(ua)) return { name: "Windows" };
  const ios = ua.match(/OS (\d+)[._](\d+)(?:[._](\d+))? like Mac OS X/);
  if (ios) {
    const v = [ios[1], ios[2], ios[3]].filter(Boolean).join(".");
    return { name: "iOS", version: v };
  }
  const ipad = /iPad/.test(ua);
  const iphone = /iPhone|iPod/.test(ua);
  if (ipad || iphone) return { name: "iOS" };
  const macos = ua.match(/Mac OS X (\d+)[._](\d+)(?:[._](\d+))?/);
  if (macos) {
    const v = [macos[1], macos[2], macos[3]].filter(Boolean).join(".");
    return { name: "macOS", version: v };
  }
  if (/Macintosh/.test(ua)) return { name: "macOS" };
  const android = ua.match(/Android (\d+(?:\.\d+)*)/);
  if (android) return { name: "Android", version: android[1] };
  if (/Android/.test(ua)) return { name: "Android" };
  if (/CrOS/.test(ua)) return { name: "Chrome OS" };
  if (/Linux/.test(ua)) return { name: "Linux" };
  return { name: "Unknown" };
}
function parseDeviceType(ua) {
  if (/iPad|Tablet|PlayBook|Silk|Kindle/i.test(ua)) return "tablet";
  if (/Android(?!.*Mobile)/.test(ua)) return "tablet";
  if (/Mobi|Mobile|iPhone|iPod|BlackBerry|IEMobile|Opera Mini/i.test(ua)) return "mobile";
  return "desktop";
}
function parseDeviceModel(ua) {
  if (/iPhone/.test(ua)) return { vendor: "Apple", model: "iPhone" };
  if (/iPad/.test(ua)) return { vendor: "Apple", model: "iPad" };
  if (/iPod/.test(ua)) return { vendor: "Apple", model: "iPod" };
  if (/Macintosh/.test(ua)) return { vendor: "Apple", model: "Mac" };
  const android = ua.match(/Android[^;]*;\s*([^)]+?)(?:\s+Build|;|\))/);
  if (android) {
    const raw = android[1].trim().replace(/\s+/g, " ");
    return { vendor: raw.split(/\s+/)[0], model: raw };
  }
  return {};
}
function collectWebDeviceMetadata() {
  var _a, _b;
  const fallback = {
    sdkType: SDK_TYPE,
    sdkVersion: SDK_VERSION,
    sdkPlatform: "web",
    capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
    device: { type: "unknown" },
    os: { name: "Unknown" },
    browser: { name: "Unknown" }
  };
  if (typeof window === "undefined" || typeof navigator === "undefined") {
    return fallback;
  }
  try {
    const nav = navigator;
    const ua = nav.userAgent || "";
    const browser = parseBrowser(ua);
    const os = parseOS(ua);
    const type = parseDeviceType(ua);
    const { vendor, model } = parseDeviceModel(ua);
    const conn = nav.connection || nav.mozConnection || nav.webkitConnection;
    const meta = {
      sdkType: SDK_TYPE,
      sdkVersion: SDK_VERSION,
      sdkPlatform: "web",
      capturedAt: (/* @__PURE__ */ new Date()).toISOString(),
      device: _chunkYINJ5YZ5js.__spreadValues.call(void 0, _chunkYINJ5YZ5js.__spreadValues.call(void 0, { type }, vendor && { vendor }), model && { model }),
      os,
      browser,
      userAgent: ua,
      platform: nav.platform || ((_a = nav.userAgentData) == null ? void 0 : _a.platform)
    };
    if (typeof window.screen !== "undefined") {
      meta.screen = {
        width: window.screen.width,
        height: window.screen.height,
        availWidth: window.screen.availWidth,
        availHeight: window.screen.availHeight,
        devicePixelRatio: window.devicePixelRatio || 1,
        colorDepth: window.screen.colorDepth,
        orientation: (_b = window.screen.orientation) == null ? void 0 : _b.type
      };
    }
    meta.viewport = {
      width: window.innerWidth,
      height: window.innerHeight
    };
    try {
      meta.timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
    } catch (e) {
    }
    meta.timezoneOffsetMinutes = -(/* @__PURE__ */ new Date()).getTimezoneOffset();
    meta.locale = nav.language;
    meta.language = nav.language;
    meta.languages = Array.isArray(nav.languages) ? [...nav.languages] : void 0;
    meta.hardware = {
      cores: nav.hardwareConcurrency,
      memoryGb: nav.deviceMemory,
      touchPoints: nav.maxTouchPoints
    };
    if (conn) {
      meta.network = {
        type: conn.effectiveType,
        downlinkMbps: conn.downlink,
        rttMs: conn.rtt,
        saveData: conn.saveData
      };
    }
    meta.capabilities = {
      cookies: nav.cookieEnabled,
      doNotTrack: nav.doNotTrack === "1" || nav.doNotTrack === "yes",
      online: nav.onLine,
      webdriver: nav.webdriver
    };
    return meta;
  } catch (e) {
    return fallback;
  }
}

// src/services/api.ts
var KYCApiError = class extends Error {
  constructor(message, statusCode, code, body) {
    super(message);
    this.statusCode = statusCode;
    this.code = code;
    this.body = body;
    this.name = "KYCApiError";
  }
};
function baseHeaders(apiKey) {
  return {
    Authorization: `Bearer ${apiKey}`,
    "X-SDK-Version": SDK_VERSION
  };
}
async function handleResponse(res) {
  var _a, _b;
  const text = await res.text();
  let data = null;
  if (text) {
    try {
      data = JSON.parse(text);
    } catch (e) {
      data = { message: text };
    }
  }
  if (!res.ok) {
    const errObj = typeof data === "object" && data !== null ? data : {};
    const message = String((_b = (_a = errObj.message) != null ? _a : errObj.error) != null ? _b : `Request failed with status ${res.status}`);
    const code = typeof errObj.error === "string" ? errObj.error : void 0;
    throw new KYCApiError(message, res.status, code, errObj);
  }
  return data;
}
var IMAGE_MIME_TYPES = ["image/jpeg", "image/png", "image/webp"];
var VIDEO_MIME_TYPES = ["video/webm", "video/mp4"];
function normalizeMimeType(blobType, type) {
  const base = (blobType.split(";")[0] || "").trim().toLowerCase();
  const isVideo = type.endsWith("_video");
  const allowed = isVideo ? VIDEO_MIME_TYPES : IMAGE_MIME_TYPES;
  if (allowed.includes(base)) return base;
  return isVideo ? "video/webm" : "image/jpeg";
}
var MIME_EXTENSIONS = {
  "image/jpeg": "jpg",
  "image/png": "png",
  "image/webp": "webp",
  "video/webm": "webm",
  "video/mp4": "mp4"
};
function toUploadFile(file, type) {
  const mimeType = normalizeMimeType(file.type, type);
  return new File([file], `${type}.${MIME_EXTENSIONS[mimeType]}`, { type: mimeType });
}
function createKYCApi(baseUrl, apiKey) {
  const base = `${baseUrl}/api/kyc`;
  const headers = baseHeaders(apiKey);
  async function request(path, init = {}) {
    const res = await fetch(`${base}${path}`, _chunkYINJ5YZ5js.__spreadProps.call(void 0, _chunkYINJ5YZ5js.__spreadValues.call(void 0, {}, init), {
      headers: _chunkYINJ5YZ5js.__spreadValues.call(void 0, _chunkYINJ5YZ5js.__spreadValues.call(void 0, _chunkYINJ5YZ5js.__spreadValues.call(void 0, {}, headers), init.body ? { "Content-Type": "application/json" } : {}), init.headers)
    }));
    return handleResponse(res);
  }
  return {
    // Single multipart upload: the file bytes are POSTed to our server, which
    // stores them in R2 and returns the mediaId referenced later by /verify.
    async upload(file, type) {
      const form = new FormData();
      form.append("file", toUploadFile(file, type));
      form.append("type", type);
      const res = await fetch(`${base}/upload`, {
        method: "POST",
        headers,
        body: form
      });
      const { mediaId } = await handleResponse(res);
      return mediaId;
    },
    async verify(body) {
      return request("/verify", {
        method: "POST",
        body: JSON.stringify(body)
      });
    },
    // Minimal, publishable-safe status (no PII). The full result lives behind a
    // secret-key-only endpoint and must be fetched from your backend.
    async status(verificationId) {
      return request(`/status/${verificationId}`);
    },
    async config() {
      return request("/config");
    },
    // ── Device handoff (continue-on-phone) ──────────────────────────────────
    /** Desktop: mint a handoff session from a PII-free config snapshot. */
    async createHandoffSession(snapshot) {
      return request("/session", {
        method: "POST",
        body: JSON.stringify(snapshot)
      });
    },
    /** Desktop: poll a handoff session's lifecycle status. */
    async getHandoffSession(sessionId) {
      return request(`/session/${sessionId}`);
    },
    /** Phone: bootstrap the hosted flow from the session token (public route). */
    async bootstrapHandoff(token) {
      return request(`/session/by-token/${token}/bootstrap`);
    }
  };
}

// src/lib/resolve-url.ts
var BASE_URLS = {
  // Sandbox and production share the same host; the key prefix selects the env.
  sandbox: "https://identity.myaza.app",
  production: "https://identity.myaza.app"
};
var DEFAULT_DEV_URL = "http://localhost:3001";
var KEY_ENV_RE = /^(?:pk|sk)_(dev|test|live)_/;
var ENV_BY_PREFIX = {
  dev: "development",
  test: "sandbox",
  live: "production"
};
function detectEnvironment(apiKey) {
  const match = typeof apiKey === "string" ? apiKey.match(KEY_ENV_RE) : null;
  if (!match) {
    throw new Error(
      "Invalid Myaza API key: expected a dev, test, or live key prefix (e.g. pk_dev_\u2026, pk_test_\u2026, or pk_live_\u2026)."
    );
  }
  return ENV_BY_PREFIX[match[1]];
}
function resolveBaseUrl(apiKey, devUrl) {
  const environment = detectEnvironment(apiKey);
  if (environment === "development") {
    return devUrl != null ? devUrl : DEFAULT_DEV_URL;
  }
  return BASE_URLS[environment];
}

// src/lib/errors.ts
function safeReportError(onError, error) {
  if (!onError) return;
  try {
    onError(error);
  } catch (err) {
    if (typeof console !== "undefined") {
      console.warn("[MyazaKYC] onError handler threw and was ignored:", err);
    }
  }
}
function toNum(v) {
  if (typeof v === "number") return v;
  if (typeof v === "string") {
    const n = parseFloat(v);
    return Number.isNaN(n) ? void 0 : n;
  }
  return void 0;
}
function mapToKycError(err, context) {
  var _a, _b;
  if (err instanceof KYCApiError) {
    if (err.statusCode === 401) {
      return new KYCError("invalid_api_key", "Invalid API key. Please contact support.");
    }
    if (err.statusCode === 402) {
      const body = (_a = err.body) != null ? _a : {};
      const required = toNum(body.required);
      const balance = toNum(body.balance);
      const currency = typeof body.currency === "string" ? body.currency : void 0;
      const message = required !== void 0 && balance !== void 0 ? `Insufficient credits. Required: $${required.toFixed(2)}, Available: $${balance.toFixed(2)}` : "Insufficient credits to process this verification.";
      return new KYCError("insufficient_credits", message, { required, balance, currency });
    }
    if (err.statusCode === 403) {
      const feature = typeof ((_b = err.body) == null ? void 0 : _b.feature) === "string" ? err.body.feature : null;
      const message = err.code === "id_type_not_allowed" ? "This ID type isn't enabled for your organization. Contact your administrator to request access." : feature === "document_verification" ? "Document verification is currently disabled for your organization." : feature === "gov_db_check" ? "Government database verification is currently disabled for your organization." : err.message || "This verification feature is currently disabled for your organization.";
      return new KYCError("feature_disabled", message);
    }
    if (err.statusCode >= 500 || err.statusCode === 0) {
      const code3 = context === "upload" ? "upload_failed" : "network_error";
      return new KYCError(code3, "A server error occurred. Please try again in a moment.");
    }
    const code2 = context === "upload" ? "upload_failed" : "unknown";
    return new KYCError(code2, err.message);
  }
  if (err instanceof TypeError) {
    return new KYCError(
      "network_error",
      "Network error. Please check your connection and try again."
    );
  }
  const code = context === "upload" ? "upload_failed" : "unknown";
  return new KYCError(code, err instanceof Error ? err.message : "Something went wrong. Please try again.");
}

// src/context/KYCConfigContext.tsx
var _jsxruntime = require('react/jsx-runtime');
var KYCConfigContext = _react.createContext.call(void 0, null);
function describeConfigError(err) {
  if (err instanceof KYCApiError) {
    if (err.statusCode === 401) {
      return {
        message: "Invalid API key. Please check the API key configured in the SDK.",
        statusCode: 401,
        fatal: true,
        code: "invalid_api_key"
      };
    }
    if (err.statusCode === 403) {
      return {
        message: err.message || "This API key is not permitted to use the verification SDK.",
        statusCode: 403,
        fatal: true,
        code: "feature_disabled"
      };
    }
    if (err.statusCode >= 500) {
      return {
        message: "A server error occurred while loading verification settings. Please try again.",
        statusCode: err.statusCode,
        fatal: false,
        code: "unknown"
      };
    }
    return { message: err.message, statusCode: err.statusCode, fatal: false, code: "unknown" };
  }
  if (err instanceof TypeError) {
    return { message: "Network error. Please check your connection and try again.", fatal: false, code: "network_error" };
  }
  return { message: err instanceof Error ? err.message : "Failed to load SDK config", fatal: false, code: "unknown" };
}
function KYCConfigProvider(_a) {
  var _b = _a, { children, apiOverride, serverConfigOverride } = _b, config = _chunkYINJ5YZ5js.__objRest.call(void 0, _b, ["children", "apiOverride", "serverConfigOverride"]);
  const [serverConfig, setServerConfig] = _react.useState.call(void 0, 
    serverConfigOverride != null ? serverConfigOverride : { status: "loading", idTypes: [] }
  );
  const api = _react.useMemo.call(void 0, 
    () => apiOverride != null ? apiOverride : createKYCApi(resolveBaseUrl(config.apiKey, config.devUrl), config.apiKey),
    [apiOverride, config.apiKey, config.devUrl]
  );
  const reportedErrorRef = _react.useRef.call(void 0, null);
  _react.useEffect.call(void 0, () => {
    if (serverConfigOverride) return;
    let cancelled = false;
    api.config().then((res) => {
      if (cancelled) return;
      setServerConfig({
        status: "ready",
        idTypes: res.idTypes,
        environment: res.environment,
        branding: res.branding
      });
    }).catch((err) => {
      if (cancelled) return;
      const { message, statusCode, fatal, code } = describeConfigError(err);
      setServerConfig({ status: "error", idTypes: [], error: message, statusCode, fatal });
      if (fatal && reportedErrorRef.current !== api) {
        reportedErrorRef.current = api;
        safeReportError(config.onError, new KYCError(code, message));
      }
    });
    return () => {
      cancelled = true;
    };
  }, [api]);
  const idTypesByKey = _react.useMemo.call(void 0, () => {
    const map = /* @__PURE__ */ new Map();
    for (const row of serverConfig.idTypes) {
      map.set(`${row.country}/${row.idType}`, row);
    }
    return map;
  }, [serverConfig.idTypes]);
  const value = _react.useMemo.call(void 0, 
    () => _chunkYINJ5YZ5js.__spreadProps.call(void 0, _chunkYINJ5YZ5js.__spreadValues.call(void 0, {}, config), {
      api,
      serverConfig,
      getIdTypeFeatures: (country, idType) => {
        var _a2, _b2;
        return (_b2 = (_a2 = idTypesByKey.get(`${country}/${idType}`)) == null ? void 0 : _a2.features) != null ? _b2 : null;
      }
    }),
    // eslint-disable-next-line react-hooks/exhaustive-deps
    [
      config.devUrl,
      config.apiKey,
      api,
      config.country,
      config.idTypes,
      config.metadata,
      config.userData,
      config.enableSelfie,
      config.enableDocumentCapture,
      config.allowDocumentUpload,
      config.enableLiveness,
      config.deviceHandoff,
      config.assetsBasePath,
      config.appearance,
      config.consent,
      config.success,
      config.onSubmit,
      config.onClose,
      config.onError,
      serverConfig,
      idTypesByKey
    ]
  );
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, KYCConfigContext.Provider, { value, children });
}
function useKYCConfig() {
  const ctx = _react.useContext.call(void 0, KYCConfigContext);
  if (!ctx) {
    throw new Error("useKYCConfig must be used within a <KYCConfigProvider>");
  }
  return ctx;
}

// src/hooks/useBranding.ts
function useBranding() {
  var _a, _b, _c;
  const config = useKYCConfig();
  const serverBranding = config.serverConfig.branding;
  const configuredLogo = (_a = config.appearance) == null ? void 0 : _a.logo;
  return {
    logo: configuredLogo === "default" ? serverBranding == null ? void 0 : serverBranding.logo : configuredLogo,
    companyName: (_c = (_b = config.appearance) == null ? void 0 : _b.companyName) != null ? _c : serverBranding == null ? void 0 : serverBranding.companyName
  };
}

// src/lib/theme.ts
function buildThemeVars(appearance) {
  if (!appearance) return {};
  const vars = {};
  const set = (token, value) => {
    if (value) vars[token] = value;
  };
  set("--primary", appearance.primaryColor);
  set("--ring", appearance.primaryColor);
  set("--primary-foreground", appearance.primaryTextColor);
  set("--accent", appearance.accentColor);
  set("--background", appearance.backgroundColor);
  set("--secondary", appearance.surfaceColor);
  set("--muted", appearance.surfaceColor);
  set("--border", appearance.borderColor);
  set("--input", appearance.borderColor);
  set("--foreground", appearance.textColor);
  return vars;
}

// src/lib/utils.ts
var _clsx = require('clsx');
var _tailwindmerge = require('tailwind-merge');
function cn(...inputs) {
  return _tailwindmerge.twMerge.call(void 0, _clsx.clsx.call(void 0, inputs));
}

// src/components/ui/dialog.tsx

var _reactdialog = require('@radix-ui/react-dialog'); var DialogPrimitive = _interopRequireWildcard(_reactdialog);

var Dialog = DialogPrimitive.Root;
var DialogPortal = DialogPrimitive.Portal;
var DialogOverlay = React2.forwardRef((_a, ref) => {
  var _b = _a, { className } = _b, props = _chunkYINJ5YZ5js.__objRest.call(void 0, _b, ["className"]);
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
    DialogPrimitive.Overlay,
    _chunkYINJ5YZ5js.__spreadValues.call(void 0, {
      ref,
      className: cn("fixed inset-0 z-50 animate-fade-in transition-colors duration-500", className)
    }, props)
  );
});
DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
var DialogContent = React2.forwardRef((_a, ref) => {
  var _b = _a, { className, children, fullscreen, overlayClassName } = _b, props = _chunkYINJ5YZ5js.__objRest.call(void 0, _b, ["className", "children", "fullscreen", "overlayClassName"]);
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, DialogPortal, { children: [
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, DialogOverlay, { className: cn("bg-black/60", overlayClassName) }),
    /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      DialogPrimitive.Content,
      _chunkYINJ5YZ5js.__spreadProps.call(void 0, _chunkYINJ5YZ5js.__spreadValues.call(void 0, {
        ref,
        className: cn(
          "fixed z-50 bg-background text-foreground shadow-lg animate-slide-up focus:outline-none overflow-y-auto",
          fullscreen ? "inset-0 rounded-none" : "inset-0 rounded-none xl:inset-auto xl:left-[50%] xl:top-[50%] xl:translate-x-[-50%] xl:translate-y-[-50%] xl:w-[40vw] xl:max-h-[92vh] xl:rounded-2xl",
          className
        )
      }, props), {
        children
      })
    )
  ] });
});
DialogContent.displayName = DialogPrimitive.Content.displayName;
var DialogTitle = React2.forwardRef((_a, ref) => {
  var _b = _a, { className } = _b, props = _chunkYINJ5YZ5js.__objRest.call(void 0, _b, ["className"]);
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
    DialogPrimitive.Title,
    _chunkYINJ5YZ5js.__spreadValues.call(void 0, {
      ref,
      className: cn(
        "text-lg font-semibold leading-none tracking-tight",
        className
      )
    }, props)
  );
});
DialogTitle.displayName = DialogPrimitive.Title.displayName;
var DialogDescription = React2.forwardRef((_a, ref) => {
  var _b = _a, { className } = _b, props = _chunkYINJ5YZ5js.__objRest.call(void 0, _b, ["className"]);
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
    DialogPrimitive.Description,
    _chunkYINJ5YZ5js.__spreadValues.call(void 0, {
      ref,
      className: cn("text-sm text-muted-foreground", className)
    }, props)
  );
});
DialogDescription.displayName = DialogPrimitive.Description.displayName;

// src/components/ui/button.tsx

var _classvarianceauthority = require('class-variance-authority');

var buttonVariants = _classvarianceauthority.cva.call(void 0, 
  "inline-flex items-center justify-center whitespace-nowrap rounded-xl text-base font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
  {
    variants: {
      variant: {
        default: "bg-primary text-primary-foreground hover:bg-primary/90",
        destructive: "bg-destructive text-destructive-foreground hover:bg-destructive/90",
        outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
        secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
        ghost: "hover:bg-accent hover:text-accent-foreground",
        link: "text-primary underline-offset-4 hover:underline"
      },
      size: {
        default: "h-12 px-4 py-2",
        sm: "h-9 rounded-lg px-3 text-sm",
        lg: "h-14 rounded-xl px-8 text-lg",
        icon: "h-10 w-10"
      }
    },
    defaultVariants: {
      variant: "default",
      size: "default"
    }
  }
);
var Button = React3.forwardRef(
  (_a, ref) => {
    var _b = _a, { className, variant, size } = _b, props = _chunkYINJ5YZ5js.__objRest.call(void 0, _b, ["className", "variant", "size"]);
    return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
      "button",
      _chunkYINJ5YZ5js.__spreadValues.call(void 0, {
        className: cn(buttonVariants({ variant, size, className })),
        ref
      }, props)
    );
  }
);
Button.displayName = "Button";

// src/components/VisuallyHidden.tsx

function VisuallyHidden({ children }) {
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, 
    "span",
    {
      style: {
        position: "absolute",
        width: 1,
        height: 1,
        padding: 0,
        margin: -1,
        overflow: "hidden",
        clip: "rect(0,0,0,0)",
        whiteSpace: "nowrap",
        borderWidth: 0
      },
      children
    }
  );
}

// src/hooks/useDeviceHandoff.ts

var POLL_INTERVAL_MS = 2500;
function useDeviceHandoff(api, snapshot, enabled) {
  const [phase, setPhase] = _react.useState.call(void 0, "creating");
  const [code, setCode] = _react.useState.call(void 0, null);
  const [url, setUrl] = _react.useState.call(void 0, null);
  const [sessionId, setSessionId] = _react.useState.call(void 0, null);
  const [verificationId, setVerificationId] = _react.useState.call(void 0, null);
  const [error, setError] = _react.useState.call(void 0, null);
  const [nonce, setNonce] = _react.useState.call(void 0, 0);
  const pollRef = _react.useRef.call(void 0, null);
  const snapshotRef = _react.useRef.call(void 0, snapshot);
  snapshotRef.current = snapshot;
  const regenerate = _react.useCallback.call(void 0, () => setNonce((n) => n + 1), []);
  _react.useEffect.call(void 0, () => {
    if (!enabled) return;
    let cancelled = false;
    const stopPoll = () => {
      if (pollRef.current) {
        clearInterval(pollRef.current);
        pollRef.current = null;
      }
    };
    setPhase("creating");
    setError(null);
    setVerificationId(null);
    api.createHandoffSession(snapshotRef.current).then((res) => {
      if (cancelled) return;
      setSessionId(res.sessionId);
      setCode(res.code);
      setUrl(res.url);
      setPhase("waiting");
      pollRef.current = setInterval(async () => {
        var _a;
        try {
          const s = await api.getHandoffSession(res.sessionId);
          if (cancelled) return;
          if (s.status === "submitted") {
            setVerificationId((_a = s.verificationId) != null ? _a : null);
            setPhase("submitted");
            stopPoll();
          } else if (s.status === "expired") {
            setPhase("expired");
            stopPoll();
          } else if (s.status === "opened") {
            setPhase("opened");
          }
        } catch (e) {
        }
      }, POLL_INTERVAL_MS);
    }).catch((err) => {
      if (cancelled) return;
      setError(err instanceof Error ? err.message : "Could not start device handoff.");
      setPhase("error");
    });
    return () => {
      cancelled = true;
      stopPoll();
    };
  }, [api, enabled, nonce]);
  return { phase, code, url, sessionId, verificationId, error, regenerate };
}

// src/lib/device.ts
function isDesktopDevice() {
  var _a, _b, _c, _d, _e, _f;
  if (typeof window === "undefined") return false;
  const mql = (_a = window.matchMedia) == null ? void 0 : _a.bind(window);
  const finePointer = (_c = (_b = mql == null ? void 0 : mql("(pointer: fine)")) == null ? void 0 : _b.matches) != null ? _c : false;
  const coarsePointer = (_e = (_d = mql == null ? void 0 : mql("(pointer: coarse)")) == null ? void 0 : _d.matches) != null ? _e : false;
  const hasTouch = "ontouchstart" in window || typeof navigator !== "undefined" && ((_f = navigator.maxTouchPoints) != null ? _f : 0) > 0;
  const wideViewport = window.innerWidth >= 1024;
  if (coarsePointer && hasTouch) return false;
  return finePointer && wideViewport;
}
async function hasNoWebcam() {
  var _a;
  try {
    if (typeof navigator === "undefined" || !((_a = navigator.mediaDevices) == null ? void 0 : _a.enumerateDevices)) {
      return false;
    }
    const devices = await navigator.mediaDevices.enumerateDevices();
    return !devices.some((d) => d.kind === "videoinput");
  } catch (e) {
    return false;
  }
}






















exports.collectWebDeviceMetadata = collectWebDeviceMetadata; exports.KYCApiError = KYCApiError; exports.createKYCApi = createKYCApi; exports.KYCError = KYCError; exports.safeReportError = safeReportError; exports.mapToKycError = mapToKycError; exports.KYCConfigProvider = KYCConfigProvider; exports.useKYCConfig = useKYCConfig; exports.useBranding = useBranding; exports.buildThemeVars = buildThemeVars; exports.cn = cn; exports.Dialog = Dialog; exports.DialogContent = DialogContent; exports.DialogTitle = DialogTitle; exports.DialogDescription = DialogDescription; exports.Button = Button; exports.VisuallyHidden = VisuallyHidden; exports.useDeviceHandoff = useDeviceHandoff; exports.isDesktopDevice = isDesktopDevice; exports.hasNoWebcam = hasNoWebcam;
//# sourceMappingURL=chunk-XSD2S42I.js.map