"use client";
import { composeRefs } from "../../utils/compose-refs.js";
import { ark } from "../factory.js";
import { useFieldContext } from "./use-field-context.js";
import { forwardRef, useEffect, useRef } from "react";
import { mergeProps } from "@zag-js/react";
import { jsx } from "react/jsx-runtime";
import { autoresizeTextarea } from "@zag-js/auto-resize";
//#region src/components/field/field-textarea.tsx
var FieldTextarea = forwardRef((props, ref) => {
	const { autoresize, ...textareaProps } = props;
	const textareaRef = useRef(null);
	const mergedProps = mergeProps(useFieldContext()?.getTextareaProps(), { style: { resize: autoresize ? "none" : void 0 } }, textareaProps);
	useEffect(() => {
		if (!autoresize) return;
		return autoresizeTextarea(textareaRef.current);
	}, [autoresize]);
	return /* @__PURE__ */ jsx(ark.textarea, {
		...mergedProps,
		ref: composeRefs(ref, textareaRef)
	});
});
FieldTextarea.displayName = "FieldTextarea";
//#endregion
export { FieldTextarea };
