import{Chip_default as e,FormControl_default as t,FormHelperText_default as n,InputLabel_default as r,MenuItem_default as i,Select_default as a,__toESM as o,commonRepository as s,createStyles as c,jsx as l,jsxs as u,makeStyles_default as d,require_react as f}from"./index-D6C_Nj7C.js";const p=e=>{if(!e)return``;let t=JSON.parse(e);return t.VendorName||`(vendor?)`};var m=o(f());const h=d(e=>c({root:{padding:`2px 4px`,display:`flex`,alignItems:`center`,width:400},input:{marginLeft:e.spacing(1),flex:1},iconButton:{padding:10},divider:{height:28,margin:4},formControl:{margin:e.spacing(1),minWidth:300},modal:{backgroundColor:`#fff`}})),g=({value:o,onChange:c,componentTypeId:d=null,error:f=``})=>{let g=h(),[_,v]=(0,m.useState)(null);return(0,m.useEffect)(()=>{(async()=>{let e=await s.getParts({componentTypeId:d});e.ok&&v(e.data)})()},[]),u(t,{className:g.formControl,variant:`outlined`,children:[l(r,{children:`Part`}),u(a,{label:`Part`,error:!!f,value:o??null,onChange:c,renderValue:t=>{if(t.length===0)return l(`div`,{});let n=_?.find(e=>e.partId===t),r=`${n?.partName} - ${p(n?.vendor||`{}`)}`;return l(`div`,{style:{display:`flex`,flexWrap:`wrap`},children:l(e,{label:r})})},children:[l(i,{disabled:!0,value:``,children:l(`div`,{})}),_&&_.filter(e=>e.isActive).map(e=>u(i,{value:e.partId,children:[e.partName,` - `,p(e.vendor)]},`part-${e.partId}`))]}),l(n,{error:!!f,children:f})]})};export{g as PartFormField};
//# sourceMappingURL=part.form-field-DUWF0fiV.js.map