import{a9 as b,an as F,x as v,a8 as D,ab as x,ao as S,c as C,r as A,i as w,D as B,j as p}from"./index-fb4a4614.js";import{D as E}from"./DashboardDevice-c60201bb.js";import{i as I,b as j,g as k,c as y,D as N}from"./DashboardFeatureWrapper-ef543cb2.js";import{_ as T}from"./_baseSet-411f0b9b.js";import{c as G}from"./_getAllKeysIn-d7fdca48.js";import{r as O,a as P,g as L,G as K,p as M}from"./persist-47ba9205.js";import{D as _}from"./DEVICES_GLOBAL_NAME-6620c611.js";import"./index-662e592d.js";import"./powerSourceTypeToTranslationKey-452dac81.js";import"./DeviceImage-a3fb91b8.js";import"./index-361b7a42.js";import"./isEqual-ddfc316d.js";var R=b,V=T,W=F;function $(t,a,i){for(var e=-1,s=a.length,l={};++e<s;){var r=a[e],n=R(t,r);i(n,r)&&V(l,W(r,t),n)}return l}var q=$,z=D,H=x,J=q,Q=G;function U(t,a){if(t==null)return{};var i=z(Q(t),function(e){return[e]});return a=H(a),J(t,i,function(e,s){return a(e,s[0])})}var X=U;const Y=v(X),Z=["linkquality","battery","battery_low","battery_state","color_temp_startup","voltage","strength","color_options","warning","position","operation_mode","operation_mode2","programming_mode","options","programming","schedule_monday","schedule_tuesday","schedule_wednesday","schedule_thursday","schedule_friday","schedule_saturday","schedule_sunday","holiday_mode_date"],ee=["state","brightness","color_temp","mode","sound","occupancy","tamper","alarm"],re=["light"],te=["",null,void 0],g=(t,a={})=>{const{access:i,property:e,name:s,type:l}=t;let{features:r}=t;if(I(t)||j(t)){r=r.map(d=>g(d,e?a[e]:a)).filter(d=>d);const c=k(r,"property");r=Object.values(c).map(d=>d[0])}const n={...t,features:r};return ee.includes(s)||re.includes(l)?n:i&&!(i&y.ACCESS_STATE&&!te.includes(a[e]))?!1:s=="voltage"&&a.battery==null?n:Z.includes(s)?!1:i&y.ACCESS_STATE&&S(i)||Array.isArray(r)&&r.length>0?n:!1},ae=["friendly_name","description","ieee_address","manufacturer","type","power_source","model_id","definition.model","definition.vendor"];function se(t,a,i){return Object.values(t).filter(e=>e.supported).map(e=>({device:e,deviceState:a[e.friendly_name]??{}})).map(({device:e,deviceState:s})=>{var n;const r=(((n=e.definition)==null?void 0:n.exposes)??[]).map(c=>i(c,s)).filter(c=>c);return{device:e,deviceState:s,filteredFeatures:r}}).filter(({filteredFeatures:e})=>e.length>0).sort((e,s)=>e.device.friendly_name.localeCompare(s.device.friendly_name))}function ne(t){const{setDeviceState:a,getDeviceState:i,deviceStates:e,bridgeInfo:s,devices:l}=t,[r,n]=A.useState(()=>P(L(_))??{}),c=o=>{const m={...r,globalFilter:o};n(m),M(_,m)},d=Y(l,(o,m)=>w(o,s.config)?!1:r.globalFilter?ae.map(u=>B(o,u)).filter(Boolean).map(String).map(u=>u.toLowerCase()).some(u=>u.includes(r.globalFilter.toLowerCase())):!0);return p.jsxs("div",{className:"row",children:[p.jsx("div",{className:"col-12",children:p.jsx("div",{className:"flex-fill card flex-shrink-1",children:p.jsx("div",{className:"card-footer",children:p.jsx(K,{globalFilter:r.globalFilter,setGlobalFilter:c})})})}),se(d,e,g).map(({device:o,deviceState:m,filteredFeatures:u})=>p.jsx(E,{feature:{features:u},device:o,deviceState:m,onChange:(h,f)=>a(o.friendly_name,f),onRead:(h,f)=>i(o.friendly_name,f),featureWrapperClass:N,lastSeenType:s.config.advanced.last_seen},o.ieee_address))]})}const he=C(["devices","deviceStates","bridgeInfo"],O.actions)(ne);export{he as ConnectedDashboardPage};
