import{defineComponent as P,ref as D,createVNode as a}from"vue";import m from"../_util/classNames.mjs";import{cloneElement as N}from"../_util/vnode.mjs";import{baseInputProps as E}from"./inputProps.mjs";import{hasPrefixSuffix as R,hasAddon as g}from"./utils/commonUtils.mjs";const j=P({name:"BaseInput",inheritAttrs:!1,props:E(),setup(x,{slots:t,attrs:c}){const y=D(),I=f=>{if(y.value?.contains(f.target)){const{triggerFocus:r}=x;r?.()}},v=()=>{const{allowClear:f,value:r,disabled:C,readonly:i,handleReset:$,suffix:d=t.suffix,prefixCls:e}=x;if(!f)return null;const p=!C&&!i&&r,n=`${e}-clear-icon`,o=t.clearIcon?.()||"*";return a("span",{onClick:$,onMousedown:l=>l.preventDefault(),class:m({[`${n}-hidden`]:!p,[`${n}-has-suffix`]:!!d},n),role:"button",tabindex:-1},[o])};return()=>{const{focused:f,value:r,disabled:C,allowClear:i,readonly:$,hidden:d,prefixCls:e,prefix:p=t.prefix?.(),suffix:n=t.suffix?.(),addonAfter:o=t.addonAfter,addonBefore:l=t.addonBefore,inputElement:b,affixWrapperClassName:A,wrapperClassName:B,groupClassName:W}=x;let h=N(b,{value:r,hidden:d});if(R({prefix:p,suffix:n,allowClear:i})){const s=`${e}-affix-wrapper`,u=m(s,{[`${s}-disabled`]:C,[`${s}-focused`]:f,[`${s}-readonly`]:$,[`${s}-input-with-clear-btn`]:n&&i&&r},!g({addonAfter:o,addonBefore:l})&&c.class,A),w=(n||i)&&a("span",{class:`${e}-suffix`},[v(),n]);h=a("span",{class:u,style:c.style,hidden:!g({addonAfter:o,addonBefore:l})&&d,onMousedown:I,ref:y},[p&&a("span",{class:`${e}-prefix`},[p]),N(b,{style:null,value:r,hidden:null}),w])}if(g({addonAfter:o,addonBefore:l})){const s=`${e}-group`,u=`${s}-addon`,w=m(`${e}-wrapper`,s,B),M=m(`${e}-group-wrapper`,c.class,W);return a("span",{class:M,style:c.style,hidden:d},[a("span",{class:w},[l&&a("span",{class:u},[l]),N(h,{style:null,hidden:null}),o&&a("span",{class:u},[o])])])}return h}}});export{j as default};
