import{defineComponent as y,shallowRef as m,watchEffect as I,computed as R,createVNode as s}from"vue";import E from"@ant-design/icons-vue/EyeInvisibleOutlined";import h from"@ant-design/icons-vue/EyeOutlined";import M from"../_util/classNames.mjs";import k from"../_util/omit.mjs";import{isValidElement as A}from"../_util/props-util/index.mjs";import{cloneElement as D}from"../_util/vnode.mjs";import N from"../config-provider/hooks/useConfigInject.mjs";import O from"./Input.mjs";import S from"./inputProps.mjs";const T={click:"onClick",hover:"onMouseover"},V=e=>e?s(h,null,null):s(E,null,null),Q=y({compatConfig:{MODE:3},name:"AInputPassword",inheritAttrs:!1,props:{...S(),prefixCls:String,inputPrefixCls:String,action:{type:String,default:"click"},visibilityToggle:{type:Boolean,default:!0},visible:{type:Boolean,default:void 0},"onUpdate:visible":Function,iconRender:Function},setup(e,{slots:p,attrs:d,expose:v,emit:b}){const o=m(!1),g=()=>{const{disabled:n}=e;n||(o.value=!o.value,b("update:visible",o.value))};I(()=>{e.visible!==void 0&&(o.value=!!e.visible)});const l=m();v({focus:()=>{l.value?.focus()},blur:()=>{l.value?.blur()}});const C=n=>{const{action:u,iconRender:c=p.iconRender||V}=e,a=T[u]||"",t=c(o.value),i={[a]:g,class:`${n}-icon`,key:"passwordIcon",onMousedown:f=>{f.preventDefault()},onMouseup:f=>{f.preventDefault()}};return D(A(t)?t:s("span",null,[t]),i)},{prefixCls:r,getPrefixCls:x}=N("input-password",e),P=R(()=>x("input",e.inputPrefixCls)),w=()=>{const{size:n,visibilityToggle:u,...c}=e,a=u&&C(r.value),t=M(r.value,d.class,{[`${r.value}-${n}`]:!!n}),i={...k(c,["suffix","iconRender","action"]),...d,type:o.value?"text":"password",class:t,prefixCls:P.value,suffix:a};return n&&(i.size=n),s(O,{ref:l,...i},p)};return()=>w()}});export{Q as default};
