import{r as t,W as I,y as C,a as r,b as _,R as P,S as w,T as N,j as s,L as T,B as m,F as k,U as x,V as v,X as S}from"./index-vDL8KyrI.js";import{T as F}from"./Table-DDSIa7cd.js";import"./DebouncedInput-DpBqTOhq.js";function q(){const{sendMessage:i}=t.useContext(I),a=C(),b=r(e=>e.touchlinkDevices),d=r(e=>e.devices),o=r(e=>e.touchlinkIdentifyInProgress),c=r(e=>e.touchlinkResetInProgress),h=r(e=>e.touchlinkScanInProgress),u=o||c,{t:n}=_(["touchlink","common","zigbee"]),j=t.useCallback(async()=>{a(P({inProgress:!0,devices:[]})),await i("bridge/request/touchlink/scan","")},[i,a]),f=t.useCallback(async e=>{a(w(!0)),await i("bridge/request/touchlink/identify",e)},[i,a]),g=t.useCallback(async e=>{a(N(!0)),await i("bridge/request/touchlink/factory_reset",e)},[i,a]),p=t.useMemo(()=>[{header:n("zigbee:ieee_address"),accessorFn:e=>e.ieee_address,cell:({row:{original:e}})=>d.find(l=>l.ieee_address===e.ieee_address)?s.jsx(T,{to:`/device/${e.ieee_address}/info`,className:"link link-hover",children:e.ieee_address}):e.ieee_address},{header:n("common:friendly_name"),accessorFn:e=>{var l;return(l=d.find(y=>y.ieee_address===e.ieee_address))==null?void 0:l.friendly_name}},{id:"channel",header:n("zigbee:channel"),accessorFn:e=>e.channel},{id:"actions",header:"",cell:({row:{original:e}})=>s.jsxs("div",{className:"join join-vertical lg:join-horizontal",children:[s.jsx(m,{disabled:u,item:e,title:n("identify"),className:"btn btn-primary join-item",onClick:f,children:s.jsx(k,{icon:o?x:v,spin:o})}),s.jsx(m,{disabled:u,item:e,title:n("factory_reset"),className:"btn btn-error join-item",onClick:g,children:s.jsx(k,{icon:c?x:S,spin:c})})]}),enableSorting:!1,enableColumnFilter:!1}],[o,c,u,d,n,f,g]);return h?s.jsx("div",{className:"flex flex-row justify-center items-center gap-2",children:s.jsx("span",{className:"loading loading-infinity loading-xl"})}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex flex-row flex-wrap justify-center items-center gap-2 mb-3",children:s.jsx(m,{className:"btn btn-primary",onClick:j,disabled:h,children:n("scan")})}),s.jsx(F,{id:"touchlink-devices",columns:p,data:b})]})}export{q as default};
