import{T as D,dC as G,dG as N,dq as o,dm as e,N as V,B as v,o as j,b7 as H,dB as f,dF as h,dx as b,x as g,b9 as B,t as y,aF as J,cz as C,_ as W,J as K,dA as Q,a0 as S,a as Z,a6 as E}from"./index-DjbVAZHL.js";import{s as X}from"./snakeCase-Dg4N4ThO.js";import{O as Y,D as ee,A as se,a as te}from"./oui-CxSFHEtQ.js";import{T as ne}from"./TextareaField-CDvERvhg.js";import{D as ae}from"./DeviceImage-Bsu1Hk6P.js";import{h as ie}from"./index-BzinHeAr.js";import{f as oe,O as re}from"./OtaControlGroup-C0FUugn7.js";import{D as le,V as ce}from"./VendorLink-CYoZa7Lj.js";import{D as de}from"./DisplayValue-e_yVQGok.js";import{L as me}from"./LastSeen-TlG8TNPK.js";import{P as pe}from"./PowerSource-DwoxK9gS.js";import"./envs-CRUy-_iG.js";import"./_createCompounder-CI5okWsL.js";import"./isObjectLike-DlSfHoCn.js";import"./RemoveDeviceModal-C6cax91v.js";import"./CheckboxField-h2bgaDmU.js";import"./InputField-D1U5kSs2.js";import"./defineProperty-CegpTSss.js";import"./floating-ui.react-B9Qqkq_g.js";import"./floating-ui.dom-CFVCCol6.js";import"./SelectField-XDAy-a1R.js";import"./TimeAgo-B6rAagzx.js";const be=D.create(({device:n,setDeviceDescription:s})=>{const a=G(),{t:i}=N(["zigbee","common"]),[r,m]=o.useState(n.description||"");return o.useEffect(()=>{m(n.description||"")},[n.description]),o.useEffect(()=>{const c=x=>{x.key==="Escape"&&(x.preventDefault(),a.remove())};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[a]),e.jsx(V,{isOpen:a.visible,title:`${i(c=>c.update_description)} ${n.friendly_name}`,footer:e.jsxs(e.Fragment,{children:[e.jsx(v,{className:"btn btn-neutral",onClick:a.remove,children:i(c=>c.cancel,{ns:"common"})}),e.jsx(v,{className:"btn btn-primary ms-1",onClick:async()=>{a.remove(),await s(n.ieee_address,r)},children:i(c=>c.save_description)})]}),children:e.jsx("div",{className:"flex flex-col gap-2",children:e.jsx(ne,{label:i(c=>c.description),name:"update_description",onChange:c=>m(c.target.value),rows:3,value:r})})})}),xe=o.memo(({device:n,setDeviceDescription:s})=>{const{t:a}=N("zigbee");return e.jsx(v,{className:`btn btn-link btn-md ${n.description?"btn-square":""} tooltip-bottom`,onClick:async()=>await D.show(be,{device:n,setDeviceDescription:s}),title:a(i=>i.edit_description),children:n.description?e.jsx(j,{icon:H}):a(i=>i.edit_description)})}),ue=/\[(.*?)]\((.*?)\)/,fe={native:"badge-success",external:"badge-info",generated:"badge-warning"},he=(n,s)=>{if(!(n==="bindings"||n==="configured_reportings"||n==="scenes"))return s},_e=o.memo(({sourceIdx:n,device:s})=>{const{t:a}=N("zigbee"),i=f(h(m=>m.bridgeInfo[n])),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,he)}
\`\`\``};return e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:`${E}?${new URLSearchParams(r).toString()}`,className:"link link-hover",children:a(m=>m.submit_converter)})}),je=o.memo(({sourceIdx:n,device:s})=>{const{t:a}=N("zigbee"),i=f(h(d=>d.bridgeInfo[n])),r=f(h(d=>d.bridgeHealth[n])),m=s.definition;if(!m)return null;const c=m.model!==s.model_id?` (${m.model})`:"",x={template:"problem_report.yaml",title:`[${s.model_id}${c} / ${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:a(d=>d.report_problem)})});function ze({sourceIdx:n,device:s}){const{t:a}=N(["zigbee","availability","common","ota"]),i=f(h(t=>t.deviceStates[n])),r=f(h(t=>t.bridgeInfo[n].config)),m=f(h(t=>t.availability[n])),c=f(h(t=>t.recentActivity[n])),x=r.homeassistant.enabled,d=i[s.friendly_name]??{},w=c[s.friendly_name],O=o.useMemo(()=>ie(s),[s]),_=o.useMemo(()=>oe(d.update?.installed_version),[d.update?.installed_version]),U=o.useMemo(()=>Y.get(s.ieee_address.slice(2,8))??"?",[s.ieee_address]),L=o.useCallback(async(t,l)=>{await b(n,"bridge/request/device/options",{id:t,options:{description:l}})},[n]),k=o.useCallback(async(t,l,p,u)=>{await b(t,"bridge/request/device/rename",{from:l,to:p,homeassistant_rename:u,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})},[]),P=o.useCallback(async(t,l,p,u)=>{await b(t,"bridge/request/device/remove",{id:l,force:p,block:u})},[]),A=o.useCallback(async({sourceIdx:t,ieee:l,...p})=>await b(t,"bridge/request/device/ota_update/check",{id:l,...p}),[]),I=o.useCallback(async({sourceIdx:t,ieee:l,downgrade:p,...u})=>await b(t,p?"bridge/request/device/ota_update/update/downgrade":"bridge/request/device/ota_update/update",{id:l,...u}),[]),R=o.useCallback(async({sourceIdx:t,ieee:l,downgrade:p,...u})=>await b(t,p?"bridge/request/device/ota_update/schedule/downgrade":"bridge/request/device/ota_update/schedule",{id:l,...u}),[]),F=o.useCallback(async({sourceIdx:t,ieee:l})=>await b(t,"bridge/request/device/ota_update/unschedule",{id:l}),[]),$=r.devices[s.ieee_address]?.availability,T=o.useMemo(()=>{const t=s.definition?.description?ue.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 y.Pending:return e.jsx(j,{icon:C,className:"text-info"});case y.InProgress:return e.jsx(j,{icon:C,spin:!0,className:"text-info"});case y.Successful:return e.jsx(j,{icon:J,className:"text-success"});default:return e.jsx(j,{icon:B,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(ae,{device:s,otaState:d.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(ee,{sourceIdx:n,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?fe[s.definition.source]:""}`,children:[e.jsx(de,{name:"supported",value:s.supported}),s.definition?`: ${s.definition.source}`:""]}),!s.supported&&e.jsx("span",{className:"badge",children:e.jsx(g,{target:"_blank",rel:"noopener noreferrer",to:W,className:"link link-hover",children:a(t=>t.how_to_add_support)})}),s.definition?.source==="external"&&e.jsx("span",{className:"badge",children:e.jsx(_e,{sourceIdx:n,device:s})}),e.jsxs("span",{className:"badge opacity-70 tooltip tooltip-bottom","data-tip":s.interview_state,children:[a(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(xe,{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:a(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":a(t=>t[X(s.power_source||"unknown")]),e.jsx("span",{className:"ms-3",children:e.jsx(pe,{showLevel:!0,device:s,batteryPercent:d.battery,batteryState:d.battery_state,batteryLow:d.battery_low})})]})]}),e.jsx("div",{className:"font-semibold text-base-content/70",children:a(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:a(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":a(t=>t.network_address_hex),children:e.jsx("span",{className:"font-mono",children:Q(s.network_address)})})}),e.jsxs("p",{className:"text-base-content/50",children:[a(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:a(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:s.manufacturer})]}),e.jsxs("div",{className:"font-semibold text-base-content/70",children:[a(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(le,{modelId:s.model_id,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(ce,{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:a(t=>t.firmware_id)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:s.software_build_id||"N/A"}),e.jsx("p",{className:"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:a(t=>t.firmware_version,{ns:"ota"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"font-semibold",children:[d.update?.installed_version??a(t=>t.unknown),e.jsx("span",{className:"ms-3",children:e.jsx(re,{sourceIdx:n,device:s,otaSettings:r.ota,state:d.update,onCheckClick:A,onUpdateClick:I,onScheduleClick:R,onUnscheduleClick:F})})]}),_?e.jsxs("p",{className:"text-base-content/50",children:[a(t=>t.app,{ns:"ota"}),": ",`${_[0]} build ${_[1]}`," | ",a(t=>t.stack,{ns:"ota"}),": ",`${_[2]} build ${_[3]}`]}):null]})]}):null,e.jsx("div",{className:"font-semibold text-base-content/70",children:a(t=>t.last_seen)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:e.jsx(me,{config:r.advanced.last_seen,lastSeen:d.last_seen,fallback:a(t=>t.disabled,{ns:"common"})})}),e.jsxs("p",{className:"text-base-content/50",children:[a(t=>t.availability,{ns:"availability"}),": ",e.jsx(se,{availability:m[s.friendly_name]?.state??"offline",disabled:s.disabled,availabilityFeatureEnabled:r.availability.enabled,availabilityEnabledForDevice:$!=null?!!$:void 0})]})]}),w&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:a(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(S,{idx:n,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:"-"})]}),K&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"font-semibold text-base-content/70",children:a(t=>t.source,{ns:"common"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-semibold",children:e.jsx(S,{idx:n,alwaysShowName:!0})}),e.jsx("p",{className:"text-base-content/50",children:Z[n]})]})]})]}),e.jsxs("div",{className:"card-actions justify-center md:justify-end mt-2 me-4",children:[s.supported&&e.jsx(je,{sourceIdx:n,device:s}),e.jsx(te,{sourceIdx:n,device:s,otaState:d.update?.state,homeassistantEnabled:x,renameDevice:k,configureDevice:M,interviewDevice:q,removeDevice:P})]})]})]})}export{ze as default};
