const e=require("../../_util/classNames.js"),t=require("../../_util/vue-types/index.js"),n=require("../../vc-tree-select/LegacyContext.js"),r=require("../../_util/pickAttrs.js"),i=require("../../vc-overflow/index.js"),a=require("../TransBtn.js"),o=require("./Input.js");let s=require("vue");var c={id:String,prefixCls:String,values:t.default.array,open:{type:Boolean,default:void 0},searchValue:String,inputRef:t.default.any,placeholder:t.default.any,disabled:{type:Boolean,default:void 0},mode:String,showSearch:{type:Boolean,default:void 0},autofocus:{type:Boolean,default:void 0},autocomplete:String,activeDescendantId:String,tabindex:t.default.oneOfType([t.default.number,t.default.string]),compositionStatus:Boolean,removeIcon:t.default.any,choiceTransitionName:String,maxTagCount:t.default.oneOfType([t.default.number,t.default.string]),maxTagTextLength:Number,maxTagPlaceholder:t.default.any.def(()=>e=>`+ ${e.length} ...`),tagRender:Function,onToggleOpen:{type:Function},onRemove:Function,onInputChange:Function,onInputPaste:Function,onInputKeyDown:Function,onInputMouseDown:Function,onInputCompositionStart:Function,onInputCompositionEnd:Function},l=e=>{e.preventDefault(),e.stopPropagation()},u=(0,s.defineComponent)({name:`MultipleSelectSelector`,inheritAttrs:!1,props:c,setup(t){let c=(0,s.shallowRef)(),u=(0,s.shallowRef)(0),d=(0,s.shallowRef)(!1),f=n.default(),p=(0,s.computed)(()=>`${t.prefixCls}-selection`),m=(0,s.computed)(()=>t.open||t.mode===`tags`?t.searchValue:``),h=(0,s.computed)(()=>t.mode===`tags`||t.showSearch&&(t.open||d.value)),g=(0,s.ref)(``);(0,s.watchEffect)(()=>{g.value=m.value}),(0,s.onMounted)(()=>{(0,s.watch)(g,()=>{u.value=c.value.scrollWidth},{flush:`post`,immediate:!0})});function _(n,r,i,o,c){return(0,s.createVNode)(`span`,{class:e.default(`${p.value}-item`,{[`${p.value}-item-disabled`]:i}),title:typeof n==`string`||typeof n==`number`?n.toString():void 0},[(0,s.createVNode)(`span`,{class:`${p.value}-item-content`},[r]),o&&(0,s.createVNode)(a.default,{class:`${p.value}-item-remove`,onMousedown:l,onClick:c,customizeIcon:t.removeIcon},{default:()=>[(0,s.createTextVNode)(`×`)]})])}function v(e,n,r,i,a,o){let c=e=>{l(e),t.onToggleOpen(!t.open)},u=o;return f.keyEntities&&(u=f.keyEntities[e]?.node||{}),(0,s.createVNode)(`span`,{key:e,onMousedown:c},[t.tagRender({label:n,value:e,disabled:r,closable:i,onClose:a,option:u})])}function y(e){let{disabled:n,label:r,value:i,option:a}=e,o=!t.disabled&&!n,s=r;if(typeof t.maxTagTextLength==`number`&&(typeof r==`string`||typeof r==`number`)){let e=String(s);e.length>t.maxTagTextLength&&(s=`${e.slice(0,t.maxTagTextLength)}...`)}let c=n=>{n&&n.stopPropagation(),t.onRemove?.(e)};return typeof t.tagRender==`function`?v(i,s,n,o,c,a):_(r,s,n,o,c)}function b(e){let{maxTagPlaceholder:n=e=>`+ ${e.length} ...`}=t,r=typeof n==`function`?n(e):n;return _(r,r,!1)}let x=e=>{let n=e.target.composing;g.value=e.target.value,n||t.onInputChange(e)};return()=>{let{id:e,prefixCls:n,values:a,open:l,inputRef:f,placeholder:_,disabled:v,autofocus:S,autocomplete:C,activeDescendantId:w,tabindex:T,compositionStatus:E,onInputPaste:D,onInputKeyDown:O,onInputMouseDown:k,onInputCompositionStart:A,onInputCompositionEnd:j}=t,M=(0,s.createVNode)(`div`,{class:`${p.value}-search`,style:{width:`${u.value}px`},key:`input`},[(0,s.createVNode)(o.default,{inputRef:f,open:l,prefixCls:n,id:e,inputElement:null,disabled:v,autofocus:S,autocomplete:C,editable:h.value,activeDescendantId:w,value:g.value,onKeydown:O,onMousedown:k,onChange:x,onPaste:D,onCompositionstart:A,onCompositionend:j,tabindex:T,attrs:r.default(t,!0),onFocus:()=>d.value=!0,onBlur:()=>d.value=!1},null),(0,s.createVNode)(`span`,{ref:c,class:`${p.value}-search-mirror`,"aria-hidden":!0},[g.value,(0,s.createTextVNode)(`\xA0`)])]);return(0,s.createVNode)(s.Fragment,null,[(0,s.createVNode)(i.default,{prefixCls:`${p.value}-overflow`,data:a,renderItem:y,renderRest:b,suffix:M,itemKey:`key`,maxCount:t.maxTagCount,key:`overflow`},null),!a.length&&!m.value&&!E&&(0,s.createVNode)(`span`,{class:`${p.value}-placeholder`},[_])])}}});exports.default=u;