"use client";
const require_get_size = require("../../core/utils/get-size/get-size.cjs");
const require_create_vars_resolver = require("../../core/styles-api/create-vars-resolver/create-vars-resolver.cjs");
const require_parse_theme_color = require("../../core/MantineProvider/color-functions/parse-theme-color/parse-theme-color.cjs");
const require_get_theme_color = require("../../core/MantineProvider/color-functions/get-theme-color/get-theme-color.cjs");
const require_get_contrast_color = require("../../core/MantineProvider/color-functions/get-contrast-color/get-contrast-color.cjs");
const require_get_auto_contrast_value = require("../../core/MantineProvider/color-functions/get-auto-contrast-value/get-auto-contrast-value.cjs");
const require_use_props = require("../../core/MantineProvider/use-props/use-props.cjs");
const require_use_styles = require("../../core/styles-api/use-styles/use-styles.cjs");
const require_extract_style_props = require("../../core/Box/style-props/extract-style-props/extract-style-props.cjs");
const require_factory = require("../../core/factory/factory.cjs");
const require_Box = require("../../core/Box/Box.cjs");
const require_InlineInput = require("../../utils/InlineInput/InlineInput.cjs");
const require_RadioIcon = require("./RadioIcon.cjs");
const require_RadioGroup = require("./RadioGroup/RadioGroup.cjs");
const require_RadioCard = require("./RadioCard/RadioCard.cjs");
const require_RadioIndicator = require("./RadioIndicator/RadioIndicator.cjs");
const require_Radio_module = require("./Radio.module.cjs");
let react = require("react");
let _mantine_hooks = require("@mantine/hooks");
let react_jsx_runtime = require("react/jsx-runtime");
//#region packages/@mantine/core/src/components/Radio/Radio.tsx
const defaultProps = {
	labelPosition: "right",
	withErrorStyles: true
};
const varsResolver = require_create_vars_resolver.createVarsResolver((theme, { size, radius, color, iconColor, variant, autoContrast }) => {
	const parsedColor = require_parse_theme_color.parseThemeColor({
		color: color || theme.primaryColor,
		theme
	});
	const outlineColor = parsedColor.isThemeColor && parsedColor.shade === void 0 ? `var(--mantine-color-${parsedColor.color}-outline)` : parsedColor.color;
	return { root: {
		"--radio-size": require_get_size.getSize(size, "radio-size"),
		"--radio-radius": radius === void 0 ? void 0 : require_get_size.getRadius(radius),
		"--radio-color": variant === "outline" ? outlineColor : require_get_theme_color.getThemeColor(color, theme),
		"--radio-icon-color": iconColor ? require_get_theme_color.getThemeColor(iconColor, theme) : require_get_auto_contrast_value.getAutoContrastValue(autoContrast, theme) ? require_get_contrast_color.getContrastColor({
			color,
			theme,
			autoContrast
		}) : void 0,
		"--radio-icon-size": require_get_size.getSize(size, "radio-icon-size")
	} };
});
const Radio = require_factory.factory((_props) => {
	const props = require_use_props.useProps("Radio", defaultProps, _props);
	const { classNames, className, style, styles, unstyled, vars, id, size, label, labelPosition, description, error, radius, color, variant, disabled, wrapperProps, icon: Icon = require_RadioIcon.RadioIcon, rootRef, iconColor, onChange, mod, attributes, withErrorStyles, checked, ...others } = props;
	const getStyles = require_use_styles.useStyles({
		name: "Radio",
		classes: require_Radio_module.default,
		props,
		className,
		style,
		classNames,
		styles,
		unstyled,
		attributes,
		vars,
		varsResolver
	});
	const ctx = (0, react.use)(require_RadioGroup.RadioGroupContext);
	const contextSize = ctx?.size ?? size;
	const componentSize = props.size ? size : contextSize;
	const { styleProps, rest } = require_extract_style_props.extractStyleProps(others);
	const uuid = (0, _mantine_hooks.useId)(id);
	const describedBy = [
		description ? `${uuid}-description` : void 0,
		error && typeof error !== "boolean" ? `${uuid}-error` : void 0,
		rest["aria-describedby"]
	].filter(Boolean).join(" ") || void 0;
	const contextChecked = ctx ? ctx.value === rest.value : void 0;
	const withContextProps = {
		checked: contextChecked ?? checked,
		name: rest.name ?? ctx?.name,
		onChange: (event) => {
			ctx?.onChange(event);
			onChange?.(event);
		},
		disabled: ctx?.disabled ?? disabled
	};
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_InlineInput.InlineInput, {
		...getStyles("root"),
		__staticSelector: "Radio",
		__stylesApiProps: props,
		id: uuid,
		size: componentSize,
		labelPosition,
		label,
		description,
		error,
		disabled: withContextProps.disabled,
		classNames,
		styles,
		unstyled,
		"data-checked": (contextChecked ?? checked) || void 0,
		variant,
		ref: rootRef,
		mod,
		attributes,
		...styleProps,
		...wrapperProps,
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(require_Box.Box, {
			...getStyles("inner"),
			mod: { "label-position": labelPosition },
			children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Box.Box, {
				...getStyles("radio", {
					focusable: true,
					variant
				}),
				...rest,
				...withContextProps,
				component: "input",
				mod: {
					error: !!error,
					"with-error-styles": withErrorStyles
				},
				id: uuid,
				type: "radio",
				"aria-describedby": describedBy
			}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, {
				...getStyles("icon"),
				"aria-hidden": true
			})]
		})
	});
});
Radio.classes = require_Radio_module.default;
Radio.varsResolver = varsResolver;
Radio.displayName = "@mantine/core/Radio";
Radio.Group = require_RadioGroup.RadioGroup;
Radio.Card = require_RadioCard.RadioCard;
Radio.Indicator = require_RadioIndicator.RadioIndicator;
//#endregion
exports.Radio = Radio;

//# sourceMappingURL=Radio.cjs.map