import{c as m,a as p,w as u,r as g,j as e,L as f,g as k,B as t,b as d}from"./index-fb4a4614.js";import{T as x}from"./ReactTableCom-5f5db069.js";import"./persist-47ba9205.js";class b extends g.Component{constructor(){super(...arguments),this.onIdentifyClick=n=>{const{touchlinkIdentify:i}=this.props;i(n)},this.onResetClick=n=>{const{touchlinkReset:i}=this.props;i(n)}}renderTouchlinkDevices(){const{touchlinkDevices:n,devices:i,touchlinkIdentifyInProgress:r,touchlinkResetInProgress:a,t:c}=this.props,o=r||a,h=[{Header:c("zigbee:ieee_address"),accessor:s=>s.ieee_address,Cell:({row:{original:s}})=>i[s.ieee_address]?e.jsx(f,{to:k(s.ieee_address),children:s.ieee_address}):s.ieee_address},{Header:c("zigbee:friendly_name"),accessor:s=>{var l;return(l=i[s.ieee_address])==null?void 0:l.friendly_name}},{id:"channel",Header:c("zigbee:channel"),accessor:"channel"},{id:"actions",Header:"",Cell:({row:{original:s}})=>e.jsxs("div",{className:"btn-group float-right",role:"group","aria-label":"Basic example",children:[e.jsx(t,{disabled:o,item:s,title:c("identify"),className:"btn btn-primary",onClick:this.onIdentifyClick,children:e.jsx("i",{className:d("fa",{"fa-exclamation-triangle":!r,"fas fa-circle-notch fa-spin":r})})}),e.jsx(t,{disabled:o,item:s,title:c("factory_reset"),className:"btn btn-danger",onClick:this.onResetClick,children:e.jsx("i",{className:d("fa",{"fa-broom":!a,"fas fa-circle-notch fa-spin":a})})})]})}];return e.jsx("div",{className:"table-responsive",children:e.jsx(x,{id:"touchlinkDevices",columns:h,data:n})})}renderNoDevices(){const{touchlinkScan:n,t:i}=this.props;return e.jsx(t,{className:"btn btn-primary mx-auto d-block",onClick:n,children:i("scan")})}render(){const{touchlinkDevices:n,touchlinkScanInProgress:i,touchlinkScan:r,t:a}=this.props;return e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-header allign-middle",children:[a("detected_devices_message",{count:n.length}),e.jsx(t,{title:a("rescan"),className:"btn btn-primary btn-sm float-right",onClick:r,children:e.jsx("i",{className:"fa fa-sync"})})]}),e.jsx("div",{className:"card-body",children:i?e.jsx("div",{className:"d-flex justify-content-center",children:e.jsx("div",{className:"spinner-border",role:"status",children:e.jsx("span",{className:"sr-only",children:a("common:loading")})})}):n.length===0?this.renderNoDevices():this.renderTouchlinkDevices()})]})}}const j=["touchlinkDevices","devices","touchlinkScanInProgress","touchlinkIdentifyInProgress","touchlinkResetInProgress"],I=m(j,p)(u(["touchlink","zigbee","common"])(b));export{I as ConnectedTouchlinkPage};
