var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React, { forwardRef, useRef, useId } from "react";
import { cn } from "@utils";
import { textareaVariants, containerVariants, helperTextVariants } from "./textareaVariants";
/**
 * Textarea component for multiline text input fields.
 */
export const Textarea = forwardRef((_a, ref) => {
    var { label, helperText, error = false, infoText, className } = _a, restProps = __rest(_a, ["label", "helperText", "error", "infoText", "className"]);
    const { id, disabled } = restProps, rest = __rest(restProps, ["id", "disabled"]);
    const inputId = useRef(useId());
    // Determine the state based on disabled and error props
    const state = disabled ? "disabled" : error ? "error" : "default";
    return (_jsxs("div", { className: cn("inline-flex flex-col gap-2", className), children: [label && (_jsx("label", { htmlFor: id || inputId.current, className: "text-base text-secondary-400 font-medium", children: label })), _jsxs("div", { className: containerVariants({ state }), children: [_jsx("textarea", Object.assign({ className: cn(textareaVariants({ state }), typeof infoText === "undefined" && "pb-3 rounded-b"), rows: 3, disabled: disabled, id: id || inputId.current, ref: ref }, rest)), typeof infoText !== "undefined" && (_jsx("div", { className: "text-xxs text-secondary-400 self-end px-4 py-3", children: infoText }))] }), typeof helperText !== "undefined" && (_jsx("div", { className: helperTextVariants({ state: error ? "error" : "default" }), children: helperText }))] }));
});
Textarea.displayName = "Textarea";
//# sourceMappingURL=textarea.js.map