"use strict";const d=require("react/jsx-runtime"),l=require("react"),x=require("@chakra-ui/react"),P=require("@chakra-ui/react/styled-system"),f=require("./utils-BNYGVv6l.cjs.js"),H=require("./useHover-BCGp55jR.cjs.js"),I=require("./useFocusRing-DScmIOhv.cjs.js"),R=require("./mergeProps-DD8aR8go.cjs.js"),T=require("./extract-style-props-DVhOcGEi.cjs.js"),q=require("./index-Dzrt5_tw.cjs.js"),S=require("./useObjectRef-4v2MxSjQ.cjs.js"),y=require("./useTextField-xUsOzG8r.cjs.js"),F=l.createContext({});let w=s=>{let{onHoverStart:t,onHoverChange:n,onHoverEnd:r,...e}=s;return e};const C=l.forwardRef(function(t,n){[t,n]=f.$64fa3d84918910a7$export$29f1550f4b0d4415(t,n,F);let{hoverProps:r,isHovered:e}=H.$6179b936705e76d3$export$ae780daf29e6d456(t),{isFocused:i,isFocusVisible:c,focusProps:a}=I.$f7dceffc5ad7768b$export$4e328f61c538687f({isTextInput:!0,autoFocus:t.autoFocus}),o=!!t["aria-invalid"]&&t["aria-invalid"]!=="false",u=f.$64fa3d84918910a7$export$4d86445c2cf5e3({...t,values:{isHovered:e,isFocused:i,isFocusVisible:c,isDisabled:t.disabled||!1,isInvalid:o},defaultClassName:"react-aria-TextArea"});return l.createElement("textarea",{...R.$3ef42575df84b30b$export$9d1611c77c2fe928(w(t),a,r),...u,ref:n,"data-focused":i||void 0,"data-disabled":t.disabled||void 0,"data-hovered":e||void 0,"data-focus-visible":c||void 0,"data-invalid":o||void 0})}),{withContext:$,withProvider:E}=x.createSlotRecipeContext({key:"nimbusMultilineTextInput"}),j=E("div","root"),M=$("div","leadingElement"),N=$("textarea","textarea");function V(s,t={}){const{enabled:n=!1}=t,r=l.useCallback(()=>{const e=s.current;if(!e||!n)return;e.style.height="auto";const i=e.scrollHeight,c=window.getComputedStyle(e),a=parseInt(c.maxHeight,10),o=!isNaN(a)&&a>0?Math.min(i,a):i;e.style.height=`${o}px`},[n]);l.useEffect(()=>{const e=s.current;if(!e||!n)return;r();const i=()=>{r()};return e.addEventListener("input",i),()=>{e.removeEventListener("input",i)}},[r,n])}const p=s=>{const{ref:t,leadingElement:n,rows:r=1,autoGrow:e=!1,...i}=s,c=P.useRecipe({recipe:q.multilineTextInputRecipe}),a=l.useRef(null),o=S.$df56164dff5785e2$export$4338b53315abf666(x.mergeRefs(a,t)),[u,v]=c.splitVariantProps(i),[b,h]=T.extractStyleProps(v),{inputProps:m}=y.$2d73ec29415bd339$export$712718f7aec83d5(h,o);V(o,{enabled:e});const g={"data-disabled":i.isDisabled?"true":void 0,"data-invalid":i.isInvalid?"true":"false"};return d.jsx(j,{className:s?.className,...u,...b,...g,children:d.jsxs(d.Fragment,{children:[n&&d.jsx(M,{children:n}),d.jsx(N,{asChild:!0,children:d.jsx(C,{ref:o,rows:r,...m})})]})})};p.displayName="MultilineTextInput";exports.MultilineTextInput=p;
//# sourceMappingURL=multiline-text-input-COs7r-ny.cjs.js.map
