import e from"../_util/classNames.mjs";import t from"../_util/omit.mjs";import{useInjectDisabled as n}from"../config-provider/DisabledContext.mjs";import r from"../config-provider/hooks/useConfigInject.mjs";import{getMergedStatus as i,getStatusClassNames as a}from"../_util/statusUtils.mjs";import{FormItemInputContext as o,NoFormStatus as s,useInjectFormItemContext as c}from"../form/FormItemContext.mjs";import{NoCompactStyle as l,useCompactItemContext as u}from"../space/Compact.mjs";import d from"./style/index.mjs";import{hasPrefixSuffix as f}from"../vc-input/utils/commonUtils.mjs";import p from"../vc-input/Input.mjs";import m from"./inputProps.mjs";import{Fragment as h,computed as g,createVNode as _,defineComponent as v,onBeforeUnmount as y,onBeforeUpdate as b,onMounted as x,ref as S}from"vue";import{CloseCircleFilled as C}from"@antsoo-lib/icons";var w=v({compatConfig:{MODE:3},name:`AInput`,inheritAttrs:!1,props:m(),setup(m,{slots:v,attrs:w,expose:T,emit:E}){let D=S(),O=c(),k=o.useInject(),A=g(()=>i(k.status,m.status)),{direction:j,prefixCls:M,size:N,autocomplete:P}=r(`input`,m),{compactSize:F,compactItemClassnames:I}=u(M,j),L=g(()=>F.value||N.value),[R,z]=d(M),B=n();T({focus:e=>{D.value?.focus(e)},blur:()=>{D.value?.blur()},input:D,setSelectionRange:(e,t,n)=>{D.value?.setSelectionRange(e,t,n)},select:()=>{D.value?.select()}});let V=S([]),H=()=>{V.value.push(setTimeout(()=>{D.value?.input&&D.value?.input.getAttribute(`type`)===`password`&&D.value?.input.hasAttribute(`value`)&&D.value?.input.removeAttribute(`value`)}))};x(()=>{H()}),b(()=>{V.value.forEach(e=>clearTimeout(e))}),y(()=>{V.value.forEach(e=>clearTimeout(e))});let U=e=>{H(),E(`blur`,e),O.onFieldBlur()},W=e=>{H(),E(`focus`,e)},G=e=>{E(`update:value`,e.target.value),E(`change`,e),E(`input`,e),O.onFieldChange()};return()=>{let{hasFeedback:n,feedbackIcon:r}=k,{allowClear:i,bordered:o=!0,prefix:c=v.prefix?.(),suffix:u=v.suffix?.(),addonAfter:d=v.addonAfter?.(),addonBefore:g=v.addonBefore?.(),id:y=O.id?.value,...b}=m,x=(n||u)&&_(h,null,[u,n&&r]),S=M.value,T=f({prefix:c,suffix:u})||!!n,E=v.clearIcon||(()=>_(C,null,null));return R(_(p,{...w,...t(b,[`onUpdate:value`,`onChange`,`onInput`]),onChange:G,id:y,disabled:m.disabled??B.value,ref:D,prefixCls:S,autocomplete:P.value,onBlur:U,onFocus:W,prefix:c,suffix:x,allowClear:i,addonAfter:d&&_(l,null,{default:()=>[_(s,null,{default:()=>[d]})]}),addonBefore:g&&_(l,null,{default:()=>[_(s,null,{default:()=>[g]})]}),class:[w.class,I.value],inputClassName:e({[`${S}-sm`]:L.value===`small`,[`${S}-lg`]:L.value===`large`,[`${S}-rtl`]:j.value===`rtl`,[`${S}-borderless`]:!o},!T&&a(S,A.value),z.value),affixWrapperClassName:e({[`${S}-affix-wrapper-sm`]:L.value===`small`,[`${S}-affix-wrapper-lg`]:L.value===`large`,[`${S}-affix-wrapper-rtl`]:j.value===`rtl`,[`${S}-affix-wrapper-borderless`]:!o},a(`${S}-affix-wrapper`,A.value,n),z.value),wrapperClassName:e({[`${S}-group-rtl`]:j.value===`rtl`},z.value),groupClassName:e({[`${S}-group-wrapper-sm`]:L.value===`small`,[`${S}-group-wrapper-lg`]:L.value===`large`,[`${S}-group-wrapper-rtl`]:j.value===`rtl`},a(`${S}-group-wrapper`,A.value,n),z.value)},{...v,clearIcon:E}))}}});export{w as default};