import { cn } from "./index3.js";
import { FieldTooltip } from "./index19.js";
import { hasFieldProps, splitFieldProps } from "./index20.js";
import { Field, FieldBottom, FieldBottomRight, FieldControl, FieldDescription, FieldError, FieldLabel, FieldTop, FieldTopRight } from "./index22.js";
import { stateClasses as stateClasses$1 } from "./index29.js";
import { textareaBaseStyles } from "./index39.js";
import * as React from "react";
import { jsx, jsxs } from "react/jsx-runtime";
//#region src/components/atoms/forms/Textarea/Textarea.tsx
var stateClasses = stateClasses$1;
var TextareaControl = React.forwardRef(({ state = "default", startIcon, endIcon, hasOutline, className, ...props }, ref) => {
	const hasStartIcon = !!startIcon;
	const hasEndIcon = !!endIcon;
	const hasIcons = hasStartIcon || hasEndIcon;
	const textareaStyles = cn(textareaBaseStyles, stateClasses[state], hasOutline && "border-border ring-1 ring-border focus-visible:ring-2 focus-visible:ring-ring", hasStartIcon && "ps-10", hasEndIcon && "pe-10");
	if (!hasIcons) return /* @__PURE__ */ jsx("textarea", {
		ref,
		"data-slot": "textarea",
		"data-state": state,
		"aria-invalid": state === "destructive" || void 0,
		className: cn(textareaStyles, className),
		...props
	});
	return /* @__PURE__ */ jsxs("div", {
		"data-slot": "textarea-wrapper",
		className: cn("group/textarea relative", className),
		children: [
			hasStartIcon && /* @__PURE__ */ jsx("span", {
				"aria-hidden": "true",
				className: "absolute start-3 top-2.5 text-quaternary-foreground pointer-events-none transition-colors duration-200 ease-out motion-reduce:transition-none [&>svg]:size-5 group-focus-within/textarea:text-muted-foreground",
				children: startIcon
			}),
			/* @__PURE__ */ jsx("textarea", {
				ref,
				"data-slot": "textarea",
				"data-state": state,
				"aria-invalid": state === "destructive" || void 0,
				className: textareaStyles,
				...props
			}),
			hasEndIcon && /* @__PURE__ */ jsx("span", {
				"aria-hidden": "true",
				className: "absolute end-3 top-2.5 text-quaternary-foreground pointer-events-none transition-colors duration-200 ease-out motion-reduce:transition-none [&>svg]:size-5 group-focus-within/textarea:text-muted-foreground",
				children: endIcon
			})
		]
	});
});
TextareaControl.displayName = "TextareaControl";
var Textarea = React.forwardRef((props, ref) => {
	const [fieldPropsObj, controlProps] = splitFieldProps(props);
	if (!hasFieldProps(fieldPropsObj)) return /* @__PURE__ */ jsx(TextareaControl, {
		ref,
		...controlProps,
		required: fieldPropsObj.required
	});
	const { label, required, labelIcon, tooltip, topRight, description, bottomRight, error, fieldClassName } = fieldPropsObj;
	const cp = controlProps;
	const resolvedState = error ? "destructive" : cp.state;
	const hasTopRow = label || topRight;
	const hasBottomRow = description || bottomRight || error;
	return /* @__PURE__ */ jsxs(Field, {
		state: resolvedState,
		disabled: cp.disabled,
		className: fieldClassName,
		children: [
			hasTopRow && /* @__PURE__ */ jsxs(FieldTop, { children: [label && /* @__PURE__ */ jsxs(FieldLabel, {
				required,
				labelIcon,
				children: [label, tooltip && /* @__PURE__ */ jsx(FieldTooltip, { content: tooltip })]
			}), topRight && /* @__PURE__ */ jsx(FieldTopRight, { children: topRight })] }),
			/* @__PURE__ */ jsx(FieldControl, { children: (ctrlProps) => /* @__PURE__ */ jsx(TextareaControl, {
				ref,
				...cp,
				...ctrlProps,
				required,
				state: resolvedState
			}) }),
			hasBottomRow && /* @__PURE__ */ jsxs(FieldBottom, { children: [
				error && /* @__PURE__ */ jsx(FieldError, { children: error }),
				!error && description && /* @__PURE__ */ jsx(FieldDescription, { children: description }),
				bottomRight && /* @__PURE__ */ jsx(FieldBottomRight, {
					className: "ms-auto",
					children: bottomRight
				})
			] })
		]
	});
});
Textarea.displayName = "Textarea";
//#endregion
export { Textarea };

//# sourceMappingURL=index40.js.map