import { checkboxContainer as e, checkboxInput as t, checkboxLabel as n, customCheckbox as r } from "./checkbox.css.js";
import { Input as i } from "../input/Input.js";
import { Label as a } from "../label/Label.js";
import { useEffect as o, useRef as s } from "react";
import { jsx as c, jsxs as l } from "react/jsx-runtime";
//#region src/atomic/atoms/checkbox/Checkbox.tsx
var u = (u) => {
	let { label: d, checked: f = !1, indeterminate: p = !1, disabled: m = !1, onChange: h, ref: g, ..._ } = u, v = s(null);
	o(() => {
		v.current != null && (v.current.indeterminate = p);
	}, [p]);
	let y = (e) => {
		v.current = e, typeof g == "function" ? g(e) : g != null && (g.current = e);
	}, b = f;
	p && (b = "mixed");
	let x = null;
	return d != null && d !== "" && (x = /* @__PURE__ */ c("span", {
		className: n,
		children: d
	})), /* @__PURE__ */ l(a, {
		className: e,
		children: [
			/* @__PURE__ */ c(i, {
				ref: y,
				type: "checkbox",
				className: t,
				checked: f,
				disabled: m,
				onChange: h,
				"aria-checked": b,
				..._
			}),
			/* @__PURE__ */ c("span", {
				className: r({
					checked: f,
					disabled: m,
					indeterminate: p
				}),
				"aria-hidden": "true"
			}),
			x
		]
	});
};
//#endregion
export { u as Checkbox };

//# sourceMappingURL=Checkbox.js.map