"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_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_factory = require("../../../core/factory/factory.cjs");
const require_UnstyledButton = require("../../UnstyledButton/UnstyledButton.cjs");
const require_CheckboxGroup = require("../CheckboxGroup/CheckboxGroup.cjs");
const require_CheckboxCard_module = require("./CheckboxCard.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/Checkbox/CheckboxCard/CheckboxCard.tsx
const CheckboxCardContext = (0, react.createContext)(null);
const defaultProps = { withBorder: true };
const varsResolver = require_create_vars_resolver.createVarsResolver((_, { radius }) => ({ card: { "--card-radius": require_get_size.getRadius(radius) } }));
const CheckboxCard = require_factory.factory((_props) => {
	const props = require_use_props.useProps("CheckboxCard", defaultProps, _props);
	const { classNames, className, style, styles, unstyled, vars, checked, mod, withBorder, value, onClick, defaultChecked, onChange, attributes, ...others } = props;
	const getStyles = require_use_styles.useStyles({
		name: "CheckboxCard",
		classes: require_CheckboxCard_module.default,
		props,
		className,
		style,
		classNames,
		styles,
		unstyled,
		attributes,
		vars,
		varsResolver,
		rootSelector: "card"
	});
	const ctx = (0, react.use)(require_CheckboxGroup.CheckboxGroupContext);
	const [_value, setValue] = (0, _mantine_hooks.useUncontrolled)({
		value: typeof checked === "boolean" ? checked : ctx ? ctx.value.includes(value || "") : void 0,
		defaultValue: defaultChecked,
		finalValue: false,
		onChange
	});
	return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CheckboxCardContext, {
		value: { checked: _value },
		children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_UnstyledButton.UnstyledButton, {
			mod: [{
				"with-border": withBorder,
				checked: _value
			}, mod],
			...getStyles("card"),
			...others,
			role: "checkbox",
			"aria-checked": _value,
			onClick: (event) => {
				onClick?.(event);
				ctx?.onChange(value || "");
				setValue(!_value);
			}
		})
	});
});
CheckboxCard.displayName = "@mantine/core/CheckboxCard";
CheckboxCard.classes = require_CheckboxCard_module.default;
CheckboxCard.varsResolver = varsResolver;
//#endregion
exports.CheckboxCard = CheckboxCard;
exports.CheckboxCardContext = CheckboxCardContext;

//# sourceMappingURL=CheckboxCard.cjs.map