import{a1 as D,a6 as V,u as N,r as o,j as e,a7 as B,B as y,F as _,a8 as H,a as u,I as h,s as b,L as g,ap as J,aj as v,b5 as W,b6 as S,aB as K,b7 as Q,q as Z,b3 as X,M as Y,t as ee,S as $,A as se,b4 as E}from"./index-B_eahVWI.js";import{s as te}from"./snakeCase-CJzHmbbg.js";import{O as ne,a as ae,A as ie,D as oe}from"./oui-DZhdJrax.js";import{T as re}from"./TextareaField-DL3qwzHr.js";import{D as le}from"./DeviceImage-BuQphSNv.js";import{h as ce}from"./index-CDoSh7QA.js";import{f as de,b as me}from"./OtaControlGroup-DSxACZwU.js";import{D as pe,V as be}from"./VendorLink-BTghUeUV.js";import{L as xe}from"./LastSeen-DuqkpiII.js";import{P as fe}from"./PowerSource-C9PkIWWx.js";import"./envs-CRUy-_iG.js";import"./_createCompounder-KpkcgNnL.js";import"./isObjectLike-mS1hgzH9.js";import"./RemoveDeviceModal-C-C4nIYP.js";import"./CheckboxField-CzUa3ISp.js";import"./InputField-DBG-IjF8.js";import"./floating-ui.react-BHMQGHCG.js";import"./floating-ui.dom-D02yrJtw.js";import"./SelectField-JWPpuidh.js";import"./TimeAgo-D8Qg455l.js";const ue=D.create(({device:a,setDeviceDescription:s})=>{const n=V(),{t:i}=N(["zigbee","common"]),[r,m]=o.useState(a.description||"");return o.useEffect(()=>{m(a.description||"")},[a.description]),o.useEffect(()=>{const d=x=>{x.key==="Escape"&&(x.preventDefault(),n.remove())};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[n]),e.jsx(B,{isOpen:n.visible,title:`${i(d=>d.update_description)} ${a.friendly_name}`,footer:e.jsxs(e.Fragment,{children:[e.jsx(y,{className:"btn btn-neutral",onClick:n.remove,children:i(d=>d.cancel,{ns:"common"})}),e.jsx(y,{className:"btn btn-primary ms-1",onClick:async()=>{n.remove(),await s(a.ieee_address,r)},children:i(d=>d.save_description)})]}),children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(re,{label:i(d=>d.description),name:"update_description",onChange:d=>m(d.target.value),rows:3,value:r})})})}),he=o.memo(({device:a,setDeviceDescription:s})=>{const{t:n}=N("zigbee");return e.jsx(y,{className:`btn btn-link btn-md ${a.description?"btn-square":""} tooltip-bottom`,onClick:async()=>await D.show(ue,{device:a,setDeviceDescription:s}),title:n(i=>i.edit_description),children:a.description?e.jsx(_,{icon:H}):n(i=>i.edit_description)})}),_e=/\[(.*?)]\((.*?)\)/,je={native:"badge-success",external:"badge-info",generated:"badge-accent"},Ne={native:Z,external:Q,generated:K},ge=(a,s)=>{if(!(a==="bindings"||a==="configured_reportings"||a==="scenes"))return s},we=o.memo(({sourceIdx:a,device:s})=>{const{t:n}=N("zigbee"),i=u(h(m=>m.bridgeInfo[a])),r={template:"external_converter.yaml",title:`[External Converter]: ${s.model_id} from ${s.manufacturer}`,z2m_version:`${i.version} (${i.commit})`,notes:`
software_build_id: \`${s.software_build_id}\`
date_code: \`${s.date_code}\`
endpoints:
\`\`\`json
${JSON.stringify(s.endpoints,ge)}
\`\`\``};return e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:`${E}?${new URLSearchParams(r).toString()}`,className:"link link-hover",children:n(m=>m.submit_converter)})}),ve=o.memo(({sourceIdx:a,device:s})=>{const{t:n}=N("zigbee"),i=u(h(c=>c.bridgeInfo[a])),r=u(h(c=>c.bridgeHealth[a])),m=s.definition;if(!m)return null;const d=m.model!==s.model_id?` (${m.model})`:"",x={template:"problem_report.yaml",title:`[${s.model_id}${d} / ${s.manufacturer}] ???`,z2m_version:`${i.version} (${i.commit})`,adapter_fwversion:JSON.stringify(i.coordinator.meta),adapter:i.coordinator.type,setup:`os: \`${i.os.version}\`
node: \`${i.os.node_version}\`
ha: \`${i.config.homeassistant.enabled}\``,notes:`
#### Device
definition: \`${m.model}\` - \`${m.vendor}\` (\`v${m.version??"0.0.0"}\`)
software_build_id: \`${s.software_build_id}\`
date_code: \`${s.date_code}\`
endpoints:
\`\`\`json
${JSON.stringify(s.endpoints)}
\`\`\``};return r.response_time>0&&(x.notes+=`
##### Health
time: \`${new Date(r.response_time)}\`
os.load_average: \`${r.os.load_average.join(", ")}\`
os.memory_percent: \`${r.os.memory_percent}\`
process.memory_percent: \`${r.process.memory_percent}\`
process.uptime_sec: \`${Math.round(r.process.uptime_sec)}\`
\`\`\`json
${JSON.stringify(r.devices[s.ieee_address]??{})}
\`\`\`
`),e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:`${E}?${new URLSearchParams(x).toString()}`,className:"btn btn-ghost",children:n(c=>c.report_problem)})});function Ve({sourceIdx:a,device:s}){const{t:n}=N(["zigbee","availability","common","ota"]),i=u(h(t=>t.deviceStates[a])),r=u(h(t=>t.bridgeInfo[a].config)),m=u(h(t=>t.availability[a])),d=u(h(t=>t.recentActivity[a])),x=r.homeassistant.enabled,c=i[s.friendly_name]??{},w=d[s.friendly_name],O=o.useMemo(()=>ce(s),[s]),j=o.useMemo(()=>de(c.update?.installed_version),[c.update?.installed_version]),U=o.useMemo(()=>ne.get(s.ieee_address.slice(2,8))??"?",[s.ieee_address]),L=o.useCallback(async(t,l)=>{await b(a,"bridge/request/device/options",{id:t,options:{description:l}})},[a]),k=o.useCallback(async(t,l,p,f)=>{await b(t,"bridge/request/device/rename",{from:l,to:p,homeassistant_rename:f,last:void 0})},[]),M=o.useCallback(async([t,l])=>{await b(t,"bridge/request/device/configure",{id:l})},[]),q=o.useCallback(async([t,l])=>{await b(t,"bridge/request/device/interview",{id:l})},[]),A=o.useCallback(async(t,l,p,f,G)=>{await b(t,"bridge/request/device/remove",{id:l,force:p,block:f,clear_cache:G})},[]),I=o.useCallback(async({sourceIdx:t,ieee:l,...p})=>await b(t,"bridge/request/device/ota_update/check",{id:l,...p}),[]),P=o.useCallback(async({sourceIdx:t,ieee:l,downgrade:p,...f})=>await b(t,p?"bridge/request/device/ota_update/update/downgrade":"bridge/request/device/ota_update/update",{id:l,...f}),[]),R=o.useCallback(async({sourceIdx:t,ieee:l,downgrade:p,...f})=>await b(t,p?"bridge/request/device/ota_update/schedule/downgrade":"bridge/request/device/ota_update/schedule",{id:l,...f}),[]),F=o.useCallback(async({sourceIdx:t,ieee:l})=>await b(t,"bridge/request/device/ota_update/unschedule",{id:l}),[]),C=r.devices[s.ieee_address]?.availability,T=o.useMemo(()=>{const t=s.definition?.description?_e.exec(s.definition?.description):void 0;if(t){const[,l,p]=t;return e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:p,className:"link link-hover",children:l})}return e.jsx(e.Fragment,{children:s.definition?.description})},[s.definition]),z=o.useMemo(()=>{switch(s.interview_state){case v.Pending:return e.jsx(_,{icon:S,className:"text-info"});case v.InProgress:return e.jsx(_,{icon:S,spin:!0,className:"text-info"});case v.Successful:return e.jsx(_,{icon:W,className:"text-success"});default:return e.jsx(_,{icon:J,beat:!0,className:"text-error"})}},[s.interview_state]);return e.jsxs("div",{className:"card lg:card-side bg-base-100",children:[e.jsx("figure",{className:"w-64 h-64",style:{overflow:"visible"},children:e.jsx(le,{device:s,otaState:c.update?.state,disabled:s.disabled,noIndicator:!0})}),e.jsxs("div",{className:"card-body py-0 px-3",children:[e.jsxs("h2",{className:"card-title",children:[s.friendly_name,e.jsx(ae,{sourceIdx:a,name:s.friendly_name,renameDevice:k,homeassistantEnabled:x,style:"btn-link btn-md btn-square"})]}),e.jsxs("div",{className:"flex flex-row flex-wrap gap-2",children:[e.jsxs("span",{className:`badge ${s.definition?je[s.definition.source]:""}`,children:[s.definition?e.jsx(_,{icon:Ne[s.definition.source]}):null,n(t=>s.definition?t[s.definition.source]:t.unsupported)]}),!s.supported&&e.jsx("span",{className:"badge",children:e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:X,className:"link link-hover",children:n(t=>t.how_to_add_support)})}),s.definition?.source==="external"&&e.jsx("span",{className:"badge",children:e.jsx(we,{sourceIdx:a,device:s})}),e.jsxs("span",{className:"badge opacity-70 tooltip tooltip-bottom","data-tip":s.interview_state,children:[n(t=>t.interview_state),": ",z]})]}),e.jsxs("div",{className:"flex flex-row flex-wrap items-center text-wrap break-all text-base-content/70",children:[s.description||"",e.jsx(he,{device:s,setDeviceDescription:L})]}),e.jsxs("div",{className:"grid grid-cols-[max-content_1fr] gap-x-3 gap-y-2 text-wrap",children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.type)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:s.type}),e.jsxs("p",{className:"text-base-content/50",children:[s.type==="GreenPower"?"GreenPower":n(t=>t[te(s.power_source||"unknown")]),e.jsx("span",{className:"ms-3",children:e.jsx(fe,{showLevel:!0,device:s,batteryPercent:c.battery,batteryState:c.battery_state,batteryLow:c.battery_low})})]})]}),e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.ieee_address)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold font-mono",children:s.ieee_address}),e.jsx("p",{className:"text-base-content/50",children:e.jsxs("span",{className:"tooltip tooltip-bottom",children:[e.jsxs("span",{className:"tooltip-content",children:["Organizationally Unique Identifier",e.jsx("br",{}),"(IEEE Vendor Prefix)"]}),"OUI: ",U]})})]}),e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.network_address)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:e.jsx("span",{className:"tooltip tooltip-bottom","data-tip":n(t=>t.network_address_hex),children:e.jsx("span",{className:"font-mono",children:ee(s.network_address)})})}),e.jsxs("p",{className:"text-base-content/50",children:[n(t=>t.network_address_dec),": ",e.jsx("span",{className:"font-mono",children:s.network_address})]})]}),e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.zigbee_model)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold break-all",children:s.model_id}),e.jsx("p",{className:"text-base-content/50",children:e.jsx("span",{className:"tooltip tooltip-bottom","data-tip":n(t=>t.zigbee_manufacturer),children:s.manufacturer})})]}),e.jsxs("div",{className:"font-semibold text-base-content/70",children:[n(t=>t.definition,{ns:"common"})," (Zigbee2MQTT)"]}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-semibold break-all",children:[e.jsx(pe,{supported:s.supported,definitionModel:s.definition?.model,icon:!0}),s.definition?.version&&s.definition.version!=="0.0.0"?` (v${s.definition.version})`:null]}),e.jsxs("p",{className:"text-base-content/50",children:[T,e.jsx("br",{}),e.jsx(be,{supported:s.supported,definitionVendor:s.definition?.vendor,icon:!0})]})]}),s.software_build_id?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.firmware_id)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-mono font-semibold",children:s.software_build_id||"N/A"}),e.jsx("p",{className:"font-mono text-base-content/50",children:s.date_code||"N/A"})]})]}):null,O?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.firmware_version,{ns:"ota"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-semibold",children:[c.update?.installed_version?e.jsx("span",{className:"font-mono",children:c.update.installed_version}):e.jsx("span",{children:n(t=>t.not_assessed,{ns:"common"})}),e.jsx("span",{className:"ms-3",children:e.jsx(me,{sourceIdx:a,device:s,otaSettings:r.ota,state:c.update,onCheckClick:I,onUpdateClick:P,onScheduleClick:R,onUnscheduleClick:F})})]}),j?e.jsxs("p",{className:"text-base-content/50",children:[n(t=>t.app,{ns:"ota"}),": ",`${j[0]} build ${j[1]}`," | ",n(t=>t.stack,{ns:"ota"}),": ",`${j[2]} build ${j[3]}`]}):null]})]}):null,e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.last_seen)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:e.jsx(xe,{config:r.advanced.last_seen,lastSeen:c.last_seen,fallback:n(t=>t.disabled,{ns:"common"})})}),e.jsxs("p",{className:"text-base-content/50",children:[n(t=>t.availability,{ns:"availability"}),": ",e.jsx(ie,{availability:m[s.friendly_name]?.state??"offline",disabled:s.disabled,availabilityFeatureEnabled:r.availability.enabled,availabilityEnabledForDevice:C!=null?!!C:void 0})]})]}),w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.recent_activity,{ns:"common"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-semibold break-all",children:[e.jsx($,{idx:a,autoHide:!0}),w.desc]}),e.jsx("p",{className:"text-base-content/50",children:new Date(w.timestamp).toLocaleString()})]})]}),e.jsx("div",{className:"font-semibold text-base-content/70",children:"MQTT"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-semibold break-all",children:[r.mqtt.base_topic,"/",s.friendly_name]}),e.jsx("p",{className:"text-base-content/0",children:"-"})]}),Y&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:n(t=>t.source,{ns:"common"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:e.jsx($,{idx:a,alwaysShowName:!0})}),e.jsx("p",{className:"text-base-content/50",children:se[a]})]})]})]}),e.jsxs("div",{className:"card-actions justify-center md:justify-end mt-2 me-4",children:[e.jsx(ve,{sourceIdx:a,device:s}),e.jsx(oe,{sourceIdx:a,device:s,otaState:c.update?.state,homeassistantEnabled:x,renameDevice:k,configureDevice:M,interviewDevice:q,removeDevice:A})]})]})]})}export{Ve as default};
