import{u as C,a as g,r as S,A as _,j as s,N as $,F as t,aq as k,B as b,f,as as D,S as L,L as p,at as q}from"./index-KAtljJVt.js";import{D as T}from"./DeviceImage-BIyKFxKY.js";import{D as N}from"./DebouncedInput-BwaHeQMe.js";import{u as w}from"./useSearch-DmlCvOGy.js";import"./envs-CSqIi4cL.js";import"./index-B0hOIgnO.js";import"./defineProperty-CegpTSss.js";function P(){const{t:a}=C("common"),d=g(e=>e.devices),m=g(e=>e.recentActivity),[h,o,x]=w(),[u,l,j]=w(),r=S.useMemo(()=>{const e=[];for(let i=0;i<_.length;i++){const n=m[i],I=d[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,d,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(t,{icon:k}),s.jsx(N,{onChange:x,placeholder:a(e=>e.search,{ns:"common"}),value:h,disabled:r.length===0})]}),s.jsx(b,{item:"",onClick:x,className:"btn btn-sm btn-square btn-warning btn-outline join-item",title:a(e=>e.clear,{ns:"common"}),disabled:h.length===0,children:s.jsx(t,{icon:f})})]}),s.jsxs("div",{className:"join me-1",children:[s.jsxs("label",{className:"input input-sm join-item",children:[s.jsx(t,{icon:D}),s.jsx(N,{onChange:j,placeholder:a(e=>e.highlight,{ns:"common"}),value:u,disabled:r.length===0})]}),s.jsx(b,{item:"",onClick:j,className:"btn btn-sm btn-square btn-warning btn-outline join-item",title:a(e=>e.clear,{ns:"common"}),disabled:u==="",children:s.jsx(t,{icon:f})})]})]}),s.jsx("div",{className:"flex flex-col mb-5",children:s.jsx("ul",{className:"list bg-base-100",children:r.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(T,{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(t,{icon:q})})]},`${e.device.friendly_name}-${e.sourceIdx}-${e.activity}`))})})]})}export{P as default};
