import { cn } from "./cva.js";
import { useFieldControl } from "./Field.js";
import * as React from "react";
import { cva } from "class-variance-authority";
import { jsx } from "react/jsx-runtime";
//#region src/Textarea.tsx
const textareaVariants = cva("w-full border border-border bg-surface text-fg rounded-md focus-visible:outline focus-visible:outline-accent disabled:opacity-50 disabled:cursor-not-allowed px-3 py-2 text-base", {
	variants: { invalid: {
		true: "border-danger",
		false: ""
	} },
	defaultVariants: { invalid: false }
});
const Textarea = React.forwardRef(({ className, invalid, id, "aria-invalid": ariaInvalid, "aria-describedby": ariaDescribedBy, ...props }, ref) => {
	const field = useFieldControl();
	const resolvedInvalid = invalid ?? field?.invalid ?? false;
	return /* @__PURE__ */ jsx("textarea", {
		ref,
		id: id ?? field?.id,
		"aria-invalid": ariaInvalid ?? (resolvedInvalid ? true : void 0),
		"aria-describedby": ariaDescribedBy ?? field?.describedBy,
		"aria-required": props.required ?? field?.required,
		className: cn(textareaVariants({ invalid: resolvedInvalid }), className),
		...props
	});
});
Textarea.displayName = "Textarea";
//#endregion
export { Textarea };
