matterbridge 3.2.8-dev-20250916-da71182 → 3.2.8-dev-20250918-52dc90c

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.
Files changed (104) hide show
  1. package/CHANGELOG.md +12 -2
  2. package/dist/frontend.js +130 -199
  3. package/dist/frontendTypes.js +25 -0
  4. package/dist/matterbridge.js +3 -7
  5. package/dist/shelly.js +4 -5
  6. package/dist/utils/spawn.js +4 -4
  7. package/frontend/build/assets/index.css +1 -0
  8. package/frontend/build/assets/index.js +23 -0
  9. package/frontend/build/assets/vendor_emotion.js +1 -0
  10. package/frontend/build/assets/vendor_lodash.js +1 -0
  11. package/frontend/build/assets/vendor_mdi.js +1 -0
  12. package/frontend/build/assets/vendor_mui.js +137 -0
  13. package/frontend/build/assets/vendor_node_modules.js +100 -0
  14. package/frontend/build/assets/vendor_notistack.js +5 -0
  15. package/frontend/build/assets/vendor_qrcode.js +9 -0
  16. package/frontend/build/assets/vendor_react_table.js +1 -0
  17. package/frontend/build/assets/vendor_rjsf.js +10 -0
  18. package/frontend/build/index.html +27 -1
  19. package/frontend/index.html +17 -0
  20. package/frontend/package-lock.json +5697 -17190
  21. package/frontend/package.json +60 -53
  22. package/npm-shrinkwrap.json +5 -5
  23. package/package.json +1 -1
  24. package/frontend/build/asset-manifest.json +0 -85
  25. package/frontend/build/favicon.ico +0 -0
  26. package/frontend/build/manifest.json +0 -15
  27. package/frontend/build/robots.txt +0 -3
  28. package/frontend/build/static/css/main.56c16a87.css +0 -2
  29. package/frontend/build/static/css/main.56c16a87.css.map +0 -1
  30. package/frontend/build/static/js/main.565f820c.js +0 -3
  31. package/frontend/build/static/js/main.565f820c.js.LICENSE.txt +0 -97
  32. package/frontend/build/static/js/main.565f820c.js.map +0 -1
  33. package/frontend/build/static/media/roboto-cyrillic-300-normal.44340549d94d10899346.woff +0 -0
  34. package/frontend/build/static/media/roboto-cyrillic-300-normal.89d0351bce4bc857dba6.woff2 +0 -0
  35. package/frontend/build/static/media/roboto-cyrillic-400-normal.86d5c52f4588f9f221d7.woff2 +0 -0
  36. package/frontend/build/static/media/roboto-cyrillic-400-normal.d67ac585bb6a05dbf71c.woff +0 -0
  37. package/frontend/build/static/media/roboto-cyrillic-500-normal.1fb2c6d685bfb888cfa3.woff2 +0 -0
  38. package/frontend/build/static/media/roboto-cyrillic-500-normal.36f79cc7e73a69da4438.woff +0 -0
  39. package/frontend/build/static/media/roboto-cyrillic-700-normal.e00802373a2c2db6b30d.woff +0 -0
  40. package/frontend/build/static/media/roboto-cyrillic-700-normal.fd3dfdd6cb1a9175b63d.woff2 +0 -0
  41. package/frontend/build/static/media/roboto-cyrillic-ext-300-normal.a80c0d0719b1acb8f731.woff +0 -0
  42. package/frontend/build/static/media/roboto-cyrillic-ext-300-normal.b9d87b04a9119d8d2fdf.woff2 +0 -0
  43. package/frontend/build/static/media/roboto-cyrillic-ext-400-normal.31476620b88eec076438.woff2 +0 -0
  44. package/frontend/build/static/media/roboto-cyrillic-ext-400-normal.5e3f232f89080810567d.woff +0 -0
  45. package/frontend/build/static/media/roboto-cyrillic-ext-500-normal.634ee2238bf30f362d52.woff2 +0 -0
  46. package/frontend/build/static/media/roboto-cyrillic-ext-500-normal.d6c661248da2fde17768.woff +0 -0
  47. package/frontend/build/static/media/roboto-cyrillic-ext-700-normal.361cdfd3a3f9c4bb09ca.woff2 +0 -0
  48. package/frontend/build/static/media/roboto-cyrillic-ext-700-normal.6b08bc756cd72f5af9e8.woff +0 -0
  49. package/frontend/build/static/media/roboto-greek-300-normal.8300b541aa89b8301a6f.woff +0 -0
  50. package/frontend/build/static/media/roboto-greek-300-normal.fdd1f928a606aa116a44.woff2 +0 -0
  51. package/frontend/build/static/media/roboto-greek-400-normal.98a717d5a38e77c0f657.woff2 +0 -0
  52. package/frontend/build/static/media/roboto-greek-400-normal.ecd8572d631f20ff5bd5.woff +0 -0
  53. package/frontend/build/static/media/roboto-greek-500-normal.4fe733bc436afc295c24.woff +0 -0
  54. package/frontend/build/static/media/roboto-greek-500-normal.5c8100481d4e784afbf2.woff2 +0 -0
  55. package/frontend/build/static/media/roboto-greek-700-normal.d23e03cf87ba44e5af6f.woff +0 -0
  56. package/frontend/build/static/media/roboto-greek-700-normal.d7dfd0b02cd8311e2a97.woff2 +0 -0
  57. package/frontend/build/static/media/roboto-greek-ext-300-normal.60729cafbded24073dfb.woff +0 -0
  58. package/frontend/build/static/media/roboto-greek-ext-300-normal.a88b77bb10633a8045e3.woff2 +0 -0
  59. package/frontend/build/static/media/roboto-greek-ext-400-normal.2d5875b032a1cca91eb2.woff2 +0 -0
  60. package/frontend/build/static/media/roboto-greek-ext-400-normal.a0baf7d6726d8f751a27.woff +0 -0
  61. package/frontend/build/static/media/roboto-greek-ext-500-normal.1964239c2800b6bd7e39.woff +0 -0
  62. package/frontend/build/static/media/roboto-greek-ext-500-normal.bef9c15c7164d6435aad.woff2 +0 -0
  63. package/frontend/build/static/media/roboto-greek-ext-700-normal.1aff9f4cd71608489b9a.woff +0 -0
  64. package/frontend/build/static/media/roboto-greek-ext-700-normal.eb28a447335ba6d54fcb.woff2 +0 -0
  65. package/frontend/build/static/media/roboto-latin-300-normal.cb14f8e80cc69ddbac34.woff +0 -0
  66. package/frontend/build/static/media/roboto-latin-300-normal.db56943a88e4852343ae.woff2 +0 -0
  67. package/frontend/build/static/media/roboto-latin-400-normal.50a0a61e29c19a2f05cb.woff +0 -0
  68. package/frontend/build/static/media/roboto-latin-400-normal.df1be0be92f6f19b8115.woff2 +0 -0
  69. package/frontend/build/static/media/roboto-latin-500-normal.599f66a60bdf974e578e.woff2 +0 -0
  70. package/frontend/build/static/media/roboto-latin-500-normal.c320def131b39bceabd8.woff +0 -0
  71. package/frontend/build/static/media/roboto-latin-700-normal.bcfbe8accc968a375a8e.woff +0 -0
  72. package/frontend/build/static/media/roboto-latin-700-normal.c4d6cab43bec89049809.woff2 +0 -0
  73. package/frontend/build/static/media/roboto-latin-ext-300-normal.6ddd1cfdbc5e74bcdab8.woff +0 -0
  74. package/frontend/build/static/media/roboto-latin-ext-300-normal.948c05192b1e64d931b1.woff2 +0 -0
  75. package/frontend/build/static/media/roboto-latin-ext-400-normal.0f86a30ca7e981fcfc99.woff2 +0 -0
  76. package/frontend/build/static/media/roboto-latin-ext-400-normal.2bfbba2d51a85c8702dd.woff +0 -0
  77. package/frontend/build/static/media/roboto-latin-ext-500-normal.8f02573e78730021ef49.woff2 +0 -0
  78. package/frontend/build/static/media/roboto-latin-ext-500-normal.aecaab4c4da2bf91377a.woff +0 -0
  79. package/frontend/build/static/media/roboto-latin-ext-700-normal.2d3c3ba6fe2d9c1026a5.woff +0 -0
  80. package/frontend/build/static/media/roboto-latin-ext-700-normal.8e656eff240311c6050a.woff2 +0 -0
  81. package/frontend/build/static/media/roboto-math-300-normal.90364ecfad5101ceb1a0.woff +0 -0
  82. package/frontend/build/static/media/roboto-math-300-normal.acc9c7c1d1fe3a1c7d44.woff2 +0 -0
  83. package/frontend/build/static/media/roboto-math-400-normal.3d3a272e5233c5fb1969.woff +0 -0
  84. package/frontend/build/static/media/roboto-math-400-normal.b60d9fba1e21da7497e6.woff2 +0 -0
  85. package/frontend/build/static/media/roboto-math-500-normal.41db483cb764343fca71.woff2 +0 -0
  86. package/frontend/build/static/media/roboto-math-500-normal.c3014a611cd9d8fa6252.woff +0 -0
  87. package/frontend/build/static/media/roboto-math-700-normal.a6fde3ddcb1629fd58b7.woff +0 -0
  88. package/frontend/build/static/media/roboto-math-700-normal.f6f4b54add6ab9d60a0f.woff2 +0 -0
  89. package/frontend/build/static/media/roboto-symbols-300-normal.52cdf8344b378f0c4580.woff +0 -0
  90. package/frontend/build/static/media/roboto-symbols-300-normal.616638ec44336b3da884.woff2 +0 -0
  91. package/frontend/build/static/media/roboto-symbols-400-normal.bb5b5d1459beb07bd3d5.woff2 +0 -0
  92. package/frontend/build/static/media/roboto-symbols-400-normal.f4f7e3bd8264f1a640cb.woff +0 -0
  93. package/frontend/build/static/media/roboto-symbols-500-normal.09b674875029289fd9a7.woff +0 -0
  94. package/frontend/build/static/media/roboto-symbols-500-normal.a5457b0ec984fd4cc8da.woff2 +0 -0
  95. package/frontend/build/static/media/roboto-symbols-700-normal.017e476ef02f62144169.woff +0 -0
  96. package/frontend/build/static/media/roboto-symbols-700-normal.634070e045ac99822c21.woff2 +0 -0
  97. package/frontend/build/static/media/roboto-vietnamese-300-normal.53f399e4522b647bafa7.woff +0 -0
  98. package/frontend/build/static/media/roboto-vietnamese-300-normal.6f0bf63e956c09377ef8.woff2 +0 -0
  99. package/frontend/build/static/media/roboto-vietnamese-400-normal.1cffe58e71a9109191a2.woff +0 -0
  100. package/frontend/build/static/media/roboto-vietnamese-400-normal.b1b8baa94fbcaa57d098.woff2 +0 -0
  101. package/frontend/build/static/media/roboto-vietnamese-500-normal.148734d63bd96c6e964f.woff2 +0 -0
  102. package/frontend/build/static/media/roboto-vietnamese-500-normal.72dbf2a25dd55b80b137.woff +0 -0
  103. package/frontend/build/static/media/roboto-vietnamese-700-normal.44a103f706f3ffe6a041.woff2 +0 -0
  104. package/frontend/build/static/media/roboto-vietnamese-700-normal.fa58a041a3336692af1e.woff +0 -0
