import{u as C,a as g,r as S,A as _,j as s,N as $,F as a,aw as k,B as b,f,ay as D,S as L,L as p,az as y}from"./index-CE-9RlbR.js";import{D as z}from"./DeviceImage-Bcp15E0n.js";import{D as N}from"./DebouncedInput-D3cHKuwF.js";import{u as w}from"./useSearch-B79j3YUN.js";import"./envs-CRUy-_iG.js";import"./index-CDoSh7QA.js";function M(){const{t}=C("common"),r=g(e=>e.devices),m=g(e=>e.recentActivity),[h,o,x]=w(),[u,l,j]=w(),d=S.useMemo(()=>{const e=[];for(let i=0;i<_.length;i++){const n=m[i],I=r[i];for(const v in n){const c=I.find(A=>A.friendly_name===v);c!==void 0&&(o.length===0||c.friendly_name.toLowerCase().includes(o))&&e.push({sourceIdx:i,device:c,activity:n[v],highlighted:l.length>0&&c.friendly_name.toLowerCase().includes(l)})}}return e.sort((i,n)=>n.activity.timestamp-i.activity.timestamp),e},[m,r,o,l]);return s.jsxs(s.Fragment,{children:[s.jsxs($,{children:[s.jsxs("div",{className:"join",children:[s.jsxs("label",{className:"input input-sm join-item",children:[s.jsx(a,{icon:k}),s.jsx(N,{onChange:x,placeholder:t(e=>e.search,{ns:"common"}),value:h,disabled:d.length===0})]}),s.jsx(b,{item:"",onClick:x,className:"btn btn-sm btn-square btn-warning btn-outline join-item",title:t(e=>e.clear,{ns:"common"}),disabled:h.length===0,children:s.jsx(a,{icon:f})})]}),s.jsxs("div",{className:"join me-1",children:[s.jsxs("label",{className:"input input-sm join-item",children:[s.jsx(a,{icon:D}),s.jsx(N,{onChange:j,placeholder:t(e=>e.highlight,{ns:"common"}),value:u,disabled:d.length===0})]}),s.jsx(b,{item:"",onClick:j,className:"btn btn-sm btn-square btn-warning btn-outline join-item",title:t(e=>e.clear,{ns:"common"}),disabled:u==="",children:s.jsx(a,{icon:f})})]})]}),s.jsx("div",{className:"flex flex-col mb-5",children:s.jsx("ul",{className:"list bg-base-100",children:d.map(e=>s.jsxs("li",{className:`list-row p-2 ${e.highlighted?"bg-accent text-accent-content":""}`,children:[s.jsx("div",{className:"size-10",children:s.jsx(z,{device:e.device,disabled:e.device.disabled,noIndicator:!0})}),s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx(L,{idx:e.sourceIdx,autoHide:!0,namePostfix:" –",className:"me-1"}),s.jsx(p,{to:`/device/${e.sourceIdx}/${e.device.ieee_address}/info`,className:"link link-hover font-semibold truncate",children:e.device.friendly_name})]}),s.jsx("div",{className:"text-xs font-semibold min-w-0",children:s.jsxs("p",{className:"text-xs text-base-content/70 truncate",children:["[",new Date(e.activity.timestamp).toLocaleString(),"] ",e.activity.desc]})})]}),s.jsx(p,{to:`/device/${e.sourceIdx}/${e.device.ieee_address}/info`,className:"btn btn-square btn-ghost",children:s.jsx(a,{icon:y})})]},`${e.device.friendly_name}-${e.sourceIdx}-${e.activity}`))})})]})}export{M as default};
