'use client';

import { useFormField } from "../FormField.mjs";
import { FormItemLayout } from "../layout/FormItemLayout.mjs";
import { SwitchSelector } from "../../SwitchSelector/index.mjs";
import { Form } from "../Form.mjs";
import { jsx } from "react/jsx-runtime";
import { useFormContext } from "react-hook-form";

//#region src/components/Form/elements/SwitchSelectorElement.tsx
const SwitchSelectorFieldContent = ({ field, name, label, description, isRequired, info, showErrorMessage, children, ...props }) => {
	const { error } = useFormField();
	return /* @__PURE__ */ jsx(FormItemLayout, {
		htmlFor: name,
		label,
		description,
		isRequired,
		info,
		showErrorMessage,
		"aria-invalid": !!error,
		children: /* @__PURE__ */ jsx(SwitchSelector, {
			...field,
			...props,
			children
		})
	});
};
const SwitchSelectorElement = ({ name, description, label, isRequired, info, showErrorMessage, children, ...props }) => {
	const { control } = useFormContext();
	return /* @__PURE__ */ jsx(Form.Field, {
		control,
		name,
		render: ({ field }) => /* @__PURE__ */ jsx(SwitchSelectorFieldContent, {
			field,
			name,
			label,
			description,
			isRequired,
			info,
			showErrorMessage,
			...props,
			children
		})
	});
};

//#endregion
export { SwitchSelectorElement };
//# sourceMappingURL=SwitchSelectorElement.mjs.map