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