import{Y as p,a3 as h,u as v,r as b,j as e,a4 as y,B as f,F as u,a5 as w,aV as x,a6 as _,aY as g,I as k,Z as C,aZ as E}from"./index-ClCsMWbS.js";import{R as D}from"./RemoveDeviceModal-Dcccpw6_.js";import{C as N}from"./CheckboxField-BxtT6ttj.js";import{I}from"./InputField-CqTVHKf8.js";const A=p.create(({sourceIdx:l,homeassistantEnabled:t,name:i,renameDevice:m})=>{const o=h(),{t:r}=v(["zigbee","common"]),[s,j]=b.useState(!1),[d,c]=b.useState(i);return b.useEffect(()=>{c(i)},[i]),b.useEffect(()=>{const n=a=>{a.key==="Escape"&&(a.preventDefault(),o.remove())};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[o]),e.jsx(y,{isOpen:o.visible,title:`${r(n=>n.rename_device)} ${i}`,footer:e.jsxs(e.Fragment,{children:[e.jsx(f,{className:"btn btn-neutral",onClick:o.remove,children:r(n=>n.cancel,{ns:"common"})}),e.jsx(f,{className:"btn btn-primary ms-1",onClick:async()=>{o.remove(),await m(l,i,d,s)},children:r(n=>n.rename_device)})]}),children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx(I,{name:"friendly_name",label:r(n=>n.friendly_name,{ns:"common"}),onChange:n=>c(n.target.value),value:d,type:"text"}),t&&e.jsx(N,{label:r(n=>n.update_Home_assistant_entity_id),name:"update_Home_assistant_entity_id",onChange:n=>j(n.target.checked),checked:s})]})})}),F=b.memo(({sourceIdx:l,name:t,homeassistantEnabled:i,style:m,renameDevice:o})=>{const{t:r}=v("zigbee");return e.jsx(f,{className:`btn ${m}`,onClick:async()=>await p.show(A,{sourceIdx:l,name:t,renameDevice:o,homeassistantEnabled:i}),title:r(s=>s.rename_device),children:e.jsx(u,{icon:w})})});function M({sourceIdx:l,device:t,otaState:i,homeassistantEnabled:m,renameDevice:o,configureDevice:r,interviewDevice:s,removeDevice:j,btnClassName:d=""}){const{t:c}=v(["zigbee","common"]),n=t.interview_state===x.InProgress||t.interview_state===x.Pending||i==="updating";return e.jsxs("div",{className:"join join-horizontal",children:[e.jsx(F,{sourceIdx:l,name:t.friendly_name,renameDevice:o,homeassistantEnabled:m,style:`btn-outline btn-primary join-item btn-square ${d}`}),e.jsx(_,{className:`btn btn-outline btn-warning join-item btn-square ${d}`,onClick:r,item:[l,t.ieee_address],title:c(a=>a.reconfigure),modalDescription:c(a=>a.dialog_confirmation_prompt,{ns:"common"}),modalCancelLabel:c(a=>a.cancel,{ns:"common"}),disabled:n,children:e.jsx(u,{icon:g})}),e.jsx(_,{className:`btn btn-outline btn-info join-item btn-square ${d}`,onClick:s,item:[l,t.ieee_address],title:c(a=>a.interview),modalDescription:c(a=>a.dialog_confirmation_prompt,{ns:"common"}),modalCancelLabel:c(a=>a.cancel,{ns:"common"}),disabled:n,children:e.jsx(u,{icon:k})}),e.jsx(f,{onClick:async()=>await p.show(D,{sourceIdx:l,device:t,removeDevice:j}),className:`btn btn-outline btn-error join-item btn-square ${d}`,title:c(a=>a.remove_device),children:e.jsx(u,{icon:C})})]})}const q=b.memo(l=>{const{t}=v("availability"),{availability:i,availabilityFeatureEnabled:m,availabilityEnabledForDevice:o,disabled:r}=l;return r?e.jsx("span",{children:t(s=>s.disabled)}):o??m?e.jsx("span",{className:i==="online"?"text-success":"text-error",children:t(s=>s[i])}):e.jsx("a",{className:"link link-hover",target:"_blank",rel:"noopener noreferrer",href:E,children:t(s=>s.disabled)})});export{q as A,M as D,F as a};
