import e from"../_util/warning.mjs";import t from"../_util/classNames.mjs";import n from"../_util/omit.mjs";import{flattenChildren as r,getOptionProps as i}from"../_util/props-util/index.mjs";import a from"../config-provider/hooks/useConfigInject.mjs";import o from"../_util/vue-types/index.mjs";import{getMergedStatus as s,getStatusClassNames as c}from"../_util/statusUtils.mjs";import{FormItemInputContext as l,useInjectFormItemContext as u}from"../form/FormItemContext.mjs";import{useProvideOverride as d}from"../menu/src/OverrideContext.mjs";import f from"../spin/index.mjs";import{mentionsProps as p}from"../vc-mentions/src/mentionsProps.mjs";import{optionOptions as m,optionProps as h}from"../vc-mentions/src/Option.mjs";import g from"../vc-mentions/index.mjs";import _ from"./style/index.mjs";import{computed as v,createVNode as y,defineComponent as b,shallowRef as x,watch as S}from"vue";function C(){return!0}var w=(e=``,t={})=>{let{prefix:n=`@`,split:r=` `}=t,i=Array.isArray(n)?n:[n];return e.split(r).map((e=``)=>{let t=null;return i.some(n=>e.slice(0,n.length)===n?(t=n,!0):!1),t===null?null:{prefix:t,value:e.slice(t.length)}}).filter(e=>!!e&&!!e.value)},T=()=>({...p,loading:{type:Boolean,default:void 0},onFocus:{type:Function},onBlur:{type:Function},onSelect:{type:Function},onChange:{type:Function},onPressenter:{type:Function},"onUpdate:value":{type:Function},notFoundContent:o.any,defaultValue:String,id:String,status:String}),E=b({compatConfig:{MODE:3},name:`AMentions`,inheritAttrs:!1,props:T(),slots:Object,setup(o,{slots:p,emit:m,attrs:h,expose:b}){let{prefixCls:w,renderEmpty:T,direction:E}=a(`mentions`,o),[D,O]=_(w),k=x(!1),A=x(null),j=x(o.value??o.defaultValue??``),M=u(),N=l.useInject(),P=v(()=>s(N.status,o.status));d({prefixCls:v(()=>`${w.value}-menu`),mode:v(()=>`vertical`),selectable:v(()=>!1),onClick:()=>{},validator:({mode:t})=>{e(!t||t===`vertical`,`Mentions`,`mode="${t}" is not supported for Mentions's Menu.`)}}),S(()=>o.value,e=>{j.value=e});let F=e=>{k.value=!0,m(`focus`,e)},I=e=>{k.value=!1,m(`blur`,e),M.onFieldBlur()},L=(...e)=>{m(`select`,...e),k.value=!0},R=e=>{o.value===void 0&&(j.value=e),m(`update:value`,e),m(`change`,e),M.onFieldChange()},z=()=>{let e=o.notFoundContent;return e===void 0?p.notFoundContent?p.notFoundContent():T(`Select`):e},B=()=>r(p.default?.()||[]).map(e=>({...i(e),label:e.children?.default?.()}));b({focus:()=>{A.value.focus()},blur:()=>{A.value.blur()}});let V=v(()=>o.loading?C:o.filterOption);return()=>{let{disabled:e,getPopupContainer:r,rows:i=1,id:a=M.id.value,...s}=o,{hasFeedback:l,feedbackIcon:u}=N,{class:d,...m}=h,_=n(s,[`defaultValue`,`onUpdate:value`,`prefixCls`]),v=t({[`${w.value}-disabled`]:e,[`${w.value}-focused`]:k.value,[`${w.value}-rtl`]:E.value===`rtl`},c(w.value,P.value),!l&&d,O.value),b=y(g,{prefixCls:w.value,..._,disabled:e,direction:E.value,filterOption:V.value,getPopupContainer:r,options:o.loading?[{value:`ANTDV_SEARCHING`,disabled:!0,label:y(f,{size:`small`},null)}]:o.options||B(),class:v,...m,rows:i,onChange:R,onSelect:L,onFocus:F,onBlur:I,ref:A,value:j.value,id:a,dropdownClassName:O.value},{notFoundContent:z,option:p.option});return D(l?y(`div`,{class:t(`${w.value}-affix-wrapper`,c(`${w.value}-affix-wrapper`,P.value,l),d,O.value)},[b,y(`span`,{class:`${w.value}-suffix`},[u])]):b)}}}),D=b({compatConfig:{MODE:3},...m,name:`AMentionsOption`,props:h}),O=Object.assign(E,{Option:D,getMentions:w,install:e=>(e.component(E.name,E),e.component(D.name,D),e)});export{D as MentionsOption,O as default,T as mentionsProps};