matterbridge 3.4.3-dev-20251207-895bbc3 → 3.4.3-dev-20251208-0c8a552

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{B as e,y as r,S as dt,U as Ir,V as Dr,X as Ue,Y as Pr,Z as Lr,I as $r}from"./vendor_node_modules.js";import{u as Wr,S as Nr}from"./vendor_notistack.js";import{D as Ne,a as Te,b as Fe,B as ae,c as Ae,F as ze,C as Ve,d as Y,A as Tr,I as Q,e as Fr,f as Rr,T as V,g as he,M as Hr,h as Ye,i as P,j as De,k as Or,l as wt,m as Vr,n as le,K as Ot,o as Vt,p as Nt,L as ct,q as ot,r as pt,s as B,W as it,t as ut,H as gt,u as X,V as Et,v as At,w as Er,E as Ar,Q as or,R as Ct,S as _r,x as qr,U as zr,P as Ur,y as nr,z as ir,G as Pe,J as sr,N as ar,O as St,X as lr,Y as Br,Z as Qr,_ as Kr,$ as Gr,a0 as Jr,a1 as _t,a2 as Zr,a3 as Yr,a4 as Xr,a5 as eo,a6 as to,a7 as ro,a8 as oo,a9 as qt,aa as no,ab as io,ac as so,ad as ao,ae as lo,af as co,ag as po,ah as uo,ai as go,aj as mo,ak as ho,al as fo,am as xo,an as bo,ao as vo,ap as zt,aq as Xe,ar as dr,as as Se,at as cr,au as Mt,av as Ee,aw as yo,ax as jo,ay as wo,az as qe,aA as Co,aB as mt,aC as Be,aD as It,aE as So,aF as Mo}from"./vendor_mui.js";import{I as ne,m as ko,a as Ut,b as Io,c as Do,d as Bt,e as Po,f as Lo,g as $o,h as Wo,i as No,j as To,k as Fo,l as Ro,n as Ho,o as Oo,p as Vo,q as Eo,r as Qt,s as Ao,t as _o,u as qo,v as zo,w as Uo,x as Bo,y as Qo,z as Ko,A as Kt,B as Go,C as Jo}from"./vendor_mdi.js";import{Q as Zo}from"./vendor_qrcode.js";import{F as Yo,v as Xo,e as en,a as tn,g as rn,b as on,c as nn,d as Dt,A as sn}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const d=document.createElement("link").relList;if(d&&d.supports&&d.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const h of a)if(h.type==="childList")for(const u of h.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&i(u)}).observe(document,{childList:!0,subtree:!0});function l(a){const h={};return a.integrity&&(h.integrity=a.integrity),a.referrerPolicy&&(h.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?h.credentials="include":a.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function i(a){if(a.ep)return;a.ep=!0;const h=l(a);fetch(a.href,h)}})();function an({open:n,title:d,message:l,onConfirm:i,onCancel:a}){const h=v=>{o&&console.log("Confirmed"),v.preventDefault(),i()},u=v=>{o&&console.log("Canceled"),v.preventDefault(),a()};return e.jsxs(Ne,{open:n,children:[e.jsx(Te,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:d})]})}),e.jsxs(Fe,{children:[e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"0",marginBottom:"20px",maxHeight:"350px",maxWidth:"350px"},children:e.jsx("p",{style:{flex:1,margin:"0"},children:l})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(ae,{onClick:h,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ae,{onClick:u,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const ln=({open:n,output:d,title:l,_command:i,_packageName:a,onInstall:h,onClose:u})=>{const{installAutoExit:v,setInstallAutoExit:t}=r.useContext(Le),I=r.useRef(null),y=C=>{t(C.target.checked),localStorage.setItem("installAutoExit",C.target.checked?"true":"false"),o&&console.log("handleInstallAutoExitChange called with value:",C.target.checked)};return r.useEffect(()=>{o&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${I.current}`),setTimeout(()=>{o&&console.log("Scrolling to bottom:",I.current),I.current?.scrollIntoView({behavior:"smooth",block:"end"})},0)},[d]),e.jsxs(Ne,{open:n,onClose:(C,S)=>{S==="backdropClick"||S==="escapeKeyDown"||u()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx(Te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:l})]})}),e.jsxs(Fe,{dividers:!0,style:{overflow:"hidden",display:"flex",flexDirection:"column",height:400,paddingBottom:0},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"16px",fontWeight:"bold",color:"var(--primary-color)"},children:"Process log"}),e.jsxs("ul",{style:{width:"100%",height:"100%",fontFamily:"monospace",fontSize:"14px",padding:"10px",margin:0,marginBottom:"10px",color:"var(--div-text-color)",background:"var(--div-bg-color)",overflow:"auto",listStyle:"none",boxSizing:"border-box",borderRadius:4,border:"4px solid var(--primary-color)",whiteSpace:"pre-wrap",display:"block"},children:[d.split(`
2
- `).map((C,S)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:C},S)),e.jsx("li",{ref:I,style:{padding:0,margin:0}})]})]}),e.jsxs(Ae,{sx:{justifyContent:"space-evenly"},children:[h&&e.jsx(ae,{variant:"contained",onClick:h,children:"Install"}),e.jsx(ae,{onClick:u,children:"Close"}),e.jsx(ze,{control:e.jsx(Ve,{checked:v,onChange:C=>y(C)}),label:"Close on success",style:{color:"var(--div-text-color)"}})]})]})},ht=[],Le=r.createContext(null);function dn({children:n}){const[d,l]=r.useState(!1),[i,a]=r.useState(null),{enqueueSnackbar:h,closeSnackbar:u}=Wr(),v=r.useCallback(M=>{o&&console.log(`UiProvider closeSnackbarMessage: message ${M}`);const L=ht.findIndex(K=>K.message===M);L!==-1&&(u(ht[L].key),ht.splice(L,1),o&&console.log(`UiProvider closeSnackbarMessage: message ${M} removed from persistMessages`))},[u]),t=r.useCallback((M,L,K)=>{o&&console.log(`UiProvider showSnackbarMessage: message ${M} timeout ${L}`);const se=h(M,{variant:"default",autoHideDuration:L==null||L>0?(L??5)*1e3:null,persist:L===0,content:oe=>e.jsx(Y,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Tr,{severity:K??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>u(oe),action:e.jsx(Q,{size:"small",onClick:()=>u(oe),sx:{color:"#fff"},children:e.jsx(Fr,{fontSize:"small"})}),children:M},oe)},oe)});L===0&&(o&&console.log(`UiProvider showSnackbarMessage: message ${M} timeout ${L} - persist key ${se}`),ht.push({message:M,key:se}))},[h,u]),[I,y]=r.useState(!1),[C,S]=r.useState(""),[E,A]=r.useState(""),[q,w]=r.useState(""),p=r.useRef(null),b=r.useRef(null),x=()=>{o&&console.log(`UiProvider handle confirm action ${q}`),y(!1),p.current&&p.current(q)},H=()=>{o&&console.log(`UiProvider handle cancel action ${q}`),y(!1),b.current&&b.current(q)},T=r.useCallback((M,L,K,se,oe)=>{o&&console.log(`UiProvider showConfirmCancelDialog for command ${K}`),S(M),A(L),w(K),p.current=se,b.current=oe,y(!0)},[]),[j,_]=r.useState(!1),[ee,c]=r.useState(""),[s,g]=r.useState(""),[f,R]=r.useState(""),[ce,ye]=r.useState(""),[ie,je]=r.useState(localStorage.getItem("installAutoExit")!=="false"),F=r.useCallback((M,L,K)=>{o&&console.log(`UiProvider show install progress for package ${M}`),c(M),g(L),R(K),_(!0)},[]),U=r.useCallback(M=>{o&&console.log(`UiProvider addInstallProgress: output ${M}`),ye(L=>L+M+`
3
- `)},[]),N=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${f}`),localStorage.getItem("installAutoExit")!=="false"&&_(!1)},[f]),G=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressError: package ${f}`)},[f]),$=r.useCallback(()=>{o&&console.log("UiProvider hide install progress"),_(!1)},[]),W=()=>{o&&console.log("UiProvider handle install close action"),_(!1),R(""),ye("")},k=r.useMemo(()=>({mobile:d,setMobile:l,currentPage:i,setCurrentPage:a,showSnackbarMessage:t,closeSnackbarMessage:v,closeSnackbar:u,showConfirmCancelDialog:T,showInstallProgress:F,exitInstallProgressSuccess:N,exitInstallProgressError:G,hideInstallProgress:$,addInstallProgress:U,installAutoExit:ie,setInstallAutoExit:je}),[d,i,l,a,t,v,u,T,F,N,G,$,U,ie,je]);return e.jsxs(Le.Provider,{value:k,children:[e.jsx(an,{open:I,title:C,message:E,onConfirm:x,onCancel:H}),e.jsx(ln,{open:j,title:ee,_command:s,_packageName:f,output:ce,onClose:W}),n]})}const pr=r.createContext(null),be=r.createContext(null);function cn({children:n}){const[d,l]=r.useState([]),[i,a]=r.useState(1e3),[h,u]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[v,t]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[I,y]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),[C,S]=r.useState(!1),{showSnackbarMessage:E,closeSnackbarMessage:A,closeSnackbar:q,showInstallProgress:w,hideInstallProgress:p,exitInstallProgressSuccess:b,exitInstallProgressError:x,addInstallProgress:H}=r.useContext(Le),T=r.useRef([]),j=r.useRef(null),_=r.useRef(1),ee=r.useRef(Math.floor(Math.random()*999e3)+1e3),c=r.useRef(null),s=r.useRef(null),g=r.useRef(null),f=r.useRef(h),R=r.useRef(v),ce=r.useRef(0),ye=r.useRef(null),ie=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),je=r.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),F=100,U=60,N=50,G=300,$=10;r.useEffect(()=>(o&&console.log("WebSocket messages started counter interval"),ye.current=setInterval(()=>{ce.current>0&&(o&&console.log(`WebSocket messages received in the last ${$} seconds: ${ce.current*(60/$)} messages/minute`),ce.current=0)},$*1e3),()=>{o&&console.log("WebSocket messages stopped counter interval"),ye.current&&clearInterval(ye.current),ye.current=null}),[]),r.useEffect(()=>{f.current=h},[h]),r.useEffect(()=>{R.current=v},[v]);const W=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),k=r.useCallback((D,m)=>{o&&console.log(`WebSocket filterLogMessages called with level "${D}" and search "${m}"...`),l(xe=>xe.filter(te=>!(["debug","info","notice","warn","error","fatal"].includes(te.level)&&(D==="info"&&te.level==="debug"||D==="notice"&&(te.level==="debug"||te.level==="info")||D==="warn"&&(te.level==="debug"||te.level==="info"||te.level==="notice")||D==="error"&&(te.level==="debug"||te.level==="info"||te.level==="notice"||te.level==="warn")||D==="fatal"&&(te.level==="debug"||te.level==="info"||te.level==="notice"||te.level==="warn"||te.level==="error"))||m!=="*"&&m!==""&&!te.message.toLowerCase().includes(m.toLowerCase())&&!te.name.toLowerCase().includes(m.toLowerCase()))))},[]),M=r.useCallback(D=>{if(j.current&&j.current.readyState===WebSocket.OPEN)try{o&&console.log(`WebSocket sending message with id ${D.id}:`,D),D.id===void 0&&(D.id=ee.current);const m=JSON.stringify(D);j.current.send(m),o&&console.log("WebSocket sent message:",D)}catch(m){o&&console.error(`WebSocket error sending message: ${m}`)}else o&&console.error("WebSocket message not sent, WebSocket not connected:",D)},[]),L=r.useCallback((D,m)=>{l(xe=>[...xe,{level:D,time:"",name:"",message:m}])},[]),K=r.useCallback((D,m)=>{o&&console.log(`WebSocket addListener id ${m}:`,D),(m==null||isNaN(m)||m===0)&&console.error("WebSocket addListener called without id, listener not added:",D),T.current=[...T.current,{listener:D,id:m}],o&&console.log("WebSocket addListener total listeners:",T.current.length)},[]),se=r.useCallback(D=>{o&&console.log("WebSocket removeListener:",D),T.current=T.current.filter(m=>m.listener!==D),o&&console.log("WebSocket removeListener total listeners:",T.current.length)},[]),oe=r.useCallback(()=>{ie===""||ie===null||ie===void 0||(L("WebSocket",`Connecting ${et?"with password":""} to WebSocket: ${ie}`),o&&console.log(`WebSocket connecting to: ${ie}${et?"?password=[redacted]":""}`),j.current=new WebSocket(ie+(et?`?password=${encodeURIComponent(et)}`:"")),j.current.onmessage=D=>{C||S(!0),ce.current+=1;try{const m=JSON.parse(D.data);if(m.id===void 0||m.src===void 0||m.dst===void 0){o&&console.error("WebSocket undefined message id/src/dst:",m);return}if(m.src!=="Matterbridge"||m.dst!=="Frontend"){o&&console.error("WebSocket invalid message src/dst:",m);return}if(m.error){o&&console.error("WebSocket error message response:",m);return}if(m.id===ee.current&&m.method==="pong"&&m.response==="pong"){o&&console.log(`WebSocket pong response message id ${m.id}:`,m),s.current&&clearTimeout(s.current),s.current=null;return}else if(m.method==="snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),E(m.response.message,m.response.timeout,m.response.severity);return}else if(m.method==="close_snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),A(m.response.message);return}else if(m.method==="log"){if(!m.response||!m.response.level||!m.response.time||!m.response.name||!m.response.message||(m.response.level==="spawn"&&(m.response.name==="Matterbridge:spawn-init"?w(m.response.message,"",""):m.response.name==="Matterbridge:spawn-exit-success"?b():m.response.name==="Matterbridge:spawn-exit-error"?x():H(m.response.message+`
4
- `)),["debug","info","notice","warn","error","fatal"].includes(m.response.level)&&(f.current==="info"&&m.response.level==="debug"||f.current==="notice"&&(m.response.level==="debug"||m.response.level==="info")||f.current==="warn"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice")||f.current==="error"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn")||f.current==="fatal"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn"||m.response.level==="error")))||R.current!=="*"&&R.current!==""&&!m.response.message.toLowerCase().includes(R.current.toLowerCase())&&!m.response.name.toLowerCase().includes(R.current.toLowerCase())||m.response.name==="Commissioning"&&m.response.message.includes("is uncommissioned"))return;l(te=>{const fe=[...te,{level:m.response.level,time:m.response.time,name:m.response.name,message:m.response.message}];return fe.length>i*2?fe.slice(i):fe})}else{if(o&&console.log(`WebSocket received message id ${m.id} method ${m.method}:`,m),m.id===0)T.current.forEach(xe=>xe.listener(m));else{const xe=T.current.find(te=>te.id===m.id);xe?xe.listener(m):console.warn(`WebSocket no listener found for message id ${m.id}:`,m)}return}}catch(m){console.error(`WebSocket error parsing message: ${m}`,m instanceof Error?m.stack:null)}},j.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${ie}`),L("WebSocket",`Connected to WebSocket: ${ie}`),S(!0),q(),_.current=1,g.current=setTimeout(()=>{c.current=setInterval(()=>{M({id:ee.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${ie}`),L("WebSocket",`No pong response received from WebSocket: ${ie}`),S(!1)},1e3*N)},1e3*U)},1e3*G)},j.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${je?"with Ingress":""}: ${ie}`),L("WebSocket",`Disconnected from WebSocket: ${ie}`),S(!1),q(),p(),g.current&&clearTimeout(g.current),s.current&&clearTimeout(s.current),c.current&&clearInterval(c.current),L("WebSocket",`Reconnecting (attempt ${_.current} of ${F}) to WebSocket${je?" (Ingress)":""}: ${ie}`),je?setTimeout(de,5e3):_.current===1?de():_.current<F?setTimeout(de,1e3*_.current):L("WebSocket",`Reconnect attempts exceeded limit of ${F} retries, refresh the page to reconnect to: ${ie}`),_.current=_.current+1},j.current.onerror=D=>{o&&console.error(`WebSocket: WebSocket error connecting to ${ie}:`,D),L("WebSocket",`WebSocket error connecting to ${ie}`)})},[ie]),de=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${_.current}/${F} to:`,ie),oe()},[oe]);r.useEffect(()=>(oe(),()=>{j.current&&j.current.readyState===WebSocket.OPEN&&j.current.close()}),[oe]);const ge=r.useMemo(()=>({messages:d,logMaxMessages:i,logAutoScroll:I,logFilterLevel:h,logFilterSearch:v,setMessages:l,setLogMaxMessages:a,setLogFilterLevel:u,setLogFilterSearch:t,setLogAutoScroll:y,filterLogMessages:k}),[d,i,I,h,v,l,u,t,a,y,k]),pe=r.useMemo(()=>({logMaxMessages:i,logAutoScroll:I,logFilterLevel:h,logFilterSearch:v,setMessages:l,setLogMaxMessages:a,setLogFilterLevel:u,setLogFilterSearch:t,setLogAutoScroll:y,filterLogMessages:k,online:C,retry:_.current,getUniqueId:W,addListener:K,removeListener:se,sendMessage:M,logMessage:L}),[i,I,l,u,t,a,y,C,_.current,K,se,M,L]);return e.jsx(pr.Provider,{value:ge,children:e.jsx(be.Provider,{value:pe,children:n})})}function pn(n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 296.2 296.2",...n,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"lg1",x1:"16.6",y1:"16.6",x2:"279.6",y2:"279.6",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".1",stopColor:"#3faa77"}),e.jsx("stop",{offset:".3",stopColor:"#234148"}),e.jsx("stop",{offset:".7",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#ad2e6e"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg2",x1:"31.1",y1:"31.1",x2:"265.1",y2:"265.1",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".2",stopColor:"#285251"}),e.jsx("stop",{offset:".4",stopColor:"#234148"}),e.jsx("stop",{offset:".8",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#a8316c"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg3",x1:"116.2",y1:"143.9",x2:"139.8",y2:"143.9",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#8bc751"}),e.jsx("stop",{offset:"1",stopColor:"#0db14b"})]}),e.jsx("linearGradient",{id:"lg4",x1:"136.1",y1:"100.8",x2:"159.6",y2:"100.8",xlinkHref:"#lg3"}),e.jsx("linearGradient",{id:"lg5",x1:"155.3",y1:"143.9",x2:"178.9",y2:"143.9",xlinkHref:"#lg3"}),e.jsxs("linearGradient",{id:"lg6",x1:"46.8",y1:"25.7",x2:"89.6",y2:"74.8",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#b1d34a"}),e.jsx("stop",{offset:"1",stopColor:"#50b848"})]})]}),e.jsx("rect",{width:"296.2",height:"296.2",rx:"56.7",ry:"56.7",style:{fill:"url(#lg1)"}}),e.jsx("rect",{x:"16.3",y:"16.3",width:"263.6",height:"263.6",rx:"50.5",ry:"50.5",style:{fill:"url(#lg2)"}}),e.jsx("circle",{cx:"128",cy:"143.9",r:"11.8",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"147.8",cy:"100.8",r:"11.8",style:{fill:"url(#lg4)"}}),e.jsx("path",{d:"m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"167.1",cy:"143.9",r:"11.8",style:{fill:"url(#lg5)"}}),e.jsx("path",{fill:"#fff",d:"M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z"}),e.jsx("path",{d:"M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z",style:{fill:"url(#lg6)"}}),e.jsx("path",{d:"M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z",fill:"#1e5857"}),e.jsx("path",{fill:"#fff",d:"M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z"})]})}function $e(){const{retry:n}=r.useContext(be),d=()=>{window.location.reload()};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center",fontSize:"20px",color:"var(--main-text-color)",backgroundColor:"var(--main-bg-color)"},children:[e.jsx(pn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(Rr,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+n+")","..."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{})]}),e.jsx(ae,{variant:"contained",color:"primary",onClick:d,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function ur({value:n,maxChars:d}){let l=n;if(n.length>d&&d>3){const i=d-3,a=n.substring(0,Math.ceil(i/2)),h=n.substring(n.length-Math.floor(i/2),n.length);l=`${a} … ${h}`}return n!==l?e.jsx(V,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:l})}):e.jsx("span",{children:l})}function Me({children:n,style:d}){const l={display:"flex",flexDirection:"column",flex:"0 0 auto",width:"100%",overflow:"hidden",margin:"0px",padding:"0px",gap:"0px",backgroundColor:"var(--div-bg-color)",boxShadow:"5px 5px 10px var(--div-shadow-color)",border:"1px solid var(--table-border-color)",borderRadius:"var(--div-border-radius)",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function _e({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",borderBottom:"1px solid var(--table-border-color)",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function Oe({children:n,style:d}){const l={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function ft({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function xt({children:n,style:d}){const l={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function nt({children:n,style:d}){const l={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function st({children:n,style:d,onDragOver:l,onDragLeave:i,onDrop:a}){const h={display:"flex",flexDirection:"row",flex:"0 0 auto",overflow:"hidden",alignItems:"start",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"};return e.jsx("div",{style:{...h,...d},onDragOver:l,onDragLeave:i,onDrop:a,children:n})}function tt({children:n,style:d,onClose:l}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...d},children:[n,ki]})}function un({systemInfo:n,compact:d}){const{addListener:l,removeListener:i,getUniqueId:a,sendMessage:h}=r.useContext(be),[u,v]=r.useState(n),t=r.useRef(a());if(o&&console.log("SystemInfoTable loading with systemInfo:",u,"compact:",d),n&&d&&u.totalMemory&&u.freeMemory){const w=u.totalMemory,p=u.freeMemory;u.freeMemory=`${p} / ${w}`,u.totalMemory=""}if(n&&d&&u.heapTotal&&u.heapUsed){const w=u.heapTotal,p=u.heapUsed;u.heapUsed=`${p} / ${w}`,u.heapTotal=""}if(n&&d&&u.osRelease&&u.osType){const w=u.osType,p=u.osRelease;u.osType=`${w} (${p})`,u.osRelease=""}if(n&&d&&u.osArch&&u.osPlatform){const w=u.osPlatform,p=u.osArch;u.osPlatform=`${w} (${p})`,u.osArch=""}const I=(w,p,b,x,H)=>{v(T=>({...T,totalMemory:w,freeMemory:p,heapTotal:b,heapUsed:x,rss:H}))},y=w=>{v(p=>({...p,cpuUsage:w.toFixed(2)+" %"}))},C=w=>{v(p=>({...p,processCpuUsage:w.toFixed(2)+" %"}))},S=(w,p)=>{v(b=>({...b,systemUptime:w,processUptime:p}))},E=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),h({id:t.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const w=p=>{o&&console.log("SystemInfoTable received WebSocket Message:",p),p.method==="memory_update"&&p.response&&p.response.totalMemory&&p.response.freeMemory&&p.response.heapTotal&&p.response.heapUsed&&p.response.rss?(o&&console.log("SystemInfoTable received memory_update",p),I(p.response.totalMemory,p.response.freeMemory,p.response.heapTotal,p.response.heapUsed,p.response.rss)):p.method==="cpu_update"&&p.response&&p.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",p),y(p.response.cpuUsage),C(p.response.processCpuUsage)):p.method==="uptime_update"&&p.response&&p.response.systemUptime&&p.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",p),S(p.response.systemUptime,p.response.processUptime)):p.method==="/api/viewhistorypage"&&p.id===t.current&&p.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return l(w,t.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${t.current}`),()=>{i(w),o&&console.log("SystemInfoTable removed WebSocket listener")}},[l,i]);const[A,q]=r.useState(!1);return!u||A?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(Me,{style:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(_e,{children:[e.jsx(Oe,{children:"System Information"}),e.jsx(tt,{onClose:()=>q(!0),children:e.jsx(Q,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:E,children:e.jsx(V,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(ne,{path:ko,size:"22px"})})})})]}),e.jsx(st,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(u).filter(([w,p])=>p!==void 0&&p!=="").map(([w,p],b)=>e.jsxs("tr",{className:b%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:w.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(ur,{value:typeof p!="string"?p.toString():p,maxChars:24})})]},w))})})})]}))}const Gt=r.memo(un),Jt={margin:"0px",padding:"0px",color:"var(--div-text-color)",transition:"color 0.2s ease","& svg":{display:"block"},"& svg path":{fill:"var(--div-text-color)",transition:"fill 0.2s ease"},"&:hover":{color:"var(--primary-color)"},"&:hover svg path":{fill:"var(--primary-color)"},"&:focus-visible":{outline:"2px solid var(--primary-color)",outlineOffset:"2px"}},gn=n=>{if(!n)return"";const d=n.toString().replace(/[^0-9]/g,"");if(d.length<5)return d;const l=d.slice(0,4),i=d.slice(4,7),a=d.slice(7,11);return[l,i,a].filter(Boolean).join("-")};function mn({id:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(be),[u,v]=r.useState(null),t=r.useRef(null),I=r.useRef(null),y=r.useRef(h()),{showConfirmCancelDialog:C}=r.useContext(Le);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${I.current} and matter:`,u),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),t.current=n,I.current&&clearTimeout(I.current),I.current=null,n?(o&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:n,server:!0}})):(o&&console.log("QRDiv id effect setting matter to null"),v(null))},[n,l]),r.useEffect(()=>{const p=b=>{o&&console.log("QRDiv received WebSocket Message:",b),b.method==="refresh_required"&&b.response.changed==="matter"&&b.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${b.response.changed} for storeId "${b.response.matter.id}":`,b.response.matter),t.current===b.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${b.response.matter.id}":`,b.response.matter),I.current&&clearTimeout(I.current),b.response.matter.advertising&&b.response.matter.advertiseTime&&b.response.matter.advertiseTime+9e5<=Date.now()&&(b.response.matter.advertising=!1),v(b.response.matter),b.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${b.response.matter.id}":`,b.response.matter.advertiseTime+9e5-Date.now()),I.current=setTimeout(()=>{I.current&&clearTimeout(I.current),o&&console.log(`QRDiv clearing advertising state for storeId "${t.current}" after 15 minutes`),v(x=>x&&{...x,advertising:!1})},b.response.matter.advertiseTime+9e5-Date.now()))))};return i(p,y.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{a(p),I.current&&clearTimeout(I.current),I.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,a]);const S=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${u?.id}"`),u&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,startCommission:!0}})},E=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${u?.id}"`),u&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,stopCommission:!0}})},A=()=>{o&&console.log(`QRDiv sent matter advertise for node "${u?.id}"`),u&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,advertise:!0}})},q=p=>{o&&console.log(`QRDiv sent matter removeFabric for node "${u?.id}" and fabricIndex ${p}`),u&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,removeFabric:p}})},w=async()=>{if(!u||!u.manualPairingCode)return;const p=u.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(p);else{const b=document.createElement("textarea");b.value=p,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select(),document.execCommand("copy"),document.body.removeChild(b)}o&&console.log("Manual pairing code copied to clipboard")}catch(b){console.error("Failed to copy manual pairing code",b)}};return!u||!d?(o&&console.log("QRDiv rendering undefined state"),null):u.online?u.advertising&&u.qrPairingCode&&u.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(Me,{style:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsxs(_e,{children:[e.jsx(Oe,{children:"QR pairing code"}),e.jsxs(tt,{children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:A,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Ut,size:"22px"})})}),e.jsx(Q,{"aria-label":"stop pairing",size:"small",onClick:E,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Turn off pairing",arrow:!0,children:e.jsx(ne,{path:Io,size:"22px"})})})]})]}),e.jsx(nt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Zo,{value:u.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(ft,{style:{justifyContent:"space-between"},children:[e.jsxs(xt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",gn(u.manualPairingCode)]}),e.jsx(tt,{children:e.jsx(V,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(Q,{"aria-label":"copy manual pairing code",size:"small",onClick:w,sx:Jt,children:e.jsx(ne,{path:Do,size:.85})})})})]})]})):u.commissioned&&u.fabricInformations&&u.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(Me,{style:{alignItems:"center",width:"302px",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(_e,{children:[e.jsx(Oe,{children:"Paired fabrics"}),e.jsxs(tt,{children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:A,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Ut,size:"22px"})})}),e.jsx(Q,{"aria-label":"start pairing",size:"small",onClick:S,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Turn on pairing",arrow:!0,children:e.jsx(ne,{path:Bt,size:"22px"})})})]})]}),e.jsx(nt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(st,{style:{flexDirection:"column",flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px 0px 10px 0px",gap:"0px"},children:u.fabricInformations.map((p,b)=>e.jsxs("div",{style:{margin:"0px",padding:"10px",gap:"0px",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",textAlign:"left",fontSize:"14px"},children:[e.jsxs("div",{style:{marginLeft:"20px",marginBottom:"10px",display:"flex",flexDirection:"row",justifyContent:"space-between",gap:"20px",alignItems:"center"},children:[e.jsxs("p",{className:"status-blue",style:{margin:"0px",padding:"3px 10px",width:"200px",fontSize:"14px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},children:["Fabric: ",p.fabricIndex]}),e.jsx(V,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(Q,{"aria-label":"remove the fabric",size:"small",onClick:()=>C("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>q(p.fabricIndex),()=>{}),sx:{...Jt,padding:"2px"},children:e.jsx(ne,{path:Po,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",p.rootVendorId," ",p.rootVendorName]}),p.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",p.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",u.sessionInformations?u.sessionInformations.filter(x=>x.fabric?.fabricIndex===p.fabricIndex&&x.isPeerActive===!0).length:"0"," ","subscriptions: ",u.sessionInformations?u.sessionInformations.filter(x=>x.fabric?.fabricIndex===p.fabricIndex&&x.isPeerActive===!0&&x.numberOfActiveSubscriptions>0).length:"0"]})]},b))}),e.jsx(ft,{style:{justifyContent:"center"},children:e.jsxs(xt,{style:{fontWeight:"normal"},children:["Serial number: ",u.serialNumber]})})]})):!u.commissioned&&!u.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(Me,{style:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(_e,{children:e.jsx(Oe,{children:"QR pairing code"})}),e.jsx(nt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(ae,{onClick:S,endIcon:e.jsx(ne,{path:Bt,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx(ft,{style:{justifyContent:"center"},children:e.jsxs(xt,{style:{fontWeight:"normal"},children:["Serial number: ",u.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(Me,{style:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(_e,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(Oe,{children:"Server node"})}),e.jsx(nt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(nt,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(ft,{style:{justifyContent:"center"},children:e.jsxs(xt,{style:{fontWeight:"normal"},children:["Serial number: ",u.serialNumber]})})]}))}const Zt=r.memo(mn);function hn(){const{mobile:n}=r.useContext(Le),{logMessage:d,sendMessage:l,getUniqueId:i}=r.useContext(be),[a,h]=r.useState("matterbridge-"),[u,v]=r.useState(!1),[t,I]=r.useState(null),y=r.useRef(i()),C=c=>{c.preventDefault(),v(!0)},S=()=>{v(!1)},E=c=>{c.preventDefault(),v(!1);const s=c.dataTransfer.files[0];if(s){d("Plugins",`Installing package ${s.name}. Please wait...`);const g=new FormData;g.append("file",s),g.append("filename",s.name),fetch("./api/uploadpackage",{method:"POST",body:g}).then(f=>f.text()).then(f=>{d("Plugins",`Server response: ${f}`)}).catch(f=>{console.error("Error uploading plugin file:",f),d("Plugins",`Error installing package ${f}`)})}},A=c=>{const s=c.target.files&&c.target.files[0];if(s){d("Plugins",`Uploading package ${s.name}`);const g=new FormData;g.append("file",s),g.append("filename",s.name),fetch("./api/uploadpackage",{method:"POST",body:g}).then(f=>f.text()).then(f=>{d("Plugins",`Server response: ${f}`)}).catch(f=>{console.error("Error uploading plugin file:",f),d("Plugins",`Error uploading package ${f}`)})}},q=()=>{l({id:y.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:a,restart:!1}})},w=()=>{document.getElementById("file-upload")?.click()},p=()=>{l({id:y.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:a}})},b=c=>{c.preventDefault(),l({id:y.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:a}})},x=c=>{c.preventDefault(),console.log("Right-clicked Upload button")},H=c=>{c.preventDefault(),console.log("Right-clicked Add button")},T=c=>{I(c.currentTarget)},j=c=>{c!==""&&h(c),I(null)},[_,ee]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),_?null:e.jsxs(Me,{children:[e.jsxs(_e,{children:[e.jsx(Oe,{children:"Install plugins"}),e.jsx(tt,{onClose:()=>ee(!0)})]}),e.jsxs(st,{onDragOver:C,onDragLeave:S,onDrop:E,style:n?{flexWrap:"wrap",gap:"10px"}:{flexWrap:"wrap",gap:"20px"},children:[e.jsxs("div",{style:{flex:"auto",display:"flex",flexDirection:"row",gap:"10px"},children:[e.jsx(he,{value:a,onChange:c=>{h(c.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(Q,{onClick:T,children:e.jsx(Hr,{})}),e.jsxs(Ye,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>j(""),children:[e.jsx(P,{onClick:()=>j("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(P,{onClick:()=>j("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(P,{onClick:()=>j("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(P,{onClick:()=>j("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(P,{onClick:()=>j("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(P,{onClick:()=>j("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(P,{onClick:()=>j("matterbridge-test"),children:"matterbridge-test"}),e.jsx(P,{onClick:()=>j("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(P,{onClick:()=>j("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(P,{onClick:()=>j("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(P,{onClick:()=>j("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(P,{onClick:()=>j("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(P,{onClick:()=>j("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(P,{onClick:()=>j("matterbridge-eve-room"),children:"matterbridge-eve-room"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",gap:"10px"},children:[e.jsx(V,{title:"Install or update a plugin from npm",children:e.jsxs(ae,{onClick:q,onContextMenu:b,endIcon:e.jsx(De,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(V,{title:"Upload and install a plugin from a tarball",children:e.jsxs(ae,{onClick:w,onContextMenu:x,endIcon:e.jsx(Or,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(V,{title:"Add an installed plugin",children:e.jsxs(ae,{onClick:p,onContextMenu:H,endIcon:e.jsx(wt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Add"]})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:A})]})]})]})}const fn=r.memo(hn);function Qe({status:n,enabledText:d="Enabled",disabledText:l=void 0,tooltipText:i=void 0,onClick:a}){if(n===void 0)return null;{const h=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:a,children:n?d:l??d});return i!==void 0?e.jsx(V,{title:i,children:h}):h}}function xn(n,d,l){const i=n?.[l],a=d?.[l];return i==null&&a==null?0:i==null?-1:a==null?1:typeof i=="boolean"&&typeof a=="boolean"?i===a?0:i?1:-1:typeof i=="number"&&typeof a=="number"?i-a:String(i).localeCompare(String(a))}function bn({name:n,title:d,columns:l,rows:i,getRowKey:a,footerLeft:h,footerRight:u,onRowClick:v}){const t=r.useRef(new WeakMap),I=r.useRef(1),y=c=>{if(typeof a=="string"&&c&&c[a]!=null)return c[a];if(typeof a=="function"){const f=a(c);if(f!=null)return f}const s=l?.[0]?.id;if(s&&c&&c[s]!=null)return c[s];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let g=t.current.get(c);return g||(g=`rk_${I.current++}`,t.current.set(c,g)),g},[C,S]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[E,A]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[q,w]=r.useState(!1),[p,b]=r.useState(()=>{try{const c=localStorage.getItem(`${n}_column_visibility`);if(c)return JSON.parse(c)}catch{}return{}}),x=r.useMemo(()=>{const c={};for(const s of l)s.hidden||(c[s.id]=s.required?!0:p[s.id]!==!1);return c},[l,p]),H=r.useMemo(()=>{if(!C||!E)return i;const c=l.find(g=>g.id===C);if(!c||c.noSort)return i;const s=i.map((g,f)=>({el:g,index:f}));return s.sort((g,f)=>{let R;return typeof c.comparator=="function"?R=c.comparator(g.el,f.el):R=xn(g.el,f.el,C),R!==0?E==="asc"?R:-R:g.index-f.index}),s.map(g=>g.el)},[i,C,E,l]),T=c=>{if(C!==c||!C){S(c),A("asc"),localStorage.setItem(`${n}_table_order_by`,c),localStorage.setItem(`${n}_table_order`,"asc");return}if(E==="asc"){A("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}S(null),A(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},j=()=>{w(!q)},_=c=>{b(s=>{const g=l.find(ce=>ce.id===c);if(g&&g.required)return s;const f=x[c]!==!1,R={...s};f?R[c]=!1:delete R[c];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(R))}catch{}return R})},ee=()=>{b({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}w(!1)};return o&&console.log(`Rendering table ${n}${C&&E?` ordered by ${C}:${E}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(Ne,{open:q,onClose:(c,s)=>{s==="backdropClick"||s==="escapeKeyDown"||j()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Te,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${n} columns`})]})}),e.jsx(Fe,{children:e.jsx(Vr,{children:l.filter(c=>!c.hidden).map(c=>e.jsx(ze,{control:e.jsx(Ve,{disabled:!!c.required,checked:c.required?!0:x[c.id]!==!1,onChange:()=>_(c.id)}),label:c.label},c.id))})}),e.jsxs(Ae,{children:[e.jsx(ae,{onClick:ee,children:"Reset"}),e.jsx(ae,{variant:"contained",onClick:c=>{if(c?.currentTarget&&typeof c.currentTarget.blur=="function")try{c.currentTarget.blur()}catch{}const s=document.activeElement;if(s&&s instanceof HTMLElement&&typeof s.blur=="function")try{s.blur()}catch{}j()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:n}),d&&e.jsx("p",{className:"MbfWindowHeaderText",children:d}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(Q,{onClick:c=>{if(c?.currentTarget?.blur)try{c.currentTarget.blur()}catch{}j()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(V,{title:`Configure ${n} columns`,children:e.jsx(ne,{path:Lo,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:l.map(c=>{if(c.hidden||!c.required&&x[c.id]===!1)return null;const s=!c.noSort,g=s&&C===c.id&&!!E;return e.jsxs("th",{onClick:s?()=>T(c.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:c.minWidth,maxWidth:c.maxWidth,textAlign:c.align||"left",cursor:s?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:c.maxWidth?"nowrap":void 0,overflow:c.maxWidth?"hidden":void 0,textOverflow:c.maxWidth?"ellipsis":void 0},"aria-sort":s?g?E==="asc"?"ascending":"descending":"none":void 0,children:[c.label,g&&e.jsxs("span",{style:{marginLeft:6},children:[E==="asc"&&e.jsx(ne,{path:$o,size:"15px"}),E==="desc"&&e.jsx(ne,{path:Wo,size:"15px"})]})]},c.id)})})}),e.jsx("tbody",{children:H.map((c,s)=>{const g=y(c);return e.jsx("tr",{className:s%2===0?"table-content-even":"table-content-odd",onClick:v?f=>v(c,g,f):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:v?"pointer":void 0},children:l.map(f=>{if(f.hidden||!f.required&&x[f.id]===!1)return null;const R=c[f.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:f.align||"left",padding:"5px 10px",margin:"0",maxWidth:f.maxWidth,whiteSpace:f.maxWidth?"nowrap":void 0,overflow:f.maxWidth?"hidden":void 0,textOverflow:f.maxWidth?"ellipsis":void 0},children:typeof f.render=="function"?f.render(R,g,c,f):typeof R=="boolean"?e.jsx(Ve,{checked:R,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):f.format&&typeof R=="number"?f.format(R):R!=null?String(R):null},f.id)})},g)})})]})}),(h||u)&&e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:u})]})]})}function vn(n){return r.memo(n)}const kt=vn(bn);function Yt(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const Ke={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Ge={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},yn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},jn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},He={padding:"0px",margin:"0px"},wn="5px 10px 5px 10px",bt={},Ce={},vt={},yt={};let Je=[],Pt=[];const Cn=({open:n,onClose:d,plugin:l})=>{const{sendMessage:i,addListener:a,removeListener:h,getUniqueId:u}=r.useContext(be),v=r.useRef(u()),[t,I]=r.useState(l.configJson),[y,C]=r.useState(null),[S,E]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[A,q]=r.useState("");let w={};r.useEffect(()=>{const W=k=>{k.src==="Matterbridge"&&k.dst==="Frontend"&&(Yt(k)&&k.id===v.current&&k.method==="/api/select/devices"&&k.response&&(o&&console.log(`ConfigPluginDialog (id: ${k.id}) received ${k.response.length} /api/select/devices:`,k.response),Je=k.response),Yt(k)&&k.id===v.current&&k.method==="/api/select/entities"&&k.response&&(o&&console.log(`ConfigPluginDialog (id: ${k.id}) received ${k.response.length} /api/select/entities:`,k.response),Pt=k.response))};return a(W,v.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",v.current),t&&y&&y.properties&&(Object.keys(y.properties).forEach(k=>{Object.keys(y.properties[k]).forEach(M=>{M.startsWith("ui:")&&(S[k]={},S[k][M]=y.properties[k][M],delete y.properties[k][M])})}),E(S)),l.name&&l.configJson&&l.schemaJson&&(I(l.configJson),C(l.schemaJson),i({id:v.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),i({id:v.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),o&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',l.name)),()=>{h(W),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[a,t,l,h,y,i,S]);const p=(W,k)=>{w=W.formData},b=W=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",W.formData),I(W.formData),l.configJson=W.formData,l.restartRequired=!0,i({id:v.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.formData.name,formData:W.formData}}),d()};function x(W){const{id:k,label:M,onKeyChange:L,onDropPropertyClick:K,disabled:se,schema:oe,children:de,registry:ge,readonly:pe,required:D}=W,{templates:m}=ge,{RemoveButton:xe}=m.ButtonTemplates;if(!(sn in oe))return e.jsx(Y,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:de});const fe=({target:Z})=>L(Z&&Z.value);return e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(he,{id:`${k}-key`,name:`${k}-key`,required:D,disabled:se||pe,defaultValue:M,onBlur:pe?void 0:fe,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Y,{sx:{flex:1},children:de}),e.jsx(xe,{disabled:se||pe,onClick:K(M),registry:ge})]})}function H(W){const{children:k,description:M,displayLabel:L,errors:K,help:se,hidden:oe,registry:de,uiSchema:ge}=W,pe=on(ge),D=nn("WrapIfAdditionalTemplate",de,pe);return oe?e.jsx("div",{style:{display:"none"},children:k}):e.jsx(Y,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(D,{...W,children:[L===!0&&M,k,K,se]})})}function T(W){const{description:k}=W;return k?e.jsx(le,{sx:Ge,children:k}):null}function j(W){const{required:k,title:M}=W;return M?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(le,{sx:Ke,children:["Title ",M," ",k&&e.jsx("mark",{children:"***"})]})}):null}function _(W){const{help:k}=W;return k?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(le,{sx:yn,children:k})}):null}function ee(W){const{errors:k}=W;return k?e.jsxs(Y,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(le,{color:"error",sx:jn,children:"Please fix the following errors:"}),e.jsx(ot,{children:k.map((M,L)=>e.jsxs(Er,{children:[e.jsx(B,{children:e.jsx(Ar,{color:"error"})}),e.jsx(X,{primary:M.stack})]},L))})]}):null}function c(W){const{errors:k}=W;return k?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:k.map((M,L)=>e.jsxs(le,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",M]},L))}):null}function s(W){const{id:k,name:M,_schema:L,_uiSchema:K,value:se,options:oe,label:de,type:ge,placeholder:pe,required:D,disabled:m,readonly:xe,autofocus:te,onChange:fe,onChangeOverride:Z,onBlur:me,onFocus:ve,_rawErrors:rt,_hideError:We,_registry:z,_formContext:O}=W,re=({target:{value:Ie}})=>fe(Ie===""?oe.emptyValue:Ie),we=({target:Ie})=>me(k,Ie&&Ie.value),lt=({target:Ie})=>ve(k,Ie&&Ie.value);return e.jsx(Y,{sx:{padding:"0px",margin:"0px"},children:e.jsx(he,{id:k,name:k,label:pe&&pe!==""?de:void 0,variant:"outlined",placeholder:pe&&pe!==""?pe:de,required:D,disabled:m||xe,autoFocus:te,value:se||se===0?se:"",type:ge,autoComplete:ge==="password"?"current-password":M,onChange:Z||re,onBlur:we,onFocus:lt,fullWidth:!0})})}function g(W){return console.log("ArrayFieldTitleTemplate:",W),null}function f(W){return console.log("ArrayFieldDescriptionTemplate:",W),null}function R(W){return console.log("ArrayFieldItemTemplate:",W),null}function ce(W){const{canAdd:k,onAddClick:M,schema:L,title:K}=W,[se,oe]=r.useState(!1),[de,ge]=r.useState(!1),[pe,D]=r.useState(!1),[m,xe]=r.useState(""),te=z=>{xe(z.target.value)},fe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",m,"selectDevices:",Je),oe(!se)},Z=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",m,"selectEntities:",Pt),ge(!de)},me=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",m,"selectDevices:",Je),D(!pe)},ve=z=>{oe(!1),L.selectFrom==="serial"?L.items.default=z.serial:L.selectFrom==="name"&&(L.items.default=z.name),M()},rt=z=>{ge(!1),L.selectEntityFrom==="name"?L.items.default=z.name:L.selectEntityFrom==="description"&&(L.items.default=z.description),M()},We=z=>{D(!1),L.selectDeviceEntityFrom==="name"?L.items.default=z.name:L.selectDeviceEntityFrom==="description"&&(L.items.default=z.description),M()};return e.jsxs(Y,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[K&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[K&&e.jsx(le,{sx:Ke,children:K}),k&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[L.selectFrom&&e.jsx(V,{title:"Add a device from the list",children:e.jsx(Q,{onClick:fe,size:"small",color:"primary",sx:He,children:e.jsx(ct,{})})}),L.selectEntityFrom&&e.jsx(V,{title:"Add an entity from the list",children:e.jsx(Q,{onClick:Z,size:"small",color:"primary",sx:He,children:e.jsx(ct,{})})}),L.selectDeviceEntityFrom&&e.jsx(V,{title:"Add a device entity from the list",children:e.jsx(Q,{onClick:me,size:"small",color:"primary",sx:He,children:e.jsx(ct,{})})}),e.jsx(V,{title:"Add a new item",children:e.jsx(Q,{onClick:M,size:"small",color:"primary",sx:He,children:e.jsx(wt,{})})})]})]}),L.description&&e.jsx(le,{sx:Ge,children:L.description}),W.items.map(z=>e.jsxs(Y,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Y,{sx:{flexGrow:1,marginRight:"10px"},children:z.children}),e.jsx(Q,{disabled:!z.hasMoveUp,onClick:z.onReorderClick(z.index,z.index-1),size:"small",color:"primary",sx:He,children:e.jsx(Vt,{})}),e.jsx(Q,{disabled:!z.hasMoveDown,onClick:z.onReorderClick(z.index,z.index+1),size:"small",color:"primary",sx:He,children:e.jsx(Ot,{})}),e.jsx(Q,{onClick:z.onDropIndexClick(z.index),size:"small",color:"primary",sx:He,children:e.jsx(Nt,{})})]},z.index)),e.jsxs(Ne,{open:se,onClose:fe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Te,{children:"Select a device"}),e.jsxs(Fe,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:m,onChange:te,placeholder:"Enter serial or name"})]}),e.jsx(ot,{dense:!0,children:Je.filter(z=>z.serial.toLowerCase().includes(m.toLowerCase())||z.name.toLowerCase().includes(m.toLowerCase())).map((z,O)=>e.jsxs(pt,{onClick:()=>ve(z),sx:bt,children:[z.icon==="wifi"&&e.jsx(B,{children:e.jsx(it,{style:Ce})}),z.icon==="ble"&&e.jsx(B,{children:e.jsx(ut,{style:Ce})}),z.icon==="hub"&&e.jsx(B,{children:e.jsx(gt,{style:Ce})}),e.jsx(X,{primary:z.name,secondary:z.serial,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},O))})]}),e.jsx(Ae,{children:e.jsx(ae,{onClick:fe,children:"Close"})})]}),e.jsxs(Ne,{open:de,onClose:Z,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Te,{children:"Select an entity"}),e.jsxs(Fe,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:m,onChange:te,placeholder:"Enter name or description"})]}),e.jsx(ot,{dense:!0,children:Pt.filter(z=>z.name.toLowerCase().includes(m.toLowerCase())||z.description.toLowerCase().includes(m.toLowerCase())).map((z,O)=>e.jsxs(pt,{onClick:()=>rt(z),sx:bt,children:[z.icon==="wifi"&&e.jsx(B,{children:e.jsx(it,{style:Ce})}),z.icon==="ble"&&e.jsx(B,{children:e.jsx(ut,{style:Ce})}),z.icon==="hub"&&e.jsx(B,{children:e.jsx(gt,{style:Ce})}),z.icon==="component"&&e.jsx(B,{children:e.jsx(Et,{style:Ce})}),z.icon==="matter"&&e.jsx(B,{children:e.jsx(At,{style:Ce})}),e.jsx(X,{primary:z.name,secondary:z.description,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},O))})]}),e.jsx(Ae,{children:e.jsx(ae,{onClick:Z,children:"Close"})})]}),e.jsxs(Ne,{open:pe,onClose:me,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Te,{children:["Select an entity for ",K]}),e.jsx(Fe,{children:e.jsx(ot,{dense:!0,children:Je.filter(z=>z.serial===K||z.name===K).map(z=>z.entities?.map((O,re)=>e.jsxs(pt,{onClick:()=>We(O),sx:bt,children:[O.icon==="wifi"&&e.jsx(B,{children:e.jsx(it,{style:Ce})}),O.icon==="ble"&&e.jsx(B,{children:e.jsx(ut,{style:Ce})}),O.icon==="hub"&&e.jsx(B,{children:e.jsx(gt,{style:Ce})}),O.icon==="component"&&e.jsx(B,{children:e.jsx(Et,{style:Ce})}),O.icon==="matter"&&e.jsx(B,{children:e.jsx(At,{style:Ce})}),e.jsx(X,{primary:O.name,secondary:O.description,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},re)))})}),e.jsx(Ae,{children:e.jsx(ae,{onClick:me,children:"Close"})})]})]})}function ye(W){const{onAddClick:k,schema:M,properties:L,title:K,description:se}=W,[oe,de]=r.useState(!1),[ge,pe]=r.useState(""),D=Z=>{pe(Z.target.value)},m=()=>{de(!oe)},xe=Z=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${Z.serial}" for schema "${M.selectFrom}"`),de(!1);let me="";M.selectFrom==="serial"?me=Z.serial:M.selectFrom==="name"&&(me=Z.name),q(me),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${me}"`),k(M)()},te=()=>{k(M)()},fe=!M.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${fe} newkey "${A}"`),!fe&&A!==""&&(o&&console.log("ObjectFieldTemplate: newkey",A,"properties",L),L.forEach(Z=>{if(Z.name==="newKey"&&Z.content.key==="newKey"&&Z.content.props.name==="newKey"&&Z.content.props.onKeyChange&&A!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",A);const me=A;q(""),Z.content.props.onKeyChange(me)}})),e.jsxs(Y,{sx:{margin:"0px",padding:fe?"10px":"5px 10px 0px 10px",border:fe?"none":"1px solid grey"},children:[M.title&&fe&&e.jsx(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:Ke,children:M.title})}),K&&!fe&&e.jsxs(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(le,{sx:Ke,children:K}),e.jsxs(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[M.selectFrom&&e.jsx(V,{title:"Add a device from the list",children:e.jsx(Q,{onClick:m,size:"small",color:"primary",sx:He,children:e.jsx(ct,{})})}),e.jsx(V,{title:"Add a new item",children:e.jsx(Q,{onClick:te,size:"small",color:"primary",sx:He,children:e.jsx(wt,{})})})]})]}),M.description&&e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:Ge,children:M.description})}),L.map(({content:Z,name:me,hidden:ve})=>!ve&&e.jsxs(Y,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(M.properties[me].type)?"0px":wn,border:["object","array","boolean"].includes(M.properties[me].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(M.properties[me].type)&&e.jsx(le,{sx:Ke,children:me}),e.jsx(Y,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:Z})]},me)),e.jsxs(Ne,{open:oe,onClose:m,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Te,{children:"Select a device"}),e.jsxs(Fe,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:ge,onChange:D,placeholder:"Enter serial or name"})]}),e.jsx(ot,{dense:!0,children:Je.filter(Z=>Z.serial.toLowerCase().includes(ge.toLowerCase())||Z.name.toLowerCase().includes(ge.toLowerCase())).map((Z,me)=>e.jsxs(pt,{onClick:()=>xe(Z),sx:bt,children:[Z.icon==="wifi"&&e.jsx(B,{children:e.jsx(it,{style:Ce})}),Z.icon==="ble"&&e.jsx(B,{children:e.jsx(ut,{style:Ce})}),Z.icon==="hub"&&e.jsx(B,{children:e.jsx(gt,{style:Ce})}),e.jsx(X,{primary:Z.name,secondary:Z.serial,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},me))})]}),e.jsx(Ae,{children:e.jsx(ae,{onClick:m,children:"Close"})})]})]})}function ie(W){const{uiSchema:k}=W,{submitText:M,norender:L}=rn(k);return L?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ae,{type:"submit",variant:"contained",color:"primary",children:M}),e.jsx(ae,{variant:"contained",color:"primary",onClick:d,children:"Cancel"})]})}function je(W){const{className:k,disabled:M,onClick:L,registry:K,style:se,uiSchema:oe,...de}=W;return e.jsx(V,{title:"Remove the item",children:e.jsx(Q,{disabled:M,size:"small",color:"primary",onClick:L,children:e.jsx(Nt,{})})})}function F(W){const{className:k,disabled:M,onClick:L,registry:K,uiSchema:se,...oe}=W;return e.jsx(V,{title:"Add an item",children:e.jsx(Q,{size:"small",color:"primary",onClick:L,children:e.jsx(wt,{})})})}function U(W){const{disabled:k,onClick:M,registry:L,style:K,uiSchema:se,...oe}=W;return e.jsx(V,{title:"Move up the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:M,children:e.jsx(Vt,{})})})}function N(W){const{disabled:k,onClick:M,registry:L,style:K,uiSchema:se,...oe}=W;return e.jsx(V,{title:"Move down the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:M,children:e.jsx(Ot,{})})})}function G(W){const{id:k,name:M,value:L,schema:K,readonly:se,onChange:oe}=W,[de,ge]=r.useState(),pe=m=>{o&&console.log(`CheckboxWidget ${M} onChangeField:`,m),ge(m&&m!==""?m:void 0)},D=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${M}" value="${de}"`),i({id:v.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:M,value:de,formData:w,id:k}}),K.buttonClose===!0?d():K.buttonSave===!0&&b({formData:t})};return K.buttonText&&K.description?e.jsxs(Y,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:Ge,children:K.description}),e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>D(),children:K.buttonText})]}):K.buttonField&&K.description?e.jsxs(Y,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:Ge,children:K.description}),e.jsx(he,{id:M+"-input",name:M,label:K.textLabel,placeholder:K.textPlaceholder,onChange:m=>pe(m.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ae,{id:M+"-button",variant:"contained",color:"primary",disabled:de===void 0,onClick:()=>D(),children:K.buttonField})]}):e.jsxs(Y,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[M&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(le,{sx:Ke,children:M}),e.jsx(Ve,{checked:L,readOnly:se,onChange:()=>oe(!L),sx:{padding:"0px",margin:"0px"}})]}),K.description&&e.jsx(le,{sx:Ge,children:K.description})]})}function $({schema:W,id:k,name:M,options:L,label:K,hideLabel:se,required:oe,disabled:de,placeholder:ge,readonly:pe,value:D,multiple:m,autofocus:xe,onChange:te,onBlur:fe,onFocus:Z,errorSchema:me,rawErrors:ve=[],registry:rt,uiSchema:We,hideError:z,formContext:O,...re}){const{enumOptions:we,enumDisabled:lt,emptyValue:Ie}=L;m=typeof m>"u"?!1:!!m;const Tt=m?[]:"",Ft=typeof D>"u"||m&&D.length<1||!m&&D===Tt,xr=({target:{value:Re}})=>te(Dt(Re,we,Ie)),br=({target:Re})=>fe(k,Dt(Re&&Re.value,we,Ie)),vr=({target:Re})=>Z(k,Dt(Re&&Re.value,we,Ie)),Rt=en(D,we,m),{InputLabelProps:yr,SelectProps:jr,autocomplete:wr,...Cr}=re,Sr=!m&&W.default===void 0;return e.jsxs(he,{id:k,name:k,value:!Ft&&typeof Rt<"u"?Rt:Tt,required:oe,disabled:de||pe,autoFocus:xe,autoComplete:wr,placeholder:ge,error:ve.length>0,onChange:xr,onBlur:br,onFocus:vr,...Cr,select:!0,InputLabelProps:{...yr,shrink:!Ft},SelectProps:{...jr,multiple:m},"aria-describedby":tn(k),children:[Sr&&e.jsx(P,{value:"",children:ge}),Array.isArray(we)&&we.map(({value:Re,label:Mr},Ht)=>{const kr=Array.isArray(lt)&&lt.indexOf(Re)!==-1;return e.jsx(P,{value:String(Ht),disabled:kr,children:Mr},Ht)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!y||!t?null:e.jsxs(Ne,{open:n,onClose:d,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Te,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{children:"Matterbridge plugin configuration"})]})}),e.jsx(Fe,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Yo,{schema:y,formData:t,uiSchema:S,validator:Xo,templates:{FieldTemplate:H,BaseInputTemplate:s,TitleFieldTemplate:j,DescriptionFieldTemplate:T,FieldHelpTemplate:_,FieldErrorTemplate:c,ErrorListTemplate:ee,WrapIfAdditionalTemplate:x,ArrayFieldTitleTemplate:g,ArrayFieldDescriptionTemplate:f,ArrayFieldItemTemplate:R,ArrayFieldTemplate:ce,ObjectFieldTemplate:ye,ButtonTemplates:{SubmitButton:ie,RemoveButton:je,AddButton:F,MoveUpButton:U,MoveDownButton:N}},widgets:{CheckboxWidget:G,SelectWidget:$},onChange:p,onSubmit:b})})]})};function gr(n){if(o&&console.log(`getQRColor (id: ${n?.id}) received matter:`,n??"undefined"),n===void 0||!n.online||!n.qrPairingCode&&!n.manualPairingCode&&!n.fabricInformations&&!n.sessionInformations)return"red";if(n.commissioned===!1&&n.qrPairingCode&&n.manualPairingCode)return"var(--primary-color)";let d=0,l=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&d++,i.numberOfActiveSubscriptions>0&&(l+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(d===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function Sn({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:a,removeListener:h,getUniqueId:u}=r.useContext(be),{showConfirmCancelDialog:v}=r.useContext(Le),t=r.useRef(u()),[I,y]=r.useState(null),[C,S]=r.useState(null),[E,A]=r.useState([]),q=[{label:"Name",id:"name",required:!0,render:(N,G,$,W)=>e.jsx(V,{title:`Plugin path ${$.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>c($),children:$.name})})},{label:"Description",id:"description",render:(N,G,$,W)=>e.jsx(V,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>c($),children:$.description})})},{label:"Version",id:"version",render:(N,G,$,W)=>e.jsx(e.Fragment,{children:e.jsx(V,{title:`Plugin v.${$.version}`,children:e.jsx("span",{children:$.version.split("-dev-")[0]+($.version.includes("-dev-")?"@dev":"")})})})},{label:"Author",id:"author",render:(N,G,$,W)=>e.jsx(e.Fragment,{children:$.author?$.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(N,G,$,W)=>e.jsx(e.Fragment,{children:$.type?$.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(N,G,$,W)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[C&&C.bridgeMode==="childbridge"&&!$.error&&$.enabled&&e.jsx(V,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:gr($.matter)},onClick:()=>{$.matter?.id&&d($.matter?.id)},size:"small",children:e.jsx(or,{})})}),C&&C.bridgeMode==="childbridge"&&!$.error&&$.enabled&&e.jsx(V,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>_($),size:"small",children:e.jsx(Ct,{})})}),e.jsx(V,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{disabled:$.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>je($),size:"small",children:e.jsx(_r,{})})}),C&&!C.readOnly&&e.jsx(V,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{p("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",$)},size:"small",children:e.jsx(qr,{})})}),$.enabled?e.jsx(V,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{p("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",$)},size:"small",children:e.jsx(zr,{})})}):e.jsx(e.Fragment,{}),$.enabled?e.jsx(e.Fragment,{}):e.jsx(V,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>ee($),size:"small",children:e.jsx(Ur,{})})}),e.jsx(V,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>g($),size:"small",children:e.jsx(nr,{})})}),e.jsx(V,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>f($),size:"small",children:e.jsx(ir,{})})}),$.latestVersion!==void 0&&$.latestVersion!==$.version&&C&&!C.readOnly&&e.jsx(V,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>H($),size:"small",children:e.jsx(Pe,{})})}),$.version.includes("-dev-")&&$.devVersion!==void 0&&$.devVersion!==$.version&&C&&!C.readOnly&&e.jsx(V,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>T($),size:"small",children:e.jsx(Pe,{})})}),C&&!C.readOnly&&e.jsx(V,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>s($),size:"small",children:e.jsx(sr,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(N,G,$,W)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:$.error?e.jsx(e.Fragment,{children:e.jsx(Qe,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:$.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Qe,{status:$.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:$.loaded&&$.started&&$.configured?e.jsx(e.Fragment,{children:e.jsx(Qe,{status:$.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Qe,{status:$.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Qe,{status:$.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Qe,{status:$.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const N=G=>{o&&console.log("HomePlugins received WebSocket Message:",G),G.method==="refresh_required"&&G.response.changed==="plugins"?(o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):G.method==="refresh_required"&&G.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and setting matter id ${G.response.matter?.id}`),A($=>{const W=$.findIndex(M=>M.matter?.id===G.response.matter?.id);if(W<0)return o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and matter id ${G.response.matter?.id} not found`),$;o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} set matter id ${G.response.matter?.id}`);const k=[...$];return k[W]={...k[W],matter:G.response.matter},k})):G.method==="refresh_required"&&G.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),G.id===t.current&&G.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${G.id}) received settings:`,G.response),y(G.response.systemInformation),S(G.response.matterbridgeInformation)):G.id===t.current&&G.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${G.id}) received ${G.response.length} plugins:`,G.response),A(G.response))};return a(N,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{h(N),o&&console.log("HomePlugins removed WebSocket listener")}},[a,h,i]),r.useEffect(()=>{l&&(o&&console.log("HomePlugins sending api requests"),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const w=r.useRef(null),p=(N,G,$,W)=>{o&&console.log(`handleActionWithConfirmCancel ${$} ${W.name}`),w.current=W,v(N,G,$,b,x)},b=N=>{o&&console.log(`handleConfirm action confirmed ${N} ${w.current?.name}`),N==="remove"&&w.current?j(w.current):N==="disable"&&w.current&&ee(w.current),w.current=null},x=N=>{o&&console.log(`handleCancel action canceled ${N} ${w.current?.name}`),w.current=null},H=N=>{o&&console.log("handleUpdatePlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:N.name,restart:!1}})},T=N=>{o&&console.log("handleUpdateDevPlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:N.name+"@dev",restart:!1}})},j=N=>{o&&console.log("handleRemovePlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})},_=N=>{o&&console.log("handleRestartPlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})},ee=N=>{o&&console.log("handleEnableDisablePlugin plugin:",N.name,"enabled:",N.enabled),N.enabled===!0?(N.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})):(N.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}}))},c=N=>{o&&console.log(`handleHomepagePlugin plugin: ${N.name} homepage: ${N.homepage}`),N.homepage&&window.open(N.homepage,"_blank")},s=N=>{o&&console.log("handleSponsorPlugin plugin:",N.name,"funding:",N.funding),N.funding&&window.open(N.funding,"_blank")},g=N=>{o&&console.log("handleHelpPlugin plugin:",N.name,"help:",N.help),N.help&&window.open(N.help,"_blank")},f=N=>{o&&console.log("handleChangelogPlugin plugin:",N.name,"changelog:",N.changelog),N.changelog&&window.open(N.changelog,"_blank")},[R,ce]=r.useState(),[ye,ie]=r.useState(!1),je=N=>{o&&console.log("handleConfigPlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:N.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:N.name}}),ce(N),F()},F=()=>{ie(!0)},U=()=>{ie(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs(Me,{children:[R&&e.jsx(Cn,{open:ye,onClose:U,plugin:R}),e.jsx(kt,{name:"Plugins",columns:q,rows:E,footerRight:"",footerLeft:""})]}):e.jsx($e,{})}const Mn=r.memo(Sn),kn=n=>`${n.pluginName}::${n.serial}`;function In({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:a,removeListener:h,getUniqueId:u}=r.useContext(be),[v,t]=r.useState(!1),[I,y]=r.useState(!0),[C,S]=r.useState(null),[E,A]=r.useState([]),[q,w]=r.useState([]),[p,b]=r.useState([]),[x,H]=r.useState([]),T=r.useRef(u()),j=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(c,s,g,f)=>g.reachable===!0?"Online":g.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(c,s)=>{const g=c.reachable===!0?1:c.reachable===!1?0:-1,f=s.reachable===!0?1:s.reachable===!1?0:-1;return g-f}},{label:"Power",id:"powerSource",render:(c,s,g,f)=>g.powerSource==="ac"||g.powerSource==="dc"?e.jsx(ar,{fontSize:"small",sx:{color:"var(--primary-color)"}}):g.powerSource==="ok"?e.jsx(St,{fontSize:"small",sx:{color:"green"}}):g.powerSource==="warning"?e.jsx(St,{fontSize:"small",sx:{color:"yellow"}}):g.powerSource==="critical"?e.jsx(St,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Actions",id:"selected",required:!0,render:(c,s,g,f)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[g.matter!==void 0?e.jsx(V,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>d(n===g.matter?.id?C?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:g.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:gr(g.matter)},children:e.jsx(or,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),g.configUrl?e.jsx(V,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>window.open(g.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(lr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),g.selected!==void 0?e.jsx(V,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Ve,{checked:g.selected,onChange:R=>ee(R,g),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],_=r.useCallback(c=>{c.selected=void 0;const s=E.find(R=>R.name===c.pluginName);if(!s)return console.error(`HomeDevices isSelected: plugin ${c.pluginName} not found for device ${c.name} `),c.selected;const g=s.schemaJson?.properties?.whiteList?.selectFrom;let f=s.configJson.postfix;return f===""&&(f=void 0),s.hasWhiteList===!0&&s.hasBlackList===!0&&g&&(c.selected=!0,g==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(f?c.serial.replace("-"+f,""):c.serial)&&(c.selected=!0),g==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(f?c.serial.replace("-"+f,""):c.serial)&&(c.selected=!1),g==="serial"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(f?c.serial.replace("-"+f,""):c.serial)&&(c.selected=!1),g==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(c.name)&&(c.selected=!0),g==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(c.name)&&(c.selected=!1),g==="name"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(c.name)&&(c.selected=!1)),c.selected},[E]);r.useEffect(()=>{const c=s=>{if(o&&console.log("HomeDevices received WebSocket Message:",s),s.method==="refresh_required"&&s.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and sending /api/plugins request`),i({id:T.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):s.method==="refresh_required"&&s.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and setting matter id ${s.response.matter?.id}`),H(g=>{const f=g.findIndex(ce=>ce.name.replaceAll(" ","")===s.response.matter?.id);if(f<0)return o&&console.debug(`HomeDevices: matter id ${s.response.matter?.id} not found`),g;const R=[...g];return R[f]={...R[f],matter:s.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and set matter id ${s.response.matter?.id}`),R})):s.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):s.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):s.method==="state_update"&&s.response.plugin&&s.response.serialNumber&&s.response.cluster.includes("BasicInformation")&&s.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${s.response.plugin} serial ${s.response.serialNumber} value ${s.response.value}`),w(g=>{const f=g.findIndex(R=>R.pluginName===s.response.plugin&&R.serial===s.response.serialNumber);return f<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${s.response.plugin} serial ${s.response.serialNumber}`),g):(g[f]={...g[f],reachable:s.response.value},[...g])})),s.id===T.current&&s.method==="/api/settings")o&&console.log(`HomeDevices (id: ${s.id}) received settings:`,s.response),S(s.response),t(s.response.matterbridgeInformation.restartRequired||s.response.matterbridgeInformation.fixedRestartRequired);else if(s.id===T.current&&s.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} plugins:`,s.response),s.response){let g=!0;for(const f of s.response)f.enabled===!0&&(f.loaded!==!0||f.started!==!0||f.error===!0)&&(g=!1);if(!g)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),y(!1),A(s.response),w([]),b([]),i({id:T.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const f of s.response)f.enabled===!0&&f.loaded===!0&&f.started===!0&&f.error!==!0&&(i({id:T.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:f.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${f.name}`))}}else if(s.id===T.current&&s.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} devices:`,s.response),s.response){for(const g of s.response)g.selected=_(g);w(s.response)}}else s.id===T.current&&s.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} selectDevices for plugin ${s.response&&s.response.length>0?s.response[0].pluginName:"without select devices"}:`,s.response),s.response&&s.response.length>0&&b(g=>{const f=g.filter(ce=>ce.pluginName!==s.response[0].pluginName),R=s.response.map(ce=>({...ce,selected:_(ce)}));return[...f,...R]}))};return a(c,T.current),o&&console.log(`HomeDevices added WebSocket listener id ${T.current}`),()=>{h(c),o&&console.log("HomeDevices removed WebSocket listener")}},[E,a,h,i,_]),r.useEffect(()=>{if(q.length===0&&p.length===0){H([]);return}o&&console.log(`HomeDevices mixing devices (${q.length}) and selectDevices (${p.length})`);const c=[];for(const s of q)c.push(s);for(const s of p)q.find(g=>g.pluginName===s.pluginName&&g.serial.includes(s.serial))||c.push(s);c.length>0&&(H(c),o&&console.log(`HomeDevices mixed ${c.length} devices and selectDevices`))},[E,q,p,H]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:T.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:T.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const ee=(c,s)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${c.target.checked} for device ${s.name} serial ${s.serial}`),q.findIndex(g=>g.pluginName===s.pluginName&&g.serial===s.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices, trying in mixedDevices`),H(g=>{const f=g.findIndex(R=>R.pluginName===s.pluginName&&R.serial===s.serial);return f<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in mixedDevices`),g):(g[f]={...g[f],selected:c.target.checked},[...g])})):w(g=>{const f=g.findIndex(R=>R.pluginName===s.pluginName&&R.serial===s.serial);return f<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices`),g):(g[f]={...g[f],selected:c.target.checked},[...g])}),c.target.checked?i({id:T.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}}):i({id:T.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}})};return o&&console.log("HomeDevices rendering..."),l?e.jsx(Me,{style:{flex:"1 1 auto"},children:e.jsx(kt,{name:"Devices",getRowKey:kn,rows:x,columns:j,footerLeft:I?"Waiting for the plugins to fully load...":`Registered devices: ${q.length.toString()}/${x.length.toString()}`,footerRight:v?"Restart required":""})}):e.jsx($e,{})}const Dn=r.memo(In);function at({children:n,style:d,name:l}){const{setCurrentPage:i}=r.useContext(Le);i(l),o&&console.log(`MbfPage: current page set to ${l}`);const a={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...a,...d},children:n})}const Pn=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(o&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(o&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Ln(){const{messages:n,logAutoScroll:d}=r.useContext(pr),[l,i]=r.useState(!1),a=r.useRef(null),h=r.useRef(0),u=r.useRef(null),v=r.useMemo(()=>Pn(),[]),t=S=>i(!0),I=S=>i(!1);r.useEffect(()=>{if(o&&console.log(`WebSocketLogs logAutoScroll: ${d} isHovering: ${l}`),d&&!l&&!v){const S=Date.now();S-h.current>=500?(o&&console.log("WebSocketLogs auto-scroll to bottom"),h.current=S,a.current?.scrollIntoView({behavior:"smooth",block:"end"})):(o&&console.log("WebSocketLogs auto-scroll skipped to avoid flicker"),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{a.current?.scrollIntoView({behavior:"smooth"}),h.current=Date.now()},1e3))}},[n,d,l,v]);const y=S=>{switch(S.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"#5c0e91"}},C=S=>{switch(S.toLowerCase()){case"warn":return"black";default:return"white"}};return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:t,onMouseLeave:I,children:[n.map((S,E)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:y(S.level),color:C(S.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:S.level}),S.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+S.time+"]"}),S.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+S.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:S.message})]},E)),e.jsx("div",{ref:a})]})})}const mr=r.memo(Ln);function $n(){const[n,d]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,h]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{online:u}=r.useContext(be);return o&&console.log("HomeLogs rendering..."),u?e.jsxs(Me,{style:{flex:"1 1 auto"},children:[e.jsxs(_e,{children:[e.jsx(Oe,{children:"Logs"}),e.jsxs(Oe,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',l,'" Scroll: ',a?"auto":"manual"]})]}),e.jsx(st,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(mr,{})})]}):e.jsx($e,{})}const Wn=r.memo($n);function Nn(){const{online:n}=r.useContext(be);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(Me,{children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(ae,{onClick:()=>window.location.reload(),endIcon:e.jsx(Br,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx($e,{})}const Tn=r.memo(Nn);function Fn({changelog:n}){const{online:d}=r.useContext(be);return o&&console.log("HomeShowChangelog rendering..."),d?e.jsxs(Me,{children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(ae,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Qr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ae,{onClick:()=>window.location.reload(),endIcon:e.jsx(Kr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx($e,{})}const Rn=r.memo(Fn);function Hn({matterbridgeInfo:n}){o&&console.log("MatterbridgeInfoTable:",n);const d=["matterbridgeLatestVersion","matterbridgeDevVersion","matterFileLogger","fileLogger","matterLoggerLevel","loggerLevel","cccvirtualMode","--bridgeMode","--restartMode","---restartRequired","fixedRestartRequired","---updateRequired","matterMdnsInterface","matterIpv4Address","matterIpv6Address","readOnly","shellyBoard","shellySysUpdate","shellyMainUpdate","matterPort","matterDiscriminator","matterPasscode"],[l,i]=r.useState(!1);return!n||l?null:(o&&console.log("MatterbridgeInfoTable rendering..."),e.jsxs(Me,{style:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(_e,{children:[e.jsx(Oe,{children:"Matterbridge Information"}),e.jsx(tt,{onClose:()=>i(!0)})]}),e.jsx(st,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(n).filter(([a,h])=>!d.includes(a)&&h!==null&&h!==void 0&&h!=="").map(([a,h],u)=>e.jsxs("tr",{className:u%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:a.replace("matterbridgeVersion","matterbridge v.").replace("matterbridgeLatestVersion","matterbridge latest v.").replace("matterbridgeDevVersion","matterbridge dev v.").replace("frontendVersion","frontend v.").replace("homeDirectory","home").replace("rootDirectory","root").replace("matterbridgeDirectory","storage").replace("matterbridgeCertDirectory","cert").replace("matterbridgePluginDirectory","plugins").replace("globalModulesDirectory","modules")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(ur,{value:typeof h!="string"?h.toString():h,maxChars:24})})]},a))})})})]}))}const On=r.memo(Hn);function Vn(){const[n,d]=r.useState(null),[l,i]=r.useState(null),[a,h]=r.useState([]),[u]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[v,t]=r.useState(localStorage.getItem("homePageMode")??"devices"),[I,y]=r.useState(""),[C,S]=r.useState(!1),[E,A]=r.useState(!1),[q,w]=r.useState(null),{mobile:p}=r.useContext(Le),{addListener:b,removeListener:x,online:H,sendMessage:T,getUniqueId:j}=r.useContext(be),_=r.useRef(j());return r.useEffect(()=>{const ee=c=>{o&&console.log("Home received WebSocket Message:",c),c.method==="refresh_required"&&c.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${c.response.changed} and sending /api/settings request`),w(null),h([]),T({id:_.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),T({id:_.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),c.method==="/api/settings"&&c.id===_.current&&(o&&console.log("Home received settings:",c.response),d(c.response.systemInformation),i(c.response.matterbridgeInformation),c.response.matterbridgeInformation.matterbridgeVersion&&y(`https://github.com/Luligu/matterbridge/blob/${c.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&c.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",c.response.matterbridgeInformation.frontendVersion):c.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&c.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",c.response.matterbridgeInformation.frontendVersion),A(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",c.response.matterbridgeInformation.matterbridgeVersion):c.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",c.response.matterbridgeInformation.matterbridgeVersion),S(!0)),c.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),t("devices")))),c.method==="/api/plugins"&&c.id===_.current&&(o&&console.log("Home received plugins:",c.response),h(c.response))};return b(ee,_.current),o&&console.log(`Home added WebSocket listener id ${_.current}`),()=>{x(ee),o&&console.log("Home removed WebSocket listener")}},[b,x,T]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${q}`),l?.bridgeMode==="bridge"&&!q&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),w("Matterbridge")),l?.bridgeMode==="childbridge"&&!q&&a){for(const ee of a)if(ee.matter?.id){o&&console.log(`Home storeId effect set storeId to ${ee.matter.id}`),w(ee.matter.id);break}}},[l,a,q]),r.useEffect(()=>{H&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),T({id:_.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),T({id:_.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[H,T]),o&&console.log("Home rendering..."),!H||!n||!l?e.jsx($e,{}):e.jsxs(at,{name:"Home",style:p?{flexDirection:"column",alignItems:"center"}:{flexDirection:"row"},children:[(!p||!1)&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(Zt,{id:q}),e.jsx(Gt,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[E&&e.jsx(Tn,{}),C&&e.jsx(Rn,{changelog:I}),p&&e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(Zt,{id:q}),e.jsx(Gt,{systemInfo:n,compact:!0}),e.jsx(On,{matterbridgeInfo:l})]}),u&&!l.readOnly&&e.jsx(fn,{}),u&&e.jsx(Mn,{storeId:q,setStoreId:w}),v==="devices"&&e.jsx(Dn,{storeId:q,setStoreId:w}),v==="logs"&&e.jsx(Wn,{})]})]})}const En=r.memo(Vn),jt=!1,Xt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},An={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},_n={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},er={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},qn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},zn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Un={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Bn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Qn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Lt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},Kn=[256,257,268,269],Gn=[266,267],Jn=[259,260,261,271,272],Zn=[256,257,268,269,266,267,259,260,261,272];function J({icon:n,iconColor:d,cluster:l,value:i,unit:a,prefix:h}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${a}"`),h=h??!1,e.jsxs(Y,{sx:Xt,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...An,color:d??"var(--primary-color)"}}),e.jsxs(Y,{sx:{...Xt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[a&&h===!0&&e.jsx(le,{sx:er,children:a},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(le,{sx:_n,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${l.clusterId}-${l.attributeId}-value`),a&&h===!1&&e.jsx(le,{sx:er,children:a},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function Yn({device:n,endpoint:d,id:l,deviceType:i,clusters:a}){const h=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let u="";o&&console.log(`Device "${n.name}" endpoint "${d}" id "${l}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${a?.length})`);const v=a.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(v){let t="";v.map(I=>{I.label&&(t+=I.label+" ")}),u=t.trim()}if(i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>u=`${t.attributeLocalValue} mV`),Zn.includes(i)&&a.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>u=`Level ${t.attributeValue}`),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>u=`Position ${t.attributeLocalValue/100}%`),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>u=`Heat ${t.attributeLocalValue/100}°C `),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>u=u+`Cool ${t.attributeLocalValue/100}°C`),i===118&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>u=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>u=`${t.attributeLocalValue/1e3} V, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>u=u+`${t.attributeLocalValue/1e3} A, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>u=u+`${t.attributeLocalValue/1e3} W`),i===39){const t=a.find(y=>y.clusterName==="ModeSelect"&&y.attributeName==="currentMode")?.attributeLocalValue;u=a.find(y=>y.clusterName==="ModeSelect"&&y.attributeName==="supportedModes")?.attributeLocalValue?.find(y=>y.mode===t)?.label||"Unknown"}if(i===116){const t=a.find(y=>y.clusterName==="RvcRunMode"&&y.attributeName==="currentMode")?.attributeLocalValue;u=a.find(y=>y.clusterName==="RvcRunMode"&&y.attributeName==="supportedModes")?.attributeLocalValue?.find(y=>y.mode===t)?.label||"Unknown"}return e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:t.attributeLocalValue===!0?e.jsx(it,{}):e.jsx(Gr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(J,{icon:e.jsx(St,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(J,{icon:e.jsx(ar,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&a.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),Kn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Gn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Jn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Ro,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Oo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:e.jsx(_t,{}),cluster:t,value:"Oven"})),i===112&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:e.jsx(Zr,{}),cluster:t,value:"Fridge"})),i===113&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(_t,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Eo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(J,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Ao,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&a.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(J,{icon:t.attributeValue==="1"?e.jsx(Xr,{}):e.jsx(eo,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(J,{icon:e.jsx(to,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&a.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:_o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&a.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(J,{icon:e.jsx(ro,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(oo,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(J,{icon:e.jsx(qt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(J,{icon:e.jsx(qt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(no,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(io,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(so,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&a.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:qo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&a.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:zo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&a.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Uo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Qo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Kt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Kt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&a.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(J,{icon:e.jsx(ao,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&a.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:h[t.attributeLocalValue??0]})),i===770&&a.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(lo,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&a.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&a.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(co,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&a.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(po,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:t.attributeValue==="true"?e.jsx(uo,{}):e.jsx(go,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&a.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(J,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(mo,{}):e.jsx(ho,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&a.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(fo,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&a.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(J,{icon:e.jsx(xo,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Y,{sx:qn,children:e.jsx(le,{sx:zn,children:u})}),e.jsx(Y,{sx:Un,children:e.jsx(le,{sx:Bn,children:n.name})}),e.jsxs(Y,{sx:Qn,children:[o&&e.jsx(le,{sx:Lt,children:d}),e.jsx(le,{sx:Lt,children:l}),o&&e.jsxs(le,{sx:Lt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Xn({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(be),[u,v]=r.useState([]),[t,I]=r.useState({}),[y,C]=r.useState({}),[S,E]=r.useState({}),A=r.useRef(h()),q=r.useCallback(b=>{(o||jt)&&console.log(`DevicesIcons received state_update "${b.response.cluster}.${b.response.attribute}" for "${b.response.id}:${b.response.number}": "${b.response.value}"`,b.response);const x=u.find(T=>T.pluginName===b.response.plugin&&T.serial===b.response.serialNumber);if(!x){(o||jt)&&console.warn(`DevicesIcons updater device of plugin "${b.response.plugin}" serial "${b.response.serialNumber}" number "${b.response.number}" id "${b.response.id}" not found in devices(${u.length})`);return}const H=S[x.serial]?.find(T=>T.endpoint===b.response.number.toString()&&T.clusterName===b.response.cluster&&T.attributeName===b.response.attribute);if(!H){(o||jt)&&console.warn(`DevicesIcons updater device "${x.name}" serial "${x.serial}" cluster "${b.response.cluster}" attribute "${b.response.attribute}" not found in clusters(${S[x.serial]?.length})`);return}H.attributeValue=String(b.response.value),H.attributeLocalValue=b.response.value,E({...S}),(o||jt)&&console.log(`DevicesIcons updated "${H.clusterName}.${H.attributeName}" for device "${x.name}" serial "${x.serial}" to "${H.attributeValue}"`)},[S,u]),w=r.useCallback(b=>{if(o&&console.log(`DevicesIcons received for device "${b.response.deviceName}" serial "${b.response.serialNumber}" deviceTypes (${b.response.deviceTypes.length}) "${b.response.deviceTypes.join(",")}" clusters (${b.response.clusters.length}):`,b.response),b.response.clusters.length===0)return;const x=b.response.serialNumber;t[x]=[],y[x]=b.response.deviceTypes,S[x]=[];for(const H of b.response.clusters)t[x].find(T=>T.endpoint===H.endpoint)||t[x].push({endpoint:H.endpoint,id:H.id,deviceTypes:H.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(H.clusterName)&&S[x].push(H);I({...t}),C({...y}),E({...S}),o&&console.log(`DevicesIcons endpoints for "${x}":`,t[x]),o&&console.log(`DevicesIcons deviceTypes for "${x}":`,y[x]),o&&console.log(`DevicesIcons clusters for "${x}":`,S[x])},[S,y,t]);r.useEffect(()=>{const b=x=>{if(o&&console.log("DevicesIcons received WebSocket Message:",x),x.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${x.response.changed} and sending api requests`),l({id:A.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(x.method==="state_update"&&x.response)q(x);else if(x.method==="/api/devices"&&x.response){o&&console.log(`DevicesIcons received ${x.response.length} devices:`,x.response),v(x.response),I({}),C({}),E({});for(const H of x.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:A.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:H.pluginName,endpoint:H.endpoint||0}})}else x.method==="/api/clusters"&&x.response&&w(x)};return i(b,A.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{a(b),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[u]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),d&&(o&&console.log("DevicesIcons useEffect online sending api requests"),l({id:A.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),o&&console.log("DevicesIcons useEffect online mounted"),()=>{o&&console.log("DevicesIcons useEffect online unmounted")}),[d,l]);const p=r.memo(Yn);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:u.filter(b=>b.name.toLowerCase().includes(n)||b.serial.toLowerCase().includes(n)).map(b=>t[b.serial]&&t[b.serial].map(x=>x.deviceTypes.map(H=>e.jsx(p,{device:b,endpoint:x.endpoint,id:x.id,deviceType:H,clusters:S[b.serial].filter(T=>T.endpoint===x.endpoint)},`${b.pluginName}-${b.uniqueId}-${x.endpoint}-${x.id}-${H.toString()}`))))})}const ei=r.memo(Xn),ti=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(n,d,l,i)=>l.configUrl?e.jsx(Q,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(lr,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],ri=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,d,l,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(a=>`0x${a.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,render:(n,d,l,i)=>e.jsx(V,{title:String(n),componentsProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("div",{style:{maxWidth:"500px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(n)})})}],oi=n=>`${n.pluginName}::${n.uniqueId}`,ni=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function ii({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(be),[u,v]=r.useState([]),[t,I]=r.useState(u),[y,C]=r.useState([]),[S,E]=r.useState(0),[A,q]=r.useState(null),[w,p]=r.useState(null),[b,x]=r.useState(null),[H,T]=r.useState(null),j=r.useRef(h()),_=r.useRef(t),ee=r.useCallback(s=>{o&&console.log(`DevicesTable received state_update "${s.response.cluster}.${s.response.attribute}" for "${s.response.id}:${s.response.number}": "${s.response.value}"`,s.response);const g=_.current.find(f=>f.pluginName===s.response.plugin&&f.uniqueId===s.response.uniqueId);if(!g){o&&console.warn(`DevicesTable updater device of plugin "${s.response.plugin}" serial "${s.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(A&&w&&g.pluginName===A&&g.uniqueId===H&&s.response.number.toString()===w){const f=y.find(R=>R.endpoint===s.response.number.toString()&&R.clusterName===s.response.cluster&&R.attributeName===s.response.attribute);if(!f){o&&console.warn(`DevicesTable updater cluster ${s.response.cluster}.${s.response.attribute} for device "${g.name}" serial "${g.serial}" not found in clusters`);return}f.attributeValue=typeof s.response.value=="object"?JSON.stringify(s.response.value,void 0,1).replaceAll('"',""):String(s.response.value),f.attributeLocalValue=s.response.value,C([...y]),o&&console.log(`DevicesTable updated attribute ${f.clusterName}.${f.attributeName} for device "${g.name}" serial "${g.serial}" to "${f.attributeValue}"`)}},[y,w,A,H]);r.useEffect(()=>{const s=g=>{if(o&&console.log("DevicesTable received WebSocket Message:",g),g.method==="refresh_required"&&g.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${g.response.changed} and sending /api/devices request`),l({id:j.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(g.method==="state_update"&&g.response)ee(g);else if(g.method==="/api/devices")o&&console.log(`DevicesTable received ${g.response.length} devices:`,g.response),v(g.response);else if(g.method==="/api/clusters"){o&&console.log(`DevicesTable received ${g.response.clusters.length} clusters for plugin ${g.response.plugin}:`,g.response),C(g.response.clusters);const f={};for(const R of g.response.clusters)o&&console.log("Cluster:",R.endpoint),f[R.endpoint]?f[R.endpoint]++:f[R.endpoint]=1;E(Object.keys(f).length)}};return i(s,j.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{a(s),o&&console.log("DevicesTable removed WebSocket listener")}},[l,i,a,ee]),r.useEffect(()=>{d&&(o&&console.log("DevicesTable sending api requests with id ",j.current),l({id:j.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:j.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:j.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[d,l]),r.useEffect(()=>{A&&w&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:j.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:A,endpoint:Number(w)}}))},[A,w,l]),r.useEffect(()=>{if(n===""){I(u),_.current=u;return}const s=u.filter(g=>g.name.toLowerCase().includes(n)||g.serial.toLowerCase().includes(n));I(s),_.current=s},[u,n]);const c=s=>{if(s.uniqueId===H){T(null),q(null),p(null),x(null);return}T(s.uniqueId),q(s.pluginName),p(s.endpoint?s.endpoint.toString():null),x(s.name)};return o&&console.log("DevicesTable rendering..."),d?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${A&&w?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(kt,{name:"Registered devices",getRowKey:oi,onRowClick:c,rows:t,columns:ti,footerLeft:`Total devices: ${t.length.toString()}`})}),A&&w&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(kt,{name:"Clusters",title:b||"",getRowKey:ni,rows:y,columns:ri,footerLeft:`Total child endpoints: ${S-1}`})})]}):e.jsx($e,{})}const si=r.memo(ii);function ai(){const{online:n}=r.useContext(be),[d,l]=r.useState(""),[i,a]=r.useState("icon");r.useEffect(()=>{const v=localStorage.getItem("devicesFilter");v&&l(v)},[]),r.useEffect(()=>{const v=localStorage.getItem("devicesViewMode");v&&a(v)},[]);const h=v=>{l(v.target.value.toLowerCase()),localStorage.setItem("devicesFilter",v.target.value.toLowerCase())},u=v=>{a(v),localStorage.setItem("devicesViewMode",v)};return o&&console.log("Devices rendering..."),n?e.jsxs(at,{name:"Devices",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",padding:0,margin:0,gap:"20px",width:"100%"},children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(le,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{variant:"outlined",value:d,onChange:h,placeholder:"Enter the device name or serial",sx:{width:"260px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(le,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(Q,{onClick:()=>u("table"),"aria-label":"Table View",disabled:i==="table",children:e.jsx(V,{title:"Table View",children:e.jsx(bo,{style:{color:i==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(Q,{onClick:()=>u("icon"),"aria-label":"Icon View",disabled:i==="icon",children:e.jsx(V,{title:"Icon View (beta)",children:e.jsx(vo,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(si,{filter:d}),i==="icon"&&e.jsx(ei,{filter:d})]}):e.jsx($e,{})}const li=r.memo(ai);function di(){const[n,d]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,h]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:u,setLogFilterLevel:v,setLogFilterSearch:t,online:I,setLogAutoScroll:y,filterLogMessages:C}=r.useContext(be),S=w=>{d(w.target.value),v(w.target.value),C(w.target.value,l),localStorage.setItem("logFilterLevel",w.target.value),o&&console.log("handleChangeLevel called with value:",w.target.value)},E=w=>{i(w.target.value),t(w.target.value),C(n,w.target.value),localStorage.setItem("logFilterSearch",w.target.value),o&&console.log("handleChangeSearch called with value:",w.target.value)},A=w=>{h(w.target.checked),y(w.target.checked),C(n,l),localStorage.setItem("logAutoScroll",w.target.checked?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",w.target.checked)},q=()=>{o&&console.log("handleClearLogsClick called"),u([])};return o&&console.log("Logs rendering..."),I?e.jsxs(at,{name:"Logs",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"15px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(zt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Xe,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:n,onChange:S,children:[e.jsx(P,{value:"debug",children:"Debug"}),e.jsx(P,{value:"info",children:"Info"}),e.jsx(P,{value:"notice",children:"Notice"}),e.jsx(P,{value:"warn",children:"Warn"}),e.jsx(P,{value:"error",children:"Error"}),e.jsx(P,{value:"fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(zt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(he,{style:{width:"210px"},size:"small",id:"logsearch",variant:"outlined",value:l,onChange:E,slotProps:{input:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}})]}),e.jsx(ze,{control:e.jsx(Ve,{checked:a,onChange:A}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center"},children:e.jsx(V,{title:"Clear the logs",children:e.jsx(ae,{onClick:q,endIcon:e.jsx(Nt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Clear"})})})]}),e.jsx("div",{style:{flex:"1",overflow:"auto",margin:"0px",padding:"0px"},children:e.jsx(mr,{})})]}):e.jsx($e,{})}const ci=r.memo(di),pi=({open:n,ip:d,onClose:l,onSave:i})=>{const a=d?d.split(".").slice(0,3).join(".")+".1":"",[h,u]=r.useState("dhcp"),[v,t]=r.useState({ip:d??"",subnet:"255.255.255.0",gateway:a,dns:a}),I=S=>E=>{t({...v,[S]:E.target.value})},y=()=>{l()},C=()=>{i({type:h,...v}),l()};return e.jsxs(Ne,{open:n,onClose:(S,E)=>{E==="backdropClick"||E==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Te,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Network Configuration"})]})}),e.jsxs(Fe,{dividers:!0,children:[e.jsxs(dr,{component:"fieldset",fullWidth:!0,children:[e.jsx(Se,{component:"legend",children:"Select IP Configuration"}),e.jsxs(cr,{row:!0,value:h,onChange:S=>u(S.target.value),children:[e.jsx(ze,{value:"dhcp",control:e.jsx(Mt,{}),label:"DHCP"}),e.jsx(ze,{value:"static",control:e.jsx(Mt,{}),label:"Static"})]})]}),h==="static"&&e.jsxs(Ee,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ee,{size:6,children:e.jsx(he,{label:"IP Address",fullWidth:!0,value:v.ip,onChange:I("ip")})}),e.jsx(Ee,{size:6,children:e.jsx(he,{label:"Subnet Mask",fullWidth:!0,value:v.subnet,onChange:I("subnet")})}),e.jsx(Ee,{size:6,children:e.jsx(he,{label:"Gateway",fullWidth:!0,value:v.gateway,onChange:I("gateway")})}),e.jsx(Ee,{size:6,children:e.jsx(he,{label:"DNS Server",fullWidth:!0,value:v.dns,onChange:I("dns")})})]})]}),e.jsxs(Ae,{children:[e.jsx(ae,{onClick:y,children:"Cancel"}),e.jsx(ae,{variant:"contained",onClick:C,children:"Save"})]})]})},ui=({open:n,onClose:d,onSave:l})=>{const[i,a]=r.useState(""),[h,u]=r.useState(""),v=E=>{a(E.target.value)},t=E=>{u(E.target.value)},I=i.length>0&&i===h,y=()=>{d()},C=()=>{I&&(l(i),d())},S=()=>{l(""),d()};return e.jsxs(Ne,{open:n,onClose:(E,A)=>{A==="backdropClick"||A==="escapeKeyDown"||d()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Change Password"})]})}),e.jsx(Fe,{dividers:!0,children:e.jsx(dr,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(Ee,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Ee,{size:12,children:e.jsx(he,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:v})}),e.jsx(Ee,{size:12,children:e.jsx(he,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:h,onChange:t,error:h!==""&&i!==h,helperText:h!==""&&i!==h?"Passwords do not match":""})})]})})}),e.jsxs(Ae,{children:[e.jsx(ae,{onClick:y,children:"Cancel"}),e.jsx(ae,{variant:"contained",onClick:C,disabled:!I,children:"Change"}),e.jsx(ae,{variant:"contained",onClick:S,children:"Reset"})]})]})};function Ze(n=1e3){let d=null;const l=(i=>{d!==null&&window.clearTimeout(d),d=window.setTimeout(()=>{i(),d=null},n)});return l.cancel=()=>{d!==null&&(window.clearTimeout(d),d=null)},l}const ue=335;function gi(){const{online:n,addListener:d,removeListener:l,sendMessage:i,getUniqueId:a}=r.useContext(be),[h,u]=r.useState(null),[v,t]=r.useState(null),I=r.useRef(a());return r.useEffect(()=>{const y=C=>{o&&console.log("Settings received WebSocket Message:",C),C.method==="refresh_required"&&C.response.changed==="settings"?(o&&console.log(`Settings received refresh_required: changed=${C.response.changed} and sending /api/settings request`),i({id:I.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):C.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",C.response),u(C.response.matterbridgeInformation),t(C.response.systemInformation))};return d(y,I.current),o&&console.log("Settings added WebSocket listener"),()=>{l(y),o&&console.log("Settings removed WebSocket listener")}},[d,l,i]),r.useEffect(()=>{n&&(o&&console.log("Settings received online"),i({id:I.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[n,i]),o&&console.log("Settings rendering..."),!n||!h||!v?e.jsx($e,{}):e.jsx(at,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(mi,{matterbridgeInfo:h,systemInfo:v}),e.jsx(hi,{matterbridgeInfo:h}),e.jsx(fi,{matterbridgeInfo:h}),e.jsx(xi,{systemInfo:v})]})})}function mi({matterbridgeInfo:n,systemInfo:d}){const{sendMessage:l,getUniqueId:i}=r.useContext(be),[a,h]=r.useState("bridge"),[u,v]=r.useState("Info"),[t,I]=r.useState(!1),[y,C]=r.useState("dark"),[S,E]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[A,q]=r.useState(localStorage.getItem("homePageMode")??"devices"),[w,p]=r.useState(localStorage.getItem("virtualMode")??"outlet"),b=r.useRef(i()),[x,H]=r.useState(!1),T=()=>H(!1),j=F=>{o&&console.log("handleSaveNetConfig called with config:",F),l({id:b.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:F})},[_,ee]=r.useState(!1),c=()=>ee(!1),s=F=>{o&&console.log("handleSaveChangePassword called with password:",F),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:F}}),Ii(F)};r.useEffect(()=>{n&&(h(n.bridgeMode==="bridge"?"bridge":"childbridge"),v(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),I(n.fileLogger),p(n.virtualMode))},[n]),r.useEffect(()=>{const F=localStorage.getItem("frontendTheme");F&&C(F)},[]);const g=F=>{o&&console.log("handleChangeBridgeMode called with value:",F.target.value),h(F.target.value),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:F.target.value}})},f=F=>{o&&console.log("handleChangeMbLoggerLevel called with value:",F.target.value),v(F.target.value),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:F.target.value}})},R=F=>{o&&console.log("handleLogOnFileMbChange called with value:",F.target.checked),I(F.target.checked),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:F.target.checked}})},ce=F=>{const U=F.target.value;o&&console.log("handleChangeTheme called with value:",U),C(U),localStorage.setItem("frontendTheme",U),document.body.setAttribute("frontend-theme",U)},ye=F=>{const U=F.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",U),E(U),localStorage.setItem("homePagePlugins",U?"true":"false")},ie=F=>{const U=F.target.value;o&&console.log("handleChangeHomePageMode called with value:",U),q(U),localStorage.setItem("homePageMode",U)},je=F=>{const U=F.target.value;o&&console.log("handleChangeVirtualMode called with value:",U),p(U),localStorage.setItem("virtualMode",U),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:U}})};return!n||!d?null:e.jsxs(Me,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(pi,{open:x,ip:d.ipv4Address,onClose:T,onSave:j}),e.jsx(ui,{open:_,onClose:c,onSave:s}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:`${ue-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Mode:"}),e.jsxs(cr,{row:!0,name:"mode-buttons-group",value:a,onChange:g,children:[e.jsx(ze,{value:"bridge",control:e.jsx(Mt,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(ze,{value:"childbridge",control:e.jsx(Mt,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:u,onChange:f,children:[e.jsx(P,{value:"Debug",children:"Debug"}),e.jsx(P,{value:"Info",children:"Info"}),e.jsx(P,{value:"Notice",children:"Notice"}),e.jsx(P,{value:"Warn",children:"Warn"}),e.jsx(P,{value:"Error",children:"Error"}),e.jsx(P,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mblogger-file-label",children:"Log on file:"}),e.jsx(Ve,{checked:t,onChange:R,id:"mblogger-file",name:"logOnFileMb"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:y,onChange:ce,children:[e.jsx(P,{value:"classic",children:"Classic"}),e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Ve,{checked:S,onChange:ye,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:A,onChange:ie,children:[e.jsx(P,{value:"logs",children:"Logs"}),e.jsx(P,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:w,onChange:je,children:[e.jsx(P,{value:"disabled",children:"Disabled"}),e.jsx(P,{value:"outlet",children:"Outlet"}),e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"switch",children:"Switch"}),e.jsx(P,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>ee(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>H(!0),children:"Configure IP"})})]})})]})}function hi({matterbridgeInfo:n}){const{sendMessage:d,getUniqueId:l}=r.useContext(be),[i,a]=r.useState("Info"),[h,u]=r.useState(!1),[v,t]=r.useState(""),[I,y]=r.useState(""),[C,S]=r.useState(""),[E,A]=r.useState(""),[q,w]=r.useState(""),[p,b]=r.useState(""),x=r.useRef(l()),H=r.useMemo(()=>Ze(1e3),[]),T=r.useMemo(()=>Ze(1e3),[]),j=r.useMemo(()=>Ze(1e3),[]),_=r.useMemo(()=>Ze(1e3),[]),ee=r.useMemo(()=>Ze(1e3),[]),c=r.useMemo(()=>Ze(1e3),[]);r.useEffect(()=>{n&&(a(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),u(n.matterFileLogger),t(n.matterMdnsInterface||""),y(n.matterIpv4Address||""),S(n.matterIpv6Address||""),A(n.matterPort?n.matterPort.toString():""),w(n.matterDiscriminator?n.matterDiscriminator.toString():""),b(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>H.cancel(),[H]),r.useEffect(()=>()=>T.cancel(),[T]),r.useEffect(()=>()=>j.cancel(),[j]),r.useEffect(()=>()=>_.cancel(),[_]),r.useEffect(()=>()=>ee.cancel(),[ee]),r.useEffect(()=>()=>c.cancel(),[c]);const s=F=>{o&&console.log("handleChangeMjLoggerLevel called with value:",F.target.value),a(F.target.value),d({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:F.target.value}})},g=F=>{o&&console.log("handleLogOnFileMjChange called with value:",F.target.checked),u(F.target.checked),d({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:F.target.checked}})},f=F=>{o&&console.log("handleChangeMdnsInterface called with value:",F.target.value);const U=F.target.value;t(U),H(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",U),d({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:U}})})},R=F=>{o&&console.log("handleChangeIpv4Address called with value:",F.target.value);const U=F.target.value;y(U),T(()=>{o&&console.log("debounced sendMessage setipv4address with value:",U),d({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:U}})})},ce=F=>{o&&console.log("handleChangeIpv6Address called with value:",F.target.value);const U=F.target.value;S(U),j(()=>{o&&console.log("debounced sendMessage setipv6address with value:",U),d({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:U}})})},ye=F=>{o&&console.log("handleChangeMatterPort called with value:",F.target.value);const U=F.target.value;A(U),_(()=>{o&&console.log("debounced sendMessage setmatterport with value:",U),d({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:U}})})},ie=F=>{o&&console.log("handleChangeMatterDiscriminator called with value:",F.target.value);const U=F.target.value;w(U),ee(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",U),d({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:U}})})},je=F=>{o&&console.log("handleChangemMatterPasscode called with value:",F.target.value);const U=F.target.value;b(U),c(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",U),d({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:U}})})};return n?e.jsxs(Me,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"20px",margin:"0px",padding:"10px",width:`${ue-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mjlogger-level-label",children:"Logger level:"}),e.jsxs(Xe,{style:{height:"30px"},labelId:"mjlogger-level-label",id:"mjlogger-level",value:i,onChange:s,children:[e.jsx(P,{value:"Debug",children:"Debug"}),e.jsx(P,{value:"Info",children:"Info"}),e.jsx(P,{value:"Notice",children:"Notice"}),e.jsx(P,{value:"Warn",children:"Warn"}),e.jsx(P,{value:"Error",children:"Error"}),e.jsx(P,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mjlogger-file-label",children:"Log on file:"}),e.jsx(Ve,{checked:h,onChange:g,id:"mjlogger-file",name:"logOnFileMj"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(he,{value:v,onChange:f,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(he,{value:I,onChange:R,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(he,{value:C,onChange:ce,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(he,{value:E,onChange:ye,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(he,{value:q,onChange:ie,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(he,{value:p,onChange:je,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function fi({matterbridgeInfo:n}){return n?e.jsxs(Me,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(ke,{value:n.matterbridgeVersion,label:"Current Version",width:ue}),e.jsx(ke,{value:n.matterbridgeLatestVersion,label:"Latest Version",width:ue}),e.jsx(ke,{value:n.rootDirectory,label:"Root Directory",width:ue}),e.jsx(ke,{value:n.homeDirectory,label:"Home Directory",width:ue}),e.jsx(ke,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory",width:ue}),e.jsx(ke,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory",width:ue}),e.jsx(ke,{value:n.globalModulesDirectory,label:"Global Module Directory",width:ue})]})})]}):null}function xi({systemInfo:n}){return n?e.jsxs(Me,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"System info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(ke,{value:n.interfaceName,label:"Interface name",width:ue}),e.jsx(ke,{value:n.macAddress,label:"MAC Address",width:ue}),e.jsx(ke,{value:n.ipv4Address,label:"IPv4 Address",width:ue}),e.jsx(ke,{value:n.ipv6Address,label:"IPv6 Address",width:ue}),e.jsx(ke,{value:n.nodeVersion,label:"Node Version",width:ue}),e.jsx(ke,{value:n.hostname,label:"Hostname",width:ue}),e.jsx(ke,{value:n.user,label:"User",width:ue})]})})]}):null}function ke({value:n,label:d,width:l}){return e.jsx(he,{focused:!0,value:n,size:"small",label:d,variant:"standard",sx:{width:l?`${l-20}px`:"400px","& .MuiInput-underline:before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},inputLabel:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}}})}const bi=r.memo(gi);function vi(){const{online:n,sendMessage:d,addListener:l,removeListener:i,getUniqueId:a}=r.useContext(be),{showSnackbarMessage:h}=r.useContext(Le),[u,v]=r.useState(null),[t,I]=r.useState([]),[y,C]=r.useState([]),[S,E]=r.useState(null),[A,q]=r.useState({cpuUsage:0}),[w,p]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[b,x]=r.useState({systemUptime:"",processUptime:""}),H=r.useRef(a());return o&&console.log("Test uniqueId:",H),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const T=j=>{if(j.method==="restart_required")o&&console.log("Test received restart_required"),h("Restart required",0);else if(j.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${j.response.changed} and sending api requests`),h("Refresh required",0),d({id:H.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:H.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:H.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(j.method==="memory_update")o&&console.log("Test received memory_update",j),p(j.response);else if(j.method==="cpu_update")o&&console.log("Test received cpu_update",j),q(j.response);else if(j.method==="uptime_update")o&&console.log("Test received uptime_update",j),x(j.response);else if(j.method==="/api/settings"&&j.response)o&&console.log("Test received /api/settings:",j.response),h("Test received /api/settings",0),v(j.response);else if(j.method==="/api/plugins"&&j.response)o&&console.log(`Test received ${j.response.length} plugins:`,j.response),h("Test received /api/plugins",0),I(j.response);else if(j.method==="/api/devices"&&j.response){o&&console.log(`Test received ${j.response.length} devices:`,j.response),h("Test received /api/devices",0),C(j.response);for(const _ of j.response)o&&console.log("Test sending /api/clusters for device:",_.pluginName,_.name,_.endpoint),d({id:H.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:_.pluginName,endpoint:_.endpoint||0}})}else j.method==="/api/clusters"&&j.response&&(o&&console.log(`Test received ${j.response.clusters.length} clusters for device ${j.response.deviceName} endpoint ${j.response.id}:${j.response.number}:`,j),h(`Test received /api/clusters for ${j.response.plugin}::${j.response.deviceName}`,0),E(j.response))};return l(T,H.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(T),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,i,d,h]),r.useEffect(()=>(o&&console.log("Test useEffect online mounting"),n&&o&&console.log("Test useEffect online received online"),o&&console.log("Test useEffect online mounted"),()=>{o&&console.log("Test useEffect online unmounted")}),[n,d,h]),o&&console.log("Test rendering..."),n?e.jsx(at,{name:"Test",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",gap:"20px",height:"100vh",width:"100vw"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"})]})}):e.jsx($e,{})}const yi=r.memo(vi);function ji(n,d){o&&console.log("getCssVariable:",n,"defaultValue",d);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||d}function wi(n){return yo({palette:{primary:{main:n},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}function Ci(){const{mobile:n,showSnackbarMessage:d,showConfirmCancelDialog:l}=r.useContext(Le),{online:i,sendMessage:a,logMessage:h,addListener:u,removeListener:v,getUniqueId:t}=r.useContext(be),[I,y]=r.useState(!1),[C,S]=r.useState(!1),[E,A]=r.useState(!1),[q,w]=r.useState(!1),[p,b]=r.useState(null),x=r.useRef(t()),[H,T]=r.useState(null),[j,_]=r.useState(null),[ee,c]=r.useState(null),[s,g]=r.useState(null),[f,R]=r.useState(null),ce=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},ye=()=>{window.open("https://matterbridge.io/")},ie=()=>{window.open("https://matterbridge.io/README.html")},je=()=>{window.open("https://matterbridge.io/CHANGELOG.html")},F=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},U=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},N=()=>{a({id:x.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},G=()=>{a({id:x.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},$=()=>{a({id:x.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},W=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),h("Matterbridge","Installing system updates..."),a({id:x.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),h("Matterbridge","Installing software updates..."),a({id:x.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),a({id:x.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},L=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),h("Matterbridge","Downloading Shelly system log..."),d("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},K=()=>{p?.matterbridgeInformation.restartMode===""?a({id:x.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):a({id:x.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},se=()=>{a({id:x.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},oe=()=>{a({id:x.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},de=()=>{a({id:x.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ge=()=>{a({id:x.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},pe=O=>{T(O.currentTarget)},D=O=>{o&&console.log("Header: handleMenuClose",O),T(null),O==="download-mblog"?(h("Matterbridge","Downloading matterbridge log..."),d("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):O==="download-mjlog"?(h("Matterbridge","Downloading matter log..."),d("Downloading matter log...",5),window.location.href="./api/download-mjlog"):O==="view-mblog"?(h("Matterbridge","Loading matterbridge log..."),d("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):O==="view-mjlog"?(h("Matterbridge","Loading matter log..."),d("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):O==="view-diagnostic"?(h("Matterbridge","Loading diagnostic log..."),d("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):O==="download-diagnostic"?(h("Matterbridge","Downloading diagnostic log..."),d("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):O==="view-history"?a({id:x.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):O==="download-history"?a({id:x.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):O==="view-shellylog"?(h("Matterbridge","Loading shelly system log..."),d("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):O==="download-mbstorage"?(h("Matterbridge","Downloading matterbridge storage..."),d("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):O==="download-pluginstorage"?(h("Matterbridge","Downloading matterbridge plugins storage..."),d("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):O==="download-pluginconfig"?(h("Matterbridge","Downloading matterbridge plugins config..."),d("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):O==="download-mjstorage"?(h("Matterbridge","Downloading matter storage..."),d("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):O==="download-backup"?(h("Matterbridge","Downloading backup..."),d("Downloading backup...",10),window.location.href="./api/download-backup"):O==="update"?N():O==="updatedev"?G():O==="updatecheck"?$():O==="shelly-sys-update"?W():O==="shelly-main-update"?k():O==="shelly-create-system-log"?M():O==="shelly-download-system-log"?L():O==="softreset"?de():O==="hardreset"?ge():O==="restart"?K():O==="shutdown"?se():O==="reboot"?oe():O==="create-backup"?a({id:x.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):O==="unregister"?a({id:x.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):O==="reset"?a({id:x.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):O==="factoryreset"&&a({id:x.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},m=O=>{o&&console.log("Header: handleMenuCloseCancel:",O),T(null)},xe=O=>{_(O.currentTarget)},te=()=>{_(null)},fe=O=>{c(O.currentTarget)},Z=()=>{c(null)},me=O=>{g(O.currentTarget)},ve=()=>{g(null)},rt=O=>{R(O.currentTarget)},We=()=>{R(null)},z=()=>{Mi(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const O=re=>{o&&console.log("Header received WebSocket Message:",re),re.method==="/api/settings"&&re.id===x.current?(o&&console.log("Header received settings:",re.response),b(re.response),y(re.response.matterbridgeInformation.restartRequired||re.response.matterbridgeInformation.fixedRestartRequired),S(re.response.matterbridgeInformation.fixedRestartRequired),A(re.response.matterbridgeInformation.updateRequired)):re.method==="refresh_required"&&re.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${re.response.changed} and sending /api/settings request`),a({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):re.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${re.response.fixed}`),y(!0),re.response.fixed===!0&&S(!0)):re.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),y(!1)):re.method==="update_required"?(o&&console.log("Header received update_required"),re.response.devVersion===!0?w(!0):A(!0),a({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):re.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),b(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellySysUpdate:re.response.available},systemInformation:we.systemInformation}:null)):re.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),b(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellyMainUpdate:re.response.available},systemInformation:we.systemInformation}:null)):re.method==="/api/viewhistorypage"&&re.id===x.current&&re.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):re.method==="/api/downloadhistorypage"&&re.id===x.current&&re.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return u(O,x.current),o&&console.log(`Header added WebSocket listener id ${x.current}`),()=>{v(O),o&&console.log("Header removed WebSocket listener")}},[u,v,a,d]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),a({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:x.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,a]),o&&console.log("Header rendering... mobile %s",n),!i||!p?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",width:"100%",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:z}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:e.jsxs("nav",{children:[e.jsx(dt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(dt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(dt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(dt,{to:"/settings",className:"nav-link",children:"Settings"})]})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[!p.matterbridgeInformation.readOnly&&e.jsx(V,{title:`Matterbridge v.${p.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",p.matterbridgeInformation.matterbridgeVersion.split("-dev-")[0]+(p.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")]})}),p.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),p.matterbridgeInformation.bridgeMode!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.bridgeMode})}):null,p.matterbridgeInformation.restartMode!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.restartMode})}):null,p.matterbridgeInformation.profile&&p.matterbridgeInformation.profile!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"5px"},children:[p.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:F})}):null,p.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Give a star to Matterbridge",children:e.jsx(Q,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:U,children:e.jsx(jo,{})})}):null,p.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Sponsor Matterbridge",children:e.jsx(Q,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:ce,children:e.jsx(sr,{})})}):null,e.jsx(V,{title:"Matterbridge homepage",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ye,children:e.jsx(wo,{})})}),e.jsx(V,{title:"Matterbridge help",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ie,children:e.jsx(nr,{})})}),e.jsx(V,{title:"Matterbridge changelog",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:je,children:e.jsx(ir,{})})}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&E&&e.jsx(V,{title:`Update matterbridge to latest version v.${p.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(Q,{style:{color:E?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:N,children:e.jsx(Pe,{})})}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&q&&e.jsx(V,{title:`Update matterbridge to latest dev version v.${p.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(Q,{style:{color:q?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:G,children:e.jsx(Pe,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellySysUpdate&&e.jsx(V,{title:"Shelly system update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:W,children:e.jsx(Pe,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellyMainUpdate&&e.jsx(V,{title:"Shelly software update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:k,children:e.jsx(Pe,{})})}),e.jsx(V,{title:"Restart matterbridge",children:e.jsx(Q,{style:{color:I||C?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:K,children:e.jsx(Ct,{})})}),p.matterbridgeInformation.restartMode===""?e.jsx(V,{title:"Shut down matterbridge",children:e.jsx(Q,{style:{color:I||C?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:se,children:e.jsx(qe,{})})}):null,e.jsx(V,{title:"Download, backup and more",children:e.jsx(Q,{onClick:pe,children:e.jsx(Co,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Ye,{id:"command-menu",anchorEl:H,keepMounted:!0,open:!!H,onClose:()=>D(""),children:[p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>D("update"),children:[e.jsx(B,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>D("updatedev"),children:[e.jsx(B,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>D("updatecheck"),children:[e.jsx(B,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellySysUpdate&&e.jsxs(P,{onClick:()=>D("shelly-sys-update"),children:[e.jsx(B,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellyMainUpdate&&e.jsxs(P,{onClick:()=>D("shelly-main-update"),children:[e.jsx(B,{children:e.jsx(Pe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>D("restart"),children:[e.jsx(B,{children:e.jsx(Ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation.restartMode===""?e.jsxs(P,{onClick:()=>D("shutdown"),children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",D,m)},children:[e.jsx(B,{children:e.jsx(Ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(mt,{}),e.jsxs(P,{onClick:fe,children:[e.jsx(B,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-view",anchorEl:ee,keepMounted:!0,open:!!ee,onClose:Z,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{D("view-mblog"),Z()},children:[e.jsx(B,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("view-mjlog"),Z()},children:[e.jsx(B,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("view-diagnostic"),Z()},children:[e.jsx(B,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("view-history"),Z()},children:[e.jsx(B,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{D("view-shellylog"),Z()},children:[e.jsx(B,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(mt,{}),e.jsxs(P,{onClick:me,children:[e.jsx(B,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-download",anchorEl:s,keepMounted:!0,open:!!s,onClose:ve,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{D("download-mbstorage"),ve()},children:[e.jsx(B,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-pluginstorage"),ve()},children:[e.jsx(B,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-pluginconfig"),ve()},children:[e.jsx(B,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-mblog"),ve()},children:[e.jsx(B,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-mjstorage"),ve()},children:[e.jsx(B,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-mjlog"),ve()},children:[e.jsx(B,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-diagnostic"),ve()},children:[e.jsx(B,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-history"),ve()},children:[e.jsx(B,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{D("shelly-create-system-log"),ve()},children:[e.jsx(B,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{D("shelly-download-system-log"),ve()},children:[e.jsx(B,{children:e.jsx(De,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(mt,{}),e.jsxs(P,{onClick:xe,children:[e.jsx(B,{children:e.jsx(It,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-backup",anchorEl:j,keepMounted:!0,open:!!j,onClose:te,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{D("create-backup"),te()},children:[e.jsx(B,{children:e.jsx(It,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-backup"),te()},children:[e.jsx(B,{children:e.jsx(It,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(mt,{}),e.jsxs(P,{onClick:rt,children:[e.jsx(B,{children:e.jsx(So,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Ye,{id:"sub-menu-reset",anchorEl:f,keepMounted:!0,open:!!f,onClose:We,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{We(),l("Reset all devices and shutdown","Are you sure you want to unregister all devices? This will temporarily remove all devices from the controller and you may loose the controller configuration.","unregister",D,m)},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{We(),l("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",D,m)},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>{We(),l("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",D,m)},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{We(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",D,m)},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{We(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",D,m)},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const tr=r.memo(Ci),hr=1200,fr=900;let $t,Wt;function rr(){if(typeof window<"u"){$t=Math.floor(window.visualViewport?.width??window.innerWidth),Wt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=$t<hr||Wt<fr;return o&&console.log("Visual viewport (%s) width %i height %i mobile %s",window.visualViewport!==void 0,$t,Wt,n),n}return!1}function Si({children:n}){const{mobile:d,setMobile:l}=r.useContext(Le);return r.useEffect(()=>{function i(){l(rr())}return window.addEventListener("resize",i),l(rr()),()=>window.removeEventListener("resize",i)},[l]),o&&console.log("MbfScreen rendering... mobile %s",d),d?e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"visible",margin:"0px",padding:"10px",gap:"10px"},children:[e.jsx(tr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"10px"},children:n})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:d?`${hr}px`:"calc(100vw - 40px)",height:d?`${fr}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(tr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let o=!1;const Mi=()=>{o=!o},ki=!1;let et;const Ii=n=>{et=n};function Di({setLoggedIn:n}){const[d,l]=r.useState(""),[i,a]=r.useState(""),h={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},u={display:"flex",flexDirection:"column",maxWidth:"400px",margin:"0 auto",padding:"20px",gap:"20px",border:"1px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},v={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},t=async y=>{try{const C=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(C.ok){const{valid:S}=await C.json();S?(n(!0),y!==""&&(et=y)):y!==""&&a("Incorrect password!")}else console.error("Failed to log in:",C.statusText)}catch(C){console.error("Failed to log in:",C)}},I=y=>{y.preventDefault(),t(d)};return t(""),e.jsx("div",{style:h,children:e.jsxs("form",{onSubmit:I,style:u,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"64px",width:"64px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:d,onChange:y=>l(y.target.value),style:v,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:i&&e.jsx("p",{style:{color:"red"},children:i})})]})})}function Pi(){const[n,d]=r.useState(!1),l=localStorage.getItem("frontendTheme")||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const i=ji("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const a=wi(i);window.location.href.includes("/api/hassio_ingress/");const h=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return o&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${h}"`)),n?e.jsx(Mo,{theme:a,children:e.jsx(Nr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(dn,{children:e.jsx(cn,{children:e.jsx(Ir,{basename:h,children:e.jsx(Si,{children:e.jsxs(Dr,{children:[e.jsx(Ue,{path:"/",element:e.jsx(En,{})}),e.jsx(Ue,{path:"/devices",element:e.jsx(li,{})}),e.jsx(Ue,{path:"/log",element:e.jsx(ci,{})}),e.jsx(Ue,{path:"/settings",element:e.jsx(bi,{})}),e.jsx(Ue,{path:"/test",element:e.jsx(yi,{})}),e.jsx(Ue,{path:"*",element:e.jsx(Pr,{to:"/"})})]})})})})})})}):e.jsx(Di,{setLoggedIn:d})}Lr.createRoot(document.getElementById("root")).render(e.jsx($r.StrictMode,{children:e.jsx(Pi,{})}));
1
+ import{B as e,y as r,S as ct,U as Pr,V as Lr,X as Be,Y as $r,Z as Wr,I as Nr}from"./vendor_node_modules.js";import{u as Fr,S as Tr}from"./vendor_notistack.js";import{D as Re,a as He,b as Oe,B as ie,c as Ue,F as ze,C as Ae,d as Y,A as Rr,I as Q,e as Hr,f as Or,T as O,g as he,M as Vr,h as Xe,i as P,j as Le,k as ir,l as Er,m as wt,n as Ar,o as le,K as Et,p as At,q as Nt,L as dt,r as nt,s as pt,t as B,W as st,u as ut,H as gt,v as X,V as _t,w as Ut,x as _r,E as Ur,Q as sr,R as Ct,S as qr,U as zr,P as Br,y as ar,z as Ft,G as $e,J as Tt,N as lr,O as St,X as cr,Y as Qr,Z as dr,_ as Kr,$ as Gr,a0 as Jr,a1 as qt,a2 as Zr,a3 as Yr,a4 as Xr,a5 as eo,a6 as to,a7 as ro,a8 as oo,a9 as zt,aa as no,ab as io,ac as so,ad as ao,ae as lo,af as co,ag as po,ah as uo,ai as go,aj as mo,ak as ho,al as fo,am as xo,an as bo,ao as vo,ap as Bt,aq as et,ar as pr,as as Se,at as ur,au as kt,av as _e,aw as yo,ax as jo,ay as qe,az as wo,aA as mt,aB as Qe,aC as Mt,aD as Co,aE as So}from"./vendor_mui.js";import{I as ne,m as ko,a as Qt,b as Io,c as Mo,d as Kt,e as Do,f as Po,g as Lo,h as $o,i as Wo,j as No,k as Fo,l as To,n as Ro,o as Ho,p as Oo,q as Vo,r as Gt,s as Eo,t as Ao,u as _o,v as Uo,w as qo,x as zo,y as Bo,z as Qo,A as Jt,B as Ko,C as Go}from"./vendor_mdi.js";import{Q as Jo}from"./vendor_qrcode.js";import{F as Zo,v as Yo,e as Xo,a as en,g as tn,b as rn,c as on,d as Dt,A as nn}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const c=document.createElement("link").relList;if(c&&c.supports&&c.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const h of a)if(h.type==="childList")for(const u of h.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&i(u)}).observe(document,{childList:!0,subtree:!0});function l(a){const h={};return a.integrity&&(h.integrity=a.integrity),a.referrerPolicy&&(h.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?h.credentials="include":a.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function i(a){if(a.ep)return;a.ep=!0;const h=l(a);fetch(a.href,h)}})();function sn({open:n,title:c,message:l,onConfirm:i,onCancel:a}){const h=v=>{o&&console.log("Confirmed"),v.preventDefault(),i()},u=v=>{o&&console.log("Canceled"),v.preventDefault(),a()};return e.jsxs(Re,{open:n,children:[e.jsx(He,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:c})]})}),e.jsxs(Oe,{children:[e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"0",marginBottom:"20px",maxHeight:"350px",maxWidth:"350px"},children:e.jsx("p",{style:{flex:1,margin:"0"},children:l})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(ie,{onClick:h,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ie,{onClick:u,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const an=({open:n,output:c,title:l,_command:i,_packageName:a,onInstall:h,onClose:u})=>{const{installAutoExit:v,setInstallAutoExit:t}=r.useContext(We),M=r.useRef(null),y=C=>{t(C.target.checked),localStorage.setItem("installAutoExit",C.target.checked?"true":"false"),o&&console.log("handleInstallAutoExitChange called with value:",C.target.checked)};return r.useEffect(()=>{o&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${M.current}`),setTimeout(()=>{o&&console.log("Scrolling to bottom:",M.current),M.current?.scrollIntoView({behavior:"smooth",block:"end"})},0)},[c]),e.jsxs(Re,{open:n,onClose:(C,S)=>{S==="backdropClick"||S==="escapeKeyDown"||u()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx(He,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:l})]})}),e.jsxs(Oe,{dividers:!0,style:{overflow:"hidden",display:"flex",flexDirection:"column",height:400,paddingBottom:0},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"16px",fontWeight:"bold",color:"var(--primary-color)"},children:"Process log"}),e.jsxs("ul",{style:{width:"100%",height:"100%",fontFamily:"monospace",fontSize:"14px",padding:"10px",margin:0,marginBottom:"10px",color:"var(--div-text-color)",background:"var(--div-bg-color)",overflow:"auto",listStyle:"none",boxSizing:"border-box",borderRadius:4,border:"4px solid var(--primary-color)",whiteSpace:"pre-wrap",display:"block"},children:[c.split(`
2
+ `).map((C,S)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:C},S)),e.jsx("li",{ref:M,style:{padding:0,margin:0}})]})]}),e.jsxs(Ue,{sx:{justifyContent:"space-evenly"},children:[h&&e.jsx(ie,{variant:"contained",onClick:h,children:"Install"}),e.jsx(ie,{onClick:u,children:"Close"}),e.jsx(ze,{control:e.jsx(Ae,{checked:v,onChange:C=>y(C)}),label:"Close on success",style:{color:"var(--div-text-color)"}})]})]})},ht=[],We=r.createContext(null);function ln({children:n}){const[c,l]=r.useState(!1),[i,a]=r.useState(null),{enqueueSnackbar:h,closeSnackbar:u}=Fr(),v=r.useCallback(k=>{o&&console.log(`UiProvider closeSnackbarMessage: message ${k}`);const L=ht.findIndex(K=>K.message===k);L!==-1&&(u(ht[L].key),ht.splice(L,1),o&&console.log(`UiProvider closeSnackbarMessage: message ${k} removed from persistMessages`))},[u]),t=r.useCallback((k,L,K)=>{o&&console.log(`UiProvider showSnackbarMessage: message ${k} timeout ${L}`);const ae=h(k,{variant:"default",autoHideDuration:L==null||L>0?(L??5)*1e3:null,persist:L===0,content:oe=>e.jsx(Y,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Rr,{severity:K??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>u(oe),action:e.jsx(Q,{size:"small",onClick:()=>u(oe),sx:{color:"#fff"},children:e.jsx(Hr,{fontSize:"small"})}),children:k},oe)},oe)});L===0&&(o&&console.log(`UiProvider showSnackbarMessage: message ${k} timeout ${L} - persist key ${ae}`),ht.push({message:k,key:ae}))},[h,u]),[M,y]=r.useState(!1),[C,S]=r.useState(""),[E,A]=r.useState(""),[U,w]=r.useState(""),p=r.useRef(null),b=r.useRef(null),x=()=>{o&&console.log(`UiProvider handle confirm action ${U}`),y(!1),p.current&&p.current(U)},H=()=>{o&&console.log(`UiProvider handle cancel action ${U}`),y(!1),b.current&&b.current(U)},F=r.useCallback((k,L,K,ae,oe)=>{o&&console.log(`UiProvider showConfirmCancelDialog for command ${K}`),S(k),A(L),w(K),p.current=ae,b.current=oe,y(!0)},[]),[j,_]=r.useState(!1),[ee,d]=r.useState(""),[s,g]=r.useState(""),[f,R]=r.useState(""),[de,ye]=r.useState(""),[se,je]=r.useState(localStorage.getItem("installAutoExit")!=="false"),T=r.useCallback((k,L,K)=>{o&&console.log(`UiProvider show install progress for package ${k}`),d(k),g(L),R(K),_(!0)},[]),z=r.useCallback(k=>{o&&console.log(`UiProvider addInstallProgress: output ${k}`),ye(L=>L+k+`
3
+ `)},[]),N=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${f}`),localStorage.getItem("installAutoExit")!=="false"&&_(!1)},[f]),G=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressError: package ${f}`)},[f]),$=r.useCallback(()=>{o&&console.log("UiProvider hide install progress"),_(!1)},[]),W=()=>{o&&console.log("UiProvider handle install close action"),_(!1),R(""),ye("")},I=r.useMemo(()=>({mobile:c,setMobile:l,currentPage:i,setCurrentPage:a,showSnackbarMessage:t,closeSnackbarMessage:v,closeSnackbar:u,showConfirmCancelDialog:F,showInstallProgress:T,exitInstallProgressSuccess:N,exitInstallProgressError:G,hideInstallProgress:$,addInstallProgress:z,installAutoExit:se,setInstallAutoExit:je}),[c,i,l,a,t,v,u,F,T,N,G,$,z,se,je]);return e.jsxs(We.Provider,{value:I,children:[e.jsx(sn,{open:M,title:C,message:E,onConfirm:x,onCancel:H}),e.jsx(an,{open:j,title:ee,_command:s,_packageName:f,output:de,onClose:W}),n]})}const gr=r.createContext(null),be=r.createContext(null);function cn({children:n}){const[c,l]=r.useState([]),[i,a]=r.useState(1e3),[h,u]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[v,t]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[M,y]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),[C,S]=r.useState(!1),{showSnackbarMessage:E,closeSnackbarMessage:A,closeSnackbar:U,showInstallProgress:w,hideInstallProgress:p,exitInstallProgressSuccess:b,exitInstallProgressError:x,addInstallProgress:H}=r.useContext(We),F=r.useRef([]),j=r.useRef(null),_=r.useRef(1),ee=r.useRef(Math.floor(Math.random()*999e3)+1e3),d=r.useRef(null),s=r.useRef(null),g=r.useRef(null),f=r.useRef(h),R=r.useRef(v),de=r.useRef(0),ye=r.useRef(null),se=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),je=r.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),T=100,z=60,N=50,G=300,$=10;r.useEffect(()=>(o&&console.log("WebSocket messages started counter interval"),ye.current=setInterval(()=>{de.current>0&&(o&&console.log(`WebSocket messages received in the last ${$} seconds: ${de.current*(60/$)} messages/minute`),de.current=0)},$*1e3),()=>{o&&console.log("WebSocket messages stopped counter interval"),ye.current&&clearInterval(ye.current),ye.current=null}),[]),r.useEffect(()=>{f.current=h},[h]),r.useEffect(()=>{R.current=v},[v]);const W=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),I=r.useCallback((D,m)=>{o&&console.log(`WebSocket filterLogMessages called with level "${D}" and search "${m}"...`),l(xe=>xe.filter(te=>!(["debug","info","notice","warn","error","fatal"].includes(te.level)&&(D==="info"&&te.level==="debug"||D==="notice"&&(te.level==="debug"||te.level==="info")||D==="warn"&&(te.level==="debug"||te.level==="info"||te.level==="notice")||D==="error"&&(te.level==="debug"||te.level==="info"||te.level==="notice"||te.level==="warn")||D==="fatal"&&(te.level==="debug"||te.level==="info"||te.level==="notice"||te.level==="warn"||te.level==="error"))||m!=="*"&&m!==""&&!te.message.toLowerCase().includes(m.toLowerCase())&&!te.name.toLowerCase().includes(m.toLowerCase()))))},[]),k=r.useCallback(D=>{if(j.current&&j.current.readyState===WebSocket.OPEN)try{o&&console.log(`WebSocket sending message with id ${D.id}:`,D),D.id===void 0&&(D.id=ee.current);const m=JSON.stringify(D);j.current.send(m),o&&console.log("WebSocket sent message:",D)}catch(m){o&&console.error(`WebSocket error sending message: ${m}`)}else o&&console.error("WebSocket message not sent, WebSocket not connected:",D)},[]),L=r.useCallback((D,m)=>{l(xe=>[...xe,{level:D,time:"",name:"",message:m}])},[]),K=r.useCallback((D,m)=>{o&&console.log(`WebSocket addListener id ${m}:`,D),(m==null||isNaN(m)||m===0)&&console.error("WebSocket addListener called without id, listener not added:",D),F.current=[...F.current,{listener:D,id:m}],o&&console.log("WebSocket addListener total listeners:",F.current.length)},[]),ae=r.useCallback(D=>{o&&console.log("WebSocket removeListener:",D),F.current=F.current.filter(m=>m.listener!==D),o&&console.log("WebSocket removeListener total listeners:",F.current.length)},[]),oe=r.useCallback(()=>{se===""||se===null||se===void 0||(L("WebSocket",`Connecting ${tt?"with password":""} to WebSocket: ${se}`),o&&console.log(`WebSocket connecting to: ${se}${tt?"?password=[redacted]":""}`),j.current=new WebSocket(se+(tt?`?password=${encodeURIComponent(tt)}`:"")),j.current.onmessage=D=>{C||S(!0),de.current+=1;try{const m=JSON.parse(D.data);if(m.id===void 0||m.src===void 0||m.dst===void 0){o&&console.error("WebSocket undefined message id/src/dst:",m);return}if(m.src!=="Matterbridge"||m.dst!=="Frontend"){o&&console.error("WebSocket invalid message src/dst:",m);return}if(m.error){o&&console.error("WebSocket error message response:",m);return}if(m.id===ee.current&&m.method==="pong"&&m.response==="pong"){o&&console.log(`WebSocket pong response message id ${m.id}:`,m),s.current&&clearTimeout(s.current),s.current=null;return}else if(m.method==="snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),E(m.response.message,m.response.timeout,m.response.severity);return}else if(m.method==="close_snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),A(m.response.message);return}else if(m.method==="log"){if(!m.response||!m.response.level||!m.response.time||!m.response.name||!m.response.message||(m.response.level==="spawn"&&(m.response.name==="Matterbridge:spawn-init"?w(m.response.message,"",""):m.response.name==="Matterbridge:spawn-exit-success"?b():m.response.name==="Matterbridge:spawn-exit-error"?x():H(m.response.message+`
4
+ `)),["debug","info","notice","warn","error","fatal"].includes(m.response.level)&&(f.current==="info"&&m.response.level==="debug"||f.current==="notice"&&(m.response.level==="debug"||m.response.level==="info")||f.current==="warn"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice")||f.current==="error"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn")||f.current==="fatal"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn"||m.response.level==="error")))||R.current!=="*"&&R.current!==""&&!m.response.message.toLowerCase().includes(R.current.toLowerCase())&&!m.response.name.toLowerCase().includes(R.current.toLowerCase())||m.response.name==="Commissioning"&&m.response.message.includes("is uncommissioned"))return;l(te=>{const fe=[...te,{level:m.response.level,time:m.response.time,name:m.response.name,message:m.response.message}];return fe.length>i*2?fe.slice(i):fe})}else{if(o&&console.log(`WebSocket received message id ${m.id} method ${m.method}:`,m),m.id===0)F.current.forEach(xe=>xe.listener(m));else{const xe=F.current.find(te=>te.id===m.id);xe?xe.listener(m):console.warn(`WebSocket no listener found for message id ${m.id}:`,m)}return}}catch(m){console.error(`WebSocket error parsing message: ${m}`,m instanceof Error?m.stack:null)}},j.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${se}`),L("WebSocket",`Connected to WebSocket: ${se}`),S(!0),U(),_.current=1,g.current=setTimeout(()=>{d.current=setInterval(()=>{k({id:ee.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${se}`),L("WebSocket",`No pong response received from WebSocket: ${se}`),S(!1)},1e3*N)},1e3*z)},1e3*G)},j.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${je?"with Ingress":""}: ${se}`),L("WebSocket",`Disconnected from WebSocket: ${se}`),S(!1),U(),p(),g.current&&clearTimeout(g.current),s.current&&clearTimeout(s.current),d.current&&clearInterval(d.current),L("WebSocket",`Reconnecting (attempt ${_.current} of ${T}) to WebSocket${je?" (Ingress)":""}: ${se}`),je?setTimeout(ce,5e3):_.current===1?ce():_.current<T?setTimeout(ce,1e3*_.current):L("WebSocket",`Reconnect attempts exceeded limit of ${T} retries, refresh the page to reconnect to: ${se}`),_.current=_.current+1},j.current.onerror=D=>{o&&console.error(`WebSocket: WebSocket error connecting to ${se}:`,D),L("WebSocket",`WebSocket error connecting to ${se}`)})},[se]),ce=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${_.current}/${T} to:`,se),oe()},[oe]);r.useEffect(()=>(oe(),()=>{j.current&&j.current.readyState===WebSocket.OPEN&&j.current.close()}),[oe]);const ge=r.useMemo(()=>({messages:c,logMaxMessages:i,logAutoScroll:M,logFilterLevel:h,logFilterSearch:v,setMessages:l,setLogMaxMessages:a,setLogFilterLevel:u,setLogFilterSearch:t,setLogAutoScroll:y,filterLogMessages:I}),[c,i,M,h,v,l,u,t,a,y,I]),pe=r.useMemo(()=>({logMaxMessages:i,logAutoScroll:M,logFilterLevel:h,logFilterSearch:v,setMessages:l,setLogMaxMessages:a,setLogFilterLevel:u,setLogFilterSearch:t,setLogAutoScroll:y,filterLogMessages:I,online:C,retry:_.current,getUniqueId:W,addListener:K,removeListener:ae,sendMessage:k,logMessage:L}),[i,M,l,u,t,a,y,C,_.current,K,ae,k,L]);return e.jsx(gr.Provider,{value:ge,children:e.jsx(be.Provider,{value:pe,children:n})})}function dn(n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 296.2 296.2",...n,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"lg1",x1:"16.6",y1:"16.6",x2:"279.6",y2:"279.6",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".1",stopColor:"#3faa77"}),e.jsx("stop",{offset:".3",stopColor:"#234148"}),e.jsx("stop",{offset:".7",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#ad2e6e"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg2",x1:"31.1",y1:"31.1",x2:"265.1",y2:"265.1",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".2",stopColor:"#285251"}),e.jsx("stop",{offset:".4",stopColor:"#234148"}),e.jsx("stop",{offset:".8",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#a8316c"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg3",x1:"116.2",y1:"143.9",x2:"139.8",y2:"143.9",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#8bc751"}),e.jsx("stop",{offset:"1",stopColor:"#0db14b"})]}),e.jsx("linearGradient",{id:"lg4",x1:"136.1",y1:"100.8",x2:"159.6",y2:"100.8",xlinkHref:"#lg3"}),e.jsx("linearGradient",{id:"lg5",x1:"155.3",y1:"143.9",x2:"178.9",y2:"143.9",xlinkHref:"#lg3"}),e.jsxs("linearGradient",{id:"lg6",x1:"46.8",y1:"25.7",x2:"89.6",y2:"74.8",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#b1d34a"}),e.jsx("stop",{offset:"1",stopColor:"#50b848"})]})]}),e.jsx("rect",{width:"296.2",height:"296.2",rx:"56.7",ry:"56.7",style:{fill:"url(#lg1)"}}),e.jsx("rect",{x:"16.3",y:"16.3",width:"263.6",height:"263.6",rx:"50.5",ry:"50.5",style:{fill:"url(#lg2)"}}),e.jsx("circle",{cx:"128",cy:"143.9",r:"11.8",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"147.8",cy:"100.8",r:"11.8",style:{fill:"url(#lg4)"}}),e.jsx("path",{d:"m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"167.1",cy:"143.9",r:"11.8",style:{fill:"url(#lg5)"}}),e.jsx("path",{fill:"#fff",d:"M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z"}),e.jsx("path",{d:"M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z",style:{fill:"url(#lg6)"}}),e.jsx("path",{d:"M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z",fill:"#1e5857"}),e.jsx("path",{fill:"#fff",d:"M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z"})]})}function Ne(){const{retry:n}=r.useContext(be),c=()=>{window.location.reload()};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center",fontSize:"20px",color:"var(--main-text-color)",backgroundColor:"var(--main-bg-color)"},children:[e.jsx(dn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(Or,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+n+")","..."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{})]}),e.jsx(ie,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function mr({value:n,maxChars:c}){let l=n;if(n.length>c&&c>3){const i=c-3,a=n.substring(0,Math.ceil(i/2)),h=n.substring(n.length-Math.floor(i/2),n.length);l=`${a} … ${h}`}return n!==l?e.jsx(O,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:l})}):e.jsx("span",{children:l})}function ke({children:n,style:c}){const l={display:"flex",flexDirection:"column",flex:"0 0 auto",width:"100%",overflow:"hidden",margin:"0px",padding:"0px",gap:"0px",backgroundColor:"var(--div-bg-color)",boxShadow:"5px 5px 10px var(--div-shadow-color)",border:"1px solid var(--table-border-color)",borderRadius:"var(--div-border-radius)",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...c},children:n})}function De({children:n,style:c}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",borderBottom:"1px solid var(--table-border-color)",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...c},children:n})}function Ie({children:n,style:c}){const l={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...c},children:n})}function ft({children:n,style:c}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...c},children:n})}function xt({children:n,style:c}){const l={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...c},children:n})}function it({children:n,style:c}){const l={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...c},children:n})}function Fe({children:n,style:c,onDragOver:l,onDragLeave:i,onDrop:a}){const h={flex:"0 0 auto",display:"flex",flexDirection:"row",overflow:"hidden",alignItems:"start",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"};return e.jsx("div",{style:{...h,...c},onDragOver:l,onDragLeave:i,onDrop:a,children:n})}function rt({children:n,style:c,onClose:l}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...c},children:[n,ki]})}function pn({systemInfo:n,compact:c}){const{addListener:l,removeListener:i,getUniqueId:a,sendMessage:h}=r.useContext(be),[u,v]=r.useState(n),t=r.useRef(a());if(o&&console.log("SystemInfoTable loading with systemInfo:",u,"compact:",c),n&&c&&u.totalMemory&&u.freeMemory){const w=u.totalMemory,p=u.freeMemory;u.freeMemory=`${p} / ${w}`,u.totalMemory=""}if(n&&c&&u.heapTotal&&u.heapUsed){const w=u.heapTotal,p=u.heapUsed;u.heapUsed=`${p} / ${w}`,u.heapTotal=""}if(n&&c&&u.osRelease&&u.osType){const w=u.osType,p=u.osRelease;u.osType=`${w} (${p})`,u.osRelease=""}if(n&&c&&u.osArch&&u.osPlatform){const w=u.osPlatform,p=u.osArch;u.osPlatform=`${w} (${p})`,u.osArch=""}const M=(w,p,b,x,H)=>{v(F=>({...F,totalMemory:w,freeMemory:p,heapTotal:b,heapUsed:x,rss:H}))},y=w=>{v(p=>({...p,cpuUsage:w.toFixed(2)+" %"}))},C=w=>{v(p=>({...p,processCpuUsage:w.toFixed(2)+" %"}))},S=(w,p)=>{v(b=>({...b,systemUptime:w,processUptime:p}))},E=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),h({id:t.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const w=p=>{o&&console.log("SystemInfoTable received WebSocket Message:",p),p.method==="memory_update"&&p.response&&p.response.totalMemory&&p.response.freeMemory&&p.response.heapTotal&&p.response.heapUsed&&p.response.rss?(o&&console.log("SystemInfoTable received memory_update",p),M(p.response.totalMemory,p.response.freeMemory,p.response.heapTotal,p.response.heapUsed,p.response.rss)):p.method==="cpu_update"&&p.response&&p.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",p),y(p.response.cpuUsage),C(p.response.processCpuUsage)):p.method==="uptime_update"&&p.response&&p.response.systemUptime&&p.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",p),S(p.response.systemUptime,p.response.processUptime)):p.method==="/api/viewhistorypage"&&p.id===t.current&&p.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return l(w,t.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${t.current}`),()=>{i(w),o&&console.log("SystemInfoTable removed WebSocket listener")}},[l,i]);const[A,U]=r.useState(!1);return!u||A?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(ke,{style:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(De,{children:[e.jsx(Ie,{children:"System Information"}),e.jsx(rt,{onClose:()=>U(!0),children:e.jsx(Q,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:E,children:e.jsx(O,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(ne,{path:ko,size:"22px"})})})})]}),e.jsx(Fe,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(u).filter(([w,p])=>p!==void 0&&p!=="").map(([w,p],b)=>e.jsxs("tr",{className:b%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:w.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(mr,{value:typeof p!="string"?p.toString():p,maxChars:24})})]},w))})})})]}))}const Zt=r.memo(pn),Yt={margin:"0px",padding:"0px",color:"var(--div-text-color)",transition:"color 0.2s ease","& svg":{display:"block"},"& svg path":{fill:"var(--div-text-color)",transition:"fill 0.2s ease"},"&:hover":{color:"var(--primary-color)"},"&:hover svg path":{fill:"var(--primary-color)"},"&:focus-visible":{outline:"2px solid var(--primary-color)",outlineOffset:"2px"}},un=n=>{if(!n)return"";const c=n.toString().replace(/[^0-9]/g,"");if(c.length<5)return c;const l=c.slice(0,4),i=c.slice(4,7),a=c.slice(7,11);return[l,i,a].filter(Boolean).join("-")};function gn({id:n}){const{online:c,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(be),[u,v]=r.useState(null),t=r.useRef(null),M=r.useRef(null),y=r.useRef(h()),{showConfirmCancelDialog:C}=r.useContext(We);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${M.current} and matter:`,u),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),t.current=n,M.current&&clearTimeout(M.current),M.current=null,n?(o&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:n,server:!0}})):(o&&console.log("QRDiv id effect setting matter to null"),v(null))},[n,l]),r.useEffect(()=>{const p=b=>{o&&console.log("QRDiv received WebSocket Message:",b),b.method==="refresh_required"&&b.response.changed==="matter"&&b.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${b.response.changed} for storeId "${b.response.matter.id}":`,b.response.matter),t.current===b.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${b.response.matter.id}":`,b.response.matter),M.current&&clearTimeout(M.current),b.response.matter.advertising&&b.response.matter.advertiseTime&&b.response.matter.advertiseTime+9e5<=Date.now()&&(b.response.matter.advertising=!1),v(b.response.matter),b.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${b.response.matter.id}":`,b.response.matter.advertiseTime+9e5-Date.now()),M.current=setTimeout(()=>{M.current&&clearTimeout(M.current),o&&console.log(`QRDiv clearing advertising state for storeId "${t.current}" after 15 minutes`),v(x=>x&&{...x,advertising:!1})},b.response.matter.advertiseTime+9e5-Date.now()))))};return i(p,y.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{a(p),M.current&&clearTimeout(M.current),M.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,a]);const S=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${u?.id}"`),u&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,startCommission:!0}})},E=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${u?.id}"`),u&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,stopCommission:!0}})},A=()=>{o&&console.log(`QRDiv sent matter advertise for node "${u?.id}"`),u&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,advertise:!0}})},U=p=>{o&&console.log(`QRDiv sent matter removeFabric for node "${u?.id}" and fabricIndex ${p}`),u&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:u.id,removeFabric:p}})},w=async()=>{if(!u||!u.manualPairingCode)return;const p=u.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(p);else{const b=document.createElement("textarea");b.value=p,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.focus(),b.select(),document.execCommand("copy"),document.body.removeChild(b)}o&&console.log("Manual pairing code copied to clipboard")}catch(b){console.error("Failed to copy manual pairing code",b)}};return!u||!c?(o&&console.log("QRDiv rendering undefined state"),null):u.online?u.advertising&&u.qrPairingCode&&u.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(ke,{style:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsxs(De,{children:[e.jsx(Ie,{children:"QR pairing code"}),e.jsxs(rt,{children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:A,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(O,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Qt,size:"22px"})})}),e.jsx(Q,{"aria-label":"stop pairing",size:"small",onClick:E,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(O,{title:"Turn off pairing",arrow:!0,children:e.jsx(ne,{path:Io,size:"22px"})})})]})]}),e.jsx(it,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Jo,{value:u.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(ft,{style:{justifyContent:"space-between"},children:[e.jsxs(xt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",un(u.manualPairingCode)]}),e.jsx(rt,{children:e.jsx(O,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(Q,{"aria-label":"copy manual pairing code",size:"small",onClick:w,sx:Yt,children:e.jsx(ne,{path:Mo,size:.85})})})})]})]})):u.commissioned&&u.fabricInformations&&u.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(ke,{style:{alignItems:"center",width:"302px",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(De,{children:[e.jsx(Ie,{children:"Paired fabrics"}),e.jsxs(rt,{children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:A,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(O,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Qt,size:"22px"})})}),e.jsx(Q,{"aria-label":"start pairing",size:"small",onClick:S,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(O,{title:"Turn on pairing",arrow:!0,children:e.jsx(ne,{path:Kt,size:"22px"})})})]})]}),e.jsx(it,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Fe,{style:{flexDirection:"column",flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px 0px 10px 0px",gap:"0px"},children:u.fabricInformations.map((p,b)=>e.jsxs("div",{style:{margin:"0px",padding:"10px",gap:"0px",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",textAlign:"left",fontSize:"14px"},children:[e.jsxs("div",{style:{marginLeft:"20px",marginBottom:"10px",display:"flex",flexDirection:"row",justifyContent:"space-between",gap:"20px",alignItems:"center"},children:[e.jsxs("p",{className:"status-blue",style:{margin:"0px",padding:"3px 10px",width:"200px",fontSize:"14px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},children:["Fabric: ",p.fabricIndex]}),e.jsx(O,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(Q,{"aria-label":"remove the fabric",size:"small",onClick:()=>C("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>U(p.fabricIndex),()=>{}),sx:{...Yt,padding:"2px"},children:e.jsx(ne,{path:Do,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",p.rootVendorId," ",p.rootVendorName]}),p.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",p.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",u.sessionInformations?u.sessionInformations.filter(x=>x.fabric?.fabricIndex===p.fabricIndex&&x.isPeerActive===!0).length:"0"," ","subscriptions: ",u.sessionInformations?u.sessionInformations.filter(x=>x.fabric?.fabricIndex===p.fabricIndex&&x.isPeerActive===!0&&x.numberOfActiveSubscriptions>0).length:"0"]})]},b))}),e.jsx(ft,{style:{justifyContent:"center"},children:e.jsxs(xt,{style:{fontWeight:"normal"},children:["Serial number: ",u.serialNumber]})})]})):!u.commissioned&&!u.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(ke,{style:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(De,{children:e.jsx(Ie,{children:"QR pairing code"})}),e.jsx(it,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(ie,{onClick:S,endIcon:e.jsx(ne,{path:Kt,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx(ft,{style:{justifyContent:"center"},children:e.jsxs(xt,{style:{fontWeight:"normal"},children:["Serial number: ",u.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(ke,{style:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(De,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(Ie,{children:"Server node"})}),e.jsx(it,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(it,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(ft,{style:{justifyContent:"center"},children:e.jsxs(xt,{style:{fontWeight:"normal"},children:["Serial number: ",u.serialNumber]})})]}))}const Xt=r.memo(gn);function mn(){const{mobile:n}=r.useContext(We),{logMessage:c,sendMessage:l,getUniqueId:i}=r.useContext(be),[a,h]=r.useState("matterbridge-"),[u,v]=r.useState(!1),[t,M]=r.useState(null),y=r.useRef(i()),C=d=>{d.preventDefault(),v(!0)},S=()=>{v(!1)},E=d=>{d.preventDefault(),v(!1);const s=d.dataTransfer.files[0];if(s){c("Plugins",`Installing package ${s.name}. Please wait...`);const g=new FormData;g.append("file",s),g.append("filename",s.name),fetch("./api/uploadpackage",{method:"POST",body:g}).then(f=>f.text()).then(f=>{c("Plugins",`Server response: ${f}`)}).catch(f=>{console.error("Error uploading plugin file:",f),c("Plugins",`Error installing package ${f}`)})}},A=d=>{const s=d.target.files&&d.target.files[0];if(s){c("Plugins",`Uploading package ${s.name}`);const g=new FormData;g.append("file",s),g.append("filename",s.name),fetch("./api/uploadpackage",{method:"POST",body:g}).then(f=>f.text()).then(f=>{c("Plugins",`Server response: ${f}`)}).catch(f=>{console.error("Error uploading plugin file:",f),c("Plugins",`Error uploading package ${f}`)})}},U=()=>{l({id:y.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:a,restart:!1}})},w=()=>{l({id:y.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:a}})},p=()=>{document.getElementById("file-upload")?.click()},b=()=>{l({id:y.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:a}})},x=d=>{d.preventDefault(),console.log("Right-clicked Upload button")},H=d=>{d.preventDefault(),console.log("Right-clicked Add button")},F=d=>{M(d.currentTarget)},j=d=>{d!==""&&h(d),M(null)},[_,ee]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),_?null:e.jsxs(ke,{children:[e.jsxs(De,{children:[e.jsx(Ie,{children:"Install plugins"}),e.jsx(rt,{onClose:()=>ee(!0)})]}),e.jsxs(Fe,{onDragOver:C,onDragLeave:S,onDrop:E,style:n?{flexWrap:"wrap",alignItems:"center",gap:"10px"}:{flexWrap:"wrap",alignItems:"center",gap:"20px"},children:[e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(he,{value:a,onChange:d=>{h(d.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(Q,{onClick:F,children:e.jsx(Vr,{})}),e.jsxs(Xe,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>j(""),children:[e.jsx(P,{onClick:()=>j("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(P,{onClick:()=>j("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(P,{onClick:()=>j("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(P,{onClick:()=>j("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(P,{onClick:()=>j("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(P,{onClick:()=>j("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(P,{onClick:()=>j("matterbridge-test"),children:"matterbridge-test"}),e.jsx(P,{onClick:()=>j("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(P,{onClick:()=>j("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(P,{onClick:()=>j("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(P,{onClick:()=>j("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(P,{onClick:()=>j("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(P,{onClick:()=>j("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(P,{onClick:()=>j("matterbridge-eve-room"),children:"matterbridge-eve-room"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(O,{title:"Install or update a plugin from npm",children:e.jsxs(ie,{onClick:U,endIcon:e.jsx(Le,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(O,{title:"Uninstall and remove a plugin",children:e.jsxs(ie,{onClick:w,endIcon:e.jsx(ir,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Uninstall"]})}),e.jsx(O,{title:"Upload and install a plugin from a tarball",children:e.jsxs(ie,{onClick:p,onContextMenu:x,endIcon:e.jsx(Er,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(O,{title:"Add an installed plugin",children:e.jsxs(ie,{onClick:b,onContextMenu:H,endIcon:e.jsx(wt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Add"]})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:A})]})]})]})}const hn=r.memo(mn);function Ke({status:n,enabledText:c="Enabled",disabledText:l=void 0,tooltipText:i=void 0,onClick:a}){if(n===void 0)return null;{const h=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:a,children:n?c:l??c});return i!==void 0?e.jsx(O,{title:i,children:h}):h}}function fn(n,c,l){const i=n?.[l],a=c?.[l];return i==null&&a==null?0:i==null?-1:a==null?1:typeof i=="boolean"&&typeof a=="boolean"?i===a?0:i?1:-1:typeof i=="number"&&typeof a=="number"?i-a:String(i).localeCompare(String(a))}function xn({name:n,title:c,columns:l,rows:i,getRowKey:a,footerLeft:h,footerRight:u,onRowClick:v}){const t=r.useRef(new WeakMap),M=r.useRef(1),y=d=>{if(typeof a=="string"&&d&&d[a]!=null)return d[a];if(typeof a=="function"){const f=a(d);if(f!=null)return f}const s=l?.[0]?.id;if(s&&d&&d[s]!=null)return d[s];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let g=t.current.get(d);return g||(g=`rk_${M.current++}`,t.current.set(d,g)),g},[C,S]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[E,A]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[U,w]=r.useState(!1),[p,b]=r.useState(()=>{try{const d=localStorage.getItem(`${n}_column_visibility`);if(d)return JSON.parse(d)}catch{}return{}}),x=r.useMemo(()=>{const d={};for(const s of l)s.hidden||(d[s.id]=s.required?!0:p[s.id]!==!1);return d},[l,p]),H=r.useMemo(()=>{if(!C||!E)return i;const d=l.find(g=>g.id===C);if(!d||d.noSort)return i;const s=i.map((g,f)=>({el:g,index:f}));return s.sort((g,f)=>{let R;return typeof d.comparator=="function"?R=d.comparator(g.el,f.el):R=fn(g.el,f.el,C),R!==0?E==="asc"?R:-R:g.index-f.index}),s.map(g=>g.el)},[i,C,E,l]),F=d=>{if(C!==d||!C){S(d),A("asc"),localStorage.setItem(`${n}_table_order_by`,d),localStorage.setItem(`${n}_table_order`,"asc");return}if(E==="asc"){A("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}S(null),A(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},j=()=>{w(!U)},_=d=>{b(s=>{const g=l.find(de=>de.id===d);if(g&&g.required)return s;const f=x[d]!==!1,R={...s};f?R[d]=!1:delete R[d];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(R))}catch{}return R})},ee=()=>{b({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}w(!1)};return o&&console.log(`Rendering table ${n}${C&&E?` ordered by ${C}:${E}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(Re,{open:U,onClose:(d,s)=>{s==="backdropClick"||s==="escapeKeyDown"||j()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(He,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${n} columns`})]})}),e.jsx(Oe,{children:e.jsx(Ar,{children:l.filter(d=>!d.hidden).map(d=>e.jsx(ze,{control:e.jsx(Ae,{disabled:!!d.required,checked:d.required?!0:x[d.id]!==!1,onChange:()=>_(d.id)}),label:d.label},d.id))})}),e.jsxs(Ue,{children:[e.jsx(ie,{onClick:ee,children:"Reset"}),e.jsx(ie,{variant:"contained",onClick:d=>{if(d?.currentTarget&&typeof d.currentTarget.blur=="function")try{d.currentTarget.blur()}catch{}const s=document.activeElement;if(s&&s instanceof HTMLElement&&typeof s.blur=="function")try{s.blur()}catch{}j()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:n}),c&&e.jsx("p",{className:"MbfWindowHeaderText",children:c}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(Q,{onClick:d=>{if(d?.currentTarget?.blur)try{d.currentTarget.blur()}catch{}j()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(O,{title:`Configure ${n} columns`,children:e.jsx(ne,{path:Po,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:l.map(d=>{if(d.hidden||!d.required&&x[d.id]===!1)return null;const s=!d.noSort,g=s&&C===d.id&&!!E;return e.jsxs("th",{onClick:s?()=>F(d.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:d.minWidth,maxWidth:d.maxWidth,textAlign:d.align||"left",cursor:s?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:d.maxWidth?"nowrap":void 0,overflow:d.maxWidth?"hidden":void 0,textOverflow:d.maxWidth?"ellipsis":void 0},"aria-sort":s?g?E==="asc"?"ascending":"descending":"none":void 0,children:[d.label,g&&e.jsxs("span",{style:{marginLeft:6},children:[E==="asc"&&e.jsx(ne,{path:Lo,size:"15px"}),E==="desc"&&e.jsx(ne,{path:$o,size:"15px"})]})]},d.id)})})}),e.jsx("tbody",{children:H.map((d,s)=>{const g=y(d);return e.jsx("tr",{className:s%2===0?"table-content-even":"table-content-odd",onClick:v?f=>v(d,g,f):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:v?"pointer":void 0},children:l.map(f=>{if(f.hidden||!f.required&&x[f.id]===!1)return null;const R=d[f.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:f.align||"left",padding:"5px 10px",margin:"0",maxWidth:f.maxWidth,whiteSpace:f.maxWidth?"nowrap":void 0,overflow:f.maxWidth?"hidden":void 0,textOverflow:f.maxWidth?"ellipsis":void 0},children:typeof f.render=="function"?f.render(R,g,d,f):typeof R=="boolean"?e.jsx(Ae,{checked:R,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):f.format&&typeof R=="number"?f.format(R):R!=null?String(R):null},f.id)})},g)})})]})}),(h||u)&&e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:u})]})]})}function bn(n){return r.memo(n)}const It=bn(xn);function er(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const Ge={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Je={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},vn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},yn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ee={padding:"0px",margin:"0px"},jn="5px 10px 5px 10px",bt={},Ce={},vt={},yt={};let Ze=[],Pt=[];const wn=({open:n,onClose:c,plugin:l})=>{const{sendMessage:i,addListener:a,removeListener:h,getUniqueId:u}=r.useContext(be),v=r.useRef(u()),[t,M]=r.useState(l.configJson),[y,C]=r.useState(null),[S,E]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[A,U]=r.useState("");let w={};r.useEffect(()=>{const W=I=>{I.src==="Matterbridge"&&I.dst==="Frontend"&&(er(I)&&I.id===v.current&&I.method==="/api/select/devices"&&I.response&&(o&&console.log(`ConfigPluginDialog (id: ${I.id}) received ${I.response.length} /api/select/devices:`,I.response),Ze=I.response),er(I)&&I.id===v.current&&I.method==="/api/select/entities"&&I.response&&(o&&console.log(`ConfigPluginDialog (id: ${I.id}) received ${I.response.length} /api/select/entities:`,I.response),Pt=I.response))};return a(W,v.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",v.current),t&&y&&y.properties&&(Object.keys(y.properties).forEach(I=>{Object.keys(y.properties[I]).forEach(k=>{k.startsWith("ui:")&&(S[I]={},S[I][k]=y.properties[I][k],delete y.properties[I][k])})}),E(S)),l.name&&l.configJson&&l.schemaJson&&(M(l.configJson),C(l.schemaJson),i({id:v.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),i({id:v.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),o&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',l.name)),()=>{h(W),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[a,t,l,h,y,i,S]);const p=(W,I)=>{w=W.formData},b=W=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",W.formData),M(W.formData),l.configJson=W.formData,l.restartRequired=!0,i({id:v.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.formData.name,formData:W.formData}}),c()};function x(W){const{id:I,label:k,onKeyChange:L,onDropPropertyClick:K,disabled:ae,schema:oe,children:ce,registry:ge,readonly:pe,required:D}=W,{templates:m}=ge,{RemoveButton:xe}=m.ButtonTemplates;if(!(nn in oe))return e.jsx(Y,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:ce});const fe=({target:Z})=>L(Z&&Z.value);return e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(he,{id:`${I}-key`,name:`${I}-key`,required:D,disabled:ae||pe,defaultValue:k,onBlur:pe?void 0:fe,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Y,{sx:{flex:1},children:ce}),e.jsx(xe,{disabled:ae||pe,onClick:K(k),registry:ge})]})}function H(W){const{children:I,description:k,displayLabel:L,errors:K,help:ae,hidden:oe,registry:ce,uiSchema:ge}=W,pe=rn(ge),D=on("WrapIfAdditionalTemplate",ce,pe);return oe?e.jsx("div",{style:{display:"none"},children:I}):e.jsx(Y,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(D,{...W,children:[L===!0&&k,I,K,ae]})})}function F(W){const{description:I}=W;return I?e.jsx(le,{sx:Je,children:I}):null}function j(W){const{required:I,title:k}=W;return k?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(le,{sx:Ge,children:["Title ",k," ",I&&e.jsx("mark",{children:"***"})]})}):null}function _(W){const{help:I}=W;return I?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(le,{sx:vn,children:I})}):null}function ee(W){const{errors:I}=W;return I?e.jsxs(Y,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(le,{color:"error",sx:yn,children:"Please fix the following errors:"}),e.jsx(nt,{children:I.map((k,L)=>e.jsxs(_r,{children:[e.jsx(B,{children:e.jsx(Ur,{color:"error"})}),e.jsx(X,{primary:k.stack})]},L))})]}):null}function d(W){const{errors:I}=W;return I?e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:I.map((k,L)=>e.jsxs(le,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",k]},L))}):null}function s(W){const{id:I,name:k,_schema:L,_uiSchema:K,value:ae,options:oe,label:ce,type:ge,placeholder:pe,required:D,disabled:m,readonly:xe,autofocus:te,onChange:fe,onChangeOverride:Z,onBlur:me,onFocus:ve,_rawErrors:ot,_hideError:Te,_registry:q,_formContext:V}=W,re=({target:{value:Pe}})=>fe(Pe===""?oe.emptyValue:Pe),we=({target:Pe})=>me(I,Pe&&Pe.value),lt=({target:Pe})=>ve(I,Pe&&Pe.value);return e.jsx(Y,{sx:{padding:"0px",margin:"0px"},children:e.jsx(he,{id:I,name:I,label:pe&&pe!==""?ce:void 0,variant:"outlined",placeholder:pe&&pe!==""?pe:ce,required:D,disabled:m||xe,autoFocus:te,value:ae||ae===0?ae:"",type:ge,autoComplete:ge==="password"?"current-password":k,onChange:Z||re,onBlur:we,onFocus:lt,fullWidth:!0})})}function g(W){return console.log("ArrayFieldTitleTemplate:",W),null}function f(W){return console.log("ArrayFieldDescriptionTemplate:",W),null}function R(W){return console.log("ArrayFieldItemTemplate:",W),null}function de(W){const{canAdd:I,onAddClick:k,schema:L,title:K}=W,[ae,oe]=r.useState(!1),[ce,ge]=r.useState(!1),[pe,D]=r.useState(!1),[m,xe]=r.useState(""),te=q=>{xe(q.target.value)},fe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",m,"selectDevices:",Ze),oe(!ae)},Z=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",m,"selectEntities:",Pt),ge(!ce)},me=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",m,"selectDevices:",Ze),D(!pe)},ve=q=>{oe(!1),L.selectFrom==="serial"?L.items.default=q.serial:L.selectFrom==="name"&&(L.items.default=q.name),k()},ot=q=>{ge(!1),L.selectEntityFrom==="name"?L.items.default=q.name:L.selectEntityFrom==="description"&&(L.items.default=q.description),k()},Te=q=>{D(!1),L.selectDeviceEntityFrom==="name"?L.items.default=q.name:L.selectDeviceEntityFrom==="description"&&(L.items.default=q.description),k()};return e.jsxs(Y,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[K&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[K&&e.jsx(le,{sx:Ge,children:K}),I&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[L.selectFrom&&e.jsx(O,{title:"Add a device from the list",children:e.jsx(Q,{onClick:fe,size:"small",color:"primary",sx:Ee,children:e.jsx(dt,{})})}),L.selectEntityFrom&&e.jsx(O,{title:"Add an entity from the list",children:e.jsx(Q,{onClick:Z,size:"small",color:"primary",sx:Ee,children:e.jsx(dt,{})})}),L.selectDeviceEntityFrom&&e.jsx(O,{title:"Add a device entity from the list",children:e.jsx(Q,{onClick:me,size:"small",color:"primary",sx:Ee,children:e.jsx(dt,{})})}),e.jsx(O,{title:"Add a new item",children:e.jsx(Q,{onClick:k,size:"small",color:"primary",sx:Ee,children:e.jsx(wt,{})})})]})]}),L.description&&e.jsx(le,{sx:Je,children:L.description}),W.items.map(q=>e.jsxs(Y,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Y,{sx:{flexGrow:1,marginRight:"10px"},children:q.children}),e.jsx(Q,{disabled:!q.hasMoveUp,onClick:q.onReorderClick(q.index,q.index-1),size:"small",color:"primary",sx:Ee,children:e.jsx(At,{})}),e.jsx(Q,{disabled:!q.hasMoveDown,onClick:q.onReorderClick(q.index,q.index+1),size:"small",color:"primary",sx:Ee,children:e.jsx(Et,{})}),e.jsx(Q,{onClick:q.onDropIndexClick(q.index),size:"small",color:"primary",sx:Ee,children:e.jsx(Nt,{})})]},q.index)),e.jsxs(Re,{open:ae,onClose:fe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(He,{children:"Select a device"}),e.jsxs(Oe,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:m,onChange:te,placeholder:"Enter serial or name"})]}),e.jsx(nt,{dense:!0,children:Ze.filter(q=>q.serial.toLowerCase().includes(m.toLowerCase())||q.name.toLowerCase().includes(m.toLowerCase())).map((q,V)=>e.jsxs(pt,{onClick:()=>ve(q),sx:bt,children:[q.icon==="wifi"&&e.jsx(B,{children:e.jsx(st,{style:Ce})}),q.icon==="ble"&&e.jsx(B,{children:e.jsx(ut,{style:Ce})}),q.icon==="hub"&&e.jsx(B,{children:e.jsx(gt,{style:Ce})}),e.jsx(X,{primary:q.name,secondary:q.serial,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},V))})]}),e.jsx(Ue,{children:e.jsx(ie,{onClick:fe,children:"Close"})})]}),e.jsxs(Re,{open:ce,onClose:Z,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(He,{children:"Select an entity"}),e.jsxs(Oe,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:m,onChange:te,placeholder:"Enter name or description"})]}),e.jsx(nt,{dense:!0,children:Pt.filter(q=>q.name.toLowerCase().includes(m.toLowerCase())||q.description.toLowerCase().includes(m.toLowerCase())).map((q,V)=>e.jsxs(pt,{onClick:()=>ot(q),sx:bt,children:[q.icon==="wifi"&&e.jsx(B,{children:e.jsx(st,{style:Ce})}),q.icon==="ble"&&e.jsx(B,{children:e.jsx(ut,{style:Ce})}),q.icon==="hub"&&e.jsx(B,{children:e.jsx(gt,{style:Ce})}),q.icon==="component"&&e.jsx(B,{children:e.jsx(_t,{style:Ce})}),q.icon==="matter"&&e.jsx(B,{children:e.jsx(Ut,{style:Ce})}),e.jsx(X,{primary:q.name,secondary:q.description,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},V))})]}),e.jsx(Ue,{children:e.jsx(ie,{onClick:Z,children:"Close"})})]}),e.jsxs(Re,{open:pe,onClose:me,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(He,{children:["Select an entity for ",K]}),e.jsx(Oe,{children:e.jsx(nt,{dense:!0,children:Ze.filter(q=>q.serial===K||q.name===K).map(q=>q.entities?.map((V,re)=>e.jsxs(pt,{onClick:()=>Te(V),sx:bt,children:[V.icon==="wifi"&&e.jsx(B,{children:e.jsx(st,{style:Ce})}),V.icon==="ble"&&e.jsx(B,{children:e.jsx(ut,{style:Ce})}),V.icon==="hub"&&e.jsx(B,{children:e.jsx(gt,{style:Ce})}),V.icon==="component"&&e.jsx(B,{children:e.jsx(_t,{style:Ce})}),V.icon==="matter"&&e.jsx(B,{children:e.jsx(Ut,{style:Ce})}),e.jsx(X,{primary:V.name,secondary:V.description,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},re)))})}),e.jsx(Ue,{children:e.jsx(ie,{onClick:me,children:"Close"})})]})]})}function ye(W){const{onAddClick:I,schema:k,properties:L,title:K,description:ae}=W,[oe,ce]=r.useState(!1),[ge,pe]=r.useState(""),D=Z=>{pe(Z.target.value)},m=()=>{ce(!oe)},xe=Z=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${Z.serial}" for schema "${k.selectFrom}"`),ce(!1);let me="";k.selectFrom==="serial"?me=Z.serial:k.selectFrom==="name"&&(me=Z.name),U(me),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${me}"`),I(k)()},te=()=>{I(k)()},fe=!k.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${fe} newkey "${A}"`),!fe&&A!==""&&(o&&console.log("ObjectFieldTemplate: newkey",A,"properties",L),L.forEach(Z=>{if(Z.name==="newKey"&&Z.content.key==="newKey"&&Z.content.props.name==="newKey"&&Z.content.props.onKeyChange&&A!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",A);const me=A;U(""),Z.content.props.onKeyChange(me)}})),e.jsxs(Y,{sx:{margin:"0px",padding:fe?"10px":"5px 10px 0px 10px",border:fe?"none":"1px solid grey"},children:[k.title&&fe&&e.jsx(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:Ge,children:k.title})}),K&&!fe&&e.jsxs(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(le,{sx:Ge,children:K}),e.jsxs(Y,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[k.selectFrom&&e.jsx(O,{title:"Add a device from the list",children:e.jsx(Q,{onClick:m,size:"small",color:"primary",sx:Ee,children:e.jsx(dt,{})})}),e.jsx(O,{title:"Add a new item",children:e.jsx(Q,{onClick:te,size:"small",color:"primary",sx:Ee,children:e.jsx(wt,{})})})]})]}),k.description&&e.jsx(Y,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:Je,children:k.description})}),L.map(({content:Z,name:me,hidden:ve})=>!ve&&e.jsxs(Y,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(k.properties[me].type)?"0px":jn,border:["object","array","boolean"].includes(k.properties[me].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(k.properties[me].type)&&e.jsx(le,{sx:Ge,children:me}),e.jsx(Y,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:Z})]},me)),e.jsxs(Re,{open:oe,onClose:m,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(He,{children:"Select a device"}),e.jsxs(Oe,{children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(le,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:ge,onChange:D,placeholder:"Enter serial or name"})]}),e.jsx(nt,{dense:!0,children:Ze.filter(Z=>Z.serial.toLowerCase().includes(ge.toLowerCase())||Z.name.toLowerCase().includes(ge.toLowerCase())).map((Z,me)=>e.jsxs(pt,{onClick:()=>xe(Z),sx:bt,children:[Z.icon==="wifi"&&e.jsx(B,{children:e.jsx(st,{style:Ce})}),Z.icon==="ble"&&e.jsx(B,{children:e.jsx(ut,{style:Ce})}),Z.icon==="hub"&&e.jsx(B,{children:e.jsx(gt,{style:Ce})}),e.jsx(X,{primary:Z.name,secondary:Z.serial,primaryTypographyProps:{style:vt},secondaryTypographyProps:{style:yt}})]},me))})]}),e.jsx(Ue,{children:e.jsx(ie,{onClick:m,children:"Close"})})]})]})}function se(W){const{uiSchema:I}=W,{submitText:k,norender:L}=tn(I);return L?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ie,{type:"submit",variant:"contained",color:"primary",children:k}),e.jsx(ie,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function je(W){const{className:I,disabled:k,onClick:L,registry:K,style:ae,uiSchema:oe,...ce}=W;return e.jsx(O,{title:"Remove the item",children:e.jsx(Q,{disabled:k,size:"small",color:"primary",onClick:L,children:e.jsx(Nt,{})})})}function T(W){const{className:I,disabled:k,onClick:L,registry:K,uiSchema:ae,...oe}=W;return e.jsx(O,{title:"Add an item",children:e.jsx(Q,{size:"small",color:"primary",onClick:L,children:e.jsx(wt,{})})})}function z(W){const{disabled:I,onClick:k,registry:L,style:K,uiSchema:ae,...oe}=W;return e.jsx(O,{title:"Move up the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:k,children:e.jsx(At,{})})})}function N(W){const{disabled:I,onClick:k,registry:L,style:K,uiSchema:ae,...oe}=W;return e.jsx(O,{title:"Move down the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:k,children:e.jsx(Et,{})})})}function G(W){const{id:I,name:k,value:L,schema:K,readonly:ae,onChange:oe}=W,[ce,ge]=r.useState(),pe=m=>{o&&console.log(`CheckboxWidget ${k} onChangeField:`,m),ge(m&&m!==""?m:void 0)},D=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${k}" value="${ce}"`),i({id:v.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:k,value:ce,formData:w,id:I}}),K.buttonClose===!0?c():K.buttonSave===!0&&b({formData:t})};return K.buttonText&&K.description?e.jsxs(Y,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:Je,children:K.description}),e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>D(),children:K.buttonText})]}):K.buttonField&&K.description?e.jsxs(Y,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:Je,children:K.description}),e.jsx(he,{id:k+"-input",name:k,label:K.textLabel,placeholder:K.textPlaceholder,onChange:m=>pe(m.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ie,{id:k+"-button",variant:"contained",color:"primary",disabled:ce===void 0,onClick:()=>D(),children:K.buttonField})]}):e.jsxs(Y,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[k&&e.jsxs(Y,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(le,{sx:Ge,children:k}),e.jsx(Ae,{checked:L,readOnly:ae,onChange:()=>oe(!L),sx:{padding:"0px",margin:"0px"}})]}),K.description&&e.jsx(le,{sx:Je,children:K.description})]})}function $({schema:W,id:I,name:k,options:L,label:K,hideLabel:ae,required:oe,disabled:ce,placeholder:ge,readonly:pe,value:D,multiple:m,autofocus:xe,onChange:te,onBlur:fe,onFocus:Z,errorSchema:me,rawErrors:ve=[],registry:ot,uiSchema:Te,hideError:q,formContext:V,...re}){const{enumOptions:we,enumDisabled:lt,emptyValue:Pe}=L;m=typeof m>"u"?!1:!!m;const Rt=m?[]:"",Ht=typeof D>"u"||m&&D.length<1||!m&&D===Rt,vr=({target:{value:Ve}})=>te(Dt(Ve,we,Pe)),yr=({target:Ve})=>fe(I,Dt(Ve&&Ve.value,we,Pe)),jr=({target:Ve})=>Z(I,Dt(Ve&&Ve.value,we,Pe)),Ot=Xo(D,we,m),{InputLabelProps:wr,SelectProps:Cr,autocomplete:Sr,...kr}=re,Ir=!m&&W.default===void 0;return e.jsxs(he,{id:I,name:I,value:!Ht&&typeof Ot<"u"?Ot:Rt,required:oe,disabled:ce||pe,autoFocus:xe,autoComplete:Sr,placeholder:ge,error:ve.length>0,onChange:vr,onBlur:yr,onFocus:jr,...kr,select:!0,InputLabelProps:{...wr,shrink:!Ht},SelectProps:{...Cr,multiple:m},"aria-describedby":en(I),children:[Ir&&e.jsx(P,{value:"",children:ge}),Array.isArray(we)&&we.map(({value:Ve,label:Mr},Vt)=>{const Dr=Array.isArray(lt)&&lt.indexOf(Ve)!==-1;return e.jsx(P,{value:String(Vt),disabled:Dr,children:Mr},Vt)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!y||!t?null:e.jsxs(Re,{open:n,onClose:c,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(He,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h3",{children:"Matterbridge plugin configuration"})]})}),e.jsx(Oe,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Zo,{schema:y,formData:t,uiSchema:S,validator:Yo,templates:{FieldTemplate:H,BaseInputTemplate:s,TitleFieldTemplate:j,DescriptionFieldTemplate:F,FieldHelpTemplate:_,FieldErrorTemplate:d,ErrorListTemplate:ee,WrapIfAdditionalTemplate:x,ArrayFieldTitleTemplate:g,ArrayFieldDescriptionTemplate:f,ArrayFieldItemTemplate:R,ArrayFieldTemplate:de,ObjectFieldTemplate:ye,ButtonTemplates:{SubmitButton:se,RemoveButton:je,AddButton:T,MoveUpButton:z,MoveDownButton:N}},widgets:{CheckboxWidget:G,SelectWidget:$},onChange:p,onSubmit:b})})]})};function hr(n){if(o&&console.log(`getQRColor (id: ${n?.id}) received matter:`,n??"undefined"),n===void 0||!n.online||!n.qrPairingCode&&!n.manualPairingCode&&!n.fabricInformations&&!n.sessionInformations)return"red";if(n.commissioned===!1&&n.qrPairingCode&&n.manualPairingCode)return"var(--primary-color)";let c=0,l=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&c++,i.numberOfActiveSubscriptions>0&&(l+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(c===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function Cn({storeId:n,setStoreId:c}){const{online:l,sendMessage:i,addListener:a,removeListener:h,getUniqueId:u}=r.useContext(be),{showConfirmCancelDialog:v}=r.useContext(We),t=r.useRef(u()),[M,y]=r.useState(null),[C,S]=r.useState(null),[E,A]=r.useState([]),U=[{label:"Name",id:"name",required:!0,render:(N,G,$,W)=>e.jsx(O,{title:`Plugin path ${$.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d($),children:$.name})})},{label:"Description",id:"description",render:(N,G,$,W)=>e.jsx(O,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>d($),children:$.description})})},{label:"Version",id:"version",render:(N,G,$,W)=>e.jsx(e.Fragment,{children:e.jsx(O,{title:`Plugin v.${$.version}`,children:e.jsx("span",{children:$.version.split("-dev-")[0]+($.version.includes("-dev-")?"@dev":"")})})})},{label:"Author",id:"author",render:(N,G,$,W)=>e.jsx(e.Fragment,{children:$.author?$.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(N,G,$,W)=>e.jsx(e.Fragment,{children:$.type?$.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(N,G,$,W)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[C&&C.bridgeMode==="childbridge"&&!$.error&&$.enabled&&e.jsx(O,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:hr($.matter)},onClick:()=>{$.matter?.id&&c($.matter?.id)},size:"small",children:e.jsx(sr,{})})}),C&&C.bridgeMode==="childbridge"&&!$.error&&$.enabled&&e.jsx(O,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>_($),size:"small",children:e.jsx(Ct,{})})}),e.jsx(O,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{disabled:$.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>je($),size:"small",children:e.jsx(qr,{})})}),C&&!C.readOnly&&e.jsx(O,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{p("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",$)},size:"small",children:e.jsx(ir,{})})}),$.enabled?e.jsx(O,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{p("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",$)},size:"small",children:e.jsx(zr,{})})}):e.jsx(e.Fragment,{}),$.enabled?e.jsx(e.Fragment,{}):e.jsx(O,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>ee($),size:"small",children:e.jsx(Br,{})})}),e.jsx(O,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>g($),size:"small",children:e.jsx(ar,{})})}),e.jsx(O,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>f($),size:"small",children:e.jsx(Ft,{})})}),$.latestVersion!==void 0&&$.latestVersion!==$.version&&C&&!C.readOnly&&e.jsx(O,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>H($),size:"small",children:e.jsx($e,{})})}),$.version.includes("-dev-")&&$.devVersion!==void 0&&$.devVersion!==$.version&&C&&!C.readOnly&&e.jsx(O,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>F($),size:"small",children:e.jsx($e,{})})}),C&&!C.readOnly&&e.jsx(O,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>s($),size:"small",children:e.jsx(Tt,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(N,G,$,W)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:$.error?e.jsx(e.Fragment,{children:e.jsx(Ke,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:$.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ke,{status:$.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:$.loaded&&$.started&&$.configured?e.jsx(e.Fragment,{children:e.jsx(Ke,{status:$.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ke,{status:$.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ke,{status:$.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ke,{status:$.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const N=G=>{o&&console.log("HomePlugins received WebSocket Message:",G),G.method==="refresh_required"&&G.response.changed==="plugins"?(o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):G.method==="refresh_required"&&G.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and setting matter id ${G.response.matter?.id}`),A($=>{const W=$.findIndex(k=>k.matter?.id===G.response.matter?.id);if(W<0)return o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and matter id ${G.response.matter?.id} not found`),$;o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} set matter id ${G.response.matter?.id}`);const I=[...$];return I[W]={...I[W],matter:G.response.matter},I})):G.method==="refresh_required"&&G.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${G.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),G.id===t.current&&G.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${G.id}) received settings:`,G.response),y(G.response.systemInformation),S(G.response.matterbridgeInformation)):G.id===t.current&&G.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${G.id}) received ${G.response.length} plugins:`,G.response),A(G.response))};return a(N,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{h(N),o&&console.log("HomePlugins removed WebSocket listener")}},[a,h,i]),r.useEffect(()=>{l&&(o&&console.log("HomePlugins sending api requests"),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const w=r.useRef(null),p=(N,G,$,W)=>{o&&console.log(`handleActionWithConfirmCancel ${$} ${W.name}`),w.current=W,v(N,G,$,b,x)},b=N=>{o&&console.log(`handleConfirm action confirmed ${N} ${w.current?.name}`),N==="remove"&&w.current?j(w.current):N==="disable"&&w.current&&ee(w.current),w.current=null},x=N=>{o&&console.log(`handleCancel action canceled ${N} ${w.current?.name}`),w.current=null},H=N=>{o&&console.log("handleUpdatePlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:N.name,restart:!1}})},F=N=>{o&&console.log("handleUpdateDevPlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:N.name+"@dev",restart:!1}})},j=N=>{o&&console.log("handleRemovePlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})},_=N=>{o&&console.log("handleRestartPlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})},ee=N=>{o&&console.log("handleEnableDisablePlugin plugin:",N.name,"enabled:",N.enabled),N.enabled===!0?(N.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}})):(N.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:N.name}}))},d=N=>{o&&console.log(`handleHomepagePlugin plugin: ${N.name} homepage: ${N.homepage}`),N.homepage&&window.open(N.homepage,"_blank")},s=N=>{o&&console.log("handleSponsorPlugin plugin:",N.name,"funding:",N.funding),N.funding&&window.open(N.funding,"_blank")},g=N=>{o&&console.log("handleHelpPlugin plugin:",N.name,"help:",N.help),N.help&&window.open(N.help,"_blank")},f=N=>{o&&console.log("handleChangelogPlugin plugin:",N.name,"changelog:",N.changelog),N.changelog&&window.open(N.changelog,"_blank")},[R,de]=r.useState(),[ye,se]=r.useState(!1),je=N=>{o&&console.log("handleConfigPlugin plugin:",N.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:N.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:N.name}}),de(N),T()},T=()=>{se(!0)},z=()=>{se(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs(ke,{children:[R&&e.jsx(wn,{open:ye,onClose:z,plugin:R}),e.jsx(It,{name:"Plugins",columns:U,rows:E,footerRight:"",footerLeft:""})]}):e.jsx(Ne,{})}const Sn=r.memo(Cn),kn=n=>`${n.pluginName}::${n.serial}`;function In({storeId:n,setStoreId:c}){const{online:l,sendMessage:i,addListener:a,removeListener:h,getUniqueId:u}=r.useContext(be),[v,t]=r.useState(!1),[M,y]=r.useState(!0),[C,S]=r.useState(null),[E,A]=r.useState([]),[U,w]=r.useState([]),[p,b]=r.useState([]),[x,H]=r.useState([]),F=r.useRef(u()),j=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(d,s,g,f)=>g.reachable===!0?"Online":g.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(d,s)=>{const g=d.reachable===!0?1:d.reachable===!1?0:-1,f=s.reachable===!0?1:s.reachable===!1?0:-1;return g-f}},{label:"Power",id:"powerSource",render:(d,s,g,f)=>g.powerSource==="ac"||g.powerSource==="dc"?e.jsx(lr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):g.powerSource==="ok"?e.jsx(St,{fontSize:"small",sx:{color:"green"}}):g.powerSource==="warning"?e.jsx(St,{fontSize:"small",sx:{color:"yellow"}}):g.powerSource==="critical"?e.jsx(St,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Actions",id:"selected",required:!0,render:(d,s,g,f)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[g.matter!==void 0?e.jsx(O,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>c(n===g.matter?.id?C?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:g.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:hr(g.matter)},children:e.jsx(sr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),g.configUrl?e.jsx(O,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>window.open(g.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(cr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),g.selected!==void 0?e.jsx(O,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Ae,{checked:g.selected,onChange:R=>ee(R,g),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],_=r.useCallback(d=>{d.selected=void 0;const s=E.find(R=>R.name===d.pluginName);if(!s)return console.error(`HomeDevices isSelected: plugin ${d.pluginName} not found for device ${d.name} `),d.selected;const g=s.schemaJson?.properties?.whiteList?.selectFrom;let f=s.configJson.postfix;return f===""&&(f=void 0),s.hasWhiteList===!0&&s.hasBlackList===!0&&g&&(d.selected=!0,g==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(f?d.serial.replace("-"+f,""):d.serial)&&(d.selected=!0),g==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(f?d.serial.replace("-"+f,""):d.serial)&&(d.selected=!1),g==="serial"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(f?d.serial.replace("-"+f,""):d.serial)&&(d.selected=!1),g==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(d.name)&&(d.selected=!0),g==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(d.name)&&(d.selected=!1),g==="name"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(d.name)&&(d.selected=!1)),d.selected},[E]);r.useEffect(()=>{const d=s=>{if(o&&console.log("HomeDevices received WebSocket Message:",s),s.method==="refresh_required"&&s.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and sending /api/plugins request`),i({id:F.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):s.method==="refresh_required"&&s.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and setting matter id ${s.response.matter?.id}`),H(g=>{const f=g.findIndex(de=>de.name.replaceAll(" ","")===s.response.matter?.id);if(f<0)return o&&console.debug(`HomeDevices: matter id ${s.response.matter?.id} not found`),g;const R=[...g];return R[f]={...R[f],matter:s.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and set matter id ${s.response.matter?.id}`),R})):s.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):s.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):s.method==="state_update"&&s.response.plugin&&s.response.serialNumber&&s.response.cluster.includes("BasicInformation")&&s.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${s.response.plugin} serial ${s.response.serialNumber} value ${s.response.value}`),w(g=>{const f=g.findIndex(R=>R.pluginName===s.response.plugin&&R.serial===s.response.serialNumber);return f<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${s.response.plugin} serial ${s.response.serialNumber}`),g):(g[f]={...g[f],reachable:s.response.value},[...g])})),s.id===F.current&&s.method==="/api/settings")o&&console.log(`HomeDevices (id: ${s.id}) received settings:`,s.response),S(s.response),t(s.response.matterbridgeInformation.restartRequired||s.response.matterbridgeInformation.fixedRestartRequired);else if(s.id===F.current&&s.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} plugins:`,s.response),s.response){let g=!0;for(const f of s.response)f.enabled===!0&&(f.loaded!==!0||f.started!==!0||f.error===!0)&&(g=!1);if(!g)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),y(!1),A(s.response),w([]),b([]),i({id:F.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const f of s.response)f.enabled===!0&&f.loaded===!0&&f.started===!0&&f.error!==!0&&(i({id:F.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:f.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${f.name}`))}}else if(s.id===F.current&&s.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} devices:`,s.response),s.response){for(const g of s.response)g.selected=_(g);w(s.response)}}else s.id===F.current&&s.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} selectDevices for plugin ${s.response&&s.response.length>0?s.response[0].pluginName:"without select devices"}:`,s.response),s.response&&s.response.length>0&&b(g=>{const f=g.filter(de=>de.pluginName!==s.response[0].pluginName),R=s.response.map(de=>({...de,selected:_(de)}));return[...f,...R]}))};return a(d,F.current),o&&console.log(`HomeDevices added WebSocket listener id ${F.current}`),()=>{h(d),o&&console.log("HomeDevices removed WebSocket listener")}},[E,a,h,i,_]),r.useEffect(()=>{if(U.length===0&&p.length===0){H([]);return}o&&console.log(`HomeDevices mixing devices (${U.length}) and selectDevices (${p.length})`);const d=[];for(const s of U)d.push(s);for(const s of p)U.find(g=>g.pluginName===s.pluginName&&g.serial.includes(s.serial))||d.push(s);d.length>0&&(H(d),o&&console.log(`HomeDevices mixed ${d.length} devices and selectDevices`))},[E,U,p,H]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:F.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:F.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const ee=(d,s)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${d.target.checked} for device ${s.name} serial ${s.serial}`),U.findIndex(g=>g.pluginName===s.pluginName&&g.serial===s.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices, trying in mixedDevices`),H(g=>{const f=g.findIndex(R=>R.pluginName===s.pluginName&&R.serial===s.serial);return f<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in mixedDevices`),g):(g[f]={...g[f],selected:d.target.checked},[...g])})):w(g=>{const f=g.findIndex(R=>R.pluginName===s.pluginName&&R.serial===s.serial);return f<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices`),g):(g[f]={...g[f],selected:d.target.checked},[...g])}),d.target.checked?i({id:F.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}}):i({id:F.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}})};return o&&console.log("HomeDevices rendering..."),l?e.jsx(ke,{style:{flex:"1 1 auto"},children:e.jsx(It,{name:"Devices",getRowKey:kn,rows:x,columns:j,footerLeft:M?"Waiting for the plugins to fully load...":`Registered devices: ${U.length.toString()}/${x.length.toString()}`,footerRight:v?"Restart required":""})}):e.jsx(Ne,{})}const Mn=r.memo(In);function at({children:n,style:c,name:l}){const{setCurrentPage:i}=r.useContext(We);i(l),o&&console.log(`MbfPage: current page set to ${l}`);const a={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...a,...c},children:n})}const Dn=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(o&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(o&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Pn(){const{messages:n,logAutoScroll:c}=r.useContext(gr),[l,i]=r.useState(!1),a=r.useRef(null),h=r.useRef(0),u=r.useRef(null),v=r.useMemo(()=>Dn(),[]),t=S=>i(!0),M=S=>i(!1);r.useEffect(()=>{if(o&&console.log(`WebSocketLogs logAutoScroll: ${c} isHovering: ${l}`),c&&!l&&!v){const S=Date.now();S-h.current>=500?(o&&console.log("WebSocketLogs auto-scroll to bottom"),h.current=S,a.current?.scrollIntoView({behavior:"smooth",block:"end"})):(o&&console.log("WebSocketLogs auto-scroll skipped to avoid flicker"),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>{a.current?.scrollIntoView({behavior:"smooth"}),h.current=Date.now()},1e3))}},[n,c,l,v]);const y=S=>{switch(S.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"#5c0e91"}},C=S=>{switch(S.toLowerCase()){case"warn":return"black";default:return"white"}};return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:t,onMouseLeave:M,children:[n.map((S,E)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:y(S.level),color:C(S.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:S.level}),S.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+S.time+"]"}),S.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+S.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:S.message})]},E)),e.jsx("div",{ref:a})]})})}const fr=r.memo(Pn);function Ln(){const[n,c]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,h]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{online:u}=r.useContext(be);return o&&console.log("HomeLogs rendering..."),u?e.jsxs(ke,{style:{flex:"1 1 auto"},children:[e.jsxs(De,{children:[e.jsx(Ie,{children:"Logs"}),e.jsxs(Ie,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',l,'" Scroll: ',a?"auto":"manual"]})]}),e.jsx(Fe,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(fr,{})})]}):e.jsx(Ne,{})}const $n=r.memo(Ln);function Wn(){const{online:n}=r.useContext(be);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(ke,{children:[e.jsx(De,{children:e.jsx(Ie,{children:"Frontend Update"})}),e.jsxs(Fe,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Qr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(Ne,{})}const Nn=r.memo(Wn);function Fn({changelog:n}){const{online:c}=r.useContext(be);return o&&console.log("HomeShowChangelog rendering..."),c?e.jsxs(ke,{children:[e.jsx(De,{children:e.jsx(Ie,{children:"Matterbridge Update"})}),e.jsxs(Fe,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(ie,{onClick:()=>window.open("https://github.com/Luligu/matterbridge","_blank"),endIcon:e.jsx(dr,{style:{color:"#FFD700"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Star"}),e.jsx(ie,{onClick:()=>window.open("https://www.buymeacoffee.com/luligugithub","_blank"),endIcon:e.jsx(Tt,{style:{color:"#b6409c"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Sponsor"}),e.jsx(ie,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Ft,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Kr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(Ne,{})}const Tn=r.memo(Fn);function Rn({matterbridgeInfo:n}){o&&console.log("MatterbridgeInfoTable:",n);const c=["matterbridgeLatestVersion","matterbridgeDevVersion","matterFileLogger","fileLogger","matterLoggerLevel","loggerLevel","cccvirtualMode","--bridgeMode","--restartMode","---restartRequired","fixedRestartRequired","---updateRequired","matterMdnsInterface","matterIpv4Address","matterIpv6Address","readOnly","shellyBoard","shellySysUpdate","shellyMainUpdate","matterPort","matterDiscriminator","matterPasscode"],[l,i]=r.useState(!1);return!n||l?null:(o&&console.log("MatterbridgeInfoTable rendering..."),e.jsxs(ke,{style:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(De,{children:[e.jsx(Ie,{children:"Matterbridge Information"}),e.jsx(rt,{onClose:()=>i(!0)})]}),e.jsx(Fe,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(n).filter(([a,h])=>!c.includes(a)&&h!==null&&h!==void 0&&h!=="").map(([a,h],u)=>e.jsxs("tr",{className:u%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:a.replace("matterbridgeVersion","matterbridge v.").replace("matterbridgeLatestVersion","matterbridge latest v.").replace("matterbridgeDevVersion","matterbridge dev v.").replace("frontendVersion","frontend v.").replace("homeDirectory","home").replace("rootDirectory","root").replace("matterbridgeDirectory","storage").replace("matterbridgeCertDirectory","cert").replace("matterbridgePluginDirectory","plugins").replace("globalModulesDirectory","modules")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(mr,{value:typeof h!="string"?h.toString():h,maxChars:24})})]},a))})})})]}))}const Hn=r.memo(Rn);function On(){const[n,c]=r.useState(null),[l,i]=r.useState(null),[a,h]=r.useState([]),[u]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[v,t]=r.useState(localStorage.getItem("homePageMode")??"devices"),[M,y]=r.useState(""),[C,S]=r.useState(!1),[E,A]=r.useState(!1),[U,w]=r.useState(null),{mobile:p}=r.useContext(We),{addListener:b,removeListener:x,online:H,sendMessage:F,getUniqueId:j}=r.useContext(be),_=r.useRef(j());return r.useEffect(()=>{const ee=d=>{o&&console.log("Home received WebSocket Message:",d),d.method==="refresh_required"&&d.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${d.response.changed} and sending /api/settings request`),w(null),h([]),F({id:_.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),F({id:_.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),d.method==="/api/settings"&&d.id===_.current&&(o&&console.log("Home received settings:",d.response),c(d.response.systemInformation),i(d.response.matterbridgeInformation),d.response.matterbridgeInformation.matterbridgeVersion&&y(`https://github.com/Luligu/matterbridge/blob/${d.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&d.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",d.response.matterbridgeInformation.frontendVersion):d.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&d.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",d.response.matterbridgeInformation.frontendVersion),A(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",d.response.matterbridgeInformation.matterbridgeVersion):d.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",d.response.matterbridgeInformation.matterbridgeVersion),S(!0)),d.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),t("devices")))),d.method==="/api/plugins"&&d.id===_.current&&(o&&console.log("Home received plugins:",d.response),h(d.response))};return b(ee,_.current),o&&console.log(`Home added WebSocket listener id ${_.current}`),()=>{x(ee),o&&console.log("Home removed WebSocket listener")}},[b,x,F]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${U}`),l?.bridgeMode==="bridge"&&!U&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),w("Matterbridge")),l?.bridgeMode==="childbridge"&&!U&&a){for(const ee of a)if(ee.matter?.id){o&&console.log(`Home storeId effect set storeId to ${ee.matter.id}`),w(ee.matter.id);break}}},[l,a,U]),r.useEffect(()=>{H&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),F({id:_.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),F({id:_.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[H,F]),o&&console.log("Home rendering..."),!H||!n||!l?e.jsx(Ne,{}):e.jsxs(at,{name:"Home",style:p?{alignItems:"center",gap:"10px"}:{flexDirection:"row"},children:[(!p||!1)&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(Xt,{id:U}),e.jsx(Zt,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:p?"10px":"20px"},children:[E&&e.jsx(Nn,{}),C&&e.jsx(Tn,{changelog:M}),p&&e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(Xt,{id:U}),e.jsx(Zt,{systemInfo:n,compact:!0}),e.jsx(Hn,{matterbridgeInfo:l})]}),u&&!l.readOnly&&e.jsx(hn,{}),u&&e.jsx(Sn,{storeId:U,setStoreId:w}),v==="devices"&&e.jsx(Mn,{storeId:U,setStoreId:w}),v==="logs"&&e.jsx($n,{})]})]})}const Vn=r.memo(On),jt=!1,tr={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},En={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},An={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},rr={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},_n={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Un={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},qn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},zn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Bn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Lt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},Qn=[256,257,268,269],Kn=[266,267],Gn=[259,260,261,271,272],Jn=[256,257,268,269,266,267,259,260,261,272];function J({icon:n,iconColor:c,cluster:l,value:i,unit:a,prefix:h}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${a}"`),h=h??!1,e.jsxs(Y,{sx:tr,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...En,color:c??"var(--primary-color)"}}),e.jsxs(Y,{sx:{...tr,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[a&&h===!0&&e.jsx(le,{sx:rr,children:a},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(le,{sx:An,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${l.clusterId}-${l.attributeId}-value`),a&&h===!1&&e.jsx(le,{sx:rr,children:a},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function Zn({device:n,endpoint:c,id:l,deviceType:i,clusters:a}){const h=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let u="";o&&console.log(`Device "${n.name}" endpoint "${c}" id "${l}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${a?.length})`);const v=a.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(v){let t="";v.map(M=>{M.label&&(t+=M.label+" ")}),u=t.trim()}if(i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>u=`${t.attributeLocalValue} mV`),Jn.includes(i)&&a.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>u=`Level ${t.attributeValue}`),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>u=`Position ${t.attributeLocalValue/100}%`),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>u=`Heat ${t.attributeLocalValue/100}°C `),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>u=u+`Cool ${t.attributeLocalValue/100}°C`),i===118&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>u=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>u=`${t.attributeLocalValue/1e3} V, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>u=u+`${t.attributeLocalValue/1e3} A, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>u=u+`${t.attributeLocalValue/1e3} W`),i===39){const t=a.find(y=>y.clusterName==="ModeSelect"&&y.attributeName==="currentMode")?.attributeLocalValue;u=a.find(y=>y.clusterName==="ModeSelect"&&y.attributeName==="supportedModes")?.attributeLocalValue?.find(y=>y.mode===t)?.label||"Unknown"}if(i===116){const t=a.find(y=>y.clusterName==="RvcRunMode"&&y.attributeName==="currentMode")?.attributeLocalValue;u=a.find(y=>y.clusterName==="RvcRunMode"&&y.attributeName==="supportedModes")?.attributeLocalValue?.find(y=>y.mode===t)?.label||"Unknown"}return e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:t.attributeLocalValue===!0?e.jsx(st,{}):e.jsx(Gr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(J,{icon:e.jsx(St,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(J,{icon:e.jsx(lr,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&a.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),Qn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Kn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Gn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Ro,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:e.jsx(qt,{}),cluster:t,value:"Oven"})),i===112&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:e.jsx(Zr,{}),cluster:t,value:"Fridge"})),i===113&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Oo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(qt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Gt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Gt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(J,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Eo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&a.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(J,{icon:t.attributeValue==="1"?e.jsx(Xr,{}):e.jsx(eo,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(J,{icon:e.jsx(to,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&a.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Ao,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&a.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(J,{icon:e.jsx(ro,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(oo,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(J,{icon:e.jsx(zt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(J,{icon:e.jsx(zt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(no,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(io,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(so,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&a.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:_o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&a.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Uo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&a.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:qo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:zo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Qo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Jt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Jt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&a.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(J,{icon:e.jsx(ao,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&a.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:h[t.attributeLocalValue??0]})),i===770&&a.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(lo,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&a.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(ne,{path:Go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&a.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(co,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&a.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(po,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:t.attributeValue==="true"?e.jsx(uo,{}):e.jsx(go,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&a.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(J,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(mo,{}):e.jsx(ho,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&a.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(fo,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&a.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(J,{icon:e.jsx(xo,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Y,{sx:_n,children:e.jsx(le,{sx:Un,children:u})}),e.jsx(Y,{sx:qn,children:e.jsx(le,{sx:zn,children:n.name})}),e.jsxs(Y,{sx:Bn,children:[o&&e.jsx(le,{sx:Lt,children:c}),e.jsx(le,{sx:Lt,children:l}),o&&e.jsxs(le,{sx:Lt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Yn({filter:n}){const{online:c,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(be),[u,v]=r.useState([]),[t,M]=r.useState({}),[y,C]=r.useState({}),[S,E]=r.useState({}),A=r.useRef(h()),U=r.useCallback(b=>{(o||jt)&&console.log(`DevicesIcons received state_update "${b.response.cluster}.${b.response.attribute}" for "${b.response.id}:${b.response.number}": "${b.response.value}"`,b.response);const x=u.find(F=>F.pluginName===b.response.plugin&&F.serial===b.response.serialNumber);if(!x){(o||jt)&&console.warn(`DevicesIcons updater device of plugin "${b.response.plugin}" serial "${b.response.serialNumber}" number "${b.response.number}" id "${b.response.id}" not found in devices(${u.length})`);return}const H=S[x.serial]?.find(F=>F.endpoint===b.response.number.toString()&&F.clusterName===b.response.cluster&&F.attributeName===b.response.attribute);if(!H){(o||jt)&&console.warn(`DevicesIcons updater device "${x.name}" serial "${x.serial}" cluster "${b.response.cluster}" attribute "${b.response.attribute}" not found in clusters(${S[x.serial]?.length})`);return}H.attributeValue=String(b.response.value),H.attributeLocalValue=b.response.value,E({...S}),(o||jt)&&console.log(`DevicesIcons updated "${H.clusterName}.${H.attributeName}" for device "${x.name}" serial "${x.serial}" to "${H.attributeValue}"`)},[S,u]),w=r.useCallback(b=>{if(o&&console.log(`DevicesIcons received for device "${b.response.deviceName}" serial "${b.response.serialNumber}" deviceTypes (${b.response.deviceTypes.length}) "${b.response.deviceTypes.join(",")}" clusters (${b.response.clusters.length}):`,b.response),b.response.clusters.length===0)return;const x=b.response.serialNumber;t[x]=[],y[x]=b.response.deviceTypes,S[x]=[];for(const H of b.response.clusters)t[x].find(F=>F.endpoint===H.endpoint)||t[x].push({endpoint:H.endpoint,id:H.id,deviceTypes:H.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(H.clusterName)&&S[x].push(H);M({...t}),C({...y}),E({...S}),o&&console.log(`DevicesIcons endpoints for "${x}":`,t[x]),o&&console.log(`DevicesIcons deviceTypes for "${x}":`,y[x]),o&&console.log(`DevicesIcons clusters for "${x}":`,S[x])},[S,y,t]);r.useEffect(()=>{const b=x=>{if(o&&console.log("DevicesIcons received WebSocket Message:",x),x.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${x.response.changed} and sending api requests`),l({id:A.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(x.method==="state_update"&&x.response)U(x);else if(x.method==="/api/devices"&&x.response){o&&console.log(`DevicesIcons received ${x.response.length} devices:`,x.response),v(x.response),M({}),C({}),E({});for(const H of x.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:A.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:H.pluginName,endpoint:H.endpoint||0}})}else x.method==="/api/clusters"&&x.response&&w(x)};return i(b,A.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{a(b),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[u]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),c&&(o&&console.log("DevicesIcons useEffect online sending api requests"),l({id:A.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),o&&console.log("DevicesIcons useEffect online mounted"),()=>{o&&console.log("DevicesIcons useEffect online unmounted")}),[c,l]);const p=r.memo(Zn);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:u.filter(b=>b.name.toLowerCase().includes(n)||b.serial.toLowerCase().includes(n)).map(b=>t[b.serial]&&t[b.serial].map(x=>x.deviceTypes.map(H=>e.jsx(p,{device:b,endpoint:x.endpoint,id:x.id,deviceType:H,clusters:S[b.serial].filter(F=>F.endpoint===x.endpoint)},`${b.pluginName}-${b.uniqueId}-${x.endpoint}-${x.id}-${H.toString()}`))))})}const Xn=r.memo(Yn),ei=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(n,c,l,i)=>l.configUrl?e.jsx(Q,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(cr,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],ti=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,c,l,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(a=>`0x${a.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,render:(n,c,l,i)=>e.jsx(O,{title:String(n),componentsProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("div",{style:{maxWidth:"500px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(n)})})}],ri=n=>`${n.pluginName}::${n.uniqueId}`,oi=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function ni({filter:n}){const{online:c,sendMessage:l,addListener:i,removeListener:a,getUniqueId:h}=r.useContext(be),[u,v]=r.useState([]),[t,M]=r.useState(u),[y,C]=r.useState([]),[S,E]=r.useState(0),[A,U]=r.useState(null),[w,p]=r.useState(null),[b,x]=r.useState(null),[H,F]=r.useState(null),j=r.useRef(h()),_=r.useRef(t),ee=r.useCallback(s=>{o&&console.log(`DevicesTable received state_update "${s.response.cluster}.${s.response.attribute}" for "${s.response.id}:${s.response.number}": "${s.response.value}"`,s.response);const g=_.current.find(f=>f.pluginName===s.response.plugin&&f.uniqueId===s.response.uniqueId);if(!g){o&&console.warn(`DevicesTable updater device of plugin "${s.response.plugin}" serial "${s.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(A&&w&&g.pluginName===A&&g.uniqueId===H&&s.response.number.toString()===w){const f=y.find(R=>R.endpoint===s.response.number.toString()&&R.clusterName===s.response.cluster&&R.attributeName===s.response.attribute);if(!f){o&&console.warn(`DevicesTable updater cluster ${s.response.cluster}.${s.response.attribute} for device "${g.name}" serial "${g.serial}" not found in clusters`);return}f.attributeValue=typeof s.response.value=="object"?JSON.stringify(s.response.value,void 0,1).replaceAll('"',""):String(s.response.value),f.attributeLocalValue=s.response.value,C([...y]),o&&console.log(`DevicesTable updated attribute ${f.clusterName}.${f.attributeName} for device "${g.name}" serial "${g.serial}" to "${f.attributeValue}"`)}},[y,w,A,H]);r.useEffect(()=>{const s=g=>{if(o&&console.log("DevicesTable received WebSocket Message:",g),g.method==="refresh_required"&&g.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${g.response.changed} and sending /api/devices request`),l({id:j.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(g.method==="state_update"&&g.response)ee(g);else if(g.method==="/api/devices")o&&console.log(`DevicesTable received ${g.response.length} devices:`,g.response),v(g.response);else if(g.method==="/api/clusters"){o&&console.log(`DevicesTable received ${g.response.clusters.length} clusters for plugin ${g.response.plugin}:`,g.response),C(g.response.clusters);const f={};for(const R of g.response.clusters)o&&console.log("Cluster:",R.endpoint),f[R.endpoint]?f[R.endpoint]++:f[R.endpoint]=1;E(Object.keys(f).length)}};return i(s,j.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{a(s),o&&console.log("DevicesTable removed WebSocket listener")}},[l,i,a,ee]),r.useEffect(()=>{c&&(o&&console.log("DevicesTable sending api requests with id ",j.current),l({id:j.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:j.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:j.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,l]),r.useEffect(()=>{A&&w&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:j.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:A,endpoint:Number(w)}}))},[A,w,l]),r.useEffect(()=>{if(n===""){M(u),_.current=u;return}const s=u.filter(g=>g.name.toLowerCase().includes(n)||g.serial.toLowerCase().includes(n));M(s),_.current=s},[u,n]);const d=s=>{if(s.uniqueId===H){F(null),U(null),p(null),x(null);return}F(s.uniqueId),U(s.pluginName),p(s.endpoint?s.endpoint.toString():null),x(s.name)};return o&&console.log("DevicesTable rendering..."),c?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${A&&w?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(It,{name:"Registered devices",getRowKey:ri,onRowClick:d,rows:t,columns:ei,footerLeft:`Total devices: ${t.length.toString()}`})}),A&&w&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(It,{name:"Clusters",title:b||"",getRowKey:oi,rows:y,columns:ti,footerLeft:`Total child endpoints: ${S-1}`})})]}):e.jsx(Ne,{})}const ii=r.memo(ni);function si(){const{online:n}=r.useContext(be),[c,l]=r.useState(""),[i,a]=r.useState("icon");r.useEffect(()=>{const v=localStorage.getItem("devicesFilter");v&&l(v)},[]),r.useEffect(()=>{const v=localStorage.getItem("devicesViewMode");v&&a(v)},[]);const h=v=>{l(v.target.value.toLowerCase()),localStorage.setItem("devicesFilter",v.target.value.toLowerCase())},u=v=>{a(v),localStorage.setItem("devicesViewMode",v)};return o&&console.log("Devices rendering..."),n?e.jsxs(at,{name:"Devices",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",padding:0,margin:0,gap:"20px",width:"100%"},children:[e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(le,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{variant:"outlined",value:c,onChange:h,placeholder:"Enter the device name or serial",sx:{width:"260px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(Y,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(le,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(Q,{onClick:()=>u("table"),"aria-label":"Table View",disabled:i==="table",children:e.jsx(O,{title:"Table View",children:e.jsx(bo,{style:{color:i==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(Q,{onClick:()=>u("icon"),"aria-label":"Icon View",disabled:i==="icon",children:e.jsx(O,{title:"Icon View (beta)",children:e.jsx(vo,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(ii,{filter:c}),i==="icon"&&e.jsx(Xn,{filter:c})]}):e.jsx(Ne,{})}const ai=r.memo(si);function li(){const[n,c]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,h]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:u,setLogFilterLevel:v,setLogFilterSearch:t,online:M,setLogAutoScroll:y,filterLogMessages:C}=r.useContext(be),S=w=>{c(w.target.value),v(w.target.value),C(w.target.value,l),localStorage.setItem("logFilterLevel",w.target.value),o&&console.log("handleChangeLevel called with value:",w.target.value)},E=w=>{i(w.target.value),t(w.target.value),C(n,w.target.value),localStorage.setItem("logFilterSearch",w.target.value),o&&console.log("handleChangeSearch called with value:",w.target.value)},A=w=>{h(w.target.checked),y(w.target.checked),C(n,l),localStorage.setItem("logAutoScroll",w.target.checked?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",w.target.checked)},U=()=>{o&&console.log("handleClearLogsClick called"),u([])};return o&&console.log("Logs rendering..."),M?e.jsxs(at,{name:"Logs",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"15px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(Bt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(et,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:n,onChange:S,children:[e.jsx(P,{value:"debug",children:"Debug"}),e.jsx(P,{value:"info",children:"Info"}),e.jsx(P,{value:"notice",children:"Notice"}),e.jsx(P,{value:"warn",children:"Warn"}),e.jsx(P,{value:"error",children:"Error"}),e.jsx(P,{value:"fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(Bt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(he,{style:{width:"210px"},size:"small",id:"logsearch",variant:"outlined",value:l,onChange:E,slotProps:{input:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}})]}),e.jsx(ze,{control:e.jsx(Ae,{checked:a,onChange:A}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center"},children:e.jsx(O,{title:"Clear the logs",children:e.jsx(ie,{onClick:U,endIcon:e.jsx(Nt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Clear"})})})]}),e.jsx("div",{style:{flex:"1",overflow:"auto",margin:"0px",padding:"0px"},children:e.jsx(fr,{})})]}):e.jsx(Ne,{})}const ci=r.memo(li),di=({open:n,ip:c,onClose:l,onSave:i})=>{const a=c?c.split(".").slice(0,3).join(".")+".1":"",[h,u]=r.useState("dhcp"),[v,t]=r.useState({ip:c??"",subnet:"255.255.255.0",gateway:a,dns:a}),M=S=>E=>{t({...v,[S]:E.target.value})},y=()=>{l()},C=()=>{i({type:h,...v}),l()};return e.jsxs(Re,{open:n,onClose:(S,E)=>{E==="backdropClick"||E==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(He,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Network Configuration"})]})}),e.jsxs(Oe,{dividers:!0,children:[e.jsxs(pr,{component:"fieldset",fullWidth:!0,children:[e.jsx(Se,{component:"legend",children:"Select IP Configuration"}),e.jsxs(ur,{row:!0,value:h,onChange:S=>u(S.target.value),children:[e.jsx(ze,{value:"dhcp",control:e.jsx(kt,{}),label:"DHCP"}),e.jsx(ze,{value:"static",control:e.jsx(kt,{}),label:"Static"})]})]}),h==="static"&&e.jsxs(_e,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(_e,{size:6,children:e.jsx(he,{label:"IP Address",fullWidth:!0,value:v.ip,onChange:M("ip")})}),e.jsx(_e,{size:6,children:e.jsx(he,{label:"Subnet Mask",fullWidth:!0,value:v.subnet,onChange:M("subnet")})}),e.jsx(_e,{size:6,children:e.jsx(he,{label:"Gateway",fullWidth:!0,value:v.gateway,onChange:M("gateway")})}),e.jsx(_e,{size:6,children:e.jsx(he,{label:"DNS Server",fullWidth:!0,value:v.dns,onChange:M("dns")})})]})]}),e.jsxs(Ue,{children:[e.jsx(ie,{onClick:y,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:C,children:"Save"})]})]})},pi=({open:n,onClose:c,onSave:l})=>{const[i,a]=r.useState(""),[h,u]=r.useState(""),v=E=>{a(E.target.value)},t=E=>{u(E.target.value)},M=i.length>0&&i===h,y=()=>{c()},C=()=>{M&&(l(i),c())},S=()=>{l(""),c()};return e.jsxs(Re,{open:n,onClose:(E,A)=>{A==="backdropClick"||A==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(He,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:"Change Password"})]})}),e.jsx(Oe,{dividers:!0,children:e.jsx(pr,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(_e,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(_e,{size:12,children:e.jsx(he,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:v})}),e.jsx(_e,{size:12,children:e.jsx(he,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:h,onChange:t,error:h!==""&&i!==h,helperText:h!==""&&i!==h?"Passwords do not match":""})})]})})}),e.jsxs(Ue,{children:[e.jsx(ie,{onClick:y,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:C,disabled:!M,children:"Change"}),e.jsx(ie,{variant:"contained",onClick:S,children:"Reset"})]})]})};function Ye(n=1e3){let c=null;const l=(i=>{c!==null&&window.clearTimeout(c),c=window.setTimeout(()=>{i(),c=null},n)});return l.cancel=()=>{c!==null&&(window.clearTimeout(c),c=null)},l}const ue=335;function ui(){const{online:n,addListener:c,removeListener:l,sendMessage:i,getUniqueId:a}=r.useContext(be),[h,u]=r.useState(null),[v,t]=r.useState(null),M=r.useRef(a());return r.useEffect(()=>{const y=C=>{o&&console.log("Settings received WebSocket Message:",C),C.method==="refresh_required"&&C.response.changed==="settings"?(o&&console.log(`Settings received refresh_required: changed=${C.response.changed} and sending /api/settings request`),i({id:M.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):C.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",C.response),u(C.response.matterbridgeInformation),t(C.response.systemInformation))};return c(y,M.current),o&&console.log("Settings added WebSocket listener"),()=>{l(y),o&&console.log("Settings removed WebSocket listener")}},[c,l,i]),r.useEffect(()=>{n&&(o&&console.log("Settings received online"),i({id:M.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[n,i]),o&&console.log("Settings rendering..."),!n||!h||!v?e.jsx(Ne,{}):e.jsx(at,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(gi,{matterbridgeInfo:h,systemInfo:v}),e.jsx(mi,{matterbridgeInfo:h}),e.jsx(hi,{matterbridgeInfo:h}),e.jsx(fi,{systemInfo:v})]})})}function gi({matterbridgeInfo:n,systemInfo:c}){const{sendMessage:l,getUniqueId:i}=r.useContext(be),[a,h]=r.useState("bridge"),[u,v]=r.useState("Info"),[t,M]=r.useState(!1),[y,C]=r.useState("dark"),[S,E]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[A,U]=r.useState(localStorage.getItem("homePageMode")??"devices"),[w,p]=r.useState(localStorage.getItem("virtualMode")??"outlet"),b=r.useRef(i()),[x,H]=r.useState(!1),F=()=>H(!1),j=T=>{o&&console.log("handleSaveNetConfig called with config:",T),l({id:b.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:T})},[_,ee]=r.useState(!1),d=()=>ee(!1),s=T=>{o&&console.log("handleSaveChangePassword called with password:",T),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:T}}),Ii(T)};r.useEffect(()=>{n&&(h(n.bridgeMode==="bridge"?"bridge":"childbridge"),v(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),M(n.fileLogger),p(n.virtualMode))},[n]),r.useEffect(()=>{const T=localStorage.getItem("frontendTheme");T&&C(T)},[]);const g=T=>{o&&console.log("handleChangeBridgeMode called with value:",T.target.value),h(T.target.value),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:T.target.value}})},f=T=>{o&&console.log("handleChangeMbLoggerLevel called with value:",T.target.value),v(T.target.value),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:T.target.value}})},R=T=>{o&&console.log("handleLogOnFileMbChange called with value:",T.target.checked),M(T.target.checked),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:T.target.checked}})},de=T=>{const z=T.target.value;o&&console.log("handleChangeTheme called with value:",z),C(z),localStorage.setItem("frontendTheme",z),document.body.setAttribute("frontend-theme",z)},ye=T=>{const z=T.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",z),E(z),localStorage.setItem("homePagePlugins",z?"true":"false")},se=T=>{const z=T.target.value;o&&console.log("handleChangeHomePageMode called with value:",z),U(z),localStorage.setItem("homePageMode",z)},je=T=>{const z=T.target.value;o&&console.log("handleChangeVirtualMode called with value:",z),p(z),localStorage.setItem("virtualMode",z),l({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:z}})};return!n||!c?null:e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx(De,{children:e.jsx(Ie,{children:"Matterbridge settings"})}),e.jsx(di,{open:x,ip:c.ipv4Address,onClose:F,onSave:j}),e.jsx(pi,{open:_,onClose:d,onSave:s}),e.jsx(Fe,{style:{flexDirection:"column",padding:"0",gap:"10px"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:`${ue-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Mode:"}),e.jsxs(ur,{row:!0,name:"mode-buttons-group",value:a,onChange:g,children:[e.jsx(ze,{value:"bridge",control:e.jsx(kt,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(ze,{value:"childbridge",control:e.jsx(kt,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(et,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:u,onChange:f,children:[e.jsx(P,{value:"Debug",children:"Debug"}),e.jsx(P,{value:"Info",children:"Info"}),e.jsx(P,{value:"Notice",children:"Notice"}),e.jsx(P,{value:"Warn",children:"Warn"}),e.jsx(P,{value:"Error",children:"Error"}),e.jsx(P,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mblogger-file-label",children:"Log on file:"}),e.jsx(Ae,{checked:t,onChange:R,id:"mblogger-file",name:"logOnFileMb"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(et,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:y,onChange:de,children:[e.jsx(P,{value:"classic",children:"Classic"}),e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Ae,{checked:S,onChange:ye,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(et,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:A,onChange:se,children:[e.jsx(P,{value:"logs",children:"Logs"}),e.jsx(P,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(et,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:w,onChange:je,children:[e.jsx(P,{value:"disabled",children:"Disabled"}),e.jsx(P,{value:"outlet",children:"Outlet"}),e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"switch",children:"Switch"}),e.jsx(P,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>ee(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>H(!0),children:"Configure IP"})})]})})]})}function mi({matterbridgeInfo:n}){const{sendMessage:c,getUniqueId:l}=r.useContext(be),[i,a]=r.useState("Info"),[h,u]=r.useState(!1),[v,t]=r.useState(""),[M,y]=r.useState(""),[C,S]=r.useState(""),[E,A]=r.useState(""),[U,w]=r.useState(""),[p,b]=r.useState(""),x=r.useRef(l()),H=r.useMemo(()=>Ye(1e3),[]),F=r.useMemo(()=>Ye(1e3),[]),j=r.useMemo(()=>Ye(1e3),[]),_=r.useMemo(()=>Ye(1e3),[]),ee=r.useMemo(()=>Ye(1e3),[]),d=r.useMemo(()=>Ye(1e3),[]);r.useEffect(()=>{n&&(a(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),u(n.matterFileLogger),t(n.matterMdnsInterface||""),y(n.matterIpv4Address||""),S(n.matterIpv6Address||""),A(n.matterPort?n.matterPort.toString():""),w(n.matterDiscriminator?n.matterDiscriminator.toString():""),b(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>H.cancel(),[H]),r.useEffect(()=>()=>F.cancel(),[F]),r.useEffect(()=>()=>j.cancel(),[j]),r.useEffect(()=>()=>_.cancel(),[_]),r.useEffect(()=>()=>ee.cancel(),[ee]),r.useEffect(()=>()=>d.cancel(),[d]);const s=T=>{o&&console.log("handleChangeMjLoggerLevel called with value:",T.target.value),a(T.target.value),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:T.target.value}})},g=T=>{o&&console.log("handleLogOnFileMjChange called with value:",T.target.checked),u(T.target.checked),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:T.target.checked}})},f=T=>{o&&console.log("handleChangeMdnsInterface called with value:",T.target.value);const z=T.target.value;t(z),H(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",z),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:z}})})},R=T=>{o&&console.log("handleChangeIpv4Address called with value:",T.target.value);const z=T.target.value;y(z),F(()=>{o&&console.log("debounced sendMessage setipv4address with value:",z),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:z}})})},de=T=>{o&&console.log("handleChangeIpv6Address called with value:",T.target.value);const z=T.target.value;S(z),j(()=>{o&&console.log("debounced sendMessage setipv6address with value:",z),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:z}})})},ye=T=>{o&&console.log("handleChangeMatterPort called with value:",T.target.value);const z=T.target.value;A(z),_(()=>{o&&console.log("debounced sendMessage setmatterport with value:",z),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:z}})})},se=T=>{o&&console.log("handleChangeMatterDiscriminator called with value:",T.target.value);const z=T.target.value;w(z),ee(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",z),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:z}})})},je=T=>{o&&console.log("handleChangemMatterPasscode called with value:",T.target.value);const z=T.target.value;b(z),d(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",z),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:z}})})};return n?e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx(De,{children:e.jsx(Ie,{children:"Matter settings"})}),e.jsx(Fe,{style:{flexDirection:"column",padding:"0",gap:"10px"},children:e.jsxs(Y,{sx:{gap:"20px",margin:"0px",padding:"10px",width:`${ue-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mjlogger-level-label",children:"Logger level:"}),e.jsxs(et,{style:{height:"30px"},labelId:"mjlogger-level-label",id:"mjlogger-level",value:i,onChange:s,children:[e.jsx(P,{value:"Debug",children:"Debug"}),e.jsx(P,{value:"Info",children:"Info"}),e.jsx(P,{value:"Notice",children:"Notice"}),e.jsx(P,{value:"Warn",children:"Warn"}),e.jsx(P,{value:"Error",children:"Error"}),e.jsx(P,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px"},id:"mjlogger-file-label",children:"Log on file:"}),e.jsx(Ae,{checked:h,onChange:g,id:"mjlogger-file",name:"logOnFileMj"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(he,{value:v,onChange:f,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(he,{value:M,onChange:R,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(he,{value:C,onChange:de,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(he,{value:E,onChange:ye,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(he,{value:U,onChange:se,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(Se,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(he,{value:p,onChange:je,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function hi({matterbridgeInfo:n}){return n?e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx(De,{children:e.jsx(Ie,{children:"Matterbridge info"})}),e.jsx(Fe,{style:{flexDirection:"column",padding:"0",gap:"10px"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(Me,{value:n.matterbridgeVersion,label:"Current Version",width:ue}),e.jsx(Me,{value:n.matterbridgeLatestVersion,label:"Latest Version",width:ue}),e.jsx(Me,{value:n.rootDirectory,label:"Root Directory",width:ue}),e.jsx(Me,{value:n.homeDirectory,label:"Home Directory",width:ue}),e.jsx(Me,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory",width:ue}),e.jsx(Me,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory",width:ue}),e.jsx(Me,{value:n.globalModulesDirectory,label:"Global Module Directory",width:ue})]})})]}):null}function fi({systemInfo:n}){return n?e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx(De,{children:e.jsx(Ie,{children:"System info"})}),e.jsx(Fe,{style:{flexDirection:"column",padding:"0",gap:"10px"},children:e.jsxs(Y,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(Me,{value:n.interfaceName,label:"Interface name",width:ue}),e.jsx(Me,{value:n.macAddress,label:"MAC Address",width:ue}),e.jsx(Me,{value:n.ipv4Address,label:"IPv4 Address",width:ue}),e.jsx(Me,{value:n.ipv6Address,label:"IPv6 Address",width:ue}),e.jsx(Me,{value:n.nodeVersion,label:"Node Version",width:ue}),e.jsx(Me,{value:n.hostname,label:"Hostname",width:ue}),e.jsx(Me,{value:n.user,label:"User",width:ue})]})})]}):null}function Me({value:n,label:c,width:l}){return e.jsx(he,{focused:!0,value:n,size:"small",label:c,variant:"standard",sx:{width:l?`${l-20}px`:"400px","& .MuiInput-underline:before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},inputLabel:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}}})}const xi=r.memo(ui);function bi(){const{online:n,sendMessage:c,addListener:l,removeListener:i,getUniqueId:a}=r.useContext(be),{showSnackbarMessage:h}=r.useContext(We),[u,v]=r.useState(null),[t,M]=r.useState([]),[y,C]=r.useState([]),[S,E]=r.useState(null),[A,U]=r.useState({cpuUsage:0}),[w,p]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[b,x]=r.useState({systemUptime:"",processUptime:""}),H=r.useRef(a());return o&&console.log("Test uniqueId:",H),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const F=j=>{if(j.method==="restart_required")o&&console.log("Test received restart_required"),h("Restart required",0);else if(j.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${j.response.changed} and sending api requests`),h("Refresh required",0),c({id:H.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:H.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:H.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(j.method==="memory_update")o&&console.log("Test received memory_update",j),p(j.response);else if(j.method==="cpu_update")o&&console.log("Test received cpu_update",j),U(j.response);else if(j.method==="uptime_update")o&&console.log("Test received uptime_update",j),x(j.response);else if(j.method==="/api/settings"&&j.response)o&&console.log("Test received /api/settings:",j.response),h("Test received /api/settings",0),v(j.response);else if(j.method==="/api/plugins"&&j.response)o&&console.log(`Test received ${j.response.length} plugins:`,j.response),h("Test received /api/plugins",0),M(j.response);else if(j.method==="/api/devices"&&j.response){o&&console.log(`Test received ${j.response.length} devices:`,j.response),h("Test received /api/devices",0),C(j.response);for(const _ of j.response)o&&console.log("Test sending /api/clusters for device:",_.pluginName,_.name,_.endpoint),c({id:H.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:_.pluginName,endpoint:_.endpoint||0}})}else j.method==="/api/clusters"&&j.response&&(o&&console.log(`Test received ${j.response.clusters.length} clusters for device ${j.response.deviceName} endpoint ${j.response.id}:${j.response.number}:`,j),h(`Test received /api/clusters for ${j.response.plugin}::${j.response.deviceName}`,0),E(j.response))};return l(F,H.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(F),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,i,c,h]),r.useEffect(()=>(o&&console.log("Test useEffect online mounting"),n&&o&&console.log("Test useEffect online received online"),o&&console.log("Test useEffect online mounted"),()=>{o&&console.log("Test useEffect online unmounted")}),[n,c,h]),o&&console.log("Test rendering..."),n?e.jsx(at,{name:"Test",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",gap:"20px",height:"100vh",width:"100vw"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"})]})}):e.jsx(Ne,{})}const vi=r.memo(bi);function yi(n,c){o&&console.log("getCssVariable:",n,"defaultValue",c);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||c}function ji(n){return yo({palette:{primary:{main:n},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}function wi(){const{mobile:n,showSnackbarMessage:c,showConfirmCancelDialog:l}=r.useContext(We),{online:i,sendMessage:a,logMessage:h,addListener:u,removeListener:v,getUniqueId:t}=r.useContext(be),[M,y]=r.useState(!1),[C,S]=r.useState(!1),[E,A]=r.useState(!1),[U,w]=r.useState(!1),[p,b]=r.useState(null),x=r.useRef(t()),[H,F]=r.useState(null),[j,_]=r.useState(null),[ee,d]=r.useState(null),[s,g]=r.useState(null),[f,R]=r.useState(null),de=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},ye=()=>{window.open("https://matterbridge.io/")},se=()=>{window.open("https://matterbridge.io/README.html")},je=()=>{window.open("https://matterbridge.io/CHANGELOG.html")},T=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},z=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},N=()=>{a({id:x.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},G=()=>{a({id:x.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},$=()=>{a({id:x.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},W=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),h("Matterbridge","Installing system updates..."),a({id:x.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},I=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),h("Matterbridge","Installing software updates..."),a({id:x.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),a({id:x.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},L=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),h("Matterbridge","Downloading Shelly system log..."),c("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},K=()=>{p?.matterbridgeInformation.restartMode===""?a({id:x.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):a({id:x.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},ae=()=>{a({id:x.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},oe=()=>{a({id:x.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},ce=()=>{a({id:x.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ge=()=>{a({id:x.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},pe=V=>{F(V.currentTarget)},D=V=>{o&&console.log("Header: handleMenuClose",V),F(null),V==="download-mblog"?(h("Matterbridge","Downloading matterbridge log..."),c("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):V==="download-mjlog"?(h("Matterbridge","Downloading matter log..."),c("Downloading matter log...",5),window.location.href="./api/download-mjlog"):V==="view-mblog"?(h("Matterbridge","Loading matterbridge log..."),c("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):V==="view-mjlog"?(h("Matterbridge","Loading matter log..."),c("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):V==="view-diagnostic"?(h("Matterbridge","Loading diagnostic log..."),c("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):V==="download-diagnostic"?(h("Matterbridge","Downloading diagnostic log..."),c("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):V==="view-history"?a({id:x.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):V==="download-history"?a({id:x.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):V==="view-shellylog"?(h("Matterbridge","Loading shelly system log..."),c("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):V==="download-mbstorage"?(h("Matterbridge","Downloading matterbridge storage..."),c("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):V==="download-pluginstorage"?(h("Matterbridge","Downloading matterbridge plugins storage..."),c("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):V==="download-pluginconfig"?(h("Matterbridge","Downloading matterbridge plugins config..."),c("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):V==="download-mjstorage"?(h("Matterbridge","Downloading matter storage..."),c("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):V==="download-backup"?(h("Matterbridge","Downloading backup..."),c("Downloading backup...",10),window.location.href="./api/download-backup"):V==="update"?N():V==="updatedev"?G():V==="updatecheck"?$():V==="shelly-sys-update"?W():V==="shelly-main-update"?I():V==="shelly-create-system-log"?k():V==="shelly-download-system-log"?L():V==="softreset"?ce():V==="hardreset"?ge():V==="restart"?K():V==="shutdown"?ae():V==="reboot"?oe():V==="create-backup"?a({id:x.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):V==="unregister"?a({id:x.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):V==="reset"?a({id:x.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):V==="factoryreset"&&a({id:x.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},m=V=>{o&&console.log("Header: handleMenuCloseCancel:",V),F(null)},xe=V=>{_(V.currentTarget)},te=()=>{_(null)},fe=V=>{d(V.currentTarget)},Z=()=>{d(null)},me=V=>{g(V.currentTarget)},ve=()=>{g(null)},ot=V=>{R(V.currentTarget)},Te=()=>{R(null)},q=()=>{Si(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const V=re=>{o&&console.log("Header received WebSocket Message:",re),re.method==="/api/settings"&&re.id===x.current?(o&&console.log("Header received settings:",re.response),b(re.response),y(re.response.matterbridgeInformation.restartRequired||re.response.matterbridgeInformation.fixedRestartRequired),S(re.response.matterbridgeInformation.fixedRestartRequired),A(re.response.matterbridgeInformation.updateRequired)):re.method==="refresh_required"&&re.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${re.response.changed} and sending /api/settings request`),a({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):re.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${re.response.fixed}`),y(!0),re.response.fixed===!0&&S(!0)):re.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),y(!1)):re.method==="update_required"?(o&&console.log("Header received update_required"),re.response.devVersion===!0?w(!0):A(!0),a({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):re.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),b(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellySysUpdate:re.response.available},systemInformation:we.systemInformation}:null)):re.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),b(we=>we?{matterbridgeInformation:{...we.matterbridgeInformation,shellyMainUpdate:re.response.available},systemInformation:we.systemInformation}:null)):re.method==="/api/viewhistorypage"&&re.id===x.current&&re.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):re.method==="/api/downloadhistorypage"&&re.id===x.current&&re.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return u(V,x.current),o&&console.log(`Header added WebSocket listener id ${x.current}`),()=>{v(V),o&&console.log("Header removed WebSocket listener")}},[u,v,a,c]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),a({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:x.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,a]),o&&console.log("Header rendering... mobile %s",n),!i||!p?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",width:"100%",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:q}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:e.jsxs("nav",{children:[e.jsx(ct,{to:"/",className:"nav-link",children:"Home"}),e.jsx(ct,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(ct,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(ct,{to:"/settings",className:"nav-link",children:"Settings"})]})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[!p.matterbridgeInformation.readOnly&&e.jsx(O,{title:`Matterbridge v.${p.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",p.matterbridgeInformation.matterbridgeVersion.split("-dev-")[0]+(p.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")]})}),p.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),p.matterbridgeInformation.bridgeMode!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.bridgeMode})}):null,p.matterbridgeInformation.restartMode!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.restartMode})}):null,p.matterbridgeInformation.profile&&p.matterbridgeInformation.profile!==""&&p.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"5px"},children:[p.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:T})}):null,p.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Give a star to Matterbridge",children:e.jsx(Q,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:z,children:e.jsx(dr,{})})}):null,p.matterbridgeInformation.readOnly===!1?e.jsx(O,{title:"Sponsor Matterbridge",children:e.jsx(Q,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:de,children:e.jsx(Tt,{})})}):null,e.jsx(O,{title:"Matterbridge homepage",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ye,children:e.jsx(jo,{})})}),e.jsx(O,{title:"Matterbridge help",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:se,children:e.jsx(ar,{})})}),e.jsx(O,{title:"Matterbridge changelog",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:je,children:e.jsx(Ft,{})})}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&E&&e.jsx(O,{title:`Update matterbridge to latest version v.${p.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(Q,{style:{color:E?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:N,children:e.jsx($e,{})})}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&U&&e.jsx(O,{title:`Update matterbridge to latest dev version v.${p.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(Q,{style:{color:U?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:G,children:e.jsx($e,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellySysUpdate&&e.jsx(O,{title:"Shelly system update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:W,children:e.jsx($e,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellyMainUpdate&&e.jsx(O,{title:"Shelly software update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:I,children:e.jsx($e,{})})}),e.jsx(O,{title:"Restart matterbridge",children:e.jsx(Q,{style:{color:M||C?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:K,children:e.jsx(Ct,{})})}),p.matterbridgeInformation.restartMode===""?e.jsx(O,{title:"Shut down matterbridge",children:e.jsx(Q,{style:{color:M||C?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:ae,children:e.jsx(qe,{})})}):null,e.jsx(O,{title:"Download, backup and more",children:e.jsx(Q,{onClick:pe,children:e.jsx(wo,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Xe,{id:"command-menu",anchorEl:H,keepMounted:!0,open:!!H,onClose:()=>D(""),children:[p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>D("update"),children:[e.jsx(B,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>D("updatedev"),children:[e.jsx(B,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>D("updatecheck"),children:[e.jsx(B,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellySysUpdate&&e.jsxs(P,{onClick:()=>D("shelly-sys-update"),children:[e.jsx(B,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellyMainUpdate&&e.jsxs(P,{onClick:()=>D("shelly-main-update"),children:[e.jsx(B,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>D("restart"),children:[e.jsx(B,{children:e.jsx(Ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation.restartMode===""?e.jsxs(P,{onClick:()=>D("shutdown"),children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",D,m)},children:[e.jsx(B,{children:e.jsx(Ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(mt,{}),e.jsxs(P,{onClick:fe,children:[e.jsx(B,{children:e.jsx(Qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Xe,{id:"sub-menu-view",anchorEl:ee,keepMounted:!0,open:!!ee,onClose:Z,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{D("view-mblog"),Z()},children:[e.jsx(B,{children:e.jsx(Qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("view-mjlog"),Z()},children:[e.jsx(B,{children:e.jsx(Qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("view-diagnostic"),Z()},children:[e.jsx(B,{children:e.jsx(Qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("view-history"),Z()},children:[e.jsx(B,{children:e.jsx(Qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{D("view-shellylog"),Z()},children:[e.jsx(B,{children:e.jsx(Qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(mt,{}),e.jsxs(P,{onClick:me,children:[e.jsx(B,{children:e.jsx(Le,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Xe,{id:"sub-menu-download",anchorEl:s,keepMounted:!0,open:!!s,onClose:ve,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{D("download-mbstorage"),ve()},children:[e.jsx(B,{children:e.jsx(Le,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-pluginstorage"),ve()},children:[e.jsx(B,{children:e.jsx(Le,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-pluginconfig"),ve()},children:[e.jsx(B,{children:e.jsx(Le,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-mblog"),ve()},children:[e.jsx(B,{children:e.jsx(Le,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-mjstorage"),ve()},children:[e.jsx(B,{children:e.jsx(Le,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-mjlog"),ve()},children:[e.jsx(B,{children:e.jsx(Le,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-diagnostic"),ve()},children:[e.jsx(B,{children:e.jsx(Le,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-history"),ve()},children:[e.jsx(B,{children:e.jsx(Le,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{D("shelly-create-system-log"),ve()},children:[e.jsx(B,{children:e.jsx(Le,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{D("shelly-download-system-log"),ve()},children:[e.jsx(B,{children:e.jsx(Le,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(mt,{}),e.jsxs(P,{onClick:xe,children:[e.jsx(B,{children:e.jsx(Mt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Xe,{id:"sub-menu-backup",anchorEl:j,keepMounted:!0,open:!!j,onClose:te,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{D("create-backup"),te()},children:[e.jsx(B,{children:e.jsx(Mt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{D("download-backup"),te()},children:[e.jsx(B,{children:e.jsx(Mt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(mt,{}),e.jsxs(P,{onClick:ot,children:[e.jsx(B,{children:e.jsx(Co,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Xe,{id:"sub-menu-reset",anchorEl:f,keepMounted:!0,open:!!f,onClose:Te,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{Te(),l("Reset all devices and shutdown","Are you sure you want to unregister all devices? This will temporarily remove all devices from the controller and you may loose the controller configuration.","unregister",D,m)},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{Te(),l("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",D,m)},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>{Te(),l("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",D,m)},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{Te(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",D,m)},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{Te(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",D,m)},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(X,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const or=r.memo(wi),xr=1200,br=900;let $t,Wt;function nr(){if(typeof window<"u"){$t=Math.floor(window.visualViewport?.width??window.innerWidth),Wt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=$t<xr||Wt<br;return o&&console.log("Visual viewport (%s) width %i height %i mobile %s",window.visualViewport!==void 0,$t,Wt,n),n}return!1}function Ci({children:n}){const{mobile:c,setMobile:l}=r.useContext(We);return r.useEffect(()=>{function i(){l(nr())}return window.addEventListener("resize",i),l(nr()),()=>window.removeEventListener("resize",i)},[l]),o&&console.log("MbfScreen rendering... mobile %s",c),c?e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"visible",margin:"0px",padding:"10px",gap:"10px"},children:[e.jsx(or,{}),e.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"10px"},children:n})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:c?`${xr}px`:"calc(100vw - 40px)",height:c?`${br}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(or,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let o=!1;const Si=()=>{o=!o},ki=!1;let tt;const Ii=n=>{tt=n};function Mi({setLoggedIn:n}){const[c,l]=r.useState(""),[i,a]=r.useState(""),h={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},u={display:"flex",flexDirection:"column",maxWidth:"400px",margin:"0 auto",padding:"20px",gap:"20px",border:"1px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},v={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},t=async y=>{try{const C=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(C.ok){const{valid:S}=await C.json();S?(n(!0),y!==""&&(tt=y)):y!==""&&a("Incorrect password!")}else console.error("Failed to log in:",C.statusText)}catch(C){console.error("Failed to log in:",C)}},M=y=>{y.preventDefault(),t(c)};return t(""),e.jsx("div",{style:h,children:e.jsxs("form",{onSubmit:M,style:u,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"64px",width:"64px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:c,onChange:y=>l(y.target.value),style:v,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:i&&e.jsx("p",{style:{color:"red"},children:i})})]})})}function Di(){const[n,c]=r.useState(!1),l=localStorage.getItem("frontendTheme")||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const i=yi("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const a=ji(i);window.location.href.includes("/api/hassio_ingress/");const h=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return o&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${h}"`)),n?e.jsx(So,{theme:a,children:e.jsx(Tr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(ln,{children:e.jsx(cn,{children:e.jsx(Pr,{basename:h,children:e.jsx(Ci,{children:e.jsxs(Lr,{children:[e.jsx(Be,{path:"/",element:e.jsx(Vn,{})}),e.jsx(Be,{path:"/devices",element:e.jsx(ai,{})}),e.jsx(Be,{path:"/log",element:e.jsx(ci,{})}),e.jsx(Be,{path:"/settings",element:e.jsx(xi,{})}),e.jsx(Be,{path:"/test",element:e.jsx(vi,{})}),e.jsx(Be,{path:"*",element:e.jsx($r,{to:"/"})})]})})})})})})}):e.jsx(Mi,{setLoggedIn:c})}Wr.createRoot(document.getElementById("root")).render(e.jsx(Nr.StrictMode,{children:e.jsx(Di,{})}));