import{a1 as v,a6 as C,u as j,r as l,j as a,a7 as u,B as h}from"./index-B_eahVWI.js";import{C as m}from"./CheckboxField-CzUa3ISp.js";const g=v.create(({sourceIdx:i,device:r,removeDevice:d})=>{const s=C(),{t:o}=j(["zigbee","common"]),[c,f]=l.useState({block:!1,force:!1,clearCache:!1}),t=l.useCallback(e=>{const{checked:n,name:b}=e.target;f(x=>({...x,[b]:n}))},[]),k=l.useCallback(async()=>{s.remove(),await d(i,r.ieee_address,c.force,c.block,c.clearCache)},[i,s,d,r.ieee_address,c]);return l.useEffect(()=>{const e=n=>{n.key==="Escape"&&(n.preventDefault(),s.remove())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]),a.jsx(u,{isOpen:s.visible,title:`${o(e=>e.remove_device)} ${r.friendly_name}`,footer:a.jsxs(a.Fragment,{children:[a.jsx(h,{className:"btn btn-neutral",onClick:s.remove,children:o(e=>e.cancel,{ns:"common"})}),a.jsx(h,{className:"btn btn-error ms-1",onClick:k,children:o(e=>e.delete,{ns:"common"})})]}),children:a.jsxs("div",{className:"flex flex-col gap-2",children:[a.jsx(m,{label:o(e=>e.force_remove),name:"force",onChange:t,checked:c.force}),a.jsx("span",{className:"text-xs opacity-50",children:o(e=>e.force_remove_notice)}),a.jsx(m,{label:o(e=>e.block_join),name:"block",onChange:t,checked:c.block}),a.jsx(m,{label:o(e=>e.clear_cache),name:"clearCache",onChange:t,checked:c.clearCache})]})})});export{g as R};
