import{N as x,e as y,r as v,u,j as e,M as g,f as N,h as k,k as _,B as p,b as j,x as S,I as w,y as M,J as R}from"./index-fb4a4614.js";const E=x.create(t=>{const n=y(),{homeassistantEnabled:a,device:s,renameDevice:o,setDeviceDescription:c}=t,[i,d]=v.useState(!1),[h,f]=v.useState(s.friendly_name),[r,m]=v.useState(s.description),{t:l}=u(["zigbee","common"]),C=async()=>{await o(s.friendly_name,h,i),n.remove()},D=async()=>{await c(s.friendly_name,r),n.remove()};return e.jsxs(g,{isOpen:n.visible,children:[e.jsxs(N,{children:[e.jsx("h3",{children:l("rename_device")}),e.jsx("small",{children:s.friendly_name})]}),e.jsxs(k,{children:[e.jsxs("div",{className:"card",children:[e.jsxs("div",{className:"card-body",children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"form-label",children:l("friendly_name")}),e.jsx("input",{onChange:b=>f(b.target.value),type:"text",className:"form-control",value:h})]}),a?e.jsxs("div",{className:"form-check form-switch",children:[e.jsx("input",{className:"form-check-input",checked:i,type:"checkbox",id:`hass${s.ieee_address}`,onChange:b=>d(b.target.checked)}),e.jsx("label",{className:"form-check-label",htmlFor:`hass${s.ieee_address}`,children:l("update_Home_assistant_entity_id")})]}):null]}),e.jsx("div",{className:"card-footer",children:e.jsx("button",{type:"button",className:"btn btn-primary",onClick:C,children:l("zigbee:rename_device")})})]}),e.jsxs("div",{className:"card",children:[e.jsx("div",{className:"card-body",children:e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"form-label",children:l("description")}),e.jsx("textarea",{rows:3,onChange:b=>m(b.target.value),className:"form-control",value:r})]})}),e.jsx("div",{className:"card-footer",children:e.jsx("button",{type:"button",className:"btn btn-primary",onClick:D,children:l("zigbee:save_description")})})]})]}),e.jsx(_,{children:e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:n.remove,children:l("common:close")})})]})}),F=x.create(t=>{const n=y(),{t:a}=u(["zigbee","common"]),{device:s,removeDevice:o}=t,[c,i]=v.useState({block:!1,force:!1}),d=[{label:a("force_remove"),name:"force",value:c.force},{label:a("block_join"),name:"block",value:c.block}],h=r=>{const{checked:m,name:l}=r.target;i({...c,[l]:m})},f=()=>{o(s.friendly_name,c.force,c.block),n.remove()};return e.jsxs(g,{isOpen:n.visible,children:[e.jsxs(N,{children:[e.jsx("h3",{children:a("remove_device")}),e.jsx("small",{children:s.friendly_name})]}),e.jsx(k,{children:d.map(r=>{const m=`${r.name}${s.ieee_address}`;return e.jsxs("div",{className:"form-check form-switch",children:[e.jsx("input",{className:"form-check-input",name:r.name,checked:r.value,type:"checkbox",id:m,onChange:h}),e.jsx("label",{className:"form-check-label",htmlFor:m,children:r.label})]},r.name)})}),e.jsxs(_,{children:[e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:n.remove,children:a("common:close")}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:f,children:a("common:delete")})]})]})});function L(t){const{homeassistantEnabled:n,device:a,configureDevice:s,renameDevice:o,removeDevice:c,setDeviceDescription:i}=t,{t:d}=u(["zigbee","common"]);return e.jsxs("div",{className:"btn-group btn-group-sm",role:"group",children:[e.jsx(p,{className:"btn btn-primary",onClick:()=>x.show(E,{device:a,renameDevice:o,setDeviceDescription:i,homeassistantEnabled:n}),title:d("rename_device"),children:e.jsx("i",{className:"fa fa-edit"})}),e.jsx(p,{className:"btn btn-warning",onClick:s,item:a.friendly_name,title:d("reconfigure"),prompt:!0,children:e.jsx("i",{className:j("fa","fa-retweet")})}),e.jsx("button",{onClick:()=>x.show(F,{device:a,removeDevice:c}),className:"btn btn-danger",title:d("remove_device"),children:e.jsx("i",{className:j("fa","fa-trash")})})]})}var z=w,A=M,$=R,H="[object String]";function O(t){return typeof t=="string"||!A(t)&&$(t)&&z(t)==H}var T=O;const B=S(T);function P(t){const{t:n}=u(["avaliability"]),{availability:a,availabilityFeatureEnabled:s=!0,availabilityEnabledForDevice:o=!0,disabled:c}=t;let i;return B(a)?i=a:i=a.state,i=i.toLowerCase(),c?e.jsx("span",{children:n("disabled")}):s&&o?e.jsx("span",{className:j({"text-danger animation-blinking":i==="offline","text-success":a==="online"}),children:n(i)}):e.jsx("a",{target:"_blank",rel:"noopener noreferrer",href:"https://www.zigbee2mqtt.io/guide/configuration/device-availability.html#availability-advanced-configuration",children:n("disabled")})}export{P as A,L as D,B as i};
