import { Button as e } from "../primitives/button.js";
import { usePasskey as t } from "../hooks/usePasskey.js";
import * as n from "react";
import { jsx as r } from "react/jsx-runtime";
//#region src/react/auth/passkey-button.tsx
function i({ mode: i = "authenticate", passkeyOptions: a, onSuccess: o, onError: s, children: c, ...l }) {
	let { isSupported: u, authenticate: d, register: f } = t(), [p, m] = n.useState(!1);
	async function h() {
		if (u) {
			m(!0);
			try {
				let e;
				e = i === "register" ? await f(a ?? {}) : await d(a ?? {}), o?.(e);
			} catch (e) {
				s?.(e);
			} finally {
				m(!1);
			}
		}
	}
	let g = i === "register" ? "Register passkey" : "Sign in with passkey", _ = l["aria-label"] ?? (c == null ? g : void 0);
	return /* @__PURE__ */ r(e, {
		...l,
		disabled: !u,
		loading: p,
		onClick: () => void h(),
		..._ === void 0 ? {} : { "aria-label": _ },
		children: c ?? g
	});
}
//#endregion
export { i as PasskeyButton };

//# sourceMappingURL=passkey-button.js.map