import{j as e,Q as S,R as I,S as O,U as c,J as p,bk as T,T as i,bp as z,fN as W,gc as B,bi as C,o as s}from"./index-DQhyMeoV.js";function M({fullWidth:m=!1,multiple:a=!1,required:o=!1,label:x="",placeholder:j="",options:t=[],helperText:b="",error:v=!1,margin:u="",size:f,slotProps:g={},...h}){const y=t.find(l=>l.value===h.value)?.title;return e.jsxs(S,{margin:u,fullWidth:m,error:v,children:[e.jsx(I,{size:f,children:`${x}${o?"*":""}`}),e.jsxs(O,{multiple:a,sx:{"& .MuiInputBase-input":{width:"calc(100% - 46px)","& > .MuiBox-root:first-of-type":{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},input:e.jsx(B,{defaultValue:y,sx:{flex:1},required:o,label:x,inputProps:{margin:u},size:f}),renderValue:l=>{if(a)return e.jsx(p,{sx:{display:"flex",flexWrap:"wrap",gap:.5},children:l.map(r=>{const d=t.find(w=>w.value===r);return d&&d.title&&e.jsx(W,{size:"small",label:d.title},r)})});const n=t.find(r=>r.value===l);return n&&n.title&&e.jsxs(p,{children:[e.jsx(i,{component:"span",children:n.title}),e.jsx(i,{component:"span",variant:"body2",sx:{marginLeft:1,color:"text.secondary"},children:n.description})]})},IconComponent:l=>e.jsx(z,{...l,width:20,height:20}),...h,children:[e.jsx(c,{disabled:!0,children:e.jsx("em",{children:j})}),!o&&!a&&e.jsx(c,{value:"",children:"None"}),t.map(l=>l&&l.value&&e.jsx(c,{value:l.value,disabled:l.disabled||!1,children:e.jsxs(p,{sx:T({display:"flex",flexDirection:"column"},g?.optionItem?.sx),children:[e.jsx(i,{component:"span",children:l.title}),l.description&&e.jsx(i,{component:"span",variant:"body2",sx:{maxWidth:510,fontSize:12,whiteSpace:"normal",color:"text.secondary"},children:l.description})]})},l.value))]}),e.jsx(C,{children:b})]})}M.propTypes={error:s.bool,required:s.bool,multiple:s.bool,fullWidth:s.bool,label:s.string,placeholder:s.string,options:s.array,helperText:s.string,margin:s.string,size:s.string,textDirection:s.oneOf(["row","column"]),slotProps:s.object};export{M as S};
