import{l as B,m as N,p as T,q as G,x as f,H as L,A as W,V as E,W as H,f as J,X as K,d as u,o as t,J as d,F as c,r as $,c as v,D as l,w as x,L as b,e as V,t as q,n as P}from"./index-D02r7Zsc.js";import{u as g,_ as k}from"./useFormSelect-DvaFh_iu-BGTVaqMd.js";import{u as C}from"./useDefaults-DESCdb0p-CFLjYrdG.js";import{u as R,a as U}from"./useStateClass-BGbSLWFN-BcKQ8Z3i.js";import{c as X}from"./index-C0p9vHHI-DoOEDIMw.js";import{u as j}from"./useId-t29UARy6-BH5d2231.js";const Q=["label"],Y=B({__name:"BFormSelectOptionGroup",props:{disabledField:{default:"disabled"},label:{default:void 0},options:{default:()=>[]},textField:{default:"text"},valueField:{default:"value"}},setup(r){const n=C(r,"BFormSelectOptionGroup"),{normalizedOptions:e}=g(()=>n.options,n);return(s,F)=>(t(),u("optgroup",{label:l(n).label},[d(s.$slots,"first"),(t(!0),u(c,null,$(l(e),(o,p)=>(t(),v(k,b({key:p,disabled:o.disabled,value:o.value},{ref_for:!0},s.$attrs),{default:x(()=>[d(s.$slots,"option",b({ref_for:!0},o),()=>[V(q(o.text),1)])]),_:2},1040,["disabled","value"]))),128)),d(s.$slots,"default")],8,Q))}}),Z=["id","name","form","multiple","size","disabled","required","aria-required","aria-invalid"],de=B({__name:"BFormSelect",props:N({ariaInvalid:{type:[Boolean,String],default:void 0},autofocus:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},disabledField:{default:"disabled"},form:{default:void 0},id:{default:void 0},labelField:{default:"label"},multiple:{type:Boolean,default:!1},name:{default:void 0},options:{default:()=>[]},optionsField:{default:"options"},plain:{type:Boolean,default:!1},required:{type:Boolean,default:!1},selectSize:{default:0},size:{default:"md"},state:{type:[Boolean,null],default:null},textField:{default:"text"},valueField:{default:"value"}},{modelValue:{default:""},modelModifiers:{}}),emits:["update:modelValue"],setup(r,{expose:_}){const e=C(r,"BFormSelect"),s=T(r,"modelValue"),F=j(()=>e.id,"input"),o=L(()=>e.selectSize),p=R(()=>e.state),S=G("_input"),{focused:z}=X(S,{initialValue:e.autofocus}),I=f(()=>[p.value,{"form-control":e.plain,[`form-control-${e.size}`]:e.size!=="md"&&e.plain,"form-select":!e.plain,[`form-select-${e.size}`]:e.size!=="md"&&!e.plain}]),O=f(()=>o.value||e.plain?o.value:void 0),h=U(()=>e.ariaInvalid,()=>e.state),{normalizedOptions:D,isComplex:M}=g(()=>e.options,e),w=f(()=>D.value),m=f({get:()=>s.value,set:i=>{s.value=i}});return W(H,{modelValue:E(m)}),_({blur:()=>{z.value=!1},element:S,focus:()=>{z.value=!0}}),(i,y)=>J((t(),u("select",{id:l(F),ref:"_input","onUpdate:modelValue":y[0]||(y[0]=a=>m.value=a),class:P(I.value),name:l(e).name,form:l(e).form||void 0,multiple:l(e).multiple||void 0,size:O.value,disabled:l(e).disabled,required:l(e).required||void 0,"aria-required":l(e).required||void 0,"aria-invalid":l(h)},[d(i.$slots,"first"),(t(!0),u(c,null,$(w.value,(a,A)=>(t(),u(c,{key:A},[l(M)(a)?(t(),v(Y,{key:0,label:a.label,options:a.options,"value-field":l(e).valueField,"text-field":l(e).textField,"disabled-field":l(e).disabledField},null,8,["label","options","value-field","text-field","disabled-field"])):(t(),v(k,{key:1,value:a.value,disabled:a.disabled},{default:x(()=>[d(i.$slots,"option",b({ref_for:!0},a),()=>[V(q(a.text),1)])]),_:2},1032,["value","disabled"]))],64))),128)),d(i.$slots,"default")],10,Z)),[[K,m.value]])}});export{de as _};
