import { createElement, useEffect, useRef } from "react"; import type { Ref } from "react"; import { getCurrentDocumentCspNonce } from "~/utils/security/documentCspNonce"; interface Props { /** Render the captcha widget. When false (or unconfigured) nothing is rendered. */ enabled: boolean; /** Active self-hosted provider. Defaults to mCaptcha for compatibility. */ provider?: "mcaptcha" | "cap"; /** Public base URL of the self-hosted captcha instance. */ instanceUrl?: string; /** Public sitekey for this surface. */ sitekey?: string; /** Reports whether a reusable form may submit a fresh proof. */ onStatusChange?: (status: "pending" | "solved" | "error") => void; } // mCaptcha's vanilla glue mounts the widget into an element with this id and // injects a hidden into the enclosing