import{dG as C,dB as y,dF as M,dq as h,dx as S,dm as E}from"./index-D_pphaE2.js";import{F as $}from"./startCase-BsTKbnbP.js";import{F as N}from"./FeatureWrapper-DRy_rS6q.js";import{a as j}from"./index-BhIhHSRV.js";import"./envs-CRUy-_iG.js";import"./DisplayValue-Bn_kSwDb.js";import"./isObject--vsEa_js.js";import"./_createCompounder-DD7kMWdY.js";import"./isObjectLike-DDO0-ybB.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 K({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=h.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 v=[];for(let m=1;m<s.members.length;m++){const l=s.members[m],F=p[l.ieee_address];if(!F||F.length===0)return[];const g=new Map;for(const d of F)(!d.endpoint||Number(d.endpoint)===l.endpoint||d.endpoint===n.endpoints[l.endpoint]?.name)&&g.set(b(d),d);v.push(g)}return w(_,v)},[r?.endpoint,n,i,p,s.members]),u=h.useCallback(async e=>{await S(t,`${s.id}/set`,e)},[t,s.id]),f=h.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:N,parentFeatures:[]},j(e)))}):c(e=>e.empty_exposes_definition)}export{K as default};
