import{r as C,a as P,I as e,u as m,j as R,D as L}from"./index-VJpwYvBU.js";import{S as M}from"./react-select.esm-DM_HiCZr.js";var b=(s=>(s[s.NO_DATA=0]="NO_DATA",s[s.DATA8=8]="DATA8",s[s.DATA16=9]="DATA16",s[s.DATA24=10]="DATA24",s[s.DATA32=11]="DATA32",s[s.DATA40=12]="DATA40",s[s.DATA48=13]="DATA48",s[s.DATA56=14]="DATA56",s[s.DATA64=15]="DATA64",s[s.BOOLEAN=16]="BOOLEAN",s[s.BITMAP8=24]="BITMAP8",s[s.BITMAP16=25]="BITMAP16",s[s.BITMAP24=26]="BITMAP24",s[s.BITMAP32=27]="BITMAP32",s[s.BITMAP40=28]="BITMAP40",s[s.BITMAP48=29]="BITMAP48",s[s.BITMAP56=30]="BITMAP56",s[s.BITMAP64=31]="BITMAP64",s[s.UINT8=32]="UINT8",s[s.UINT16=33]="UINT16",s[s.UINT24=34]="UINT24",s[s.UINT32=35]="UINT32",s[s.UINT40=36]="UINT40",s[s.UINT48=37]="UINT48",s[s.UINT56=38]="UINT56",s[s.UINT64=39]="UINT64",s[s.INT8=40]="INT8",s[s.INT16=41]="INT16",s[s.INT24=42]="INT24",s[s.INT32=43]="INT32",s[s.INT40=44]="INT40",s[s.INT48=45]="INT48",s[s.INT56=46]="INT56",s[s.INT64=47]="INT64",s[s.ENUM8=48]="ENUM8",s[s.ENUM16=49]="ENUM16",s[s.SEMI_PREC=56]="SEMI_PREC",s[s.SINGLE_PREC=57]="SINGLE_PREC",s[s.DOUBLE_PREC=58]="DOUBLE_PREC",s[s.OCTET_STR=65]="OCTET_STR",s[s.CHAR_STR=66]="CHAR_STR",s[s.LONG_OCTET_STR=67]="LONG_OCTET_STR",s[s.LONG_CHAR_STR=68]="LONG_CHAR_STR",s[s.ARRAY=72]="ARRAY",s[s.STRUCT=76]="STRUCT",s[s.SET=80]="SET",s[s.BAG=81]="BAG",s[s.TOD=224]="TOD",s[s.DATE=225]="DATE",s[s.UTC=226]="UTC",s[s.CLUSTER_ID=232]="CLUSTER_ID",s[s.ATTR_ID=233]="ATTR_ID",s[s.BAC_OID=234]="BAC_OID",s[s.IEEE_ADDR=240]="IEEE_ADDR",s[s.SEC_KEY=241]="SEC_KEY",s[s.UNKNOWN=255]="UNKNOWN",s))(b||{}),T=(s=>(s[s.USE_DATA_TYPE=1e3]="USE_DATA_TYPE",s[s.LIST_UINT8=1001]="LIST_UINT8",s[s.LIST_UINT16=1002]="LIST_UINT16",s[s.LIST_UINT24=1003]="LIST_UINT24",s[s.LIST_UINT32=1004]="LIST_UINT32",s[s.LIST_ZONEINFO=1005]="LIST_ZONEINFO",s[s.EXTENSION_FIELD_SETS=1006]="EXTENSION_FIELD_SETS",s[s.LIST_THERMO_TRANSITIONS=1007]="LIST_THERMO_TRANSITIONS",s[s.BUFFER=1008]="BUFFER",s[s.GPD_FRAME=1009]="GPD_FRAME",s[s.STRUCTURED_SELECTOR=1010]="STRUCTURED_SELECTOR",s[s.LIST_TUYA_DATAPOINT_VALUES=1011]="LIST_TUYA_DATAPOINT_VALUES",s[s.LIST_MIBOXER_ZONES=1012]="LIST_MIBOXER_ZONES",s[s.BIG_ENDIAN_UINT24=1013]="BIG_ENDIAN_UINT24",s[s.MI_STRUCT=1014]="MI_STRUCT",s))(T||{});const G=s=>s.type>=32&&s.type<=47||s.type>=56&&s.type<=58||s.type>=224&&s.type<=226,d=(s,S,r)=>{const _=s.custom_clusters[S];if(_){const E=_[r];if(E)return E.attributes}const n=s.clusters[r];return n?n.attributes:{}},F=(s,S,r,_)=>d(s,S,r)[_],x=(s,S,r)=>{const _=s.custom_clusters[S];if(_){const E=_[r];if(E)return E.commands}const n=s.clusters[r];return n?n.commands:{}},j=C.memo(({sourceIdx:s,cluster:S,device:r,onChange:_,value:n,label:E,required:o,disabled:c})=>{const i=P(e(I=>I.bridgeDefinitions[s])),{t:l}=m("zigbee"),A=C.useMemo(()=>d(i,r.ieee_address,S),[i,r.ieee_address,S]),u=C.useMemo(()=>{const I=[];for(const N in A)I.push({value:N,label:N});return I},[A]),U=C.useMemo(()=>n==null||n===""?null:u.find(I=>I.value===n)??null,[n,u]);return R.jsxs("fieldset",{className:"fieldset",children:[E&&R.jsxs("legend",{className:"fieldset-legend",children:[E,o?" *":""]}),R.jsx(M,{unstyled:!0,placeholder:l(I=>I.select_attribute),"aria-label":E??l(I=>I.select_attribute),options:u,value:U,isSearchable:!0,isDisabled:c,onChange:I=>{I!=null&&_(I.value,A[I.value])},className:"min-w-64",classNames:L})]})}),Y=C.memo(({clusters:s,onChange:S,value:r,label:_,disabled:n,required:E})=>{const{t:o}=m(["zigbee","common"]),[c,i]=C.useMemo(()=>{const A=[],u=[];if(Array.isArray(s))for(const U of s){const I=[];for(const N of U.clusters){const O={value:N,label:N};I.push(O),u.push(O)}I.sort((N,O)=>N.label.localeCompare(O.label)),A.push({label:o(N=>N[U.name]),options:I})}else{const U=[];for(const I of s){const N={value:I,label:I};U.push(N),u.push(N)}U.sort((I,N)=>I.label.localeCompare(N.label)),A.push({label:o(I=>I.cluster),options:U})}return[A,u]},[s,o]),l=C.useMemo(()=>r==null||r===""?null:i.find(A=>A.value===r)??null,[r,i]);return R.jsxs("fieldset",{className:"fieldset",children:[_&&R.jsxs("legend",{className:"fieldset-legend",children:[_,E?" *":""]}),R.jsx(M,{unstyled:!0,placeholder:o(A=>A.select_cluster),"aria-label":_??o(A=>A.select_cluster),options:c,value:l,isSearchable:!0,isDisabled:n,onChange:A=>{A!=null&&S(A.value)},className:"min-w-64",classNames:L})]})});export{j as A,T as B,Y as C,b as D,x as a,d as b,F as g,G as i};
