import{r as d,b as x,j as t}from"./index-BeDhuS24.js";import{S as j}from"./SelectField-CgXiODUe.js";const _=d.memo(c=>{const{t:i}=x("common"),{devices:l,value:p,label:u,onChange:a,groups:r=[],...m}=c,h=s=>{const{value:n}=s.target;if(n.startsWith("0x"))a(l.find(e=>e.ieee_address===n));else{const e=Number.parseInt(n,10);a(r.find(o=>e===o.id))}},f=d.useMemo(()=>{const s=[],n=l.map(e=>t.jsxs("option",{title:e.definition?.description,value:e.ieee_address,children:[e.friendly_name," ",e.definition?.model?`(${e.definition?.model})`:""]},e.ieee_address));if(r?.length){const e=r.map(o=>t.jsx("option",{value:o.id,children:o.friendly_name},o.id));s.push(t.jsx("optgroup",{label:i("groups"),children:e},"Groups")),s.push(t.jsx("optgroup",{label:i("devices"),children:n},"Devices"))}else s.push(...n);return s},[l,r,i]);return t.jsxs(j,{name:"device_picker",label:u,value:p,onChange:h,...m,children:[t.jsx("option",{value:"",disabled:!0,children:i("select_device")}),f]})});export{_ as D};
