import{jsx as t,jsxs as P}from"react/jsx-runtime";import{Children as z,cloneElement as q,isValidElement as Z,forwardRef as w,useRef as D}from"react";import{useTextField as E,useFocusRing as M,useHover as R,mergeProps as k}from"react-aria";import A from"../primitives/button.js";import"../primitives/checkbox.js";import"../primitives/dropdown-selector.js";import"../primitives/popover.js";import"../primitives/radio.js";import"../primitives/segmented-control.js";import"../primitives/switch.js";import p from"../primitives/text.js";import{cn as f}from"../../lib/cn.js";import{textInput as B}from"../../recipes/text-input.js";import{createSlot as m,createHost as _}from"create-slots";const H=m(({children:i,...s})=>t("div",{className:"flex items-center justify-center",children:z.map(i,e=>{var r;return q(e,{...s,color:(r=e.props.color)!==null&&r!==void 0?r:"var(--color-neutral-primary)"})})})),O=m(({children:i,...s})=>t("div",{className:"flex items-center justify-center",children:z.map(i,e=>{var r;return Z(e)?q(e,{...s,color:(r=e.props.color)!==null&&r!==void 0?r:"var(--color-brand-base)"}):null})})),S=m(A),V=m(p),W=m(p),$=w((i,s)=>{const{label:e,disabled:r,size:a="md",alignText:h="left",attr:x,description:n,autoFocus:g,className:v="",errorMessage:d,required:l}=i,u=a==="sm"?16:20,J=D(null),y=s||J,{labelProps:K,inputProps:L,descriptionProps:Q,errorMessageProps:U,isInvalid:I,validationErrors:j}=E({...i,isDisabled:r??!1,isInvalid:!!d},y),{focusProps:X}=M({autoFocus:g??!1}),{hoverProps:Y}=R({isDisabled:r??!1});return _(i.children,c=>{const N=c.get(H),b=c.get(O),C=c.getProps(S),T=c.getProps(V),F=c.getProps(W),o=B({size:a,alignText:h,disabled:r,isError:I});return P("div",{className:f(o.container,"flex flex-col gap-2.5",v),children:[e&&P("label",{className:o.label,...K,children:[e," ",l&&t("span",{className:"text-negative-darker",children:"*"})]}),P("div",{className:f(o.inputContainer,"flex flex-row items-center gap-2 group"),children:[N&&{...N,props:{...N.props,className:o.typeIcon,width:u,height:u}},T&&t(p,{...T,fontColor:"text.tertiary"}),t("input",{ref:y,className:o.input,...k(L,X,Y),...x}),F&&t(p,{...F,fontColor:"text.tertiary"}),b&&{...b,props:{...b.props,className:o.actionIcon,width:u,height:u}},C&&t("div",{className:f(o.actionButton,"flex items-center justify-center"),children:t(A,{...C,variant:"text",size:a})})]}),n&&t("div",{className:o.description,...Q,children:n}),I&&t(p,{variant:"error",...U,size:"sm",fontWeight:"normal",children:j.length>0?j.join(" "):d})]})})}),G=w((i,s)=>{const{disabled:e,autoFocus:r,className:a="",attr:h}=i,x=D(null),n=s||x,{inputProps:g}=E({...i,isDisabled:e??!1},n),{focusProps:v}=M({autoFocus:r??!1}),{hoverProps:d}=R({isDisabled:e??!1}),l=B({char:!0,disabled:e});return t("div",{className:f(l.container,l.inputContainer,a),children:t("input",{ref:n,className:l.input,...k(g,v,d),size:1,...h})})}),ee=Object.assign($,{TypeIcon:H,ActionIcon:O,ActionButton:S,Char:G,Prefix:V,Suffix:W});$.displayName="TextInput",G.displayName="TextInputChar";export{ee as TextInput};
//# sourceMappingURL=text-input.js.map
