import{u as C,a as y,I as M,r as F,s as S,j as E}from"./index-a36IMXuN.js";import{F as $}from"./startCase-K7WbZvzP.js";import{F as j}from"./FeatureWrapper-BGeGFgyv.js";import{g as N}from"./index-CCf1BEwD.js";import"./envs-CRUy-_iG.js";import"./DisplayValue-D9Ja0Su_.js";import"./isObject--vsEa_js.js";import"./_createCompounder-BuXEc9F7.js";import"./isObjectLike-BQssIl0N.js";const b=t=>t.property?`__property_${t.property}`:t.name?`__name_${t.name}`:`__type_${t.type}`,w=(t,s)=>{const c=[];for(const a of t){const p=b(a),r=[];for(const i of s){const o=i.get(p);o&&r.push(o)}if(r.length===0)continue;const n={...a};if("features"in a&&a.features.length>0){const i=[];for(const u of r)"features"in u&&i.push(new Map(u.features.map(f=>[b(f),f])));const o=w(a.features,i);o.length>0&&("features"in n&&(n.features=o),c.push(n))}else c.push(n)}return c};function z({sourceIdx:t,group:s}){const{t:c}=C("common"),a=y(M(e=>e.devices[t])),p=y(M(e=>e.deviceScenesFeatures[t])),r=s.members.length>0?s.members[0]:void 0,n=r?a.find(e=>e.ieee_address===r.ieee_address):void 0,i=n&&r?n.endpoints[r.endpoint]?.name:void 0,o=F.useMemo(()=>{if(!n)return[];const e=p[n.ieee_address]??[];if(e.length===0)return[];const _=e.filter(m=>!m.endpoint||Number(m.endpoint)===r?.endpoint||m.endpoint===i);if(s.members.length===1)return _;const g=[];for(let m=1;m<s.members.length;m++){const l=s.members[m],h=p[l.ieee_address];if(!h||h.length===0)return[];const v=new Map;for(const d of h)(!d.endpoint||Number(d.endpoint)===l.endpoint||d.endpoint===n.endpoints[l.endpoint]?.name)&&v.set(b(d),d);g.push(v)}return w(_,g)},[r?.endpoint,n,i,p,s.members]),u=F.useCallback(async e=>{await S(t,`${s.id}/set`,e)},[t,s.id]),f=F.useCallback(async e=>{await S(t,`${s.id}/get`,e)},[t,s.id]);return n&&o.length>0?E.jsx("div",{className:"list bg-base-100",children:o.map(e=>E.jsx($,{feature:e,device:n,deviceState:{},onChange:u,onRead:f,featureWrapperClass:j,parentFeatures:[]},N(e)))}):c(e=>e.empty_exposes_definition)}export{z as default};
