import{u as j,l as w,j as a,r as x,L as C,g as h,d as f,c as k,a as S,w as E,R as H,i as L}from"./index-d7144f09.js";import{V as T,M as A}from"./vendor-links-ef35af23.js";import{L as F,D as q,P as M}from"./index-f85611b2.js";import{i as N,A as P,D as I}from"./Availability-0ec0553d.js";import{T as R}from"./ReactTableCom-3efca1fa.js";import{D as V}from"./DeviceImage-d3f7881d.js";import{D as B}from"./DEVICES_GLOBAL_NAME-6620c611.js";import"./powerSourceTypeToTranslationKey-452dac81.js";import"./persist-6220a907.js";import"./index-46206196.js";const $={"action-column":"_action-column_1729o_1","device-pic":"_device-pic_1729o_8","device-image":"_device-image_1729o_14"};function z(l){const{data:t,lastSeenType:o,availabilityFeatureEnabled:r,homeassistantEnabled:d,setDeviceDescription:p}=l,{renameDevice:c,removeDevice:m,configureDevice:v,interviewDevice:b}=l,{t:s}=j(["zigbee","common","avaliability"]),u=o!=="disable"?[{id:"last_seen",Header:s("last_seen"),accessor:({state:e})=>{var i;return(i=w(e,o))==null?void 0:i.getTime()},Cell:({row:{original:{state:e}}})=>a.jsx(F,{state:e,lastSeenType:o})}]:[],_=t.some(e=>e.availabilityEnabledForDevice??r)?[{id:"availability",Header:s("avaliability:avaliability"),accessor:({availabilityState:e})=>N(e)?e:e.state,Cell:({row:{original:{availabilityState:e,availabilityEnabledForDevice:i,disabled:n}}})=>a.jsx(P,{disabled:n,availability:e,availabilityEnabledForDevice:i,availabilityFeatureEnabled:r})}]:[],y=x.useMemo(()=>[{id:"pic",Header:s("pic"),Cell:({row:{original:{device:e,state:i,disabled:n}}})=>a.jsx(V,{className:$["device-image"],device:e,deviceStatus:i,disabled:n}),accessor:e=>e,disableSortBy:!0},{id:"friendly_name",Header:s("friendly_name"),accessor:({device:e})=>[e.friendly_name,e.description].join(" "),Cell:({row:{original:{device:e}}})=>a.jsxs(a.Fragment,{children:[a.jsx(C,{to:h(e.ieee_address),children:e.friendly_name}),a.jsx("small",{className:"d-block",children:e.description})]})},{id:"ieee_address",Header:s("ieee_address"),accessor:({device:e})=>[e.ieee_address,f(e.network_address,4)].join(" "),Cell:({row:{original:{device:e}}})=>a.jsxs(a.Fragment,{children:[a.jsx("div",{children:e.ieee_address}),a.jsx("div",{children:a.jsxs("abbr",{title:`${s("network_address_hex")} (${s("network_address_dec")}: ${e.network_address})`,children:["(",f(e.network_address,4),")"]})})]})},{id:"manufacturer",Header:s("manufacturer"),accessor:({device:e})=>{var i;return[(i=e.definition)==null?void 0:i.vendor,e.manufacturer].join(" ")},Cell:({row:{original:{device:e}}})=>a.jsx(T,{device:e})},{id:"model",Header:s("model"),accessor:({device:e})=>{var i;return[(i=e.definition)==null?void 0:i.model,e.model_id].join(" ")},Cell:({row:{original:{device:e}}})=>a.jsx(A,{device:e})},{id:"lqi",Header:s("lqi"),accessor:({state:e})=>e.linkquality,Cell:({row:{original:{state:e}}})=>a.jsx(q,{value:e.linkquality,name:"linkquality"})},...u,..._,{id:"power",Header:s("power"),accessor:({state:e,device:i})=>{var n;return[e.battery,(n=i.definition)==null?void 0:n.power].join(" ")},Cell:({row:{original:{state:e,device:i}}})=>a.jsx(M,{device:i,deviceState:e})},{id:"controls",Header:"",Cell:({row:{original:{device:e,state:i}}})=>a.jsx(I,{device:e,state:i,homeassistantEnabled:d,renameDevice:c,removeDevice:m,configureDevice:v,setDeviceDescription:p,interviewDevice:b}),disableSortBy:!0}],[u,_,s,d,c,m,v,b]);return a.jsx("div",{className:"card",children:a.jsx("div",{className:"table-responsive",children:a.jsx(R,{id:B,columns:y,data:t})})})}function G(l){var y,e;const{devices:t,deviceStates:o,bridgeInfo:{config:r},availability:d}=l,{renameDevice:p,removeDevice:c,configureDevice:m,setDeviceDescription:v,interviewDevice:b}=l,s=!!((y=r.availability)!=null&&y.enabled),u=!!((e=r==null?void 0:r.homeassistant)!=null&&e.enabled),g=()=>Object.values(t).filter(i=>i.type!=="Coordinator").map(i=>{var D;const n=o[i.friendly_name]??{};return{id:i.friendly_name,disabled:L(i,r),device:i,state:n,availabilityState:d[i.friendly_name]??"offline",availabilityEnabledForDevice:(D=r.devices[i.ieee_address])==null?void 0:D.availability}}),_=H.useMemo(()=>g(),[t,o]);return a.jsx(z,{data:_,lastSeenType:r.advanced.last_seen,availabilityFeatureEnabled:s,homeassistantEnabled:u,renameDevice:p,removeDevice:c,configureDevice:m,setDeviceDescription:v,interviewDevice:b})}const O=["devices","deviceStates","bridgeInfo","availability"],ae=k(O,S)(E(["zigbee","common"])(G));export{ae as ConnectedZigbeePage};
