import{r as f,u as N,j as s,L as u,S as w,F as y,dm as L}from"./index-VJpwYvBU.js";import{F}from"./startCase-DNIChZAc.js";import{g as $}from"./index-C1LTvZEM.js";import{L as _}from"./LastSeen-YOzeyMXj.js";import{L as D}from"./Lqi-BLanrDho.js";import{P as k}from"./PowerSource-B4Kn6y4z.js";import{D as q}from"./DeviceImage-DAL8fj7m.js";const K=f.memo(({onChange:m,onRead:c,sourceIdx:i,hideSourceDot:j,device:e,endpoint:o,deviceState:t,lastSeenConfig:b,features:x,featureWrapperClass:d,children:h})=>{const{t:l}=N(["zigbee","common"]),n=o!=null?e.endpoints[o]?.name:void 0,g=f.useMemo(()=>{const a=[];for(const r of x){const p=o!=null&&!!r.endpoint;(!p||Number(r.endpoint)===o||r.endpoint===n)&&a.push(s.jsx(F,{feature:r,device:e,deviceState:t,onChange:m,onRead:c,featureWrapperClass:d,minimal:!0,parentFeatures:[],endpointSpecific:p},$(r)))}return a},[n,e,o,t,x,d,m,c]);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"card-body p-2",children:[s.jsxs("div",{className:"flex flex-row items-center gap-3 w-full",children:[s.jsx("div",{className:"flex-none h-11 w-11 overflow-visible",children:s.jsx(q,{disabled:!1,device:e,otaState:t.update?.state})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs(u,{to:`/device/${i}/${e.ieee_address}/info`,className:"link link-hover font-semibold",children:[e.friendly_name,o!=null?` (${l(a=>a.endpoint)}: ${n?`${n} / `:""}${o})`:""]}),e.description&&s.jsx("div",{className:"text-xs opacity-50 truncate",title:e.description,children:e.description}),s.jsx("div",{className:"text-xs opacity-50",children:s.jsx(_,{lastSeen:t.last_seen,config:b})}),!j&&s.jsx("span",{className:"absolute top-2 right-2",children:s.jsx(w,{idx:i,autoHide:!0})})]})]}),s.jsx("div",{className:"text-sm w-full p-2",children:g}),s.jsx("div",{className:"flex flex-row justify-end mb-2",children:s.jsxs(u,{to:`/device/${i}/${e.ieee_address}/exposes`,className:"btn btn-xs",children:[l(a=>a.exposes,{ns:"common"})," ",s.jsx(y,{icon:L,size:"lg"})]})})]}),s.jsxs("div",{className:"flex flex-row flex-wrap gap-1 mx-2 mb-2 justify-around items-center",children:[s.jsx("span",{className:"badge badge-soft badge-ghost cursor-default tooltip","data-tip":l(a=>a.lqi),children:s.jsx(D,{value:t.linkquality})}),s.jsx("span",{className:"badge badge-soft badge-ghost cursor-default tooltip","data-tip":l(a=>a.power),children:s.jsx(k,{device:e,batteryPercent:t.battery,batteryState:t.battery_state,batteryLow:t.battery_low,showLevel:!0})}),h]})]})});export{K as D};
