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