import{r as d,a as _,E as h,u as b,j as l}from"./index-ClCsMWbS.js";import{S as f}from"./SelectField-WiB6Edsu.js";const x=t=>t.type>=32&&t.type<=47||t.type>=56&&t.type<=58||t.type>=224&&t.type<=226,g=(t,e,s)=>{const i=t.custom_clusters[e];if(i){const c=i[s];if(c)return c.attributes}const a=t.clusters[s];return a?a.attributes:{}},A=(t,e,s,i)=>g(t,e,s)[i],C=(t,e)=>({isNew:t,reportable_change:0,minimum_report_interval:60,maximum_report_interval:3600,endpoint:e,cluster:"",attribute:""}),k=t=>{const e=[];for(const s in t.endpoints){const a=t.endpoints[s].configured_reportings.map(c=>({...c,endpoint:s}));e.push({endpointId:s,rules:a})}return e},y=(t,e,s)=>!(t==null||t===""||Number.isNaN(t)||e==null||e===""||Number.isNaN(e)||s===""||Number.isNaN(s)||t>e&&!(e===0&&t===65535&&s===0)),v=t=>t.endpoint===void 0||t.endpoint===""||t.cluster===void 0||t.cluster===""||t.attribute===void 0||t.attribute===""?!1:y(t.minimum_report_interval,t.maximum_report_interval,t.reportable_change),E=d.memo(({sourceIdx:t,cluster:e,device:s,onChange:i,label:a,...c})=>{const p=_(h(r=>r.bridgeDefinitions[t])),{t:m}=b("zigbee"),o=d.useMemo(()=>g(p,s.ieee_address,e),[p,s.ieee_address,e]),n=d.useMemo(()=>{const r=[];for(const u in o)r.push(l.jsx("option",{value:u,children:u},u));return r},[o]);return l.jsxs(f,{name:"attribute_picker",label:a,onChange:r=>i(r.target.value,o[r.target.value]),disabled:n.length===0,className:"select validator w-64",...c,children:[l.jsx("option",{value:"",disabled:!0,children:m(r=>r.select_attribute)}),n]})}),S=d.memo(({clusters:t,onChange:e,value:s,label:i,disabled:a,...c})=>{const{t:p}=b(["zigbee","common"]),m=d.useMemo(()=>{const o=[];if(Array.isArray(t))for(const n of t){const r=[];for(const u of n.clusters)r.push(l.jsx("option",{value:u,children:u},u));o.push(l.jsx("optgroup",{label:p(u=>u[n.name]),children:r},n.name))}else for(const n of t)o.push(l.jsx("option",{value:n,children:n},n));return o},[t,p]);return l.jsxs(f,{name:"attribute_picker",label:i,value:s,title:s,onChange:o=>e(o.target.value),disabled:a,className:"select validator w-48",...c,children:[l.jsx("option",{value:"",disabled:!0,children:p(o=>o.select_cluster)}),m]})});export{E as A,S as C,x as a,k as b,g as c,v as d,A as g,y as i,C as m};
