"use client";
import { t as e } from "./useControlled-ZBScq72P.js";
import { t } from "./useIsoLayoutEffect-CKOv1bV_.js";
import { f as n, l as r, o as i, r as a, s as o, t as ee, u as s } from "./useRenderElement-CmuWsiNa.js";
import { g as c, t as te } from "./createBaseUIEventDetails-ChcQXp54.js";
import { t as l } from "./useBaseUiId-DOm5ACje.js";
import { a as ne, o as re, t as ie } from "./useOpenChangeComplete-DjMFUwhi.js";
import { l as u } from "./floating-ui.utils.dom-5U5b4xPf.js";
import { t as d } from "./useButton-AXffhTAZ.js";
import { cn as f } from "./lib/utils.js";
import { n as p, t as m } from "./visuallyHidden-CEAV1xeA.js";
import { t as ae } from "./useValueChanged-j5e75XB6.js";
import { i as h, n as oe, r as se, t as ce } from "./LabelableContext-Q1Z-xUI9.js";
import { t as le } from "./FieldItemContext-4qBxodsW.js";
import { t as ue } from "./FormContext-4NSsO4w6.js";
import { t as de } from "./useAriaLabelledBy-DKl6aNOD.js";
import * as g from "react";
import { jsx as _, jsxs as fe } from "react/jsx-runtime";
import { CheckIcon as pe, MinusIcon as v } from "lucide-react";
//#region ../../node_modules/.bun/@base-ui+utils@0.2.9+f7941a290aa3d619/node_modules/@base-ui/utils/esm/getDefaultFormSubmitter.js
function me(e) {
	if (!e) return null;
	for (let t of e.elements) {
		let e = t.tagName;
		if (e === "BUTTON" || e === "INPUT") {
			let e = t;
			if (e.type === "submit") return e;
		}
	}
	return null;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/checkbox/root/CheckboxRootDataAttributes.js
var y = /*#__PURE__*/ function(e) {
	return e.checked = "data-checked", e.unchecked = "data-unchecked", e.indeterminate = "data-indeterminate", e.disabled = "data-disabled", e.readonly = "data-readonly", e.required = "data-required", e.valid = "data-valid", e.invalid = "data-invalid", e.touched = "data-touched", e.dirty = "data-dirty", e.filled = "data-filled", e.focused = "data-focused", e;
}({});
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/checkbox/utils/useStateAttributesMapping.js
function b(e) {
	return g.useMemo(() => ({
		checked(t) {
			return e.indeterminate ? {} : t ? { [y.checked]: "" } : { [y.unchecked]: "" };
		},
		...h
	}), [e.indeterminate]);
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/checkbox-group/CheckboxGroupContext.js
var x = /*#__PURE__*/ g.createContext(void 0);
process.env.NODE_ENV !== "production" && (x.displayName = "CheckboxGroupContext");
function he(e = !0) {
	let t = g.useContext(x);
	if (t === void 0 && !e) throw Error(process.env.NODE_ENV === "production" ? s(3) : "Base UI: CheckboxGroupContext is missing. CheckboxGroup parts must be placed within <CheckboxGroup>.");
	return t;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/checkbox/root/CheckboxRootContext.js
var S = /*#__PURE__*/ g.createContext(void 0);
process.env.NODE_ENV !== "production" && (S.displayName = "CheckboxRootContext");
function C() {
	let e = g.useContext(S);
	if (e === void 0) throw Error(process.env.NODE_ENV === "production" ? s(14) : "Base UI: CheckboxRootContext is missing. Checkbox parts must be placed within <Checkbox.Root>.");
	return e;
}
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/checkbox/root/CheckboxRoot.js
var ge = "data-parent", w = /*#__PURE__*/ g.forwardRef(function(s, ne) {
	let { checked: re, className: ie, defaultChecked: f = !1, "aria-labelledby": h, disabled: pe = !1, form: v, id: y, indeterminate: x = !1, inputRef: C, name: w, onCheckedChange: T, parent: E = !1, readOnly: D = !1, render: _e, required: O = !1, uncheckedValue: k, value: A, nativeButton: j = !1, style: ve, ...ye } = s, { clearErrors: be } = ue(), { disabled: xe, name: Se, setDirty: Ce, setFilled: M, setFocused: N, setTouched: we, state: P, validationMode: Te, validityData: Ee, shouldValidateOnChange: De, validation: Oe } = se(), ke = le(), { labelId: Ae, controlId: je, registerControlId: F, getDescriptionProps: I } = ce(), L = he(), R = L?.parent, z = R && L.allValues, B = xe || ke.disabled || L?.disabled || pe, V = Se ?? w, H = A ?? V, Me = l(), Ne = l(), U = je;
	z ? U = E ? Ne : `${R.id}-${H}` : y && (U = y);
	let W = {};
	z && (E ? W = L.parent.getParentProps() : H && (W = L.parent.getChildProps(H)));
	let { checked: Pe = re, indeterminate: G = x, onCheckedChange: Fe, ...Ie } = W, K = L?.value, Le = L?.setValue, Re = L?.defaultValue, q = g.useRef(null), J = n(() => Symbol("checkbox-control")), Y = g.useRef(!1), { getButtonProps: ze, buttonRef: Be } = d({
		disabled: B,
		native: j
	}), X = L?.validation ?? Oe, [Z, Ve] = e({
		controlled: H && K && !E ? K.includes(H) : Pe,
		default: H && Re && !E ? Re.includes(H) : f,
		name: "Checkbox",
		state: "checked"
	});
	t(() => {
		F !== o && (Y.current = !0, F(J.current, U));
	}, [
		U,
		F,
		J
	]), g.useEffect(() => {
		let e = J.current;
		return () => {
			!Y.current || F === o || (Y.current = !1, F(e, void 0));
		};
	}, [F, J]), oe(q, Me, Z, void 0, !L);
	let Q = g.useRef(null), He = r(C, Q, X.inputRef), Ue = de(h, Ae, Q, !j, U ?? void 0);
	t(() => {
		Q.current && (Q.current.indeterminate = G, Z && M(!0));
	}, [
		Z,
		G,
		M
	]), ae(Z, () => {
		L && !E || (be(V), M(Z), Ce(Z !== Ee.initialValue), De() ? X.commit(Z) : X.commit(Z, !0));
	});
	let We = a({
		checked: Z,
		disabled: B,
		form: v,
		name: E ? void 0 : V,
		id: j ? void 0 : U ?? void 0,
		required: O,
		ref: He,
		style: V ? p : m,
		tabIndex: -1,
		type: "checkbox",
		"aria-hidden": !0,
		onChange(e) {
			if (e.nativeEvent.defaultPrevented) return;
			if (D) {
				e.preventDefault();
				return;
			}
			let t = e.currentTarget.checked, n = te(c, e.nativeEvent);
			Fe?.(t, n), T?.(t, n), !n.isCanceled && (Ve(t), H && K && Le && !E && !z && Le(t ? [...K, H] : K.filter((e) => e !== H), n));
		},
		onFocus() {
			q.current?.focus();
		}
	}, A === void 0 ? i : { value: (L ? Z && A : A) || "" }, I, L ? X.getValidationProps : X.getInputValidationProps), Ge = z ? !!Pe : Z, Ke = z && G || x;
	g.useEffect(() => {
		if (!R || !H) return;
		let e = R.disabledStatesRef.current;
		return e.set(H, B), () => {
			e.delete(H);
		};
	}, [
		R,
		B,
		H
	]);
	let $ = g.useMemo(() => ({
		...P,
		checked: Ge,
		disabled: B,
		readOnly: D,
		required: O,
		indeterminate: Ke
	}), [
		P,
		Ge,
		B,
		D,
		O,
		Ke
	]), qe = b($), Je = ee("span", s, {
		state: $,
		ref: [
			Be,
			q,
			ne,
			L?.registerControlRef
		],
		props: [
			{
				id: j ? U ?? void 0 : Me,
				role: "checkbox",
				"aria-checked": G ? "mixed" : Z,
				"aria-readonly": D || void 0,
				"aria-required": O || void 0,
				"aria-labelledby": Ue,
				[ge]: E ? "" : void 0,
				onFocus() {
					N(!0);
				},
				onBlur() {
					let e = Q.current;
					e && (we(!0), N(!1), Te === "onBlur" && X.commit(L ? K : e.checked));
				},
				onKeyDown(e) {
					if (e.key !== "Enter" || (e.preventBaseUIHandler(), e.defaultPrevented)) return;
					let t = Q.current?.form ?? null, n = e.currentTarget, r = e.nativeEvent, i = e.preventDefault, a = r.preventDefault, o = !1;
					e.preventDefault = () => {
						o = !0, i.call(e);
					}, r.preventDefault = () => {
						o = !0, a.call(r);
					}, a.call(r), u(n).queueMicrotask(() => {
						e.preventDefault = i, r.preventDefault = a, o || me(t)?.click();
					});
				},
				onClick(e) {
					if (D || B) return;
					e.preventDefault();
					let t = Q.current;
					t && t.dispatchEvent(new (u(t)).PointerEvent("click", {
						bubbles: !0,
						shiftKey: e.shiftKey,
						ctrlKey: e.ctrlKey,
						altKey: e.altKey,
						metaKey: e.metaKey
					}));
				}
			},
			I,
			X.getValidationProps,
			ye,
			Ie,
			ze
		],
		stateAttributesMapping: qe
	});
	return /*#__PURE__*/ fe(S.Provider, {
		value: $,
		children: [
			Je,
			!Z && !L && V && !E && k !== void 0 && /*#__PURE__*/ _("input", {
				type: "hidden",
				form: v,
				name: V,
				value: k
			}),
			/*#__PURE__*/ _("input", {
				...We,
				suppressHydrationWarning: !0
			})
		]
	});
});
process.env.NODE_ENV !== "production" && (w.displayName = "CheckboxRoot");
//#endregion
//#region ../../node_modules/.bun/@base-ui+react@1.5.0+f4ada88178b00e6f/node_modules/@base-ui/react/esm/checkbox/indicator/CheckboxIndicator.js
var T = /*#__PURE__*/ g.forwardRef(function(e, t) {
	let { render: n, className: r, style: i, keepMounted: a = !1, ...o } = e, s = C(), c = s.checked || s.indeterminate, { mounted: te, transitionStatus: l, setMounted: u } = re(c), d = g.useRef(null), f = {
		...s,
		transitionStatus: l
	};
	ie({
		open: c,
		ref: d,
		onComplete() {
			c || u(!1);
		}
	});
	let p = {
		...b(s),
		...ne,
		...h
	}, m = a || te, ae = ee("span", e, {
		ref: [t, d],
		state: f,
		stateAttributesMapping: p,
		props: o
	});
	return m ? ae : null;
});
process.env.NODE_ENV !== "production" && (T.displayName = "CheckboxIndicator");
//#endregion
//#region lib/components/ui/atoms/checkbox.tsx
function E({ className: e, indeterminate: t, ...n }) {
	return /* @__PURE__ */ _(w, {
		className: f("peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input outline-none transition-colors after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 group-has-disabled/field:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary data-disabled:data-checked:border-muted-foreground data-disabled:data-indeterminate:border-muted-foreground data-disabled:data-checked:bg-muted-foreground data-disabled:data-indeterminate:bg-muted-foreground data-disabled:cursor-not-allowed data-checked:border-primary data-indeterminate:border-primary data-checked:bg-primary data-indeterminate:bg-primary data-checked:text-primary-foreground data-indeterminate:text-primary-foreground data-disabled:opacity-50 dark:bg-input/30 dark:data-disabled:data-checked:bg-muted-foreground dark:data-disabled:data-indeterminate:bg-muted-foreground dark:data-checked:bg-primary dark:data-indeterminate:bg-primary dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40", e),
		"data-slot": "checkbox",
		indeterminate: t,
		...n,
		children: /* @__PURE__ */ _(T, {
			className: "grid place-content-center text-current transition-none [&>svg]:size-3.5",
			"data-slot": "checkbox-indicator",
			children: _(t ? v : pe, {})
		})
	});
}
//#endregion
export { E as t };
