import e from"../_util/classNames.mjs";import t from"../_util/omit.mjs";import{isValidElement as n}from"../_util/props-util/index.mjs";import r from"../config-provider/hooks/useConfigInject.mjs";import{cloneElement as i}from"../_util/vnode.mjs";import a from"./inputProps.mjs";import o from"./Input.mjs";import{computed as s,createVNode as c,defineComponent as l,shallowRef as u,watchEffect as d}from"vue";import{EyeInvisibleOutlined as f,EyeOutlined as p}from"@antsoo-lib/icons";var m={click:`onClick`,hover:`onMouseover`},h=e=>c(e?p:f,null,null),g=l({compatConfig:{MODE:3},name:`AInputPassword`,inheritAttrs:!1,props:{...a(),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(a,{slots:l,attrs:f,expose:p,emit:g}){let _=u(!1),v=()=>{let{disabled:e}=a;e||(_.value=!_.value,g(`update:visible`,_.value))};d(()=>{a.visible!==void 0&&(_.value=!!a.visible)});let y=u();p({focus:()=>{y.value?.focus()},blur:()=>{y.value?.blur()}});let b=e=>{let{action:t,iconRender:r=l.iconRender||h}=a,o=m[t]||``,s=r(_.value),u={[o]:v,class:`${e}-icon`,key:`passwordIcon`,onMousedown:e=>{e.preventDefault()},onMouseup:e=>{e.preventDefault()}};return i(n(s)?s:c(`span`,null,[s]),u)},{prefixCls:x,getPrefixCls:S}=r(`input-password`,a),C=s(()=>S(`input`,a.inputPrefixCls)),w=()=>{let{size:n,visibilityToggle:r,...i}=a,s=r&&b(x.value),u=e(x.value,f.class,{[`${x.value}-${n}`]:!!n}),d={...t(i,[`suffix`,`iconRender`,`action`]),...f,type:_.value?`text`:`password`,class:u,prefixCls:C.value,suffix:s};return n&&(d.size=n),c(o,{ref:y,...d},l)};return()=>w()}});export{g as default};