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