@@ -0,0 +1,23 @@
1
+ import{B as e,y as r,S as st,I as Ee,U as gr,V as hr,X as Ye,Y as xr,Z as fr}from"./vendor_node_modules.js";import{u as br,S as vr}from"./vendor_notistack.js";import{D as Ie,a as De,b as Ne,B as oe,c as Z,A as yr,I as z,C as jr,T as H,S as Cr,F as Yt,H as Sr,d as Xt,e as $e,R as vt,P as ze,M as wr,f as tt,g as P,L as Q,h as re,i as lt,V as dt,j as Re,k as Dt,l as Mr,m as kr,n as pe,o as Ir,p as Dr,q as yt,r as de,s as We,K as Lt,t as Ht,u as Ct,v as ct,w as nt,x as pt,W as it,y as ut,z as mt,E as Pe,G as Rt,J as Ot,N as Nr,O as Pr,Q as at,U as Te,X as Be,Y as Zt,Z as Tr,_ as Wr,$ as Fr,a0 as Lr,a1 as er,a2 as jt,a3 as Hr,a4 as Rr,a5 as Or,a6 as Vr,a7 as Vt,a8 as Er,a9 as $r,aa as _r,ab as Ar,ac as Ur,ad as zr,ae as qr,af as Et,ag as Br,ah as Jr,ai as Gr,aj as Qr,ak as Kr,al as Yr,am as Xr,an as Zr,ao as eo,ap as to,aq as ro,ar as oo,as as no,at as io,au as ao,av as $t,aw as rt,ax as tr,ay as ke,az as rr,aA as St,aB as _e,aC as so,aD as lo}from"./vendor_mui.js";import{Q as co}from"./vendor_qrcode.js";import{I as te,m as _t,a as po,b as uo,c as At,d as mo,e as Tt,f as Wt,g as go,h as ho,i as xo,j as fo,k as bo,l as vo,n as yo,o as jo,p as Ut,q as Co,r as So,s as wo,t as Mo,u as ko,v as Io,w as Do,x as No,y as zt,z as Po,A as To,B as Wo}from"./vendor_mdi.js";import{r as Ae}from"./vendor_react_table.js";import{F as Fo,v as Lo,e as Ho,a as Ro,g as Oo,b as Vo,c as Eo,d as Nt,A as $o}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 h of s)if(h.type==="childList")for(const b of h.addedNodes)b.tagName==="LINK"&&b.rel==="modulepreload"&&n(b)}).observe(document,{childList:!0,subtree:!0});function i(s){const h={};return s.integrity&&(h.integrity=s.integrity),s.referrerPolicy&&(h.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?h.credentials="include":s.crossOrigin==="anonymous"?h.credentials="omit":h.credentials="same-origin",h}function n(s){if(s.ep)return;s.ep=!0;const h=i(s);fetch(s.href,h)}})();/**
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 Me=(o=>(o[o.Log=0]="Log",o[o.RefreshRequired=1]="RefreshRequired",o[o.RestartRequired=2]="RestartRequired",o[o.RestartNotRequired=3]="RestartNotRequired",o[o.CpuUpdate=4]="CpuUpdate",o[o.MemoryUpdate=5]="MemoryUpdate",o[o.UptimeUpdate=6]="UptimeUpdate",o[o.Snackbar=7]="Snackbar",o[o.UpdateRequired=8]="UpdateRequired",o[o.StateUpdate=9]="StateUpdate",o[o.CloseSnackbar=10]="CloseSnackbar",o[o.ShellySysUpdate=100]="ShellySysUpdate",o[o.ShellyMainUpdate=101]="ShellyMainUpdate",o))(Me||{});function _o({open:o,title:c,message:i,onConfirm:n,onCancel:s}){const h=t=>{a&&console.log("Confirmed"),t.preventDefault(),n()},b=t=>{a&&console.log("Canceled"),t.preventDefault(),s()};return e.jsxs(Ie,{open:o,children:[e.jsx(De,{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(Ne,{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:h,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(oe,{onClick:b,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const gt=[],ot=r.createContext(null);function Ao({children:o}){const{enqueueSnackbar:c,closeSnackbar:i}=br(),n=r.useCallback(F=>{a&&console.log(`UiProvider closeSnackbarMessage: message ${F}`);const O=gt.findIndex(E=>E.message===F);O!==-1&&(i(gt[O].key),gt.splice(O,1),a&&console.log(`UiProvider closeSnackbarMessage: message ${F} removed from persistMessages`))},[i]),s=r.useCallback((F,O,E)=>{a&&console.log(`UiProvider showSnackbarMessage: message ${F} timeout ${O}`);const $=c(F,{variant:"default",autoHideDuration:O==null||O>0?(O??5)*1e3:null,persist:O===0,content:B=>e.jsx(Z,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(yr,{severity:E??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>i(B),action:e.jsx(z,{size:"small",onClick:()=>i(B),sx:{color:"#fff"},children:e.jsx(jr,{fontSize:"small"})}),children:F},B)},B)});O===0&&(a&&console.log(`UiProvider showSnackbarMessage: message ${F} timeout ${O} - persist key ${$}`),gt.push({message:F,key:$}))},[c,i]),[h,b]=r.useState(!1),[t,u]=r.useState(""),[C,L]=r.useState(""),[v,W]=r.useState(""),R=r.useRef(null),y=r.useRef(null),T=()=>{a&&console.log(`UiProvider handle confirm action ${v}`),b(!1),R.current&&R.current(v)},p=()=>{a&&console.log(`UiProvider handle cancel action ${v}`),b(!1),y.current&&y.current(v)},V=r.useCallback((F,O,E,$,B)=>{a&&console.log(`UiProvider showConfirmCancelDialog for command ${E}`),u(F),L(O),W(E),R.current=$,y.current=B,b(!0)},[]),S=r.useMemo(()=>({showSnackbarMessage:s,closeSnackbarMessage:n,closeSnackbar:i,showConfirmCancelDialog:V}),[s,n,i,V]);return e.jsxs(ot.Provider,{value:S,children:[e.jsx(_o,{open:h,title:t,message:C,onConfirm:T,onCancel:p}),o]})}const or=r.createContext(null),fe=r.createContext(null);function Uo({children:o}){const[c,i]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[n,s]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[h,b]=r.useState([]),[t,u]=r.useState(1e3),[C,L]=r.useState(!0),[v,W]=r.useState(!1),{showSnackbarMessage:R,closeSnackbarMessage:y,closeSnackbar:T}=r.useContext(ot),p=r.useRef([]),V=r.useRef(null),S=r.useRef(1),F=r.useRef(Math.floor(Math.random()*999e3)+1e3),O=r.useRef(null),E=r.useRef(null),$=r.useRef(null),B=r.useRef(c),Y=r.useRef(n),l=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),x=r.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),f=100,D=60,X=50,he=300;r.useEffect(()=>{B.current=c},[c]),r.useEffect(()=>{Y.current=n},[n]);const j=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),m=r.useCallback(w=>{if(V.current&&V.current.readyState===WebSocket.OPEN)try{w.id===void 0&&(w.id=F.current);const g=JSON.stringify(w);V.current.send(g),a&&console.log("WebSocket sent message:",w)}catch(g){a&&console.error(`WebSocket error sending message: ${g}`)}else a&&console.error("WebSocket message not sent, WebSocket not connected:",w)},[]),_=r.useCallback((w,g)=>{const d=`<span style="background-color: #5c0e91; color: white; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${w}</span>`;b(N=>[...N,d+' <span style="color: var(--main-log-color);">'+g+"</span>"])},[]),I=r.useCallback((w,g)=>{i(w),s(g),_("WebSocket",`Filtering by log level "${w}" and log search "${g}"`)},[_]),ee=r.useCallback(w=>{a&&console.log("WebSocket addListener:",w),p.current=[...p.current,w],a&&console.log("WebSocket addListener total listeners:",p.current.length)},[]),xe=r.useCallback(w=>{a&&console.log("WebSocket removeListener:",w),p.current=p.current.filter(g=>g!==w),a&&console.log("WebSocket removeListener total listeners:",p.current.length)},[]),Se=r.useCallback(()=>{l===""||l===null||l===void 0||(_("WebSocket",`Connecting to WebSocket: ${l}`),V.current=new WebSocket(l),V.current.onmessage=w=>{v||W(!0);try{const g=JSON.parse(w.data);if(g.id===void 0)return;if(g.error&&a&&console.error("WebSocket error message:",g),g.id===F.current&&g.src==="Matterbridge"&&g.dst==="Frontend"&&g.response==="pong"){a&&console.log("WebSocket pong response message:",g,"listeners:",p.current.length),E.current&&clearTimeout(E.current),p.current.forEach(N=>N(g));return}if(g.id===Me.RefreshRequired){a&&console.log("WebSocket WS_ID_REFRESH_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.RestartRequired){a&&console.log("WebSocket WS_ID_RESTART_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.RestartNotRequired){a&&console.log("WebSocket WS_ID_RESTART_NOT_REQUIRED message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.CpuUpdate){a&&console.log("WebSocket WS_ID_CPU_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.MemoryUpdate){a&&console.log("WebSocket WS_ID_MEMORY_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.UptimeUpdate){a&&console.log("WebSocket WS_ID_UPTIME_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.Snackbar&&g.params&&g.params.message){a&&console.log("WebSocket WS_ID_SNACKBAR message:",g,"listeners:",p.current.length),R(g.params.message,g.params.timeout,g.params.severity);return}else if(g.id===Me.CloseSnackbar&&g.params&&g.params.message){a&&console.log("WebSocket WS_ID_CLOSE_SNACKBAR message:",g,"listeners:",p.current.length),y(g.params.message);return}else if(g.id===Me.ShellySysUpdate){a&&console.log("WebSocket WS_ID_SHELLY_SYS_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id===Me.ShellyMainUpdate){a&&console.log("WebSocket WS_ID_SHELLY_MAIN_UPDATE message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(g));return}else if(g.id!==Me.Log){a&&console.log("WebSocket message:",g,"listeners:",p.current.length),p.current.forEach(N=>N(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)&&(B.current==="info"&&g.params.level==="debug"||B.current==="notice"&&(g.params.level==="debug"||g.params.level==="info")||B.current==="warn"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice")||B.current==="error"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice"||g.params.level==="warn")||B.current==="fatal"&&(g.params.level==="debug"||g.params.level==="info"||g.params.level==="notice"||g.params.level==="warn"||g.params.level==="error"))||Y.current!=="*"&&Y.current!==""&&!g.params.message.toLowerCase().includes(Y.current.toLowerCase())&&!g.params.name.toLowerCase().includes(Y.current.toLowerCase())||g.params.name==="Commissioning"&&g.params.message.includes("is uncommissioned"))return;b(N=>{const ae=`<span style="color: #505050;">[${g.params?.time}]</span>`,le=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"}},q=be=>{switch(be?.toLowerCase()){case"warn":return"black";default:return"white"}},me=`${`<span style="background-color: ${le(g.params?.level)}; color: ${q(g.params?.level)}; padding: 1px 5px; font-size: 12px; border-radius: 3px;">${g.params?.level}</span>`} ${ae} <span style="color: #09516d;">[${g.params?.name}]</span> <span style="color: var(--main-log-color);">${g.params?.message}</span>`,ne=[...N,me];return ne.length>t?ne.slice(t/10):ne})}catch(g){console.error(`WebSocketUse error parsing message: ${g}`)}},V.current.onopen=()=>{a&&console.log(`WebSocket: Connected to WebSocket: ${l}`),_("WebSocket",`Connected to WebSocket: ${l}`),W(!0),T(),S.current=1,$.current=setTimeout(()=>{O.current=setInterval(()=>{m({id:F.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{a&&console.error(`WebSocketUse: No pong response received from WebSocket: ${l}`),_("WebSocket",`No pong response received from WebSocket: ${l}`),W(!1)},1e3*X)},1e3*D)},1e3*he)},V.current.onclose=()=>{a&&console.error(`WebSocket: Disconnected from WebSocket ${x?"with Ingress":""}: ${l}`),_("WebSocket",`Disconnected from WebSocket: ${l}`),W(!1),T(),$.current&&clearTimeout($.current),E.current&&clearTimeout(E.current),O.current&&clearInterval(O.current),_("WebSocket",`Reconnecting (attempt ${S.current} of ${f}) to WebSocket${x?" (Ingress)":""}: ${l}`),x?setTimeout(U,5e3):S.current===1?U():S.current<f?setTimeout(U,1e3*S.current):_("WebSocket",`Reconnect attempts exceeded limit of ${f} retries, refresh the page to reconnect to: ${l}`),S.current=S.current+1},V.current.onerror=w=>{a&&console.error(`WebSocket: WebSocket error connecting to ${l}:`,w),_("WebSocket",`WebSocket error connecting to ${l}`)})},[l]),U=r.useCallback(()=>{a&&console.log(`WebSocket attemptReconnect ${S.current}/${f} to:`,l),Se()},[Se]);r.useEffect(()=>(Se(),()=>{V.current&&V.current.readyState===WebSocket.OPEN&&V.current.close()}),[Se]);const M=r.useMemo(()=>({messages:h,maxMessages:t,autoScroll:C,setMessages:b,setLogFilters:I,setMaxMessages:u,setAutoScroll:L}),[h,b,I]),k=r.useMemo(()=>({maxMessages:t,autoScroll:C,logFilterLevel:c,logFilterSearch:n,setMessages:b,setLogFilters:I,setMaxMessages:u,setAutoScroll:L,online:v,retry:S.current,getUniqueId:j,addListener:ee,removeListener:xe,sendMessage:m,logMessage:_}),[t,C,b,I,u,L,v,S.current,ee,xe,m,_]);return e.jsx(or.Provider,{value:M,children:e.jsx(fe.Provider,{value:k,children:o})})}function zo(){const{showSnackbarMessage:o,showConfirmCancelDialog:c}=r.useContext(ot),{online:i,sendMessage:n,logMessage:s,addListener:h,removeListener:b,getUniqueId:t}=r.useContext(fe),[u,C]=r.useState(!1),[L,v]=r.useState(!1),[W,R]=r.useState(!1),[y,T]=r.useState(!1),[p,V]=r.useState(null),S=r.useRef(t()),[F,O]=r.useState(null),[E,$]=r.useState(null),[B,Y]=r.useState(null),[l,x]=r.useState(null),[f,D]=r.useState(null),X=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},he=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},j=()=>{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")},I=()=>{n({id:S.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},ee=()=>{n({id:S.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},xe=()=>{n({id:S.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},Se=()=>{a&&console.log("Header: handleShellySystemUpdateClick"),s("Matterbridge","Installing system updates..."),n({id:S.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},U=()=>{a&&console.log("Header: handleShellyMainUpdateClick"),s("Matterbridge","Installing software updates..."),n({id:S.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{a&&console.log("Header: handleShellyCreateSystemLog"),n({id:S.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{a&&console.log("Header: handleShellyDownloadSystemLog"),s("Matterbridge","Downloading Shelly system log..."),o("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},w=()=>{p.matterbridgeInformation.restartMode===""?n({id:S.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):n({id:S.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},g=()=>{n({id:S.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},d=()=>{n({id:S.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},N=()=>{n({id:S.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ae=()=>{n({id:S.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=J=>{O(J.currentTarget)},q=J=>{a&&console.log("Header: handleMenuClose",J),O(null),J==="download-mblog"?(s("Matterbridge","Downloading matterbridge log..."),o("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):J==="download-mjlog"?(s("Matterbridge","Downloading matter log..."),o("Downloading matter log...",5),window.location.href="./api/download-mjlog"):J==="view-mblog"?(s("Matterbridge","Loading matterbridge log..."),o("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):J==="view-mjlog"?(s("Matterbridge","Loading matter log..."),o("Loading matter log...",5),window.location.href="./api/view-mjlog"):J==="view-shellylog"?(s("Matterbridge","Loading shelly system log..."),o("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):J==="download-mbstorage"?(s("Matterbridge","Downloading matterbridge storage..."),o("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):J==="download-pluginstorage"?(s("Matterbridge","Downloading matterbridge plugins storage..."),o("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):J==="download-pluginconfig"?(s("Matterbridge","Downloading matterbridge plugins config..."),o("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):J==="download-mjstorage"?(s("Matterbridge","Downloading matter storage..."),o("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):J==="download-backup"?(s("Matterbridge","Downloading backup..."),o("Downloading backup...",10),window.location.href="./api/download-backup"):J==="update"?I():J==="updatedev"?ee():J==="updatecheck"?xe():J==="shelly-sys-update"?Se():J==="shelly-main-update"?U():J==="shelly-create-system-log"?M():J==="shelly-download-system-log"?k():J==="softreset"?N():J==="hardreset"?ae():J==="restart"?w():J==="shutdown"?g():J==="reboot"?d():J==="create-backup"?n({id:S.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):J==="unregister"?n({id:S.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):J==="reset"?n({id:S.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):J==="factoryreset"&&n({id:S.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},ce=J=>{a&&console.log("Header: handleMenuCloseCancel:",J),O(null)},me=J=>{$(J.currentTarget)},ne=()=>{$(null)},be=J=>{Y(J.currentTarget)},se=()=>{Y(null)},ge=J=>{x(J.currentTarget)},K=()=>{x(null)},ue=J=>{D(J.currentTarget)},ve=()=>{D(null)},Ge=()=>{Un(),a&&console.log("Matterbridge logo clicked: debug is now",a)};return r.useEffect(()=>{const J=ie=>{ie.src==="Matterbridge"&&ie.dst==="Frontend"&&(ie.id===S.current&&ie.method==="/api/settings"&&(a&&console.log("Header received settings:",ie.response),V(ie.response),C(ie.response.matterbridgeInformation.restartRequired||ie.response.matterbridgeInformation.fixedRestartRequired),v(ie.response.matterbridgeInformation.fixedRestartRequired),R(ie.response.matterbridgeInformation.updateRequired)),ie.method==="refresh_required"&&(ie.params.changed===null||ie.params.changed==="matterbridgeLatestVersion"||ie.params.changed==="matterbridgeAdvertise"||ie.params.changed==="fabrics")&&(a&&console.log(`Header received refresh_required: changed=${ie.params.changed}`),n({id:S.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),ie.method==="restart_required"&&(a&&console.log(`Header received restart_required with fixed: ${ie.params.fixed}`),C(!0),ie.params.fixed===!0&&v(!0)),ie.method==="restart_not_required"&&(a&&console.log("Header received restart_not_required"),C(!1)),ie.method==="update_required"&&(a&&console.log("Header received update_required"),R(!0)),ie.method==="update_required_dev"&&(a&&console.log("Header received update_required_dev"),T(!0)),ie.id===Me.ShellySysUpdate&&(a&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),V(Fe=>({...Fe,matterbridgeInformation:{...Fe.matterbridgeInformation,shellySysUpdate:ie.params.available}}))),ie.id===Me.ShellyMainUpdate&&(a&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),V(Fe=>({...Fe,matterbridgeInformation:{...Fe.matterbridgeInformation,shellyMainUpdate:ie.params.available}}))))};return h(J),a&&console.log(`Header added WebSocket listener id ${S.current}`),()=>{b(J),a&&console.log("Header removed WebSocket listener")}},[h,b,n,o]),r.useEffect(()=>{i&&(a&&console.log("Header sending /api/settings requests"),n({id:S.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(st,{to:"/",className:"nav-link",children:"Home"}),e.jsx(st,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(st,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(st,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!p.matterbridgeInformation.readOnly&&W&&e.jsx(H,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:I,children:["Update to v.",p.matterbridgeInformation.matterbridgeLatestVersion]})}),!p.matterbridgeInformation.readOnly&&y&&e.jsx(H,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:ee,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:j,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.shellyBoard&&p.matterbridgeInformation.xxxmatterbridgeVersion&&e.jsx(H,{title:"Matterbridge version",children:e.jsxs("span",{style:{fontSize:"12px",color:"var(--main-icon-color)"},onClick:j,children:["v.",p.matterbridgeInformation.matterbridgeVersion]})}),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(z,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:_,children:e.jsx(Cr,{})})}):null,p.matterbridgeInformation.readOnly===!1?e.jsx(H,{title:"Sponsor Matterbridge",children:e.jsx(z,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:X,children:e.jsx(Yt,{})})}):null,e.jsx(H,{title:"Matterbridge help",children:e.jsx(z,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:he,children:e.jsx(Sr,{})})}),e.jsx(H,{title:"Matterbridge changelog",children:e.jsx(z,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:j,children:e.jsx(Xt,{})})}),p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsx(H,{title:"Update matterbridge to latest version",children:e.jsx(z,{style:{color:W?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:I,children:e.jsx($e,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellySysUpdate&&e.jsx(H,{title:"Shelly system update",children:e.jsx(z,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Se,children:e.jsx($e,{})})}),p.matterbridgeInformation&&p.matterbridgeInformation.shellyBoard&&p.matterbridgeInformation.shellyMainUpdate&&e.jsx(H,{title:"Shelly software update",children:e.jsx(z,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:U,children:e.jsx($e,{})})}),e.jsx(H,{title:"Restart matterbridge",children:e.jsx(z,{style:{color:u||L?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:w,children:e.jsx(vt,{})})}),p.matterbridgeInformation.restartMode===""?e.jsx(H,{title:"Shut down matterbridge",children:e.jsx(z,{style:{color:u||L?"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(z,{onClick:le,children:e.jsx(wr,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(tt,{id:"command-menu",anchorEl:F,keepMounted:!0,open:!!F,onClose:()=>q(""),children:[p.matterbridgeInformation&&!p.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>q("update"),children:[e.jsx(Q,{children:e.jsx($e,{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(P,{onClick:()=>q("updatedev"),children:[e.jsx(Q,{children:e.jsx($e,{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(P,{onClick:()=>q("updatecheck"),children:[e.jsx(Q,{children:e.jsx($e,{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(P,{onClick:()=>q("shelly-sys-update"),children:[e.jsx(Q,{children:e.jsx($e,{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(P,{onClick:()=>q("shelly-main-update"),children:[e.jsx(Q,{children:e.jsx($e,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>q("restart"),children:[e.jsx(Q,{children:e.jsx(vt,{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(P,{onClick:()=>q("shutdown"),children:[e.jsx(Q,{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(P,{onClick:()=>{c("Reboot","Are you sure you want to reboot the Shelly board?","reboot",q,ce)},children:[e.jsx(Q,{children:e.jsx(vt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(lt,{}),e.jsxs(P,{onClick:be,children:[e.jsx(Q,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(tt,{id:"sub-menu-view",anchorEl:B,keepMounted:!0,open:!!B,onClose:se,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{q("view-mblog"),se()},children:[e.jsx(Q,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("view-mjlog"),se()},children:[e.jsx(Q,{children:e.jsx(dt,{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(P,{onClick:()=>{q("view-shellylog"),se()},children:[e.jsx(Q,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(lt,{}),e.jsxs(P,{onClick:ge,children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(tt,{id:"sub-menu-download",anchorEl:l,keepMounted:!0,open:!!l,onClose:K,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{q("download-mbstorage"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-pluginstorage"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-pluginconfig"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-mblog"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-mjstorage"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-mjlog"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{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(P,{onClick:()=>{q("shelly-create-system-log"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{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(P,{onClick:()=>{q("shelly-download-system-log"),K()},children:[e.jsx(Q,{children:e.jsx(Re,{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(lt,{}),e.jsxs(P,{onClick:me,children:[e.jsx(Q,{children:e.jsx(Dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(tt,{id:"sub-menu-backup",anchorEl:E,keepMounted:!0,open:!!E,onClose:ne,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{q("create-backup"),ne()},children:[e.jsx(Q,{children:e.jsx(Dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{q("download-backup"),ne()},children:[e.jsx(Q,{children:e.jsx(Dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(lt,{}),e.jsxs(P,{onClick:ue,children:[e.jsx(Q,{children:e.jsx(Mr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(tt,{id:"sub-menu-reset",anchorEl:f,keepMounted:!0,open:!!f,onClose:ve,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{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",q,ce)},children:[e.jsx(Q,{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(P,{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",q,ce)},children:[e.jsx(Q,{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(P,{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",q,ce)},children:[e.jsx(Q,{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(P,{onClick:()=>{ve(),c("Network reset","Are you sure you want to factory reset the network parameters?","softreset",q,ce)},children:[e.jsx(Q,{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(P,{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",q,ce)},children:[e.jsx(Q,{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 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 Bo(){const{messages:o,autoScroll:c}=r.useContext(or),[i,n]=r.useState(!1),s=r.useRef(null),h=r.useMemo(()=>qo(),[]),b=u=>n(!0),t=u=>n(!1);return r.useEffect(()=>{a&&console.log(`WebSocketLogs autoScroll: ${c} isHovering: ${i}`),c&&!i&&!h&&s.current?.scrollIntoView({behavior:"smooth"})},[o,i,c,h]),e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:b,onMouseLeave:t,children:[o.map((u,C)=>e.jsx("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},dangerouslySetInnerHTML:{__html:u}},C)),e.jsx("div",{ref:s})]})})}const nr=r.memo(Bo);function Je(){const{retry:o}=r.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(Z,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:o<100?e.jsxs(e.Fragment,{children:[e.jsx(kr,{style:{color:"var(--primary-color)"}}),e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)"},children:["Reconnecting to Matterbridge ","(attempt "+o+")","..."]})]}):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 Jo({value:o,maxChars:c}){let i=o;if(o.length>c&&c>3){const n=c-3,s=o.substring(0,Math.ceil(n/2)),h=o.substring(o.length-Math.floor(n/2),o.length);i=`${s} … ${h}`}return o!==i?e.jsx(H,{title:o,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:i})}):e.jsx("span",{children:i})}function Go({systemInfo:o,compact:c}){const[i,n]=r.useState(o),{sendMessage:s,addListener:h,removeListener:b}=r.useContext(fe);if(a&&console.log("SystemInfoTable:",i,"compact:",c),o&&c&&i.totalMemory&&i.freeMemory){const t=i.totalMemory,u=i.freeMemory;i.freeMemory=`${u} / ${t}`,i.totalMemory=""}if(o&&c&&i.heapTotal&&i.heapUsed){const t=i.heapTotal,u=i.heapUsed;i.heapUsed=`${u} / ${t}`,i.heapTotal=""}if(o&&c&&i.osRelease&&i.osType){const t=i.osType,u=i.osRelease;i.osType=`${t} (${u})`,i.osRelease=""}if(o&&c&&i.osArch&&i.osPlatform){const t=i.osPlatform,u=i.osArch;i.osPlatform=`${t} (${u})`,i.osArch=""}return r.useEffect(()=>{const t=u=>{u.src==="Matterbridge"&&u.dst==="Frontend"&&(u.method==="memory_update"&&u.params&&u.params.totalMemory&&u.params.freeMemory&&u.params.heapTotal&&u.params.heapUsed&&u.params.rss&&(a&&console.log("SystemInfoTable received memory_update",u),(i.totalMemory!==u.params?.totalMemory||i.freeMemory!==u.params?.freeMemory||i.heapTotal!==u.params?.heapTotal||i.heapUsed!==u.params?.heapUsed||i.rss!==u.params?.rss)&&n(C=>({...C,totalMemory:u.params?.totalMemory?u.params.totalMemory:"",freeMemory:u.params?.freeMemory?u.params.freeMemory:"",heapTotal:u.params?.heapTotal?u.params.heapTotal:"",heapUsed:u.params?.heapUsed?u.params.heapUsed:"",rss:u.params?.rss?u.params.rss:""}))),u.method==="cpu_update"&&u.params&&u.params.cpuUsage&&(a&&console.log("SystemInfoTable received cpu_update",u),i.cpuUsage!==(u.params?.cpuUsage?u.params.cpuUsage.toFixed(2)+" %":"")&&n(C=>({...C,cpuUsage:u.params?.cpuUsage?u.params.cpuUsage.toFixed(2)+" %":""}))),u.method==="uptime_update"&&u.params&&u.params.systemUptime&&u.params.processUptime&&(a&&console.log("SystemInfoTable received uptime_update",u),(i.systemUptime!==u.params?.systemUptime||i.processUptime!==u.params?.processUptime)&&n(C=>({...C,systemUptime:u.params?.systemUptime?u.params.systemUptime:"",processUptime:u.params?.processUptime?u.params.processUptime:""}))))};return a&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),h(t),a&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{a&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),b(t),a&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[h,i.cpuUsage,i.freeMemory,i.heapTotal,i.heapUsed,i.processUptime,i.rss,i.systemUptime,i.totalMemory,b,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,u])=>u!==void 0&&u!=="").map(([t,u],C)=>e.jsxs("tr",{className:C%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(Jo,{value:typeof u!="string"?u.toString():u,maxChars:25})})]},t))})})})]})):null}const Qo=r.memo(Go),qt={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"}},Ko=o=>{if(!o)return"";const c=o.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 Yo({id:o}){const{online:c,sendMessage:i,addListener:n,removeListener:s}=r.useContext(fe),[h,b]=r.useState(null),[t,u]=r.useState(null),C=r.useRef(null);r.useEffect(()=>{a&&console.log(`QRDiv received storeId update "${o}"`),o&&(a&&console.log(`QRDiv sending data request for storeId "${o}"`),b(o),i({method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:o,server:!0}}))},[o]),r.useEffect(()=>{const T=p=>{p.src==="Matterbridge"&&p.dst==="Frontend"&&p.method==="refresh_required"&&p.params.changed==="matter"&&p.params.matter&&(a&&console.log(`QRDiv received refresh_required/matter for storeId "${p.params.matter.id}":`,p.params.matter),h===p.params.matter.id&&(a&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${p.params.matter.id}":`,p.params.matter),clearTimeout(C.current),p.params.matter.advertising&&p.params.matter.advertiseTime&&p.params.matter.advertiseTime+9e5<=Date.now()&&(p.params.matter.advertising=!1),u(p.params.matter),p.params.matter.advertising&&(a&&console.log(`QRDiv setting matter advertise timeout for storeId "${p.params.matter.id}":`,p.params.matter.advertiseTime+9e5-Date.now()),C.current=setTimeout(()=>{clearTimeout(C.current),a&&console.log(`QRDiv clearing advertising state for storeId "${p.params.matter.id}" after 15 minutes`),u(V=>({...V,advertising:!1}))},p.params.matter.advertiseTime+9e5-Date.now()))))};return n(T),a&&console.log("QRDiv webSocket effect mounted"),()=>{s(T),clearTimeout(C.current),a&&console.log("QRDiv webSocket effect unmounted")}},[h]);const L=()=>{a&&console.log(`QRDiv sent matter startCommission for node "${t.id}"`),t&&i({method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:t.id,startCommission:!0}})},v=()=>{a&&console.log(`QRDiv sent matter stopCommission for node "${t.id}"`),t&&i({method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:t.id,stopCommission:!0}})},W=()=>{a&&console.log(`QRDiv sent matter advertise for node "${t.id}"`),t&&i({method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:t.id,advertise:!0}})},R=T=>{a&&console.log(`QRDiv sent matter removeFabric for node "${t.id}" and fabricIndex ${T}`),t&&i({method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:t.id,removeFabric:T}})},y=async()=>{if(!t||!t.manualPairingCode)return;const T=t.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(T);else{const p=document.createElement("textarea");p.value=T,p.style.position="fixed",p.style.opacity="0",document.body.appendChild(p),p.focus(),p.select(),document.execCommand("copy"),document.body.removeChild(p)}a&&console.log("Manual pairing code copied to clipboard")}catch(p){console.error("Failed to copy manual pairing code",p)}};return!t||!c?(a&&console.log("QRDiv rendering undefined state"),null):t.advertising&&t.qrPairingCode&&t.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(z,{"aria-label":"send advertising",size:"small",onClick:W,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:_t,size:"22px"})})}),e.jsx(z,{"aria-label":"stop pairing",size:"small",onClick:v,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:po,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:h}),e.jsx(co,{value:t.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: ",Ko(t.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(H,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(z,{"aria-label":"copy manual pairing code",size:"small",onClick:y,sx:qt,children:e.jsx(te,{path:uo,size:.85})})})})]})]})):t.commissioned&&t.fabricInformations&&t.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(z,{"aria-label":"send advertising",size:"small",onClick:W,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:_t,size:"22px"})})}),e.jsx(z,{"aria-label":"start pairing",size:"small",onClick:L,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:At,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:h}),t.fabricInformations.map((T,p)=>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: ",T.fabricIndex]}),e.jsx(H,{title:"Remove the fabric. You will need to remove it also from the controller.",arrow:!0,children:e.jsx(z,{"aria-label":"remove the fabric",size:"small",onClick:()=>R(T.fabricIndex),sx:{...qt,padding:"2px"},children:e.jsx(te,{path:mo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",T.rootVendorId," ",T.rootVendorName]}),T.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",T.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",t.sessionInformations?t.sessionInformations.filter(V=>V.fabric.fabricIndex===T.fabricIndex&&V.isPeerActive===!0).length:"0"," ","subscriptions: ",t.sessionInformations?t.sessionInformations.filter(V=>V.fabric.fabricIndex===T.fabricIndex&&V.isPeerActive===!0&&V.numberOfActiveSubscriptions>0).length:"0"]})]},p))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",t.serialNumber]})})]})):!t.commissioned&&!t.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:h}),e.jsx(oe,{onClick:L,endIcon:e.jsx(te,{path:At,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: ",t.serialNumber]})})]})):(a&&console.log("QRDiv rendering unknown state"),null)}const Xo=r.memo(Yo);function Zo(){const{logMessage:o,sendMessage:c,getUniqueId:i}=r.useContext(fe),[n,s]=r.useState("matterbridge-"),[h,b]=r.useState(!1),[t,u]=r.useState(null),C=r.useRef(i()),L=F=>{F.preventDefault(),b(!0)},v=()=>{b(!1)},W=F=>{F.preventDefault(),b(!1);const O=F.dataTransfer.files[0];if(O){o("Plugins",`Installing package ${O.name}. Please wait...`);const E=new FormData;E.append("file",O),E.append("filename",O.name),fetch("./api/uploadpackage",{method:"POST",body:E}).then($=>$.text()).then($=>{o("Plugins",`Server response: ${$}`)}).catch($=>{console.error("Error uploading plugin file:",$),o("Plugins",`Error installing package ${$}`)})}},R=F=>{const O=F.target.files&&F.target.files[0];if(O){o("Plugins",`Uploading package ${O.name}`);const E=new FormData;E.append("file",O),E.append("filename",O.name),fetch("./api/uploadpackage",{method:"POST",body:E}).then($=>$.text()).then($=>{o("Plugins",`Server response: ${$}`)}).catch($=>{console.error("Error uploading plugin file:",$),o("Plugins",`Error uploading package ${$}`)})}},y=()=>{c({id:C.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n,restart:!1}})},T=()=>{document.getElementById("file-upload")?.click()},p=()=>{c({id:C.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:n}})},V=F=>{u(F.currentTarget)},S=F=>{F!==""&&s(F),u(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:L,onDragLeave:v,onDrop:W,children:[e.jsx(pe,{value:n,onChange:F=>{s(F.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(z,{onClick:V,children:e.jsx(Ir,{})}),e.jsxs(tt,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>S(""),children:[e.jsx(P,{onClick:()=>S("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(P,{onClick:()=>S("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(P,{onClick:()=>S("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(P,{onClick:()=>S("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(P,{onClick:()=>S("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(P,{onClick:()=>S("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(P,{onClick:()=>S("matterbridge-test"),children:"matterbridge-test"}),e.jsx(P,{onClick:()=>S("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(P,{onClick:()=>S("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(P,{onClick:()=>S("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(P,{onClick:()=>S("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(P,{onClick:()=>S("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(P,{onClick:()=>S("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(P,{onClick:()=>S("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(H,{title:"Install or update a plugin from npm",children:e.jsx(oe,{onClick:y,endIcon:e.jsx(Re,{}),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:T,endIcon:e.jsx(Dr,{}),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(yt,{}),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:R})]})}function Xe({status:o,enabledText:c="Enabled",disabledText:i=void 0,tooltipText:n=void 0,onClick:s}){if(o===void 0)return e.jsx("div",{style:{margin:"-2.5px"},children:e.jsx("div",{})});{const h=e.jsx("div",{className:o?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:o?c:i??c});return n!==void 0?e.jsx(H,{title:n,children:h}):h}}const Ze={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},et={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},en={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},tn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Ve={padding:"0px",margin:"0px"},rn="5px 10px 5px 10px",ht={},je={},xt={},ft={};let bt=[],Bt=[];const on=({open:o,onClose:c,plugin:i})=>{const{sendMessage:n,addListener:s,removeListener:h,getUniqueId:b}=r.useContext(fe),t=r.useRef(b()),[u,C]=r.useState(i.configJson),[L,v]=r.useState(i.schemaJson),[W,R]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[y,T]=r.useState("");let p={};r.useEffect(()=>{const M=k=>{k.src==="Matterbridge"&&k.dst==="Frontend"&&(k.id===t.current&&k.method==="/api/select/devices"&&(k.response&&(bt=k.response),k.error&&console.error("ConfigPluginDialog received /api/select/devices error:",k.error)),k.id===t.current&&k.method==="/api/select/entities"&&(k.response&&(Bt=k.response),k.error&&console.error("ConfigPluginDialog received /api/select/entities error:",k.error)))};return s(M),u!==void 0&&L!==void 0&&(Object.keys(L.properties).forEach(k=>{Object.keys(L.properties[k]).forEach(w=>{w.startsWith("ui:")&&(W[k]={},W[k][w]=L.properties[k][w],delete L.properties[k][w])})}),R(W)),i.name!==void 0&&i.configJson!==void 0&&i.schemaJson!==void 0&&(C(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}})),()=>{h(M)}},[s,u,i,h,L,n,W]);const V=({formData:M})=>{p=M},S=({formData:M})=>{C(M),i.configJson=M,i.restartRequired=!0,n({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:M.name,formData:M}}),c()};function F(M){const{id:k,label:w,onKeyChange:g,onDropPropertyClick:d,disabled:N,schema:ae,children:le,registry:q,readonly:ce,required:me}=M,{templates:ne}=q,{RemoveButton:be}=ne.ButtonTemplates;if(!($o in ae))return e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:le});const ge=({target:K})=>g(K&&K.value);return e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(pe,{id:`${k}-key`,name:`${k}-key`,required:me,disabled:N||ce,defaultValue:w,onBlur:ce?void 0:ge,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Z,{sx:{flex:1},children:le}),e.jsx(be,{disabled:N||ce,onClick:d(w)})]})}function O(M){const{children:k,description:w,displayLabel:g,errors:d,help:N,hidden:ae,_id:le,_label:q,registry:ce,uiSchema:me}=M,ne=Vo(me),be=Eo("WrapIfAdditionalTemplate",ce,ne);return ae?e.jsx("div",{style:{display:"none"},children:k}):e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(be,{...M,children:[g===!0&&w,k,d,N]})})}function E(M){const{description:k}=M;return k?e.jsx(de,{sx:et,children:k}):null}function $(M){const{required:k,title:w}=M;return w?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(de,{sx:Ze,children:["Title ",w," ",k&&e.jsx("mark",{children:"***"})]})}):null}function B(M){const{help:k,_idSchema:w}=M;return k?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(de,{sx:en,children:k})}):null}function Y(M){const{errors:k}=M;return k?e.jsxs(Z,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(de,{color:"error",sx:tn,children:"Please fix the following errors:"}),e.jsx(nt,{children:k.map((w,g)=>e.jsxs(Nr,{children:[e.jsx(Q,{children:e.jsx(Pr,{color:"error"})}),e.jsx(re,{primary:w.stack})]},g))})]}):null}function l(M){const{errors:k}=M;return k?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:k.map((w,g)=>e.jsxs(de,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",w]},g))}):null}function x(M){const{id:k,name:w,_schema:g,_uiSchema:d,value:N,options:ae,label:le,type:q,placeholder:ce,required:me,disabled:ne,readonly:be,autofocus:se,onChange:ge,onChangeOverride:K,onBlur:ue,onFocus:ve,_rawErrors:Ge,_hideError:J,_registry:ie,_formContext:Fe}=M,Le=({target:{value:ye}})=>ge(ye===""?ae.emptyValue:ye),He=({target:ye})=>ue(k,ye&&ye.value),Ue=({target:ye})=>ve(k,ye&&ye.value);return e.jsx(Z,{sx:{padding:"0px",margin:"0px"},children:e.jsx(pe,{id:k,name:k,label:ce&&ce!==""?le:void 0,variant:"outlined",placeholder:ce&&ce!==""?ce:le,required:me,disabled:ne||be,autoFocus:se,value:N||N===0?N:"",type:q,autoComplete:q==="password"?"current-password":w,onChange:K||Le,onBlur:He,onFocus:Ue,fullWidth:!0})})}function f(M){return console.log("ArrayFieldTitleTemplate:",M),null}function D(M){return console.log("ArrayFieldDescriptionTemplate:",M),null}function X(M){return console.log("ArrayFieldItemTemplate:",M),null}function he(M){const{canAdd:k,_className:w,_disabled:g,_formContext:d,_formData:N,_idSchema:ae,_items:le,onAddClick:q,_rawErrors:ce,_readonly:me,_registry:ne,_required:be,schema:se,title:ge,_uiSchema:K}=M,[ue,ve]=r.useState(!1),[Ge,J]=r.useState(!1),[ie,Fe]=r.useState(!1),[Le,He]=r.useState(""),Ue=A=>{He(A.target.value)},ye=()=>{ve(!ue)},Qe=()=>{J(!Ge)},Ke=()=>{Fe(!ie)},wt=A=>{ve(!1),se.selectFrom==="serial"?se.items.default=A.serial:se.selectFrom==="name"&&(se.items.default=A.name),q()},Mt=A=>{J(!1),se.selectEntityFrom==="name"?se.items.default=A.name:se.selectEntityFrom==="description"&&(se.items.default=A.description),q()},kt=A=>{Fe(!1),se.selectDeviceEntityFrom==="name"?se.items.default=A.name:se.selectDeviceEntityFrom==="description"&&(se.items.default=A.description),q()};return e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[ge&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ge&&e.jsx(de,{sx:Ze,children:ge}),k&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[se.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(z,{onClick:ye,size:"small",color:"primary",sx:Ve,children:e.jsx(ct,{})})}),se.selectEntityFrom&&e.jsx(H,{title:"Add an entity from the list",children:e.jsx(z,{onClick:Qe,size:"small",color:"primary",sx:Ve,children:e.jsx(ct,{})})}),se.selectDeviceEntityFrom&&e.jsx(H,{title:"Add a device entity from the list",children:e.jsx(z,{onClick:Ke,size:"small",color:"primary",sx:Ve,children:e.jsx(ct,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(z,{onClick:q,size:"small",color:"primary",sx:Ve,children:e.jsx(yt,{})})})]})]}),se.description&&e.jsx(de,{sx:et,children:se.description}),M.items.map(A=>e.jsxs(Z,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Z,{sx:{flexGrow:1,marginRight:"10px"},children:A.children}),e.jsx(z,{disabled:!A.hasMoveUp,onClick:A.onReorderClick(A.index,A.index-1),size:"small",color:"primary",sx:Ve,children:e.jsx(Ht,{})}),e.jsx(z,{disabled:!A.hasMoveDown,onClick:A.onReorderClick(A.index,A.index+1),size:"small",color:"primary",sx:Ve,children:e.jsx(Lt,{})}),e.jsx(z,{onClick:A.onDropIndexClick(A.index),size:"small",color:"primary",sx:Ve,children:e.jsx(Ct,{})})]},A.index)),e.jsxs(Ie,{open:ue,onClose:ye,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(De,{children:"Select a device"}),e.jsxs(Ne,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(de,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:Le,onChange:Ue,placeholder:"Enter serial or name"})]}),e.jsx(nt,{dense:!0,children:bt.filter(A=>A.serial.toLowerCase().includes(Le.toLowerCase())||A.name.toLowerCase().includes(Le.toLowerCase())).map((A,we)=>e.jsxs(pt,{onClick:()=>wt(A),sx:ht,children:[A.icon==="wifi"&&e.jsx(Q,{children:e.jsx(it,{style:je})}),A.icon==="ble"&&e.jsx(Q,{children:e.jsx(ut,{style:je})}),A.icon==="hub"&&e.jsx(Q,{children:e.jsx(mt,{style:je})}),e.jsx(re,{primary:A.name,secondary:A.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:ft}})]},we))})]}),e.jsx(Pe,{children:e.jsx(oe,{onClick:ye,children:"Close"})})]}),e.jsxs(Ie,{open:Ge,onClose:Qe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(De,{children:"Select an entity"}),e.jsxs(Ne,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(de,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:Le,onChange:Ue,placeholder:"Enter name or description"})]}),e.jsx(nt,{dense:!0,children:Bt.filter(A=>A.name.toLowerCase().includes(Le.toLowerCase())||A.description.toLowerCase().includes(Le.toLowerCase())).map((A,we)=>e.jsxs(pt,{onClick:()=>Mt(A),sx:ht,children:[A.icon==="wifi"&&e.jsx(Q,{children:e.jsx(it,{style:je})}),A.icon==="ble"&&e.jsx(Q,{children:e.jsx(ut,{style:je})}),A.icon==="hub"&&e.jsx(Q,{children:e.jsx(mt,{style:je})}),A.icon==="component"&&e.jsx(Q,{children:e.jsx(Rt,{style:je})}),A.icon==="matter"&&e.jsx(Q,{children:e.jsx(Ot,{style:je})}),e.jsx(re,{primary:A.name,secondary:A.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:ft}})]},we))})]}),e.jsx(Pe,{children:e.jsx(oe,{onClick:Qe,children:"Close"})})]}),e.jsxs(Ie,{open:ie,onClose:Ke,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(De,{children:["Select an entity for ",ge]}),e.jsx(Ne,{children:e.jsx(nt,{dense:!0,children:bt.filter(A=>A.serial===ge||A.name===ge).map(A=>A.entities?.map((we,It)=>e.jsxs(pt,{onClick:()=>kt(we),sx:ht,children:[we.icon==="wifi"&&e.jsx(Q,{children:e.jsx(it,{style:je})}),we.icon==="ble"&&e.jsx(Q,{children:e.jsx(ut,{style:je})}),we.icon==="hub"&&e.jsx(Q,{children:e.jsx(mt,{style:je})}),we.icon==="component"&&e.jsx(Q,{children:e.jsx(Rt,{style:je})}),we.icon==="matter"&&e.jsx(Q,{children:e.jsx(Ot,{style:je})}),e.jsx(re,{primary:we.name,secondary:we.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:ft}})]},It)))})}),e.jsx(Pe,{children:e.jsx(oe,{onClick:Ke,children:"Close"})})]})]})}function j(M){const{onAddClick:k,schema:w,properties:g,title:d,description:N}=M,[ae,le]=r.useState(!1),[q,ce]=r.useState(""),me=K=>{ce(K.target.value)},ne=()=>{le(!ae)},be=K=>{le(!1);let ue="";w.selectFrom==="serial"?ue=K.serial:w.selectFrom==="name"&&(ue=K.name),T(ue),k(w)()},se=()=>{k(w)()},ge=!w.additionalProperties;return!ge&&y!==""&&g.forEach(K=>{if(K.name==="newKey"&&K.content.key==="newKey"&&K.content.props.name==="newKey"&&K.content.props.onKeyChange&&y!==""){const ue=y;T(""),K.content.props.onKeyChange(ue)}}),e.jsxs(Z,{sx:{margin:"0px",padding:ge?"10px":"5px 10px 0px 10px",border:ge?"none":"1px solid grey"},children:[w.title&&ge&&e.jsx(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(de,{sx:Ze,children:w.title})}),d&&!ge&&e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(de,{sx:Ze,children:d}),e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[w.selectFrom&&e.jsx(H,{title:"Add a device from the list",children:e.jsx(z,{onClick:ne,size:"small",color:"primary",sx:Ve,children:e.jsx(ct,{})})}),e.jsx(H,{title:"Add a new item",children:e.jsx(z,{onClick:se,size:"small",color:"primary",sx:Ve,children:e.jsx(yt,{})})})]})]}),w.description&&e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(de,{sx:et,children:w.description})}),g.map(({content:K,name:ue,hidden:ve})=>!ve&&e.jsxs(Z,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(w.properties[ue].type)?"0px":rn,border:["object","array","boolean"].includes(w.properties[ue].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(w.properties[ue].type)&&e.jsx(de,{sx:Ze,children:ue}),e.jsx(Z,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:K})]},ue)),e.jsxs(Ie,{open:ae,onClose:ne,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(De,{children:"Select a device"}),e.jsxs(Ne,{children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(de,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{fullWidth:!0,variant:"outlined",value:q,onChange:me,placeholder:"Enter serial or name"})]}),e.jsx(nt,{dense:!0,children:bt.filter(K=>K.serial.toLowerCase().includes(q.toLowerCase())||K.name.toLowerCase().includes(q.toLowerCase())).map((K,ue)=>e.jsxs(pt,{onClick:()=>be(K),sx:ht,children:[K.icon==="wifi"&&e.jsx(Q,{children:e.jsx(it,{style:je})}),K.icon==="ble"&&e.jsx(Q,{children:e.jsx(ut,{style:je})}),K.icon==="hub"&&e.jsx(Q,{children:e.jsx(mt,{style:je})}),e.jsx(re,{primary:K.name,secondary:K.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:ft}})]},ue))})]}),e.jsx(Pe,{children:e.jsx(oe,{onClick:ne,children:"Close"})})]})]})}function m(M){const{uiSchema:k}=M,{submitText:w,norender:g}=Oo(k);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:w}),e.jsx(oe,{variant:"contained",color:"primary",onClick:c,children:"Cancel"})]})}function _(M){const{className:k,disabled:w,onClick:g,registry:d,style:N,uiSchema:ae,...le}=M;return e.jsx(H,{title:"Remove the item",children:e.jsx(z,{disabled:w,size:"small",color:"primary",onClick:g,children:e.jsx(Ct,{})})})}function I(M){const{className:k,disabled:w,onClick:g,registry:d,uiSchema:N,...ae}=M;return e.jsx(H,{title:"Add an item",children:e.jsx(z,{size:"small",color:"primary",onClick:g,children:e.jsx(yt,{})})})}function ee(M){const{disabled:k,onClick:w,registry:g,style:d,uiSchema:N,...ae}=M;return e.jsx(H,{title:"Move up the item",children:e.jsx(z,{size:"small",color:"primary",onClick:w,children:e.jsx(Ht,{})})})}function xe(M){const{disabled:k,onClick:w,registry:g,style:d,uiSchema:N,...ae}=M;return e.jsx(H,{title:"Move down the item",children:e.jsx(z,{size:"small",color:"primary",onClick:w,children:e.jsx(Lt,{})})})}function Se(M){const{id:k,name:w,value:g,schema:d,readonly:N,onChange:ae}=M,[le,q]=r.useState(void 0),ce=ne=>{q(ne&&ne!==""?ne:void 0)},me=()=>{n({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:i.name,action:w,value:le,formData:p,id:k}}),d.buttonClose===!0?c():d.buttonSave===!0&&S({formData:u})};return d.buttonText&&d.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(de,{sx:et,children:d.description}),e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>me(),children:d.buttonText})]}):d.buttonField&&d.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(de,{sx:et,children:d.description}),e.jsx(pe,{id:w+"-input",name:w,label:d.textLabel,placeholder:d.textPlaceholder,onChange:ne=>ce(ne.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(oe,{id:w+"-button",variant:"contained",color:"primary",disabled:le===void 0,onClick:()=>me(),children:d.buttonField})]}):e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[w&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(de,{sx:Ze,children:w}),e.jsx(We,{checked:g,readOnly:N,onChange:()=>ae(!g),sx:{padding:"0px",margin:"0px"}})]}),d.description&&e.jsx(de,{sx:et,children:d.description})]})}function U({schema:M,id:k,name:w,options:g,label:d,hideLabel:N,required:ae,disabled:le,placeholder:q,readonly:ce,value:me,multiple:ne,autofocus:be,onChange:se,onBlur:ge,onFocus:K,errorSchema:ue,rawErrors:ve=[],registry:Ge,uiSchema:J,hideError:ie,formContext:Fe,...Le}){const{enumOptions:He,enumDisabled:Ue,emptyValue:ye}=g;ne=typeof ne>"u"?!1:!!ne;const Qe=ne?[]:"",Ke=typeof me>"u"||ne&&me.length<1||!ne&&me===Qe,wt=({target:{value:Oe}})=>se(Nt(Oe,He,ye)),Mt=({target:Oe})=>ge(k,Nt(Oe&&Oe.value,He,ye)),kt=({target:Oe})=>K(k,Nt(Oe&&Oe.value,He,ye)),A=Ho(me,He,ne),{InputLabelProps:we,SelectProps:It,autocomplete:dr,...cr}=Le,pr=!ne&&M.default===void 0;return e.jsxs(pe,{id:k,name:k,value:!Ke&&typeof A<"u"?A:Qe,required:ae,disabled:le||ce,autoFocus:be,autoComplete:dr,placeholder:q,error:ve.length>0,onChange:wt,onBlur:Mt,onFocus:kt,...cr,select:!0,InputLabelProps:{...we,shrink:!Ke},SelectProps:{...It,multiple:ne},"aria-describedby":Ro(k),children:[pr&&e.jsx(P,{value:"",children:q}),Array.isArray(He)&&He.map(({value:Oe,label:ur},Ft)=>{const mr=Array.isArray(Ue)&&Ue.indexOf(Oe)!==-1;return e.jsx(P,{value:String(Ft),disabled:mr,children:ur},Ft)})]})}return!o||!L||!u?null:e.jsxs(Ie,{open:o,onClose:c,maxWidth:"800px",children:[e.jsx(De,{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(Ne,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Fo,{schema:L,formData:u,uiSchema:W,validator:Lo,templates:{FieldTemplate:O,BaseInputTemplate:x,TitleFieldTemplate:$,DescriptionFieldTemplate:E,FieldHelpTemplate:B,FieldErrorTemplate:l,ErrorListTemplate:Y,WrapIfAdditionalTemplate:F,ArrayFieldTitleTemplate:f,ArrayFieldDescriptionTemplate:D,ArrayFieldItemTemplate:X,ArrayFieldTemplate:he,ObjectFieldTemplate:j,ButtonTemplates:{SubmitButton:m,RemoveButton:_,AddButton:I,MoveUpButton:ee,MoveDownButton:xe}},widgets:{CheckboxWidget:Se,SelectWidget:U},onChange:V,onSubmit:S})})]})};function nn({data:o,columns:c,columnVisibility:i}){const n=Ee.useMemo(()=>c.filter(C=>i[C.accessor]),[c,i]),{getTableProps:s,getTableBodyProps:h,headerGroups:b,rows:t,prepareRow:u}=Ae.useTable({columns:n,data:o},Ae.useSortBy);return e.jsxs("table",{...s(),style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{border:"none",borderCollapse:"collapse"},children:b.map(C=>e.jsx("tr",{...C.getHeaderGroupProps(),style:{border:"none",borderCollapse:"collapse"},children:C.headers.map(L=>e.jsx("th",{...L.getHeaderProps(void 0),style:{border:"none",borderCollapse:"collapse",cursor:L.noSort?"default":"pointer"},children:L.render("Header")}))}))}),e.jsx("tbody",{...h(),style:{border:"none",borderCollapse:"collapse"},children:t.map((C,L)=>(u(C),e.jsx("tr",{className:L%2===0?"table-content-even":"table-content-odd",...C.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:C.cells.map(v=>e.jsx("td",{...v.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:v.render("Cell")}))},L)))})]})}function an({_storeId:o,setStoreId:c}){const{online:i,sendMessage:n,addListener:s,removeListener:h,getUniqueId:b}=r.useContext(fe),{showConfirmCancelDialog:t}=r.useContext(ot),u=r.useRef(b()),[C,L]=r.useState(null),[v,W]=r.useState(null),[R,y]=r.useState([]),[T,p]=r.useState(!1),[V,S]=r.useState({name:!0,description:!0,version:!0,author:!0,type:!0,registeredDevices:!0,actions:!0,status:!0}),F=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 N=0,ae=0;for(const le of d.matter.sessionInformations??[])le.fabric&&le.isPeerActive===!0&&N++,le.numberOfActiveSubscriptions>0&&(ae+=le.numberOfActiveSubscriptions);return d.matter.commissioned===!0&&d.matter.fabricInformations&&d.matter.sessionInformations&&(N===0||ae===0)?"var(--secondary-color)":"var(--div-text-color)"},O=[{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:()=>f(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:()=>D(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(z,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:F(d.original)},onClick:()=>c(d.original?.matter?.id),size:"small",children:e.jsx(Zt,{})})}),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(z,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>he(d.original),size:"small",children:e.jsx(vt,{})})}),e.jsx(H,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{disabled:d.original.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>k(d.original),size:"small",children:e.jsx(Be,{})})}),v&&!v.readOnly&&e.jsx(H,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{Y("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(Ct,{})})}),d.original.enabled?e.jsx(H,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{Y("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(Tr,{})})}):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(z,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>j(d.original),size:"small",children:e.jsx(Wr,{})})}),e.jsx(H,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>I(d.original),size:"small",children:e.jsx(Fr,{})})}),e.jsx(H,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>ee(d.original),size:"small",children:e.jsx(Lr,{})})}),v&&!v.readOnly&&e.jsx(H,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>_(d.original),size:"small",children:e.jsx(Yt,{})})})]})},{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(Xe,{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(Xe,{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(Xe,{status:d.original.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Xe,{status:d.original.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Xe,{status:d.original.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Xe,{status:d.original.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const d=N=>{N.src==="Matterbridge"&&N.dst==="Frontend"&&(N.method==="refresh_required"&&(N.params.changed==="plugins"||N.params.changed==="fabrics"||N.params.changed==="sessions"||N.params.changed==="pluginsRestart")&&(a&&console.log("HomePlugins received refresh_required for",N.params.changed),n({id:u.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),N.method==="refresh_required"&&N.params.changed==="settings"&&(a&&console.log("HomePlugins received refresh_required for",N.params.changed),n({id:u.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),N.id===u.current&&N.method==="/api/settings"&&(a&&console.log(`HomePlugins (id: ${N.id}) received settings:`,N.response),L(N.response.systemInformation),W(N.response.matterbridgeInformation)),N.id===u.current&&N.method==="/api/plugins"&&(a&&console.log(`HomePlugins (id: ${N.id}) received ${N.response.length} plugins:`,N.response),y(N.response)))};return s(d),a&&console.log("HomePlugins added WebSocket listener id:",u.current),()=>{h(d),a&&console.log("HomePlugins removed WebSocket listener")}},[s,h,n]),r.useEffect(()=>{i&&(a&&console.log("HomePlugins sending api requests"),n({id:u.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:u.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),r.useEffect(()=>{const d=localStorage.getItem("homePluginsColumnVisibility");d&&S(JSON.parse(d))},[]);const E=()=>{p(!T)},$=d=>{S(N=>{const ae={...N,[d]:!N[d]};return localStorage.setItem("homePluginsColumnVisibility",JSON.stringify(ae)),ae})},B=r.useRef(null),Y=(d,N,ae,le)=>{a&&console.log(`handleActionWithConfirmCancel ${ae} ${le.name}`),B.current=le,t(d,N,ae,l,x)},l=d=>{a&&console.log(`handleConfirm action confirmed ${d} ${B.current.name}`),d==="remove"&&B.current?X(B.current):d==="disable"&&B.current&&j(B.current),B.current=null},x=d=>{a&&console.log(`handleCancel action canceled ${d} ${B.current.name}`),B.current=null},f=d=>{a&&console.log("handleUpdatePlugin plugin:",d.name),n({id:u.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:d.name,restart:!1}})},D=d=>{a&&console.log("handleUpdateDevPlugin plugin:",d.name),n({id:u.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:d.name+"@dev",restart:!1}})},X=d=>{a&&console.log("handleRemovePlugin plugin:",d.name),n({id:u.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})},he=d=>{a&&console.log("handleRestartPlugin plugin:",d.name),n({id:u.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})},j=d=>{a&&console.log("handleEnableDisablePlugin plugin:",d.name,"enabled:",d.enabled),d.enabled===!0?(d.enabled=!1,n({id:u.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:d.name}})):(d.enabled=!0,n({id:u.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")},I=d=>{a&&console.log("handleHelpPlugin plugin:",d.name,"help:",d.help),d.help&&window.open(d.help,"_blank")},ee=d=>{a&&console.log("handleChangelogPlugin plugin:",d.name,"changelog:",d.changelog),d.changelog&&window.open(d.changelog,"_blank")},[xe,Se]=r.useState({}),[U,M]=r.useState(!1),k=d=>{a&&console.log("handleConfigPlugin plugin:",d.name),n({id:u.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:d.name}}),n({id:u.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:d.name}}),Se(d),w()},w=()=>{M(!0)},g=()=>{M(!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(on,{open:U,onClose:g,plugin:xe}),e.jsxs(Ie,{open:T,onClose:E,children:[e.jsx(De,{children:"Configure Plugins Columns"}),e.jsx(Ne,{children:e.jsx(at,{children:O.map(d=>e.jsx(Te,{control:e.jsx(We,{disabled:["description","actions","status"].includes(d.accessor),checked:V[d.accessor],onChange:()=>$(d.accessor)}),label:d.Header},d.accessor))})}),e.jsx(Pe,{children:e.jsx(oe,{onClick:E,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(z,{onClick:E,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Be,{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(nn,{data:R,columns:O,columnVisibility:V})})]}):e.jsx(Je,{})}const sn=o=>{if(o===void 0||!o.qrPairingCode&&!o.manualPairingCode&&!o.fabricInformations&&!o.sessionInformations)return"red";if(o.commissioned===!1&&o.qrPairingCode&&o.manualPairingCode)return"var(--primary-color)";var c=0,i=0;for(const n of o.sessionInformations??[])n.fabric&&n.isPeerActive===!0&&c++,n.numberOfActiveSubscriptions>0&&(i+=n.numberOfActiveSubscriptions);return o.commissioned===!0&&o.fabricInformations&&o.sessionInformations&&(c===0||i===0)?"var(--secondary-color)":"var(--div-text-color)"},ln=o=>`${o.pluginName}::${o.serial}`;function dn({data:o,columns:c,columnVisibility:i}){const n=Ee.useMemo(()=>{const v=localStorage.getItem("homeDevicesColumnsSortBy");return v?JSON.parse(v):[{id:"name",desc:!1}]},[c]),s=Ee.useMemo(()=>c.filter(v=>i[v.accessor]),[i,c]),{getTableProps:h,getTableBodyProps:b,headerGroups:t,rows:u,prepareRow:C,state:{sortBy:L}}=Ae.useTable({columns:s,data:o,getRowId:ln,initialState:{sortBy:n}},Ae.useSortBy);return Ee.useEffect(()=>{localStorage.setItem("homeDevicesColumnsSortBy",JSON.stringify(L))},[L]),e.jsxs("table",{...h(),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(W=>e.jsxs("th",{...W.getHeaderProps(W.noSort?void 0:W.getSortByToggleProps()),style:{border:"none",borderCollapse:"collapse",cursor:W.noSort?"default":"pointer"},children:[W.render("Header"),!W.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:W.isSorted?W.isSortedDesc?e.jsx(te,{path:Tt,size:"15px"}):e.jsx(te,{path:Wt,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...b(),style:{border:"none",borderCollapse:"collapse"},children:u.map((v,W)=>(C(v),e.jsx("tr",{className:W%2===0?"table-content-even":"table-content-odd",...v.getRowProps(),style:{border:"none",borderCollapse:"collapse"},children:v.cells.map(R=>e.jsx("td",{...R.getCellProps(),style:{border:"none",borderCollapse:"collapse"},children:R.render("Cell")}))})))})]})}function cn({storeId:o,setStoreId:c}){const{online:i,sendMessage:n,addListener:s,removeListener:h,getUniqueId:b}=r.useContext(fe),[t,u]=r.useState(!1),[C,L]=r.useState(!0),[v,W]=r.useState(null),[R,y]=r.useState([]),[T,p]=r.useState([]),[V,S]=r.useState([]),[F,O]=r.useState([]),[E,$]=r.useState(!1),[B,Y]=r.useState({pluginName:!0,name:!0,serial:!0,reachable:!0,powerSource:!0,configUrl:!1,actions:!0}),l=r.useRef(b()),x=[{Header:"Plugin",accessor:"pluginName"},{Header:"Name",accessor:"name"},{Header:"Serial",accessor:"serial"},{Header:"Availability",accessor:"reachable",Cell:({row:j})=>j.original.reachable===!0?"Online":j.original.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",sortType:(j,m)=>{const _=j.original.reachable===!0?1:j.original.reachable===!1?0:-1,I=m.original.reachable===!0?1:m.original.reachable===!1?0:-1;return _-I}},{Header:"Power",accessor:"powerSource",Cell:({row:j})=>j.original.powerSource==="ac"||j.original.powerSource==="dc"?e.jsx(er,{fontSize:"small",sx:{color:"var(--primary-color)"}}):j.original.powerSource==="ok"?e.jsx(jt,{fontSize:"small",sx:{color:"green"}}):j.original.powerSource==="warning"?e.jsx(jt,{fontSize:"small",sx:{color:"yellow"}}):j.original.powerSource==="critical"?e.jsx(jt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{Header:"Url",accessor:"configUrl"},{Header:"Actions",accessor:"actions",noSort:!0,Cell:({row:j})=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[j.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(z,{onClick:()=>c(o===j.original.matter.id?v.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:j.original.matter.id),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:sn(j.original.matter)},children:e.jsx(Zt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),j.original.configUrl?e.jsx(H,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(z,{onClick:()=>window.open(j.original.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(Be,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),j.original.selected!==void 0?e.jsx(H,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(We,{checked:j.original.selected,onChange:m=>he(m,j.original),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],f=Ee.useCallback(j=>{j.selected=void 0;const m=R.find(ee=>ee.name===j.pluginName);if(!m)return console.error(`HomeDevices isSelected: plugin ${j.pluginName} not found for device ${j.deviceName} `),j.selected;const _=m.schemaJson?.properties?.whiteList?.selectFrom;let I=m.configJson?.postfix;return I===""&&(I=void 0),m.hasWhiteList===!0&&m.hasBlackList===!0&&_&&(j.selected=!0,_==="serial"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&m.configJson.whiteList.includes(I?j.serial.replace("-"+I,""):j.serial)&&(j.selected=!0),_==="serial"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&!m.configJson.whiteList.includes(I?j.serial.replace("-"+I,""):j.serial)&&(j.selected=!1),_==="serial"&&m.configJson.blackList&&m.configJson.blackList.length>0&&m.configJson.blackList.includes(I?j.serial.replace("-"+I,""):j.serial)&&(j.selected=!1),_==="name"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&m.configJson.whiteList.includes(j.name)&&(j.selected=!0),_==="name"&&m.configJson.whiteList&&m.configJson.whiteList.length>0&&!m.configJson.whiteList.includes(j.name)&&(j.selected=!1),_==="name"&&m.configJson.blackList&&m.configJson.blackList.length>0&&m.configJson.blackList.includes(j.name)&&(j.selected=!1)),j.selected},[R]);r.useEffect(()=>{const j=m=>{if(m.src==="Matterbridge"&&m.dst==="Frontend"){if(m.method==="refresh_required"&&m.params.changed!=="matter"&&m.params.changed!=="pluginsRestart"&&m.params.changed!=="sessions"&&m.params.changed!=="matterbridgeLatestVersion"&&m.params.changed!=="reachability"&&(console.log(`HomeDevices received refresh_required: changed=${m.params.changed} > requesting /api/plugins`),n({id:l.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),m.method==="restart_required"&&(a&&console.log("HomeDevices received restart_required"),u(!0)),m.method==="restart_not_required"&&(a&&console.log("HomeDevices received restart_not_required"),u(!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(I=>I.pluginName===m.params.plugin&&I.serial===m.params.serialNumber?{...I,reachable:m.params.value}:I))),m.id===l.current&&m.method==="/api/settings"&&(a&&console.log(`HomeDevices (id: ${m.id}) received settings:`,m.response),W(m.response),u(m.response.matterbridgeInformation.restartRequired)),m.id===l.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 I of m.response)I.enabled===!0&&(I.loaded!==!0||I.started!==!0||I.error===!0)&&(_=!1);if(!_)return;a&&console.log("HomeDevices reset plugins, devices and selectDevices"),L(!1),y(m.response),p([]),S([]),n({id:l.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),a&&console.log("HomeDevices sent /api/devices");for(const I of m.response)I.enabled===!0&&I.loaded===!0&&I.started===!0&&I.error!==!0&&(n({id:l.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:I.name}}),a&&console.log(`HomeDevices sent /api/select/devices for plugin: ${I.name}`))}if(m.id===l.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=f(_);p(m.response)}m.id===l.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&&S(_=>{const I=_.filter(xe=>xe.pluginName!==m.response[0].pluginName),ee=m.response.map(xe=>({...xe,selected:f(xe)}));return[...I,...ee]}))}};return s(j),a&&console.log(`HomeDevices added WebSocket listener id ${l.current}`),()=>{h(j),a&&console.log("HomeDevices removed WebSocket listener")}},[R,s,h,n,f]),r.useEffect(()=>{if(T.length===0&&V.length===0)return;console.log(`HomeDevices mixing devices (${T.length}) and selectDevices (${V.length})`);const j=[];for(const m of T)j.push(m);for(const m of V)T.find(_=>_.pluginName===m.pluginName&&_.serial.includes(m.serial))||j.push(m);j.length>0&&(O(j),console.log(`HomeDevices mixed ${j.length} devices and selectDevices`))},[R,T,V,O]),r.useEffect(()=>{i&&(a&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),n({id:l.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:l.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),r.useEffect(()=>{const j=localStorage.getItem("homeDevicesColumnVisibility");if(j){const m=JSON.parse(j);m.powerSource===void 0&&(m.powerSource=!0),Y(m),a&&console.log("HomeDevices loaded column visibility from localStorage")}},[]);const D=j=>{Y(m=>{const _={...m,[j]:!m[j]};return localStorage.setItem("homeDevicesColumnVisibility",JSON.stringify(_)),a&&console.log("HomeDevices saved column visibility to localStorage",JSON.stringify(_),_),_})},X=()=>{$(!E)},he=(j,m)=>{console.log(`handleCheckboxChange: checkbox changed to ${j.target.checked} for device ${m.name} serial ${m.serial}`),O(_=>{const I=_.findIndex(xe=>xe.pluginName===m.pluginName&&xe.serial===m.serial);if(I<0)return console.error(`handleCheckboxChange: device not found ${m.name} serial ${m.serial} id ${m.id}`),_;const ee=[..._];return ee[I]={...ee[I],selected:j.target.checked},ee}),j.target.checked?n({id:l.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:m.pluginName,serial:m.serial,name:m.name}}):n({id:l.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(Ie,{open:E,onClose:X,children:[e.jsx(De,{children:"Configure Devices Columns"}),e.jsx(Ne,{children:e.jsx(at,{children:x.map(j=>e.jsx(Te,{control:e.jsx(We,{disabled:["name","actions"].includes(j.accessor),checked:B[j.accessor],onChange:()=>D(j.accessor)}),label:j.Header},j.accessor))})}),e.jsx(Pe,{children:e.jsx(oe,{onClick:X,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(z,{onClick:X,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Be,{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:F,columns:x,columnVisibility:B})}),e.jsxs("div",{className:"MbfWindowFooter",style:{borderTop:"1px solid var(--table-border-color)",justifyContent:"space-between"},children:[C&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Waiting for the plugins to fully load..."}),!C&&e.jsxs("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:["Registered devices: ",T.length.toString(),"/",F.length.toString()]}),t&&e.jsx("p",{className:"MbfWindowFooterText",style:{fontWeight:"normal",fontSize:"14px",color:"var(--secondary-color)"},children:"Restart required"})]})]}):e.jsx(Je,{})}function pn(){const[o,c]=r.useState(null),[i,n]=r.useState(null),[s,h]=r.useState([]),[b]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,u]=r.useState(localStorage.getItem("homePageMode")??"devices"),[C,L]=r.useState(""),[v,W]=r.useState(!1),[R,y]=r.useState(!1),[T,p]=r.useState(null),{addListener:V,removeListener:S,online:F,sendMessage:O,logFilterLevel:E,logFilterSearch:$,autoScroll:B,getUniqueId:Y}=r.useContext(fe),l=r.useRef(Y());return r.useEffect(()=>{const x=f=>{f.src==="Matterbridge"&&f.dst==="Frontend"&&(f.method==="refresh_required"&&f.params.changed!=="matterbridgeLatestVersion"&&f.params.changed!=="reachability"&&(a&&console.log(`Home received refresh_required: changed=${f.params.changed}`),O({id:l.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),f.id===l.current&&f.method==="/api/settings"&&(a&&console.log("Home received settings:",f.response),c(f.response.systemInformation),n(f.response.matterbridgeInformation),f.response.matterbridgeInformation.bridgeMode==="bridge"&&(T||p(f.response.matterbridgeInformation.matter.id)),f.response.matterbridgeInformation.bridgeMode==="childbridge"&&s.length>0&&T===null&&(T||p(s[0].matter.id)),f.response.matterbridgeInformation.matterbridgeVersion&&L(`https://github.com/Luligu/matterbridge/blob/${f.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null?localStorage.setItem("frontendVersion",f.response.matterbridgeInformation.frontendVersion):f.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&(localStorage.setItem("frontendVersion",f.response.matterbridgeInformation.frontendVersion),y(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",f.response.matterbridgeInformation.matterbridgeVersion):f.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",f.response.matterbridgeInformation.matterbridgeVersion),W(!0)),f.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),u("devices")))),f.id===l.current&&f.method==="/api/plugins"&&(a&&console.log(`Home received plugins (${i?.bridgeMode}):`,f.response),h(f.response),i?.bridgeMode==="childbridge"&&f.response.length>0&&(T||p(f.response[0].matter.id))))};return V(x),a&&console.log(`Home added WebSocket listener id ${l.current}`),()=>{S(x),a&&console.log("Home removed WebSocket listener")}},[V,S,O,i,s,T]),r.useEffect(()=>{F&&(a&&console.log("Home received online"),O({id:l.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),O({id:l.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[F,O]),a&&console.log("Home rendering..."),!F||!o||!i?e.jsx(Je,{}):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(Xo,{id:T}),e.jsx(Qo,{systemInfo:o,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[R&&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(Hr,{}),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(C,"_blank"),endIcon:e.jsx(Xt,{}),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(Rr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),b&&!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(Zo,{})]}),b&&e.jsx(an,{storeId:T,setStoreId:p}),t==="devices"&&e.jsx(cn,{storeId:T,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 "',E,'" and search "',$,'" Scroll: ',B?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(nr,{})})]})]})]})}const Jt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},un={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},mn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Gt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},gn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},hn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},xn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},fn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},bn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Pt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},vn=[256,257,268,269],yn=[266,267],jn=[259,260,261,271,272],Cn=[256,257,268,269,266,267,259,260,261];function G({icon:o,iconColor:c,cluster:i,value:n,unit:s,prefix:h}){return a&&console.log(`Render cluster "${i.clusterName}.${i.attributeName}" value(${typeof n}-${isNaN(n)}) "${n}" unit "${s}"`),h=h??!1,e.jsxs(Z,{sx:Jt,children:[o&&Ee.cloneElement(o,{key:`${i.clusterId}-${i.attributeId}-icon`,sx:{...un,color:c??"var(--primary-color)"}}),e.jsxs(Z,{sx:{...Jt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&h===!0&&e.jsx(de,{sx:Gt,children:s},`${i.clusterId}-${i.attributeId}-unit`),e.jsx(de,{sx:mn,children:n==null||typeof n=="number"&&isNaN(n)||n==="NaN"?"---":n},`${i.clusterId}-${i.attributeId}-value`),s&&h===!1&&e.jsx(de,{sx:Gt,children:s},`${i.clusterId}-${i.attributeId}-unit`)]},`${i.clusterId}-${i.attributeId}-valueunitbox`)]},`${i.clusterId}-${i.attributeId}-box`)}function Sn({device:o,endpoint:c,id:i,deviceType:n,clusters:s}){const h=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let b="";return a&&console.log(`Device "${o.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=>b=`${t.attributeLocalValue} mV`),Cn.includes(n)&&s.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>b=`Level ${t.attributeValue}`),n===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>b=`Position ${t.attributeValue/100}%`),n===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>b=`Heat ${t.attributeValue/100}°C `),n===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>b=b+`Cool ${t.attributeValue/100}°C`),n===118&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>b=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>b=`${t.attributeLocalValue/1e3} V, `),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>b=b+`${t.attributeLocalValue/1e3} A, `),n===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>b=b+`${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(it,{}):e.jsx(Or,{}),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(jt,{}),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(er,{}),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:go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),vn.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"})),yn.includes(n)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(G,{icon:e.jsx(te,{path:ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),jn.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"})),n===115&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(G,{icon:e.jsx(te,{path:fo,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:bo,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:vo,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(Er,{}),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:yo,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:jo,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:Ut,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:Ut,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:Co,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($r,{}),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:So,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(_r,{}):e.jsx(Ar,{}),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(Ur,{}),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:wo,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(zr,{}),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(qr,{}),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(Et,{}),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(Et,{}),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(Br,{}),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(Jr,{}),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(Gr,{}),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:Mo,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:ko,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:Io,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:Do,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:No,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:zt,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:zt,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(Qr,{}),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:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:h[t.attributeLocalValue??0]})),n===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(G,{icon:e.jsx(Kr,{}),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:To,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(Yr,{}),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(Xr,{}),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(Zr,{}):e.jsx(eo,{}),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(to,{}):e.jsx(ro,{}),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(oo,{}),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(no,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Z,{sx:gn,children:e.jsx(de,{sx:hn,children:b})}),e.jsx(Z,{sx:xn,children:e.jsx(de,{sx:fn,children:o.name})}),e.jsxs(Z,{sx:bn,children:[a&&e.jsx(de,{sx:Pt,children:c}),e.jsx(de,{sx:Pt,children:i}),a&&e.jsxs(de,{sx:Pt,children:["0x",n.toString(16).padStart(4,"0")]})]})]})}function wn({filter:o}){const{online:c,sendMessage:i,addListener:n,removeListener:s,getUniqueId:h}=r.useContext(fe),[b,t]=r.useState(!1),[u,C]=r.useState({}),[L,v]=r.useState([]),[W,R]=r.useState([]),[y,T]=r.useState({}),[p,V]=r.useState({}),[S,F]=r.useState({}),[O,E]=r.useState(W),$=r.useRef(h()),B=()=>{t(!b)};return r.useEffect(()=>{const Y=l=>{if(l.src==="Matterbridge"&&l.dst==="Frontend"){if(l.method==="refresh_required"&&(a&&console.log("DevicesIcons received refresh_required and sending api requests"),i({id:$.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:$.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:$.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),l.method==="/api/settings"&&l.response&&(a&&console.log("DevicesIcons received settings:",l.response),C(l.response)),l.method==="/api/plugins"&&l.response&&(a&&console.log("DevicesIcons received plugins:",l.response),v(l.response)),l.method==="/api/devices"&&l.response){a&&console.log(`DevicesIcons received ${l.response.length} devices:`,l.response),R(l.response);for(let x of l.response)a&&console.log("DevicesIcons sending /api/clusters"),i({id:$.current,sender:"Icons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:x.pluginName,endpoint:x.endpoint}})}if(l.method==="/api/clusters"&&l.response){if(console.log(`DevicesIcons received for device "${l.response.deviceName}" serial "${l.response.serialNumber}" deviceType ${l.response.deviceTypes.join(" ")} clusters (${l.response.length}):`,l.response),l.response.length===0)return;const x=l.response.serialNumber;y[x]=[],p[x]=l.response.deviceTypes,S[x]=[];for(let f of l.response.clusters)y[x].find(D=>D.endpoint===f.endpoint)||y[x].push({endpoint:f.endpoint,id:f.id,deviceTypes:f.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(f.clusterName)&&S[x].push(f);T({...y}),V({...p}),F({...S}),a&&console.log(`DevicesIcons endpoints for "${x}":`,y[x]),a&&console.log(`DevicesIcons deviceTypes for "${x}":`,p[x]),a&&console.log(`DevicesIcons clusters for "${x}":`,S[x])}}};return n(Y),a&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{s(Y),a&&console.log("DevicesIcons useEffect webSocket unmounted")}},[n,s,i]),r.useEffect(()=>(a&&console.log("DevicesIcons useEffect online mounting"),c&&(a&&console.log("DevicesIcons useEffect online sending api requests"),i({id:$.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:$.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:$.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]),r.useEffect(()=>{if(o===""){E(W);return}const Y=W.filter(l=>l.name.toLowerCase().includes(o)||l.serial.toLowerCase().includes(o));E(Y)},[W,o]),a&&console.log("DevicesIcons rendering..."),e.jsxs(e.Fragment,{children:[e.jsxs(Ie,{open:b,onClose:B,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(De,{children:"Configure accessories"}),e.jsx(Ne,{}),e.jsx(Pe,{children:e.jsx(oe,{onClick:B,children:"Close"})})]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:O.map(Y=>y[Y.serial]&&y[Y.serial].map(l=>l.deviceTypes.map(x=>e.jsx(Sn,{device:Y,endpoint:l.endpoint,id:l.id,deviceType:x,clusters:S[Y.serial].filter(f=>f.endpoint===l.endpoint)}))))})]})}const ir=[{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:o})=>o.original.configUrl?e.jsx(z,{onClick:()=>window.open(o.original.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(Be,{fontSize:"small"})}):null},{Header:"Cluster",accessor:"cluster"}],ar=[{Header:"Endpoint",accessor:"endpoint"},{Header:"Id",accessor:"id"},{Header:"Device Types",accessor:"deviceTypes",Cell:({value:o})=>Array.isArray(o)?o.map(c=>`0x${c.toString(16).padStart(4,"0")}`).join(", "):o},{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:o})=>e.jsx(H,{title:o,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:o})})}],Mn=o=>`${o.pluginName}::${o.uniqueId}`,kn=o=>`${o.endpoint}::${o.clusterName}::${o.attributeName}`;function In({data:o,columnVisibility:c,setPlugin:i,setEndpoint:n,setDeviceName:s}){const[h,b]=r.useState(null),t=Ee.useMemo(()=>ir.filter(y=>c[y.accessor]),[c]),{getTableProps:u,getTableBodyProps:C,headerGroups:L,rows:v,prepareRow:W}=Ae.useTable({columns:t,data:o,getRowId:Mn},Ae.useSortBy),R=y=>{if(y.id===h){b(null),i(null),n(null),s(null),a&&console.log("Device unclicked:",y.id,"selectedDeviceIndex:",h);return}b(y.id),i(y.original.pluginName),n(y.original.endpoint),s(y.original.name),a&&console.log("Device clicked:",y.id,"selectedDeviceIndex:",h,"pluginName:",y.original.pluginName,"endpoint:",y.original.endpoint)};return e.jsxs("table",{...u(),style:{margin:"-1px",border:"1px solid var(--table-border-color)"},children:[e.jsx("thead",{children:L.map(y=>e.jsx("tr",{...y.getHeaderGroupProps(),children:y.headers.map(T=>e.jsxs("th",{...T.getHeaderProps(T.noSort?void 0:T.getSortByToggleProps()),children:[T.render("Header"),!T.noSort&&e.jsx("span",{style:{margin:"0px",marginLeft:"5px",padding:"0px"},children:T.isSorted?T.isSortedDesc?e.jsx(te,{path:Tt,size:"15px"}):e.jsx(te,{path:Wt,size:"15px"}):null})]}))}))}),e.jsx("tbody",{...C(),children:v.map((y,T)=>(W(y),e.jsx("tr",{className:T%2===0?"table-content-even":"table-content-odd",...y.getRowProps(),onClick:()=>R(y),style:{backgroundColor:h===y.id?"var(--table-selected-bg-color)":"",cursor:"pointer"},children:y.cells.map(p=>e.jsx("td",{...p.getCellProps(),children:p.render("Cell")}))})))})]})}function Dn({data:o,columnVisibility:c}){const i=Ee.useMemo(()=>ar.filter(u=>c[u.accessor]),[c]),{getTableProps:n,getTableBodyProps:s,headerGroups:h,rows:b,prepareRow:t}=Ae.useTable({columns:i,data:o,getRowId:kn},Ae.useSortBy);return e.jsxs("table",{...n(),style:{margin:"-1px"},children:[e.jsx("thead",{children:h.map(u=>e.jsx("tr",{...u.getHeaderGroupProps(),children:u.headers.map(C=>e.jsx("th",{...C.getHeaderProps(),children:C.render("Header")}))}))}),e.jsx("tbody",{...s(),children:b.map((u,C)=>(t(u),e.jsx("tr",{className:C%2===0?"table-content-even":"table-content-odd",...u.getRowProps(),children:u.cells.map(L=>e.jsx("td",{...L.getCellProps(),children:L.render("Cell")}))})))})]})}function Nn(){const{online:o,sendMessage:c,addListener:i,removeListener:n,getUniqueId:s}=r.useContext(fe),[h,b]=r.useState([]),[t,u]=r.useState([]),[C,L]=r.useState(null),[v,W]=r.useState(null),[R,y]=r.useState(null),[T,p]=r.useState(0),[V,S]=r.useState(!1),[F,O]=r.useState({pluginName:!0,type:!0,endpoint:!0,name:!0,serial:!0,uniqueId:!1,configUrl:!1,configButton:!0,cluster:!0}),[E,$]=r.useState(!1),[B,Y]=r.useState({endpoint:!0,id:!0,deviceTypes:!0,clusterName:!0,clusterId:!0,attributeName:!0,attributeId:!0,attributeValue:!0}),[l,x]=r.useState(""),[f,D]=r.useState(h),[X,he]=r.useState("icon"),j=r.useRef(s());r.useEffect(()=>{const U=M=>{if(a&&console.log("Devices received WebSocket Message:",M),M.src==="Matterbridge"&&M.dst==="Frontend"&&(M.method==="refresh_required"&&(a&&console.log("Devices received refresh_required"),c({id:j.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),M.method==="/api/devices"&&(a&&console.log(`Devices received ${M.response.length} devices:`,M.response),b(M.response)),M.method==="/api/clusters")){console.log(`Devices received ${M.response.length} clusters:`,M.response),u(M.response.clusters);const k={};for(const w of M.response.clusters)a&&console.log("Cluster:",w.endpoint),k[w.endpoint]?k[w.endpoint]++:k[w.endpoint]=1;p(Object.keys(k).length)}};return i(U),a&&console.log("Devices added WebSocket listener"),()=>{n(U),a&&console.log("Devices removed WebSocket listener")}},[i,n,c]),r.useEffect(()=>{o&&(a&&console.log("Devices sending api requests"),c({id:j.current,sender:"Devices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:j.current,sender:"Devices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:j.current,sender:"Devices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[o,c]),r.useEffect(()=>{C&&v&&(a&&console.log("Devices sending /api/clusters"),c({id:j.current,sender:"Devices",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:C,endpoint:v}}))},[C,v,c]);const m=()=>{S(!V)},_=U=>{O(M=>{const k={...M,[U]:!M[U]};return localStorage.setItem("devicesColumnVisibility",JSON.stringify(k)),k})};r.useEffect(()=>{const U=localStorage.getItem("devicesColumnVisibility");U&&O(JSON.parse(U))},[]);const I=()=>{$(!E)},ee=U=>{Y(M=>{const k={...M,[U]:!M[U]};return localStorage.setItem("clustersColumnVisibility",JSON.stringify(k)),k})};r.useEffect(()=>{const U=localStorage.getItem("clustersColumnVisibility");U&&Y(JSON.parse(U))},[]);const xe=U=>{x(U.target.value.toLowerCase()),localStorage.setItem("devicesFilter",U.target.value.toLowerCase())},Se=U=>{he(U),localStorage.setItem("devicesViewMode",U)};return r.useEffect(()=>{if(l===""){D(h);return}const U=h.filter(M=>M.name.toLowerCase().includes(l)||M.serial.toLowerCase().includes(l));D(U)},[h,l]),r.useEffect(()=>{const U=localStorage.getItem("devicesFilter");U&&x(U)},[]),r.useEffect(()=>{const U=localStorage.getItem("devicesViewMode");U&&he(U)},[]),a&&console.log("Devices rendering..."),o?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(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(de,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(pe,{variant:"outlined",value:l,onChange:xe,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(de,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(z,{onClick:()=>Se("table"),"aria-label":"Table View",disabled:X==="table",children:e.jsx(H,{title:"Table View",children:e.jsx(io,{style:{color:X==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(z,{onClick:()=>Se("icon"),"aria-label":"Icon View",disabled:X==="icon",children:e.jsx(H,{title:"Icon View (beta)",children:e.jsx(ao,{style:{color:X==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),e.jsxs(Ie,{open:V,onClose:m,children:[e.jsx(De,{children:"Configure Devices Columns"}),e.jsx(Ne,{children:e.jsx(at,{children:ir.map(U=>e.jsx(Te,{control:e.jsx(We,{disabled:["pluginName","name","configButton"].includes(U.accessor),checked:F[U.accessor],onChange:()=>_(U.accessor)}),label:U.Header},U.accessor))})}),e.jsx(Pe,{children:e.jsx(oe,{onClick:m,children:"Close"})})]}),X==="table"&&e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${C&&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(z,{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(Be,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})})]}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(In,{data:f,columnVisibility:F,setPlugin:L,setEndpoint:W,setDeviceName:y})}),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: ",f.length.toString()]})})]}),e.jsxs(Ie,{open:E,onClose:I,children:[e.jsx(De,{children:"Configure Clusters Columns"}),e.jsx(Ne,{children:e.jsx(at,{children:ar.map(U=>e.jsx(Te,{control:e.jsx(We,{disabled:["clusterName","attributeName","attributeValue"].includes(U.accessor),checked:B[U.accessor],onChange:()=>ee(U.accessor)}),label:U.Header},U.accessor))})}),e.jsx(Pe,{children:e.jsx(oe,{onClick:I,children:"Close"})})]}),X==="table"&&C&&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 "',R,'" on endpoint ',v]}),e.jsx(z,{onClick:I,"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:"Configure columns",children:e.jsx(Be,{style:{color:"var(--header-text-color)",fontSize:"19px"}})})})]})}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{margin:"0",padding:"0",gap:"0"},children:e.jsx(Dn,{data:t,columnVisibility:B})}),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: ",T-1]})})]}),X==="icon"&&e.jsx(wn,{filter:l,devices:f})]}):e.jsx(Je,{})}function Pn(){const[o,c]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[i,n]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[s,h]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:b,setLogFilters:t,online:u,setAutoScroll:C}=r.useContext(fe),L=y=>{c(y.target.value),t(y.target.value,i),localStorage.setItem("logFilterLevel",y.target.value),a&&console.log("handleChangeLevel called with value:",y.target.value)},v=y=>{n(y.target.value),t(o,y.target.value),localStorage.setItem("logFilterSearch",y.target.value),a&&console.log("handleChangeSearch called with value:",y.target.value)},W=y=>{h(y.target.checked),C(y.target.checked),localStorage.setItem("logAutoScroll",y.target.value?"true":"false"),a&&console.log("handleAutoScrollChange called with value:",y.target.checked)},R=()=>{a&&console.log("handleClearLogsClick called"),b([])};return a&&console.log("Logs rendering..."),u?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($t,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(rt,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:o,onChange:L,children:[e.jsx(P,{value:"debug",children:"Debug"}),e.jsx(P,{value:"info",children:"Info"}),e.jsx(P,{value:"notice",children:"Notice"}),e.jsx(P,{value:"warn",children:"Warn"}),e.jsx(P,{value:"error",children:"Error"}),e.jsx(P,{value:"fatal",children:"Fatal"})]}),e.jsx($t,{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(Te,{control:e.jsx(We,{checked:s,onChange:W}),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:R,endIcon:e.jsx(Ct,{}),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(nr,{})})]}):e.jsx(Je,{})}const Tn=({open:o,ip:c,onClose:i,onSave:n})=>{const s=c?c.split(".").slice(0,3).join(".")+".1":"",[h,b]=r.useState("dhcp"),[t,u]=r.useState({ip:c??"",subnet:"255.255.255.0",gateway:s,dns:s}),C=W=>R=>{u({...t,[W]:R.target.value})},L=()=>{i()},v=()=>{const W=h==="static"?{type:h,...t}:{type:h};n(W),i()};return e.jsxs(Ie,{open:o,onClose:(W,R)=>{R==="backdropClick"||R==="escapeKeyDown"||i()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(De,{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(Ne,{dividers:!0,children:[e.jsxs(tr,{component:"fieldset",fullWidth:!0,children:[e.jsx(ke,{component:"legend",children:"Select IP Configuration"}),e.jsxs(rr,{row:!0,value:h,onChange:W=>b(W.target.value),children:[e.jsx(Te,{value:"dhcp",control:e.jsx(St,{}),label:"DHCP"}),e.jsx(Te,{value:"static",control:e.jsx(St,{}),label:"Static"})]})]}),h==="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:C("ip")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:C("subnet")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:C("gateway")})}),e.jsx(_e,{size:6,children:e.jsx(pe,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:C("dns")})})]})]}),e.jsxs(Pe,{children:[e.jsx(oe,{onClick:L,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:v,children:"Save"})]})]})},Wn=({open:o,onClose:c,onSave:i})=>{const[n,s]=r.useState(""),[h,b]=r.useState(""),t=R=>{s(R.target.value)},u=R=>{b(R.target.value)},C=n.length>0&&n===h,L=()=>{c()},v=()=>{C&&(i(n),c())},W=()=>{i(""),c()};return e.jsxs(Ie,{open:o,onClose:(R,y)=>{y==="backdropClick"||y==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(De,{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(Ne,{dividers:!0,children:e.jsx(tr,{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:h,onChange:u,error:h!==""&&n!==h,helperText:h!==""&&n!==h?"Passwords do not match":""})})]})})}),e.jsxs(Pe,{children:[e.jsx(oe,{onClick:L,children:"Cancel"}),e.jsx(oe,{variant:"contained",onClick:v,disabled:!C,children:"Change"}),e.jsx(oe,{variant:"contained",onClick:W,children:"Reset"})]})]})};function Fn(){const{online:o,addListener:c,removeListener:i,sendMessage:n,getUniqueId:s}=r.useContext(fe),[h,b]=r.useState(null),[t,u]=r.useState(null),C=r.useRef(s());return r.useEffect(()=>{const L=v=>{v.src==="Matterbridge"&&v.dst==="Frontend"&&(v.method==="refresh_required"&&(a&&console.log("Settings received refresh_required"),n({id:C.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),v.method==="/api/settings"&&(a&&console.log("Settings received /api/settings:",v.response),b(v.response.matterbridgeInformation),u(v.response.systemInformation)))};return c(L),a&&console.log("Settings added WebSocket listener"),()=>{i(L),a&&console.log("Settings removed WebSocket listener")}},[c,i,n]),r.useEffect(()=>{o&&(a&&console.log("Settings received online"),n({id:C.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[o,n]),h?(a&&console.log("Settings rendering..."),o?e.jsx("div",{className:"MbfPageDiv",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(Ln,{matterbridgeInfo:h,systemInfo:t}),e.jsx(Hn,{matterbridgeInfo:h}),e.jsx(Rn,{matterbridgeInfo:h})]})}):e.jsx(Je,{})):null}function Ln({matterbridgeInfo:o,systemInfo:c}){const{sendMessage:i,getUniqueId:n}=r.useContext(fe),[s,h]=r.useState("bridge"),[b,t]=r.useState("Info"),[u,C]=r.useState(!1),[L,v]=r.useState("dark"),[W,R]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[y,T]=r.useState(localStorage.getItem("homePageMode")??"logs"),[p,V]=r.useState(localStorage.getItem("virtualMode")??"outlet"),S=r.useRef(n()),[F,O]=r.useState(!1),E=()=>O(!1),$=I=>{a&&console.log("handleSaveNetConfig called with config:",I),i({id:S.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:I})},[B,Y]=r.useState(!1),l=()=>Y(!1),x=I=>{a&&console.log("handleSaveChangePassword called with password:",I),i({id:S.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:I}})};r.useEffect(()=>{o.bridgeMode!==void 0&&(h(o.bridgeMode==="bridge"?"bridge":"childbridge"),t(o.loggerLevel.charAt(0).toUpperCase()+o.loggerLevel.slice(1)),C(o.fileLogger),V(o.virtualMode))},[o]),r.useEffect(()=>{const I=localStorage.getItem("frontendTheme");I&&v(I)},[]);const f=I=>{a&&console.log("handleChangeBridgeMode called with value:",I.target.value),h(I.target.value),i({id:S.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:I.target.value}})},D=I=>{a&&console.log("handleChangeMbLoggerLevel called with value:",I.target.value),t(I.target.value),i({id:S.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:I.target.value}})},X=I=>{a&&console.log("handleLogOnFileMbChange called with value:",I.target.checked),C(I.target.checked),i({id:S.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:I.target.checked}})},he=I=>{const ee=I.target.value;a&&console.log("handleChangeTheme called with value:",ee),v(ee),localStorage.setItem("frontendTheme",ee),document.body.setAttribute("frontend-theme",ee)},j=I=>{const ee=I.target.checked;a&&console.log("handleChangeHomePagePlugins called with value:",ee),R(ee),localStorage.setItem("homePagePlugins",ee?"true":"false")},m=I=>{const ee=I.target.value;a&&console.log("handleChangeHomePageMode called with value:",ee),T(ee),localStorage.setItem("homePageMode",ee)},_=I=>{const ee=I.target.value;a&&console.log("handleChangeVirtualMode called with value:",ee),V(ee),localStorage.setItem("virtualMode",ee),i({id:S.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:ee}})};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(Tn,{open:F,ip:c.ipv4Address,onClose:E,onSave:$}),e.jsx(Wn,{open:B,onClose:l,onSave:x}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{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(rr,{row:!0,name:"mode-buttons-group",value:s,onChange:f,children:[e.jsx(Te,{value:"bridge",control:e.jsx(St,{}),label:"Bridge",disabled:o.readOnly===!0}),e.jsx(Te,{value:"childbridge",control:e.jsx(St,{}),label:"Childbridge",disabled:o.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(rt,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:b,onChange:D,children:[e.jsx(P,{value:"Debug",children:"Debug"}),e.jsx(P,{value:"Info",children:"Info"}),e.jsx(P,{value:"Notice",children:"Notice"}),e.jsx(P,{value:"Warn",children:"Warn"}),e.jsx(P,{value:"Error",children:"Error"}),e.jsx(P,{value:"Fatal",children:"Fatal"})]}),e.jsx(Te,{style:{padding:"0px",margin:"0px"},control:e.jsx(We,{checked:u,onChange:X,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(rt,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:L,onChange:he,children:[e.jsx(P,{value:"classic",children:"Classic"}),e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(We,{checked:W,onChange:j,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(rt,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:y,onChange:m,children:[e.jsx(P,{value:"logs",children:"Logs"}),e.jsx(P,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(rt,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:p,onChange:_,children:[e.jsx(P,{value:"disabled",children:"Disabled"}),e.jsx(P,{value:"outlet",children:"Outlet"}),e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"switch",children:"Switch"}),e.jsx(P,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>Y(!0),children:"Change password"})}),o.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(oe,{variant:"contained",color:"primary",onClick:()=>O(!0),children:"Configure IP"})})]})})]})}function Hn({matterbridgeInfo:o}){const{sendMessage:c,getUniqueId:i}=r.useContext(fe),[n,s]=r.useState("Info"),[h,b]=r.useState(!1),[t,u]=r.useState(""),[C,L]=r.useState(""),[v,W]=r.useState(""),[R,y]=r.useState(),[T,p]=r.useState(),[V,S]=r.useState(),F=r.useRef(i());r.useEffect(()=>{o.bridgeMode!==void 0&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][o.matterLoggerLevel]),b(o.matterFileLogger),u(o.mattermdnsinterface),L(o.matteripv4address),W(o.matteripv6address),y(o.matterPort),p(o.matterDiscriminator),S(o.matterPasscode))},[o]);const O=D=>{a&&console.log("handleChangeMjLoggerLevel called with value:",D.target.value),s(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:D.target.value}})},E=D=>{a&&console.log("handleLogOnFileMjChange called with value:",D.target.checked),b(D.target.checked),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:D.target.checked}})},$=D=>{a&&console.log("handleChangeMdnsInterface called with value:",D.target.value),u(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:D.target.value}})},B=D=>{a&&console.log("handleChangeIpv4Address called with value:",D.target.value),L(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:D.target.value}})},Y=D=>{a&&console.log("handleChangeIpv6Address called with value:",D.target.value),W(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:D.target.value}})},l=D=>{a&&console.log("handleChangeMatterPort called with value:",D.target.value),y(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:D.target.value}})},x=D=>{a&&console.log("handleChangeMatterDiscriminator called with value:",D.target.value),p(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:D.target.value}})},f=D=>{a&&console.log("handleChangemMatterPasscode called with value:",D.target.value),S(D.target.value),c({id:F.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:D.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(Z,{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(rt,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:n,onChange:O,children:[e.jsx(P,{value:"Debug",children:"Debug"}),e.jsx(P,{value:"Info",children:"Info"}),e.jsx(P,{value:"Notice",children:"Notice"}),e.jsx(P,{value:"Warn",children:"Warn"}),e.jsx(P,{value:"Error",children:"Error"}),e.jsx(P,{value:"Fatal",children:"Fatal"})]}),e.jsx(Te,{style:{padding:"0px",margin:"0px"},control:e.jsx(We,{checked:h,onChange:E,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:$,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.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:C,onChange:B,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.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:Y,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.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:R,onChange:l,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.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:T,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.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:V,onChange:f,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:o.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]})}function Rn({matterbridgeInfo:o}){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(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[" ",e.jsx(qe,{value:o.matterbridgeVersion,label:"Current Version"}),e.jsx(qe,{value:o.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(qe,{value:o.homeDirectory,label:"Home Directory"}),e.jsx(qe,{value:o.rootDirectory,label:"Root Directory"}),e.jsx(qe,{value:o.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(qe,{value:o.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(qe,{value:o.globalModulesDirectory,label:"Global Module Directory"})]})})]})}function qe({value:o,label:c}){return e.jsx(pe,{focused:!0,value:o,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 On(o,c,i){const n=o?.[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))}const Vn=r.memo(function({name:c,columns:i,rows:n,getRowKey:s,footerLeft:h,footerRight:b}){const t=r.useRef(new WeakMap),u=r.useRef(1),C=l=>{if(typeof s=="string"&&l&&l[s]!=null)return l[s];if(typeof s=="function"){const D=s(l);if(D!=null)return D}const x=i?.[0]?.id;if(x&&l&&l[x]!=null)return l[x];console.warn(`MbfTable(${c}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let f=t.current.get(l);return f||(f=`rk_${u.current++}`,t.current.set(l,f)),f},{_showConfirmCancelDialog:L}=r.useContext(ot),[v,W]=r.useState(localStorage.getItem(`${c}_table_order_by`)||null),[R,y]=r.useState(localStorage.getItem(`${c}_table_order`)||null),[T,p]=r.useState(!1),[V,S]=r.useState(()=>{try{const l=localStorage.getItem(`${c}_column_visibility`);if(l)return JSON.parse(l)}catch{}return{}}),F=r.useMemo(()=>{const l={};for(const x of i)x.hidden||(l[x.id]=x.required?!0:V[x.id]!==!1);return l},[i,V]),O=r.useMemo(()=>{if(!v||!R)return n;const l=i.find(f=>f.id===v);if(!l||l.nosort)return n;const x=n.map((f,D)=>({el:f,index:D}));return x.sort((f,D)=>{const X=On(f.el,D.el,v);return X!==0?R==="asc"?X:-X:f.index-D.index}),x.map(f=>f.el)},[n,v,R,i]),E=l=>{if(v!==l||!v){W(l),y("asc"),localStorage.setItem(`${c}_table_order_by`,l),localStorage.setItem(`${c}_table_order`,"asc");return}if(R==="asc"){y("desc"),localStorage.setItem(`${c}_table_order`,"desc");return}W(null),y(null),localStorage.removeItem(`${c}_table_order_by`),localStorage.removeItem(`${c}_table_order`)},$=()=>{p(!T)},B=l=>{S(x=>{const f=i.find(he=>he.id===l);if(f&&f.required)return x;const D=F[l]!==!1,X={...x};D?X[l]=!1:delete X[l];try{localStorage.setItem(`${c}_column_visibility`,JSON.stringify(X))}catch{}return X})},Y=()=>{const l={};S(l);try{localStorage.setItem(`${c}_column_visibility`,JSON.stringify(l))}catch{}};return console.log(`Rendering table ${c}${v&&R?` ordered by ${v}:${R}`:""}`),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(Ie,{open:T,onClose:(l,x)=>{x==="backdropClick"||x==="escapeKeyDown"||$()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(De,{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 ${c} columns`})]})}),e.jsx(Ne,{children:e.jsx(at,{children:i.filter(l=>!l.hidden).map(l=>e.jsx(Te,{control:e.jsx(We,{disabled:!!l.required,checked:l.required?!0:F[l.id]!==!1,onChange:()=>B(l.id)}),label:l.label},l.id))})}),e.jsxs(Pe,{children:[e.jsx(oe,{onClick:Y,children:"Reset"}),e.jsx(oe,{variant:"contained",onClick:l=>{if(l?.currentTarget&&typeof l.currentTarget.blur=="function")try{l.currentTarget.blur()}catch{}const x=document.activeElement;if(x&&x instanceof HTMLElement&&typeof x.blur=="function")try{x.blur()}catch{}$()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:c}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(z,{onClick:l=>{if(l?.currentTarget?.blur)try{l.currentTarget.blur()}catch{}$()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(H,{title:`Configure ${c} columns`,children:e.jsx(te,{path:Wo,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":`${c} 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:i.map(l=>{if(l.hidden||!l.required&&F[l.id]===!1)return null;const x=!l.nosort,f=x&&v===l.id&&!!R;return e.jsxs("th",{onClick:x?()=>E(l.id):void 0,style:{margin:"0",padding:"4px 8px",position:"sticky",top:0,minWidth:l.minWidth,maxWidth:l.maxWidth,textAlign:l.align||"left",cursor:x?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:l.maxWidth?"nowrap":void 0,overflow:l.maxWidth?"hidden":void 0,textOverflow:l.maxWidth?"ellipsis":void 0},"aria-sort":x?f?R==="asc"?"ascending":"descending":"none":void 0,children:[l.label,f&&e.jsxs("span",{style:{marginLeft:6},children:[R==="asc"&&e.jsx(te,{path:Wt,size:"15px"}),R==="desc"&&e.jsx(te,{path:Tt,size:"15px"})]})]},l.id)})})}),e.jsx("tbody",{children:O.map((l,x)=>{const f=C(l);return e.jsx("tr",{className:x%2===0?"table-content-even":"table-content-odd",style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse"},children:i.map(D=>{if(D.hidden||!D.required&&F[D.id]===!1)return null;const X=l[D.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:D.align||"left",padding:"4px 8px",margin:"0",maxWidth:D.maxWidth,whiteSpace:D.maxWidth?"nowrap":void 0,overflow:D.maxWidth?"hidden":void 0,textOverflow:D.maxWidth?"ellipsis":void 0},children:typeof D.render=="function"?D.render(X,f,l,D):typeof X=="boolean"?e.jsx(We,{checked:X,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):D.format&&typeof X=="number"?D.format(X):X??""},D.id)})},f)})})]})}),e.jsxs("div",{className:"MbfWindowFooter",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:b})]})]})});function En(){const{online:o,sendMessage:c,addListener:i,removeListener:n,getUniqueId:s}=r.useContext(fe),{showSnackbarMessage:h,closeSnackbarMessage:b}=r.useContext(ot),[t,u]=r.useState(null),[C,L]=r.useState([]),[v,W]=r.useState([]),[R,y]=r.useState([]),[T,p]=r.useState(null),[V,S]=r.useState(null),[F,O]=r.useState(null),E=r.useRef(null),[$,B]=r.useState(()=>sr);E.current||(E.current=s(),console.log("Test uniqueId:",E)),r.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const l=x=>{if(x.src==="Matterbridge"&&x.dst==="Frontend"){if(x.method==="restart_required"&&(console.log("Test received restart_required"),h("Restart required",0)),x.method==="refresh_required"&&(console.log("Test received refresh_required"),h("Refresh required",0),c({id:E.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:E.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:E.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),x.method==="memory_update"&&(console.log("Test received memory_update",x),S(x.params)),x.method==="cpu_update"&&(console.log("Test received cpu_update",x),p(x.params)),x.method==="uptime_update"&&(console.log("Test received uptime_update",x),O(x.params)),x.method==="/api/settings"&&x.response&&(console.log("Test received /api/settings:",x.response),h("Test received /api/settings"),u(x.response)),x.method==="/api/plugins"&&x.response&&(console.log(`Test received ${x.response.length} plugins:`,x.response),h("Test received /api/plugins"),L(x.response)),x.method==="/api/devices"&&x.response){console.log(`Test received ${x.response.length} devices:`,x.response),h("Test received /api/devices"),W(x.response);for(let f of x.response)console.log("Test sending /api/clusters for device:",f.pluginName,f.name,f.endpoint),c({method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:f.pluginName,endpoint:f.endpoint}})}x.method==="/api/clusters"&&(console.log(`Test received ${x.response.length} clusters for device ${x.deviceName} endpoint ${x.endpoint}:`,x),h("Test received /api/clusters"),y(x.response))}else console.log("Test received WebSocketMessage:",x.method,x.src,x.dst,x.response)};return i(l),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),n(l),console.log("Test useEffect WebSocketMessage unmounted")}},[i,n,c,h]),r.useEffect(()=>(console.log("Test useEffect online mounting"),o&&(console.log("Test useEffect online received online"),c({method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),c({method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}})),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[o,c,h]);const Y=r.useCallback(l=>l.code,[]);return console.log("Test rendering..."),o?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",border:"1px solid #0004ffff"},children:e.jsx(Vn,{name:"Test",columns:$n,rows:$,getRowKey:Y,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"),h("Test button clicked"),b("Refresh required"),b("Restart required"),b("Test permanent message removal")},children:"Test"}),e.jsx(oe,{variant:"outlined",onClick:()=>{B(l=>{const x=l.findIndex(he=>he.code==="F123");if(x===-1)return l;const f=l[x],D={...f,population:(f.population||0)+1},X=l.slice();return X[x]=D,X})},children:"Update F123"})]})]})}):e.jsx(Je,{})}const $n=[{id:"name",label:"Name",minWidth:50,maxWidth:100,required:!0},{id:"code",label:"ISO Code",minWidth:100,render:(o,c)=>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(o)})},{id:"isIsland",label:"Island",minWidth:80,align:"center"},{id:"population",label:"Population",minWidth:170,align:"right",format:o=>o.toLocaleString("en-US")},{id:"size",label:"Size (km²)",minWidth:170,align:"right",format:o=>o.toLocaleString("en-US")},{id:"density",label:"Density",minWidth:170,align:"right",nosort:!0,format:o=>o.toFixed(2)},{id:"virtual",label:"Virtual",align:"right",required:!0,nosort:!0,render:(o,c,i)=>i.isIsland?"🏝️":"🏞️"}];function Ce(o,c,i,n,s){const h=i/n;return{name:o,code:c,population:i,size:n,density:h,isIsland:s}}const sr=[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)],Qt=["Zor","Eld","Myth","Drak","Lum","Xen","Thal","Quor","Vex","Nyx"],Kt=["aria","dor","mere","land","wyn","gard","heim","quess","tor","vale"];for(let o=0;o<2e3;o++){const c=`${Qt[o%Qt.length]}${Kt[o%Kt.length]} ${o}`,i=`F${o.toString().padStart(3,"0")}`,n=Math.floor(Math.random()*1e9),s=Math.floor(Math.random()*1e7),h=Math.random()<.2;sr.push(Ce(c,i,n,s,h))}function _n(o,c){a&&console.log("getCssVariable:",o,"defaultValue",c);const i=getComputedStyle(document.body).getPropertyValue(o).trim();return i||console.error("getCssVariable: undefined",i),i||c}function An(o){return so({palette:{primary:{main:o},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 Un=()=>{a=!a},lr=r.createContext(void 0);function zn({children:o}){const[c,i]=r.useState(!1),[n,s]=r.useState(""),h=async b=>{try{const t=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:b})});if(t.ok){const{valid:u}=await t.json();u?i(!0):b!==""&&s("Incorrect password!")}else console.error("Failed to log in:",t.statusText)}catch(t){console.error("Failed to log in:",t)}};return e.jsx(lr.Provider,{value:{loggedIn:c,logIn:h,errorMessage:n},children:o})}function qn(){const[o,c]=r.useState(""),i=r.useContext(lr),[n,s]=r.useState("#1976d2");if(!i)throw new Error("AuthContext not found");const{loggedIn:h,logIn:b,errorMessage:t}=i,u=y=>{y.preventDefault(),b(o)},C={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},L={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)"};r.useEffect(()=>{a&&console.log("Setting frontend theme");const y=localStorage.getItem("frontendTheme");a&&console.log("Saved theme:",y),y?document.body.setAttribute("frontend-theme",y):document.body.setAttribute("frontend-theme","dark");const T=_n("--primary-color","#1976d2");a&&console.log("Primary color from CSS:",T),s(T)},[]);const W=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="${W}"`);const R=An(n);return b(""),h?e.jsx(lo,{theme:R,children:e.jsx(vr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Ao,{children:e.jsx(Uo,{children:e.jsx(gr,{basename:W,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(zo,{}),e.jsxs(hr,{children:[e.jsx(Ye,{path:"/",element:e.jsx(pn,{})}),e.jsx(Ye,{path:"/devices",element:e.jsx(Nn,{})}),e.jsx(Ye,{path:"/log",element:e.jsx(Pn,{})}),e.jsx(Ye,{path:"/settings",element:e.jsx(Fn,{})}),e.jsx(Ye,{path:"/test",element:e.jsx(En,{})}),e.jsx(Ye,{path:"*",element:e.jsx(xr,{to:"/"})})]})]})})})})})}):e.jsx("div",{style:C,children:e.jsxs("form",{onSubmit:u,style:L,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:o,onChange:y=>c(y.target.value),style:v,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:t&&e.jsx("p",{style:{color:"red"},children:t})})]})})}function Bn(){return e.jsx(zn,{children:e.jsx(qn,{})})}fr.createRoot(document.getElementById("root")).render(e.jsx(Ee.StrictMode,{children:e.jsx(Bn,{})}));
@@ -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};