import{r as o,b2 as v,a as s,X as h,j as r,Y as x,Z as y,_ as d,aM as b,bj as I,D as P,al as S}from"./index-09tpYl64.js";const c=a=>a?JSON.parse(a).VendorName||"(vendor?)":"",C=P(a=>S({root:{padding:"2px 4px",display:"flex",alignItems:"center",width:400},input:{marginLeft:a.spacing(1),flex:1},iconButton:{padding:10},divider:{height:28,margin:4},formControl:{margin:a.spacing(1),minWidth:300},modal:{backgroundColor:"#fff"}})),j=({value:a,onChange:l,componentTypeId:p=null,error:t=""})=>{const u=C(),[n,m]=o.useState(null);return o.useEffect(()=>{(async()=>{const e=await v.getParts({componentTypeId:p});e.ok&&m(e.data)})()},[]),s(h,{className:u.formControl,variant:"outlined",children:[r(x,{children:"Part"}),s(y,{label:"Part",error:!!t,value:a??null,onChange:l,renderValue:e=>{if(e.length===0)return r("div",{});const i=n?.find(g=>g.partId===e),f=`${i?.partName} - ${c(i?.vendor||"{}")}`;return r("div",{style:{display:"flex",flexWrap:"wrap"},children:r(b,{label:f})})},children:[r(d,{disabled:!0,value:"",children:r("div",{})}),n&&n.filter(e=>e.isActive).map(e=>s(d,{value:e.partId,children:[e.partName," - ",c(e.vendor)]},`part-${e.partId}`))]}),r(I,{error:!!t,children:t})]})};export{j as P};
//# sourceMappingURL=part.form-field-DBtBift2.js.map
