"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const l=require("vue"),p=require("../_util/omit.js"),y=require("../_util/props-util/index.js"),A=require("../_util/warning.js"),w=require("../config-provider/hooks/useConfigInject.js"),m=require("../select/index.js"),r=require("./OptGroup.js"),o=require("./Option.js");function q(e){return e?.type?.isSelectOption||e?.type?.isSelectOptGroup}const S=()=>({...p.default(m.selectProps(),["loading","mode","optionLabelProp","labelInValue"]),dataSource:Array,dropdownMenuStyle:{type:Object,default:void 0},dropdownMatchSelectWidth:{type:[Number,Boolean],default:!0},prefixCls:String,showSearch:{type:Boolean,default:void 0},transitionName:String,choiceTransitionName:{type:String,default:"zoom"},autofocus:{type:Boolean,default:void 0},backfill:{type:Boolean,default:void 0},filterOption:{type:[Boolean,Function],default:!1},defaultActiveFirstOption:{type:Boolean,default:!0},status:String}),B=o.default,E=r.default,f=l.defineComponent({compatConfig:{MODE:3},name:"AAutoComplete",inheritAttrs:!1,props:S(),slots:Object,setup(e,{slots:n,attrs:O,expose:g}){A.default(!e.dropdownClassName);const d=l.ref(),h=()=>{const u=y.flattenChildren(n.default?.());return u.length?u[0]:void 0};g({focus:()=>{d.value?.focus()},blur:()=>{d.value?.blur()}});const{prefixCls:a}=w.default("select",e);return()=>{const{size:u,dataSource:s,notFoundContent:b=n.notFoundContent?.()}=e;let c;const{class:C}=O,v={[C]:!!C,[`${a.value}-lg`]:u==="large",[`${a.value}-sm`]:u==="small",[`${a.value}-show-search`]:!0,[`${a.value}-auto-complete`]:!0};if(e.options===void 0){const i=n.dataSource?.()||n.options?.()||[];i.length&&q(i[0])?c=i:c=s?s.map(t=>{if(y.isValidElement(t))return t;switch(typeof t){case"string":return l.createVNode(o.default,{key:t,value:t},{default:()=>[t]});case"object":return l.createVNode(o.default,{key:t.value,value:t.value},{default:()=>[t.text]});default:throw new Error("AutoComplete[dataSource] only supports type `string[] | Object[]`.")}}):[]}const N=p.default({...e,...O,mode:m.default.SECRET_COMBOBOX_MODE_DO_NOT_USE,getInputElement:h,notFoundContent:b,class:v,popupClassName:e.popupClassName||e.dropdownClassName,ref:d},["dataSource","loading"]);return l.createVNode(m.default,N,{default:()=>[c],...p.default(n,["default","dataSource","options"])})}}}),j=Object.assign(f,{Option:o.default,OptGroup:r.default,install(e){return e.component(f.name,f),e.component(o.default.displayName,o.default),e.component(r.default.displayName,r.default),e}});exports.AutoCompleteOptGroup=E;exports.AutoCompleteOption=B;exports.autoCompleteProps=S;exports.default=j;
