import{dG as _,dB as g,dq as $,a as k,dm as s,R as A,o as a,bO as D,B as b,aN as f,bR as S,a0 as L,x as p,aj as R}from"./index-D_pphaE2.js";import{D as q}from"./DeviceImage-DUp2lC9c.js";import{D as N}from"./DebouncedInput-BeTJlfEr.js";import{u as w}from"./useSearch-CNGHbERn.js";import"./envs-CRUy-_iG.js";import"./index-DgIuNtLX.js";import"./defineProperty-CegpTSss.js";function P(){const{t}=_("common"),r=g(e=>e.devices),m=g(e=>e.recentActivity),[h,o,x]=w(),[u,l,j]=w(),d=$.useMemo(()=>{const e=[];for(let i=0;i<k.length;i++){const n=m[i],I=r[i];for(const v in n){const c=I.find(C=>C.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(A,{children:[s.jsxs("div",{className:"join",children:[s.jsxs("label",{className:"input input-sm join-item",children:[s.jsx(a,{icon:D}),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:S}),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(q,{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:R})})]},`${e.device.friendly_name}-${e.sourceIdx}-${e.activity}`))})})]})}export{P as default};
