"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),M=require("../../_util/pickAttrs.js"),a=require("../../_util/vue-types/index.js"),P=require("../../vc-tree-select/LegacyContext.js"),T=require("./Input.js"),K={inputElement:a.default.any,id:String,prefixCls:String,values:a.default.array,open:{type:Boolean,default:void 0},searchValue:String,inputRef:a.default.any,placeholder:a.default.any,compositionStatus:{type:Boolean,default:void 0},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:a.default.oneOfType([a.default.number,a.default.string]),activeValue:String,backfill:{type:Boolean,default:void 0},optionLabelRender:Function,onInputChange:Function,onInputPaste:Function,onInputKeyDown:Function,onInputMouseDown:Function,onInputCompositionStart:Function,onInputCompositionEnd:Function},s=t.defineComponent({name:"SingleSelector",setup(e){const d=t.shallowRef(!1),l=t.computed(()=>e.mode==="combobox"),v=t.computed(()=>l.value||e.showSearch),r=t.computed(()=>{let n=e.searchValue||"";return l.value&&e.activeValue&&!d.value&&(n=e.activeValue),n}),i=P.default();t.watch([l,()=>e.activeValue],()=>{l.value&&(d.value=!1)},{immediate:!0});const f=t.computed(()=>e.mode!=="combobox"&&!e.open&&!e.showSearch?!1:!!r.value||e.compositionStatus),y=t.computed(()=>{const n=e.values[0];return n&&(typeof n.label=="string"||typeof n.label=="number")?n.label.toString():void 0}),b=()=>{if(e.values[0])return null;const n=f.value?{visibility:"hidden"}:void 0;return t.createVNode("span",{class:`${e.prefixCls}-selection-placeholder`,style:n},[e.placeholder])},g=n=>{n.target.composing||(d.value=!0,e.onInputChange(n))};return()=>{const{inputElement:n,prefixCls:c,id:S,values:h,inputRef:I,disabled:C,autofocus:x,autocomplete:V,activeDescendantId:w,open:F,tabindex:D,optionLabelRender:p,onInputKeyDown:k,onInputMouseDown:E,onInputPaste:N,onInputCompositionStart:B,onInputCompositionEnd:R}=e,o=h[0];let u=null;if(o&&i.customSlots){const q=o.key??o.value,m=i.keyEntities[q]?.node||{};u=i.customSlots[m.slots?.title]||i.customSlots.title||o.label,typeof u=="function"&&(u=u(m))}else u=p&&o?p(o.option):o?.label;return t.createVNode(t.Fragment,null,[t.createVNode("span",{class:`${c}-selection-search`},[t.createVNode(T.default,{inputRef:I,prefixCls:c,id:S,open:F,inputElement:n,disabled:C,autofocus:x,autocomplete:V,editable:v.value,activeDescendantId:w,value:r.value,onKeydown:k,onMousedown:E,onChange:g,onPaste:N,onCompositionstart:B,onCompositionend:R,tabindex:D,attrs:M.default(e,!0)},null)]),!l.value&&o&&!f.value&&t.createVNode("span",{class:`${c}-selection-item`,title:y.value},[t.createVNode(t.Fragment,{key:o.key??o.value},[u])]),b()])}}});s.props=K;s.inheritAttrs=!1;exports.default=s;
