matterbridge 3.2.8-dev-20250916-da71182 → 3.2.8-dev-20250919-e967b55
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.
- package/CHANGELOG.md +12 -2
- package/dist/frontend.js +190 -256
- package/dist/frontendTypes.js +25 -0
- package/dist/matterbridge.js +18 -54
- package/dist/shelly.js +4 -5
- package/dist/update.js +0 -2
- package/dist/utils/spawn.js +4 -4
- package/frontend/build/assets/index.css +1 -0
- package/frontend/build/assets/index.js +23 -0
- package/frontend/build/assets/vendor_emotion.js +1 -0
- package/frontend/build/assets/vendor_lodash.js +1 -0
- package/frontend/build/assets/vendor_mdi.js +1 -0
- package/frontend/build/assets/vendor_mui.js +137 -0
- package/frontend/build/assets/vendor_node_modules.js +100 -0
- package/frontend/build/assets/vendor_notistack.js +5 -0
- package/frontend/build/assets/vendor_qrcode.js +9 -0
- package/frontend/build/assets/vendor_react_table.js +1 -0
- package/frontend/build/assets/vendor_rjsf.js +10 -0
- package/frontend/build/index.html +27 -1
- package/frontend/index.html +17 -0
- package/frontend/package-lock.json +5678 -17171
- package/frontend/package.json +60 -53
- package/npm-shrinkwrap.json +5 -5
- package/package.json +1 -1
- package/frontend/build/asset-manifest.json +0 -85
- package/frontend/build/favicon.ico +0 -0
- package/frontend/build/manifest.json +0 -15
- package/frontend/build/robots.txt +0 -3
- package/frontend/build/static/css/main.56c16a87.css +0 -2
- package/frontend/build/static/css/main.56c16a87.css.map +0 -1
- package/frontend/build/static/js/main.565f820c.js +0 -3
- package/frontend/build/static/js/main.565f820c.js.LICENSE.txt +0 -97
- package/frontend/build/static/js/main.565f820c.js.map +0 -1
- package/frontend/build/static/media/roboto-cyrillic-300-normal.44340549d94d10899346.woff +0 -0
- package/frontend/build/static/media/roboto-cyrillic-300-normal.89d0351bce4bc857dba6.woff2 +0 -0
- package/frontend/build/static/media/roboto-cyrillic-400-normal.86d5c52f4588f9f221d7.woff2 +0 -0
- package/frontend/build/static/media/roboto-cyrillic-400-normal.d67ac585bb6a05dbf71c.woff +0 -0
- package/frontend/build/static/media/roboto-cyrillic-500-normal.1fb2c6d685bfb888cfa3.woff2 +0 -0
- package/frontend/build/static/media/roboto-cyrillic-500-normal.36f79cc7e73a69da4438.woff +0 -0
- package/frontend/build/static/media/roboto-cyrillic-700-normal.e00802373a2c2db6b30d.woff +0 -0
- package/frontend/build/static/media/roboto-cyrillic-700-normal.fd3dfdd6cb1a9175b63d.woff2 +0 -0
- package/frontend/build/static/media/roboto-cyrillic-ext-300-normal.a80c0d0719b1acb8f731.woff +0 -0
- package/frontend/build/static/media/roboto-cyrillic-ext-300-normal.b9d87b04a9119d8d2fdf.woff2 +0 -0
- package/frontend/build/static/media/roboto-cyrillic-ext-400-normal.31476620b88eec076438.woff2 +0 -0
- package/frontend/build/static/media/roboto-cyrillic-ext-400-normal.5e3f232f89080810567d.woff +0 -0
- package/frontend/build/static/media/roboto-cyrillic-ext-500-normal.634ee2238bf30f362d52.woff2 +0 -0
- package/frontend/build/static/media/roboto-cyrillic-ext-500-normal.d6c661248da2fde17768.woff +0 -0
- package/frontend/build/static/media/roboto-cyrillic-ext-700-normal.361cdfd3a3f9c4bb09ca.woff2 +0 -0
- package/frontend/build/static/media/roboto-cyrillic-ext-700-normal.6b08bc756cd72f5af9e8.woff +0 -0
- package/frontend/build/static/media/roboto-greek-300-normal.8300b541aa89b8301a6f.woff +0 -0
- package/frontend/build/static/media/roboto-greek-300-normal.fdd1f928a606aa116a44.woff2 +0 -0
- package/frontend/build/static/media/roboto-greek-400-normal.98a717d5a38e77c0f657.woff2 +0 -0
- package/frontend/build/static/media/roboto-greek-400-normal.ecd8572d631f20ff5bd5.woff +0 -0
- package/frontend/build/static/media/roboto-greek-500-normal.4fe733bc436afc295c24.woff +0 -0
- package/frontend/build/static/media/roboto-greek-500-normal.5c8100481d4e784afbf2.woff2 +0 -0
- package/frontend/build/static/media/roboto-greek-700-normal.d23e03cf87ba44e5af6f.woff +0 -0
- package/frontend/build/static/media/roboto-greek-700-normal.d7dfd0b02cd8311e2a97.woff2 +0 -0
- package/frontend/build/static/media/roboto-greek-ext-300-normal.60729cafbded24073dfb.woff +0 -0
- package/frontend/build/static/media/roboto-greek-ext-300-normal.a88b77bb10633a8045e3.woff2 +0 -0
- package/frontend/build/static/media/roboto-greek-ext-400-normal.2d5875b032a1cca91eb2.woff2 +0 -0
- package/frontend/build/static/media/roboto-greek-ext-400-normal.a0baf7d6726d8f751a27.woff +0 -0
- package/frontend/build/static/media/roboto-greek-ext-500-normal.1964239c2800b6bd7e39.woff +0 -0
- package/frontend/build/static/media/roboto-greek-ext-500-normal.bef9c15c7164d6435aad.woff2 +0 -0
- package/frontend/build/static/media/roboto-greek-ext-700-normal.1aff9f4cd71608489b9a.woff +0 -0
- package/frontend/build/static/media/roboto-greek-ext-700-normal.eb28a447335ba6d54fcb.woff2 +0 -0
- package/frontend/build/static/media/roboto-latin-300-normal.cb14f8e80cc69ddbac34.woff +0 -0
- package/frontend/build/static/media/roboto-latin-300-normal.db56943a88e4852343ae.woff2 +0 -0
- package/frontend/build/static/media/roboto-latin-400-normal.50a0a61e29c19a2f05cb.woff +0 -0
- package/frontend/build/static/media/roboto-latin-400-normal.df1be0be92f6f19b8115.woff2 +0 -0
- package/frontend/build/static/media/roboto-latin-500-normal.599f66a60bdf974e578e.woff2 +0 -0
- package/frontend/build/static/media/roboto-latin-500-normal.c320def131b39bceabd8.woff +0 -0
- package/frontend/build/static/media/roboto-latin-700-normal.bcfbe8accc968a375a8e.woff +0 -0
- package/frontend/build/static/media/roboto-latin-700-normal.c4d6cab43bec89049809.woff2 +0 -0
- package/frontend/build/static/media/roboto-latin-ext-300-normal.6ddd1cfdbc5e74bcdab8.woff +0 -0
- package/frontend/build/static/media/roboto-latin-ext-300-normal.948c05192b1e64d931b1.woff2 +0 -0
- package/frontend/build/static/media/roboto-latin-ext-400-normal.0f86a30ca7e981fcfc99.woff2 +0 -0
- package/frontend/build/static/media/roboto-latin-ext-400-normal.2bfbba2d51a85c8702dd.woff +0 -0
- package/frontend/build/static/media/roboto-latin-ext-500-normal.8f02573e78730021ef49.woff2 +0 -0
- package/frontend/build/static/media/roboto-latin-ext-500-normal.aecaab4c4da2bf91377a.woff +0 -0
- package/frontend/build/static/media/roboto-latin-ext-700-normal.2d3c3ba6fe2d9c1026a5.woff +0 -0
- package/frontend/build/static/media/roboto-latin-ext-700-normal.8e656eff240311c6050a.woff2 +0 -0
- package/frontend/build/static/media/roboto-math-300-normal.90364ecfad5101ceb1a0.woff +0 -0
- package/frontend/build/static/media/roboto-math-300-normal.acc9c7c1d1fe3a1c7d44.woff2 +0 -0
- package/frontend/build/static/media/roboto-math-400-normal.3d3a272e5233c5fb1969.woff +0 -0
- package/frontend/build/static/media/roboto-math-400-normal.b60d9fba1e21da7497e6.woff2 +0 -0
- package/frontend/build/static/media/roboto-math-500-normal.41db483cb764343fca71.woff2 +0 -0
- package/frontend/build/static/media/roboto-math-500-normal.c3014a611cd9d8fa6252.woff +0 -0
- package/frontend/build/static/media/roboto-math-700-normal.a6fde3ddcb1629fd58b7.woff +0 -0
- package/frontend/build/static/media/roboto-math-700-normal.f6f4b54add6ab9d60a0f.woff2 +0 -0
- package/frontend/build/static/media/roboto-symbols-300-normal.52cdf8344b378f0c4580.woff +0 -0
- package/frontend/build/static/media/roboto-symbols-300-normal.616638ec44336b3da884.woff2 +0 -0
- package/frontend/build/static/media/roboto-symbols-400-normal.bb5b5d1459beb07bd3d5.woff2 +0 -0
- package/frontend/build/static/media/roboto-symbols-400-normal.f4f7e3bd8264f1a640cb.woff +0 -0
- package/frontend/build/static/media/roboto-symbols-500-normal.09b674875029289fd9a7.woff +0 -0
- package/frontend/build/static/media/roboto-symbols-500-normal.a5457b0ec984fd4cc8da.woff2 +0 -0
- package/frontend/build/static/media/roboto-symbols-700-normal.017e476ef02f62144169.woff +0 -0
- package/frontend/build/static/media/roboto-symbols-700-normal.634070e045ac99822c21.woff2 +0 -0
- package/frontend/build/static/media/roboto-vietnamese-300-normal.53f399e4522b647bafa7.woff +0 -0
- package/frontend/build/static/media/roboto-vietnamese-300-normal.6f0bf63e956c09377ef8.woff2 +0 -0
- package/frontend/build/static/media/roboto-vietnamese-400-normal.1cffe58e71a9109191a2.woff +0 -0
- package/frontend/build/static/media/roboto-vietnamese-400-normal.b1b8baa94fbcaa57d098.woff2 +0 -0
- package/frontend/build/static/media/roboto-vietnamese-500-normal.148734d63bd96c6e964f.woff2 +0 -0
- package/frontend/build/static/media/roboto-vietnamese-500-normal.72dbf2a25dd55b80b137.woff +0 -0
- package/frontend/build/static/media/roboto-vietnamese-700-normal.44a103f706f3ffe6a041.woff2 +0 -0
- package/frontend/build/static/media/roboto-vietnamese-700-normal.fa58a041a3336692af1e.woff +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{B as e,y as o,S as lt,I as Wt,U as fr,V as xr,X as Xe,Y as br,Z as vr}from"./vendor_node_modules.js";import{u as yr,S as jr}from"./vendor_notistack.js";import{D as De,a as Ne,b as Pe,B as oe,c as X,A as Cr,I as B,C as Sr,T as H,S as wr,F as Zt,H as Mr,d as er,e as Ve,R as yt,P as ze,M as kr,f as rt,g as T,L as K,h as re,i as dt,V as ct,j as Oe,k as Nt,l as Ir,m as Dr,n as pe,o as Nr,p as Pr,q as jt,r as le,s as Le,K as Ht,t as Ot,u as St,v as pt,w as it,x as ut,W as at,y as mt,z as gt,E as We,G as $t,J as Et,N as Tr,O as Wr,Q as st,U as Fe,X as Je,Y as tr,Z as Fr,_ as Lr,$ as Rr,a0 as Hr,a1 as rr,a2 as Ct,a3 as Or,a4 as $r,a5 as Er,a6 as Vr,a7 as Vt,a8 as _r,a9 as Ar,aa as Ur,ab as zr,ac as qr,ad as Br,ae as Jr,af as _t,ag as Qr,ah as Gr,ai as Kr,aj as Yr,ak as Xr,al as Zr,am as eo,an as to,ao as ro,ap as oo,aq as no,ar as io,as as ao,at as so,au as lo,av as At,aw as ot,ax as or,ay as ke,az as nr,aA as wt,aB as _e,aC as co,aD as po}from"./vendor_mui.js";import{Q as uo}from"./vendor_qrcode.js";import{I as te,m as Ut,a as mo,b as go,c as zt,d as ho,e as Ft,f as Lt,g as fo,h as xo,i as bo,j as vo,k as yo,l as jo,n as Co,o as So,p as qt,q as wo,r as Mo,s as ko,t as Io,u as Do,v as No,w as Po,x as To,y as Bt,z as Wo,A as Fo,B as Lo}from"./vendor_mdi.js";import{r as Ae}from"./vendor_react_table.js";import{F as Ro,v as Ho,e as Oo,a as $o,g as Eo,b as Vo,c as _o,d as Pt,A as Ao}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 s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const f of s)if(f.type==="childList")for(const y of f.addedNodes)y.tagName==="LINK"&&y.rel==="modulepreload"&&n(y)}).observe(document,{childList:!0,subtree:!0});function i(s){const f={};return s.integrity&&(f.integrity=s.integrity),s.referrerPolicy&&(f.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?f.credentials="include":s.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function n(s){if(s.ep)return;s.ep=!0;const f=i(s);fetch(s.href,f)}})();/**
|
|
2
|
+
* This file contains the types for WebSocket messages.
|
|
3
|
+
*
|
|
4
|
+
* @file frontendTypes.ts
|
|
5
|
+
* @author Luca Liguori
|
|
6
|
+
* @created 2025-09-17
|
|
7
|
+
* @version 1.0.0
|
|
8
|
+
* @license Apache-2.0
|
|
9
|
+
*
|
|
10
|
+
* Copyright 2025, 2026, 2027 Luca Liguori.
|
|
11
|
+
*
|
|
12
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
13
|
+
* you may not use this file except in compliance with the License.
|
|
14
|
+
* You may obtain a copy of the License at
|
|
15
|
+
*
|
|
16
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
17
|
+
*
|
|
18
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
19
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
20
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
21
|
+
* See the License for the specific language governing permissions and
|
|
22
|
+
* limitations under the License.
|
|
23
|
+
*/var Se=(r=>(r[r.Log=0]="Log",r[r.RefreshRequired=1]="RefreshRequired",r[r.RestartRequired=2]="RestartRequired",r[r.RestartNotRequired=3]="RestartNotRequired",r[r.CpuUpdate=4]="CpuUpdate",r[r.MemoryUpdate=5]="MemoryUpdate",r[r.UptimeUpdate=6]="UptimeUpdate",r[r.Snackbar=7]="Snackbar",r[r.UpdateRequired=8]="UpdateRequired",r[r.StateUpdate=9]="StateUpdate",r[r.CloseSnackbar=10]="CloseSnackbar",r[r.ShellySysUpdate=100]="ShellySysUpdate",r[r.ShellyMainUpdate=101]="ShellyMainUpdate",r))(Se||{});function Ie(r){return r.id>=0&&r.id<=101}function Be(r){return r.id>101&&r.src==="Matterbridge"&&r.dst==="Frontend"&&("success"in r||"error"in r)}function Uo({open:r,title:c,message:i,onConfirm:n,onCancel:s}){const f=t=>{a&&console.log("Confirmed"),t.preventDefault(),n()},y=t=>{a&&console.log("Canceled"),t.preventDefault(),s()};return e.jsxs(De,{open:r,children:[e.jsx(Ne,{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(Pe,{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:i})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(oe,{onClick:f,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(oe,{onClick:y,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const ht=[],nt=o.createContext(null);function zo({children:r}){const{enqueueSnackbar:c,closeSnackbar:i}=yr(),n=o.useCallback(j=>{a&&console.log(`UiProvider closeSnackbarMessage: message ${j}`);const P=ht.findIndex(O=>O.message===j);P!==-1&&(i(ht[P].key),ht.splice(P,1),a&&console.log(`UiProvider closeSnackbarMessage: message ${j} removed from persistMessages`))},[i]),s=o.useCallback((j,P,O)=>{a&&console.log(`UiProvider showSnackbarMessage: message ${j} timeout ${P}`);const z=c(j,{variant:"default",autoHideDuration:P==null||P>0?(P??5)*1e3:null,persist:P===0,content:x=>e.jsx(X,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Cr,{severity:O??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>i(x),action:e.jsx(B,{size:"small",onClick:()=>i(x),sx:{color:"#fff"},children:e.jsx(Sr,{fontSize:"small"})}),children:j},x)},x)});P===0&&(a&&console.log(`UiProvider showSnackbarMessage: message ${j} timeout ${P} - persist key ${z}`),ht.push({message:j,key:z}))},[c,i]),[f,y]=o.useState(!1),[t,l]=o.useState(""),[S,W]=o.useState(""),[v,L]=o.useState(""),E=o.useRef(null),w=o.useRef(null),$=()=>{a&&console.log(`UiProvider handle confirm action ${v}`),y(!1),E.current&&E.current(v)},p=()=>{a&&console.log(`UiProvider handle cancel action ${v}`),y(!1),w.current&&w.current(v)},U=o.useCallback((j,P,O,z,x)=>{a&&console.log(`UiProvider showConfirmCancelDialog for command ${O}`),l(j),W(P),L(O),E.current=z,w.current=x,y(!0)},[]),b=o.useMemo(()=>({showSnackbarMessage:s,closeSnackbarMessage:n,closeSnackbar:i,showConfirmCancelDialog:U}),[s,n,i,U]);return e.jsxs(nt.Provider,{value:b,children:[e.jsx(Uo,{open:f,title:t,message:S,onConfirm:$,onCancel:p}),r]})}const ir=o.createContext(null),fe=o.createContext(null);function qo({children:r}){const[c,i]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[n,s]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[f,y]=o.useState([]),[t,l]=o.useState(1e3),[S,W]=o.useState(!0),[v,L]=o.useState(!1),{showSnackbarMessage:E,closeSnackbarMessage:w,closeSnackbar:$}=o.useContext(nt),p=o.useRef([]),U=o.useRef(null),b=o.useRef(1),j=o.useRef(Math.floor(Math.random()*999e3)+1e3),P=o.useRef(null),O=o.useRef(null),z=o.useRef(null),x=o.useRef(c),R=o.useRef(n),u=o.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),h=o.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),C=100,V=60,ce=50,xe=300;o.useEffect(()=>{x.current=c},[c]),o.useEffect(()=>{R.current=n},[n]);const M=o.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),m=o.useCallback(I=>{if(U.current&&U.current.readyState===WebSocket.OPEN)try{I.id===void 0&&(I.id=j.current);const g=JSON.stringify(I);U.current.send(g),a&&console.log("WebSocket sent message:",I)}catch(g){a&&console.error(`WebSocket error sending message: ${g}`)}else a&&console.error("WebSocket message not sent, WebSocket not connected:",I)},[]),_=o.useCallback((I,g)=>{const d=`<span style="background-color: #5c0e91; color: white; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${I}</span>`;y(F=>[...F,d+' <span style="color: var(--main-log-color);">'+g+"</span>"])},[]),N=o.useCallback((I,g)=>{i(I),s(g),_("WebSocket",`Filtering by log level "${I}" and log search "${g}"`)},[_]),Z=o.useCallback(I=>{a&&console.log("WebSocket addListener:",I),p.current=[...p.current,I],a&&console.log("WebSocket addListener total listeners:",p.current.length)},[]),he=o.useCallback(I=>{a&&console.log("WebSocket removeListener:",I),p.current=p.current.filter(g=>g!==I),a&&console.log("WebSocket removeListener total listeners:",p.current.length)},[]),we=o.useCallback(()=>{u===""||u===null||u===void 0||(_("WebSocket",`Connecting to WebSocket: ${u}`),U.current=new WebSocket(u),U.current.onmessage=I=>{v||L(!0);try{const g=JSON.parse(I.data);if(g.id===void 0)return;if(g.error&&a&&console.error("WebSocket error message:",g),g.id===j.current&&g.src==="Matterbridge"&&g.dst==="Frontend"&&g.response==="pong"){a&&console.log("WebSocket pong response message:",g,"listeners:",p.current.length),O.current&&clearTimeout(O.current),p.current.forEach(F=>F(g));return}if(g.id===Se.RefreshRequired){a&&console.log("WebSocket WS_ID_REFRESH_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.RestartRequired){a&&console.log("WebSocket WS_ID_RESTART_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.RestartNotRequired){a&&console.log("WebSocket WS_ID_RESTART_NOT_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.CpuUpdate){a&&console.log("WebSocket WS_ID_CPU_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.MemoryUpdate){a&&console.log("WebSocket WS_ID_MEMORY_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.UptimeUpdate){a&&console.log("WebSocket WS_ID_UPTIME_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.Snackbar&&g.params&&g.params.message){a&&console.log("WebSocket WS_ID_SNACKBAR message:",g,"listeners:",p.current.length),E(g.params.message,g.params.timeout,g.params.severity);return}else if(g.id===Se.CloseSnackbar&&g.params&&g.params.message){a&&console.log("WebSocket WS_ID_CLOSE_SNACKBAR message:",g,"listeners:",p.current.length),w(g.params.message);return}else if(g.id===Se.ShellySysUpdate){a&&console.log("WebSocket WS_ID_SHELLY_SYS_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id===Se.ShellyMainUpdate){a&&console.log("WebSocket WS_ID_SHELLY_MAIN_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}else if(g.id!==Se.Log){a&&console.log("WebSocket message:",g,"listeners:",p.current.length),p.current.forEach(F=>F(g));return}if(!g.params||!g.params.level||!g.params.time||!g.params.name||!g.params.message||["debug","info","notice","warn","error","fatal"].includes(g.params.level)&&(x.current==="info"&&g.params.level==="debug"||x.current==="notice"&&(g.params.level==="debug"||g.params.level==="info")||x.current==="warn"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice")||x.current==="error"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice"||g.params.level==="warn")||x.current==="fatal"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice"||g.params.level==="warn"||g.params.level==="error"))||R.current!=="*"&&R.current!==""&&!g.params.message.toLowerCase().includes(R.current.toLowerCase())&&!g.params.name.toLowerCase().includes(R.current.toLowerCase())||g.params.name==="Commissioning"&&g.params.message.includes("is uncommissioned"))return;y(F=>{const ie=`<span style="color: #505050;">[${g.params?.time}]</span>`,se=be=>{switch(be?.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"lightblue"}},J=be=>{switch(be?.toLowerCase()){case"warn":return"black";default:return"white"}},me=`${`<span style="background-color: ${se(g.params?.level)}; color: ${J(g.params?.level)}; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${g.params?.level}</span>`} ${ie} <span style="color: #09516d;">[${g.params?.name}]</span> <span style="color: var(--main-log-color);">${g.params?.message}</span>`,ne=[...F,me];return ne.length>t?ne.slice(t/10):ne})}catch(g){console.error(`WebSocketUse error parsing message: ${g}`)}},U.current.onopen=()=>{a&&console.log(`WebSocket: Connected to WebSocket: ${u}`),_("WebSocket",`Connected to WebSocket: ${u}`),L(!0),$(),b.current=1,z.current=setTimeout(()=>{P.current=setInterval(()=>{m({id:j.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>{a&&console.error(`WebSocketUse: No pong response received from WebSocket: ${u}`),_("WebSocket",`No pong response received from WebSocket: ${u}`),L(!1)},1e3*ce)},1e3*V)},1e3*xe)},U.current.onclose=()=>{a&&console.error(`WebSocket: Disconnected from WebSocket ${h?"with Ingress":""}: ${u}`),_("WebSocket",`Disconnected from WebSocket: ${u}`),L(!1),$(),z.current&&clearTimeout(z.current),O.current&&clearTimeout(O.current),P.current&&clearInterval(P.current),_("WebSocket",`Reconnecting (attempt ${b.current} of ${C}) to WebSocket${h?" (Ingress)":""}: ${u}`),h?setTimeout(q,5e3):b.current===1?q():b.current<C?setTimeout(q,1e3*b.current):_("WebSocket",`Reconnect attempts exceeded limit of ${C} retries, refresh the page to reconnect to: ${u}`),b.current=b.current+1},U.current.onerror=I=>{a&&console.error(`WebSocket: WebSocket error connecting to ${u}:`,I),_("WebSocket",`WebSocket error connecting to ${u}`)})},[u]),q=o.useCallback(()=>{a&&console.log(`WebSocket attemptReconnect ${b.current}/${C} to:`,u),we()},[we]);o.useEffect(()=>(we(),()=>{U.current&&U.current.readyState===WebSocket.OPEN&&U.current.close()}),[we]);const k=o.useMemo(()=>({messages:f,maxMessages:t,autoScroll:S,setMessages:y,setLogFilters:N,setMaxMessages:l,setAutoScroll:W}),[f,y,N]),D=o.useMemo(()=>({maxMessages:t,autoScroll:S,logFilterLevel:c,logFilterSearch:n,setMessages:y,setLogFilters:N,setMaxMessages:l,setAutoScroll:W,online:v,retry:b.current,getUniqueId:M,addListener:Z,removeListener:he,sendMessage:m,logMessage:_}),[t,S,y,N,l,W,v,b.current,Z,he,m,_]);return e.jsx(ir.Provider,{value:k,children:e.jsx(fe.Provider,{value:D,children:r})})}function Bo(){const{showSnackbarMessage:r,showConfirmCancelDialog:c}=o.useContext(nt),{online:i,sendMessage:n,logMessage:s,addListener:f,removeListener:y,getUniqueId:t}=o.useContext(fe),[l,S]=o.useState(!1),[W,v]=o.useState(!1),[L,E]=o.useState(!1),[w,$]=o.useState(!1),[p,U]=o.useState(null),b=o.useRef(t()),[j,P]=o.useState(null),[O,z]=o.useState(null),[x,R]=o.useState(null),[u,h]=o.useState(null),[C,V]=o.useState(null),ce=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},xe=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},M=()=>{p?.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?window.open("https://github.com/Luligu/matterbridge/blob/dev/CHANGELOG.md","_blank"):window.open("https://github.com/Luligu/matterbridge/blob/main/CHANGELOG.md","_blank")},m=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},_=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},N=()=>{n({id:b.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},Z=()=>{n({id:b.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},he=()=>{n({id:b.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},we=()=>{a&&console.log("Header: handleShellySystemUpdateClick"),s("Matterbridge","Installing system updates..."),n({id:b.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},q=()=>{a&&console.log("Header: handleShellyMainUpdateClick"),s("Matterbridge","Installing software updates..."),n({id:b.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{a&&console.log("Header: handleShellyCreateSystemLog"),n({id:b.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},D=()=>{a&&console.log("Header: handleShellyDownloadSystemLog"),s("Matterbridge","Downloading Shelly system log..."),r("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},I=()=>{p?.matterbridgeInformation.restartMode===""?n({id:b.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):n({id:b.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},g=()=>{n({id:b.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},d=()=>{n({id:b.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},F=()=>{n({id:b.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ie=()=>{n({id:b.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},se=Q=>{P(Q.currentTarget)},J=Q=>{a&&console.log("Header: handleMenuClose",Q),P(null),Q==="download-mblog"?(s("Matterbridge","Downloading matterbridge log..."),r("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):Q==="download-mjlog"?(s("Matterbridge","Downloading matter log..."),r("Downloading matter log...",5),window.location.href="./api/download-mjlog"):Q==="view-mblog"?(s("Matterbridge","Loading matterbridge log..."),r("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):Q==="view-mjlog"?(s("Matterbridge","Loading matter log..."),r("Loading matter log...",5),window.location.href="./api/view-mjlog"):Q==="view-shellylog"?(s("Matterbridge","Loading shelly system log..."),r("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):Q==="download-mbstorage"?(s("Matterbridge","Downloading matterbridge storage..."),r("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):Q==="download-pluginstorage"?(s("Matterbridge","Downloading matterbridge plugins storage..."),r("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):Q==="download-pluginconfig"?(s("Matterbridge","Downloading matterbridge plugins config..."),r("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):Q==="download-mjstorage"?(s("Matterbridge","Downloading matter storage..."),r("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):Q==="download-backup"?(s("Matterbridge","Downloading backup..."),r("Downloading backup...",10),window.location.href="./api/download-backup"):Q==="update"?N():Q==="updatedev"?Z():Q==="updatecheck"?he():Q==="shelly-sys-update"?we():Q==="shelly-main-update"?q():Q==="shelly-create-system-log"?k():Q==="shelly-download-system-log"?D():Q==="softreset"?F():Q==="hardreset"?ie():Q==="restart"?I():Q==="shutdown"?g():Q==="reboot"?d():Q==="create-backup"?n({id:b.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="unregister"?n({id:b.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="reset"?n({id:b.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="factoryreset"&&n({id:b.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},de=Q=>{a&&console.log("Header: handleMenuCloseCancel:",Q),P(null)},me=Q=>{z(Q.currentTarget)},ne=()=>{z(null)},be=Q=>{R(Q.currentTarget)},ae=()=>{R(null)},ge=Q=>{h(Q.currentTarget)},Y=()=>{h(null)},ue=Q=>{V(Q.currentTarget)},ve=()=>{V(null)},Ge=()=>{Zn(),a&&console.log("Matterbridge logo clicked: debug is now",a)};return o.useEffect(()=>{const Q=ee=>{ee.src==="Matterbridge"&&ee.dst==="Frontend"&&(Be(ee)&&ee.method==="/api/settings"&&ee.id===b.current&&(a&&console.log("Header received settings:",ee.response),U(ee.response),S(ee.response.matterbridgeInformation.restartRequired||ee.response.matterbridgeInformation.fixedRestartRequired),v(ee.response.matterbridgeInformation.fixedRestartRequired),E(ee.response.matterbridgeInformation.updateRequired)),Ie(ee)&&ee.method==="refresh_required"&&ee.params.changed==="settings"&&(a&&console.log(`Header received refresh_required: changed=${ee.params.changed} and sending /api/settings request`),n({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),Ie(ee)&&ee.method==="restart_required"&&(a&&console.log(`Header received restart_required with fixed: ${ee.params.fixed}`),S(!0),ee.params.fixed===!0&&v(!0)),Ie(ee)&&ee.method==="restart_not_required"&&(a&&console.log("Header received restart_not_required"),S(!1)),Ie(ee)&&ee.method==="update_required"&&(a&&console.log("Header received update_required"),E(!0)),Ie(ee)&&ee.method==="update_required_dev"&&(a&&console.log("Header received update_required_dev"),$(!0)),Ie(ee)&&ee.id===Se.ShellySysUpdate&&(a&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),U(Te=>Te?{matterbridgeInformation:{...Te.matterbridgeInformation,shellySysUpdate:ee.params.available},systemInformation:Te.systemInformation}:null)),Ie(ee)&&ee.id===Se.ShellyMainUpdate&&(a&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),U(Te=>Te?{matterbridgeInformation:{...Te.matterbridgeInformation,shellyMainUpdate:ee.params.available},systemInformation:Te.systemInformation}:null)))};return f(Q),a&&console.log(`Header added WebSocket listener id ${b.current}`),()=>{y(Q),a&&console.log("Header removed WebSocket listener")}},[f,y,n,r]),o.useEffect(()=>{i&&(a&&console.log("Header sending /api/settings requests"),n({id:b.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),a&&console.log("Header rendering..."),!i||!p?null:e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Ge}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(lt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(lt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(lt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(lt,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!p.matterbridgeInformation.readOnly&&L&&e.jsx(H,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:N,children:["Update to v.",p.matterbridgeInformation.matterbridgeLatestVersion]})}),!p.matterbridgeInformation.readOnly&&w&&e.jsx(H,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:Z,children:["Update to new dev v.",p.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!p.matterbridgeInformation.readOnly&&e.jsx(H,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:M,children:["v.",p.matterbridgeInformation.matterbridgeVersion]})}),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(H,{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(H,{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(H,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:p.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:m})}):null,p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Give a star to Matterbridge",children:e.jsx(B,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:_,children:e.jsx(wr,{})})}):null,p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Sponsor Matterbridge",children:e.jsx(B,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:ce,children:e.jsx(Zt,{})})}):null,e.jsx(H,{title:"Matterbridge help",children:e.jsx(B,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:xe,children:e.jsx(Mr,{})})}),e.jsx(H,{title:"Matterbridge changelog",children:e.jsx(B,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:M,children:e.jsx(er,{})})}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsx(H,{title:"Update matterbridge to latest version",children:e.jsx(B,{style:{color:L?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:N,children:e.jsx(Ve,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellySysUpdate&&e.jsx(H,{title:"Shelly system update",children:e.jsx(B,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:we,children:e.jsx(Ve,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellyMainUpdate&&e.jsx(H,{title:"Shelly software update",children:e.jsx(B,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:q,children:e.jsx(Ve,{})})}),e.jsx(H,{title:"Restart matterbridge",children:e.jsx(B,{style:{color:l||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:I,children:e.jsx(yt,{})})}),p.matterbridgeInformation.restartMode===""?e.jsx(H,{title:"Shut down matterbridge",children:e.jsx(B,{style:{color:l||W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:g,children:e.jsx(ze,{})})}):null,e.jsx(H,{title:"Download, backup and more",children:e.jsx(B,{onClick:se,children:e.jsx(kr,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(rt,{id:"command-menu",anchorEl:j,keepMounted:!0,open:!!j,onClose:()=>J(""),children:[p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(T,{onClick:()=>J("update"),children:[e.jsx(K,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(T,{onClick:()=>J("updatedev"),children:[e.jsx(K,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(T,{onClick:()=>J("updatecheck"),children:[e.jsx(K,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellySysUpdate&&e.jsxs(T,{onClick:()=>J("shelly-sys-update"),children:[e.jsx(K,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellyMainUpdate&&e.jsxs(T,{onClick:()=>J("shelly-main-update"),children:[e.jsx(K,{children:e.jsx(Ve,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>J("restart"),children:[e.jsx(K,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation.restartMode===""?e.jsxs(T,{onClick:()=>J("shutdown"),children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{c("Reboot","Are you sure you want to reboot the Shelly board?","reboot",J,de)},children:[e.jsx(K,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(dt,{}),e.jsxs(T,{onClick:be,children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-view",anchorEl:x,keepMounted:!0,open:!!x,onClose:ae,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(T,{onClick:()=>{J("view-mblog"),ae()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("view-mjlog"),ae()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{J("view-shellylog"),ae()},children:[e.jsx(K,{children:e.jsx(ct,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(T,{onClick:ge,children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-download",anchorEl:u,keepMounted:!0,open:!!u,onClose:Y,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(T,{onClick:()=>{J("download-mbstorage"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-pluginstorage"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-pluginconfig"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-mblog"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-mjstorage"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-mjlog"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{J("shelly-create-system-log"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{J("shelly-download-system-log"),Y()},children:[e.jsx(K,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(T,{onClick:me,children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-backup",anchorEl:O,keepMounted:!0,open:!!O,onClose:ne,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(T,{onClick:()=>{J("create-backup"),ne()},children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{J("download-backup"),ne()},children:[e.jsx(K,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(dt,{}),e.jsxs(T,{onClick:ue,children:[e.jsx(K,{children:e.jsx(Ir,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(rt,{id:"sub-menu-reset",anchorEl:C,keepMounted:!0,open:!!C,onClose:ve,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(T,{onClick:()=>{ve(),c("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",J,de)},children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(T,{onClick:()=>{ve(),c("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",J,de)},children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!p.matterbridgeInformation.readOnly&&e.jsxs(T,{onClick:()=>{ve(),c("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",J,de)},children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{ve(),c("Network reset","Are you sure you want to factory reset the network parameters?","softreset",J,de)},children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&e.jsxs(T,{onClick:()=>{ve(),c("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",J,de)},children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Jo=o.memo(Bo),Qo=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(a&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(a&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Go(){const{messages:r,autoScroll:c}=o.useContext(ir),[i,n]=o.useState(!1),s=o.useRef(null),f=o.useMemo(()=>Qo(),[]),y=l=>n(!0),t=l=>n(!1);return o.useEffect(()=>{a&&console.log(`WebSocketLogs autoScroll: ${c} isHovering: ${i}`),c&&!i&&!f&&s.current?.scrollIntoView({behavior:"smooth"})},[r,i,c,f]),e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:y,onMouseLeave:t,children:[r.map((l,S)=>e.jsx("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},dangerouslySetInnerHTML:{__html:l}},S)),e.jsx("div",{ref:s})]})})}const ar=o.memo(Go);function Qe(){const{retry:r}=o.useContext(fe),c=()=>{window.location.reload()};return e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"20px",flexDirection:"column",color:"var(--main-text-color)",height:"100vh",backgroundColor:"var(--main-bg-color)"},children:e.jsx(X,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:r<100?e.jsxs(e.Fragment,{children:[e.jsx(Dr,{style:{color:"var(--primary-color)"}}),e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)"},children:["Reconnecting to Matterbridge ","(attempt "+r+")","..."]})]}):e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:["Unable to connect to Matterbridge after multiple attempts.",e.jsx("br",{}),"Please check your network connection.",e.jsx("br",{}),e.jsx(oe,{variant:"contained",color:"primary",onClick:c,style:{marginTop:"20px"},children:"Refresh the Page"})]})})})}function Ko({value:r,maxChars:c}){let i=r;if(r.length>c&&c>3){const n=c-3,s=r.substring(0,Math.ceil(n/2)),f=r.substring(r.length-Math.floor(n/2),r.length);i=`${s} … ${f}`}return r!==i?e.jsx(H,{title:r,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:i})}):e.jsx("span",{children:i})}function Yo({systemInfo:r,compact:c}){const[i,n]=o.useState(r),{sendMessage:s,addListener:f,removeListener:y}=o.useContext(fe);if(a&&console.log("SystemInfoTable:",i,"compact:",c),r&&c&&i.totalMemory&&i.freeMemory){const t=i.totalMemory,l=i.freeMemory;i.freeMemory=`${l} / ${t}`,i.totalMemory=""}if(r&&c&&i.heapTotal&&i.heapUsed){const t=i.heapTotal,l=i.heapUsed;i.heapUsed=`${l} / ${t}`,i.heapTotal=""}if(r&&c&&i.osRelease&&i.osType){const t=i.osType,l=i.osRelease;i.osType=`${t} (${l})`,i.osRelease=""}if(r&&c&&i.osArch&&i.osPlatform){const t=i.osPlatform,l=i.osArch;i.osPlatform=`${t} (${l})`,i.osArch=""}return o.useEffect(()=>{const t=l=>{l.src==="Matterbridge"&&l.dst==="Frontend"&&(l.method==="memory_update"&&l.params&&l.params.totalMemory&&l.params.freeMemory&&l.params.heapTotal&&l.params.heapUsed&&l.params.rss&&(a&&console.log("SystemInfoTable received memory_update",l),(i.totalMemory!==l.params?.totalMemory||i.freeMemory!==l.params?.freeMemory||i.heapTotal!==l.params?.heapTotal||i.heapUsed!==l.params?.heapUsed||i.rss!==l.params?.rss)&&n(S=>({...S,totalMemory:l.params?.totalMemory?l.params.totalMemory:"",freeMemory:l.params?.freeMemory?l.params.freeMemory:"",heapTotal:l.params?.heapTotal?l.params.heapTotal:"",heapUsed:l.params?.heapUsed?l.params.heapUsed:"",rss:l.params?.rss?l.params.rss:""}))),l.method==="cpu_update"&&l.params&&l.params.cpuUsage&&(a&&console.log("SystemInfoTable received cpu_update",l),i.cpuUsage!==(l.params?.cpuUsage?l.params.cpuUsage.toFixed(2)+" %":"")&&n(S=>({...S,cpuUsage:l.params?.cpuUsage?l.params.cpuUsage.toFixed(2)+" %":""}))),l.method==="uptime_update"&&l.params&&l.params.systemUptime&&l.params.processUptime&&(a&&console.log("SystemInfoTable received uptime_update",l),(i.systemUptime!==l.params?.systemUptime||i.processUptime!==l.params?.processUptime)&&n(S=>({...S,systemUptime:l.params?.systemUptime?l.params.systemUptime:"",processUptime:l.params?.processUptime?l.params.processUptime:""}))))};return a&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),f(t),a&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{a&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),y(t),a&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[f,i.cpuUsage,i.freeMemory,i.heapTotal,i.heapUsed,i.processUptime,i.rss,i.systemUptime,i.totalMemory,y,s]),i?(a&&console.log("SystemInfoTable rendering..."),e.jsxs("div",{className:"MbfWindowDiv",style:{minWidth:"302px",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"System Information"})}),e.jsx("div",{className:"MbfWindowDivTable",children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(i).filter(([t,l])=>l!==void 0&&l!=="").map(([t,l],S)=>e.jsxs("tr",{className:S%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:t}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(Ko,{value:typeof l!="string"?l.toString():l,maxChars:25})})]},t))})})})]})):null}const Xo=o.memo(Yo),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"}},Zo=r=>{if(!r)return"";const c=r.toString().replace(/[^0-9]/g,"");if(c.length<5)return c;const i=c.slice(0,4),n=c.slice(4,7),s=c.slice(7,11);return[i,n,s].filter(Boolean).join("-")};function en({id:r}){const{online:c,sendMessage:i,addListener:n,removeListener:s,getUniqueId:f}=o.useContext(fe),[y,t]=o.useState(null),[l,S]=o.useState(null),W=o.useRef(null),v=o.useRef(f()),{showConfirmCancelDialog:L}=o.useContext(nt);o.useEffect(()=>{a&&console.log(`QRDiv received storeId update "${r}"`),r&&(a&&console.log(`QRDiv sending data request for storeId "${r}"`),t(r),i({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:r,server:!0}}))},[r]),o.useEffect(()=>{const b=j=>{j.src==="Matterbridge"&&j.dst==="Frontend"&&Ie(j)&&j.id===Se.RefreshRequired&&j.params.changed==="matter"&&j.params.matter&&(a&&console.log(`QRDiv received refresh_required: changed=${j.params.changed} for storeId "${j.params.matter.id}":`,j.params.matter),y===j.params.matter.id&&(a&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${j.params.matter.id}":`,j.params.matter),W.current&&clearTimeout(W.current),j.params.matter.advertising&&j.params.matter.advertiseTime&&j.params.matter.advertiseTime+9e5<=Date.now()&&(j.params.matter.advertising=!1),S(j.params.matter),j.params.matter.advertising&&(a&&console.log(`QRDiv setting matter advertise timeout for storeId "${j.params.matter.id}":`,j.params.matter.advertiseTime+9e5-Date.now()),W.current=setTimeout(()=>{W.current&&clearTimeout(W.current),a&&console.log(`QRDiv clearing advertising state for storeId "${y}" after 15 minutes`),S(P=>P&&{...P,advertising:!1})},j.params.matter.advertiseTime+9e5-Date.now()))))};return n(b),a&&console.log("QRDiv webSocket effect mounted"),()=>{s(b),W.current&&clearTimeout(W.current),a&&console.log("QRDiv webSocket effect unmounted")}},[y]);const E=()=>{a&&console.log(`QRDiv sent matter startCommission for node "${l?.id}"`),l&&i({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:l.id,startCommission:!0}})},w=()=>{a&&console.log(`QRDiv sent matter stopCommission for node "${l?.id}"`),l&&i({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:l.id,stopCommission:!0}})},$=()=>{a&&console.log(`QRDiv sent matter advertise for node "${l?.id}"`),l&&i({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:l.id,advertise:!0}})},p=b=>{a&&console.log(`QRDiv sent matter removeFabric for node "${l?.id}" and fabricIndex ${b}`),l&&i({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:l.id,removeFabric:b}})},U=async()=>{if(!l||!l.manualPairingCode)return;const b=l.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(b);else{const j=document.createElement("textarea");j.value=b,j.style.position="fixed",j.style.opacity="0",document.body.appendChild(j),j.focus(),j.select(),document.execCommand("copy"),document.body.removeChild(j)}a&&console.log("Manual pairing code copied to clipboard")}catch(j){console.error("Failed to copy manual pairing code",j)}};return!l||!c?(a&&console.log("QRDiv rendering undefined state"),null):l.advertising&&l.qrPairingCode&&l.manualPairingCode?(a&&console.log("QRDiv rendering advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(B,{"aria-label":"send advertising",size:"small",onClick:$,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:Ut,size:"22px"})})}),e.jsx(B,{"aria-label":"stop pairing",size:"small",onClick:w,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Turn off pairing",arrow:!0,children:e.jsx(te,{path:mo,size:"22px"})})})]})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:y}),e.jsx(uo,{value:l.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs("div",{className:"MbfWindowFooter",style:{justifyContent:"space-between"},children:[e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",Zo(l.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(H,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(B,{"aria-label":"copy manual pairing code",size:"small",onClick:U,sx:Jt,children:e.jsx(te,{path:go,size:.85})})})})]})]})):l.commissioned&&l.fabricInformations&&l.sessionInformations?(a&&console.log("QRDiv rendering commissioned state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Paired fabrics"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(B,{"aria-label":"send advertising",size:"small",onClick:$,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(te,{path:Ut,size:"22px"})})}),e.jsx(B,{"aria-label":"start pairing",size:"small",onClick:E,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(H,{title:"Turn on pairing",arrow:!0,children:e.jsx(te,{path:zt,size:"22px"})})})]})]}),e.jsxs("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:[e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:y}),l.fabricInformations.map((b,j)=>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: ",b.fabricIndex]}),e.jsx(H,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(B,{"aria-label":"remove the fabric",size:"small",onClick:()=>L("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>p(b.fabricIndex),()=>{}),sx:{...Jt,padding:"2px"},children:e.jsx(te,{path:ho,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",b.rootVendorId," ",b.rootVendorName]}),b.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",b.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",l.sessionInformations?l.sessionInformations.filter(P=>P.fabric?.fabricIndex===b.fabricIndex&&P.isPeerActive===!0).length:"0"," ","subscriptions: ",l.sessionInformations?l.sessionInformations.filter(P=>P.fabric?.fabricIndex===b.fabricIndex&&P.isPeerActive===!0&&P.numberOfActiveSubscriptions>0).length:"0"]})]},j))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",l.serialNumber]})})]})):!l.commissioned&&!l.advertising?(a&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsx("div",{className:"MbfWindowHeader",style:{height:"30px"},children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"})}),e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:y}),e.jsx(oe,{onClick:E,endIcon:e.jsx(te,{path:zt,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("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",l.serialNumber]})})]})):(a&&console.log("QRDiv rendering unknown state"),null)}const tn=o.memo(en);function rn(){const{logMessage:r,sendMessage:c,getUniqueId:i}=o.useContext(fe),[n,s]=o.useState("matterbridge-"),[f,y]=o.useState(!1),[t,l]=o.useState(null),S=o.useRef(i()),W=j=>{j.preventDefault(),y(!0)},v=()=>{y(!1)},L=j=>{j.preventDefault(),y(!1);const P=j.dataTransfer.files[0];if(P){r("Plugins",`Installing package ${P.name}. Please wait...`);const O=new FormData;O.append("file",P),O.append("filename",P.name),fetch("./api/uploadpackage",{method:"POST",body:O}).then(z=>z.text()).then(z=>{r("Plugins",`Server response: ${z}`)}).catch(z=>{console.error("Error uploading plugin file:",z),r("Plugins",`Error installing package ${z}`)})}},E=j=>{const P=j.target.files&&j.target.files[0];if(P){r("Plugins",`Uploading package ${P.name}`);const O=new FormData;O.append("file",P),O.append("filename",P.name),fetch("./api/uploadpackage",{method:"POST",body:O}).then(z=>z.text()).then(z=>{r("Plugins",`Server response: ${z}`)}).catch(z=>{console.error("Error uploading plugin file:",z),r("Plugins",`Error uploading package ${z}`)})}},w=()=>{c({id:S.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n,restart:!1}})},$=()=>{document.getElementById("file-upload")?.click()},p=()=>{c({id:S.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:n}})},U=j=>{l(j.currentTarget)},b=j=>{j!==""&&s(j),l(null)};return a&&console.log("AddRemovePlugins rendering..."),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:W,onDragLeave:v,onDrop:L,children:[e.jsx(pe,{value:n,onChange:j=>{s(j.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(B,{onClick:U,children:e.jsx(Nr,{})}),e.jsxs(rt,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>b(""),children:[e.jsx(T,{onClick:()=>b("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(T,{onClick:()=>b("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(T,{onClick:()=>b("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(T,{onClick:()=>b("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(T,{onClick:()=>b("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(T,{onClick:()=>b("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(T,{onClick:()=>b("matterbridge-test"),children:"matterbridge-test"}),e.jsx(T,{onClick:()=>b("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(T,{onClick:()=>b("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(T,{onClick:()=>b("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(T,{onClick:()=>b("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(T,{onClick:()=>b("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(T,{onClick:()=>b("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(T,{onClick:()=>b("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(H,{title:"Install or update a plugin from npm",children:e.jsx(oe,{onClick:w,endIcon:e.jsx(Oe,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx(H,{title:"Upload and install a plugin from a tarball",children:e.jsx(oe,{onClick:$,endIcon:e.jsx(Pr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx(H,{title:"Add an installed plugin",children:e.jsx(oe,{onClick:p,endIcon:e.jsx(jt,{}),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:E})]})}const on=o.memo(rn);function Ze({status:r,enabledText:c="Enabled",disabledText:i=void 0,tooltipText:n=void 0,onClick:s}){if(r===void 0)return e.jsx("div",{style:{margin:"-2.5px"},children:e.jsx("div",{})});{const f=e.jsx("div",{className:r?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:r?c:i??c});return n!==void 0?e.jsx(H,{title:n,children:f}):f}}const et={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},tt={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},nn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},an={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ee={padding:"0px",margin:"0px"},sn="5px 10px 5px 10px",ft={},je={},xt={},bt={};let vt=[],Qt=[];const ln=({open:r,onClose:c,plugin:i})=>{const{sendMessage:n,addListener:s,removeListener:f,getUniqueId:y}=o.useContext(fe),t=o.useRef(y()),[l,S]=o.useState(i.configJson),[W,v]=o.useState(i.schemaJson),[L,E]=o.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[w,$]=o.useState("");let p={};o.useEffect(()=>{const k=D=>{D.src==="Matterbridge"&&D.dst==="Frontend"&&(D.id===t.current&&D.method==="/api/select/devices"&&(D.response&&(vt=D.response),D.error&&console.error("ConfigPluginDialog received /api/select/devices error:",D.error)),D.id===t.current&&D.method==="/api/select/entities"&&(D.response&&(Qt=D.response),D.error&&console.error("ConfigPluginDialog received /api/select/entities error:",D.error)))};return s(k),l!==void 0&&W!==void 0&&(Object.keys(W.properties).forEach(D=>{Object.keys(W.properties[D]).forEach(I=>{I.startsWith("ui:")&&(L[D]={},L[D][I]=W.properties[D][I],delete W.properties[D][I])})}),E(L)),i.name!==void 0&&i.configJson!==void 0&&i.schemaJson!==void 0&&(S(i.configJson),v(i.schemaJson),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:i.name}}),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:i.name}})),()=>{f(k)}},[s,l,i,f,W,n,L]);const U=({formData:k})=>{p=k},b=({formData:k})=>{S(k),i.configJson=k,i.restartRequired=!0,n({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:k.name,formData:k}}),c()};function j(k){const{id:D,label:I,onKeyChange:g,onDropPropertyClick:d,disabled:F,schema:ie,children:se,registry:J,readonly:de,required:me}=k,{templates:ne}=J,{RemoveButton:be}=ne.ButtonTemplates;if(!(Ao in ie))return e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:se});const ge=({target:Y})=>g(Y&&Y.value);return e.jsxs(X,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(pe,{id:`${D}-key`,name:`${D}-key`,required:me,disabled:F||de,defaultValue:I,onBlur:de?void 0:ge,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(X,{sx:{flex:1},children:se}),e.jsx(be,{disabled:F||de,onClick:d(I)})]})}function P(k){const{children:D,description:I,displayLabel:g,errors:d,help:F,hidden:ie,_id:se,_label:J,registry:de,uiSchema:me}=k,ne=Vo(me),be=_o("WrapIfAdditionalTemplate",de,ne);return ie?e.jsx("div",{style:{display:"none"},children:D}):e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(be,{...k,children:[g===!0&&I,D,d,F]})})}function O(k){const{description:D}=k;return D?e.jsx(le,{sx:tt,children:D}):null}function z(k){const{required:D,title:I}=k;return I?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(le,{sx:et,children:["Title ",I," ",D&&e.jsx("mark",{children:"***"})]})}):null}function x(k){const{help:D,_idSchema:I}=k;return D?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(le,{sx:nn,children:D})}):null}function R(k){const{errors:D}=k;return D?e.jsxs(X,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(le,{color:"error",sx:an,children:"Please fix the following errors:"}),e.jsx(it,{children:D.map((I,g)=>e.jsxs(Tr,{children:[e.jsx(K,{children:e.jsx(Wr,{color:"error"})}),e.jsx(re,{primary:I.stack})]},g))})]}):null}function u(k){const{errors:D}=k;return D?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:D.map((I,g)=>e.jsxs(le,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",I]},g))}):null}function h(k){const{id:D,name:I,_schema:g,_uiSchema:d,value:F,options:ie,label:se,type:J,placeholder:de,required:me,disabled:ne,readonly:be,autofocus:ae,onChange:ge,onChangeOverride:Y,onBlur:ue,onFocus:ve,_rawErrors:Ge,_hideError:Q,_registry:ee,_formContext:Te}=k,Re=({target:{value:ye}})=>ge(ye===""?ie.emptyValue:ye),He=({target:ye})=>ue(D,ye&&ye.value),Ue=({target:ye})=>ve(D,ye&&ye.value);return e.jsx(X,{sx:{padding:"0px",margin:"0px"},children:e.jsx(pe,{id:D,name:D,label:de&&de!==""?se:void 0,variant:"outlined",placeholder:de&&de!==""?de:se,required:me,disabled:ne||be,autoFocus:ae,value:F||F===0?F:"",type:J,autoComplete:J==="password"?"current-password":I,onChange:Y||Re,onBlur:He,onFocus:Ue,fullWidth:!0})})}function C(k){return console.log("ArrayFieldTitleTemplate:",k),null}function V(k){return console.log("ArrayFieldDescriptionTemplate:",k),null}function ce(k){return console.log("ArrayFieldItemTemplate:",k),null}function xe(k){const{canAdd:D,_className:I,_disabled:g,_formContext:d,_formData:F,_idSchema:ie,_items:se,onAddClick:J,_rawErrors:de,_readonly:me,_registry:ne,_required:be,schema:ae,title:ge,_uiSchema:Y}=k,[ue,ve]=o.useState(!1),[Ge,Q]=o.useState(!1),[ee,Te]=o.useState(!1),[Re,He]=o.useState(""),Ue=A=>{He(A.target.value)},ye=()=>{ve(!ue)},Ke=()=>{Q(!Ge)},Ye=()=>{Te(!ee)},Mt=A=>{ve(!1),ae.selectFrom==="serial"?ae.items.default=A.serial:ae.selectFrom==="name"&&(ae.items.default=A.name),J()},kt=A=>{Q(!1),ae.selectEntityFrom==="name"?ae.items.default=A.name:ae.selectEntityFrom==="description"&&(ae.items.default=A.description),J()},It=A=>{Te(!1),ae.selectDeviceEntityFrom==="name"?ae.items.default=A.name:ae.selectDeviceEntityFrom==="description"&&(ae.items.default=A.description),J()};return e.jsxs(X,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[ge&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ge&&e.jsx(le,{sx:et,children:ge}),D&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ae.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(B,{onClick:ye,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),ae.selectEntityFrom&&e.jsx(H,{title:"Add an entity from the list",children:e.jsx(B,{onClick:Ke,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),ae.selectDeviceEntityFrom&&e.jsx(H,{title:"Add a device entity from the list",children:e.jsx(B,{onClick:Ye,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(B,{onClick:J,size:"small",color:"primary",sx:Ee,children:e.jsx(jt,{})})})]})]}),ae.description&&e.jsx(le,{sx:tt,children:ae.description}),k.items.map(A=>e.jsxs(X,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(X,{sx:{flexGrow:1,marginRight:"10px"},children:A.children}),e.jsx(B,{disabled:!A.hasMoveUp,onClick:A.onReorderClick(A.index,A.index-1),size:"small",color:"primary",sx:Ee,children:e.jsx(Ot,{})}),e.jsx(B,{disabled:!A.hasMoveDown,onClick:A.onReorderClick(A.index,A.index+1),size:"small",color:"primary",sx:Ee,children:e.jsx(Ht,{})}),e.jsx(B,{onClick:A.onDropIndexClick(A.index),size:"small",color:"primary",sx:Ee,children:e.jsx(St,{})})]},A.index)),e.jsxs(De,{open:ue,onClose:ye,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Pe,{children:[e.jsxs(X,{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(pe,{fullWidth:!0,variant:"outlined",value:Re,onChange:Ue,placeholder:"Enter serial or name"})]}),e.jsx(it,{dense:!0,children:vt.filter(A=>A.serial.toLowerCase().includes(Re.toLowerCase())||A.name.toLowerCase().includes(Re.toLowerCase())).map((A,Me)=>e.jsxs(ut,{onClick:()=>Mt(A),sx:ft,children:[A.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:je})}),A.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:je})}),A.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:je})}),e.jsx(re,{primary:A.name,secondary:A.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Me))})]}),e.jsx(We,{children:e.jsx(oe,{onClick:ye,children:"Close"})})]}),e.jsxs(De,{open:Ge,onClose:Ke,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select an entity"}),e.jsxs(Pe,{children:[e.jsxs(X,{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(pe,{fullWidth:!0,variant:"outlined",value:Re,onChange:Ue,placeholder:"Enter name or description"})]}),e.jsx(it,{dense:!0,children:Qt.filter(A=>A.name.toLowerCase().includes(Re.toLowerCase())||A.description.toLowerCase().includes(Re.toLowerCase())).map((A,Me)=>e.jsxs(ut,{onClick:()=>kt(A),sx:ft,children:[A.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:je})}),A.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:je})}),A.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:je})}),A.icon==="component"&&e.jsx(K,{children:e.jsx($t,{style:je})}),A.icon==="matter"&&e.jsx(K,{children:e.jsx(Et,{style:je})}),e.jsx(re,{primary:A.name,secondary:A.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Me))})]}),e.jsx(We,{children:e.jsx(oe,{onClick:Ke,children:"Close"})})]}),e.jsxs(De,{open:ee,onClose:Ye,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ne,{children:["Select an entity for ",ge]}),e.jsx(Pe,{children:e.jsx(it,{dense:!0,children:vt.filter(A=>A.serial===ge||A.name===ge).map(A=>A.entities?.map((Me,Dt)=>e.jsxs(ut,{onClick:()=>It(Me),sx:ft,children:[Me.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:je})}),Me.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:je})}),Me.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:je})}),Me.icon==="component"&&e.jsx(K,{children:e.jsx($t,{style:je})}),Me.icon==="matter"&&e.jsx(K,{children:e.jsx(Et,{style:je})}),e.jsx(re,{primary:Me.name,secondary:Me.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Dt)))})}),e.jsx(We,{children:e.jsx(oe,{onClick:Ye,children:"Close"})})]})]})}function M(k){const{onAddClick:D,schema:I,properties:g,title:d,description:F}=k,[ie,se]=o.useState(!1),[J,de]=o.useState(""),me=Y=>{de(Y.target.value)},ne=()=>{se(!ie)},be=Y=>{se(!1);let ue="";I.selectFrom==="serial"?ue=Y.serial:I.selectFrom==="name"&&(ue=Y.name),$(ue),D(I)()},ae=()=>{D(I)()},ge=!I.additionalProperties;return!ge&&w!==""&&g.forEach(Y=>{if(Y.name==="newKey"&&Y.content.key==="newKey"&&Y.content.props.name==="newKey"&&Y.content.props.onKeyChange&&w!==""){const ue=w;$(""),Y.content.props.onKeyChange(ue)}}),e.jsxs(X,{sx:{margin:"0px",padding:ge?"10px":"5px 10px 0px 10px",border:ge?"none":"1px solid grey"},children:[I.title&&ge&&e.jsx(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:et,children:I.title})}),d&&!ge&&e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(le,{sx:et,children:d}),e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[I.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(B,{onClick:ne,size:"small",color:"primary",sx:Ee,children:e.jsx(pt,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(B,{onClick:ae,size:"small",color:"primary",sx:Ee,children:e.jsx(jt,{})})})]})]}),I.description&&e.jsx(X,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(le,{sx:tt,children:I.description})}),g.map(({content:Y,name:ue,hidden:ve})=>!ve&&e.jsxs(X,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(I.properties[ue].type)?"0px":sn,border:["object","array","boolean"].includes(I.properties[ue].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(I.properties[ue].type)&&e.jsx(le,{sx:et,children:ue}),e.jsx(X,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:Y})]},ue)),e.jsxs(De,{open:ie,onClose:ne,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ne,{children:"Select a device"}),e.jsxs(Pe,{children:[e.jsxs(X,{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(pe,{fullWidth:!0,variant:"outlined",value:J,onChange:me,placeholder:"Enter serial or name"})]}),e.jsx(it,{dense:!0,children:vt.filter(Y=>Y.serial.toLowerCase().includes(J.toLowerCase())||Y.name.toLowerCase().includes(J.toLowerCase())).map((Y,ue)=>e.jsxs(ut,{onClick:()=>be(Y),sx:ft,children:[Y.icon==="wifi"&&e.jsx(K,{children:e.jsx(at,{style:je})}),Y.icon==="ble"&&e.jsx(K,{children:e.jsx(mt,{style:je})}),Y.icon==="hub"&&e.jsx(K,{children:e.jsx(gt,{style:je})}),e.jsx(re,{primary:Y.name,secondary:Y.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},ue))})]}),e.jsx(We,{children:e.jsx(oe,{onClick:ne,children:"Close"})})]})]})}function m(k){const{uiSchema:D}=k,{submitText:I,norender:g}=Eo(D);return g?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(oe,{type:"submit",variant:"contained",color:"primary",children:I}),e.jsx(oe,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function _(k){const{className:D,disabled:I,onClick:g,registry:d,style:F,uiSchema:ie,...se}=k;return e.jsx(H,{title:"Remove the item",children:e.jsx(B,{disabled:I,size:"small",color:"primary",onClick:g,children:e.jsx(St,{})})})}function N(k){const{className:D,disabled:I,onClick:g,registry:d,uiSchema:F,...ie}=k;return e.jsx(H,{title:"Add an item",children:e.jsx(B,{size:"small",color:"primary",onClick:g,children:e.jsx(jt,{})})})}function Z(k){const{disabled:D,onClick:I,registry:g,style:d,uiSchema:F,...ie}=k;return e.jsx(H,{title:"Move up the item",children:e.jsx(B,{size:"small",color:"primary",onClick:I,children:e.jsx(Ot,{})})})}function he(k){const{disabled:D,onClick:I,registry:g,style:d,uiSchema:F,...ie}=k;return e.jsx(H,{title:"Move down the item",children:e.jsx(B,{size:"small",color:"primary",onClick:I,children:e.jsx(Ht,{})})})}function we(k){const{id:D,name:I,value:g,schema:d,readonly:F,onChange:ie}=k,[se,J]=o.useState(void 0),de=ne=>{J(ne&&ne!==""?ne:void 0)},me=()=>{n({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:i.name,action:I,value:se,formData:p,id:D}}),d.buttonClose===!0?c():d.buttonSave===!0&&b({formData:l})};return d.buttonText&&d.description?e.jsxs(X,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:tt,children:d.description}),e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>me(),children:d.buttonText})]}):d.buttonField&&d.description?e.jsxs(X,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(le,{sx:tt,children:d.description}),e.jsx(pe,{id:I+"-input",name:I,label:d.textLabel,placeholder:d.textPlaceholder,onChange:ne=>de(ne.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(oe,{id:I+"-button",variant:"contained",color:"primary",disabled:se===void 0,onClick:()=>me(),children:d.buttonField})]}):e.jsxs(X,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[I&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(le,{sx:et,children:I}),e.jsx(Le,{checked:g,readOnly:F,onChange:()=>ie(!g),sx:{padding:"0px",margin:"0px"}})]}),d.description&&e.jsx(le,{sx:tt,children:d.description})]})}function q({schema:k,id:D,name:I,options:g,label:d,hideLabel:F,required:ie,disabled:se,placeholder:J,readonly:de,value:me,multiple:ne,autofocus:be,onChange:ae,onBlur:ge,onFocus:Y,errorSchema:ue,rawErrors:ve=[],registry:Ge,uiSchema:Q,hideError:ee,formContext:Te,...Re}){const{enumOptions:He,enumDisabled:Ue,emptyValue:ye}=g;ne=typeof ne>"u"?!1:!!ne;const Ke=ne?[]:"",Ye=typeof me>"u"||ne&&me.length<1||!ne&&me===Ke,Mt=({target:{value:$e}})=>ae(Pt($e,He,ye)),kt=({target:$e})=>ge(D,Pt($e&&$e.value,He,ye)),It=({target:$e})=>Y(D,Pt($e&&$e.value,He,ye)),A=Oo(me,He,ne),{InputLabelProps:Me,SelectProps:Dt,autocomplete:pr,...ur}=Re,mr=!ne&&k.default===void 0;return e.jsxs(pe,{id:D,name:D,value:!Ye&&typeof A<"u"?A:Ke,required:ie,disabled:se||de,autoFocus:be,autoComplete:pr,placeholder:J,error:ve.length>0,onChange:Mt,onBlur:kt,onFocus:It,...ur,select:!0,InputLabelProps:{...Me,shrink:!Ye},SelectProps:{...Dt,multiple:ne},"aria-describedby":$o(D),children:[mr&&e.jsx(T,{value:"",children:J}),Array.isArray(He)&&He.map(({value:$e,label:gr},Rt)=>{const hr=Array.isArray(Ue)&&Ue.indexOf($e)!==-1;return e.jsx(T,{value:String(Rt),disabled:hr,children:gr},Rt)})]})}return!r||!W||!l?null:e.jsxs(De,{open:r,onClose:c,maxWidth:"800px",children:[e.jsx(Ne,{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(Pe,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Ro,{schema:W,formData:l,uiSchema:L,validator:Ho,templates:{FieldTemplate:P,BaseInputTemplate:h,TitleFieldTemplate:z,DescriptionFieldTemplate:O,FieldHelpTemplate:x,FieldErrorTemplate:u,ErrorListTemplate:R,WrapIfAdditionalTemplate:j,ArrayFieldTitleTemplate:C,ArrayFieldDescriptionTemplate:V,ArrayFieldItemTemplate:ce,ArrayFieldTemplate:xe,ObjectFieldTemplate:M,ButtonTemplates:{SubmitButton:m,RemoveButton:_,AddButton:N,MoveUpButton:Z,MoveDownButton:he}},widgets:{CheckboxWidget:we,SelectWidget:q},onChange:U,onSubmit:b})})]})};function dn({data:r,columns:c,columnVisibility:i}){const n=Wt.useMemo(()=>c.filter(S=>i[S.accessor]),[c,i]),{getTableProps:s,getTableBodyProps:f,headerGroups:y,rows:t,prepareRow:l}=Ae.useTable({columns:n,data:r},Ae.useSortBy);return e.jsxs("table",{...s(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:y.map(S=>e.jsx("tr",{...S.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:S.headers.map(W=>e.jsx("th",{...W.getHeaderProps(void 0),style:{border:"none",borderCollapse:"collapse",cursor:W.noSort?"default":"pointer"},children:W.render("Header")}))}))}),e.jsx("tbody",{...f(),style:{border:"none",borderCollapse:"collapse"},children:t.map((S,W)=>(l(S),e.jsx("tr",{className:W%2===0?"table-content-even":"table-content-odd",...S.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:S.cells.map(v=>e.jsx("td",{...v.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:v.render("Cell")}))},W)))})]})}function cn({_storeId:r,setStoreId:c}){const{online:i,sendMessage:n,addListener:s,removeListener:f,getUniqueId:y}=o.useContext(fe),{showConfirmCancelDialog:t}=o.useContext(nt),l=o.useRef(y()),[S,W]=o.useState(null),[v,L]=o.useState(null),[E,w]=o.useState([]),[$,p]=o.useState(!1),[U,b]=o.useState({name:!0,description:!0,version:!0,author:!0,type:!0,registeredDevices:!0,actions:!0,status:!0}),j=d=>{if(d===void 0||d.matter===void 0||!d.matter.fabricInformations&&!d.matter.qrPairingCode&&!d.matter.manualPairingCode)return"red";if(d.matter.commissioned===!1&&d.matter.qrPairingCode&&d.matter.manualPairingCode)return"var(--primary-color)";var F=0,ie=0;for(const se of d.matter.sessionInformations??[])se.fabric&&se.isPeerActive===!0&&F++,se.numberOfActiveSubscriptions>0&&(ie+=se.numberOfActiveSubscriptions);return d.matter.commissioned===!0&&d.matter.fabricInformations&&d.matter.sessionInformations&&(F===0||ie===0)?"var(--secondary-color)":"var(--div-text-color)"},P=[{Header:"Name",accessor:"name",Cell:({row:d})=>e.jsx(H,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>m(d.original),children:d.original.name})})},{Header:"Description",accessor:"description",Cell:({row:d})=>e.jsx(H,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>m(d.original),children:d.original.description})})},{Header:"Version",accessor:"version",Cell:({row:d})=>e.jsxs(e.Fragment,{children:[d.original.latestVersion!==void 0&&d.original.latestVersion!==d.original.version&&v&&!v.readOnly&&e.jsx(H,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>C(d.original),children:["Update to v.",d.original.latestVersion]})}),d.original.version.includes("-dev-")&&d.original.devVersion!==void 0&&d.original.devVersion!==d.original.version&&v&&!v.readOnly&&e.jsx(H,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>V(d.original),children:["Update to new dev v.",d.original.devVersion.split("-dev-")[0]]})}),e.jsx(H,{title:"Plugin version",children:d.original.version})]})},{Header:"Author",accessor:"author",Cell:({row:d})=>e.jsx(e.Fragment,{children:d.original.author?d.original.author.replace("https://github.com/",""):"Unknown"})},{Header:"Type",accessor:"type",Cell:({row:d})=>e.jsx(e.Fragment,{children:d.original.type?d.original.type.replace("Platform",""):"Unknown"})},{Header:"Devices",accessor:"registeredDevices"},{Header:"Actions",accessor:"actions",Cell:({row:d})=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[v&&v.bridgeMode==="childbridge"&&!d.original.error&&d.original.enabled&&e.jsx(H,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:j(d.original)},onClick:()=>c(d.original?.matter?.id),size:"small",children:e.jsx(tr,{})})}),v&&v.bridgeMode==="childbridge"&&!d.original.error&&d.original.enabled&&e.jsx(H,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>xe(d.original),size:"small",children:e.jsx(yt,{})})}),e.jsx(H,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{disabled:d.original.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>D(d.original),size:"small",children:e.jsx(Je,{})})}),v&&!v.readOnly&&e.jsx(H,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{R("Remove plugin","Are you sure? This will remove also all the devices and configuration in the controller.","remove",d.original)},size:"small",children:e.jsx(St,{})})}),d.original.enabled?e.jsx(H,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{R("Disable plugin","Are you sure? This will remove also all the devices and configuration in the controller.","disable",d.original)},size:"small",children:e.jsx(Fr,{})})}):e.jsx(e.Fragment,{}),d.original.enabled?e.jsx(e.Fragment,{}):e.jsx(H,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>M(d.original),size:"small",children:e.jsx(Lr,{})})}),e.jsx(H,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>N(d.original),size:"small",children:e.jsx(Rr,{})})}),e.jsx(H,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>Z(d.original),size:"small",children:e.jsx(Hr,{})})}),v&&!v.readOnly&&e.jsx(H,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>_(d.original),size:"small",children:e.jsx(Zt,{})})})]})},{Header:"Status",accessor:"status",Cell:({row:d})=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",gap:"5px"},children:d.original.error?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:d.original.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:d.original.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:d.original.loaded&&d.original.started&&d.original.configured?e.jsx(e.Fragment,{children:e.jsx(Ze,{status:d.original.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{status:d.original.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ze,{status:d.original.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ze,{status:d.original.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];o.useEffect(()=>{const d=F=>{F.src==="Matterbridge"&&F.dst==="Frontend"&&(F.method==="refresh_required"&&F.params.changed==="plugins"&&(a&&console.log(`HomePlugins received refresh_required: changed=${F.params.changed} and sending /api/plugins request`),n({id:l.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),F.method==="refresh_required"&&F.params.changed==="settings"&&(a&&console.log(`HomePlugins received refresh_required: changed=${F.params.changed} and sending /api/settings request`),n({id:l.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),F.id===l.current&&F.method==="/api/settings"&&(a&&console.log(`HomePlugins (id: ${F.id}) received settings:`,F.response),W(F.response.systemInformation),L(F.response.matterbridgeInformation)),F.id===l.current&&F.method==="/api/plugins"&&(a&&console.log(`HomePlugins (id: ${F.id}) received ${F.response.length} plugins:`,F.response),w(F.response)))};return s(d),a&&console.log("HomePlugins added WebSocket listener id:",l.current),()=>{f(d),a&&console.log("HomePlugins removed WebSocket listener")}},[s,f,n]),o.useEffect(()=>{i&&(a&&console.log("HomePlugins sending api requests"),n({id:l.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:l.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),o.useEffect(()=>{const d=localStorage.getItem("homePluginsColumnVisibility");d&&b(JSON.parse(d))},[]);const O=()=>{p(!$)},z=d=>{b(F=>{const ie={...F,[d]:!F[d]};return localStorage.setItem("homePluginsColumnVisibility",JSON.stringify(ie)),ie})},x=o.useRef(null),R=(d,F,ie,se)=>{a&&console.log(`handleActionWithConfirmCancel ${ie} ${se.name}`),x.current=se,t(d,F,ie,u,h)},u=d=>{a&&console.log(`handleConfirm action confirmed ${d} ${x.current.name}`),d==="remove"&&x.current?ce(x.current):d==="disable"&&x.current&&M(x.current),x.current=null},h=d=>{a&&console.log(`handleCancel action canceled ${d} ${x.current.name}`),x.current=null},C=d=>{a&&console.log("handleUpdatePlugin plugin:",d.name),n({id:l.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:d.name,restart:!1}})},V=d=>{a&&console.log("handleUpdateDevPlugin plugin:",d.name),n({id:l.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:d.name+"@dev",restart:!1}})},ce=d=>{a&&console.log("handleRemovePlugin plugin:",d.name),n({id:l.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})},xe=d=>{a&&console.log("handleRestartPlugin plugin:",d.name),n({id:l.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})},M=d=>{a&&console.log("handleEnableDisablePlugin plugin:",d.name,"enabled:",d.enabled),d.enabled===!0?(d.enabled=!1,n({id:l.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})):(d.enabled=!0,n({id:l.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}}))},m=d=>{a&&console.log(`handleHomepagePlugin plugin: ${d.name} homepage: ${d.homepage}`),d.homepage&&window.open(d.homepage,"_blank")},_=d=>{a&&console.log("handleSponsorPlugin plugin:",d.name,"funding:",d.funding),d.funding&&window.open(d.funding,"_blank")},N=d=>{a&&console.log("handleHelpPlugin plugin:",d.name,"help:",d.help),d.help&&window.open(d.help,"_blank")},Z=d=>{a&&console.log("handleChangelogPlugin plugin:",d.name,"changelog:",d.changelog),d.changelog&&window.open(d.changelog,"_blank")},[he,we]=o.useState({}),[q,k]=o.useState(!1),D=d=>{a&&console.log("handleConfigPlugin plugin:",d.name),n({id:l.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:d.name}}),n({id:l.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:d.name}}),we(d),I()},I=()=>{k(!0)},g=()=>{k(!1)};return a&&console.log("HomePlugins rendering..."),i?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[e.jsx(ln,{open:q,onClose:g,plugin:he}),e.jsxs(De,{open:$,onClose:O,children:[e.jsx(Ne,{children:"Configure Plugins Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:P.map(d=>e.jsx(Fe,{control:e.jsx(Le,{disabled:["description","actions","status"].includes(d.accessor),checked:U[d.accessor],onChange:()=>z(d.accessor)}),label:d.Header},d.accessor))})}),e.jsx(We,{children:e.jsx(oe,{onClick:O,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Plugins"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(B,{onClick:O,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(dn,{data:E,columns:P,columnVisibility:U})})]}):e.jsx(Qe,{})}const pn=o.memo(cn),un=r=>{if(r===void 0||!r.qrPairingCode&&!r.manualPairingCode&&!r.fabricInformations&&!r.sessionInformations)return"red";if(r.commissioned===!1&&r.qrPairingCode&&r.manualPairingCode)return"var(--primary-color)";var c=0,i=0;for(const n of r.sessionInformations??[])n.fabric&&n.isPeerActive===!0&&c++,n.numberOfActiveSubscriptions>0&&(i+=n.numberOfActiveSubscriptions);return r.commissioned===!0&&r.fabricInformations&&r.sessionInformations&&(c===0||i===0)?"var(--secondary-color)":"var(--div-text-color)"},mn=r=>`${r.pluginName}::${r.serial}`;function gn({data:r,columns:c,columnVisibility:i}){const n=o.useMemo(()=>{const v=localStorage.getItem("homeDevicesColumnsSortBy");return v?JSON.parse(v):[{id:"name",desc:!1}]},[c]),s=o.useMemo(()=>c.filter(v=>i[v.accessor]),[i,c]),{getTableProps:f,getTableBodyProps:y,headerGroups:t,rows:l,prepareRow:S,state:{sortBy:W}}=Ae.useTable({columns:s,data:r,getRowId:mn,initialState:{sortBy:n}},Ae.useSortBy);return o.useEffect(()=>{localStorage.setItem("homeDevicesColumnsSortBy",JSON.stringify(W))},[W]),e.jsxs("table",{...f(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:t.map(v=>e.jsx("tr",{...v.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:v.headers.map(L=>e.jsxs("th",{...L.getHeaderProps(L.noSort?void 0:L.getSortByToggleProps()),style:{border:"none",borderCollapse:"collapse",cursor:L.noSort?"default":"pointer"},children:[L.render("Header"),!L.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:L.isSorted?L.isSortedDesc?e.jsx(te,{path:Ft,size:"15px"}):e.jsx(te,{path:Lt,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...y(),style:{border:"none",borderCollapse:"collapse"},children:l.map((v,L)=>(S(v),e.jsx("tr",{className:L%2===0?"table-content-even":"table-content-odd",...v.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:v.cells.map(E=>e.jsx("td",{...E.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:E.render("Cell")}))})))})]})}function hn({storeId:r,setStoreId:c}){const{online:i,sendMessage:n,addListener:s,removeListener:f,getUniqueId:y}=o.useContext(fe),[t,l]=o.useState(!1),[S,W]=o.useState(!0),[v,L]=o.useState(null),[E,w]=o.useState([]),[$,p]=o.useState([]),[U,b]=o.useState([]),[j,P]=o.useState([]),[O,z]=o.useState(!1),[x,R]=o.useState({pluginName:!0,name:!0,serial:!0,reachable:!0,powerSource:!0,configUrl:!1,actions:!0}),u=o.useRef(y()),h=[{Header:"Plugin",accessor:"pluginName"},{Header:"Name",accessor:"name"},{Header:"Serial",accessor:"serial"},{Header:"Availability",accessor:"reachable",Cell:({row:M})=>M.original.reachable===!0?"Online":M.original.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",sortType:(M,m)=>{const _=M.original.reachable===!0?1:M.original.reachable===!1?0:-1,N=m.original.reachable===!0?1:m.original.reachable===!1?0:-1;return _-N}},{Header:"Power",accessor:"powerSource",Cell:({row:M})=>M.original.powerSource==="ac"||M.original.powerSource==="dc"?e.jsx(rr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):M.original.powerSource==="ok"?e.jsx(Ct,{fontSize:"small",sx:{color:"green"}}):M.original.powerSource==="warning"?e.jsx(Ct,{fontSize:"small",sx:{color:"yellow"}}):M.original.powerSource==="critical"?e.jsx(Ct,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{Header:"Url",accessor:"configUrl"},{Header:"Actions",accessor:"actions",noSort:!0,Cell:({row:M})=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[M.original.matter!==void 0?e.jsx(H,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{onClick:()=>c(r===M.original.matter.id?v.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:M.original.matter.id),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:un(M.original.matter)},children:e.jsx(tr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),M.original.configUrl?e.jsx(H,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(B,{onClick:()=>window.open(M.original.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(Je,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),M.original.selected!==void 0?e.jsx(H,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Le,{checked:M.original.selected,onChange:m=>xe(m,M.original),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],C=o.useCallback(M=>{M.selected=void 0;const m=E.find(Z=>Z.name===M.pluginName);if(!m)return console.error(`HomeDevices isSelected: plugin ${M.pluginName} not found for device ${M.deviceName} `),M.selected;const _=m.schemaJson?.properties?.whiteList?.selectFrom;let N=m.configJson?.postfix;return N===""&&(N=void 0),m.hasWhiteList===!0&&m.hasBlackList===!0&&_&&(M.selected=!0,_==="serial"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&m.configJson.whiteList.includes(N?M.serial.replace("-"+N,""):M.serial)&&(M.selected=!0),_==="serial"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&!m.configJson.whiteList.includes(N?M.serial.replace("-"+N,""):M.serial)&&(M.selected=!1),_==="serial"&&m.configJson.blackList&&m.configJson.blackList.length>0&&m.configJson.blackList.includes(N?M.serial.replace("-"+N,""):M.serial)&&(M.selected=!1),_==="name"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&m.configJson.whiteList.includes(M.name)&&(M.selected=!0),_==="name"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&!m.configJson.whiteList.includes(M.name)&&(M.selected=!1),_==="name"&&m.configJson.blackList&&m.configJson.blackList.length>0&&m.configJson.blackList.includes(M.name)&&(M.selected=!1)),M.selected},[E]);o.useEffect(()=>{const M=m=>{if(m.src==="Matterbridge"&&m.dst==="Frontend"){if(m.method==="refresh_required"&&(console.log(`HomeDevices received refresh_required: changed=${m.params.changed} and sending /api/plugins request`),n({id:u.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),m.method==="restart_required"&&(a&&console.log("HomeDevices received restart_required"),l(!0)),m.method==="restart_not_required"&&(a&&console.log("HomeDevices received restart_not_required"),l(!1)),m.method==="state_update"&&m.params.plugin&&m.params.serialNumber&&m.params.cluster.includes("BasicInformationServer")&&m.params.attribute==="reachable"&&(console.log(`HomeDevices updating device reachability for plugin ${m.params.plugin} serial ${m.params.serialNumber} value ${m.params.value}`),p(_=>_.map(N=>N.pluginName===m.params.plugin&&N.serial===m.params.serialNumber?{...N,reachable:m.params.value}:N))),m.id===u.current&&m.method==="/api/settings"&&(a&&console.log(`HomeDevices (id: ${m.id}) received settings:`,m.response),L(m.response),l(m.response.matterbridgeInformation.restartRequired||m.response.matterbridgeInformation.fixedRestartRequired)),m.id===u.current&&m.method==="/api/plugins"&&(a&&console.log(`HomeDevices (id: ${m.id}) received ${m.response?.length} plugins:`,m.response),m.response)){let _=!0;for(const N of m.response)N.enabled===!0&&(N.loaded!==!0||N.started!==!0||N.error===!0)&&(_=!1);if(!_)return;a&&console.log("HomeDevices reset plugins, devices and selectDevices"),W(!1),w(m.response),p([]),b([]),n({id:u.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),a&&console.log("HomeDevices sent /api/devices");for(const N of m.response)N.enabled===!0&&N.loaded===!0&&N.started===!0&&N.error!==!0&&(n({id:u.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:N.name}}),a&&console.log(`HomeDevices sent /api/select/devices for plugin: ${N.name}`))}if(m.id===u.current&&m.method==="/api/devices"&&(a&&console.log(`HomeDevices (id: ${m.id}) received ${m.response?.length} devices:`,m.response),m.response)){for(const _ of m.response)_.selected=C(_);p(m.response)}m.id===u.current&&m.method==="/api/select/devices"&&(a&&console.log(`HomeDevices (id: ${m.id}) received ${m.response?.length} selectDevices for plugin ${m.response&&m.response.length>0?m.response[0].pluginName:"no select devices"}:`,m.response),m.response&&m.response.length>0&&b(_=>{const N=_.filter(he=>he.pluginName!==m.response[0].pluginName),Z=m.response.map(he=>({...he,selected:C(he)}));return[...N,...Z]}))}};return s(M),a&&console.log(`HomeDevices added WebSocket listener id ${u.current}`),()=>{f(M),a&&console.log("HomeDevices removed WebSocket listener")}},[E,s,f,n,C]),o.useEffect(()=>{if($.length===0&&U.length===0)return;console.log(`HomeDevices mixing devices (${$.length}) and selectDevices (${U.length})`);const M=[];for(const m of $)M.push(m);for(const m of U)$.find(_=>_.pluginName===m.pluginName&&_.serial.includes(m.serial))||M.push(m);M.length>0&&(P(M),console.log(`HomeDevices mixed ${M.length} devices and selectDevices`))},[E,$,U,P]),o.useEffect(()=>{i&&(a&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),n({id:u.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:u.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),o.useEffect(()=>{const M=localStorage.getItem("homeDevicesColumnVisibility");if(M){const m=JSON.parse(M);m.powerSource===void 0&&(m.powerSource=!0),R(m),a&&console.log("HomeDevices loaded column visibility from localStorage")}},[]);const V=M=>{R(m=>{const _={...m,[M]:!m[M]};return localStorage.setItem("homeDevicesColumnVisibility",JSON.stringify(_)),a&&console.log("HomeDevices saved column visibility to localStorage",JSON.stringify(_),_),_})},ce=()=>{z(!O)},xe=(M,m)=>{console.log(`handleCheckboxChange: checkbox changed to ${M.target.checked} for device ${m.name} serial ${m.serial}`),P(_=>{const N=_.findIndex(he=>he.pluginName===m.pluginName&&he.serial===m.serial);if(N<0)return console.error(`handleCheckboxChange: device not found ${m.name} serial ${m.serial} id ${m.id}`),_;const Z=[..._];return Z[N]={...Z[N],selected:M.target.checked},Z}),M.target.checked?n({id:u.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:m.pluginName,serial:m.serial,name:m.name}}):n({id:u.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:m.pluginName,serial:m.serial,name:m.name}})};return a&&console.log("HomeDevices rendering..."),i?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs(De,{open:O,onClose:ce,children:[e.jsx(Ne,{children:"Configure Devices Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:h.map(M=>e.jsx(Fe,{control:e.jsx(Le,{disabled:["name","actions"].includes(M.accessor),checked:x[M.accessor],onChange:()=>V(M.accessor)}),label:M.Header},M.accessor))})}),e.jsx(We,{children:e.jsx(oe,{onClick:ce,children:"Close"})})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(B,{onClick:ce,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0px",padding:"0px",gap:"0",overflow:"auto"},children:e.jsx(gn,{data:j,columns:h,columnVisibility:x})}),e.jsxs("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"space-between"},children:[S&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Waiting for the plugins to fully load..."}),!S&&e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:["Registered devices: ",$.length.toString(),"/",j.length.toString()]}),t&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Restart required"})]})]}):e.jsx(Qe,{})}const fn=o.memo(hn);function xn(){const[r,c]=o.useState(null),[i,n]=o.useState(null),[s,f]=o.useState([]),[y]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,l]=o.useState(localStorage.getItem("homePageMode")??"devices"),[S,W]=o.useState(""),[v,L]=o.useState(!1),[E,w]=o.useState(!1),[$,p]=o.useState(null),{addListener:U,removeListener:b,online:j,sendMessage:P,logFilterLevel:O,logFilterSearch:z,autoScroll:x,getUniqueId:R}=o.useContext(fe),u=o.useRef(R());return o.useEffect(()=>{const h=C=>{C.src==="Matterbridge"&&C.dst==="Frontend"&&(Ie(C)&&C.method==="refresh_required"&&C.params.changed==="settings"&&(a&&console.log(`Home received refresh_required: changed=${C.params.changed} and sending /api/settings request`),P({id:u.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),Be(C)&&C.method==="/api/settings"&&C.id===u.current&&(a&&console.log("Home received settings:",C.response),c(C.response.systemInformation),n(C.response.matterbridgeInformation),C.response.matterbridgeInformation.bridgeMode==="bridge"&&($||p("Matterbridge")),C.response.matterbridgeInformation.bridgeMode==="childbridge"&&s.length>0&&$===null&&!$&&s.length>0&&s[0].matter?.id&&p(s[0].matter.id),C.response.matterbridgeInformation.matterbridgeVersion&&W(`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),w(!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),L(!0)),C.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),l("devices")))),Be(C)&&C.method==="/api/plugins"&&C.id===u.current&&(a&&console.log(`Home received plugins (${i?.bridgeMode}):`,C.response),f(C.response),i?.bridgeMode==="childbridge"&&C.response.length>0&&!$&&C.response.length>0&&C.response[0].matter?.id&&p(C.response[0].matter.id)))};return U(h),a&&console.log(`Home added WebSocket listener id ${u.current}`),()=>{b(h),a&&console.log("Home removed WebSocket listener")}},[U,b,P,i,s,$]),o.useEffect(()=>{j&&(a&&console.log("Home received online"),P({id:u.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),P({id:u.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[j,P]),a&&console.log("Home rendering..."),!j||!r||!i?e.jsx(Qe,{}):e.jsxs("div",{className:"MbfPageDiv",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(tn,{id:$}),e.jsx(Xo,{systemInfo:r,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[E&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},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(oe,{onClick:()=>window.location.reload(),endIcon:e.jsx(Or,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),v&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},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(oe,{onClick:()=>window.open(S,"_blank"),endIcon:e.jsx(er,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(oe,{onClick:()=>window.location.reload(),endIcon:e.jsx($r,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),y&&!i.readOnly&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Install plugins"})}),e.jsx(on,{})]}),y&&e.jsx(pn,{storeId:$,setStoreId:p}),t==="devices"&&e.jsx(fn,{storeId:$,setStoreId:p}),t==="logs"&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"1 1 auto",width:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:"Logs"}),e.jsx("div",{className:"MbfWindowHeaderText",style:{display:"flex",justifyContent:"space-between"},children:e.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',O,'" and search "',z,'" Scroll: ',x?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(ar,{})})]})]})]})}const bn=o.memo(xn),Gt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},vn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},yn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Kt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},jn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Cn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},Sn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},wn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},Mn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Tt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},kn=[256,257,268,269],In=[266,267],Dn=[259,260,261,271,272],Nn=[256,257,268,269,266,267,259,260,261];function G({icon:r,iconColor:c,cluster:i,value:n,unit:s,prefix:f}){return a&&console.log(`Render cluster "${i.clusterName}.${i.attributeName}" value(${typeof n}-${isNaN(n)}) "${n}" unit "${s}"`),f=f??!1,e.jsxs(X,{sx:Gt,children:[r&&Wt.cloneElement(r,{key:`${i.clusterId}-${i.attributeId}-icon`,sx:{...vn,color:c??"var(--primary-color)"}}),e.jsxs(X,{sx:{...Gt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&f===!0&&e.jsx(le,{sx:Kt,children:s},`${i.clusterId}-${i.attributeId}-unit`),e.jsx(le,{sx:yn,children:n==null||typeof n=="number"&&isNaN(n)||n==="NaN"?"---":n},`${i.clusterId}-${i.attributeId}-value`),s&&f===!1&&e.jsx(le,{sx:Kt,children:s},`${i.clusterId}-${i.attributeId}-unit`)]},`${i.clusterId}-${i.attributeId}-valueunitbox`)]},`${i.clusterId}-${i.attributeId}-box`)}function Pn({device:r,endpoint:c,id:i,deviceType:n,clusters:s}){const f=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let y="";return a&&console.log(`Device "${r.name}" endpoint "${c}" id "${i}" deviceType "0x${n.toString(16).padStart(4,"0")}" clusters (${s?.length}):`,s),n===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>y=`${t.attributeLocalValue} mV`),Nn.includes(n)&&s.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>y=`Level ${t.attributeValue}`),n===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>y=`Position ${t.attributeValue/100}%`),n===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>y=`Heat ${t.attributeValue/100}°C `),n===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>y=y+`Cool ${t.attributeValue/100}°C`),n===118&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>y=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>y=`${t.attributeLocalValue/1e3} V, `),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>y=y+`${t.attributeLocalValue/1e3} A, `),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>y=y+`${t.attributeLocalValue/1e3} W`),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:[n===19&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:t.attributeLocalValue===!0?e.jsx(at,{}):e.jsx(Er,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),n===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(G,{icon:e.jsx(Ct,{}),cluster:t,value:t.attributeValue/2,unit:"%"})),n===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(G,{icon:e.jsx(rr,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),n===1293&&s.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),kn.includes(n)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(Vr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),In.includes(n)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Dn.includes(n)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===115&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===124&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===117&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===123&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:"Oven"})),n===112&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(_r,{}),cluster:t,value:"Fridge"})),n===113&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===121&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(Vt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===122&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(G,{icon:e.jsx(te,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===120&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),n===119&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(G,{icon:e.jsx(te,{path:qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===116&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(G,{icon:e.jsx(te,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),n===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(G,{icon:e.jsx(Ar,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===10&&s.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(G,{icon:t.attributeValue==="1"?e.jsx(Ur,{}):e.jsx(zr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),n===43&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(qr,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===15&&s.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(G,{icon:e.jsx(te,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),n===39&&s.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(G,{icon:e.jsx(Br,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),n===771&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===45&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(G,{icon:e.jsx(_t,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===114&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(G,{icon:e.jsx(_t,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===67&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Qr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),n===65&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Gr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),n===68&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),n===1292&&s.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),n===1295&&s.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),n===777&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),n===23&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),n===24&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(G,{icon:e.jsx(te,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),n===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Bt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),n===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Bt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),n===66&&s.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(G,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),n===44&&s.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:f[t.attributeLocalValue??0]})),n===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),n===775&&s.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(te,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===774&&s.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),n===773&&s.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(eo,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),n===21&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(G,{icon:t.attributeValue==="true"?e.jsx(to,{}):e.jsx(ro,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),n===263&&s.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(G,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(oo,{}):e.jsx(no,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),n===262&&s.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(io,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeValue/1e4)),unit:"lx"})),n===1296&&s.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(G,{icon:e.jsx(ao,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(X,{sx:jn,children:e.jsx(le,{sx:Cn,children:y})}),e.jsx(X,{sx:Sn,children:e.jsx(le,{sx:wn,children:r.name})}),e.jsxs(X,{sx:Mn,children:[a&&e.jsx(le,{sx:Tt,children:c}),e.jsx(le,{sx:Tt,children:i}),a&&e.jsxs(le,{sx:Tt,children:["0x",n.toString(16).padStart(4,"0")]})]})]})}function Tn({filter:r}){const{online:c,sendMessage:i,addListener:n,removeListener:s,getUniqueId:f}=o.useContext(fe),[y,t]=o.useState(!1),[l,S]=o.useState({}),[W,v]=o.useState([]),[L,E]=o.useState([]),[w,$]=o.useState({}),[p,U]=o.useState({}),[b,j]=o.useState({}),[P,O]=o.useState(L),z=o.useRef(f()),x=()=>{t(!y)};return o.useEffect(()=>{const R=u=>{if(u.src==="Matterbridge"&&u.dst==="Frontend"){if(u.method==="refresh_required"&&(a&&console.log(`DevicesIcons received refresh_required: changed=${u.params.changed} and sending api requests`),i({id:z.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:z.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:z.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),u.method==="/api/settings"&&u.response&&(a&&console.log("DevicesIcons received settings:",u.response),S(u.response)),u.method==="/api/plugins"&&u.response&&(a&&console.log("DevicesIcons received plugins:",u.response),v(u.response)),u.method==="/api/devices"&&u.response){a&&console.log(`DevicesIcons received ${u.response.length} devices:`,u.response),E(u.response);for(let h of u.response)a&&console.log("DevicesIcons sending /api/clusters"),i({id:z.current,sender:"Icons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:h.pluginName,endpoint:h.endpoint}})}if(u.method==="/api/clusters"&&u.response){if(console.log(`DevicesIcons received for device "${u.response.deviceName}" serial "${u.response.serialNumber}" deviceType ${u.response.deviceTypes.join(" ")} clusters (${u.response.length}):`,u.response),u.response.length===0)return;const h=u.response.serialNumber;w[h]=[],p[h]=u.response.deviceTypes,b[h]=[];for(let C of u.response.clusters)w[h].find(V=>V.endpoint===C.endpoint)||w[h].push({endpoint:C.endpoint,id:C.id,deviceTypes:C.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(C.clusterName)&&b[h].push(C);$({...w}),U({...p}),j({...b}),a&&console.log(`DevicesIcons endpoints for "${h}":`,w[h]),a&&console.log(`DevicesIcons deviceTypes for "${h}":`,p[h]),a&&console.log(`DevicesIcons clusters for "${h}":`,b[h])}}};return n(R),a&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{s(R),a&&console.log("DevicesIcons useEffect webSocket unmounted")}},[n,s,i]),o.useEffect(()=>(a&&console.log("DevicesIcons useEffect online mounting"),c&&(a&&console.log("DevicesIcons useEffect online sending api requests"),i({id:z.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:z.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:z.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),a&&console.log("DevicesIcons useEffect online mounted"),()=>{a&&console.log("DevicesIcons useEffect online unmounted")}),[c,i]),o.useEffect(()=>{if(r===""){O(L);return}const R=L.filter(u=>u.name.toLowerCase().includes(r)||u.serial.toLowerCase().includes(r));O(R)},[L,r]),a&&console.log("DevicesIcons rendering..."),e.jsxs(e.Fragment,{children:[e.jsxs(De,{open:y,onClose:x,PaperProps:{style:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--primary-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}},children:[e.jsx(Ne,{children:"Configure accessories"}),e.jsx(Pe,{}),e.jsx(We,{children:e.jsx(oe,{onClick:x,children:"Close"})})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:P.map(R=>w[R.serial]&&w[R.serial].map(u=>u.deviceTypes.map(h=>e.jsx(Pn,{device:R,endpoint:u.endpoint,id:u.id,deviceType:h,clusters:b[R.serial].filter(C=>C.endpoint===u.endpoint)}))))})]})}const sr=[{Header:"Plugin name",accessor:"pluginName"},{Header:"Device type",accessor:"type"},{Header:"Endpoint",accessor:"endpoint"},{Header:"Name",accessor:"name"},{Header:"Serial number",accessor:"serial"},{Header:"Unique ID",accessor:"uniqueId"},{Header:"Url",accessor:"configUrl"},{Header:"Config",accessor:"configButton",noSort:!0,Cell:({row:r})=>r.original.configUrl?e.jsx(B,{onClick:()=>window.open(r.original.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(Je,{fontSize:"small"})}):null},{Header:"Cluster",accessor:"cluster"}],lr=[{Header:"Endpoint",accessor:"endpoint"},{Header:"Id",accessor:"id"},{Header:"Device Types",accessor:"deviceTypes",Cell:({value:r})=>Array.isArray(r)?r.map(c=>`0x${c.toString(16).padStart(4,"0")}`).join(", "):r},{Header:"Cluster Name",accessor:"clusterName"},{Header:"Cluster ID",accessor:"clusterId"},{Header:"Attribute Name",accessor:"attributeName"},{Header:"Attribute ID",accessor:"attributeId"},{Header:"Attribute Value",accessor:"attributeValue",Cell:({value:r})=>e.jsx(H,{title:r,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:r})})}],Wn=r=>`${r.pluginName}::${r.uniqueId}`,Fn=r=>`${r.endpoint}::${r.clusterName}::${r.attributeName}`;function Ln({data:r,columnVisibility:c,setPlugin:i,setEndpoint:n,setDeviceName:s}){const[f,y]=o.useState(null),t=o.useMemo(()=>sr.filter(w=>c[w.accessor]),[c]),{getTableProps:l,getTableBodyProps:S,headerGroups:W,rows:v,prepareRow:L}=Ae.useTable({columns:t,data:r,getRowId:Wn},Ae.useSortBy),E=w=>{if(w.id===f){y(null),i(null),n(null),s(null),a&&console.log("Device unclicked:",w.id,"selectedDeviceIndex:",f);return}y(w.id),i(w.original.pluginName),n(w.original.endpoint),s(w.original.name),a&&console.log("Device clicked:",w.id,"selectedDeviceIndex:",f,"pluginName:",w.original.pluginName,"endpoint:",w.original.endpoint)};return e.jsxs("table",{...l(),style:{margin:"-1px",border:"1px solid var(--table-border-color)"},children:[e.jsx("thead",{children:W.map(w=>e.jsx("tr",{...w.getHeaderGroupProps(),children:w.headers.map($=>e.jsxs("th",{...$.getHeaderProps($.noSort?void 0:$.getSortByToggleProps()),children:[$.render("Header"),!$.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:$.isSorted?$.isSortedDesc?e.jsx(te,{path:Ft,size:"15px"}):e.jsx(te,{path:Lt,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...S(),children:v.map((w,$)=>(L(w),e.jsx("tr",{className:$%2===0?"table-content-even":"table-content-odd",...w.getRowProps(),onClick:()=>E(w),style:{backgroundColor:f===w.id?"var(--table-selected-bg-color)":"",cursor:"pointer"},children:w.cells.map(p=>e.jsx("td",{...p.getCellProps(),children:p.render("Cell")}))})))})]})}function Rn({data:r,columnVisibility:c}){const i=o.useMemo(()=>lr.filter(l=>c[l.accessor]),[c]),{getTableProps:n,getTableBodyProps:s,headerGroups:f,rows:y,prepareRow:t}=Ae.useTable({columns:i,data:r,getRowId:Fn},Ae.useSortBy);return e.jsxs("table",{...n(),style:{margin:"-1px"},children:[e.jsx("thead",{children:f.map(l=>e.jsx("tr",{...l.getHeaderGroupProps(),children:l.headers.map(S=>e.jsx("th",{...S.getHeaderProps(),children:S.render("Header")}))}))}),e.jsx("tbody",{...s(),children:y.map((l,S)=>(t(l),e.jsx("tr",{className:S%2===0?"table-content-even":"table-content-odd",...l.getRowProps(),children:l.cells.map(W=>e.jsx("td",{...W.getCellProps(),children:W.render("Cell")}))})))})]})}function Hn(){const{online:r,sendMessage:c,addListener:i,removeListener:n,getUniqueId:s}=o.useContext(fe),[f,y]=o.useState([]),[t,l]=o.useState([]),[S,W]=o.useState(null),[v,L]=o.useState(null),[E,w]=o.useState(null),[$,p]=o.useState(0),[U,b]=o.useState(!1),[j,P]=o.useState({pluginName:!0,type:!0,endpoint:!0,name:!0,serial:!0,uniqueId:!1,configUrl:!1,configButton:!0,cluster:!0}),[O,z]=o.useState(!1),[x,R]=o.useState({endpoint:!0,id:!0,deviceTypes:!0,clusterName:!0,clusterId:!0,attributeName:!0,attributeId:!0,attributeValue:!0}),[u,h]=o.useState(""),[C,V]=o.useState(f),[ce,xe]=o.useState("icon"),M=o.useRef(s());o.useEffect(()=>{const q=k=>{if(a&&console.log("Devices received WebSocket Message:",k),k.src==="Matterbridge"&&k.dst==="Frontend"&&(k.method==="refresh_required"&&k.params.changed==="devices"&&(a&&console.log(`Devices received refresh_required: changed=${k.params.changed} and sending /api/devices request`),c({id:M.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),k.method==="/api/devices"&&(a&&console.log(`Devices received ${k.response.length} devices:`,k.response),y(k.response)),k.method==="/api/clusters")){console.log(`Devices received ${k.response.length} clusters:`,k.response),l(k.response.clusters);const D={};for(const I of k.response.clusters)a&&console.log("Cluster:",I.endpoint),D[I.endpoint]?D[I.endpoint]++:D[I.endpoint]=1;p(Object.keys(D).length)}};return i(q),a&&console.log("Devices added WebSocket listener"),()=>{n(q),a&&console.log("Devices removed WebSocket listener")}},[i,n,c]),o.useEffect(()=>{r&&(a&&console.log("Devices sending api requests"),c({id:M.current,sender:"Devices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:M.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:M.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,c]),o.useEffect(()=>{S&&v&&(a&&console.log("Devices sending /api/clusters"),c({id:M.current,sender:"Devices",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:S,endpoint:v}}))},[S,v,c]);const m=()=>{b(!U)},_=q=>{P(k=>{const D={...k,[q]:!k[q]};return localStorage.setItem("devicesColumnVisibility",JSON.stringify(D)),D})};o.useEffect(()=>{const q=localStorage.getItem("devicesColumnVisibility");q&&P(JSON.parse(q))},[]);const N=()=>{z(!O)},Z=q=>{R(k=>{const D={...k,[q]:!k[q]};return localStorage.setItem("clustersColumnVisibility",JSON.stringify(D)),D})};o.useEffect(()=>{const q=localStorage.getItem("clustersColumnVisibility");q&&R(JSON.parse(q))},[]);const he=q=>{h(q.target.value.toLowerCase()),localStorage.setItem("devicesFilter",q.target.value.toLowerCase())},we=q=>{xe(q),localStorage.setItem("devicesViewMode",q)};return o.useEffect(()=>{if(u===""){V(f);return}const q=f.filter(k=>k.name.toLowerCase().includes(u)||k.serial.toLowerCase().includes(u));V(q)},[f,u]),o.useEffect(()=>{const q=localStorage.getItem("devicesFilter");q&&h(q)},[]),o.useEffect(()=>{const q=localStorage.getItem("devicesViewMode");q&&xe(q)},[]),a&&console.log("Devices rendering..."),r?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(X,{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(pe,{variant:"outlined",value:u,onChange:he,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(X,{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(B,{onClick:()=>we("table"),"aria-label":"Table View",disabled:ce==="table",children:e.jsx(H,{title:"Table View",children:e.jsx(so,{style:{color:ce==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(B,{onClick:()=>we("icon"),"aria-label":"Icon View",disabled:ce==="icon",children:e.jsx(H,{title:"Icon View (beta)",children:e.jsx(lo,{style:{color:ce==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),e.jsxs(De,{open:U,onClose:m,children:[e.jsx(Ne,{children:"Configure Devices Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:sr.map(q=>e.jsx(Fe,{control:e.jsx(Le,{disabled:["pluginName","name","configButton"].includes(q.accessor),checked:j[q.accessor],onChange:()=>_(q.accessor)}),label:q.Header},q.accessor))})}),e.jsx(We,{children:e.jsx(oe,{onClick:m,children:"Close"})})]}),ce==="table"&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${S&&v?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Registered devices"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(B,{onClick:m,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Ln,{data:C,columnVisibility:j,setPlugin:W,setEndpoint:L,setDeviceName:w})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total devices: ",C.length.toString()]})})]}),e.jsxs(De,{open:O,onClose:N,children:[e.jsx(Ne,{children:"Configure Clusters Columns"}),e.jsx(Pe,{children:e.jsx(st,{children:lr.map(q=>e.jsx(Fe,{control:e.jsx(Le,{disabled:["clusterName","attributeName","attributeValue"].includes(q.accessor),checked:x[q.accessor],onChange:()=>Z(q.accessor)}),label:q.Header},q.accessor))})}),e.jsx(We,{children:e.jsx(oe,{onClick:N,children:"Close"})})]}),ce==="table"&&S&&v&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",height:"50%",maxHeight:"50%",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsxs("div",{className:"MbfWindowHeaderText",style:{display:"flex",flexDirection:"row",justifyContent:"space-between"},children:[e.jsxs("p",{style:{margin:"0px",padding:"0px"},children:['Clusters for device "',E,'" on endpoint ',v]}),e.jsx(B,{onClick:N,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Je,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})]})}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Rn,{data:t,columnVisibility:x})}),e.jsx("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"flex-start"},children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",textAlign:"left"},children:["Total child endpoints: ",$-1]})})]}),ce==="icon"&&e.jsx(Tn,{filter:u,devices:C})]}):e.jsx(Qe,{})}const On=o.memo(Hn);function $n(){const[r,c]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[i,n]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[s,f]=o.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:y,setLogFilters:t,online:l,setAutoScroll:S}=o.useContext(fe),W=w=>{c(w.target.value),t(w.target.value,i),localStorage.setItem("logFilterLevel",w.target.value),a&&console.log("handleChangeLevel called with value:",w.target.value)},v=w=>{n(w.target.value),t(r,w.target.value),localStorage.setItem("logFilterSearch",w.target.value),a&&console.log("handleChangeSearch called with value:",w.target.value)},L=w=>{f(w.target.checked),S(w.target.checked),localStorage.setItem("logAutoScroll",w.target.value?"true":"false"),a&&console.log("handleAutoScrollChange called with value:",w.target.checked)},E=()=>{a&&console.log("handleClearLogsClick called"),y([])};return a&&console.log("Logs rendering..."),l?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(At,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(ot,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:r,onChange:W,children:[e.jsx(T,{value:"debug",children:"Debug"}),e.jsx(T,{value:"info",children:"Info"}),e.jsx(T,{value:"notice",children:"Notice"}),e.jsx(T,{value:"warn",children:"Warn"}),e.jsx(T,{value:"error",children:"Error"}),e.jsx(T,{value:"fatal",children:"Fatal"})]}),e.jsx(At,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(pe,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:i,onChange:v,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Fe,{control:e.jsx(Le,{checked:s,onChange:L}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(H,{title:"Clear the logs",children:e.jsx(oe,{onClick:E,endIcon:e.jsx(St,{}),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(ar,{})})]}):e.jsx(Qe,{})}const En=({open:r,ip:c,onClose:i,onSave:n})=>{const s=c?c.split(".").slice(0,3).join(".")+".1":"",[f,y]=o.useState("dhcp"),[t,l]=o.useState({ip:c??"",subnet:"255.255.255.0",gateway:s,dns:s}),S=L=>E=>{l({...t,[L]:E.target.value})},W=()=>{i()},v=()=>{const L=f==="static"?{type:f,...t}:{type:f};n(L),i()};return e.jsxs(De,{open:r,onClose:(L,E)=>{E==="backdropClick"||E==="escapeKeyDown"||i()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Ne,{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(Pe,{dividers:!0,children:[e.jsxs(or,{component:"fieldset",fullWidth:!0,children:[e.jsx(ke,{component:"legend",children:"Select IP Configuration"}),e.jsxs(nr,{row:!0,value:f,onChange:L=>y(L.target.value),children:[e.jsx(Fe,{value:"dhcp",control:e.jsx(wt,{}),label:"DHCP"}),e.jsx(Fe,{value:"static",control:e.jsx(wt,{}),label:"Static"})]})]}),f==="static"&&e.jsxs(_e,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(_e,{size:6,children:e.jsx(pe,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:S("ip")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:S("subnet")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:S("gateway")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:S("dns")})})]})]}),e.jsxs(We,{children:[e.jsx(oe,{onClick:W,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:v,children:"Save"})]})]})},Vn=({open:r,onClose:c,onSave:i})=>{const[n,s]=o.useState(""),[f,y]=o.useState(""),t=E=>{s(E.target.value)},l=E=>{y(E.target.value)},S=n.length>0&&n===f,W=()=>{c()},v=()=>{S&&(i(n),c())},L=()=>{i(""),c()};return e.jsxs(De,{open:r,onClose:(E,w)=>{w==="backdropClick"||w==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Ne,{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(Pe,{dividers:!0,children:e.jsx(or,{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(pe,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:n,onChange:t})}),e.jsx(_e,{size:12,children:e.jsx(pe,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:f,onChange:l,error:f!==""&&n!==f,helperText:f!==""&&n!==f?"Passwords do not match":""})})]})})}),e.jsxs(We,{children:[e.jsx(oe,{onClick:W,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:v,disabled:!S,children:"Change"}),e.jsx(oe,{variant:"contained",onClick:L,children:"Reset"})]})]})};function _n(){const{online:r,addListener:c,removeListener:i,sendMessage:n,getUniqueId:s}=o.useContext(fe),[f,y]=o.useState(null),[t,l]=o.useState(null),S=o.useRef(s());return o.useEffect(()=>{const W=v=>{v.src==="Matterbridge"&&v.dst==="Frontend"&&(v.method==="refresh_required"&&v.params.changed==="settings"&&(a&&console.log(`Settings received refresh_required: changed=${v.params.changed} and sending /api/settings request`),n({id:S.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),v.method==="/api/settings"&&(a&&console.log("Settings received /api/settings:",v.response),y(v.response.matterbridgeInformation),l(v.response.systemInformation)))};return c(W),a&&console.log("Settings added WebSocket listener"),()=>{i(W),a&&console.log("Settings removed WebSocket listener")}},[c,i,n]),o.useEffect(()=>{r&&(a&&console.log("Settings received online"),n({id:S.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[r,n]),f?(a&&console.log("Settings rendering..."),r?e.jsx("div",{className:"MbfPageDiv",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(An,{matterbridgeInfo:f,systemInfo:t}),e.jsx(Un,{matterbridgeInfo:f}),e.jsx(zn,{matterbridgeInfo:f})]})}):e.jsx(Qe,{})):null}function An({matterbridgeInfo:r,systemInfo:c}){const{sendMessage:i,getUniqueId:n}=o.useContext(fe),[s,f]=o.useState("bridge"),[y,t]=o.useState("Info"),[l,S]=o.useState(!1),[W,v]=o.useState("dark"),[L,E]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[w,$]=o.useState(localStorage.getItem("homePageMode")??"logs"),[p,U]=o.useState(localStorage.getItem("virtualMode")??"outlet"),b=o.useRef(n()),[j,P]=o.useState(!1),O=()=>P(!1),z=N=>{a&&console.log("handleSaveNetConfig called with config:",N),i({id:b.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:N})},[x,R]=o.useState(!1),u=()=>R(!1),h=N=>{a&&console.log("handleSaveChangePassword called with password:",N),i({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:N}})};o.useEffect(()=>{r.bridgeMode!==void 0&&(f(r.bridgeMode==="bridge"?"bridge":"childbridge"),t(r.loggerLevel.charAt(0).toUpperCase()+r.loggerLevel.slice(1)),S(r.fileLogger),U(r.virtualMode))},[r]),o.useEffect(()=>{const N=localStorage.getItem("frontendTheme");N&&v(N)},[]);const C=N=>{a&&console.log("handleChangeBridgeMode called with value:",N.target.value),f(N.target.value),i({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:N.target.value}})},V=N=>{a&&console.log("handleChangeMbLoggerLevel called with value:",N.target.value),t(N.target.value),i({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:N.target.value}})},ce=N=>{a&&console.log("handleLogOnFileMbChange called with value:",N.target.checked),S(N.target.checked),i({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:N.target.checked}})},xe=N=>{const Z=N.target.value;a&&console.log("handleChangeTheme called with value:",Z),v(Z),localStorage.setItem("frontendTheme",Z),document.body.setAttribute("frontend-theme",Z)},M=N=>{const Z=N.target.checked;a&&console.log("handleChangeHomePagePlugins called with value:",Z),E(Z),localStorage.setItem("homePagePlugins",Z?"true":"false")},m=N=>{const Z=N.target.value;a&&console.log("handleChangeHomePageMode called with value:",Z),$(Z),localStorage.setItem("homePageMode",Z)},_=N=>{const Z=N.target.value;a&&console.log("handleChangeVirtualMode called with value:",Z),U(Z),localStorage.setItem("virtualMode",Z),i({id:b.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:Z}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(En,{open:j,ip:c.ipv4Address,onClose:O,onSave:z}),e.jsx(Vn,{open:x,onClose:u,onSave:h}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(nr,{row:!0,name:"mode-buttons-group",value:s,onChange:C,children:[e.jsx(Fe,{value:"bridge",control:e.jsx(wt,{}),label:"Bridge",disabled:r.readOnly===!0}),e.jsx(Fe,{value:"childbridge",control:e.jsx(wt,{}),label:"Childbridge",disabled:r.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:y,onChange:V,children:[e.jsx(T,{value:"Debug",children:"Debug"}),e.jsx(T,{value:"Info",children:"Info"}),e.jsx(T,{value:"Notice",children:"Notice"}),e.jsx(T,{value:"Warn",children:"Warn"}),e.jsx(T,{value:"Error",children:"Error"}),e.jsx(T,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Le,{checked:l,onChange:ce,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:W,onChange:xe,children:[e.jsx(T,{value:"classic",children:"Classic"}),e.jsx(T,{value:"light",children:"Light"}),e.jsx(T,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Le,{checked:L,onChange:M,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:w,onChange:m,children:[e.jsx(T,{value:"logs",children:"Logs"}),e.jsx(T,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:p,onChange:_,children:[e.jsx(T,{value:"disabled",children:"Disabled"}),e.jsx(T,{value:"outlet",children:"Outlet"}),e.jsx(T,{value:"light",children:"Light"}),e.jsx(T,{value:"switch",children:"Switch"}),e.jsx(T,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>R(!0),children:"Change password"})}),r.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>P(!0),children:"Configure IP"})})]})})]})}function Un({matterbridgeInfo:r}){const{sendMessage:c,getUniqueId:i}=o.useContext(fe),[n,s]=o.useState("Info"),[f,y]=o.useState(!1),[t,l]=o.useState(""),[S,W]=o.useState(""),[v,L]=o.useState(""),[E,w]=o.useState(),[$,p]=o.useState(),[U,b]=o.useState(),j=o.useRef(i());o.useEffect(()=>{r.bridgeMode!==void 0&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][r.matterLoggerLevel]),y(r.matterFileLogger),l(r.matterMdnsInterface),W(r.matterIpv4Address),L(r.matterIpv6Address),w(r.matterPort),p(r.matterDiscriminator),b(r.matterPasscode))},[r]);const P=V=>{a&&console.log("handleChangeMjLoggerLevel called with value:",V.target.value),s(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:V.target.value}})},O=V=>{a&&console.log("handleLogOnFileMjChange called with value:",V.target.checked),y(V.target.checked),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:V.target.checked}})},z=V=>{a&&console.log("handleChangeMdnsInterface called with value:",V.target.value),l(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:V.target.value}})},x=V=>{a&&console.log("handleChangeIpv4Address called with value:",V.target.value),W(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:V.target.value}})},R=V=>{a&&console.log("handleChangeIpv6Address called with value:",V.target.value),L(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:V.target.value}})},u=V=>{a&&console.log("handleChangeMatterPort called with value:",V.target.value),w(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:V.target.value}})},h=V=>{a&&console.log("handleChangeMatterDiscriminator called with value:",V.target.value),p(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:V.target.value}})},C=V=>{a&&console.log("handleChangemMatterPasscode called with value:",V.target.value),b(V.target.value),c({id:j.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:V.target.value}})};return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},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(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(ot,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:n,onChange:P,children:[e.jsx(T,{value:"Debug",children:"Debug"}),e.jsx(T,{value:"Info",children:"Info"}),e.jsx(T,{value:"Notice",children:"Notice"}),e.jsx(T,{value:"Warn",children:"Warn"}),e.jsx(T,{value:"Error",children:"Error"}),e.jsx(T,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Le,{checked:f,onChange:O,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Mdns interface:"}),e.jsx(pe,{value:t,onChange:z,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Ipv4 address:"}),e.jsx(pe,{value:S,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Ipv6 address:"}),e.jsx(pe,{value:v,onChange:R,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Commissioning port:"}),e.jsx(pe,{value:E,onChange:u,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Commissioning discriminator:"}),e.jsx(pe,{value:$,onChange:h,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},children:"Commissioning passcode:"}),e.jsx(pe,{value:U,onChange:C,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:r.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]})}function zn({matterbridgeInfo:r}){return e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},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(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[" ",e.jsx(qe,{value:r.matterbridgeVersion,label:"Current Version"}),e.jsx(qe,{value:r.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(qe,{value:r.homeDirectory,label:"Home Directory"}),e.jsx(qe,{value:r.rootDirectory,label:"Root Directory"}),e.jsx(qe,{value:r.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(qe,{value:r.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(qe,{value:r.globalModulesDirectory,label:"Global Module Directory"})]})})]})}function qe({value:r,label:c}){return e.jsx(pe,{focused:!0,value:r,size:"small",label:c,variant:"standard",sx:{width:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}function qn(r,c,i){const n=r?.[i],s=c?.[i];return n==null&&s==null?0:n==null?-1:s==null?1:typeof n=="boolean"&&typeof s=="boolean"?n===s?0:n?1:-1:typeof n=="number"&&typeof s=="number"?n-s:String(n).localeCompare(String(s))}function Bn({name:r,columns:c,rows:i,getRowKey:n,footerLeft:s,footerRight:f}){const y=o.useRef(new WeakMap),t=o.useRef(1),l=x=>{if(typeof n=="string"&&x&&x[n]!=null)return x[n];if(typeof n=="function"){const h=n(x);if(h!=null)return h}const R=c?.[0]?.id;if(R&&x&&x[R]!=null)return x[R];console.warn(`MbfTable(${r}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let u=y.current.get(x);return u||(u=`rk_${t.current++}`,y.current.set(x,u)),u},[S,W]=o.useState(localStorage.getItem(`${r}_table_order_by`)||null),[v,L]=o.useState(localStorage.getItem(`${r}_table_order`)||null),[E,w]=o.useState(!1),[$,p]=o.useState(()=>{try{const x=localStorage.getItem(`${r}_column_visibility`);if(x)return JSON.parse(x)}catch{}return{}}),U=o.useMemo(()=>{const x={};for(const R of c)R.hidden||(x[R.id]=R.required?!0:$[R.id]!==!1);return x},[c,$]),b=o.useMemo(()=>{if(!S||!v)return i;const x=c.find(u=>u.id===S);if(!x||x.nosort)return i;const R=i.map((u,h)=>({el:u,index:h}));return R.sort((u,h)=>{const C=qn(u.el,h.el,S);return C!==0?v==="asc"?C:-C:u.index-h.index}),R.map(u=>u.el)},[i,S,v,c]),j=x=>{if(S!==x||!S){W(x),L("asc"),localStorage.setItem(`${r}_table_order_by`,x),localStorage.setItem(`${r}_table_order`,"asc");return}if(v==="asc"){L("desc"),localStorage.setItem(`${r}_table_order`,"desc");return}W(null),L(null),localStorage.removeItem(`${r}_table_order_by`),localStorage.removeItem(`${r}_table_order`)},P=()=>{w(!E)},O=x=>{p(R=>{const u=c.find(V=>V.id===x);if(u&&u.required)return R;const h=U[x]!==!1,C={...R};h?C[x]=!1:delete C[x];try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(C))}catch{}return C})},z=()=>{const x={};p(x);try{localStorage.setItem(`${r}_column_visibility`,JSON.stringify(x))}catch{}};return console.log(`Rendering table ${r}${S&&v?` ordered by ${S}:${v}`:""}`),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(De,{open:E,onClose:(x,R)=>{R==="backdropClick"||R==="escapeKeyDown"||P()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Ne,{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 ${r} columns`})]})}),e.jsx(Pe,{children:e.jsx(st,{children:c.filter(x=>!x.hidden).map(x=>e.jsx(Fe,{control:e.jsx(Le,{disabled:!!x.required,checked:x.required?!0:U[x.id]!==!1,onChange:()=>O(x.id)}),label:x.label},x.id))})}),e.jsxs(We,{children:[e.jsx(oe,{onClick:z,children:"Reset"}),e.jsx(oe,{variant:"contained",onClick:x=>{if(x?.currentTarget&&typeof x.currentTarget.blur=="function")try{x.currentTarget.blur()}catch{}const R=document.activeElement;if(R&&R instanceof HTMLElement&&typeof R.blur=="function")try{R.blur()}catch{}P()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:r}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(B,{onClick:x=>{if(x?.currentTarget?.blur)try{x.currentTarget.blur()}catch{}P()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:`Configure ${r} columns`,children:e.jsx(te,{path:Lo,size:"20px",style:{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":`${r} 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:c.map(x=>{if(x.hidden||!x.required&&U[x.id]===!1)return null;const R=!x.nosort,u=R&&S===x.id&&!!v;return e.jsxs("th",{onClick:R?()=>j(x.id):void 0,style:{margin:"0",padding:"4px 8px",position:"sticky",top:0,minWidth:x.minWidth,maxWidth:x.maxWidth,textAlign:x.align||"left",cursor:R?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:x.maxWidth?"nowrap":void 0,overflow:x.maxWidth?"hidden":void 0,textOverflow:x.maxWidth?"ellipsis":void 0},"aria-sort":R?u?v==="asc"?"ascending":"descending":"none":void 0,children:[x.label,u&&e.jsxs("span",{style:{marginLeft:6},children:[v==="asc"&&e.jsx(te,{path:Lt,size:"15px"}),v==="desc"&&e.jsx(te,{path:Ft,size:"15px"})]})]},x.id)})})}),e.jsx("tbody",{children:b.map((x,R)=>{const u=l(x);return e.jsx("tr",{className:R%2===0?"table-content-even":"table-content-odd",style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse"},children:c.map(h=>{if(h.hidden||!h.required&&U[h.id]===!1)return null;const C=x[h.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:h.align||"left",padding:"4px 8px",margin:"0",maxWidth:h.maxWidth,whiteSpace:h.maxWidth?"nowrap":void 0,overflow:h.maxWidth?"hidden":void 0,textOverflow:h.maxWidth?"ellipsis":void 0},children:typeof h.render=="function"?h.render(C,u,x,h):typeof C=="boolean"?e.jsx(Le,{checked:C,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):h.format&&typeof C=="number"?h.format(C):C!=null?String(C):null},h.id)})},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:s}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:f})]})]})}const Jn=o.memo(Bn);function Qn(){const{online:r,sendMessage:c,addListener:i,removeListener:n,getUniqueId:s}=o.useContext(fe),{showSnackbarMessage:f,closeSnackbarMessage:y}=o.useContext(nt),[t,l]=o.useState(null),[S,W]=o.useState(null),[v,L]=o.useState(null),[E,w]=o.useState(null),[$,p]=o.useState({cpuUsage:0}),[U,b]=o.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[j,P]=o.useState({systemUptime:"",processUptime:""}),O=o.useRef(-1),[z,x]=o.useState(()=>dr);O.current||(O.current=s(),console.log("Test uniqueId:",O)),o.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const u=h=>{if(h.src==="Matterbridge"&&h.dst==="Frontend"){if(Ie(h)&&h.method==="restart_required"&&(console.log("Test received restart_required"),f("Restart required",0)),Ie(h)&&h.method==="refresh_required"&&(console.log(`Test received refresh_required: changed=${h.params.changed} and sending api requests`),f("Refresh required",0),c({id:O.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:O.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:O.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),Ie(h)&&h.method==="memory_update"&&(console.log("Test received memory_update",h),b(h.params)),Ie(h)&&h.method==="cpu_update"&&(console.log("Test received cpu_update",h),p(h.params)),Ie(h)&&h.method==="uptime_update"&&(console.log("Test received uptime_update",h),P(h.params)),Be(h)&&h.method==="/api/settings"&&h.response&&(console.log("Test received /api/settings:",h.response),f("Test received /api/settings"),l(h.response)),Be(h)&&h.method==="/api/plugins"&&h.response&&(console.log(`Test received ${h.response.length} plugins:`,h.response),f("Test received /api/plugins"),W(h.response)),Be(h)&&h.method==="/api/devices"&&h.response){console.log(`Test received ${h.response.length} devices:`,h.response),f("Test received /api/devices"),L(h.response);for(const C of h.response)console.log("Test sending /api/clusters for device:",C.pluginName,C.name,C.endpoint),c({id:O.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:C.pluginName,endpoint:C.endpoint}})}Be(h)&&h.method==="/api/clusters"&&h.response&&(console.log(`Test received ${h.response.clusters.length} clusters for device ${h.response.deviceName} endpoint ${h.response.endpoint}:`,h),f("Test received /api/clusters"),w(h.response))}};return i(u),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),n(u),console.log("Test useEffect WebSocketMessage unmounted")}},[i,n,c,f]),o.useEffect(()=>(console.log("Test useEffect online mounting"),r&&(console.log("Test useEffect online received online"),c({id:O.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:O.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:O.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[r,c,f]);const R=o.useCallback(u=>String(u.code),[]);return console.log("Test rendering..."),r?e.jsx("div",{className:"MbfPageDiv",style:{display:"flex",flexDirection:"row",justifyContent:"center",alignItems:"center",height:"100vh"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"20px",width:"100%"},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("div",{style:{margin:"0",padding:"0",gap:"0",width:"1200px",maxWidth:"1200px",height:"600px",maxHeight:"600px",overflow:"hidden",backgroundColor:"var(--div-bg-color)",border:"1px solid #0004ffff"},children:e.jsx(Jn,{name:"Test",columns:Kn,rows:z,getRowKey:R,footerLeft:"Left Footer",footerRight:"Right Footer"})}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>{console.log("Test button clicked"),f("Test button clicked"),y("Refresh required"),y("Restart required"),y("Test permanent message removal")},children:"Test"}),e.jsx(oe,{variant:"outlined",onClick:()=>{x(u=>{const h=u.findIndex(xe=>xe.code==="F123");if(h===-1)return u;const C=u[h],V={...C,population:(C.population||0)+1},ce=u.slice();return ce[h]=V,ce})},children:"Update F123"})]})]})}):e.jsx(Qe,{})}const Gn=o.memo(Qn),Kn=[{id:"name",label:"Name",minWidth:50,maxWidth:100,required:!0},{id:"code",label:"ISO Code",minWidth:100,render:(r,c,i,n)=>e.jsx("span",{style:{display:"inline-block",padding:"2px 6px",borderRadius:"8px",backgroundColor:"var(--chip-bg, #e6f4ff)",color:"var(--chip-fg, #0550ae)",fontFamily:'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace',fontSize:"0.85em"},children:String(r)})},{id:"isIsland",label:"Island",minWidth:80,align:"center"},{id:"population",label:"Population",minWidth:170,align:"right",format:r=>r.toLocaleString("en-US")},{id:"size",label:"Size (km²)",minWidth:170,align:"right",format:r=>r.toLocaleString("en-US")},{id:"density",label:"Density",minWidth:170,align:"right",nosort:!0,format:r=>r.toFixed(2)},{id:"virtual",label:"Virtual",align:"right",required:!0,nosort:!0,render:(r,c,i,n)=>i.isIsland?"🏝️":"🏞️"}];function Ce(r,c,i,n,s){const f=i/n;return{name:r,code:c,population:i,size:n,density:f,isIsland:s}}const dr=[Ce("India","IN",1324171354,3287263,!1),Ce("China","CN",1403500365,9596961,!1),Ce("Italy","IT",60483973,301340,!1),Ce("United States","US",327167434,9833520,!1),Ce("Canada is a truly wonderful country","CA",37602103,9984670,!1),Ce("Australia","AU",25475400,7692024,!0),Ce("Germany","DE",83019200,357578,!1),Ce("Ireland","IE",4857e3,70273,!0),Ce("Mexico","MX",126577691,1972550,!1),Ce("Japan","JP",126317e3,377973,!0),Ce("France","FR",67022e3,640679,!1),Ce("United Kingdom","GB",67545757,242495,!0),Ce("Russia","RU",146793744,17098246,!1),Ce("Nigeria","NG",200962417,923768,!1),Ce("Brazil","BR",210147125,8515767,!1)],Yt=["Zor","Eld","Myth","Drak","Lum","Xen","Thal","Quor","Vex","Nyx"],Xt=["aria","dor","mere","land","wyn","gard","heim","quess","tor","vale"];for(let r=0;r<2e3;r++){const c=`${Yt[r%Yt.length]}${Xt[r%Xt.length]} ${r}`,i=`F${r.toString().padStart(3,"0")}`,n=Math.floor(Math.random()*1e9),s=Math.floor(Math.random()*1e7),f=Math.random()<.2;dr.push(Ce(c,i,n,s,f))}function Yn(r,c){a&&console.log("getCssVariable:",r,"defaultValue",c);const i=getComputedStyle(document.body).getPropertyValue(r).trim();return i||console.error("getCssVariable: undefined",i),i||c}function Xn(r){return co({palette:{primary:{main:r},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)"}}}}})}let a=!1;const Zn=()=>{a=!a},cr=o.createContext(void 0);function ei({children:r}){const[c,i]=o.useState(!1),[n,s]=o.useState(""),f=async y=>{try{const t=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(t.ok){const{valid:l}=await t.json();l?i(!0):y!==""&&s("Incorrect password!")}else console.error("Failed to log in:",t.statusText)}catch(t){console.error("Failed to log in:",t)}};return e.jsx(cr.Provider,{value:{loggedIn:c,logIn:f,errorMessage:n},children:r})}function ti(){const[r,c]=o.useState(""),i=o.useContext(cr),[n,s]=o.useState("#1976d2");if(!i)throw new Error("AuthContext not found");const{loggedIn:f,logIn:y,errorMessage:t}=i,l=w=>{w.preventDefault(),y(r)},S={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},W={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)"};o.useEffect(()=>{a&&console.log("Setting frontend theme");const w=localStorage.getItem("frontendTheme");a&&console.log("Saved theme:",w),w?document.body.setAttribute("frontend-theme",w):document.body.setAttribute("frontend-theme","dark");const $=Yn("--primary-color","#1976d2");a&&console.log("Primary color from CSS:",$),s($)},[]);const L=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";console.log(`Loading App.js with href="${window.location.href}" and pathname="${window.location.pathname}" >>> baseName="${L}"`);const E=Xn(n);return y(""),f?e.jsx(po,{theme:E,children:e.jsx(jr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(zo,{children:e.jsx(qo,{children:e.jsx(fr,{basename:L,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(Jo,{}),e.jsxs(xr,{children:[e.jsx(Xe,{path:"/",element:e.jsx(bn,{})}),e.jsx(Xe,{path:"/devices",element:e.jsx(On,{})}),e.jsx(Xe,{path:"/log",element:e.jsx($n,{})}),e.jsx(Xe,{path:"/settings",element:e.jsx(_n,{})}),e.jsx(Xe,{path:"/test",element:e.jsx(Gn,{})}),e.jsx(Xe,{path:"*",element:e.jsx(br,{to:"/"})})]})]})})})})})}):e.jsx("div",{style:S,children:e.jsxs("form",{onSubmit:l,style:W,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:r,onChange:w=>c(w.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:t&&e.jsx("p",{style:{color:"red"},children:t})})]})})}function ri(){return e.jsx(ei,{children:e.jsx(ti,{})})}vr.createRoot(document.getElementById("root")).render(e.jsx(Wt.StrictMode,{children:e.jsx(ri,{})}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{s as O,c as pe,m as ge,a as ye,r as ve,R as be,b as xe,K as we,d as P,e as f,W as c,D as Se,f as ke,g as Ce,h as Pe,i as w,M as g,j as X,k as B,l as $,n as Ae,o as ae,t as ie,p as Ee,q as M,u as Te,v as Re,w as se,x as j,y as p,_ as _e}from"./vendor_node_modules.js";function Oe(t){if(t.sheet)return t.sheet;for(var e=0;e<document.styleSheets.length;e++)if(document.styleSheets[e].ownerNode===t)return document.styleSheets[e]}function $e(t){var e=document.createElement("style");return e.setAttribute("data-emotion",t.key),t.nonce!==void 0&&e.setAttribute("nonce",t.nonce),e.appendChild(document.createTextNode("")),e.setAttribute("data-s",""),e}var Ie=(function(){function t(r){var n=this;this._insertTag=function(a){var i;n.tags.length===0?n.insertionPoint?i=n.insertionPoint.nextSibling:n.prepend?i=n.container.firstChild:i=n.before:i=n.tags[n.tags.length-1].nextSibling,n.container.insertBefore(a,i),n.tags.push(a)},this.isSpeedy=r.speedy===void 0?!0:r.speedy,this.tags=[],this.ctr=0,this.nonce=r.nonce,this.key=r.key,this.container=r.container,this.prepend=r.prepend,this.insertionPoint=r.insertionPoint,this.before=null}var e=t.prototype;return e.hydrate=function(n){n.forEach(this._insertTag)},e.insert=function(n){this.ctr%(this.isSpeedy?65e3:1)===0&&this._insertTag($e(this));var a=this.tags[this.tags.length-1];if(this.isSpeedy){var i=Oe(a);try{i.insertRule(n,i.cssRules.length)}catch{}}else a.appendChild(document.createTextNode(n));this.ctr++},e.flush=function(){this.tags.forEach(function(n){var a;return(a=n.parentNode)==null?void 0:a.removeChild(n)}),this.tags=[],this.ctr=0},t})();function oe(t){var e=Object.create(null);return function(r){return e[r]===void 0&&(e[r]=t(r)),e[r]}}var Ne=function(e,r,n){for(var a=0,i=0;a=i,i=M(),a===38&&i===12&&(r[n]=1),!ie(i);)ae();return Re(e,se)},Fe=function(e,r){var n=-1,a=44;do switch(ie(a)){case 0:a===38&&M()===12&&(r[n]=1),e[n]+=Ne(se-1,r,n);break;case 2:e[n]+=Te(a);break;case 4:if(a===44){e[++n]=M()===58?"&\f":"",r[n]=e[n].length;break}default:e[n]+=Ee(a)}while(a=ae());return e},Me=function(e,r){return ke(Fe(Ce(e),r))},Y=new WeakMap,Le=function(e){if(!(e.type!=="rule"||!e.parent||e.length<1)){for(var r=e.value,n=e.parent,a=e.column===n.column&&e.line===n.line;n.type!=="rule";)if(n=n.parent,!n)return;if(!(e.props.length===1&&r.charCodeAt(0)!==58&&!Y.get(n))&&!a){Y.set(e,!0);for(var i=[],s=Me(r,i),l=n.props,o=0,u=0;o<s.length;o++)for(var m=0;m<l.length;m++,u++)e.props[u]=i[o]?s[o].replace(/&\f/g,l[m]):l[m]+" "+s[o]}}},ze=function(e){if(e.type==="decl"){var r=e.value;r.charCodeAt(0)===108&&r.charCodeAt(2)===98&&(e.return="",e.value="")}};function ce(t,e){switch(Pe(t,e)){case 5103:return c+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return c+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return c+t+$+t+g+t+t;case 6828:case 4268:return c+t+g+t+t;case 6165:return c+t+g+"flex-"+t+t;case 5187:return c+t+f(t,/(\w+).+(:[^]+)/,c+"box-$1$2"+g+"flex-$1$2")+t;case 5443:return c+t+g+"flex-item-"+f(t,/flex-|-self/,"")+t;case 4675:return c+t+g+"flex-line-pack"+f(t,/align-content|flex-|-self/,"")+t;case 5548:return c+t+g+f(t,"shrink","negative")+t;case 5292:return c+t+g+f(t,"basis","preferred-size")+t;case 6060:return c+"box-"+f(t,"-grow","")+c+t+g+f(t,"grow","positive")+t;case 4554:return c+f(t,/([^-])(transform)/g,"$1"+c+"$2")+t;case 6187:return f(f(f(t,/(zoom-|grab)/,c+"$1"),/(image-set)/,c+"$1"),t,"")+t;case 5495:case 3959:return f(t,/(image-set\([^]*)/,c+"$1$`$1");case 4968:return f(f(t,/(.+:)(flex-)?(.*)/,c+"box-pack:$3"+g+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+c+t+t;case 4095:case 3583:case 4068:case 2532:return f(t,/(.+)-inline(.+)/,c+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(X(t)-1-e>6)switch(w(t,e+1)){case 109:if(w(t,e+4)!==45)break;case 102:return f(t,/(.+:)(.+)-([^]+)/,"$1"+c+"$2-$3$1"+$+(w(t,e+3)==108?"$3":"$2-$3"))+t;case 115:return~B(t,"stretch")?ce(f(t,"stretch","fill-available"),e)+t:t}break;case 4949:if(w(t,e+1)!==115)break;case 6444:switch(w(t,X(t)-3-(~B(t,"!important")&&10))){case 107:return f(t,":",":"+c)+t;case 101:return f(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+c+(w(t,14)===45?"inline-":"")+"box$3$1"+c+"$2$3$1"+g+"$2box$3")+t}break;case 5936:switch(w(t,e+11)){case 114:return c+t+g+f(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return c+t+g+f(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return c+t+g+f(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return c+t+g+t+t}return t}var We=function(e,r,n,a){if(e.length>-1&&!e.return)switch(e.type){case Se:e.return=ce(e.value,e.length);break;case we:return O([P(e,{value:f(e.value,"@","@"+c)})],a);case be:if(e.length)return xe(e.props,function(i){switch(Ae(i,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return O([P(e,{props:[f(i,/:(read-\w+)/,":"+$+"$1")]})],a);case"::placeholder":return O([P(e,{props:[f(i,/:(plac\w+)/,":"+c+"input-$1")]}),P(e,{props:[f(i,/:(plac\w+)/,":"+$+"$1")]}),P(e,{props:[f(i,/:(plac\w+)/,g+"input-$1")]})],a)}return""})}},De=[We],He=function(e){var r=e.key;if(r==="css"){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,function(h){var d=h.getAttribute("data-emotion");d.indexOf(" ")!==-1&&(document.head.appendChild(h),h.setAttribute("data-s",""))})}var a=e.stylisPlugins||De,i={},s,l=[];s=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+r+' "]'),function(h){for(var d=h.getAttribute("data-emotion").split(" "),v=1;v<d.length;v++)i[d[v]]=!0;l.push(h)});var o,u=[Le,ze];{var m,y=[ye,ve(function(h){m.insert(h)})],E=ge(u.concat(a,y)),N=function(d){return O(pe(d),E)};o=function(d,v,S,k){m=S,N(d?d+"{"+v.styles+"}":v.styles),k&&(x.inserted[v.name]=!0)}}var x={key:r,sheet:new Ie({key:r,container:s,nonce:e.nonce,speedy:e.speedy,prepend:e.prepend,insertionPoint:e.insertionPoint}),nonce:e.nonce,inserted:i,registered:{},insert:o};return x.sheet.hydrate(l),x},qe=!0;function le(t,e,r){var n="";return r.split(" ").forEach(function(a){t[a]!==void 0?e.push(t[a]+";"):a&&(n+=a+" ")}),n}var z=function(e,r,n){var a=e.key+"-"+r.name;(n===!1||qe===!1)&&e.registered[a]===void 0&&(e.registered[a]=r.styles)},W=function(e,r,n){z(e,r,n);var a=e.key+"-"+r.name;if(e.inserted[r.name]===void 0){var i=r;do e.insert(r===i?"."+a:"",i,e.sheet,!0),i=i.next;while(i!==void 0)}};function Ue(t){for(var e=0,r,n=0,a=t.length;a>=4;++n,a-=4)r=t.charCodeAt(n)&255|(t.charCodeAt(++n)&255)<<8|(t.charCodeAt(++n)&255)<<16|(t.charCodeAt(++n)&255)<<24,r=(r&65535)*1540483477+((r>>>16)*59797<<16),r^=r>>>24,e=(r&65535)*1540483477+((r>>>16)*59797<<16)^(e&65535)*1540483477+((e>>>16)*59797<<16);switch(a){case 3:e^=(t.charCodeAt(n+2)&255)<<16;case 2:e^=(t.charCodeAt(n+1)&255)<<8;case 1:e^=t.charCodeAt(n)&255,e=(e&65535)*1540483477+((e>>>16)*59797<<16)}return e^=e>>>13,e=(e&65535)*1540483477+((e>>>16)*59797<<16),((e^e>>>15)>>>0).toString(36)}var Ge={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,scale:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Ve=/[A-Z]|^ms/g,Xe=/_EMO_([^_]+?)_([^]*?)_EMO_/g,fe=function(e){return e.charCodeAt(1)===45},K=function(e){return e!=null&&typeof e!="boolean"},F=oe(function(t){return fe(t)?t:t.replace(Ve,"-$&").toLowerCase()}),J=function(e,r){switch(e){case"animation":case"animationName":if(typeof r=="string")return r.replace(Xe,function(n,a,i){return b={name:a,styles:i,next:b},a})}return Ge[e]!==1&&!fe(e)&&typeof r=="number"&&r!==0?r+"px":r};function A(t,e,r){if(r==null)return"";var n=r;if(n.__emotion_styles!==void 0)return n;switch(typeof r){case"boolean":return"";case"object":{var a=r;if(a.anim===1)return b={name:a.name,styles:a.styles,next:b},a.name;var i=r;if(i.styles!==void 0){var s=i.next;if(s!==void 0)for(;s!==void 0;)b={name:s.name,styles:s.styles,next:b},s=s.next;var l=i.styles+";";return l}return Be(t,e,r)}case"function":{if(t!==void 0){var o=b,u=r(t);return b=o,A(t,e,u)}break}}var m=r;if(e==null)return m;var y=e[m];return y!==void 0?y:m}function Be(t,e,r){var n="";if(Array.isArray(r))for(var a=0;a<r.length;a++)n+=A(t,e,r[a])+";";else for(var i in r){var s=r[i];if(typeof s!="object"){var l=s;e!=null&&e[l]!==void 0?n+=i+"{"+e[l]+"}":K(l)&&(n+=F(i)+":"+J(i,l)+";")}else if(Array.isArray(s)&&typeof s[0]=="string"&&(e==null||e[s[0]]===void 0))for(var o=0;o<s.length;o++)K(s[o])&&(n+=F(i)+":"+J(i,s[o])+";");else{var u=A(t,e,s);switch(i){case"animation":case"animationName":{n+=F(i)+":"+u+";";break}default:n+=i+"{"+u+"}"}}}return n}var Z=/label:\s*([^\s;{]+)\s*(;|$)/g,b;function I(t,e,r){if(t.length===1&&typeof t[0]=="object"&&t[0]!==null&&t[0].styles!==void 0)return t[0];var n=!0,a="";b=void 0;var i=t[0];if(i==null||i.raw===void 0)n=!1,a+=A(r,e,i);else{var s=i;a+=s[0]}for(var l=1;l<t.length;l++)if(a+=A(r,e,t[l]),n){var o=i;a+=o[l]}Z.lastIndex=0;for(var u="",m;(m=Z.exec(a))!==null;)u+="-"+m[1];var y=Ue(a)+u;return{name:y,styles:a,next:b}}var je=function(e){return e()},de=j.useInsertionEffect?j.useInsertionEffect:!1,ue=de||je,Q=de||p.useLayoutEffect,he=p.createContext(typeof HTMLElement<"u"?He({key:"css"}):null);he.Provider;var D=function(e){return p.forwardRef(function(r,n){var a=p.useContext(he);return e(r,a,n)})},H=p.createContext({}),q={}.hasOwnProperty,L="__EMOTION_TYPE_PLEASE_DO_NOT_USE__",Ye=function(e,r){var n={};for(var a in r)q.call(r,a)&&(n[a]=r[a]);return n[L]=e,n},Ke=function(e){var r=e.cache,n=e.serialized,a=e.isStringTag;return z(r,n,a),ue(function(){return W(r,n,a)}),null},Je=D(function(t,e,r){var n=t.css;typeof n=="string"&&e.registered[n]!==void 0&&(n=e.registered[n]);var a=t[L],i=[n],s="";typeof t.className=="string"?s=le(e.registered,i,t.className):t.className!=null&&(s=t.className+" ");var l=I(i,void 0,p.useContext(H));s+=e.key+"-"+l.name;var o={};for(var u in t)q.call(t,u)&&u!=="css"&&u!==L&&(o[u]=t[u]);return o.className=s,r&&(o.ref=r),p.createElement(p.Fragment,null,p.createElement(Ke,{cache:e,serialized:l,isStringTag:typeof a=="string"}),p.createElement(a,o))}),Ze=Je,ee=function(e,r){var n=arguments;if(r==null||!q.call(r,"css"))return p.createElement.apply(void 0,n);var a=n.length,i=new Array(a);i[0]=Ze,i[1]=Ye(e,r);for(var s=2;s<a;s++)i[s]=n[s];return p.createElement.apply(null,i)};(function(t){var e;e||(e=t.JSX||(t.JSX={}))})(ee||(ee={}));var ct=D(function(t,e){var r=t.styles,n=I([r],void 0,p.useContext(H)),a=p.useRef();return Q(function(){var i=e.key+"-global",s=new e.sheet.constructor({key:i,nonce:e.sheet.nonce,container:e.sheet.container,speedy:e.sheet.isSpeedy}),l=!1,o=document.querySelector('style[data-emotion="'+i+" "+n.name+'"]');return e.sheet.tags.length&&(s.before=e.sheet.tags[0]),o!==null&&(l=!0,o.setAttribute("data-emotion",i),s.hydrate([o])),a.current=[s,l],function(){s.flush()}},[e]),Q(function(){var i=a.current,s=i[0],l=i[1];if(l){i[1]=!1;return}if(n.next!==void 0&&W(e,n.next,!0),s.tags.length){var o=s.tags[s.tags.length-1].nextElementSibling;s.before=o,s.flush()}e.insert("",n,s,!1)},[e,n.name]),null});function Qe(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];return I(e)}function lt(){var t=Qe.apply(void 0,arguments),e="animation-"+t.name;return{name:e,styles:"@keyframes "+e+"{"+t.styles+"}",anim:1,toString:function(){return"_EMO_"+this.name+"_"+this.styles+"_EMO_"}}}var et=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|fetchpriority|fetchPriority|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|popover|popoverTarget|popoverTargetAction|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,tt=oe(function(t){return et.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),rt=tt,nt=function(e){return e!=="theme"},te=function(e){return typeof e=="string"&&e.charCodeAt(0)>96?rt:nt},re=function(e,r,n){var a;if(r){var i=r.shouldForwardProp;a=e.__emotion_forwardProp&&i?function(s){return e.__emotion_forwardProp(s)&&i(s)}:i}return typeof a!="function"&&n&&(a=e.__emotion_forwardProp),a},at=function(e){var r=e.cache,n=e.serialized,a=e.isStringTag;return z(r,n,a),ue(function(){return W(r,n,a)}),null},it=function t(e,r){var n=e.__emotion_real===e,a=n&&e.__emotion_base||e,i,s;r!==void 0&&(i=r.label,s=r.target);var l=re(e,r,n),o=l||te(a),u=!o("as");return function(){var m=arguments,y=n&&e.__emotion_styles!==void 0?e.__emotion_styles.slice(0):[];if(i!==void 0&&y.push("label:"+i+";"),m[0]==null||m[0].raw===void 0)y.push.apply(y,m);else{var E=m[0];y.push(E[0]);for(var N=m.length,x=1;x<N;x++)y.push(m[x],E[x])}var h=D(function(d,v,S){var k=u&&d.as||a,C="",U=[],T=d;if(d.theme==null){T={};for(var G in d)T[G]=d[G];T.theme=p.useContext(H)}typeof d.className=="string"?C=le(v.registered,U,d.className):d.className!=null&&(C=d.className+" ");var V=I(y.concat(U),v.registered,T);C+=v.key+"-"+V.name,s!==void 0&&(C+=" "+s);var me=u&&l===void 0?te(k):o,R={};for(var _ in d)u&&_==="as"||me(_)&&(R[_]=d[_]);return R.className=C,S&&(R.ref=S),p.createElement(p.Fragment,null,p.createElement(at,{cache:v,serialized:V,isStringTag:typeof k=="string"}),p.createElement(k,R))});return h.displayName=i!==void 0?i:"Styled("+(typeof a=="string"?a:a.displayName||a.name||"Component")+")",h.defaultProps=e.defaultProps,h.__emotion_real=h,h.__emotion_base=a,h.__emotion_styles=y,h.__emotion_forwardProp=l,Object.defineProperty(h,"toString",{value:function(){return"."+s}}),h.withComponent=function(d,v){var S=t(d,_e({},r,v,{shouldForwardProp:re(h,v,!0)}));return S.apply(void 0,y)},h}},st=["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","marquee","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","u","ul","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"],ne=it.bind(null);st.forEach(function(t){ne[t]=ne(t)});export{ct as G,H as T,I as a,Qe as c,lt as k,ne as s};
|