"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/jsx-runtime.js"),i=require("react"),k=require("../../../icons/AlertTriangle.js"),w=require("../../../utils/index.js"),t=require("../styles.js"),O=require("../utils.js"),W=require("./styles.js");function _({autoComplete:m=!1,disabled:s=!1,label:r,id:h,name:a,placeholder:R,required:q=!0,showCharCount:f=!1,width:v,maxChar:l,minChar:y,hasError:o=!1,errorText:g,touched:u,assistText:x,optionalText:A="Optional",variant:C,onChange:L,onKeyUp:S,onBlur:T,onFocus:B,value:n,...c}){const[I,E]=i.useState(0),[p,M]=i.useState(!1);i.useEffect(()=>{n&&typeof n=="string"&&E(n.length)},[]),i.useEffect(()=>{M(typeof u>"u"?o:o&&u)},[o,u]);function $(d){E(d.target.value.length),L(d)}const j=w.getId(c["data-testid"]);return e.jsxRuntimeExports.jsxs(t.Wrapper,{"data-testid":j("text-area"),width:v,children:[e.jsxRuntimeExports.jsxs(t.LabelWrapper,{disabled:s,hasLabel:!!(r!=null&&r.length),children:[r&&e.jsxRuntimeExports.jsx(t.Label,{htmlFor:h||`input-${a}`,disabled:s,children:r}),!q&&!f&&e.jsxRuntimeExports.jsx(t.Text,{children:A}),f&&e.jsxRuntimeExports.jsx(t.Text,{"data-testid":j("character-count"),children:O.getCharacterCount(I,l)})]}),e.jsxRuntimeExports.jsx(t.Border,{hasError:p,disabled:s,children:e.jsxRuntimeExports.jsx(W.TextAreaInput,{id:h||`input-${a}`,name:a,placeholder:R,variant:C,autoComplete:m?"on":"off",disabled:s,maxLength:l,minLength:y,value:String(n),onChange:$,onKeyUp:S,onBlur:T,onFocus:B,"data-testid":j(),"data-trackid":c["data-trackid"],"aria-label":c["aria-label"]||r})}),e.jsxRuntimeExports.jsxs(t.SupportingText,{children:[!!g&&p&&!s&&e.jsxRuntimeExports.jsxs(t.ErrorMessage,{children:[e.jsxRuntimeExports.jsx(k.default,{width:20,height:20}),g]}),!p&&(typeof x=="string"?e.jsxRuntimeExports.jsx(t.AssistMessage,{children:x}):x)]})]})}exports.TextArea=_;
