import{u as C,a as y,I as M,r as F,s as S,j as E}from"./index-CE-9RlbR.js";import{F as $}from"./startCase-BwzMWzGM.js";import{F as j}from"./FeatureWrapper-CyVtzJVN.js";import{g as N}from"./DisplayValue-eLtXORWe.js";import"./envs-CRUy-_iG.js";import"./isObject--vsEa_js.js";import"./_createCompounder-pwnXEtry.js";import"./isObjectLike-BsEMHB57.js";const b=t=>t.property?`__property_${t.property}`:t.name?`__name_${t.name}`:`__type_${t.type}`,w=(t,s)=>{const c=[];for(const o of t){const p=b(o),r=[];for(const i of s){const a=i.get(p);a&&r.push(a)}if(r.length===0)continue;const n={...o};if("features"in o&&o.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 a=w(o.features,i);a.length>0&&("features"in n&&(n.features=a),c.push(n))}else c.push(n)}return c};function q({sourceIdx:t,group:s}){const{t:c}=C("common"),o=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?o.find(e=>e.ieee_address===r.ieee_address):void 0,i=n&&r?n.endpoints[r.endpoint]?.name:void 0,a=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&&a.length>0?E.jsx("div",{className:"list bg-base-100",children:a.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{q as default};
