import { t as e } from "../chunks/ui.module-BisoTevy.js";
import { useId as t } from "react";
import { cn as n } from "@ryuzaki13/react-foundation-lib/utils";
import { BanIcon as r, CheckCircle2Icon as i } from "lucide-react";
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
var c = {
	switchWrapper: "Or5LYA",
	switch: "qge3io",
	iconWrapper: "w0AMfA",
	auto: "P1x4lq",
	checked: "-ZVOZo"
};
//#endregion
//#region src/switch/Switch.tsx
function l(l) {
	let { label: u, description: d, disabled: f, checkedIcon: p = /* @__PURE__ */ o(i, {}), uncheckedIcon: m = /* @__PURE__ */ o(r, {}), className: h, type: g, id: _, size: v, placeholder: y, onChange: b, value: x, triState: S, ...C } = l, w = t(), T = _ ?? w, E = d ? `${T}-description` : void 0, D = u ? `${T}-label` : void 0, O = () => {
		if (!l.triState) {
			l.onChange(!l.value);
			return;
		}
		if (l.value === void 0) {
			l.onChange(!0);
			return;
		}
		if (l.value === !0) {
			l.onChange(!1);
			return;
		}
		l.value === !1 && l.onChange(void 0);
	}, k = typeof l.value == "boolean" && l.value, A = l.triState && typeof l.value != "boolean", j = C["aria-label"] ?? (u ? void 0 : "Переключатель");
	return /* @__PURE__ */ s("div", {
		className: n(e.uiElement, f && e.disabled),
		"aria-disabled": f || void 0,
		children: [
			u && /* @__PURE__ */ s("div", {
				id: D,
				className: e.uiLabel,
				children: [u, ":"]
			}),
			d && /* @__PURE__ */ o("p", {
				id: E,
				className: e.uiDescription,
				children: d
			}),
			/* @__PURE__ */ o("button", {
				...C,
				id: T,
				type: g ?? "button",
				role: "switch",
				disabled: f,
				"aria-checked": k,
				"aria-describedby": E,
				"aria-labelledby": D,
				"aria-label": j,
				"aria-disabled": f,
				"data-ui": "switch",
				"data-action": "toggle-switch",
				onClick: O,
				className: n(e.uiInputControl, c.switchWrapper, h),
				children: /* @__PURE__ */ o("div", {
					className: c.switch,
					"data-disabled": f || void 0,
					children: A ? /* @__PURE__ */ o("div", {
						className: n(c.iconWrapper, c.auto, c.checked),
						children: "Auto"
					}) : /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o("div", {
						className: n(c.iconWrapper, !l.value && c.checked),
						children: m
					}), /* @__PURE__ */ o("div", {
						className: n(c.iconWrapper, l.value && c.checked),
						children: p
					})] })
				})
			})
		]
	});
}
//#endregion
export { l as Switch };

//# sourceMappingURL=index.js.map