import{A as D,b as a,Y as U,N as H,dG as W,E as K,j,c as l,aH as q,by as A,db as N,as as O,dL as _}from"./index.BdH_oWMm.js";import{I as w}from"./InputInstructions.DGHznNow.js";import{W as G}from"./WidgetLabel.ZStEr2fI.js";import{W as Y}from"./WidgetLabelHelpIcon.CochPswC.js";import{a as $}from"./useBasicWidgetState.U_bd_Q53.js";import{u as J,a as M,b as Q}from"./useUpdateUiValue.6fG_KG41.js";import{I as X}from"./input.BCPzSWog.js";import"./styled-components.jdcyFPSS.js";import"./FormClearHelper.B3vyDvH9.js";import"./inputUtils.CptNuJwn.js";import"./base-input.Dg8TnJbw.js";import"./constants.Bk9yhl7Y.js";const Z=D("div",{target:"eiqkja70"})("position:relative;");function tt({disabled:o,element:t,widgetMgr:r,fragmentId:u}){const[i,p]=a.useState(()=>I(r,t)??null),{width:S,elementRef:T}=U(),[s,m]=a.useState(!1),C=a.useCallback(()=>{p(t.default??null),m(!0)},[t.default]),x=t.queryParamKey?{paramKey:t.queryParamKey,valueType:"string_value",clearable:!0}:void 0,[v,h]=$({getStateFromWidgetMgr:I,getDefaultStateFromProto:et,getCurrStateFromProto:ot,updateWidgetMgrState:at,element:t,widgetMgr:r,fragmentId:u,formClearBehavior:"resetValueAndRunCallback",onFormCleared:C,queryParamBinding:x});J(v,i,p,s);const[V,b]=a.useState(!1),e=H(),f=a.useId(),{placeholder:E,formId:n,icon:d,maxChars:y}=t,g=a.useCallback(()=>{m(!1),h({value:i,fromUi:!0})},[i,h]),F=W({formId:n})?r.allowFormEnterToSubmit(n):s,R=V&&S>K(e.breakpoints.hideWidgetDetails),L=a.useCallback(()=>{s&&g(),b(!1)},[s,g]),P=a.useCallback(()=>{b(!0)},[]),B=M({formId:n,maxChars:y,setDirty:m,setUiValue:p,setValueWithSource:h}),k=Q(n,g,s,r,u);return j(Z,{className:"stTextInput","data-testid":"stTextInput",ref:T,children:[l(G,{label:t.label,disabled:o,labelVisibility:q(t.labelVisibility?.value),htmlFor:f,children:t.help&&l(Y,{content:t.help,label:t.label})}),l(X,{value:i??"",placeholder:E,onBlur:L,onFocus:P,onChange:B,onKeyPress:k,"aria-label":t.label,disabled:o,id:f,type:rt(t),autoComplete:t.autocomplete,startEnhancer:d&&l(O,{"data-testid":"stTextInputIcon",iconValue:d,size:"lg"}),overrides:{Input:{style:{fontWeight:e.fontWeights.normal,minWidth:0,lineHeight:e.lineHeights.inputWidget,paddingRight:e.spacing.sm,paddingLeft:e.spacing.md,paddingBottom:e.spacing.sm,paddingTop:e.spacing.sm,"::placeholder":{color:e.colors.fadedText60}}},Root:{props:{"data-testid":"stTextInputRootElement"},style:({$isFocused:z})=>{const c=N(e.colors,z);return{height:e.sizes.minElementHeight,borderLeftWidth:e.sizes.borderWidth,borderRightWidth:e.sizes.borderWidth,borderTopWidth:e.sizes.borderWidth,borderBottomWidth:e.sizes.borderWidth,borderTopColor:c,borderRightColor:c,borderBottomColor:c,borderLeftColor:c,paddingLeft:d?e.spacing.sm:0}}},StartEnhancer:{style:{paddingLeft:0,paddingRight:0,minWidth:e.iconSizes.lg,color:A(d)?e.colors.fadedText60:"inherit"}}}}),R&&l(w,{dirty:s,value:i??"",maxLength:y,inForm:W({formId:n}),allowEnterToSubmit:F})]})}function I(o,t){return o.getStringValue(t)??null}function et(o){return o.default??null}function ot(o){return o.value??null}function at(o,t,r,u){t.setStringValue(o,r.value,{fromUi:r.fromUi},u)}function rt(o){return o.type===_.Type.PASSWORD?"password":"text"}const ft=a.memo(tt);export{ft as default};
