matterbridge 3.3.5 → 3.3.7-dev-20251102-c85d574

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 (309) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/dist/broadcastServer.js +1 -92
  3. package/dist/broadcastServerTypes.js +0 -24
  4. package/dist/cli.js +1 -97
  5. package/dist/cliEmitter.js +0 -37
  6. package/dist/cliHistory.js +0 -38
  7. package/dist/clusters/export.js +0 -2
  8. package/dist/defaultConfigSchema.js +0 -24
  9. package/dist/deviceManager.js +1 -124
  10. package/dist/devices/airConditioner.js +0 -57
  11. package/dist/devices/batteryStorage.js +1 -48
  12. package/dist/devices/cooktop.js +0 -55
  13. package/dist/devices/dishwasher.js +0 -57
  14. package/dist/devices/evse.js +10 -74
  15. package/dist/devices/export.js +0 -5
  16. package/dist/devices/extractorHood.js +0 -42
  17. package/dist/devices/heatPump.js +2 -50
  18. package/dist/devices/laundryDryer.js +3 -62
  19. package/dist/devices/laundryWasher.js +4 -70
  20. package/dist/devices/microwaveOven.js +5 -88
  21. package/dist/devices/oven.js +0 -85
  22. package/dist/devices/refrigerator.js +0 -102
  23. package/dist/devices/roboticVacuumCleaner.js +9 -100
  24. package/dist/devices/solarPower.js +0 -38
  25. package/dist/devices/speaker.js +0 -84
  26. package/dist/devices/temperatureControl.js +3 -24
  27. package/dist/devices/waterHeater.js +2 -82
  28. package/dist/dgram/coap.js +13 -126
  29. package/dist/dgram/dgram.js +2 -114
  30. package/dist/dgram/mb_coap.js +3 -41
  31. package/dist/dgram/mb_mdns.js +15 -80
  32. package/dist/dgram/mdns.js +137 -299
  33. package/dist/dgram/multicast.js +1 -62
  34. package/dist/dgram/unicast.js +0 -54
  35. package/dist/frontend.js +34 -431
  36. package/dist/frontendTypes.js +0 -45
  37. package/dist/helpers.js +0 -53
  38. package/dist/index.js +0 -25
  39. package/dist/logger/export.js +0 -1
  40. package/dist/matter/behaviors.js +0 -2
  41. package/dist/matter/clusters.js +0 -2
  42. package/dist/matter/devices.js +0 -2
  43. package/dist/matter/endpoints.js +0 -2
  44. package/dist/matter/export.js +0 -3
  45. package/dist/matter/types.js +0 -3
  46. package/dist/matterbridge.js +46 -828
  47. package/dist/matterbridgeAccessoryPlatform.js +0 -37
  48. package/dist/matterbridgeBehaviors.js +5 -68
  49. package/dist/matterbridgeDeviceTypes.js +17 -638
  50. package/dist/matterbridgeDynamicPlatform.js +0 -37
  51. package/dist/matterbridgeEndpoint.js +52 -1408
  52. package/dist/matterbridgeEndpointHelpers.js +19 -464
  53. package/dist/matterbridgePlatform.js +1 -341
  54. package/dist/matterbridgeTypes.js +0 -26
  55. package/dist/pluginManager.js +3 -319
  56. package/dist/shelly.js +7 -168
  57. package/dist/storage/export.js +0 -1
  58. package/dist/update.js +0 -69
  59. package/dist/utils/colorUtils.js +2 -97
  60. package/dist/utils/commandLine.js +0 -60
  61. package/dist/utils/copyDirectory.js +1 -38
  62. package/dist/utils/createDirectory.js +0 -33
  63. package/dist/utils/createZip.js +2 -47
  64. package/dist/utils/deepCopy.js +0 -39
  65. package/dist/utils/deepEqual.js +1 -72
  66. package/dist/utils/error.js +0 -41
  67. package/dist/utils/export.js +0 -1
  68. package/dist/utils/format.js +0 -49
  69. package/dist/utils/hex.js +0 -124
  70. package/dist/utils/inspector.js +1 -69
  71. package/dist/utils/isvalid.js +0 -101
  72. package/dist/utils/jestHelpers.js +3 -153
  73. package/dist/utils/network.js +5 -96
  74. package/dist/utils/spawn.js +0 -71
  75. package/dist/utils/tracker.js +1 -64
  76. package/dist/utils/wait.js +8 -60
  77. package/frontend/build/assets/index.css +1 -1
  78. package/frontend/build/assets/index.js +4 -4
  79. package/frontend/build/assets/vendor_mui.js +10 -10
  80. package/frontend/build/assets/vendor_node_modules.js +30 -29
  81. package/frontend/package-lock.json +727 -732
  82. package/frontend/package.json +22 -22
  83. package/npm-shrinkwrap.json +2 -2
  84. package/package.json +1 -2
  85. package/dist/broadcastServer.d.ts +0 -112
  86. package/dist/broadcastServer.d.ts.map +0 -1
  87. package/dist/broadcastServer.js.map +0 -1
  88. package/dist/broadcastServerTypes.d.ts +0 -803
  89. package/dist/broadcastServerTypes.d.ts.map +0 -1
  90. package/dist/broadcastServerTypes.js.map +0 -1
  91. package/dist/cli.d.ts +0 -30
  92. package/dist/cli.d.ts.map +0 -1
  93. package/dist/cli.js.map +0 -1
  94. package/dist/cliEmitter.d.ts +0 -50
  95. package/dist/cliEmitter.d.ts.map +0 -1
  96. package/dist/cliEmitter.js.map +0 -1
  97. package/dist/cliHistory.d.ts +0 -48
  98. package/dist/cliHistory.d.ts.map +0 -1
  99. package/dist/cliHistory.js.map +0 -1
  100. package/dist/clusters/export.d.ts +0 -2
  101. package/dist/clusters/export.d.ts.map +0 -1
  102. package/dist/clusters/export.js.map +0 -1
  103. package/dist/defaultConfigSchema.d.ts +0 -28
  104. package/dist/defaultConfigSchema.d.ts.map +0 -1
  105. package/dist/defaultConfigSchema.js.map +0 -1
  106. package/dist/deviceManager.d.ts +0 -117
  107. package/dist/deviceManager.d.ts.map +0 -1
  108. package/dist/deviceManager.js.map +0 -1
  109. package/dist/devices/airConditioner.d.ts +0 -98
  110. package/dist/devices/airConditioner.d.ts.map +0 -1
  111. package/dist/devices/airConditioner.js.map +0 -1
  112. package/dist/devices/batteryStorage.d.ts +0 -48
  113. package/dist/devices/batteryStorage.d.ts.map +0 -1
  114. package/dist/devices/batteryStorage.js.map +0 -1
  115. package/dist/devices/cooktop.d.ts +0 -60
  116. package/dist/devices/cooktop.d.ts.map +0 -1
  117. package/dist/devices/cooktop.js.map +0 -1
  118. package/dist/devices/dishwasher.d.ts +0 -71
  119. package/dist/devices/dishwasher.d.ts.map +0 -1
  120. package/dist/devices/dishwasher.js.map +0 -1
  121. package/dist/devices/evse.d.ts +0 -76
  122. package/dist/devices/evse.d.ts.map +0 -1
  123. package/dist/devices/evse.js.map +0 -1
  124. package/dist/devices/export.d.ts +0 -17
  125. package/dist/devices/export.d.ts.map +0 -1
  126. package/dist/devices/export.js.map +0 -1
  127. package/dist/devices/extractorHood.d.ts +0 -46
  128. package/dist/devices/extractorHood.d.ts.map +0 -1
  129. package/dist/devices/extractorHood.js.map +0 -1
  130. package/dist/devices/heatPump.d.ts +0 -47
  131. package/dist/devices/heatPump.d.ts.map +0 -1
  132. package/dist/devices/heatPump.js.map +0 -1
  133. package/dist/devices/laundryDryer.d.ts +0 -67
  134. package/dist/devices/laundryDryer.d.ts.map +0 -1
  135. package/dist/devices/laundryDryer.js.map +0 -1
  136. package/dist/devices/laundryWasher.d.ts +0 -81
  137. package/dist/devices/laundryWasher.d.ts.map +0 -1
  138. package/dist/devices/laundryWasher.js.map +0 -1
  139. package/dist/devices/microwaveOven.d.ts +0 -168
  140. package/dist/devices/microwaveOven.d.ts.map +0 -1
  141. package/dist/devices/microwaveOven.js.map +0 -1
  142. package/dist/devices/oven.d.ts +0 -105
  143. package/dist/devices/oven.d.ts.map +0 -1
  144. package/dist/devices/oven.js.map +0 -1
  145. package/dist/devices/refrigerator.d.ts +0 -118
  146. package/dist/devices/refrigerator.d.ts.map +0 -1
  147. package/dist/devices/refrigerator.js.map +0 -1
  148. package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
  149. package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
  150. package/dist/devices/roboticVacuumCleaner.js.map +0 -1
  151. package/dist/devices/solarPower.d.ts +0 -40
  152. package/dist/devices/solarPower.d.ts.map +0 -1
  153. package/dist/devices/solarPower.js.map +0 -1
  154. package/dist/devices/speaker.d.ts +0 -87
  155. package/dist/devices/speaker.d.ts.map +0 -1
  156. package/dist/devices/speaker.js.map +0 -1
  157. package/dist/devices/temperatureControl.d.ts +0 -166
  158. package/dist/devices/temperatureControl.d.ts.map +0 -1
  159. package/dist/devices/temperatureControl.js.map +0 -1
  160. package/dist/devices/waterHeater.d.ts +0 -111
  161. package/dist/devices/waterHeater.d.ts.map +0 -1
  162. package/dist/devices/waterHeater.js.map +0 -1
  163. package/dist/dgram/coap.d.ts +0 -205
  164. package/dist/dgram/coap.d.ts.map +0 -1
  165. package/dist/dgram/coap.js.map +0 -1
  166. package/dist/dgram/dgram.d.ts +0 -141
  167. package/dist/dgram/dgram.d.ts.map +0 -1
  168. package/dist/dgram/dgram.js.map +0 -1
  169. package/dist/dgram/mb_coap.d.ts +0 -24
  170. package/dist/dgram/mb_coap.d.ts.map +0 -1
  171. package/dist/dgram/mb_coap.js.map +0 -1
  172. package/dist/dgram/mb_mdns.d.ts +0 -24
  173. package/dist/dgram/mb_mdns.d.ts.map +0 -1
  174. package/dist/dgram/mb_mdns.js.map +0 -1
  175. package/dist/dgram/mdns.d.ts +0 -290
  176. package/dist/dgram/mdns.d.ts.map +0 -1
  177. package/dist/dgram/mdns.js.map +0 -1
  178. package/dist/dgram/multicast.d.ts +0 -67
  179. package/dist/dgram/multicast.d.ts.map +0 -1
  180. package/dist/dgram/multicast.js.map +0 -1
  181. package/dist/dgram/unicast.d.ts +0 -56
  182. package/dist/dgram/unicast.d.ts.map +0 -1
  183. package/dist/dgram/unicast.js.map +0 -1
  184. package/dist/frontend.d.ts +0 -236
  185. package/dist/frontend.d.ts.map +0 -1
  186. package/dist/frontend.js.map +0 -1
  187. package/dist/frontendTypes.d.ts +0 -529
  188. package/dist/frontendTypes.d.ts.map +0 -1
  189. package/dist/frontendTypes.js.map +0 -1
  190. package/dist/helpers.d.ts +0 -48
  191. package/dist/helpers.d.ts.map +0 -1
  192. package/dist/helpers.js.map +0 -1
  193. package/dist/index.d.ts +0 -33
  194. package/dist/index.d.ts.map +0 -1
  195. package/dist/index.js.map +0 -1
  196. package/dist/logger/export.d.ts +0 -2
  197. package/dist/logger/export.d.ts.map +0 -1
  198. package/dist/logger/export.js.map +0 -1
  199. package/dist/matter/behaviors.d.ts +0 -2
  200. package/dist/matter/behaviors.d.ts.map +0 -1
  201. package/dist/matter/behaviors.js.map +0 -1
  202. package/dist/matter/clusters.d.ts +0 -2
  203. package/dist/matter/clusters.d.ts.map +0 -1
  204. package/dist/matter/clusters.js.map +0 -1
  205. package/dist/matter/devices.d.ts +0 -2
  206. package/dist/matter/devices.d.ts.map +0 -1
  207. package/dist/matter/devices.js.map +0 -1
  208. package/dist/matter/endpoints.d.ts +0 -2
  209. package/dist/matter/endpoints.d.ts.map +0 -1
  210. package/dist/matter/endpoints.js.map +0 -1
  211. package/dist/matter/export.d.ts +0 -5
  212. package/dist/matter/export.d.ts.map +0 -1
  213. package/dist/matter/export.js.map +0 -1
  214. package/dist/matter/types.d.ts +0 -3
  215. package/dist/matter/types.d.ts.map +0 -1
  216. package/dist/matter/types.js.map +0 -1
  217. package/dist/matterbridge.d.ts +0 -476
  218. package/dist/matterbridge.d.ts.map +0 -1
  219. package/dist/matterbridge.js.map +0 -1
  220. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
  221. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  222. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  223. package/dist/matterbridgeBehaviors.d.ts +0 -2404
  224. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  225. package/dist/matterbridgeBehaviors.js.map +0 -1
  226. package/dist/matterbridgeDeviceTypes.d.ts +0 -770
  227. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  228. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  229. package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
  230. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  231. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  232. package/dist/matterbridgeEndpoint.d.ts +0 -1556
  233. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  234. package/dist/matterbridgeEndpoint.js.map +0 -1
  235. package/dist/matterbridgeEndpointHelpers.d.ts +0 -758
  236. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  237. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  238. package/dist/matterbridgePlatform.d.ts +0 -402
  239. package/dist/matterbridgePlatform.d.ts.map +0 -1
  240. package/dist/matterbridgePlatform.js.map +0 -1
  241. package/dist/matterbridgeTypes.d.ts +0 -226
  242. package/dist/matterbridgeTypes.d.ts.map +0 -1
  243. package/dist/matterbridgeTypes.js.map +0 -1
  244. package/dist/pluginManager.d.ts +0 -347
  245. package/dist/pluginManager.d.ts.map +0 -1
  246. package/dist/pluginManager.js.map +0 -1
  247. package/dist/shelly.d.ts +0 -174
  248. package/dist/shelly.d.ts.map +0 -1
  249. package/dist/shelly.js.map +0 -1
  250. package/dist/storage/export.d.ts +0 -2
  251. package/dist/storage/export.d.ts.map +0 -1
  252. package/dist/storage/export.js.map +0 -1
  253. package/dist/update.d.ts +0 -75
  254. package/dist/update.d.ts.map +0 -1
  255. package/dist/update.js.map +0 -1
  256. package/dist/utils/colorUtils.d.ts +0 -101
  257. package/dist/utils/colorUtils.d.ts.map +0 -1
  258. package/dist/utils/colorUtils.js.map +0 -1
  259. package/dist/utils/commandLine.d.ts +0 -66
  260. package/dist/utils/commandLine.d.ts.map +0 -1
  261. package/dist/utils/commandLine.js.map +0 -1
  262. package/dist/utils/copyDirectory.d.ts +0 -33
  263. package/dist/utils/copyDirectory.d.ts.map +0 -1
  264. package/dist/utils/copyDirectory.js.map +0 -1
  265. package/dist/utils/createDirectory.d.ts +0 -34
  266. package/dist/utils/createDirectory.d.ts.map +0 -1
  267. package/dist/utils/createDirectory.js.map +0 -1
  268. package/dist/utils/createZip.d.ts +0 -39
  269. package/dist/utils/createZip.d.ts.map +0 -1
  270. package/dist/utils/createZip.js.map +0 -1
  271. package/dist/utils/deepCopy.d.ts +0 -32
  272. package/dist/utils/deepCopy.d.ts.map +0 -1
  273. package/dist/utils/deepCopy.js.map +0 -1
  274. package/dist/utils/deepEqual.d.ts +0 -54
  275. package/dist/utils/deepEqual.d.ts.map +0 -1
  276. package/dist/utils/deepEqual.js.map +0 -1
  277. package/dist/utils/error.d.ts +0 -44
  278. package/dist/utils/error.d.ts.map +0 -1
  279. package/dist/utils/error.js.map +0 -1
  280. package/dist/utils/export.d.ts +0 -13
  281. package/dist/utils/export.d.ts.map +0 -1
  282. package/dist/utils/export.js.map +0 -1
  283. package/dist/utils/format.d.ts +0 -53
  284. package/dist/utils/format.d.ts.map +0 -1
  285. package/dist/utils/format.js.map +0 -1
  286. package/dist/utils/hex.d.ts +0 -89
  287. package/dist/utils/hex.d.ts.map +0 -1
  288. package/dist/utils/hex.js.map +0 -1
  289. package/dist/utils/inspector.d.ts +0 -87
  290. package/dist/utils/inspector.d.ts.map +0 -1
  291. package/dist/utils/inspector.js.map +0 -1
  292. package/dist/utils/isvalid.d.ts +0 -103
  293. package/dist/utils/isvalid.d.ts.map +0 -1
  294. package/dist/utils/isvalid.js.map +0 -1
  295. package/dist/utils/jestHelpers.d.ts +0 -139
  296. package/dist/utils/jestHelpers.d.ts.map +0 -1
  297. package/dist/utils/jestHelpers.js.map +0 -1
  298. package/dist/utils/network.d.ts +0 -101
  299. package/dist/utils/network.d.ts.map +0 -1
  300. package/dist/utils/network.js.map +0 -1
  301. package/dist/utils/spawn.d.ts +0 -35
  302. package/dist/utils/spawn.d.ts.map +0 -1
  303. package/dist/utils/spawn.js.map +0 -1
  304. package/dist/utils/tracker.d.ts +0 -108
  305. package/dist/utils/tracker.d.ts.map +0 -1
  306. package/dist/utils/tracker.js.map +0 -1
  307. package/dist/utils/wait.d.ts +0 -54
  308. package/dist/utils/wait.d.ts.map +0 -1
  309. package/dist/utils/wait.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import{B as e,y as r,S as st,U as jr,V as wr,X as ze,Y as Cr,Z as Sr,I as kr}from"./vendor_node_modules.js";import{u as Mr,S as Ir}from"./vendor_notistack.js";import{D as Ne,a as $e,b as We,B as se,c as Oe,d as te,A as Dr,I as G,C as Pr,e as Lr,T as V,f as he,M as Nr,g as Je,h as P,i as ke,F as $r,j as vt,k as Wr,l as Ve,m as Ee,n as ae,K as Ot,o as Vt,p as $t,L as at,q as tt,r as lt,s as Q,W as ot,t as dt,H as ct,u as re,V as Et,v as _t,w as Tr,E as Fr,Q as Xt,R as yt,S as Rr,x as Hr,U as Or,P as Vr,y as er,z as Wt,G as Ie,J as tr,N as rr,O as jt,X as or,Y as Er,Z as _r,_ as Ar,$ as zr,a0 as At,a1 as Ur,a2 as qr,a3 as Br,a4 as Qr,a5 as Gr,a6 as Kr,a7 as Jr,a8 as zt,a9 as Zr,aa as Yr,ab as Xr,ac as eo,ad as to,ae as ro,af as oo,ag as no,ah as io,ai as so,aj as ao,ak as lo,al as co,am as po,an as uo,ao as Ut,ap as Ze,aq as nr,ar as je,as as ir,at as wt,au as He,av as go,aw as mo,ax as Ae,ay as ho,az as pt,aA as Ue,aB as Mt,aC as fo,aD as xo}from"./vendor_mui.js";import{I as ne,m as bo,a as qt,b as vo,c as yo,d as Bt,e as jo,f as wo,g as Co,h as So,i as ko,j as Mo,k as Io,l as Do,n as Po,o as Lo,p as No,q as $o,r as Qt,s as Wo,t as To,u as Fo,v as Ro,w as Ho,x as Oo,y as Vo,z as Eo,A as Gt,B as _o,C as Ao}from"./vendor_mdi.js";import{Q as zo}from"./vendor_qrcode.js";import{F as Uo,v as qo,e as Bo,a as Qo,g as Go,b as Ko,c as Jo,d as It,A as Zo}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const d=document.createElement("link").relList;if(d&&d.supports&&d.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const f of a)if(f.type==="childList")for(const p of f.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&i(p)}).observe(document,{childList:!0,subtree:!0});function l(a){const f={};return a.integrity&&(f.integrity=a.integrity),a.referrerPolicy&&(f.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?f.credentials="include":a.crossOrigin==="anonymous"?f.credentials="omit":f.credentials="same-origin",f}function i(a){if(a.ep)return;a.ep=!0;const f=l(a);fetch(a.href,f)}})();function Yo({open:n,title:d,message:l,onConfirm:i,onCancel:a}){const f=y=>{o&&console.log("Confirmed"),y.preventDefault(),i()},p=y=>{o&&console.log("Canceled"),y.preventDefault(),a()};return e.jsxs(Ne,{open:n,children:[e.jsx($e,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:d})]})}),e.jsxs(We,{children:[e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"0",marginBottom:"20px",maxHeight:"350px",maxWidth:"350px"},children:e.jsx("p",{style:{flex:1,margin:"0"},children:l})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(se,{onClick:f,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(se,{onClick:p,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const Xo=({open:n,output:d,title:l,_command:i,_packageName:a,onInstall:f,onClose:p})=>{const y=r.useRef(null);return r.useEffect(()=>{o&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${y.current}`),setTimeout(()=>{o&&console.log("Scrolling to bottom:",y.current),y.current?.scrollIntoView({behavior:"smooth"})},0)},[d]),e.jsxs(Ne,{open:n,onClose:(t,I)=>{I==="backdropClick"||I==="escapeKeyDown"||p()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx($e,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:l})]})}),e.jsxs(We,{dividers:!0,style:{overflow:"hidden",display:"flex",flexDirection:"column",height:400,paddingBottom:0},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"16px",fontWeight:"bold",color:"var(--primary-color)"},children:"Process log"}),e.jsxs("ul",{style:{width:"100%",height:"100%",fontFamily:"monospace",fontSize:"14px",padding:"10px",margin:0,marginBottom:"10px",color:"var(--div-text-color)",background:"var(--div-bg-color)",overflow:"auto",listStyle:"none",boxSizing:"border-box",borderRadius:4,border:"4px solid var(--primary-color)",whiteSpace:"pre-wrap",display:"block"},children:[d.split(`
2
- `).map((t,I)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:t},I)),e.jsx("li",{ref:y,style:{padding:0,margin:0}})]})]}),e.jsxs(Oe,{sx:{justifyContent:"center"},children:[f&&e.jsx(se,{variant:"contained",onClick:f,children:"Install"}),e.jsx(se,{onClick:p,children:"Close"})]})]})},ut=[],_e=r.createContext(null);function en({children:n}){const[d,l]=r.useState(!1),[i,a]=r.useState(null),{enqueueSnackbar:f,closeSnackbar:p}=Mr(),y=r.useCallback(S=>{o&&console.log(`UiProvider closeSnackbarMessage: message ${S}`);const j=ut.findIndex(k=>k.message===S);j!==-1&&(p(ut[j].key),ut.splice(j,1),o&&console.log(`UiProvider closeSnackbarMessage: message ${S} removed from persistMessages`))},[p]),t=r.useCallback((S,j,k)=>{o&&console.log(`UiProvider showSnackbarMessage: message ${S} timeout ${j}`);const A=f(S,{variant:"default",autoHideDuration:j==null||j>0?(j??5)*1e3:null,persist:j===0,content:J=>e.jsx(te,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Dr,{severity:k??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>p(J),action:e.jsx(G,{size:"small",onClick:()=>p(J),sx:{color:"#fff"},children:e.jsx(Pr,{fontSize:"small"})}),children:S},J)},J)});j===0&&(o&&console.log(`UiProvider showSnackbarMessage: message ${S} timeout ${j} - persist key ${A}`),ut.push({message:S,key:A}))},[f,p]),[I,b]=r.useState(!1),[M,O]=r.useState(""),[E,T]=r.useState(""),[B,L]=r.useState(""),c=r.useRef(null),h=r.useRef(null),m=()=>{o&&console.log(`UiProvider handle confirm action ${B}`),b(!1),c.current&&c.current(B)},H=()=>{o&&console.log(`UiProvider handle cancel action ${B}`),b(!1),h.current&&h.current(B)},D=r.useCallback((S,j,k,A,J)=>{o&&console.log(`UiProvider showConfirmCancelDialog for command ${k}`),O(S),T(j),L(k),c.current=A,h.current=J,b(!0)},[]),[C,q]=r.useState(!1),[N,g]=r.useState(""),[s,u]=r.useState(""),[x,R]=r.useState(""),[pe,xe]=r.useState(""),ie=r.useCallback((S,j,k)=>{o&&console.log(`UiProvider show install progress for package ${S}`),g(S),u(j),R(k),q(!0)},[]),ve=r.useCallback(S=>{o&&console.log(`UiProvider addInstallProgress: output ${S}`),xe(j=>j+S+`
3
- `)},[]),F=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${x}`)},[x]),U=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressError: package ${x}`)},[x]),W=r.useCallback(()=>{o&&console.log("UiProvider hide install progress"),q(!1)},[]),Y=()=>{o&&console.log("UiProvider handle install close action"),q(!1),R(""),xe("")},$=r.useMemo(()=>({mobile:d,setMobile:l,currentPage:i,setCurrentPage:a,showSnackbarMessage:t,closeSnackbarMessage:y,closeSnackbar:p,showConfirmCancelDialog:D,showInstallProgress:ie,exitInstallProgressSuccess:F,exitInstallProgressError:U,hideInstallProgress:W,addInstallProgress:ve}),[d,i,l,a,t,y,p,D,ie,F,U,W,ve]);return e.jsxs(_e.Provider,{value:$,children:[e.jsx(Yo,{open:I,title:M,message:E,onConfirm:m,onCancel:H}),e.jsx(Xo,{open:C,title:N,_command:s,_packageName:x,output:pe,onClose:Y}),n]})}const sr=r.createContext(null),fe=r.createContext(null);function tn({children:n}){const[d,l]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[i,a]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[f,p]=r.useState([]),[y,t]=r.useState(1e3),[I,b]=r.useState(!0),[M,O]=r.useState(!1),{showSnackbarMessage:E,closeSnackbarMessage:T,closeSnackbar:B,showInstallProgress:L,hideInstallProgress:c,exitInstallProgressSuccess:h,exitInstallProgressError:m,addInstallProgress:H}=r.useContext(_e),D=r.useRef([]),C=r.useRef(null),q=r.useRef(1),N=r.useRef(Math.floor(Math.random()*999e3)+1e3),g=r.useRef(null),s=r.useRef(null),u=r.useRef(null),x=r.useRef(d),R=r.useRef(i),pe=r.useRef(0),xe=r.useRef(null),ie=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),ve=r.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),F=100,U=60,W=50,Y=300,$=10;r.useEffect(()=>(o&&console.log("WebSocket messages started counter interval"),xe.current=setInterval(()=>{pe.current>0&&(o&&console.log(`WebSocket messages received in the last ${$} seconds: ${pe.current*(60/$)} messages/minute`),pe.current=0)},$*1e3),()=>{o&&console.log("WebSocket messages stopped counter interval"),xe.current&&clearInterval(xe.current),xe.current=null}),[]),r.useEffect(()=>{x.current=d},[d]),r.useEffect(()=>{R.current=i},[i]);const S=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),j=r.useCallback(K=>{if(C.current&&C.current.readyState===WebSocket.OPEN)try{o&&console.log(`WebSocket sending message with id ${K.id}:`,K),K.id===void 0&&(K.id=N.current);const _=JSON.stringify(K);C.current.send(_),o&&console.log("WebSocket sent message:",K)}catch(_){o&&console.error(`WebSocket error sending message: ${_}`)}else o&&console.error("WebSocket message not sent, WebSocket not connected:",K)},[]),k=r.useCallback((K,_)=>{p(w=>[...w,{level:K,time:"",name:"",message:_}])},[]),A=r.useCallback((K,_)=>{l(K),a(_),k("WebSocket",`Filtering by log level "${K}" and log search "${_}"`)},[k]),J=r.useCallback((K,_)=>{o&&console.log(`WebSocket addListener id ${_}:`,K),(_==null||isNaN(_)||_===0)&&console.error("WebSocket addListener called without id, listener not added:",K),D.current=[...D.current,{listener:K,id:_}],o&&console.log("WebSocket addListener total listeners:",D.current.length)},[]),ue=r.useCallback(K=>{o&&console.log("WebSocket removeListener:",K),D.current=D.current.filter(_=>_.listener!==K),o&&console.log("WebSocket removeListener total listeners:",D.current.length)},[]),de=r.useCallback(()=>{if(ie===""||ie===null||ie===void 0)return;const K=new URL("/",ie);St&&K.searchParams.set("password",St),k("WebSocket",`Connecting to WebSocket: ${ie}`),C.current=new WebSocket(K.toString()),C.current.onmessage=_=>{M||O(!0),pe.current+=1;try{const w=JSON.parse(_.data);if(w.id===void 0||w.src===void 0||w.dst===void 0){o&&console.error("WebSocket undefined message id/src/dst:",w);return}if(w.src!=="Matterbridge"||w.dst!=="Frontend"){o&&console.error("WebSocket invalid message src/dst:",w);return}if(w.error){o&&console.error("WebSocket error message response:",w);return}if(w.id===N.current&&w.method==="pong"&&w.response==="pong"){o&&console.log(`WebSocket pong response message id ${w.id}:`,w),s.current&&clearTimeout(s.current),s.current=null;return}else if(w.method==="snackbar"&&w.response&&w.response.message){o&&console.log(`WebSocket message id ${w.id} method ${w.method}:`,w),E(w.response.message,w.response.timeout,w.response.severity);return}else if(w.method==="close_snackbar"&&w.response&&w.response.message){o&&console.log(`WebSocket message id ${w.id} method ${w.method}:`,w),T(w.response.message);return}else if(w.method==="log"){if(!w.response||!w.response.level||!w.response.time||!w.response.name||!w.response.message||(w.response.level==="spawn"&&(w.response.name==="Matterbridge:spawn-init"?L(w.response.message,"",""):w.response.name==="Matterbridge:spawn-exit-success"?h():w.response.name==="Matterbridge:spawn-exit-error"?m():H(w.response.message+`
4
- `)),["debug","info","notice","warn","error","fatal"].includes(w.response.level)&&(x.current==="info"&&w.response.level==="debug"||x.current==="notice"&&(w.response.level==="debug"||w.response.level==="info")||x.current==="warn"&&(w.response.level==="debug"||w.response.level==="info"||w.response.level==="notice")||x.current==="error"&&(w.response.level==="debug"||w.response.level==="info"||w.response.level==="notice"||w.response.level==="warn")||x.current==="fatal"&&(w.response.level==="debug"||w.response.level==="info"||w.response.level==="notice"||w.response.level==="warn"||w.response.level==="error")))||R.current!=="*"&&R.current!==""&&!w.response.message.toLowerCase().includes(R.current.toLowerCase())&&!w.response.name.toLowerCase().includes(R.current.toLowerCase())||w.response.name==="Commissioning"&&w.response.message.includes("is uncommissioned"))return;p(le=>{const ee=[...le,{level:w.response.level,time:w.response.time,name:w.response.name,message:w.response.message}];return ee.length>y*2?ee.slice(y):ee})}else{if(o&&console.log(`WebSocket received message id ${w.id} method ${w.method}:`,w),w.id===0)D.current.forEach(be=>be.listener(w));else{const be=D.current.find(le=>le.id===w.id);be?be.listener(w):console.warn(`WebSocket no listener found for message id ${w.id}:`,w)}return}}catch(w){console.error(`WebSocket error parsing message: ${w}`,w instanceof Error?w.stack:null)}},C.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${ie}`),k("WebSocket",`Connected to WebSocket: ${ie}`),O(!0),B(),q.current=1,u.current=setTimeout(()=>{g.current=setInterval(()=>{j({id:N.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${ie}`),k("WebSocket",`No pong response received from WebSocket: ${ie}`),O(!1)},1e3*W)},1e3*U)},1e3*Y)},C.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${ve?"with Ingress":""}: ${ie}`),k("WebSocket",`Disconnected from WebSocket: ${ie}`),O(!1),B(),c(),u.current&&clearTimeout(u.current),s.current&&clearTimeout(s.current),g.current&&clearInterval(g.current),k("WebSocket",`Reconnecting (attempt ${q.current} of ${F}) to WebSocket${ve?" (Ingress)":""}: ${ie}`),ve?setTimeout(ce,5e3):q.current===1?ce():q.current<F?setTimeout(ce,1e3*q.current):k("WebSocket",`Reconnect attempts exceeded limit of ${F} retries, refresh the page to reconnect to: ${ie}`),q.current=q.current+1},C.current.onerror=_=>{o&&console.error(`WebSocket: WebSocket error connecting to ${ie}:`,_),k("WebSocket",`WebSocket error connecting to ${ie}`)}},[ie]),ce=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${q.current}/${F} to:`,ie),de()},[de]);r.useEffect(()=>(de(),()=>{C.current&&C.current.readyState===WebSocket.OPEN&&C.current.close()}),[de]);const me=r.useMemo(()=>({messages:f,maxMessages:y,autoScroll:I,setMessages:p,setLogFilters:A,setMaxMessages:t,setAutoScroll:b}),[f,p,A]),z=r.useMemo(()=>({maxMessages:y,autoScroll:I,logFilterLevel:d,logFilterSearch:i,setMessages:p,setLogFilters:A,setMaxMessages:t,setAutoScroll:b,online:M,retry:q.current,getUniqueId:S,addListener:J,removeListener:ue,sendMessage:j,logMessage:k}),[y,I,p,A,t,b,M,q.current,J,ue,j,k]);return e.jsx(sr.Provider,{value:me,children:e.jsx(fe.Provider,{value:z,children:n})})}function rn(n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 296.2 296.2",...n,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"lg1",x1:"16.6",y1:"16.6",x2:"279.6",y2:"279.6",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".1",stopColor:"#3faa77"}),e.jsx("stop",{offset:".3",stopColor:"#234148"}),e.jsx("stop",{offset:".7",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#ad2e6e"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg2",x1:"31.1",y1:"31.1",x2:"265.1",y2:"265.1",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".2",stopColor:"#285251"}),e.jsx("stop",{offset:".4",stopColor:"#234148"}),e.jsx("stop",{offset:".8",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#a8316c"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg3",x1:"116.2",y1:"143.9",x2:"139.8",y2:"143.9",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#8bc751"}),e.jsx("stop",{offset:"1",stopColor:"#0db14b"})]}),e.jsx("linearGradient",{id:"lg4",x1:"136.1",y1:"100.8",x2:"159.6",y2:"100.8",xlinkHref:"#lg3"}),e.jsx("linearGradient",{id:"lg5",x1:"155.3",y1:"143.9",x2:"178.9",y2:"143.9",xlinkHref:"#lg3"}),e.jsxs("linearGradient",{id:"lg6",x1:"46.8",y1:"25.7",x2:"89.6",y2:"74.8",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#b1d34a"}),e.jsx("stop",{offset:"1",stopColor:"#50b848"})]})]}),e.jsx("rect",{width:"296.2",height:"296.2",rx:"56.7",ry:"56.7",style:{fill:"url(#lg1)"}}),e.jsx("rect",{x:"16.3",y:"16.3",width:"263.6",height:"263.6",rx:"50.5",ry:"50.5",style:{fill:"url(#lg2)"}}),e.jsx("circle",{cx:"128",cy:"143.9",r:"11.8",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"147.8",cy:"100.8",r:"11.8",style:{fill:"url(#lg4)"}}),e.jsx("path",{d:"m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"167.1",cy:"143.9",r:"11.8",style:{fill:"url(#lg5)"}}),e.jsx("path",{fill:"#fff",d:"M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z"}),e.jsx("path",{d:"M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z",style:{fill:"url(#lg6)"}}),e.jsx("path",{d:"M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z",fill:"#1e5857"}),e.jsx("path",{fill:"#fff",d:"M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z"})]})}function De(){const{retry:n}=r.useContext(fe),d=()=>{window.location.reload()};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center",fontSize:"20px",color:"var(--main-text-color)",backgroundColor:"var(--main-bg-color)"},children:[e.jsx(rn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(Lr,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+n+")","..."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{})]}),e.jsx(se,{variant:"contained",color:"primary",onClick:d,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function on({value:n,maxChars:d}){let l=n;if(n.length>d&&d>3){const i=d-3,a=n.substring(0,Math.ceil(i/2)),f=n.substring(n.length-Math.floor(i/2),n.length);l=`${a} … ${f}`}return n!==l?e.jsx(V,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:l})}):e.jsx("span",{children:l})}function Me({children:n,style:d}){const l={display:"flex",flexDirection:"column",flex:"0 0 auto",width:"100%",overflow:"hidden",margin:"0px",padding:"0px",gap:"0px",backgroundColor:"var(--div-bg-color)",boxShadow:"5px 5px 10px var(--div-shadow-color)",border:"1px solid var(--table-border-color)",borderRadius:"var(--div-border-radius)",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function Ye({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",borderBottom:"1px solid var(--table-border-color)",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function Xe({children:n,style:d}){const l={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function gt({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function mt({children:n,style:d}){const l={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function rt({children:n,style:d}){const l={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function nt({children:n,style:d,onClose:l}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...d},children:[n,ji]})}function nn({systemInfo:n,compact:d}){const{addListener:l,removeListener:i,getUniqueId:a,sendMessage:f}=r.useContext(fe),[p,y]=r.useState(n),t=r.useRef(a());if(o&&console.log("SystemInfoTable loading with systemInfo:",p,"compact:",d),n&&d&&p.totalMemory&&p.freeMemory){const L=p.totalMemory,c=p.freeMemory;p.freeMemory=`${c} / ${L}`,p.totalMemory=""}if(n&&d&&p.heapTotal&&p.heapUsed){const L=p.heapTotal,c=p.heapUsed;p.heapUsed=`${c} / ${L}`,p.heapTotal=""}if(n&&d&&p.osRelease&&p.osType){const L=p.osType,c=p.osRelease;p.osType=`${L} (${c})`,p.osRelease=""}if(n&&d&&p.osArch&&p.osPlatform){const L=p.osPlatform,c=p.osArch;p.osPlatform=`${L} (${c})`,p.osArch=""}const I=(L,c,h,m,H)=>{y(D=>({...D,totalMemory:L,freeMemory:c,heapTotal:h,heapUsed:m,rss:H}))},b=L=>{y(c=>({...c,cpuUsage:L.toFixed(2)+" %"}))},M=L=>{y(c=>({...c,processCpuUsage:L.toFixed(2)+" %"}))},O=(L,c)=>{y(h=>({...h,systemUptime:L,processUptime:c}))},E=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),f({id:t.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const L=c=>{o&&console.log("SystemInfoTable received WebSocket Message:",c),c.method==="memory_update"&&c.response&&c.response.totalMemory&&c.response.freeMemory&&c.response.heapTotal&&c.response.heapUsed&&c.response.rss?(o&&console.log("SystemInfoTable received memory_update",c),I(c.response.totalMemory,c.response.freeMemory,c.response.heapTotal,c.response.heapUsed,c.response.rss)):c.method==="cpu_update"&&c.response&&c.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",c),b(c.response.cpuUsage),M(c.response.processCpuUsage)):c.method==="uptime_update"&&c.response&&c.response.systemUptime&&c.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",c),O(c.response.systemUptime,c.response.processUptime)):c.method==="/api/viewhistorypage"&&c.id===t.current&&c.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return l(L,t.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${t.current}`),()=>{i(L),o&&console.log("SystemInfoTable removed WebSocket listener")}},[l,i]);const[T,B]=r.useState(!1);return!p||T?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(Me,{style:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ye,{children:[e.jsx(Xe,{children:"System Information"}),e.jsx(nt,{onClose:()=>B(!0),children:e.jsx(G,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:E,children:e.jsx(V,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(ne,{path:bo,size:"22px"})})})})]}),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(p).filter(([L,c])=>c!==void 0&&c!=="").map(([L,c],h)=>e.jsxs("tr",{className:h%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:L.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(on,{value:typeof c!="string"?c.toString():c,maxChars:24})})]},L))})})})]}))}const sn=r.memo(nn),Kt={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"}},an=n=>{if(!n)return"";const d=n.toString().replace(/[^0-9]/g,"");if(d.length<5)return d;const l=d.slice(0,4),i=d.slice(4,7),a=d.slice(7,11);return[l,i,a].filter(Boolean).join("-")};function ln({id:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:f}=r.useContext(fe),[p,y]=r.useState(null),t=r.useRef(null),I=r.useRef(null),b=r.useRef(f()),{showConfirmCancelDialog:M}=r.useContext(_e);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${I.current} and matter:`,p),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),t.current=n,I.current&&clearTimeout(I.current),I.current=null,n?(o&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),l({id:b.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:n,server:!0}})):(o&&console.log("QRDiv id effect setting matter to null"),y(null))},[n,l]),r.useEffect(()=>{const c=h=>{o&&console.log("QRDiv received WebSocket Message:",h),h.method==="refresh_required"&&h.response.changed==="matter"&&h.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${h.response.changed} for storeId "${h.response.matter.id}":`,h.response.matter),t.current===h.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${h.response.matter.id}":`,h.response.matter),I.current&&clearTimeout(I.current),h.response.matter.advertising&&h.response.matter.advertiseTime&&h.response.matter.advertiseTime+9e5<=Date.now()&&(h.response.matter.advertising=!1),y(h.response.matter),h.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${h.response.matter.id}":`,h.response.matter.advertiseTime+9e5-Date.now()),I.current=setTimeout(()=>{I.current&&clearTimeout(I.current),o&&console.log(`QRDiv clearing advertising state for storeId "${t.current}" after 15 minutes`),y(m=>m&&{...m,advertising:!1})},h.response.matter.advertiseTime+9e5-Date.now()))))};return i(c,b.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{a(c),I.current&&clearTimeout(I.current),I.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,a]);const O=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${p?.id}"`),p&&l({id:b.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,startCommission:!0}})},E=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${p?.id}"`),p&&l({id:b.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,stopCommission:!0}})},T=()=>{o&&console.log(`QRDiv sent matter advertise for node "${p?.id}"`),p&&l({id:b.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,advertise:!0}})},B=c=>{o&&console.log(`QRDiv sent matter removeFabric for node "${p?.id}" and fabricIndex ${c}`),p&&l({id:b.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,removeFabric:c}})},L=async()=>{if(!p||!p.manualPairingCode)return;const c=p.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(c);else{const h=document.createElement("textarea");h.value=c,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.focus(),h.select(),document.execCommand("copy"),document.body.removeChild(h)}o&&console.log("Manual pairing code copied to clipboard")}catch(h){console.error("Failed to copy manual pairing code",h)}};return!p||!d?(o&&console.log("QRDiv rendering undefined state"),null):p.online?p.advertising&&p.qrPairingCode&&p.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(Me,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs(Ye,{children:[e.jsx(Xe,{children:"QR pairing code"}),e.jsxs(nt,{children:[e.jsx(G,{"aria-label":"send advertising",size:"small",onClick:T,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:qt,size:"22px"})})}),e.jsx(G,{"aria-label":"stop pairing",size:"small",onClick:E,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Turn off pairing",arrow:!0,children:e.jsx(ne,{path:vo,size:"22px"})})})]})]}),e.jsx(rt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(zo,{value:p.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(gt,{style:{justifyContent:"space-between"},children:[e.jsxs(mt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",an(p.manualPairingCode)]}),e.jsx(nt,{children:e.jsx(V,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(G,{"aria-label":"copy manual pairing code",size:"small",onClick:L,sx:Kt,children:e.jsx(ne,{path:yo,size:.85})})})})]})]})):p.commissioned&&p.fabricInformations&&p.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(Me,{style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Ye,{children:[e.jsx(Xe,{children:"Paired fabrics"}),e.jsxs(nt,{children:[e.jsx(G,{"aria-label":"send advertising",size:"small",onClick:T,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:qt,size:"22px"})})}),e.jsx(G,{"aria-label":"start pairing",size:"small",onClick:O,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Turn on pairing",arrow:!0,children:e.jsx(ne,{path:Bt,size:"22px"})})})]})]}),e.jsx(rt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:p.fabricInformations.map((c,h)=>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: ",c.fabricIndex]}),e.jsx(V,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(G,{"aria-label":"remove the fabric",size:"small",onClick:()=>M("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>B(c.fabricIndex),()=>{}),sx:{...Kt,padding:"2px"},children:e.jsx(ne,{path:jo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",c.rootVendorId," ",c.rootVendorName]}),c.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",c.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",p.sessionInformations?p.sessionInformations.filter(m=>m.fabric?.fabricIndex===c.fabricIndex&&m.isPeerActive===!0).length:"0"," ","subscriptions: ",p.sessionInformations?p.sessionInformations.filter(m=>m.fabric?.fabricIndex===c.fabricIndex&&m.isPeerActive===!0&&m.numberOfActiveSubscriptions>0).length:"0"]})]},h))}),e.jsx(gt,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",p.serialNumber]})})]})):!p.commissioned&&!p.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(Me,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Ye,{children:e.jsx(Xe,{children:"QR pairing code"})}),e.jsx(rt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(se,{onClick:O,endIcon:e.jsx(ne,{path:Bt,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx(gt,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",p.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(Me,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Ye,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(Xe,{children:"Server node"})}),e.jsx(rt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(rt,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(gt,{style:{justifyContent:"center"},children:e.jsxs(mt,{style:{fontWeight:"normal"},children:["Serial number: ",p.serialNumber]})})]}))}const dn=r.memo(ln);function cn(){const{logMessage:n,sendMessage:d,getUniqueId:l}=r.useContext(fe),[i,a]=r.useState("matterbridge-"),[f,p]=r.useState(!1),[y,t]=r.useState(null),I=r.useRef(l()),b=N=>{N.preventDefault(),p(!0)},M=()=>{p(!1)},O=N=>{N.preventDefault(),p(!1);const g=N.dataTransfer.files[0];if(g){n("Plugins",`Installing package ${g.name}. Please wait...`);const s=new FormData;s.append("file",g),s.append("filename",g.name),fetch("./api/uploadpackage",{method:"POST",body:s}).then(u=>u.text()).then(u=>{n("Plugins",`Server response: ${u}`)}).catch(u=>{console.error("Error uploading plugin file:",u),n("Plugins",`Error installing package ${u}`)})}},E=N=>{const g=N.target.files&&N.target.files[0];if(g){n("Plugins",`Uploading package ${g.name}`);const s=new FormData;s.append("file",g),s.append("filename",g.name),fetch("./api/uploadpackage",{method:"POST",body:s}).then(u=>u.text()).then(u=>{n("Plugins",`Server response: ${u}`)}).catch(u=>{console.error("Error uploading plugin file:",u),n("Plugins",`Error uploading package ${u}`)})}},T=()=>{d({id:I.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:i,restart:!1}})},B=()=>{document.getElementById("file-upload")?.click()},L=()=>{d({id:I.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:i}})},c=N=>{N.preventDefault(),d({id:I.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:i}})},h=N=>{N.preventDefault(),console.log("Right-clicked Upload button")},m=N=>{N.preventDefault(),console.log("Right-clicked Add button")},H=N=>{t(N.currentTarget)},D=N=>{N!==""&&a(N),t(null)},[C,q]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),C?null:e.jsxs(Me,{children:[e.jsxs(Ye,{children:[e.jsx(Xe,{children:"Install plugins"}),e.jsx(nt,{onClose:()=>q(!0)})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:b,onDragLeave:M,onDrop:O,children:[e.jsx(he,{value:i,onChange:N=>{a(N.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(G,{onClick:H,children:e.jsx(Nr,{})}),e.jsxs(Je,{id:"simple-menu",anchorEl:y,keepMounted:!0,open:!!y,onClose:()=>D(""),children:[e.jsx(P,{onClick:()=>D("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(P,{onClick:()=>D("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(P,{onClick:()=>D("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(P,{onClick:()=>D("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(P,{onClick:()=>D("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(P,{onClick:()=>D("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(P,{onClick:()=>D("matterbridge-test"),children:"matterbridge-test"}),e.jsx(P,{onClick:()=>D("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(P,{onClick:()=>D("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(P,{onClick:()=>D("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(P,{onClick:()=>D("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(P,{onClick:()=>D("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(P,{onClick:()=>D("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(P,{onClick:()=>D("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(V,{title:"Install or update a plugin from npm",children:e.jsxs(se,{onClick:T,onContextMenu:c,endIcon:e.jsx(ke,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(V,{title:"Upload and install a plugin from a tarball",children:e.jsxs(se,{onClick:B,onContextMenu:h,endIcon:e.jsx($r,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(V,{title:"Add an installed plugin",children:e.jsxs(se,{onClick:L,onContextMenu:m,endIcon:e.jsx(vt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Add"]})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:E})]})]})}const pn=r.memo(cn);function qe({status:n,enabledText:d="Enabled",disabledText:l=void 0,tooltipText:i=void 0,onClick:a}){if(n===void 0)return null;{const f=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:a,children:n?d:l??d});return i!==void 0?e.jsx(V,{title:i,children:f}):f}}function un(n,d,l){const i=n?.[l],a=d?.[l];return i==null&&a==null?0:i==null?-1:a==null?1:typeof i=="boolean"&&typeof a=="boolean"?i===a?0:i?1:-1:typeof i=="number"&&typeof a=="number"?i-a:String(i).localeCompare(String(a))}function gn({name:n,title:d,columns:l,rows:i,getRowKey:a,footerLeft:f,footerRight:p,onRowClick:y}){const t=r.useRef(new WeakMap),I=r.useRef(1),b=g=>{if(typeof a=="string"&&g&&g[a]!=null)return g[a];if(typeof a=="function"){const x=a(g);if(x!=null)return x}const s=l?.[0]?.id;if(s&&g&&g[s]!=null)return g[s];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let u=t.current.get(g);return u||(u=`rk_${I.current++}`,t.current.set(g,u)),u},[M,O]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[E,T]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[B,L]=r.useState(!1),[c,h]=r.useState(()=>{try{const g=localStorage.getItem(`${n}_column_visibility`);if(g)return JSON.parse(g)}catch{}return{}}),m=r.useMemo(()=>{const g={};for(const s of l)s.hidden||(g[s.id]=s.required?!0:c[s.id]!==!1);return g},[l,c]),H=r.useMemo(()=>{if(!M||!E)return i;const g=l.find(u=>u.id===M);if(!g||g.noSort)return i;const s=i.map((u,x)=>({el:u,index:x}));return s.sort((u,x)=>{let R;return typeof g.comparator=="function"?R=g.comparator(u.el,x.el):R=un(u.el,x.el,M),R!==0?E==="asc"?R:-R:u.index-x.index}),s.map(u=>u.el)},[i,M,E,l]),D=g=>{if(M!==g||!M){O(g),T("asc"),localStorage.setItem(`${n}_table_order_by`,g),localStorage.setItem(`${n}_table_order`,"asc");return}if(E==="asc"){T("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}O(null),T(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},C=()=>{L(!B)},q=g=>{h(s=>{const u=l.find(pe=>pe.id===g);if(u&&u.required)return s;const x=m[g]!==!1,R={...s};x?R[g]=!1:delete R[g];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(R))}catch{}return R})},N=()=>{h({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}L(!1)};return o&&console.log(`Rendering table ${n}${M&&E?` ordered by ${M}:${E}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(Ne,{open:B,onClose:(g,s)=>{s==="backdropClick"||s==="escapeKeyDown"||C()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx($e,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${n} columns`})]})}),e.jsx(We,{children:e.jsx(Wr,{children:l.filter(g=>!g.hidden).map(g=>e.jsx(Ve,{control:e.jsx(Ee,{disabled:!!g.required,checked:g.required?!0:m[g.id]!==!1,onChange:()=>q(g.id)}),label:g.label},g.id))})}),e.jsxs(Oe,{children:[e.jsx(se,{onClick:N,children:"Reset"}),e.jsx(se,{variant:"contained",onClick:g=>{if(g?.currentTarget&&typeof g.currentTarget.blur=="function")try{g.currentTarget.blur()}catch{}const s=document.activeElement;if(s&&s instanceof HTMLElement&&typeof s.blur=="function")try{s.blur()}catch{}C()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:n}),d&&e.jsx("p",{className:"MbfWindowHeaderText",children:d}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(G,{onClick:g=>{if(g?.currentTarget?.blur)try{g.currentTarget.blur()}catch{}C()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(V,{title:`Configure ${n} columns`,children:e.jsx(ne,{path:wo,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:l.map(g=>{if(g.hidden||!g.required&&m[g.id]===!1)return null;const s=!g.noSort,u=s&&M===g.id&&!!E;return e.jsxs("th",{onClick:s?()=>D(g.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:g.minWidth,maxWidth:g.maxWidth,textAlign:g.align||"left",cursor:s?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:g.maxWidth?"nowrap":void 0,overflow:g.maxWidth?"hidden":void 0,textOverflow:g.maxWidth?"ellipsis":void 0},"aria-sort":s?u?E==="asc"?"ascending":"descending":"none":void 0,children:[g.label,u&&e.jsxs("span",{style:{marginLeft:6},children:[E==="asc"&&e.jsx(ne,{path:Co,size:"15px"}),E==="desc"&&e.jsx(ne,{path:So,size:"15px"})]})]},g.id)})})}),e.jsx("tbody",{children:H.map((g,s)=>{const u=b(g);return e.jsx("tr",{className:s%2===0?"table-content-even":"table-content-odd",onClick:y?x=>y(g,u,x):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:y?"pointer":void 0},children:l.map(x=>{if(x.hidden||!x.required&&m[x.id]===!1)return null;const R=g[x.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:x.align||"left",padding:"5px 10px",margin:"0",maxWidth:x.maxWidth,whiteSpace:x.maxWidth?"nowrap":void 0,overflow:x.maxWidth?"hidden":void 0,textOverflow:x.maxWidth?"ellipsis":void 0},children:typeof x.render=="function"?x.render(R,u,g,x):typeof R=="boolean"?e.jsx(Ee,{checked:R,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):x.format&&typeof R=="number"?x.format(R):R!=null?String(R):null},x.id)})},u)})})]})}),(f||p)&&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:f}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:p})]})]})}function mn(n){return r.memo(n)}const Ct=mn(gn);function Jt(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const Be={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Qe={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},hn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},fn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Fe={padding:"0px",margin:"0px"},xn="5px 10px 5px 10px",ht={},ye={},ft={},xt={};let Ge=[],Dt=[];const bn=({open:n,onClose:d,plugin:l})=>{const{sendMessage:i,addListener:a,removeListener:f,getUniqueId:p}=r.useContext(fe),y=r.useRef(p()),[t,I]=r.useState(l.configJson),[b,M]=r.useState(null),[O,E]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[T,B]=r.useState("");let L={};r.useEffect(()=>{const S=j=>{j.src==="Matterbridge"&&j.dst==="Frontend"&&(Jt(j)&&j.id===y.current&&j.method==="/api/select/devices"&&j.response&&(o&&console.log(`ConfigPluginDialog (id: ${j.id}) received ${j.response.length} /api/select/devices:`,j.response),Ge=j.response),Jt(j)&&j.id===y.current&&j.method==="/api/select/entities"&&j.response&&(o&&console.log(`ConfigPluginDialog (id: ${j.id}) received ${j.response.length} /api/select/entities:`,j.response),Dt=j.response))};return a(S,y.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",y.current),t&&b&&b.properties&&(Object.keys(b.properties).forEach(j=>{Object.keys(b.properties[j]).forEach(k=>{k.startsWith("ui:")&&(O[j]={},O[j][k]=b.properties[j][k],delete b.properties[j][k])})}),E(O)),l.name&&l.configJson&&l.schemaJson&&(I(l.configJson),M(l.schemaJson),i({id:y.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),i({id:y.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),o&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',l.name)),()=>{f(S),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[a,t,l,f,b,i,O]);const c=(S,j)=>{L=S.formData},h=S=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",S.formData),I(S.formData),l.configJson=S.formData,l.restartRequired=!0,i({id:y.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:S.formData.name,formData:S.formData}}),d()};function m(S){const{id:j,label:k,onKeyChange:A,onDropPropertyClick:J,disabled:ue,schema:de,children:ce,registry:me,readonly:z,required:K}=S,{templates:_}=me,{RemoveButton:w}=_.ButtonTemplates;if(!(Zo in de))return e.jsx(te,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:ce});const le=({target:ee})=>A(ee&&ee.value);return e.jsxs(te,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(he,{id:`${j}-key`,name:`${j}-key`,required:K,disabled:ue||z,defaultValue:k,onBlur:z?void 0:le,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(te,{sx:{flex:1},children:ce}),e.jsx(w,{disabled:ue||z,onClick:J(k),registry:me})]})}function H(S){const{children:j,description:k,displayLabel:A,errors:J,help:ue,hidden:de,registry:ce,uiSchema:me}=S,z=Ko(me),K=Jo("WrapIfAdditionalTemplate",ce,z);return de?e.jsx("div",{style:{display:"none"},children:j}):e.jsx(te,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(K,{...S,children:[A===!0&&k,j,J,ue]})})}function D(S){const{description:j}=S;return j?e.jsx(ae,{sx:Qe,children:j}):null}function C(S){const{required:j,title:k}=S;return k?e.jsx(te,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ae,{sx:Be,children:["Title ",k," ",j&&e.jsx("mark",{children:"***"})]})}):null}function q(S){const{help:j}=S;return j?e.jsx(te,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ae,{sx:hn,children:j})}):null}function N(S){const{errors:j}=S;return j?e.jsxs(te,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ae,{color:"error",sx:fn,children:"Please fix the following errors:"}),e.jsx(tt,{children:j.map((k,A)=>e.jsxs(Tr,{children:[e.jsx(Q,{children:e.jsx(Fr,{color:"error"})}),e.jsx(re,{primary:k.stack})]},A))})]}):null}function g(S){const{errors:j}=S;return j?e.jsx(te,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:j.map((k,A)=>e.jsxs(ae,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",k]},A))}):null}function s(S){const{id:j,name:k,_schema:A,_uiSchema:J,value:ue,options:de,label:ce,type:me,placeholder:z,required:K,disabled:_,readonly:w,autofocus:be,onChange:le,onChangeOverride:ee,onBlur:oe,onFocus:Pe,_rawErrors:Le,_hideError:et,_registry:v,_formContext:X}=S,Ce=({target:{value:Se}})=>le(Se===""?de.emptyValue:Se),Re=({target:Se})=>oe(j,Se&&Se.value),it=({target:Se})=>Pe(j,Se&&Se.value);return e.jsx(te,{sx:{padding:"0px",margin:"0px"},children:e.jsx(he,{id:j,name:j,label:z&&z!==""?ce:void 0,variant:"outlined",placeholder:z&&z!==""?z:ce,required:K,disabled:_||w,autoFocus:be,value:ue||ue===0?ue:"",type:me,autoComplete:me==="password"?"current-password":k,onChange:ee||Ce,onBlur:Re,onFocus:it,fullWidth:!0})})}function u(S){return console.log("ArrayFieldTitleTemplate:",S),null}function x(S){return console.log("ArrayFieldDescriptionTemplate:",S),null}function R(S){return console.log("ArrayFieldItemTemplate:",S),null}function pe(S){const{canAdd:j,onAddClick:k,schema:A,title:J}=S,[ue,de]=r.useState(!1),[ce,me]=r.useState(!1),[z,K]=r.useState(!1),[_,w]=r.useState(""),be=v=>{w(v.target.value)},le=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",_,"selectDevices:",Ge),de(!ue)},ee=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",_,"selectEntities:",Dt),me(!ce)},oe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",_,"selectDevices:",Ge),K(!z)},Pe=v=>{de(!1),A.selectFrom==="serial"?A.items.default=v.serial:A.selectFrom==="name"&&(A.items.default=v.name),k()},Le=v=>{me(!1),A.selectEntityFrom==="name"?A.items.default=v.name:A.selectEntityFrom==="description"&&(A.items.default=v.description),k()},et=v=>{K(!1),A.selectDeviceEntityFrom==="name"?A.items.default=v.name:A.selectDeviceEntityFrom==="description"&&(A.items.default=v.description),k()};return e.jsxs(te,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[J&&e.jsxs(te,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[J&&e.jsx(ae,{sx:Be,children:J}),j&&e.jsxs(te,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[A.selectFrom&&e.jsx(V,{title:"Add a device from the list",children:e.jsx(G,{onClick:le,size:"small",color:"primary",sx:Fe,children:e.jsx(at,{})})}),A.selectEntityFrom&&e.jsx(V,{title:"Add an entity from the list",children:e.jsx(G,{onClick:ee,size:"small",color:"primary",sx:Fe,children:e.jsx(at,{})})}),A.selectDeviceEntityFrom&&e.jsx(V,{title:"Add a device entity from the list",children:e.jsx(G,{onClick:oe,size:"small",color:"primary",sx:Fe,children:e.jsx(at,{})})}),e.jsx(V,{title:"Add a new item",children:e.jsx(G,{onClick:k,size:"small",color:"primary",sx:Fe,children:e.jsx(vt,{})})})]})]}),A.description&&e.jsx(ae,{sx:Qe,children:A.description}),S.items.map(v=>e.jsxs(te,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(te,{sx:{flexGrow:1,marginRight:"10px"},children:v.children}),e.jsx(G,{disabled:!v.hasMoveUp,onClick:v.onReorderClick(v.index,v.index-1),size:"small",color:"primary",sx:Fe,children:e.jsx(Vt,{})}),e.jsx(G,{disabled:!v.hasMoveDown,onClick:v.onReorderClick(v.index,v.index+1),size:"small",color:"primary",sx:Fe,children:e.jsx(Ot,{})}),e.jsx(G,{onClick:v.onDropIndexClick(v.index),size:"small",color:"primary",sx:Fe,children:e.jsx($t,{})})]},v.index)),e.jsxs(Ne,{open:ue,onClose:le,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx($e,{children:"Select a device"}),e.jsxs(We,{children:[e.jsxs(te,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ae,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:_,onChange:be,placeholder:"Enter serial or name"})]}),e.jsx(tt,{dense:!0,children:Ge.filter(v=>v.serial.toLowerCase().includes(_.toLowerCase())||v.name.toLowerCase().includes(_.toLowerCase())).map((v,X)=>e.jsxs(lt,{onClick:()=>Pe(v),sx:ht,children:[v.icon==="wifi"&&e.jsx(Q,{children:e.jsx(ot,{style:ye})}),v.icon==="ble"&&e.jsx(Q,{children:e.jsx(dt,{style:ye})}),v.icon==="hub"&&e.jsx(Q,{children:e.jsx(ct,{style:ye})}),e.jsx(re,{primary:v.name,secondary:v.serial,primaryTypographyProps:{style:ft},secondaryTypographyProps:{style:xt}})]},X))})]}),e.jsx(Oe,{children:e.jsx(se,{onClick:le,children:"Close"})})]}),e.jsxs(Ne,{open:ce,onClose:ee,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx($e,{children:"Select an entity"}),e.jsxs(We,{children:[e.jsxs(te,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ae,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:_,onChange:be,placeholder:"Enter name or description"})]}),e.jsx(tt,{dense:!0,children:Dt.filter(v=>v.name.toLowerCase().includes(_.toLowerCase())||v.description.toLowerCase().includes(_.toLowerCase())).map((v,X)=>e.jsxs(lt,{onClick:()=>Le(v),sx:ht,children:[v.icon==="wifi"&&e.jsx(Q,{children:e.jsx(ot,{style:ye})}),v.icon==="ble"&&e.jsx(Q,{children:e.jsx(dt,{style:ye})}),v.icon==="hub"&&e.jsx(Q,{children:e.jsx(ct,{style:ye})}),v.icon==="component"&&e.jsx(Q,{children:e.jsx(Et,{style:ye})}),v.icon==="matter"&&e.jsx(Q,{children:e.jsx(_t,{style:ye})}),e.jsx(re,{primary:v.name,secondary:v.description,primaryTypographyProps:{style:ft},secondaryTypographyProps:{style:xt}})]},X))})]}),e.jsx(Oe,{children:e.jsx(se,{onClick:ee,children:"Close"})})]}),e.jsxs(Ne,{open:z,onClose:oe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs($e,{children:["Select an entity for ",J]}),e.jsx(We,{children:e.jsx(tt,{dense:!0,children:Ge.filter(v=>v.serial===J||v.name===J).map(v=>v.entities?.map((X,Ce)=>e.jsxs(lt,{onClick:()=>et(X),sx:ht,children:[X.icon==="wifi"&&e.jsx(Q,{children:e.jsx(ot,{style:ye})}),X.icon==="ble"&&e.jsx(Q,{children:e.jsx(dt,{style:ye})}),X.icon==="hub"&&e.jsx(Q,{children:e.jsx(ct,{style:ye})}),X.icon==="component"&&e.jsx(Q,{children:e.jsx(Et,{style:ye})}),X.icon==="matter"&&e.jsx(Q,{children:e.jsx(_t,{style:ye})}),e.jsx(re,{primary:X.name,secondary:X.description,primaryTypographyProps:{style:ft},secondaryTypographyProps:{style:xt}})]},Ce)))})}),e.jsx(Oe,{children:e.jsx(se,{onClick:oe,children:"Close"})})]})]})}function xe(S){const{onAddClick:j,schema:k,properties:A,title:J,description:ue}=S,[de,ce]=r.useState(!1),[me,z]=r.useState(""),K=ee=>{z(ee.target.value)},_=()=>{ce(!de)},w=ee=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${ee.serial}" for schema "${k.selectFrom}"`),ce(!1);let oe="";k.selectFrom==="serial"?oe=ee.serial:k.selectFrom==="name"&&(oe=ee.name),B(oe),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${oe}"`),j(k)()},be=()=>{j(k)()},le=!k.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${le} newkey "${T}"`),!le&&T!==""&&(o&&console.log("ObjectFieldTemplate: newkey",T,"properties",A),A.forEach(ee=>{if(ee.name==="newKey"&&ee.content.key==="newKey"&&ee.content.props.name==="newKey"&&ee.content.props.onKeyChange&&T!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",T);const oe=T;B(""),ee.content.props.onKeyChange(oe)}})),e.jsxs(te,{sx:{margin:"0px",padding:le?"10px":"5px 10px 0px 10px",border:le?"none":"1px solid grey"},children:[k.title&&le&&e.jsx(te,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ae,{sx:Be,children:k.title})}),J&&!le&&e.jsxs(te,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ae,{sx:Be,children:J}),e.jsxs(te,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[k.selectFrom&&e.jsx(V,{title:"Add a device from the list",children:e.jsx(G,{onClick:_,size:"small",color:"primary",sx:Fe,children:e.jsx(at,{})})}),e.jsx(V,{title:"Add a new item",children:e.jsx(G,{onClick:be,size:"small",color:"primary",sx:Fe,children:e.jsx(vt,{})})})]})]}),k.description&&e.jsx(te,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ae,{sx:Qe,children:k.description})}),A.map(({content:ee,name:oe,hidden:Pe})=>!Pe&&e.jsxs(te,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(k.properties[oe].type)?"0px":xn,border:["object","array","boolean"].includes(k.properties[oe].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(k.properties[oe].type)&&e.jsx(ae,{sx:Be,children:oe}),e.jsx(te,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:ee})]},oe)),e.jsxs(Ne,{open:de,onClose:_,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx($e,{children:"Select a device"}),e.jsxs(We,{children:[e.jsxs(te,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ae,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{fullWidth:!0,variant:"outlined",value:me,onChange:K,placeholder:"Enter serial or name"})]}),e.jsx(tt,{dense:!0,children:Ge.filter(ee=>ee.serial.toLowerCase().includes(me.toLowerCase())||ee.name.toLowerCase().includes(me.toLowerCase())).map((ee,oe)=>e.jsxs(lt,{onClick:()=>w(ee),sx:ht,children:[ee.icon==="wifi"&&e.jsx(Q,{children:e.jsx(ot,{style:ye})}),ee.icon==="ble"&&e.jsx(Q,{children:e.jsx(dt,{style:ye})}),ee.icon==="hub"&&e.jsx(Q,{children:e.jsx(ct,{style:ye})}),e.jsx(re,{primary:ee.name,secondary:ee.serial,primaryTypographyProps:{style:ft},secondaryTypographyProps:{style:xt}})]},oe))})]}),e.jsx(Oe,{children:e.jsx(se,{onClick:_,children:"Close"})})]})]})}function ie(S){const{uiSchema:j}=S,{submitText:k,norender:A}=Go(j);return A?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(se,{type:"submit",variant:"contained",color:"primary",children:k}),e.jsx(se,{variant:"contained",color:"primary",onClick:d,children:"Cancel"})]})}function ve(S){const{className:j,disabled:k,onClick:A,registry:J,style:ue,uiSchema:de,...ce}=S;return e.jsx(V,{title:"Remove the item",children:e.jsx(G,{disabled:k,size:"small",color:"primary",onClick:A,children:e.jsx($t,{})})})}function F(S){const{className:j,disabled:k,onClick:A,registry:J,uiSchema:ue,...de}=S;return e.jsx(V,{title:"Add an item",children:e.jsx(G,{size:"small",color:"primary",onClick:A,children:e.jsx(vt,{})})})}function U(S){const{disabled:j,onClick:k,registry:A,style:J,uiSchema:ue,...de}=S;return e.jsx(V,{title:"Move up the item",children:e.jsx(G,{size:"small",color:"primary",onClick:k,children:e.jsx(Vt,{})})})}function W(S){const{disabled:j,onClick:k,registry:A,style:J,uiSchema:ue,...de}=S;return e.jsx(V,{title:"Move down the item",children:e.jsx(G,{size:"small",color:"primary",onClick:k,children:e.jsx(Ot,{})})})}function Y(S){const{id:j,name:k,value:A,schema:J,readonly:ue,onChange:de}=S,[ce,me]=r.useState(),z=_=>{o&&console.log(`CheckboxWidget ${k} onChangeField:`,_),me(_&&_!==""?_:void 0)},K=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${k}" value="${ce}"`),i({id:y.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:k,value:ce,formData:L,id:j}}),J.buttonClose===!0?d():J.buttonSave===!0&&h({formData:t})};return J.buttonText&&J.description?e.jsxs(te,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ae,{sx:Qe,children:J.description}),e.jsx(se,{variant:"contained",color:"primary",onClick:()=>K(),children:J.buttonText})]}):J.buttonField&&J.description?e.jsxs(te,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ae,{sx:Qe,children:J.description}),e.jsx(he,{id:k+"-input",name:k,label:J.textLabel,placeholder:J.textPlaceholder,onChange:_=>z(_.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(se,{id:k+"-button",variant:"contained",color:"primary",disabled:ce===void 0,onClick:()=>K(),children:J.buttonField})]}):e.jsxs(te,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[k&&e.jsxs(te,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(ae,{sx:Be,children:k}),e.jsx(Ee,{checked:A,readOnly:ue,onChange:()=>de(!A),sx:{padding:"0px",margin:"0px"}})]}),J.description&&e.jsx(ae,{sx:Qe,children:J.description})]})}function $({schema:S,id:j,name:k,options:A,label:J,hideLabel:ue,required:de,disabled:ce,placeholder:me,readonly:z,value:K,multiple:_,autofocus:w,onChange:be,onBlur:le,onFocus:ee,errorSchema:oe,rawErrors:Pe=[],registry:Le,uiSchema:et,hideError:v,formContext:X,...Ce}){const{enumOptions:Re,enumDisabled:it,emptyValue:Se}=A;_=typeof _>"u"?!1:!!_;const Tt=_?[]:"",Ft=typeof K>"u"||_&&K.length<1||!_&&K===Tt,pr=({target:{value:Te}})=>be(It(Te,Re,Se)),ur=({target:Te})=>le(j,It(Te&&Te.value,Re,Se)),gr=({target:Te})=>ee(j,It(Te&&Te.value,Re,Se)),Rt=Bo(K,Re,_),{InputLabelProps:mr,SelectProps:hr,autocomplete:fr,...xr}=Ce,br=!_&&S.default===void 0;return e.jsxs(he,{id:j,name:j,value:!Ft&&typeof Rt<"u"?Rt:Tt,required:de,disabled:ce||z,autoFocus:w,autoComplete:fr,placeholder:me,error:Pe.length>0,onChange:pr,onBlur:ur,onFocus:gr,...xr,select:!0,InputLabelProps:{...mr,shrink:!Ft},SelectProps:{...hr,multiple:_},"aria-describedby":Qo(j),children:[br&&e.jsx(P,{value:"",children:me}),Array.isArray(Re)&&Re.map(({value:Te,label:vr},Ht)=>{const yr=Array.isArray(it)&&it.indexOf(Te)!==-1;return e.jsx(P,{value:String(Ht),disabled:yr,children:vr},Ht)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!b||!t?null:e.jsxs(Ne,{open:n,onClose:d,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx($e,{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(We,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Uo,{schema:b,formData:t,uiSchema:O,validator:qo,templates:{FieldTemplate:H,BaseInputTemplate:s,TitleFieldTemplate:C,DescriptionFieldTemplate:D,FieldHelpTemplate:q,FieldErrorTemplate:g,ErrorListTemplate:N,WrapIfAdditionalTemplate:m,ArrayFieldTitleTemplate:u,ArrayFieldDescriptionTemplate:x,ArrayFieldItemTemplate:R,ArrayFieldTemplate:pe,ObjectFieldTemplate:xe,ButtonTemplates:{SubmitButton:ie,RemoveButton:ve,AddButton:F,MoveUpButton:U,MoveDownButton:W}},widgets:{CheckboxWidget:Y,SelectWidget:$},onChange:c,onSubmit:h})})]})};function ar(n){if(o&&console.log(`getQRColor (id: ${n?.id}) received matter:`,n??"undefined"),n===void 0||!n.online||!n.qrPairingCode&&!n.manualPairingCode&&!n.fabricInformations&&!n.sessionInformations)return"red";if(n.commissioned===!1&&n.qrPairingCode&&n.manualPairingCode)return"var(--primary-color)";let d=0,l=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&d++,i.numberOfActiveSubscriptions>0&&(l+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(d===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function vn({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:a,removeListener:f,getUniqueId:p}=r.useContext(fe),{showConfirmCancelDialog:y}=r.useContext(_e),t=r.useRef(p()),[I,b]=r.useState(null),[M,O]=r.useState(null),[E,T]=r.useState([]),B=[{label:"Name",id:"name",required:!0,render:(W,Y,$,S)=>e.jsx(V,{title:`Plugin path ${$.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>g($),children:$.name})})},{label:"Description",id:"description",render:(W,Y,$,S)=>e.jsx(V,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>g($),children:$.description})})},{label:"Version",id:"version",render:(W,Y,$,S)=>e.jsx(e.Fragment,{children:e.jsx(V,{title:`Plugin v.${$.version}`,children:e.jsx("span",{children:$.version.split("-dev-")[0]+($.version.includes("-dev-")?"@dev":"")})})})},{label:"Author",id:"author",render:(W,Y,$,S)=>e.jsx(e.Fragment,{children:$.author?$.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(W,Y,$,S)=>e.jsx(e.Fragment,{children:$.type?$.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(W,Y,$,S)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[M&&M.bridgeMode==="childbridge"&&!$.error&&$.enabled&&e.jsx(V,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:ar($.matter)},onClick:()=>{$.matter?.id&&d($.matter?.id)},size:"small",children:e.jsx(Xt,{})})}),M&&M.bridgeMode==="childbridge"&&!$.error&&$.enabled&&e.jsx(V,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>q($),size:"small",children:e.jsx(yt,{})})}),e.jsx(V,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{disabled:$.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>ve($),size:"small",children:e.jsx(Rr,{})})}),M&&!M.readOnly&&e.jsx(V,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{c("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",$)},size:"small",children:e.jsx(Hr,{})})}),$.enabled?e.jsx(V,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{c("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",$)},size:"small",children:e.jsx(Or,{})})}):e.jsx(e.Fragment,{}),$.enabled?e.jsx(e.Fragment,{}):e.jsx(V,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>N($),size:"small",children:e.jsx(Vr,{})})}),e.jsx(V,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>u($),size:"small",children:e.jsx(er,{})})}),e.jsx(V,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>x($),size:"small",children:e.jsx(Wt,{})})}),$.latestVersion!==void 0&&$.latestVersion!==$.version&&M&&!M.readOnly&&e.jsx(V,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>H($),size:"small",children:e.jsx(Ie,{})})}),$.version.includes("-dev-")&&$.devVersion!==void 0&&$.devVersion!==$.version&&M&&!M.readOnly&&e.jsx(V,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>D($),size:"small",children:e.jsx(Ie,{})})}),M&&!M.readOnly&&e.jsx(V,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>s($),size:"small",children:e.jsx(tr,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(W,Y,$,S)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:$.error?e.jsx(e.Fragment,{children:e.jsx(qe,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:$.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(qe,{status:$.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:$.loaded&&$.started&&$.configured?e.jsx(e.Fragment,{children:e.jsx(qe,{status:$.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(qe,{status:$.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(qe,{status:$.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(qe,{status:$.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const W=Y=>{o&&console.log("HomePlugins received WebSocket Message:",Y),Y.method==="refresh_required"&&Y.response.changed==="plugins"?(o&&console.log(`HomePlugins received refresh_required: changed=${Y.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):Y.method==="refresh_required"&&Y.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${Y.response.changed} and setting matter id ${Y.response.matter?.id}`),T($=>{const S=$.findIndex(k=>k.matter?.id===Y.response.matter?.id);if(S<0)return o&&console.log(`HomePlugins received refresh_required: changed=${Y.response.changed} and matter id ${Y.response.matter?.id} not found`),$;o&&console.log(`HomePlugins received refresh_required: changed=${Y.response.changed} set matter id ${Y.response.matter?.id}`);const j=[...$];return j[S]={...j[S],matter:Y.response.matter},j})):Y.method==="refresh_required"&&Y.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${Y.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),Y.id===t.current&&Y.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${Y.id}) received settings:`,Y.response),b(Y.response.systemInformation),O(Y.response.matterbridgeInformation)):Y.id===t.current&&Y.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${Y.id}) received ${Y.response.length} plugins:`,Y.response),T(Y.response))};return a(W,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{f(W),o&&console.log("HomePlugins removed WebSocket listener")}},[a,f,i]),r.useEffect(()=>{l&&(o&&console.log("HomePlugins sending api requests"),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const L=r.useRef(null),c=(W,Y,$,S)=>{o&&console.log(`handleActionWithConfirmCancel ${$} ${S.name}`),L.current=S,y(W,Y,$,h,m)},h=W=>{o&&console.log(`handleConfirm action confirmed ${W} ${L.current?.name}`),W==="remove"&&L.current?C(L.current):W==="disable"&&L.current&&N(L.current),L.current=null},m=W=>{o&&console.log(`handleCancel action canceled ${W} ${L.current?.name}`),L.current=null},H=W=>{o&&console.log("handleUpdatePlugin plugin:",W.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:W.name,restart:!1}})},D=W=>{o&&console.log("handleUpdateDevPlugin plugin:",W.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:W.name+"@dev",restart:!1}})},C=W=>{o&&console.log("handleRemovePlugin plugin:",W.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}})},q=W=>{o&&console.log("handleRestartPlugin plugin:",W.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}})},N=W=>{o&&console.log("handleEnableDisablePlugin plugin:",W.name,"enabled:",W.enabled),W.enabled===!0?(W.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}})):(W.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}}))},g=W=>{o&&console.log(`handleHomepagePlugin plugin: ${W.name} homepage: ${W.homepage}`),W.homepage&&window.open(W.homepage,"_blank")},s=W=>{o&&console.log("handleSponsorPlugin plugin:",W.name,"funding:",W.funding),W.funding&&window.open(W.funding,"_blank")},u=W=>{o&&console.log("handleHelpPlugin plugin:",W.name,"help:",W.help),W.help&&window.open(W.help,"_blank")},x=W=>{o&&console.log("handleChangelogPlugin plugin:",W.name,"changelog:",W.changelog),W.changelog&&window.open(W.changelog,"_blank")},[R,pe]=r.useState(),[xe,ie]=r.useState(!1),ve=W=>{o&&console.log("handleConfigPlugin plugin:",W.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:W.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:W.name}}),pe(W),F()},F=()=>{ie(!0)},U=()=>{ie(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[R&&e.jsx(bn,{open:xe,onClose:U,plugin:R}),e.jsx(Ct,{name:"Plugins",columns:B,rows:E,footerRight:"",footerLeft:""})]}):e.jsx(De,{})}const yn=r.memo(vn),jn=n=>`${n.pluginName}::${n.serial}`;function wn({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:a,removeListener:f,getUniqueId:p}=r.useContext(fe),[y,t]=r.useState(!1),[I,b]=r.useState(!0),[M,O]=r.useState(null),[E,T]=r.useState([]),[B,L]=r.useState([]),[c,h]=r.useState([]),[m,H]=r.useState([]),D=r.useRef(p()),C=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(g,s,u,x)=>u.reachable===!0?"Online":u.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(g,s)=>{const u=g.reachable===!0?1:g.reachable===!1?0:-1,x=s.reachable===!0?1:s.reachable===!1?0:-1;return u-x}},{label:"Power",id:"powerSource",render:(g,s,u,x)=>u.powerSource==="ac"||u.powerSource==="dc"?e.jsx(rr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):u.powerSource==="ok"?e.jsx(jt,{fontSize:"small",sx:{color:"green"}}):u.powerSource==="warning"?e.jsx(jt,{fontSize:"small",sx:{color:"yellow"}}):u.powerSource==="critical"?e.jsx(jt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl"},{label:"Actions",id:"selected",required:!0,render:(g,s,u,x)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[u.matter!==void 0?e.jsx(V,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{onClick:()=>d(n===u.matter?.id?M?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:u.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:ar(u.matter)},children:e.jsx(Xt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),u.configUrl?e.jsx(V,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{onClick:()=>window.open(u.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(or,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),u.selected!==void 0?e.jsx(V,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Ee,{checked:u.selected,onChange:R=>N(R,u),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],q=r.useCallback(g=>{g.selected=void 0;const s=E.find(R=>R.name===g.pluginName);if(!s)return console.error(`HomeDevices isSelected: plugin ${g.pluginName} not found for device ${g.name} `),g.selected;const u=s.schemaJson?.properties?.whiteList?.selectFrom;let x=s.configJson.postfix;return x===""&&(x=void 0),s.hasWhiteList===!0&&s.hasBlackList===!0&&u&&(g.selected=!0,u==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(x?g.serial.replace("-"+x,""):g.serial)&&(g.selected=!0),u==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(x?g.serial.replace("-"+x,""):g.serial)&&(g.selected=!1),u==="serial"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(x?g.serial.replace("-"+x,""):g.serial)&&(g.selected=!1),u==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(g.name)&&(g.selected=!0),u==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(g.name)&&(g.selected=!1),u==="name"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(g.name)&&(g.selected=!1)),g.selected},[E]);r.useEffect(()=>{const g=s=>{if(o&&console.log("HomeDevices received WebSocket Message:",s),s.method==="refresh_required"&&s.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and sending /api/plugins request`),i({id:D.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):s.method==="refresh_required"&&s.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and setting matter id ${s.response.matter?.id}`),H(u=>{const x=u.findIndex(pe=>pe.name.replaceAll(" ","")===s.response.matter?.id);if(x<0)return o&&console.debug(`HomeDevices: matter id ${s.response.matter?.id} not found`),u;const R=[...u];return R[x]={...R[x],matter:s.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and set matter id ${s.response.matter?.id}`),R})):s.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):s.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):s.method==="state_update"&&s.response.plugin&&s.response.serialNumber&&s.response.cluster.includes("BasicInformation")&&s.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${s.response.plugin} serial ${s.response.serialNumber} value ${s.response.value}`),L(u=>{const x=u.findIndex(R=>R.pluginName===s.response.plugin&&R.serial===s.response.serialNumber);return x<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${s.response.plugin} serial ${s.response.serialNumber}`),u):(u[x]={...u[x],reachable:s.response.value},[...u])})),s.id===D.current&&s.method==="/api/settings")o&&console.log(`HomeDevices (id: ${s.id}) received settings:`,s.response),O(s.response),t(s.response.matterbridgeInformation.restartRequired||s.response.matterbridgeInformation.fixedRestartRequired);else if(s.id===D.current&&s.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} plugins:`,s.response),s.response){let u=!0;for(const x of s.response)x.enabled===!0&&(x.loaded!==!0||x.started!==!0||x.error===!0)&&(u=!1);if(!u)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),b(!1),T(s.response),L([]),h([]),i({id:D.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const x of s.response)x.enabled===!0&&x.loaded===!0&&x.started===!0&&x.error!==!0&&(i({id:D.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:x.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${x.name}`))}}else if(s.id===D.current&&s.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} devices:`,s.response),s.response){for(const u of s.response)u.selected=q(u);L(s.response)}}else s.id===D.current&&s.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} selectDevices for plugin ${s.response&&s.response.length>0?s.response[0].pluginName:"without select devices"}:`,s.response),s.response&&s.response.length>0&&h(u=>{const x=u.filter(pe=>pe.pluginName!==s.response[0].pluginName),R=s.response.map(pe=>({...pe,selected:q(pe)}));return[...x,...R]}))};return a(g,D.current),o&&console.log(`HomeDevices added WebSocket listener id ${D.current}`),()=>{f(g),o&&console.log("HomeDevices removed WebSocket listener")}},[E,a,f,i,q]),r.useEffect(()=>{if(B.length===0&&c.length===0){H([]);return}o&&console.log(`HomeDevices mixing devices (${B.length}) and selectDevices (${c.length})`);const g=[];for(const s of B)g.push(s);for(const s of c)B.find(u=>u.pluginName===s.pluginName&&u.serial.includes(s.serial))||g.push(s);g.length>0&&(H(g),o&&console.log(`HomeDevices mixed ${g.length} devices and selectDevices`))},[E,B,c,H]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:D.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:D.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const N=(g,s)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${g.target.checked} for device ${s.name} serial ${s.serial}`),B.findIndex(u=>u.pluginName===s.pluginName&&u.serial===s.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices, trying in mixedDevices`),H(u=>{const x=u.findIndex(R=>R.pluginName===s.pluginName&&R.serial===s.serial);return x<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in mixedDevices`),u):(u[x]={...u[x],selected:g.target.checked},[...u])})):L(u=>{const x=u.findIndex(R=>R.pluginName===s.pluginName&&R.serial===s.serial);return x<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices`),u):(u[x]={...u[x],selected:g.target.checked},[...u])}),g.target.checked?i({id:D.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}}):i({id:D.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}})};return o&&console.log("HomeDevices rendering..."),l?e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Ct,{name:"Devices",getRowKey:jn,rows:m,columns:C,footerLeft:I?"Waiting for the plugins to fully load...":`Registered devices: ${B.length.toString()}/${m.length.toString()}`,footerRight:y?"Restart required":""})}):e.jsx(De,{})}const Cn=r.memo(wn);function kt({children:n,style:d,name:l}){const{setCurrentPage:i}=r.useContext(_e);i(l),o&&console.log(`MbfPage: current page set to ${l}`);const a={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...a,...d},children:n})}const Sn=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(o&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(o&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function kn(){const{messages:n,autoScroll:d}=r.useContext(sr),[l,i]=r.useState(!1),a=r.useRef(null),f=r.useMemo(()=>Sn(),[]),p=b=>i(!0),y=b=>i(!1);r.useEffect(()=>{o&&console.log(`WebSocketLogs autoScroll: ${d} isHovering: ${l}`),d&&!l&&!f&&a.current?.scrollIntoView({behavior:"smooth"})},[n,l,d,f]);const t=b=>{switch(b.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"#5c0e91"}},I=b=>{switch(b.toLowerCase()){case"warn":return"black";default:return"white"}};return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:p,onMouseLeave:y,children:[n.map((b,M)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:t(b.level),color:I(b.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:b.level}),b.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+b.time+"]"}),b.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+b.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:b.message})]},M)),e.jsx("div",{ref:a})]})})}const lr=r.memo(kn);function Mn(){const{logFilterLevel:n,logFilterSearch:d,autoScroll:l,online:i}=r.useContext(fe);return o&&console.log("HomeLogs rendering..."),i?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 "',n,'" and search "',d,'" Scroll: ',l?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(lr,{})})]}):e.jsx(De,{})}const In=r.memo(Mn);function Dn(){const{online:n}=r.useContext(fe);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(Me,{children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(se,{onClick:()=>window.location.reload(),endIcon:e.jsx(Er,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(De,{})}const Pn=r.memo(Dn);function Ln({changelog:n}){const{online:d}=r.useContext(fe);return o&&console.log("HomeShowChangelog rendering..."),d?e.jsxs(Me,{children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(se,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Wt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(se,{onClick:()=>window.location.reload(),endIcon:e.jsx(_r,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(De,{})}const Nn=r.memo(Ln);function $n(){const[n,d]=r.useState(null),[l,i]=r.useState(null),[a,f]=r.useState([]),[p]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[y,t]=r.useState(localStorage.getItem("homePageMode")??"devices"),[I,b]=r.useState(""),[M,O]=r.useState(!1),[E,T]=r.useState(!1),[B,L]=r.useState(null),{addListener:c,removeListener:h,online:m,sendMessage:H,getUniqueId:D}=r.useContext(fe),C=r.useRef(D());return r.useEffect(()=>{const q=N=>{o&&console.log("Home received WebSocket Message:",N),N.method==="refresh_required"&&N.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${N.response.changed} and sending /api/settings request`),L(null),f([]),H({id:C.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),H({id:C.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),N.method==="/api/settings"&&N.id===C.current&&(o&&console.log("Home received settings:",N.response),d(N.response.systemInformation),i(N.response.matterbridgeInformation),N.response.matterbridgeInformation.matterbridgeVersion&&b(`https://github.com/Luligu/matterbridge/blob/${N.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&N.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",N.response.matterbridgeInformation.frontendVersion):N.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&N.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",N.response.matterbridgeInformation.frontendVersion),T(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",N.response.matterbridgeInformation.matterbridgeVersion):N.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",N.response.matterbridgeInformation.matterbridgeVersion),O(!0)),N.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),t("devices")))),N.method==="/api/plugins"&&N.id===C.current&&(o&&console.log("Home received plugins:",N.response),f(N.response))};return c(q,C.current),o&&console.log(`Home added WebSocket listener id ${C.current}`),()=>{h(q),o&&console.log("Home removed WebSocket listener")}},[c,h,H]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${B}`),l?.bridgeMode==="bridge"&&!B&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),L("Matterbridge")),l?.bridgeMode==="childbridge"&&!B&&a){for(const q of a)if(q.matter?.id){o&&console.log(`Home storeId effect set storeId to ${q.matter.id}`),L(q.matter.id);break}}},[l,a,B]),r.useEffect(()=>{m&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),H({id:C.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),H({id:C.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[m,H]),o&&console.log("Home rendering..."),!m||!n||!l?e.jsx(De,{}):e.jsxs(kt,{name:"Home",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(dn,{id:B}),e.jsx(sn,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[E&&e.jsx(Pn,{}),M&&e.jsx(Nn,{changelog:I}),p&&!l.readOnly&&e.jsx(pn,{}),p&&e.jsx(yn,{storeId:B,setStoreId:L}),y==="devices"&&e.jsx(Cn,{storeId:B,setStoreId:L}),y==="logs"&&e.jsx(In,{})]})]})}const Wn=r.memo($n),bt=!1,Zt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},Tn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},Fn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Yt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Rn={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)"},On={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Vn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},En={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)"},_n=[256,257,268,269],An=[266,267],zn=[259,260,261,271,272],Un=[256,257,268,269,266,267,259,260,261,272];function Z({icon:n,iconColor:d,cluster:l,value:i,unit:a,prefix:f}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${a}"`),f=f??!1,e.jsxs(te,{sx:Zt,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...Tn,color:d??"var(--primary-color)"}}),e.jsxs(te,{sx:{...Zt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[a&&f===!0&&e.jsx(ae,{sx:Yt,children:a},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(ae,{sx:Fn,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${l.clusterId}-${l.attributeId}-value`),a&&f===!1&&e.jsx(ae,{sx:Yt,children:a},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function qn({device:n,endpoint:d,id:l,deviceType:i,clusters:a}){const f=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let p="";o&&console.log(`Device "${n.name}" endpoint "${d}" id "${l}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${a?.length})`);const y=a.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(y){let t="";y.map(I=>{I.label&&(t+=I.label+" ")}),p=t.trim()}if(i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>p=`${t.attributeLocalValue} mV`),Un.includes(i)&&a.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>p=`Level ${t.attributeValue}`),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>p=`Position ${t.attributeLocalValue/100}%`),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>p=`Heat ${t.attributeLocalValue/100}°C `),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>p=p+`Cool ${t.attributeLocalValue/100}°C`),i===118&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>p=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>p=`${t.attributeLocalValue/1e3} V, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>p=p+`${t.attributeLocalValue/1e3} A, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>p=p+`${t.attributeLocalValue/1e3} W`),i===39){const t=a.find(b=>b.clusterName==="ModeSelect"&&b.attributeName==="currentMode")?.attributeLocalValue;p=a.find(b=>b.clusterName==="ModeSelect"&&b.attributeName==="supportedModes")?.attributeLocalValue?.find(b=>b.mode===t)?.label||"Unknown"}if(i===116){const t=a.find(b=>b.clusterName==="RvcRunMode"&&b.attributeName==="currentMode")?.attributeLocalValue;p=a.find(b=>b.clusterName==="RvcRunMode"&&b.attributeName==="supportedModes")?.attributeLocalValue?.find(b=>b.mode===t)?.label||"Unknown"}return e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:t.attributeLocalValue===!0?e.jsx(ot,{}):e.jsx(Ar,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(Z,{icon:e.jsx(jt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(Z,{icon:e.jsx(rr,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&a.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),_n.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(zr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),An.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),zn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:e.jsx(At,{}),cluster:t,value:"Oven"})),i===112&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:e.jsx(Ur,{}),cluster:t,value:"Fridge"})),i===113&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(Z,{icon:e.jsx(At,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:$o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(Z,{icon:e.jsx(qr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&a.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(Z,{icon:t.attributeValue==="1"?e.jsx(Br,{}):e.jsx(Qr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(Z,{icon:e.jsx(Gr,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&a.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&a.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(Z,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(Z,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(Z,{icon:e.jsx(zt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(Z,{icon:e.jsx(zt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&a.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&a.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Ro,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&a.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Oo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Eo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Gt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Gt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&a.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(Z,{icon:e.jsx(eo,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&a.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:_o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:f[t.attributeLocalValue??0]})),i===770&&a.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(to,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&a.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(ne,{path:Ao,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&a.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(ro,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&a.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(oo,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(Z,{icon:t.attributeValue==="true"?e.jsx(no,{}):e.jsx(io,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&a.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(Z,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(so,{}):e.jsx(ao,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&a.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(Z,{icon:e.jsx(lo,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&a.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(Z,{icon:e.jsx(co,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(te,{sx:Rn,children:e.jsx(ae,{sx:Hn,children:p})}),e.jsx(te,{sx:On,children:e.jsx(ae,{sx:Vn,children:n.name})}),e.jsxs(te,{sx:En,children:[o&&e.jsx(ae,{sx:Pt,children:d}),e.jsx(ae,{sx:Pt,children:l}),o&&e.jsxs(ae,{sx:Pt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Bn({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:f}=r.useContext(fe),[p,y]=r.useState([]),[t,I]=r.useState({}),[b,M]=r.useState({}),[O,E]=r.useState({}),T=r.useRef(f()),B=r.useCallback(h=>{(o||bt)&&console.log(`DevicesIcons received state_update "${h.response.cluster}.${h.response.attribute}" for "${h.response.id}:${h.response.number}": "${h.response.value}"`,h.response);const m=p.find(D=>D.pluginName===h.response.plugin&&D.serial===h.response.serialNumber);if(!m){(o||bt)&&console.warn(`DevicesIcons updater device of plugin "${h.response.plugin}" serial "${h.response.serialNumber}" number "${h.response.number}" id "${h.response.id}" not found in devices(${p.length})`);return}const H=O[m.serial]?.find(D=>D.endpoint===h.response.number.toString()&&D.clusterName===h.response.cluster&&D.attributeName===h.response.attribute);if(!H){(o||bt)&&console.warn(`DevicesIcons updater device "${m.name}" serial "${m.serial}" cluster "${h.response.cluster}" attribute "${h.response.attribute}" not found in clusters(${O[m.serial]?.length})`);return}H.attributeValue=String(h.response.value),H.attributeLocalValue=h.response.value,E({...O}),(o||bt)&&console.log(`DevicesIcons updated "${H.clusterName}.${H.attributeName}" for device "${m.name}" serial "${m.serial}" to "${H.attributeValue}"`)},[O,p]),L=r.useCallback(h=>{if(o&&console.log(`DevicesIcons received for device "${h.response.deviceName}" serial "${h.response.serialNumber}" deviceTypes (${h.response.deviceTypes.length}) "${h.response.deviceTypes.join(",")}" clusters (${h.response.clusters.length}):`,h.response),h.response.clusters.length===0)return;const m=h.response.serialNumber;t[m]=[],b[m]=h.response.deviceTypes,O[m]=[];for(const H of h.response.clusters)t[m].find(D=>D.endpoint===H.endpoint)||t[m].push({endpoint:H.endpoint,id:H.id,deviceTypes:H.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(H.clusterName)&&O[m].push(H);I({...t}),M({...b}),E({...O}),o&&console.log(`DevicesIcons endpoints for "${m}":`,t[m]),o&&console.log(`DevicesIcons deviceTypes for "${m}":`,b[m]),o&&console.log(`DevicesIcons clusters for "${m}":`,O[m])},[O,b,t]);r.useEffect(()=>{const h=m=>{if(o&&console.log("DevicesIcons received WebSocket Message:",m),m.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${m.response.changed} and sending api requests`),l({id:T.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(m.method==="state_update"&&m.response)B(m);else if(m.method==="/api/devices"&&m.response){o&&console.log(`DevicesIcons received ${m.response.length} devices:`,m.response),y(m.response),I({}),M({}),E({});for(const H of m.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:T.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:H.pluginName,endpoint:H.endpoint||0}})}else m.method==="/api/clusters"&&m.response&&L(m)};return i(h,T.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{a(h),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[p]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),d&&(o&&console.log("DevicesIcons useEffect online sending api requests"),l({id:T.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),o&&console.log("DevicesIcons useEffect online mounted"),()=>{o&&console.log("DevicesIcons useEffect online unmounted")}),[d,l]);const c=r.memo(qn);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:p.filter(h=>h.name.toLowerCase().includes(n)||h.serial.toLowerCase().includes(n)).map(h=>t[h.serial]&&t[h.serial].map(m=>m.deviceTypes.map(H=>e.jsx(c,{device:h,endpoint:m.endpoint,id:m.id,deviceType:H,clusters:O[h.serial].filter(D=>D.endpoint===m.endpoint)},`${h.pluginName}-${h.uniqueId}-${m.endpoint}-${m.id}-${H.toString()}`))))})}const Qn=r.memo(Bn),Gn=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(n,d,l,i)=>l.configUrl?e.jsx(G,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(or,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Kn=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,d,l,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(a=>`0x${a.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,render:(n,d,l,i)=>e.jsx(V,{title:String(n),componentsProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("div",{style:{maxWidth:"500px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(n)})})}],Jn=n=>`${n.pluginName}::${n.uniqueId}`,Zn=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function Yn({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:f}=r.useContext(fe),[p,y]=r.useState([]),[t,I]=r.useState(p),[b,M]=r.useState([]),[O,E]=r.useState(0),[T,B]=r.useState(null),[L,c]=r.useState(null),[h,m]=r.useState(null),[H,D]=r.useState(null),C=r.useRef(f()),q=r.useRef(t),N=r.useCallback(s=>{o&&console.log(`DevicesTable received state_update "${s.response.cluster}.${s.response.attribute}" for "${s.response.id}:${s.response.number}": "${s.response.value}"`,s.response);const u=q.current.find(x=>x.pluginName===s.response.plugin&&x.uniqueId===s.response.uniqueId);if(!u){o&&console.warn(`DevicesTable updater device of plugin "${s.response.plugin}" serial "${s.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(T&&L&&u.pluginName===T&&u.uniqueId===H&&s.response.number.toString()===L){const x=b.find(R=>R.endpoint===s.response.number.toString()&&R.clusterName===s.response.cluster&&R.attributeName===s.response.attribute);if(!x){o&&console.warn(`DevicesTable updater cluster ${s.response.cluster}.${s.response.attribute} for device "${u.name}" serial "${u.serial}" not found in clusters`);return}x.attributeValue=typeof s.response.value=="object"?JSON.stringify(s.response.value,void 0,1).replaceAll('"',""):String(s.response.value),x.attributeLocalValue=s.response.value,M([...b]),o&&console.log(`DevicesTable updated attribute ${x.clusterName}.${x.attributeName} for device "${u.name}" serial "${u.serial}" to "${x.attributeValue}"`)}},[b,L,T,H]);r.useEffect(()=>{const s=u=>{if(o&&console.log("DevicesTable received WebSocket Message:",u),u.method==="refresh_required"&&u.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${u.response.changed} and sending /api/devices request`),l({id:C.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(u.method==="state_update"&&u.response)N(u);else if(u.method==="/api/devices")o&&console.log(`DevicesTable received ${u.response.length} devices:`,u.response),y(u.response);else if(u.method==="/api/clusters"){o&&console.log(`DevicesTable received ${u.response.clusters.length} clusters for plugin ${u.response.plugin}:`,u.response),M(u.response.clusters);const x={};for(const R of u.response.clusters)o&&console.log("Cluster:",R.endpoint),x[R.endpoint]?x[R.endpoint]++:x[R.endpoint]=1;E(Object.keys(x).length)}};return i(s,C.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{a(s),o&&console.log("DevicesTable removed WebSocket listener")}},[l,i,a,N]),r.useEffect(()=>{d&&(o&&console.log("DevicesTable sending api requests with id ",C.current),l({id:C.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:C.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:C.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[d,l]),r.useEffect(()=>{T&&L&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:C.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:T,endpoint:Number(L)}}))},[T,L,l]),r.useEffect(()=>{if(n===""){I(p),q.current=p;return}const s=p.filter(u=>u.name.toLowerCase().includes(n)||u.serial.toLowerCase().includes(n));I(s),q.current=s},[p,n]);const g=s=>{if(s.uniqueId===H){D(null),B(null),c(null),m(null);return}D(s.uniqueId),B(s.pluginName),c(s.endpoint?s.endpoint.toString():null),m(s.name)};return o&&console.log("DevicesTable rendering..."),d?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${T&&L?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Ct,{name:"Registered devices",getRowKey:Jn,onRowClick:g,rows:t,columns:Gn,footerLeft:`Total devices: ${t.length.toString()}`})}),T&&L&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Ct,{name:"Clusters",title:h||"",getRowKey:Zn,rows:b,columns:Kn,footerLeft:`Total child endpoints: ${O-1}`})})]}):e.jsx(De,{})}const Xn=r.memo(Yn);function ei(){const{online:n}=r.useContext(fe),[d,l]=r.useState(""),[i,a]=r.useState("icon");r.useEffect(()=>{const y=localStorage.getItem("devicesFilter");y&&l(y)},[]),r.useEffect(()=>{const y=localStorage.getItem("devicesViewMode");y&&a(y)},[]);const f=y=>{l(y.target.value.toLowerCase()),localStorage.setItem("devicesFilter",y.target.value.toLowerCase())},p=y=>{a(y),localStorage.setItem("devicesViewMode",y)};return o&&console.log("Devices rendering..."),n?e.jsxs(kt,{name:"Devices",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(te,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ae,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(he,{variant:"outlined",value:d,onChange:f,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(te,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ae,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(G,{onClick:()=>p("table"),"aria-label":"Table View",disabled:i==="table",children:e.jsx(V,{title:"Table View",children:e.jsx(po,{style:{color:i==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(G,{onClick:()=>p("icon"),"aria-label":"Icon View",disabled:i==="icon",children:e.jsx(V,{title:"Icon View (beta)",children:e.jsx(uo,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(Xn,{filter:d}),i==="icon"&&e.jsx(Qn,{filter:d})]}):e.jsx(De,{})}const ti=r.memo(ei);function ri(){const[n,d]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,f]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:p,setLogFilters:y,online:t,setAutoScroll:I}=r.useContext(fe),b=T=>{d(T.target.value),y(T.target.value,l),localStorage.setItem("logFilterLevel",T.target.value),o&&console.log("handleChangeLevel called with value:",T.target.value)},M=T=>{i(T.target.value),y(n,T.target.value),localStorage.setItem("logFilterSearch",T.target.value),o&&console.log("handleChangeSearch called with value:",T.target.value)},O=T=>{f(T.target.checked),I(T.target.checked),localStorage.setItem("logAutoScroll",T.target.value?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",T.target.checked)},E=()=>{o&&console.log("handleClearLogsClick called"),p([])};return o&&console.log("Logs rendering..."),t?e.jsxs(kt,{name:"Logs",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(Ut,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Ze,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:n,onChange:b,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(Ut,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(he,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:l,onChange:M,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Ve,{control:e.jsx(Ee,{checked:a,onChange:O}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(V,{title:"Clear the logs",children:e.jsx(se,{onClick:E,endIcon:e.jsx($t,{}),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(lr,{})})]}):e.jsx(De,{})}const oi=r.memo(ri),ni=({open:n,ip:d,onClose:l,onSave:i})=>{const a=d?d.split(".").slice(0,3).join(".")+".1":"",[f,p]=r.useState("dhcp"),[y,t]=r.useState({ip:d??"",subnet:"255.255.255.0",gateway:a,dns:a}),I=O=>E=>{t({...y,[O]:E.target.value})},b=()=>{l()},M=()=>{i({type:f,...y}),l()};return e.jsxs(Ne,{open:n,onClose:(O,E)=>{E==="backdropClick"||E==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx($e,{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(We,{dividers:!0,children:[e.jsxs(nr,{component:"fieldset",fullWidth:!0,children:[e.jsx(je,{component:"legend",children:"Select IP Configuration"}),e.jsxs(ir,{row:!0,value:f,onChange:O=>p(O.target.value),children:[e.jsx(Ve,{value:"dhcp",control:e.jsx(wt,{}),label:"DHCP"}),e.jsx(Ve,{value:"static",control:e.jsx(wt,{}),label:"Static"})]})]}),f==="static"&&e.jsxs(He,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(He,{size:6,children:e.jsx(he,{label:"IP Address",fullWidth:!0,value:y.ip,onChange:I("ip")})}),e.jsx(He,{size:6,children:e.jsx(he,{label:"Subnet Mask",fullWidth:!0,value:y.subnet,onChange:I("subnet")})}),e.jsx(He,{size:6,children:e.jsx(he,{label:"Gateway",fullWidth:!0,value:y.gateway,onChange:I("gateway")})}),e.jsx(He,{size:6,children:e.jsx(he,{label:"DNS Server",fullWidth:!0,value:y.dns,onChange:I("dns")})})]})]}),e.jsxs(Oe,{children:[e.jsx(se,{onClick:b,children:"Cancel"}),e.jsx(se,{variant:"contained",onClick:M,children:"Save"})]})]})},ii=({open:n,onClose:d,onSave:l})=>{const[i,a]=r.useState(""),[f,p]=r.useState(""),y=E=>{a(E.target.value)},t=E=>{p(E.target.value)},I=i.length>0&&i===f,b=()=>{d()},M=()=>{I&&(l(i),d())},O=()=>{l(""),d()};return e.jsxs(Ne,{open:n,onClose:(E,T)=>{T==="backdropClick"||T==="escapeKeyDown"||d()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx($e,{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(We,{dividers:!0,children:e.jsx(nr,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(He,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(He,{size:12,children:e.jsx(he,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:y})}),e.jsx(He,{size:12,children:e.jsx(he,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:f,onChange:t,error:f!==""&&i!==f,helperText:f!==""&&i!==f?"Passwords do not match":""})})]})})}),e.jsxs(Oe,{children:[e.jsx(se,{onClick:b,children:"Cancel"}),e.jsx(se,{variant:"contained",onClick:M,disabled:!I,children:"Change"}),e.jsx(se,{variant:"contained",onClick:O,children:"Reset"})]})]})};function Ke(n=1e3){let d=null;const l=(i=>{d!==null&&window.clearTimeout(d),d=window.setTimeout(()=>{i(),d=null},n)});return l.cancel=()=>{d!==null&&(window.clearTimeout(d),d=null)},l}const ge=500;function si(){const{online:n,addListener:d,removeListener:l,sendMessage:i,getUniqueId:a}=r.useContext(fe),[f,p]=r.useState(null),[y,t]=r.useState(null),I=r.useRef(a());return r.useEffect(()=>{const b=M=>{o&&console.log("Settings received WebSocket Message:",M),M.method==="refresh_required"&&M.response.changed==="settings"?(o&&console.log(`Settings received refresh_required: changed=${M.response.changed} and sending /api/settings request`),i({id:I.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):M.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",M.response),p(M.response.matterbridgeInformation),t(M.response.systemInformation))};return d(b,I.current),o&&console.log("Settings added WebSocket listener"),()=>{l(b),o&&console.log("Settings removed WebSocket listener")}},[d,l,i]),r.useEffect(()=>{n&&(o&&console.log("Settings received online"),i({id:I.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[n,i]),o&&console.log("Settings rendering..."),!n||!f||!y?e.jsx(De,{}):e.jsx(kt,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(ai,{matterbridgeInfo:f,systemInfo:y}),e.jsx(li,{matterbridgeInfo:f}),e.jsx(di,{matterbridgeInfo:f}),e.jsx(ci,{systemInfo:y})]})})}function ai({matterbridgeInfo:n,systemInfo:d}){const{sendMessage:l,getUniqueId:i}=r.useContext(fe),[a,f]=r.useState("bridge"),[p,y]=r.useState("Info"),[t,I]=r.useState(!1),[b,M]=r.useState("dark"),[O,E]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[T,B]=r.useState(localStorage.getItem("homePageMode")??"devices"),[L,c]=r.useState(localStorage.getItem("virtualMode")??"outlet"),h=r.useRef(i()),[m,H]=r.useState(!1),D=()=>H(!1),C=F=>{o&&console.log("handleSaveNetConfig called with config:",F),l({id:h.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:F})},[q,N]=r.useState(!1),g=()=>N(!1),s=F=>{o&&console.log("handleSaveChangePassword called with password:",F),l({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:F}}),wi(F)};r.useEffect(()=>{n&&(f(n.bridgeMode==="bridge"?"bridge":"childbridge"),y(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),I(n.fileLogger),c(n.virtualMode))},[n]),r.useEffect(()=>{const F=localStorage.getItem("frontendTheme");F&&M(F)},[]);const u=F=>{o&&console.log("handleChangeBridgeMode called with value:",F.target.value),f(F.target.value),l({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:F.target.value}})},x=F=>{o&&console.log("handleChangeMbLoggerLevel called with value:",F.target.value),y(F.target.value),l({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:F.target.value}})},R=F=>{o&&console.log("handleLogOnFileMbChange called with value:",F.target.checked),I(F.target.checked),l({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:F.target.checked}})},pe=F=>{const U=F.target.value;o&&console.log("handleChangeTheme called with value:",U),M(U),localStorage.setItem("frontendTheme",U),document.body.setAttribute("frontend-theme",U)},xe=F=>{const U=F.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",U),E(U),localStorage.setItem("homePagePlugins",U?"true":"false")},ie=F=>{const U=F.target.value;o&&console.log("handleChangeHomePageMode called with value:",U),B(U),localStorage.setItem("homePageMode",U)},ve=F=>{const U=F.target.value;o&&console.log("handleChangeVirtualMode called with value:",U),c(U),localStorage.setItem("virtualMode",U),l({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:U}})};return!n||!d?null:e.jsxs(Me,{style:{width:`${ge}px`,maxWidth:`${ge}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(ni,{open:m,ip:d.ipv4Address,onClose:D,onSave:C}),e.jsx(ii,{open:q,onClose:g,onSave:s}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(te,{sx:{gap:"10px",margin:"0px",padding:"10px",width:`${ge-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(ir,{row:!0,name:"mode-buttons-group",value:a,onChange:u,children:[e.jsx(Ve,{value:"bridge",control:e.jsx(wt,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(Ve,{value:"childbridge",control:e.jsx(wt,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Ze,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:p,onChange:x,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(Ve,{style:{padding:"0px",margin:"0px"},control:e.jsx(Ee,{checked:t,onChange:R,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Ze,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:b,onChange:pe,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(je,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Ee,{checked:O,onChange:xe,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Ze,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:T,onChange:ie,children:[e.jsx(P,{value:"logs",children:"Logs"}),e.jsx(P,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Ze,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:L,onChange:ve,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(se,{variant:"contained",color:"primary",onClick:()=>N(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(se,{variant:"contained",color:"primary",onClick:()=>H(!0),children:"Configure IP"})})]})})]})}function li({matterbridgeInfo:n}){const{sendMessage:d,getUniqueId:l}=r.useContext(fe),[i,a]=r.useState("Info"),[f,p]=r.useState(!1),[y,t]=r.useState(""),[I,b]=r.useState(""),[M,O]=r.useState(""),[E,T]=r.useState(""),[B,L]=r.useState(""),[c,h]=r.useState(""),m=r.useRef(l()),H=r.useMemo(()=>Ke(1e3),[]),D=r.useMemo(()=>Ke(1e3),[]),C=r.useMemo(()=>Ke(1e3),[]),q=r.useMemo(()=>Ke(1e3),[]),N=r.useMemo(()=>Ke(1e3),[]),g=r.useMemo(()=>Ke(1e3),[]);r.useEffect(()=>{n&&(a(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),p(n.matterFileLogger),t(n.matterMdnsInterface||""),b(n.matterIpv4Address||""),O(n.matterIpv6Address||""),T(n.matterPort?n.matterPort.toString():""),L(n.matterDiscriminator?n.matterDiscriminator.toString():""),h(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>H.cancel(),[H]),r.useEffect(()=>()=>D.cancel(),[D]),r.useEffect(()=>()=>C.cancel(),[C]),r.useEffect(()=>()=>q.cancel(),[q]),r.useEffect(()=>()=>N.cancel(),[N]),r.useEffect(()=>()=>g.cancel(),[g]);const s=F=>{o&&console.log("handleChangeMjLoggerLevel called with value:",F.target.value),a(F.target.value),d({id:m.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:F.target.value}})},u=F=>{o&&console.log("handleLogOnFileMjChange called with value:",F.target.checked),p(F.target.checked),d({id:m.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:F.target.checked}})},x=F=>{o&&console.log("handleChangeMdnsInterface called with value:",F.target.value);const U=F.target.value;t(U),H(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",U),d({id:m.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:U}})})},R=F=>{o&&console.log("handleChangeIpv4Address called with value:",F.target.value);const U=F.target.value;b(U),D(()=>{o&&console.log("debounced sendMessage setipv4address with value:",U),d({id:m.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:U}})})},pe=F=>{o&&console.log("handleChangeIpv6Address called with value:",F.target.value);const U=F.target.value;O(U),C(()=>{o&&console.log("debounced sendMessage setipv6address with value:",U),d({id:m.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:U}})})},xe=F=>{o&&console.log("handleChangeMatterPort called with value:",F.target.value);const U=F.target.value;T(U),q(()=>{o&&console.log("debounced sendMessage setmatterport with value:",U),d({id:m.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:U}})})},ie=F=>{o&&console.log("handleChangeMatterDiscriminator called with value:",F.target.value);const U=F.target.value;L(U),N(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",U),d({id:m.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:U}})})},ve=F=>{o&&console.log("handleChangemMatterPasscode called with value:",F.target.value);const U=F.target.value;h(U),g(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",U),d({id:m.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:U}})})};return n?e.jsxs(Me,{style:{width:`${ge}px`,maxWidth:`${ge}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(te,{sx:{gap:"20px",margin:"0px",padding:"10px",width:`${ge-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(Ze,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:i,onChange:s,children:[e.jsx(P,{value:"Debug",children:"Debug"}),e.jsx(P,{value:"Info",children:"Info"}),e.jsx(P,{value:"Notice",children:"Notice"}),e.jsx(P,{value:"Warn",children:"Warn"}),e.jsx(P,{value:"Error",children:"Error"}),e.jsx(P,{value:"Fatal",children:"Fatal"})]}),e.jsx(Ve,{style:{padding:"0px",margin:"0px"},control:e.jsx(Ee,{checked:f,onChange:u,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(he,{value:y,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(he,{value:I,onChange:R,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(he,{value:M,onChange:pe,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(he,{value:E,onChange:xe,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(he,{value:B,onChange:ie,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(he,{value:c,onChange:ve,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function di({matterbridgeInfo:n}){return n?e.jsxs(Me,{style:{width:`${ge}px`,maxWidth:`${ge}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(te,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(we,{value:n.matterbridgeVersion,label:"Current Version",width:ge}),e.jsx(we,{value:n.matterbridgeLatestVersion,label:"Latest Version",width:ge}),e.jsx(we,{value:n.homeDirectory,label:"Home Directory",width:ge}),e.jsx(we,{value:n.rootDirectory,label:"Root Directory",width:ge}),e.jsx(we,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory",width:ge}),e.jsx(we,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory",width:ge}),e.jsx(we,{value:n.globalModulesDirectory,label:"Global Module Directory",width:ge})]})})]}):null}function ci({systemInfo:n}){return n?e.jsxs(Me,{style:{width:`${ge}px`,maxWidth:`${ge}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"System info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(te,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(we,{value:n.interfaceName,label:"Interface name",width:ge}),e.jsx(we,{value:n.macAddress,label:"MAC Address",width:ge}),e.jsx(we,{value:n.ipv4Address,label:"IPv4 Address",width:ge}),e.jsx(we,{value:n.ipv6Address,label:"IPv6 Address",width:ge}),e.jsx(we,{value:n.nodeVersion,label:"Node Version",width:ge}),e.jsx(we,{value:n.hostname,label:"Hostname",width:ge}),e.jsx(we,{value:n.user,label:"User",width:ge})]})})]}):null}function we({value:n,label:d,width:l}){return e.jsx(he,{focused:!0,value:n,size:"small",label:d,variant:"standard",sx:{width:l?`${l-20}px`:"400px"},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)"}}}})}const pi=r.memo(si);function ui(){const{online:n,sendMessage:d,addListener:l,removeListener:i,getUniqueId:a}=r.useContext(fe),{showSnackbarMessage:f}=r.useContext(_e),[p,y]=r.useState(null),[t,I]=r.useState([]),[b,M]=r.useState([]),[O,E]=r.useState(null),[T,B]=r.useState({cpuUsage:0}),[L,c]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[h,m]=r.useState({systemUptime:"",processUptime:""}),H=r.useRef(a());return o&&console.log("Test uniqueId:",H),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const D=C=>{if(C.method==="restart_required")o&&console.log("Test received restart_required"),f("Restart required",0);else if(C.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${C.response.changed} and sending api requests`),f("Refresh required",0),d({id:H.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:H.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:H.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(C.method==="memory_update")o&&console.log("Test received memory_update",C),c(C.response);else if(C.method==="cpu_update")o&&console.log("Test received cpu_update",C),B(C.response);else if(C.method==="uptime_update")o&&console.log("Test received uptime_update",C),m(C.response);else if(C.method==="/api/settings"&&C.response)o&&console.log("Test received /api/settings:",C.response),f("Test received /api/settings",0),y(C.response);else if(C.method==="/api/plugins"&&C.response)o&&console.log(`Test received ${C.response.length} plugins:`,C.response),f("Test received /api/plugins",0),I(C.response);else if(C.method==="/api/devices"&&C.response){o&&console.log(`Test received ${C.response.length} devices:`,C.response),f("Test received /api/devices",0),M(C.response);for(const q of C.response)o&&console.log("Test sending /api/clusters for device:",q.pluginName,q.name,q.endpoint),d({id:H.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:q.pluginName,endpoint:q.endpoint||0}})}else C.method==="/api/clusters"&&C.response&&(o&&console.log(`Test received ${C.response.clusters.length} clusters for device ${C.response.deviceName} endpoint ${C.response.id}:${C.response.number}:`,C),f(`Test received /api/clusters for ${C.response.plugin}::${C.response.deviceName}`,0),E(C.response))};return l(D,H.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(D),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,i,d,f]),r.useEffect(()=>(o&&console.log("Test useEffect online mounting"),n&&o&&console.log("Test useEffect online received online"),o&&console.log("Test useEffect online mounted"),()=>{o&&console.log("Test useEffect online unmounted")}),[n,d,f]),o&&console.log("Test rendering..."),n?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(De,{})}const gi=r.memo(ui);function mi(n,d){o&&console.log("getCssVariable:",n,"defaultValue",d);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||d}function hi(n){return go({palette:{primary:{main:n},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}function fi(){const{mobile:n,showSnackbarMessage:d,showConfirmCancelDialog:l}=r.useContext(_e),{online:i,sendMessage:a,logMessage:f,addListener:p,removeListener:y,getUniqueId:t}=r.useContext(fe),[I,b]=r.useState(!1),[M,O]=r.useState(!1),[E,T]=r.useState(!1),[B,L]=r.useState(!1),[c,h]=r.useState(null),m=r.useRef(t()),[H,D]=r.useState(null),[C,q]=r.useState(null),[N,g]=r.useState(null),[s,u]=r.useState(null),[x,R]=r.useState(null),pe=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},xe=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},ie=()=>{c?.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")},ve=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},F=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},U=()=>{a({id:m.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},W=()=>{a({id:m.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},Y=()=>{a({id:m.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},$=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),f("Matterbridge","Installing system updates..."),a({id:m.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},S=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),f("Matterbridge","Installing software updates..."),a({id:m.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},j=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),a({id:m.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},k=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),f("Matterbridge","Downloading Shelly system log..."),d("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},A=()=>{c?.matterbridgeInformation.restartMode===""?a({id:m.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):a({id:m.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},J=()=>{a({id:m.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},ue=()=>{a({id:m.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},de=()=>{a({id:m.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ce=()=>{a({id:m.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},me=v=>{D(v.currentTarget)},z=v=>{o&&console.log("Header: handleMenuClose",v),D(null),v==="download-mblog"?(f("Matterbridge","Downloading matterbridge log..."),d("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):v==="download-mjlog"?(f("Matterbridge","Downloading matter log..."),d("Downloading matter log...",5),window.location.href="./api/download-mjlog"):v==="view-mblog"?(f("Matterbridge","Loading matterbridge log..."),d("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):v==="view-mjlog"?(f("Matterbridge","Loading matter log..."),d("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):v==="view-diagnostic"?(f("Matterbridge","Loading diagnostic log..."),d("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):v==="download-diagnostic"?(f("Matterbridge","Downloading diagnostic log..."),d("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):v==="view-history"?a({id:m.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):v==="download-history"?a({id:m.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):v==="view-shellylog"?(f("Matterbridge","Loading shelly system log..."),d("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):v==="download-mbstorage"?(f("Matterbridge","Downloading matterbridge storage..."),d("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):v==="download-pluginstorage"?(f("Matterbridge","Downloading matterbridge plugins storage..."),d("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):v==="download-pluginconfig"?(f("Matterbridge","Downloading matterbridge plugins config..."),d("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):v==="download-mjstorage"?(f("Matterbridge","Downloading matter storage..."),d("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):v==="download-backup"?(f("Matterbridge","Downloading backup..."),d("Downloading backup...",10),window.location.href="./api/download-backup"):v==="update"?U():v==="updatedev"?W():v==="updatecheck"?Y():v==="shelly-sys-update"?$():v==="shelly-main-update"?S():v==="shelly-create-system-log"?j():v==="shelly-download-system-log"?k():v==="softreset"?de():v==="hardreset"?ce():v==="restart"?A():v==="shutdown"?J():v==="reboot"?ue():v==="create-backup"?a({id:m.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):v==="unregister"?a({id:m.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):v==="reset"?a({id:m.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):v==="factoryreset"&&a({id:m.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},K=v=>{o&&console.log("Header: handleMenuCloseCancel:",v),D(null)},_=v=>{q(v.currentTarget)},w=()=>{q(null)},be=v=>{g(v.currentTarget)},le=()=>{g(null)},ee=v=>{u(v.currentTarget)},oe=()=>{u(null)},Pe=v=>{R(v.currentTarget)},Le=()=>{R(null)},et=()=>{yi(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const v=X=>{o&&console.log("Header received WebSocket Message:",X),X.method==="/api/settings"&&X.id===m.current?(o&&console.log("Header received settings:",X.response),h(X.response),b(X.response.matterbridgeInformation.restartRequired||X.response.matterbridgeInformation.fixedRestartRequired),O(X.response.matterbridgeInformation.fixedRestartRequired),T(X.response.matterbridgeInformation.updateRequired)):X.method==="refresh_required"&&X.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${X.response.changed} and sending /api/settings request`),a({id:m.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):X.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${X.response.fixed}`),b(!0),X.response.fixed===!0&&O(!0)):X.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),b(!1)):X.method==="update_required"?(o&&console.log("Header received update_required"),X.response.devVersion===!0?L(!0):T(!0),a({id:m.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):X.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),h(Ce=>Ce?{matterbridgeInformation:{...Ce.matterbridgeInformation,shellySysUpdate:X.response.available},systemInformation:Ce.systemInformation}:null)):X.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),h(Ce=>Ce?{matterbridgeInformation:{...Ce.matterbridgeInformation,shellyMainUpdate:X.response.available},systemInformation:Ce.systemInformation}:null)):X.method==="/api/viewhistorypage"&&X.id===m.current&&X.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):X.method==="/api/downloadhistorypage"&&X.id===m.current&&X.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return p(v,m.current),o&&console.log(`Header added WebSocket listener id ${m.current}`),()=>{y(v),o&&console.log("Header removed WebSocket listener")}},[p,y,a,d]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),a({id:m.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:m.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,a]),o&&console.log("Header rendering... mobile %s",n),!i||!c?null:e.jsxs("div",{className:"header",style:{},children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:et}),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:[!c.matterbridgeInformation.readOnly&&e.jsx(V,{title:`Matterbridge v.${c.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",c.matterbridgeInformation.matterbridgeVersion.split("-dev-")[0]+(c.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")]})}),c.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),c.matterbridgeInformation.bridgeMode!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.bridgeMode})}):null,c.matterbridgeInformation.restartMode!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.restartMode})}):null,c.matterbridgeInformation.profile&&c.matterbridgeInformation.profile!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:ve})}):null,c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Give a star to Matterbridge",children:e.jsx(G,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:F,children:e.jsx(mo,{})})}):null,c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Sponsor Matterbridge",children:e.jsx(G,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:pe,children:e.jsx(tr,{})})}):null,e.jsx(V,{title:"Matterbridge help",children:e.jsx(G,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:xe,children:e.jsx(er,{})})}),e.jsx(V,{title:"Matterbridge changelog",children:e.jsx(G,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ie,children:e.jsx(Wt,{})})}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&E&&e.jsx(V,{title:`Update matterbridge to latest version v.${c.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(G,{style:{color:E?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:U,children:e.jsx(Ie,{})})}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&B&&e.jsx(V,{title:`Update matterbridge to latest dev version v.${c.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(G,{style:{color:B?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:W,children:e.jsx(Ie,{})})}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellySysUpdate&&e.jsx(V,{title:"Shelly system update",children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:$,children:e.jsx(Ie,{})})}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellyMainUpdate&&e.jsx(V,{title:"Shelly software update",children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:S,children:e.jsx(Ie,{})})}),e.jsx(V,{title:"Restart matterbridge",children:e.jsx(G,{style:{color:I||M?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:A,children:e.jsx(yt,{})})}),c.matterbridgeInformation.restartMode===""?e.jsx(V,{title:"Shut down matterbridge",children:e.jsx(G,{style:{color:I||M?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:J,children:e.jsx(Ae,{})})}):null,e.jsx(V,{title:"Download, backup and more",children:e.jsx(G,{onClick:me,children:e.jsx(ho,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Je,{id:"command-menu",anchorEl:H,keepMounted:!0,open:!!H,onClose:()=>z(""),children:[c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>z("update"),children:[e.jsx(Q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>z("updatedev"),children:[e.jsx(Q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>z("updatecheck"),children:[e.jsx(Q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellySysUpdate&&e.jsxs(P,{onClick:()=>z("shelly-sys-update"),children:[e.jsx(Q,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellyMainUpdate&&e.jsxs(P,{onClick:()=>z("shelly-main-update"),children:[e.jsx(Q,{children:e.jsx(Ie,{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:()=>z("restart"),children:[e.jsx(Q,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation.restartMode===""?e.jsxs(P,{onClick:()=>z("shutdown"),children:[e.jsx(Q,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",z,K)},children:[e.jsx(Q,{children:e.jsx(yt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(pt,{}),e.jsxs(P,{onClick:be,children:[e.jsx(Q,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Je,{id:"sub-menu-view",anchorEl:N,keepMounted:!0,open:!!N,onClose:le,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{z("view-mblog"),le()},children:[e.jsx(Q,{children:e.jsx(Ue,{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:()=>{z("view-mjlog"),le()},children:[e.jsx(Q,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{z("view-diagnostic"),le()},children:[e.jsx(Q,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{z("view-history"),le()},children:[e.jsx(Q,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{z("view-shellylog"),le()},children:[e.jsx(Q,{children:e.jsx(Ue,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(pt,{}),e.jsxs(P,{onClick:ee,children:[e.jsx(Q,{children:e.jsx(ke,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Je,{id:"sub-menu-download",anchorEl:s,keepMounted:!0,open:!!s,onClose:oe,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{z("download-mbstorage"),oe()},children:[e.jsx(Q,{children:e.jsx(ke,{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:()=>{z("download-pluginstorage"),oe()},children:[e.jsx(Q,{children:e.jsx(ke,{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:()=>{z("download-pluginconfig"),oe()},children:[e.jsx(Q,{children:e.jsx(ke,{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:()=>{z("download-mblog"),oe()},children:[e.jsx(Q,{children:e.jsx(ke,{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:()=>{z("download-mjstorage"),oe()},children:[e.jsx(Q,{children:e.jsx(ke,{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:()=>{z("download-mjlog"),oe()},children:[e.jsx(Q,{children:e.jsx(ke,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{z("download-diagnostic"),oe()},children:[e.jsx(Q,{children:e.jsx(ke,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{z("download-history"),oe()},children:[e.jsx(Q,{children:e.jsx(ke,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{z("shelly-create-system-log"),oe()},children:[e.jsx(Q,{children:e.jsx(ke,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{z("shelly-download-system-log"),oe()},children:[e.jsx(Q,{children:e.jsx(ke,{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(pt,{}),e.jsxs(P,{onClick:_,children:[e.jsx(Q,{children:e.jsx(Mt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Je,{id:"sub-menu-backup",anchorEl:C,keepMounted:!0,open:!!C,onClose:w,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{z("create-backup"),w()},children:[e.jsx(Q,{children:e.jsx(Mt,{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:()=>{z("download-backup"),w()},children:[e.jsx(Q,{children:e.jsx(Mt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(pt,{}),e.jsxs(P,{onClick:Pe,children:[e.jsx(Q,{children:e.jsx(fo,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Je,{id:"sub-menu-reset",anchorEl:x,keepMounted:!0,open:!!x,onClose:Le,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{Le(),l("Reset all devices and shutdown","Are you sure you want to unregister all devices? This will temporarily remove all devices from the controller and you may loose the controller configuration.","unregister",z,K)},children:[e.jsx(Q,{children:e.jsx(Ae,{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:()=>{Le(),l("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",z,K)},children:[e.jsx(Q,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!c.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>{Le(),l("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",z,K)},children:[e.jsx(Q,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{Le(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",z,K)},children:[e.jsx(Q,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{Le(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",z,K)},children:[e.jsx(Q,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const xi=r.memo(fi),dr=1200,cr=800;let Lt,Nt;function bi(){if(typeof window<"u"){Lt=Math.floor(window.visualViewport?.width??window.innerWidth),Nt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=Lt<dr||Nt<cr;return o&&console.log("Visual viewport width %i height %i mobile %s",Lt,Nt,n),n}return!1}function vi({children:n}){const{mobile:d,setMobile:l}=r.useContext(_e);return r.useEffect(()=>{function i(){l(bi())}return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[l]),o&&console.log("MbfScreen rendering... mobile %s",d),e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:d?`${dr}px`:"calc(100vw - 40px)",height:d?`${cr}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(xi,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let o=!1;const yi=()=>{o=!o},ji=!1;let St;const wi=n=>{St=n};function Ci({setLoggedIn:n}){const[d,l]=r.useState(""),[i,a]=r.useState(""),f={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},p={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)"},y={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},t=async b=>{try{const M=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:b})});if(M.ok){const{valid:O}=await M.json();O?(n(!0),b!==""&&(St=b)):b!==""&&a("Incorrect password!")}else console.error("Failed to log in:",M.statusText)}catch(M){console.error("Failed to log in:",M)}},I=b=>{b.preventDefault(),t(d)};return t(""),e.jsx("div",{style:f,children:e.jsxs("form",{onSubmit:I,style:p,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"64px",width:"64px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:d,onChange:b=>l(b.target.value),style:y,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:i&&e.jsx("p",{style:{color:"red"},children:i})})]})})}function Si(){const[n,d]=r.useState(!1),l=localStorage.getItem("frontendTheme")||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const i=mi("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const a=hi(i),f=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return o&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${f}"`)),n?e.jsx(xo,{theme:a,children:e.jsx(Ir,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(en,{children:e.jsx(tn,{children:e.jsx(jr,{basename:f,children:e.jsx(vi,{children:e.jsxs(wr,{children:[e.jsx(ze,{path:"/",element:e.jsx(Wn,{})}),e.jsx(ze,{path:"/devices",element:e.jsx(ti,{})}),e.jsx(ze,{path:"/log",element:e.jsx(oi,{})}),e.jsx(ze,{path:"/settings",element:e.jsx(pi,{})}),e.jsx(ze,{path:"/test",element:e.jsx(gi,{})}),e.jsx(ze,{path:"*",element:e.jsx(Cr,{to:"/"})})]})})})})})})}):e.jsx(Ci,{setLoggedIn:d})}Sr.createRoot(document.getElementById("root")).render(e.jsx(kr.StrictMode,{children:e.jsx(Si,{})}));
1
+ import{B as e,y as r,S as at,U as jr,V as wr,X as ze,Y as Cr,Z as Sr,I as Mr}from"./vendor_node_modules.js";import{u as kr,S as Ir}from"./vendor_notistack.js";import{D as Ne,a as Le,b as We,B as ie,c as Oe,d as X,A as Dr,I as Q,C as Pr,e as $r,T as V,f as me,M as Nr,g as Je,h as P,i as Me,F as Lr,j as yt,k as Wr,l as Ve,m as Ee,n as se,K as Ot,o as Vt,p as Lt,L as lt,q as rt,r as dt,s as B,W as nt,t as ct,H as pt,u as ee,V as Et,v as _t,w as Tr,E as Fr,Q as Xt,R as jt,S as Rr,x as Hr,U as Or,P as Vr,y as er,z as Wt,G as Ie,J as tr,N as rr,O as wt,X as or,Y as Er,Z as _r,_ as Ar,$ as zr,a0 as At,a1 as qr,a2 as Ur,a3 as Br,a4 as Qr,a5 as Gr,a6 as Kr,a7 as Jr,a8 as zt,a9 as Zr,aa as Yr,ab as Xr,ac as eo,ad as to,ae as ro,af as oo,ag as no,ah as io,ai as so,aj as ao,ak as lo,al as co,am as po,an as uo,ao as qt,ap as Ze,aq as nr,ar as je,as as ir,at as Ct,au as He,av as go,aw as mo,ax as Ae,ay as ho,az as ut,aA as qe,aB as kt,aC as fo,aD as xo}from"./vendor_mui.js";import{I as oe,m as bo,a as Ut,b as vo,c as yo,d as Bt,e as jo,f as wo,g as Co,h as So,i as Mo,j as ko,k as Io,l as Do,n as Po,o as $o,p as No,q as Lo,r as Qt,s as Wo,t as To,u as Fo,v as Ro,w as Ho,x as Oo,y as Vo,z as Eo,A as Gt,B as _o,C as Ao}from"./vendor_mdi.js";import{Q as zo}from"./vendor_qrcode.js";import{F as qo,v as Uo,e as Bo,a as Qo,g as Go,b as Ko,c as Jo,d as It,A as Zo}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const d=document.createElement("link").relList;if(d&&d.supports&&d.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))i(a);new MutationObserver(a=>{for(const x of a)if(x.type==="childList")for(const p of x.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&i(p)}).observe(document,{childList:!0,subtree:!0});function l(a){const x={};return a.integrity&&(x.integrity=a.integrity),a.referrerPolicy&&(x.referrerPolicy=a.referrerPolicy),a.crossOrigin==="use-credentials"?x.credentials="include":a.crossOrigin==="anonymous"?x.credentials="omit":x.credentials="same-origin",x}function i(a){if(a.ep)return;a.ep=!0;const x=l(a);fetch(a.href,x)}})();function Yo({open:n,title:d,message:l,onConfirm:i,onCancel:a}){const x=j=>{o&&console.log("Confirmed"),j.preventDefault(),i()},p=j=>{o&&console.log("Canceled"),j.preventDefault(),a()};return e.jsxs(Ne,{open:n,children:[e.jsx(Le,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:d})]})}),e.jsxs(We,{children:[e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"0",marginBottom:"20px",maxHeight:"350px",maxWidth:"350px"},children:e.jsx("p",{style:{flex:1,margin:"0"},children:l})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(ie,{onClick:x,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ie,{onClick:p,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const Xo=({open:n,output:d,title:l,_command:i,_packageName:a,onInstall:x,onClose:p})=>{const j=r.useRef(null);return r.useEffect(()=>{o&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${j.current}`),setTimeout(()=>{o&&console.log("Scrolling to bottom:",j.current),j.current?.scrollIntoView({behavior:"smooth"})},0)},[d]),e.jsxs(Ne,{open:n,onClose:(t,I)=>{I==="backdropClick"||I==="escapeKeyDown"||p()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx(Le,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:l})]})}),e.jsxs(We,{dividers:!0,style:{overflow:"hidden",display:"flex",flexDirection:"column",height:400,paddingBottom:0},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"16px",fontWeight:"bold",color:"var(--primary-color)"},children:"Process log"}),e.jsxs("ul",{style:{width:"100%",height:"100%",fontFamily:"monospace",fontSize:"14px",padding:"10px",margin:0,marginBottom:"10px",color:"var(--div-text-color)",background:"var(--div-bg-color)",overflow:"auto",listStyle:"none",boxSizing:"border-box",borderRadius:4,border:"4px solid var(--primary-color)",whiteSpace:"pre-wrap",display:"block"},children:[d.split(`
2
+ `).map((t,I)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:t},I)),e.jsx("li",{ref:j,style:{padding:0,margin:0}})]})]}),e.jsxs(Oe,{sx:{justifyContent:"center"},children:[x&&e.jsx(ie,{variant:"contained",onClick:x,children:"Install"}),e.jsx(ie,{onClick:p,children:"Close"})]})]})},gt=[],_e=r.createContext(null);function en({children:n}){const[d,l]=r.useState(!1),[i,a]=r.useState(null),{enqueueSnackbar:x,closeSnackbar:p}=kr(),j=r.useCallback(S=>{o&&console.log(`UiProvider closeSnackbarMessage: message ${S}`);const w=gt.findIndex(M=>M.message===S);w!==-1&&(p(gt[w].key),gt.splice(w,1),o&&console.log(`UiProvider closeSnackbarMessage: message ${S} removed from persistMessages`))},[p]),t=r.useCallback((S,w,M)=>{o&&console.log(`UiProvider showSnackbarMessage: message ${S} timeout ${w}`);const _=x(S,{variant:"default",autoHideDuration:w==null||w>0?(w??5)*1e3:null,persist:w===0,content:K=>e.jsx(X,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Dr,{severity:M??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>p(K),action:e.jsx(Q,{size:"small",onClick:()=>p(K),sx:{color:"#fff"},children:e.jsx(Pr,{fontSize:"small"})}),children:S},K)},K)});w===0&&(o&&console.log(`UiProvider showSnackbarMessage: message ${S} timeout ${w} - persist key ${_}`),gt.push({message:S,key:_}))},[x,p]),[I,v]=r.useState(!1),[k,O]=r.useState(""),[E,T]=r.useState(""),[U,$]=r.useState(""),c=r.useRef(null),f=r.useRef(null),h=()=>{o&&console.log(`UiProvider handle confirm action ${U}`),v(!1),c.current&&c.current(U)},H=()=>{o&&console.log(`UiProvider handle cancel action ${U}`),v(!1),f.current&&f.current(U)},D=r.useCallback((S,w,M,_,K)=>{o&&console.log(`UiProvider showConfirmCancelDialog for command ${M}`),O(S),T(w),$(M),c.current=_,f.current=K,v(!0)},[]),[C,q]=r.useState(!1),[N,g]=r.useState(""),[s,u]=r.useState(""),[b,R]=r.useState(""),[ce,xe]=r.useState(""),ne=r.useCallback((S,w,M)=>{o&&console.log(`UiProvider show install progress for package ${S}`),g(S),u(w),R(M),q(!0)},[]),be=r.useCallback(S=>{o&&console.log(`UiProvider addInstallProgress: output ${S}`),xe(w=>w+S+`
3
+ `)},[]),F=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressSuccess: package ${b}`)},[b]),z=r.useCallback(()=>{o&&console.log(`UiProvider exitInstallProgressError: package ${b}`)},[b]),W=r.useCallback(()=>{o&&console.log("UiProvider hide install progress"),q(!1)},[]),Z=()=>{o&&console.log("UiProvider handle install close action"),q(!1),R(""),xe("")},L=r.useMemo(()=>({mobile:d,setMobile:l,currentPage:i,setCurrentPage:a,showSnackbarMessage:t,closeSnackbarMessage:j,closeSnackbar:p,showConfirmCancelDialog:D,showInstallProgress:ne,exitInstallProgressSuccess:F,exitInstallProgressError:z,hideInstallProgress:W,addInstallProgress:be}),[d,i,l,a,t,j,p,D,ne,F,z,W,be]);return e.jsxs(_e.Provider,{value:L,children:[e.jsx(Yo,{open:I,title:k,message:E,onConfirm:h,onCancel:H}),e.jsx(Xo,{open:C,title:N,_command:s,_packageName:b,output:ce,onClose:Z}),n]})}const sr=r.createContext(null),fe=r.createContext(null);function tn({children:n}){const[d,l]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[i,a]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[x,p]=r.useState([]),[j,t]=r.useState(1e3),[I,v]=r.useState(!0),[k,O]=r.useState(!1),{showSnackbarMessage:E,closeSnackbarMessage:T,closeSnackbar:U,showInstallProgress:$,hideInstallProgress:c,exitInstallProgressSuccess:f,exitInstallProgressError:h,addInstallProgress:H}=r.useContext(_e),D=r.useRef([]),C=r.useRef(null),q=r.useRef(1),N=r.useRef(Math.floor(Math.random()*999e3)+1e3),g=r.useRef(null),s=r.useRef(null),u=r.useRef(null),b=r.useRef(d),R=r.useRef(i),ce=r.useRef(0),xe=r.useRef(null),ne=r.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),be=r.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),F=100,z=60,W=50,Z=300,L=10;r.useEffect(()=>(o&&console.log("WebSocket messages started counter interval"),xe.current=setInterval(()=>{ce.current>0&&(o&&console.log(`WebSocket messages received in the last ${L} seconds: ${ce.current*(60/L)} messages/minute`),ce.current=0)},L*1e3),()=>{o&&console.log("WebSocket messages stopped counter interval"),xe.current&&clearInterval(xe.current),xe.current=null}),[]),r.useEffect(()=>{b.current=d},[d]),r.useEffect(()=>{R.current=i},[i]);const S=r.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),w=r.useCallback(G=>{if(C.current&&C.current.readyState===WebSocket.OPEN)try{o&&console.log(`WebSocket sending message with id ${G.id}:`,G),G.id===void 0&&(G.id=N.current);const m=JSON.stringify(G);C.current.send(m),o&&console.log("WebSocket sent message:",G)}catch(m){o&&console.error(`WebSocket error sending message: ${m}`)}else o&&console.error("WebSocket message not sent, WebSocket not connected:",G)},[]),M=r.useCallback((G,m)=>{p(he=>[...he,{level:G,time:"",name:"",message:m}])},[]),_=r.useCallback((G,m)=>{l(G),a(m),M("WebSocket",`Filtering by log level "${G}" and log search "${m}"`)},[M]),K=r.useCallback((G,m)=>{o&&console.log(`WebSocket addListener id ${m}:`,G),(m==null||isNaN(m)||m===0)&&console.error("WebSocket addListener called without id, listener not added:",G),D.current=[...D.current,{listener:G,id:m}],o&&console.log("WebSocket addListener total listeners:",D.current.length)},[]),pe=r.useCallback(G=>{o&&console.log("WebSocket removeListener:",G),D.current=D.current.filter(m=>m.listener!==G),o&&console.log("WebSocket removeListener total listeners:",D.current.length)},[]),le=r.useCallback(()=>{ne===""||ne===null||ne===void 0||(M("WebSocket",`Connecting ${et?"with password":""} to WebSocket: ${ne}`),o&&console.log(`WebSocket connecting to: ${ne}${et?"?password=[redacted]":""}`),C.current=new WebSocket(ne+(et?`?password=${et}`:"")),C.current.onmessage=G=>{k||O(!0),ce.current+=1;try{const m=JSON.parse(G.data);if(m.id===void 0||m.src===void 0||m.dst===void 0){o&&console.error("WebSocket undefined message id/src/dst:",m);return}if(m.src!=="Matterbridge"||m.dst!=="Frontend"){o&&console.error("WebSocket invalid message src/dst:",m);return}if(m.error){o&&console.error("WebSocket error message response:",m);return}if(m.id===N.current&&m.method==="pong"&&m.response==="pong"){o&&console.log(`WebSocket pong response message id ${m.id}:`,m),s.current&&clearTimeout(s.current),s.current=null;return}else if(m.method==="snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),E(m.response.message,m.response.timeout,m.response.severity);return}else if(m.method==="close_snackbar"&&m.response&&m.response.message){o&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),T(m.response.message);return}else if(m.method==="log"){if(!m.response||!m.response.level||!m.response.time||!m.response.name||!m.response.message||(m.response.level==="spawn"&&(m.response.name==="Matterbridge:spawn-init"?$(m.response.message,"",""):m.response.name==="Matterbridge:spawn-exit-success"?f():m.response.name==="Matterbridge:spawn-exit-error"?h():H(m.response.message+`
4
+ `)),["debug","info","notice","warn","error","fatal"].includes(m.response.level)&&(b.current==="info"&&m.response.level==="debug"||b.current==="notice"&&(m.response.level==="debug"||m.response.level==="info")||b.current==="warn"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice")||b.current==="error"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn")||b.current==="fatal"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn"||m.response.level==="error")))||R.current!=="*"&&R.current!==""&&!m.response.message.toLowerCase().includes(R.current.toLowerCase())&&!m.response.name.toLowerCase().includes(R.current.toLowerCase())||m.response.name==="Commissioning"&&m.response.message.includes("is uncommissioned"))return;p(ye=>{const ae=[...ye,{level:m.response.level,time:m.response.time,name:m.response.name,message:m.response.message}];return ae.length>j*2?ae.slice(j):ae})}else{if(o&&console.log(`WebSocket received message id ${m.id} method ${m.method}:`,m),m.id===0)D.current.forEach(he=>he.listener(m));else{const he=D.current.find(ye=>ye.id===m.id);he?he.listener(m):console.warn(`WebSocket no listener found for message id ${m.id}:`,m)}return}}catch(m){console.error(`WebSocket error parsing message: ${m}`,m instanceof Error?m.stack:null)}},C.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${ne}`),M("WebSocket",`Connected to WebSocket: ${ne}`),O(!0),U(),q.current=1,u.current=setTimeout(()=>{g.current=setInterval(()=>{w({id:N.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),s.current&&clearTimeout(s.current),s.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${ne}`),M("WebSocket",`No pong response received from WebSocket: ${ne}`),O(!1)},1e3*W)},1e3*z)},1e3*Z)},C.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${be?"with Ingress":""}: ${ne}`),M("WebSocket",`Disconnected from WebSocket: ${ne}`),O(!1),U(),c(),u.current&&clearTimeout(u.current),s.current&&clearTimeout(s.current),g.current&&clearInterval(g.current),M("WebSocket",`Reconnecting (attempt ${q.current} of ${F}) to WebSocket${be?" (Ingress)":""}: ${ne}`),be?setTimeout(de,5e3):q.current===1?de():q.current<F?setTimeout(de,1e3*q.current):M("WebSocket",`Reconnect attempts exceeded limit of ${F} retries, refresh the page to reconnect to: ${ne}`),q.current=q.current+1},C.current.onerror=G=>{o&&console.error(`WebSocket: WebSocket error connecting to ${ne}:`,G),M("WebSocket",`WebSocket error connecting to ${ne}`)})},[ne]),de=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${q.current}/${F} to:`,ne),le()},[le]);r.useEffect(()=>(le(),()=>{C.current&&C.current.readyState===WebSocket.OPEN&&C.current.close()}),[le]);const ge=r.useMemo(()=>({messages:x,maxMessages:j,autoScroll:I,setMessages:p,setLogFilters:_,setMaxMessages:t,setAutoScroll:v}),[x,p,_]),A=r.useMemo(()=>({maxMessages:j,autoScroll:I,logFilterLevel:d,logFilterSearch:i,setMessages:p,setLogFilters:_,setMaxMessages:t,setAutoScroll:v,online:k,retry:q.current,getUniqueId:S,addListener:K,removeListener:pe,sendMessage:w,logMessage:M}),[j,I,p,_,t,v,k,q.current,K,pe,w,M]);return e.jsx(sr.Provider,{value:ge,children:e.jsx(fe.Provider,{value:A,children:n})})}function rn(n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 296.2 296.2",...n,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"lg1",x1:"16.6",y1:"16.6",x2:"279.6",y2:"279.6",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".1",stopColor:"#3faa77"}),e.jsx("stop",{offset:".3",stopColor:"#234148"}),e.jsx("stop",{offset:".7",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#ad2e6e"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg2",x1:"31.1",y1:"31.1",x2:"265.1",y2:"265.1",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".2",stopColor:"#285251"}),e.jsx("stop",{offset:".4",stopColor:"#234148"}),e.jsx("stop",{offset:".8",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#a8316c"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg3",x1:"116.2",y1:"143.9",x2:"139.8",y2:"143.9",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#8bc751"}),e.jsx("stop",{offset:"1",stopColor:"#0db14b"})]}),e.jsx("linearGradient",{id:"lg4",x1:"136.1",y1:"100.8",x2:"159.6",y2:"100.8",xlinkHref:"#lg3"}),e.jsx("linearGradient",{id:"lg5",x1:"155.3",y1:"143.9",x2:"178.9",y2:"143.9",xlinkHref:"#lg3"}),e.jsxs("linearGradient",{id:"lg6",x1:"46.8",y1:"25.7",x2:"89.6",y2:"74.8",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#b1d34a"}),e.jsx("stop",{offset:"1",stopColor:"#50b848"})]})]}),e.jsx("rect",{width:"296.2",height:"296.2",rx:"56.7",ry:"56.7",style:{fill:"url(#lg1)"}}),e.jsx("rect",{x:"16.3",y:"16.3",width:"263.6",height:"263.6",rx:"50.5",ry:"50.5",style:{fill:"url(#lg2)"}}),e.jsx("circle",{cx:"128",cy:"143.9",r:"11.8",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"147.8",cy:"100.8",r:"11.8",style:{fill:"url(#lg4)"}}),e.jsx("path",{d:"m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"167.1",cy:"143.9",r:"11.8",style:{fill:"url(#lg5)"}}),e.jsx("path",{fill:"#fff",d:"M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z"}),e.jsx("path",{d:"M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z",style:{fill:"url(#lg6)"}}),e.jsx("path",{d:"M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z",fill:"#1e5857"}),e.jsx("path",{fill:"#fff",d:"M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z"})]})}function De(){const{retry:n}=r.useContext(fe),d=()=>{window.location.reload()};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center",fontSize:"20px",color:"var(--main-text-color)",backgroundColor:"var(--main-bg-color)"},children:[e.jsx(rn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx($r,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+n+")","..."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{})]}),e.jsx(ie,{variant:"contained",color:"primary",onClick:d,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function on({value:n,maxChars:d}){let l=n;if(n.length>d&&d>3){const i=d-3,a=n.substring(0,Math.ceil(i/2)),x=n.substring(n.length-Math.floor(i/2),n.length);l=`${a} … ${x}`}return n!==l?e.jsx(V,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:l})}):e.jsx("span",{children:l})}function ke({children:n,style:d}){const l={display:"flex",flexDirection:"column",flex:"0 0 auto",width:"100%",overflow:"hidden",margin:"0px",padding:"0px",gap:"0px",backgroundColor:"var(--div-bg-color)",boxShadow:"5px 5px 10px var(--div-shadow-color)",border:"1px solid var(--table-border-color)",borderRadius:"var(--div-border-radius)",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function Ye({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",borderBottom:"1px solid var(--table-border-color)",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function Xe({children:n,style:d}){const l={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function mt({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function ht({children:n,style:d}){const l={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function ot({children:n,style:d}){const l={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function it({children:n,style:d,onClose:l}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...d},children:[n,ji]})}function nn({systemInfo:n,compact:d}){const{addListener:l,removeListener:i,getUniqueId:a,sendMessage:x}=r.useContext(fe),[p,j]=r.useState(n),t=r.useRef(a());if(o&&console.log("SystemInfoTable loading with systemInfo:",p,"compact:",d),n&&d&&p.totalMemory&&p.freeMemory){const $=p.totalMemory,c=p.freeMemory;p.freeMemory=`${c} / ${$}`,p.totalMemory=""}if(n&&d&&p.heapTotal&&p.heapUsed){const $=p.heapTotal,c=p.heapUsed;p.heapUsed=`${c} / ${$}`,p.heapTotal=""}if(n&&d&&p.osRelease&&p.osType){const $=p.osType,c=p.osRelease;p.osType=`${$} (${c})`,p.osRelease=""}if(n&&d&&p.osArch&&p.osPlatform){const $=p.osPlatform,c=p.osArch;p.osPlatform=`${$} (${c})`,p.osArch=""}const I=($,c,f,h,H)=>{j(D=>({...D,totalMemory:$,freeMemory:c,heapTotal:f,heapUsed:h,rss:H}))},v=$=>{j(c=>({...c,cpuUsage:$.toFixed(2)+" %"}))},k=$=>{j(c=>({...c,processCpuUsage:$.toFixed(2)+" %"}))},O=($,c)=>{j(f=>({...f,systemUptime:$,processUptime:c}))},E=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),x({id:t.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const $=c=>{o&&console.log("SystemInfoTable received WebSocket Message:",c),c.method==="memory_update"&&c.response&&c.response.totalMemory&&c.response.freeMemory&&c.response.heapTotal&&c.response.heapUsed&&c.response.rss?(o&&console.log("SystemInfoTable received memory_update",c),I(c.response.totalMemory,c.response.freeMemory,c.response.heapTotal,c.response.heapUsed,c.response.rss)):c.method==="cpu_update"&&c.response&&c.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",c),v(c.response.cpuUsage),k(c.response.processCpuUsage)):c.method==="uptime_update"&&c.response&&c.response.systemUptime&&c.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",c),O(c.response.systemUptime,c.response.processUptime)):c.method==="/api/viewhistorypage"&&c.id===t.current&&c.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return l($,t.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${t.current}`),()=>{i($),o&&console.log("SystemInfoTable removed WebSocket listener")}},[l,i]);const[T,U]=r.useState(!1);return!p||T?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(ke,{style:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Ye,{children:[e.jsx(Xe,{children:"System Information"}),e.jsx(it,{onClose:()=>U(!0),children:e.jsx(Q,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:E,children:e.jsx(V,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(oe,{path:bo,size:"22px"})})})})]}),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(p).filter(([$,c])=>c!==void 0&&c!=="").map(([$,c],f)=>e.jsxs("tr",{className:f%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:$.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(on,{value:typeof c!="string"?c.toString():c,maxChars:24})})]},$))})})})]}))}const sn=r.memo(nn),Kt={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"}},an=n=>{if(!n)return"";const d=n.toString().replace(/[^0-9]/g,"");if(d.length<5)return d;const l=d.slice(0,4),i=d.slice(4,7),a=d.slice(7,11);return[l,i,a].filter(Boolean).join("-")};function ln({id:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:x}=r.useContext(fe),[p,j]=r.useState(null),t=r.useRef(null),I=r.useRef(null),v=r.useRef(x()),{showConfirmCancelDialog:k}=r.useContext(_e);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${I.current} and matter:`,p),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),t.current=n,I.current&&clearTimeout(I.current),I.current=null,n?(o&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),l({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:n,server:!0}})):(o&&console.log("QRDiv id effect setting matter to null"),j(null))},[n,l]),r.useEffect(()=>{const c=f=>{o&&console.log("QRDiv received WebSocket Message:",f),f.method==="refresh_required"&&f.response.changed==="matter"&&f.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${f.response.changed} for storeId "${f.response.matter.id}":`,f.response.matter),t.current===f.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${f.response.matter.id}":`,f.response.matter),I.current&&clearTimeout(I.current),f.response.matter.advertising&&f.response.matter.advertiseTime&&f.response.matter.advertiseTime+9e5<=Date.now()&&(f.response.matter.advertising=!1),j(f.response.matter),f.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${f.response.matter.id}":`,f.response.matter.advertiseTime+9e5-Date.now()),I.current=setTimeout(()=>{I.current&&clearTimeout(I.current),o&&console.log(`QRDiv clearing advertising state for storeId "${t.current}" after 15 minutes`),j(h=>h&&{...h,advertising:!1})},f.response.matter.advertiseTime+9e5-Date.now()))))};return i(c,v.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{a(c),I.current&&clearTimeout(I.current),I.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,a]);const O=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${p?.id}"`),p&&l({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,startCommission:!0}})},E=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${p?.id}"`),p&&l({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,stopCommission:!0}})},T=()=>{o&&console.log(`QRDiv sent matter advertise for node "${p?.id}"`),p&&l({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,advertise:!0}})},U=c=>{o&&console.log(`QRDiv sent matter removeFabric for node "${p?.id}" and fabricIndex ${c}`),p&&l({id:v.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,removeFabric:c}})},$=async()=>{if(!p||!p.manualPairingCode)return;const c=p.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(c);else{const f=document.createElement("textarea");f.value=c,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.focus(),f.select(),document.execCommand("copy"),document.body.removeChild(f)}o&&console.log("Manual pairing code copied to clipboard")}catch(f){console.error("Failed to copy manual pairing code",f)}};return!p||!d?(o&&console.log("QRDiv rendering undefined state"),null):p.online?p.advertising&&p.qrPairingCode&&p.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(ke,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs(Ye,{children:[e.jsx(Xe,{children:"QR pairing code"}),e.jsxs(it,{children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:T,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(oe,{path:Ut,size:"22px"})})}),e.jsx(Q,{"aria-label":"stop pairing",size:"small",onClick:E,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Turn off pairing",arrow:!0,children:e.jsx(oe,{path:vo,size:"22px"})})})]})]}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(zo,{value:p.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(mt,{style:{justifyContent:"space-between"},children:[e.jsxs(ht,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",an(p.manualPairingCode)]}),e.jsx(it,{children:e.jsx(V,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(Q,{"aria-label":"copy manual pairing code",size:"small",onClick:$,sx:Kt,children:e.jsx(oe,{path:yo,size:.85})})})})]})]})):p.commissioned&&p.fabricInformations&&p.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(ke,{style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Ye,{children:[e.jsx(Xe,{children:"Paired fabrics"}),e.jsxs(it,{children:[e.jsx(Q,{"aria-label":"send advertising",size:"small",onClick:T,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(oe,{path:Ut,size:"22px"})})}),e.jsx(Q,{"aria-label":"start pairing",size:"small",onClick:O,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(V,{title:"Turn on pairing",arrow:!0,children:e.jsx(oe,{path:Bt,size:"22px"})})})]})]}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:p.fabricInformations.map((c,f)=>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: ",c.fabricIndex]}),e.jsx(V,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(Q,{"aria-label":"remove the fabric",size:"small",onClick:()=>k("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>U(c.fabricIndex),()=>{}),sx:{...Kt,padding:"2px"},children:e.jsx(oe,{path:jo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",c.rootVendorId," ",c.rootVendorName]}),c.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",c.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",p.sessionInformations?p.sessionInformations.filter(h=>h.fabric?.fabricIndex===c.fabricIndex&&h.isPeerActive===!0).length:"0"," ","subscriptions: ",p.sessionInformations?p.sessionInformations.filter(h=>h.fabric?.fabricIndex===c.fabricIndex&&h.isPeerActive===!0&&h.numberOfActiveSubscriptions>0).length:"0"]})]},f))}),e.jsx(mt,{style:{justifyContent:"center"},children:e.jsxs(ht,{style:{fontWeight:"normal"},children:["Serial number: ",p.serialNumber]})})]})):!p.commissioned&&!p.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(ke,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Ye,{children:e.jsx(Xe,{children:"QR pairing code"})}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(ie,{onClick:O,endIcon:e.jsx(oe,{path:Bt,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx(mt,{style:{justifyContent:"center"},children:e.jsxs(ht,{style:{fontWeight:"normal"},children:["Serial number: ",p.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(ke,{style:{alignItems:"center",minWidth:"302px"},children:[e.jsx(Ye,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(Xe,{children:"Server node"})}),e.jsx(ot,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(ot,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(mt,{style:{justifyContent:"center"},children:e.jsxs(ht,{style:{fontWeight:"normal"},children:["Serial number: ",p.serialNumber]})})]}))}const dn=r.memo(ln);function cn(){const{logMessage:n,sendMessage:d,getUniqueId:l}=r.useContext(fe),[i,a]=r.useState("matterbridge-"),[x,p]=r.useState(!1),[j,t]=r.useState(null),I=r.useRef(l()),v=N=>{N.preventDefault(),p(!0)},k=()=>{p(!1)},O=N=>{N.preventDefault(),p(!1);const g=N.dataTransfer.files[0];if(g){n("Plugins",`Installing package ${g.name}. Please wait...`);const s=new FormData;s.append("file",g),s.append("filename",g.name),fetch("./api/uploadpackage",{method:"POST",body:s}).then(u=>u.text()).then(u=>{n("Plugins",`Server response: ${u}`)}).catch(u=>{console.error("Error uploading plugin file:",u),n("Plugins",`Error installing package ${u}`)})}},E=N=>{const g=N.target.files&&N.target.files[0];if(g){n("Plugins",`Uploading package ${g.name}`);const s=new FormData;s.append("file",g),s.append("filename",g.name),fetch("./api/uploadpackage",{method:"POST",body:s}).then(u=>u.text()).then(u=>{n("Plugins",`Server response: ${u}`)}).catch(u=>{console.error("Error uploading plugin file:",u),n("Plugins",`Error uploading package ${u}`)})}},T=()=>{d({id:I.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:i,restart:!1}})},U=()=>{document.getElementById("file-upload")?.click()},$=()=>{d({id:I.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:i}})},c=N=>{N.preventDefault(),d({id:I.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:i}})},f=N=>{N.preventDefault(),console.log("Right-clicked Upload button")},h=N=>{N.preventDefault(),console.log("Right-clicked Add button")},H=N=>{t(N.currentTarget)},D=N=>{N!==""&&a(N),t(null)},[C,q]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),C?null:e.jsxs(ke,{children:[e.jsxs(Ye,{children:[e.jsx(Xe,{children:"Install plugins"}),e.jsx(it,{onClose:()=>q(!0)})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:v,onDragLeave:k,onDrop:O,children:[e.jsx(me,{value:i,onChange:N=>{a(N.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(Q,{onClick:H,children:e.jsx(Nr,{})}),e.jsxs(Je,{id:"simple-menu",anchorEl:j,keepMounted:!0,open:!!j,onClose:()=>D(""),children:[e.jsx(P,{onClick:()=>D("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(P,{onClick:()=>D("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(P,{onClick:()=>D("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(P,{onClick:()=>D("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(P,{onClick:()=>D("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(P,{onClick:()=>D("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(P,{onClick:()=>D("matterbridge-test"),children:"matterbridge-test"}),e.jsx(P,{onClick:()=>D("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(P,{onClick:()=>D("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(P,{onClick:()=>D("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(P,{onClick:()=>D("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(P,{onClick:()=>D("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(P,{onClick:()=>D("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(P,{onClick:()=>D("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(V,{title:"Install or update a plugin from npm",children:e.jsxs(ie,{onClick:T,onContextMenu:c,endIcon:e.jsx(Me,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(V,{title:"Upload and install a plugin from a tarball",children:e.jsxs(ie,{onClick:U,onContextMenu:f,endIcon:e.jsx(Lr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(V,{title:"Add an installed plugin",children:e.jsxs(ie,{onClick:$,onContextMenu:h,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:E})]})]})}const pn=r.memo(cn);function Ue({status:n,enabledText:d="Enabled",disabledText:l=void 0,tooltipText:i=void 0,onClick:a}){if(n===void 0)return null;{const x=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:a,children:n?d:l??d});return i!==void 0?e.jsx(V,{title:i,children:x}):x}}function un(n,d,l){const i=n?.[l],a=d?.[l];return i==null&&a==null?0:i==null?-1:a==null?1:typeof i=="boolean"&&typeof a=="boolean"?i===a?0:i?1:-1:typeof i=="number"&&typeof a=="number"?i-a:String(i).localeCompare(String(a))}function gn({name:n,title:d,columns:l,rows:i,getRowKey:a,footerLeft:x,footerRight:p,onRowClick:j}){const t=r.useRef(new WeakMap),I=r.useRef(1),v=g=>{if(typeof a=="string"&&g&&g[a]!=null)return g[a];if(typeof a=="function"){const b=a(g);if(b!=null)return b}const s=l?.[0]?.id;if(s&&g&&g[s]!=null)return g[s];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let u=t.current.get(g);return u||(u=`rk_${I.current++}`,t.current.set(g,u)),u},[k,O]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[E,T]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[U,$]=r.useState(!1),[c,f]=r.useState(()=>{try{const g=localStorage.getItem(`${n}_column_visibility`);if(g)return JSON.parse(g)}catch{}return{}}),h=r.useMemo(()=>{const g={};for(const s of l)s.hidden||(g[s.id]=s.required?!0:c[s.id]!==!1);return g},[l,c]),H=r.useMemo(()=>{if(!k||!E)return i;const g=l.find(u=>u.id===k);if(!g||g.noSort)return i;const s=i.map((u,b)=>({el:u,index:b}));return s.sort((u,b)=>{let R;return typeof g.comparator=="function"?R=g.comparator(u.el,b.el):R=un(u.el,b.el,k),R!==0?E==="asc"?R:-R:u.index-b.index}),s.map(u=>u.el)},[i,k,E,l]),D=g=>{if(k!==g||!k){O(g),T("asc"),localStorage.setItem(`${n}_table_order_by`,g),localStorage.setItem(`${n}_table_order`,"asc");return}if(E==="asc"){T("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}O(null),T(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},C=()=>{$(!U)},q=g=>{f(s=>{const u=l.find(ce=>ce.id===g);if(u&&u.required)return s;const b=h[g]!==!1,R={...s};b?R[g]=!1:delete R[g];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(R))}catch{}return R})},N=()=>{f({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}$(!1)};return o&&console.log(`Rendering table ${n}${k&&E?` ordered by ${k}:${E}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(Ne,{open:U,onClose:(g,s)=>{s==="backdropClick"||s==="escapeKeyDown"||C()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Le,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${n} columns`})]})}),e.jsx(We,{children:e.jsx(Wr,{children:l.filter(g=>!g.hidden).map(g=>e.jsx(Ve,{control:e.jsx(Ee,{disabled:!!g.required,checked:g.required?!0:h[g.id]!==!1,onChange:()=>q(g.id)}),label:g.label},g.id))})}),e.jsxs(Oe,{children:[e.jsx(ie,{onClick:N,children:"Reset"}),e.jsx(ie,{variant:"contained",onClick:g=>{if(g?.currentTarget&&typeof g.currentTarget.blur=="function")try{g.currentTarget.blur()}catch{}const s=document.activeElement;if(s&&s instanceof HTMLElement&&typeof s.blur=="function")try{s.blur()}catch{}C()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:n}),d&&e.jsx("p",{className:"MbfWindowHeaderText",children:d}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(Q,{onClick:g=>{if(g?.currentTarget?.blur)try{g.currentTarget.blur()}catch{}C()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(V,{title:`Configure ${n} columns`,children:e.jsx(oe,{path:wo,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",flex:"1 1 auto",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:l.map(g=>{if(g.hidden||!g.required&&h[g.id]===!1)return null;const s=!g.noSort,u=s&&k===g.id&&!!E;return e.jsxs("th",{onClick:s?()=>D(g.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:g.minWidth,maxWidth:g.maxWidth,textAlign:g.align||"left",cursor:s?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:g.maxWidth?"nowrap":void 0,overflow:g.maxWidth?"hidden":void 0,textOverflow:g.maxWidth?"ellipsis":void 0},"aria-sort":s?u?E==="asc"?"ascending":"descending":"none":void 0,children:[g.label,u&&e.jsxs("span",{style:{marginLeft:6},children:[E==="asc"&&e.jsx(oe,{path:Co,size:"15px"}),E==="desc"&&e.jsx(oe,{path:So,size:"15px"})]})]},g.id)})})}),e.jsx("tbody",{children:H.map((g,s)=>{const u=v(g);return e.jsx("tr",{className:s%2===0?"table-content-even":"table-content-odd",onClick:j?b=>j(g,u,b):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:j?"pointer":void 0},children:l.map(b=>{if(b.hidden||!b.required&&h[b.id]===!1)return null;const R=g[b.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:b.align||"left",padding:"5px 10px",margin:"0",maxWidth:b.maxWidth,whiteSpace:b.maxWidth?"nowrap":void 0,overflow:b.maxWidth?"hidden":void 0,textOverflow:b.maxWidth?"ellipsis":void 0},children:typeof b.render=="function"?b.render(R,u,g,b):typeof R=="boolean"?e.jsx(Ee,{checked:R,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):b.format&&typeof R=="number"?b.format(R):R!=null?String(R):null},b.id)})},u)})})]})}),(x||p)&&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:x}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:p})]})]})}function mn(n){return r.memo(n)}const St=mn(gn);function Jt(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const Be={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Qe={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},hn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},fn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Fe={padding:"0px",margin:"0px"},xn="5px 10px 5px 10px",ft={},ve={},xt={},bt={};let Ge=[],Dt=[];const bn=({open:n,onClose:d,plugin:l})=>{const{sendMessage:i,addListener:a,removeListener:x,getUniqueId:p}=r.useContext(fe),j=r.useRef(p()),[t,I]=r.useState(l.configJson),[v,k]=r.useState(null),[O,E]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[T,U]=r.useState("");let $={};r.useEffect(()=>{const S=w=>{w.src==="Matterbridge"&&w.dst==="Frontend"&&(Jt(w)&&w.id===j.current&&w.method==="/api/select/devices"&&w.response&&(o&&console.log(`ConfigPluginDialog (id: ${w.id}) received ${w.response.length} /api/select/devices:`,w.response),Ge=w.response),Jt(w)&&w.id===j.current&&w.method==="/api/select/entities"&&w.response&&(o&&console.log(`ConfigPluginDialog (id: ${w.id}) received ${w.response.length} /api/select/entities:`,w.response),Dt=w.response))};return a(S,j.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",j.current),t&&v&&v.properties&&(Object.keys(v.properties).forEach(w=>{Object.keys(v.properties[w]).forEach(M=>{M.startsWith("ui:")&&(O[w]={},O[w][M]=v.properties[w][M],delete v.properties[w][M])})}),E(O)),l.name&&l.configJson&&l.schemaJson&&(I(l.configJson),k(l.schemaJson),i({id:j.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),i({id:j.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),o&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',l.name)),()=>{x(S),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[a,t,l,x,v,i,O]);const c=(S,w)=>{$=S.formData},f=S=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",S.formData),I(S.formData),l.configJson=S.formData,l.restartRequired=!0,i({id:j.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:S.formData.name,formData:S.formData}}),d()};function h(S){const{id:w,label:M,onKeyChange:_,onDropPropertyClick:K,disabled:pe,schema:le,children:de,registry:ge,readonly:A,required:G}=S,{templates:m}=ge,{RemoveButton:he}=m.ButtonTemplates;if(!(Zo in le))return e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:de});const ae=({target:te})=>_(te&&te.value);return e.jsxs(X,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(me,{id:`${w}-key`,name:`${w}-key`,required:G,disabled:pe||A,defaultValue:M,onBlur:A?void 0:ae,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(X,{sx:{flex:1},children:de}),e.jsx(he,{disabled:pe||A,onClick:K(M),registry:ge})]})}function H(S){const{children:w,description:M,displayLabel:_,errors:K,help:pe,hidden:le,registry:de,uiSchema:ge}=S,A=Ko(ge),G=Jo("WrapIfAdditionalTemplate",de,A);return le?e.jsx("div",{style:{display:"none"},children:w}):e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(G,{...S,children:[_===!0&&M,w,K,pe]})})}function D(S){const{description:w}=S;return w?e.jsx(se,{sx:Qe,children:w}):null}function C(S){const{required:w,title:M}=S;return M?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(se,{sx:Be,children:["Title ",M," ",w&&e.jsx("mark",{children:"***"})]})}):null}function q(S){const{help:w}=S;return w?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(se,{sx:hn,children:w})}):null}function N(S){const{errors:w}=S;return w?e.jsxs(X,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(se,{color:"error",sx:fn,children:"Please fix the following errors:"}),e.jsx(rt,{children:w.map((M,_)=>e.jsxs(Tr,{children:[e.jsx(B,{children:e.jsx(Fr,{color:"error"})}),e.jsx(ee,{primary:M.stack})]},_))})]}):null}function g(S){const{errors:w}=S;return w?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:w.map((M,_)=>e.jsxs(se,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",M]},_))}):null}function s(S){const{id:w,name:M,_schema:_,_uiSchema:K,value:pe,options:le,label:de,type:ge,placeholder:A,required:G,disabled:m,readonly:he,autofocus:ye,onChange:ae,onChangeOverride:te,onBlur:re,onFocus:Pe,_rawErrors:$e,_hideError:tt,_registry:y,_formContext:Y}=S,Ce=({target:{value:Se}})=>ae(Se===""?le.emptyValue:Se),Re=({target:Se})=>re(w,Se&&Se.value),st=({target:Se})=>Pe(w,Se&&Se.value);return e.jsx(X,{sx:{padding:"0px",margin:"0px"},children:e.jsx(me,{id:w,name:w,label:A&&A!==""?de:void 0,variant:"outlined",placeholder:A&&A!==""?A:de,required:G,disabled:m||he,autoFocus:ye,value:pe||pe===0?pe:"",type:ge,autoComplete:ge==="password"?"current-password":M,onChange:te||Ce,onBlur:Re,onFocus:st,fullWidth:!0})})}function u(S){return console.log("ArrayFieldTitleTemplate:",S),null}function b(S){return console.log("ArrayFieldDescriptionTemplate:",S),null}function R(S){return console.log("ArrayFieldItemTemplate:",S),null}function ce(S){const{canAdd:w,onAddClick:M,schema:_,title:K}=S,[pe,le]=r.useState(!1),[de,ge]=r.useState(!1),[A,G]=r.useState(!1),[m,he]=r.useState(""),ye=y=>{he(y.target.value)},ae=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",m,"selectDevices:",Ge),le(!pe)},te=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",m,"selectEntities:",Dt),ge(!de)},re=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",m,"selectDevices:",Ge),G(!A)},Pe=y=>{le(!1),_.selectFrom==="serial"?_.items.default=y.serial:_.selectFrom==="name"&&(_.items.default=y.name),M()},$e=y=>{ge(!1),_.selectEntityFrom==="name"?_.items.default=y.name:_.selectEntityFrom==="description"&&(_.items.default=y.description),M()},tt=y=>{G(!1),_.selectDeviceEntityFrom==="name"?_.items.default=y.name:_.selectDeviceEntityFrom==="description"&&(_.items.default=y.description),M()};return e.jsxs(X,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[K&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[K&&e.jsx(se,{sx:Be,children:K}),w&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[_.selectFrom&&e.jsx(V,{title:"Add a device from the list",children:e.jsx(Q,{onClick:ae,size:"small",color:"primary",sx:Fe,children:e.jsx(lt,{})})}),_.selectEntityFrom&&e.jsx(V,{title:"Add an entity from the list",children:e.jsx(Q,{onClick:te,size:"small",color:"primary",sx:Fe,children:e.jsx(lt,{})})}),_.selectDeviceEntityFrom&&e.jsx(V,{title:"Add a device entity from the list",children:e.jsx(Q,{onClick:re,size:"small",color:"primary",sx:Fe,children:e.jsx(lt,{})})}),e.jsx(V,{title:"Add a new item",children:e.jsx(Q,{onClick:M,size:"small",color:"primary",sx:Fe,children:e.jsx(yt,{})})})]})]}),_.description&&e.jsx(se,{sx:Qe,children:_.description}),S.items.map(y=>e.jsxs(X,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(X,{sx:{flexGrow:1,marginRight:"10px"},children:y.children}),e.jsx(Q,{disabled:!y.hasMoveUp,onClick:y.onReorderClick(y.index,y.index-1),size:"small",color:"primary",sx:Fe,children:e.jsx(Vt,{})}),e.jsx(Q,{disabled:!y.hasMoveDown,onClick:y.onReorderClick(y.index,y.index+1),size:"small",color:"primary",sx:Fe,children:e.jsx(Ot,{})}),e.jsx(Q,{onClick:y.onDropIndexClick(y.index),size:"small",color:"primary",sx:Fe,children:e.jsx(Lt,{})})]},y.index)),e.jsxs(Ne,{open:pe,onClose:ae,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Le,{children:"Select a device"}),e.jsxs(We,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:m,onChange:ye,placeholder:"Enter serial or name"})]}),e.jsx(rt,{dense:!0,children:Ge.filter(y=>y.serial.toLowerCase().includes(m.toLowerCase())||y.name.toLowerCase().includes(m.toLowerCase())).map((y,Y)=>e.jsxs(dt,{onClick:()=>Pe(y),sx:ft,children:[y.icon==="wifi"&&e.jsx(B,{children:e.jsx(nt,{style:ve})}),y.icon==="ble"&&e.jsx(B,{children:e.jsx(ct,{style:ve})}),y.icon==="hub"&&e.jsx(B,{children:e.jsx(pt,{style:ve})}),e.jsx(ee,{primary:y.name,secondary:y.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Y))})]}),e.jsx(Oe,{children:e.jsx(ie,{onClick:ae,children:"Close"})})]}),e.jsxs(Ne,{open:de,onClose:te,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Le,{children:"Select an entity"}),e.jsxs(We,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:m,onChange:ye,placeholder:"Enter name or description"})]}),e.jsx(rt,{dense:!0,children:Dt.filter(y=>y.name.toLowerCase().includes(m.toLowerCase())||y.description.toLowerCase().includes(m.toLowerCase())).map((y,Y)=>e.jsxs(dt,{onClick:()=>$e(y),sx:ft,children:[y.icon==="wifi"&&e.jsx(B,{children:e.jsx(nt,{style:ve})}),y.icon==="ble"&&e.jsx(B,{children:e.jsx(ct,{style:ve})}),y.icon==="hub"&&e.jsx(B,{children:e.jsx(pt,{style:ve})}),y.icon==="component"&&e.jsx(B,{children:e.jsx(Et,{style:ve})}),y.icon==="matter"&&e.jsx(B,{children:e.jsx(_t,{style:ve})}),e.jsx(ee,{primary:y.name,secondary:y.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Y))})]}),e.jsx(Oe,{children:e.jsx(ie,{onClick:te,children:"Close"})})]}),e.jsxs(Ne,{open:A,onClose:re,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Le,{children:["Select an entity for ",K]}),e.jsx(We,{children:e.jsx(rt,{dense:!0,children:Ge.filter(y=>y.serial===K||y.name===K).map(y=>y.entities?.map((Y,Ce)=>e.jsxs(dt,{onClick:()=>tt(Y),sx:ft,children:[Y.icon==="wifi"&&e.jsx(B,{children:e.jsx(nt,{style:ve})}),Y.icon==="ble"&&e.jsx(B,{children:e.jsx(ct,{style:ve})}),Y.icon==="hub"&&e.jsx(B,{children:e.jsx(pt,{style:ve})}),Y.icon==="component"&&e.jsx(B,{children:e.jsx(Et,{style:ve})}),Y.icon==="matter"&&e.jsx(B,{children:e.jsx(_t,{style:ve})}),e.jsx(ee,{primary:Y.name,secondary:Y.description,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},Ce)))})}),e.jsx(Oe,{children:e.jsx(ie,{onClick:re,children:"Close"})})]})]})}function xe(S){const{onAddClick:w,schema:M,properties:_,title:K,description:pe}=S,[le,de]=r.useState(!1),[ge,A]=r.useState(""),G=te=>{A(te.target.value)},m=()=>{de(!le)},he=te=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${te.serial}" for schema "${M.selectFrom}"`),de(!1);let re="";M.selectFrom==="serial"?re=te.serial:M.selectFrom==="name"&&(re=te.name),U(re),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${re}"`),w(M)()},ye=()=>{w(M)()},ae=!M.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${ae} newkey "${T}"`),!ae&&T!==""&&(o&&console.log("ObjectFieldTemplate: newkey",T,"properties",_),_.forEach(te=>{if(te.name==="newKey"&&te.content.key==="newKey"&&te.content.props.name==="newKey"&&te.content.props.onKeyChange&&T!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",T);const re=T;U(""),te.content.props.onKeyChange(re)}})),e.jsxs(X,{sx:{margin:"0px",padding:ae?"10px":"5px 10px 0px 10px",border:ae?"none":"1px solid grey"},children:[M.title&&ae&&e.jsx(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:Be,children:M.title})}),K&&!ae&&e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(se,{sx:Be,children:K}),e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[M.selectFrom&&e.jsx(V,{title:"Add a device from the list",children:e.jsx(Q,{onClick:m,size:"small",color:"primary",sx:Fe,children:e.jsx(lt,{})})}),e.jsx(V,{title:"Add a new item",children:e.jsx(Q,{onClick:ye,size:"small",color:"primary",sx:Fe,children:e.jsx(yt,{})})})]})]}),M.description&&e.jsx(X,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(se,{sx:Qe,children:M.description})}),_.map(({content:te,name:re,hidden:Pe})=>!Pe&&e.jsxs(X,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(M.properties[re].type)?"0px":xn,border:["object","array","boolean"].includes(M.properties[re].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(M.properties[re].type)&&e.jsx(se,{sx:Be,children:re}),e.jsx(X,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:te})]},re)),e.jsxs(Ne,{open:le,onClose:m,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Le,{children:"Select a device"}),e.jsxs(We,{children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(se,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{fullWidth:!0,variant:"outlined",value:ge,onChange:G,placeholder:"Enter serial or name"})]}),e.jsx(rt,{dense:!0,children:Ge.filter(te=>te.serial.toLowerCase().includes(ge.toLowerCase())||te.name.toLowerCase().includes(ge.toLowerCase())).map((te,re)=>e.jsxs(dt,{onClick:()=>he(te),sx:ft,children:[te.icon==="wifi"&&e.jsx(B,{children:e.jsx(nt,{style:ve})}),te.icon==="ble"&&e.jsx(B,{children:e.jsx(ct,{style:ve})}),te.icon==="hub"&&e.jsx(B,{children:e.jsx(pt,{style:ve})}),e.jsx(ee,{primary:te.name,secondary:te.serial,primaryTypographyProps:{style:xt},secondaryTypographyProps:{style:bt}})]},re))})]}),e.jsx(Oe,{children:e.jsx(ie,{onClick:m,children:"Close"})})]})]})}function ne(S){const{uiSchema:w}=S,{submitText:M,norender:_}=Go(w);return _?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ie,{type:"submit",variant:"contained",color:"primary",children:M}),e.jsx(ie,{variant:"contained",color:"primary",onClick:d,children:"Cancel"})]})}function be(S){const{className:w,disabled:M,onClick:_,registry:K,style:pe,uiSchema:le,...de}=S;return e.jsx(V,{title:"Remove the item",children:e.jsx(Q,{disabled:M,size:"small",color:"primary",onClick:_,children:e.jsx(Lt,{})})})}function F(S){const{className:w,disabled:M,onClick:_,registry:K,uiSchema:pe,...le}=S;return e.jsx(V,{title:"Add an item",children:e.jsx(Q,{size:"small",color:"primary",onClick:_,children:e.jsx(yt,{})})})}function z(S){const{disabled:w,onClick:M,registry:_,style:K,uiSchema:pe,...le}=S;return e.jsx(V,{title:"Move up the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:M,children:e.jsx(Vt,{})})})}function W(S){const{disabled:w,onClick:M,registry:_,style:K,uiSchema:pe,...le}=S;return e.jsx(V,{title:"Move down the item",children:e.jsx(Q,{size:"small",color:"primary",onClick:M,children:e.jsx(Ot,{})})})}function Z(S){const{id:w,name:M,value:_,schema:K,readonly:pe,onChange:le}=S,[de,ge]=r.useState(),A=m=>{o&&console.log(`CheckboxWidget ${M} onChangeField:`,m),ge(m&&m!==""?m:void 0)},G=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${M}" value="${de}"`),i({id:j.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:M,value:de,formData:$,id:w}}),K.buttonClose===!0?d():K.buttonSave===!0&&f({formData:t})};return K.buttonText&&K.description?e.jsxs(X,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(se,{sx:Qe,children:K.description}),e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>G(),children:K.buttonText})]}):K.buttonField&&K.description?e.jsxs(X,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(se,{sx:Qe,children:K.description}),e.jsx(me,{id:M+"-input",name:M,label:K.textLabel,placeholder:K.textPlaceholder,onChange:m=>A(m.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ie,{id:M+"-button",variant:"contained",color:"primary",disabled:de===void 0,onClick:()=>G(),children:K.buttonField})]}):e.jsxs(X,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[M&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(se,{sx:Be,children:M}),e.jsx(Ee,{checked:_,readOnly:pe,onChange:()=>le(!_),sx:{padding:"0px",margin:"0px"}})]}),K.description&&e.jsx(se,{sx:Qe,children:K.description})]})}function L({schema:S,id:w,name:M,options:_,label:K,hideLabel:pe,required:le,disabled:de,placeholder:ge,readonly:A,value:G,multiple:m,autofocus:he,onChange:ye,onBlur:ae,onFocus:te,errorSchema:re,rawErrors:Pe=[],registry:$e,uiSchema:tt,hideError:y,formContext:Y,...Ce}){const{enumOptions:Re,enumDisabled:st,emptyValue:Se}=_;m=typeof m>"u"?!1:!!m;const Tt=m?[]:"",Ft=typeof G>"u"||m&&G.length<1||!m&&G===Tt,pr=({target:{value:Te}})=>ye(It(Te,Re,Se)),ur=({target:Te})=>ae(w,It(Te&&Te.value,Re,Se)),gr=({target:Te})=>te(w,It(Te&&Te.value,Re,Se)),Rt=Bo(G,Re,m),{InputLabelProps:mr,SelectProps:hr,autocomplete:fr,...xr}=Ce,br=!m&&S.default===void 0;return e.jsxs(me,{id:w,name:w,value:!Ft&&typeof Rt<"u"?Rt:Tt,required:le,disabled:de||A,autoFocus:he,autoComplete:fr,placeholder:ge,error:Pe.length>0,onChange:pr,onBlur:ur,onFocus:gr,...xr,select:!0,InputLabelProps:{...mr,shrink:!Ft},SelectProps:{...hr,multiple:m},"aria-describedby":Qo(w),children:[br&&e.jsx(P,{value:"",children:ge}),Array.isArray(Re)&&Re.map(({value:Te,label:vr},Ht)=>{const yr=Array.isArray(st)&&st.indexOf(Te)!==-1;return e.jsx(P,{value:String(Ht),disabled:yr,children:vr},Ht)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!v||!t?null:e.jsxs(Ne,{open:n,onClose:d,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Le,{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(We,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(qo,{schema:v,formData:t,uiSchema:O,validator:Uo,templates:{FieldTemplate:H,BaseInputTemplate:s,TitleFieldTemplate:C,DescriptionFieldTemplate:D,FieldHelpTemplate:q,FieldErrorTemplate:g,ErrorListTemplate:N,WrapIfAdditionalTemplate:h,ArrayFieldTitleTemplate:u,ArrayFieldDescriptionTemplate:b,ArrayFieldItemTemplate:R,ArrayFieldTemplate:ce,ObjectFieldTemplate:xe,ButtonTemplates:{SubmitButton:ne,RemoveButton:be,AddButton:F,MoveUpButton:z,MoveDownButton:W}},widgets:{CheckboxWidget:Z,SelectWidget:L},onChange:c,onSubmit:f})})]})};function ar(n){if(o&&console.log(`getQRColor (id: ${n?.id}) received matter:`,n??"undefined"),n===void 0||!n.online||!n.qrPairingCode&&!n.manualPairingCode&&!n.fabricInformations&&!n.sessionInformations)return"red";if(n.commissioned===!1&&n.qrPairingCode&&n.manualPairingCode)return"var(--primary-color)";let d=0,l=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&d++,i.numberOfActiveSubscriptions>0&&(l+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(d===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function vn({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:a,removeListener:x,getUniqueId:p}=r.useContext(fe),{showConfirmCancelDialog:j}=r.useContext(_e),t=r.useRef(p()),[I,v]=r.useState(null),[k,O]=r.useState(null),[E,T]=r.useState([]),U=[{label:"Name",id:"name",required:!0,render:(W,Z,L,S)=>e.jsx(V,{title:`Plugin path ${L.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>g(L),children:L.name})})},{label:"Description",id:"description",render:(W,Z,L,S)=>e.jsx(V,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>g(L),children:L.description})})},{label:"Version",id:"version",render:(W,Z,L,S)=>e.jsx(e.Fragment,{children:e.jsx(V,{title:`Plugin v.${L.version}`,children:e.jsx("span",{children:L.version.split("-dev-")[0]+(L.version.includes("-dev-")?"@dev":"")})})})},{label:"Author",id:"author",render:(W,Z,L,S)=>e.jsx(e.Fragment,{children:L.author?L.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(W,Z,L,S)=>e.jsx(e.Fragment,{children:L.type?L.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(W,Z,L,S)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[k&&k.bridgeMode==="childbridge"&&!L.error&&L.enabled&&e.jsx(V,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:ar(L.matter)},onClick:()=>{L.matter?.id&&d(L.matter?.id)},size:"small",children:e.jsx(Xt,{})})}),k&&k.bridgeMode==="childbridge"&&!L.error&&L.enabled&&e.jsx(V,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>q(L),size:"small",children:e.jsx(jt,{})})}),e.jsx(V,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{disabled:L.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>be(L),size:"small",children:e.jsx(Rr,{})})}),k&&!k.readOnly&&e.jsx(V,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{c("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",L)},size:"small",children:e.jsx(Hr,{})})}),L.enabled?e.jsx(V,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{c("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",L)},size:"small",children:e.jsx(Or,{})})}):e.jsx(e.Fragment,{}),L.enabled?e.jsx(e.Fragment,{}):e.jsx(V,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>N(L),size:"small",children:e.jsx(Vr,{})})}),e.jsx(V,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>u(L),size:"small",children:e.jsx(er,{})})}),e.jsx(V,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>b(L),size:"small",children:e.jsx(Wt,{})})}),L.latestVersion!==void 0&&L.latestVersion!==L.version&&k&&!k.readOnly&&e.jsx(V,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>H(L),size:"small",children:e.jsx(Ie,{})})}),L.version.includes("-dev-")&&L.devVersion!==void 0&&L.devVersion!==L.version&&k&&!k.readOnly&&e.jsx(V,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>D(L),size:"small",children:e.jsx(Ie,{})})}),k&&!k.readOnly&&e.jsx(V,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>s(L),size:"small",children:e.jsx(tr,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(W,Z,L,S)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:L.error?e.jsx(e.Fragment,{children:e.jsx(Ue,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:L.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ue,{status:L.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:L.loaded&&L.started&&L.configured?e.jsx(e.Fragment,{children:e.jsx(Ue,{status:L.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ue,{status:L.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ue,{status:L.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ue,{status:L.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const W=Z=>{o&&console.log("HomePlugins received WebSocket Message:",Z),Z.method==="refresh_required"&&Z.response.changed==="plugins"?(o&&console.log(`HomePlugins received refresh_required: changed=${Z.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):Z.method==="refresh_required"&&Z.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${Z.response.changed} and setting matter id ${Z.response.matter?.id}`),T(L=>{const S=L.findIndex(M=>M.matter?.id===Z.response.matter?.id);if(S<0)return o&&console.log(`HomePlugins received refresh_required: changed=${Z.response.changed} and matter id ${Z.response.matter?.id} not found`),L;o&&console.log(`HomePlugins received refresh_required: changed=${Z.response.changed} set matter id ${Z.response.matter?.id}`);const w=[...L];return w[S]={...w[S],matter:Z.response.matter},w})):Z.method==="refresh_required"&&Z.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${Z.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),Z.id===t.current&&Z.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${Z.id}) received settings:`,Z.response),v(Z.response.systemInformation),O(Z.response.matterbridgeInformation)):Z.id===t.current&&Z.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${Z.id}) received ${Z.response.length} plugins:`,Z.response),T(Z.response))};return a(W,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{x(W),o&&console.log("HomePlugins removed WebSocket listener")}},[a,x,i]),r.useEffect(()=>{l&&(o&&console.log("HomePlugins sending api requests"),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const $=r.useRef(null),c=(W,Z,L,S)=>{o&&console.log(`handleActionWithConfirmCancel ${L} ${S.name}`),$.current=S,j(W,Z,L,f,h)},f=W=>{o&&console.log(`handleConfirm action confirmed ${W} ${$.current?.name}`),W==="remove"&&$.current?C($.current):W==="disable"&&$.current&&N($.current),$.current=null},h=W=>{o&&console.log(`handleCancel action canceled ${W} ${$.current?.name}`),$.current=null},H=W=>{o&&console.log("handleUpdatePlugin plugin:",W.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:W.name,restart:!1}})},D=W=>{o&&console.log("handleUpdateDevPlugin plugin:",W.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:W.name+"@dev",restart:!1}})},C=W=>{o&&console.log("handleRemovePlugin plugin:",W.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}})},q=W=>{o&&console.log("handleRestartPlugin plugin:",W.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}})},N=W=>{o&&console.log("handleEnableDisablePlugin plugin:",W.name,"enabled:",W.enabled),W.enabled===!0?(W.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}})):(W.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}}))},g=W=>{o&&console.log(`handleHomepagePlugin plugin: ${W.name} homepage: ${W.homepage}`),W.homepage&&window.open(W.homepage,"_blank")},s=W=>{o&&console.log("handleSponsorPlugin plugin:",W.name,"funding:",W.funding),W.funding&&window.open(W.funding,"_blank")},u=W=>{o&&console.log("handleHelpPlugin plugin:",W.name,"help:",W.help),W.help&&window.open(W.help,"_blank")},b=W=>{o&&console.log("handleChangelogPlugin plugin:",W.name,"changelog:",W.changelog),W.changelog&&window.open(W.changelog,"_blank")},[R,ce]=r.useState(),[xe,ne]=r.useState(!1),be=W=>{o&&console.log("handleConfigPlugin plugin:",W.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:W.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:W.name}}),ce(W),F()},F=()=>{ne(!0)},z=()=>{ne(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[R&&e.jsx(bn,{open:xe,onClose:z,plugin:R}),e.jsx(St,{name:"Plugins",columns:U,rows:E,footerRight:"",footerLeft:""})]}):e.jsx(De,{})}const yn=r.memo(vn),jn=n=>`${n.pluginName}::${n.serial}`;function wn({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:a,removeListener:x,getUniqueId:p}=r.useContext(fe),[j,t]=r.useState(!1),[I,v]=r.useState(!0),[k,O]=r.useState(null),[E,T]=r.useState([]),[U,$]=r.useState([]),[c,f]=r.useState([]),[h,H]=r.useState([]),D=r.useRef(p()),C=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(g,s,u,b)=>u.reachable===!0?"Online":u.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(g,s)=>{const u=g.reachable===!0?1:g.reachable===!1?0:-1,b=s.reachable===!0?1:s.reachable===!1?0:-1;return u-b}},{label:"Power",id:"powerSource",render:(g,s,u,b)=>u.powerSource==="ac"||u.powerSource==="dc"?e.jsx(rr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):u.powerSource==="ok"?e.jsx(wt,{fontSize:"small",sx:{color:"green"}}):u.powerSource==="warning"?e.jsx(wt,{fontSize:"small",sx:{color:"yellow"}}):u.powerSource==="critical"?e.jsx(wt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl"},{label:"Actions",id:"selected",required:!0,render:(g,s,u,b)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[u.matter!==void 0?e.jsx(V,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>d(n===u.matter?.id?k?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:u.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:ar(u.matter)},children:e.jsx(Xt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),u.configUrl?e.jsx(V,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Q,{onClick:()=>window.open(u.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(or,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),u.selected!==void 0?e.jsx(V,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Ee,{checked:u.selected,onChange:R=>N(R,u),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],q=r.useCallback(g=>{g.selected=void 0;const s=E.find(R=>R.name===g.pluginName);if(!s)return console.error(`HomeDevices isSelected: plugin ${g.pluginName} not found for device ${g.name} `),g.selected;const u=s.schemaJson?.properties?.whiteList?.selectFrom;let b=s.configJson.postfix;return b===""&&(b=void 0),s.hasWhiteList===!0&&s.hasBlackList===!0&&u&&(g.selected=!0,u==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(b?g.serial.replace("-"+b,""):g.serial)&&(g.selected=!0),u==="serial"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(b?g.serial.replace("-"+b,""):g.serial)&&(g.selected=!1),u==="serial"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(b?g.serial.replace("-"+b,""):g.serial)&&(g.selected=!1),u==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&s.configJson.whiteList.includes(g.name)&&(g.selected=!0),u==="name"&&s.configJson.whiteList&&s.configJson.whiteList.length>0&&!s.configJson.whiteList.includes(g.name)&&(g.selected=!1),u==="name"&&s.configJson.blackList&&s.configJson.blackList.length>0&&s.configJson.blackList.includes(g.name)&&(g.selected=!1)),g.selected},[E]);r.useEffect(()=>{const g=s=>{if(o&&console.log("HomeDevices received WebSocket Message:",s),s.method==="refresh_required"&&s.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and sending /api/plugins request`),i({id:D.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):s.method==="refresh_required"&&s.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and setting matter id ${s.response.matter?.id}`),H(u=>{const b=u.findIndex(ce=>ce.name.replaceAll(" ","")===s.response.matter?.id);if(b<0)return o&&console.debug(`HomeDevices: matter id ${s.response.matter?.id} not found`),u;const R=[...u];return R[b]={...R[b],matter:s.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${s.response.changed} and set matter id ${s.response.matter?.id}`),R})):s.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):s.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):s.method==="state_update"&&s.response.plugin&&s.response.serialNumber&&s.response.cluster.includes("BasicInformation")&&s.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${s.response.plugin} serial ${s.response.serialNumber} value ${s.response.value}`),$(u=>{const b=u.findIndex(R=>R.pluginName===s.response.plugin&&R.serial===s.response.serialNumber);return b<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${s.response.plugin} serial ${s.response.serialNumber}`),u):(u[b]={...u[b],reachable:s.response.value},[...u])})),s.id===D.current&&s.method==="/api/settings")o&&console.log(`HomeDevices (id: ${s.id}) received settings:`,s.response),O(s.response),t(s.response.matterbridgeInformation.restartRequired||s.response.matterbridgeInformation.fixedRestartRequired);else if(s.id===D.current&&s.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} plugins:`,s.response),s.response){let u=!0;for(const b of s.response)b.enabled===!0&&(b.loaded!==!0||b.started!==!0||b.error===!0)&&(u=!1);if(!u)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),v(!1),T(s.response),$([]),f([]),i({id:D.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const b of s.response)b.enabled===!0&&b.loaded===!0&&b.started===!0&&b.error!==!0&&(i({id:D.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:b.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${b.name}`))}}else if(s.id===D.current&&s.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} devices:`,s.response),s.response){for(const u of s.response)u.selected=q(u);$(s.response)}}else s.id===D.current&&s.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${s.id}) received ${s.response?.length} selectDevices for plugin ${s.response&&s.response.length>0?s.response[0].pluginName:"without select devices"}:`,s.response),s.response&&s.response.length>0&&f(u=>{const b=u.filter(ce=>ce.pluginName!==s.response[0].pluginName),R=s.response.map(ce=>({...ce,selected:q(ce)}));return[...b,...R]}))};return a(g,D.current),o&&console.log(`HomeDevices added WebSocket listener id ${D.current}`),()=>{x(g),o&&console.log("HomeDevices removed WebSocket listener")}},[E,a,x,i,q]),r.useEffect(()=>{if(U.length===0&&c.length===0){H([]);return}o&&console.log(`HomeDevices mixing devices (${U.length}) and selectDevices (${c.length})`);const g=[];for(const s of U)g.push(s);for(const s of c)U.find(u=>u.pluginName===s.pluginName&&u.serial.includes(s.serial))||g.push(s);g.length>0&&(H(g),o&&console.log(`HomeDevices mixed ${g.length} devices and selectDevices`))},[E,U,c,H]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:D.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:D.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const N=(g,s)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${g.target.checked} for device ${s.name} serial ${s.serial}`),U.findIndex(u=>u.pluginName===s.pluginName&&u.serial===s.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices, trying in mixedDevices`),H(u=>{const b=u.findIndex(R=>R.pluginName===s.pluginName&&R.serial===s.serial);return b<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in mixedDevices`),u):(u[b]={...u[b],selected:g.target.checked},[...u])})):$(u=>{const b=u.findIndex(R=>R.pluginName===s.pluginName&&R.serial===s.serial);return b<0?(console.error(`handleCheckboxChange: device ${s.name} serial ${s.serial} not found in devices`),u):(u[b]={...u[b],selected:g.target.checked},[...u])}),g.target.checked?i({id:D.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}}):i({id:D.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:s.pluginName,serial:s.serial,name:s.name}})};return o&&console.log("HomeDevices rendering..."),l?e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(St,{name:"Devices",getRowKey:jn,rows:h,columns:C,footerLeft:I?"Waiting for the plugins to fully load...":`Registered devices: ${U.length.toString()}/${h.length.toString()}`,footerRight:j?"Restart required":""})}):e.jsx(De,{})}const Cn=r.memo(wn);function Mt({children:n,style:d,name:l}){const{setCurrentPage:i}=r.useContext(_e);i(l),o&&console.log(`MbfPage: current page set to ${l}`);const a={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...a,...d},children:n})}const Sn=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(o&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(o&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function Mn(){const{messages:n,autoScroll:d}=r.useContext(sr),[l,i]=r.useState(!1),a=r.useRef(null),x=r.useMemo(()=>Sn(),[]),p=v=>i(!0),j=v=>i(!1);r.useEffect(()=>{o&&console.log(`WebSocketLogs autoScroll: ${d} isHovering: ${l}`),d&&!l&&!x&&a.current?.scrollIntoView({behavior:"smooth"})},[n,l,d,x]);const t=v=>{switch(v.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"#5c0e91"}},I=v=>{switch(v.toLowerCase()){case"warn":return"black";default:return"white"}};return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:p,onMouseLeave:j,children:[n.map((v,k)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:t(v.level),color:I(v.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:v.level}),v.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+v.time+"]"}),v.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+v.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:v.message})]},k)),e.jsx("div",{ref:a})]})})}const lr=r.memo(Mn);function kn(){const{logFilterLevel:n,logFilterSearch:d,autoScroll:l,online:i}=r.useContext(fe);return o&&console.log("HomeLogs rendering..."),i?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 "',n,'" and search "',d,'" Scroll: ',l?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(lr,{})})]}):e.jsx(De,{})}const In=r.memo(kn);function Dn(){const{online:n}=r.useContext(fe);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(ke,{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(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Er,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(De,{})}const Pn=r.memo(Dn);function $n({changelog:n}){const{online:d}=r.useContext(fe);return o&&console.log("HomeShowChangelog rendering..."),d?e.jsxs(ke,{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(ie,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Wt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(_r,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(De,{})}const Nn=r.memo($n);function Ln(){const[n,d]=r.useState(null),[l,i]=r.useState(null),[a,x]=r.useState([]),[p]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[j,t]=r.useState(localStorage.getItem("homePageMode")??"devices"),[I,v]=r.useState(""),[k,O]=r.useState(!1),[E,T]=r.useState(!1),[U,$]=r.useState(null),{addListener:c,removeListener:f,online:h,sendMessage:H,getUniqueId:D}=r.useContext(fe),C=r.useRef(D());return r.useEffect(()=>{const q=N=>{o&&console.log("Home received WebSocket Message:",N),N.method==="refresh_required"&&N.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${N.response.changed} and sending /api/settings request`),$(null),x([]),H({id:C.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),H({id:C.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),N.method==="/api/settings"&&N.id===C.current&&(o&&console.log("Home received settings:",N.response),d(N.response.systemInformation),i(N.response.matterbridgeInformation),N.response.matterbridgeInformation.matterbridgeVersion&&v(`https://github.com/Luligu/matterbridge/blob/${N.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&N.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",N.response.matterbridgeInformation.frontendVersion):N.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&N.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",N.response.matterbridgeInformation.frontendVersion),T(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",N.response.matterbridgeInformation.matterbridgeVersion):N.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",N.response.matterbridgeInformation.matterbridgeVersion),O(!0)),N.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),t("devices")))),N.method==="/api/plugins"&&N.id===C.current&&(o&&console.log("Home received plugins:",N.response),x(N.response))};return c(q,C.current),o&&console.log(`Home added WebSocket listener id ${C.current}`),()=>{f(q),o&&console.log("Home removed WebSocket listener")}},[c,f,H]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${U}`),l?.bridgeMode==="bridge"&&!U&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),$("Matterbridge")),l?.bridgeMode==="childbridge"&&!U&&a){for(const q of a)if(q.matter?.id){o&&console.log(`Home storeId effect set storeId to ${q.matter.id}`),$(q.matter.id);break}}},[l,a,U]),r.useEffect(()=>{h&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),H({id:C.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),H({id:C.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[h,H]),o&&console.log("Home rendering..."),!h||!n||!l?e.jsx(De,{}):e.jsxs(Mt,{name:"Home",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(dn,{id:U}),e.jsx(sn,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[E&&e.jsx(Pn,{}),k&&e.jsx(Nn,{changelog:I}),p&&!l.readOnly&&e.jsx(pn,{}),p&&e.jsx(yn,{storeId:U,setStoreId:$}),j==="devices"&&e.jsx(Cn,{storeId:U,setStoreId:$}),j==="logs"&&e.jsx(In,{})]})]})}const Wn=r.memo(Ln),vt=!1,Zt={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},Tn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},Fn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Yt={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Rn={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)"},On={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},Vn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},En={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)"},_n=[256,257,268,269],An=[266,267],zn=[259,260,261,271,272],qn=[256,257,268,269,266,267,259,260,261,272];function J({icon:n,iconColor:d,cluster:l,value:i,unit:a,prefix:x}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${a}"`),x=x??!1,e.jsxs(X,{sx:Zt,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...Tn,color:d??"var(--primary-color)"}}),e.jsxs(X,{sx:{...Zt,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[a&&x===!0&&e.jsx(se,{sx:Yt,children:a},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(se,{sx:Fn,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${l.clusterId}-${l.attributeId}-value`),a&&x===!1&&e.jsx(se,{sx:Yt,children:a},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function Un({device:n,endpoint:d,id:l,deviceType:i,clusters:a}){const x=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let p="";o&&console.log(`Device "${n.name}" endpoint "${d}" id "${l}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${a?.length})`);const j=a.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(j){let t="";j.map(I=>{I.label&&(t+=I.label+" ")}),p=t.trim()}if(i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>p=`${t.attributeLocalValue} mV`),qn.includes(i)&&a.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>p=`Level ${t.attributeValue}`),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>p=`Position ${t.attributeLocalValue/100}%`),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>p=`Heat ${t.attributeLocalValue/100}°C `),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>p=p+`Cool ${t.attributeLocalValue/100}°C`),i===118&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>p=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>p=`${t.attributeLocalValue/1e3} V, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>p=p+`${t.attributeLocalValue/1e3} A, `),i===1296&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>p=p+`${t.attributeLocalValue/1e3} W`),i===39){const t=a.find(v=>v.clusterName==="ModeSelect"&&v.attributeName==="currentMode")?.attributeLocalValue;p=a.find(v=>v.clusterName==="ModeSelect"&&v.attributeName==="supportedModes")?.attributeLocalValue?.find(v=>v.mode===t)?.label||"Unknown"}if(i===116){const t=a.find(v=>v.clusterName==="RvcRunMode"&&v.attributeName==="currentMode")?.attributeLocalValue;p=a.find(v=>v.clusterName==="RvcRunMode"&&v.attributeName==="supportedModes")?.attributeLocalValue?.find(v=>v.mode===t)?.label||"Unknown"}return e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:t.attributeLocalValue===!0?e.jsx(nt,{}):e.jsx(Ar,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(J,{icon:e.jsx(wt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(J,{icon:e.jsx(rr,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&a.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),_n.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(zr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),An.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),zn.includes(i)&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Io,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Do,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:$o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:e.jsx(At,{}),cluster:t,value:"Oven"})),i===112&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:e.jsx(qr,{}),cluster:t,value:"Fridge"})),i===113&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:No,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&a.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(J,{icon:e.jsx(At,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&a.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&a.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Qt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&a.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(J,{icon:e.jsx(Ur,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&a.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(J,{icon:t.attributeValue==="1"?e.jsx(Br,{}):e.jsx(Qr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(J,{icon:e.jsx(Gr,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&a.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:To,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&a.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(J,{icon:e.jsx(Kr,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&a.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(J,{icon:e.jsx(Jr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&a.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(J,{icon:e.jsx(zt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&a.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(J,{icon:e.jsx(zt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(Zr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(Yr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:e.jsx(Xr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&a.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&a.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Ro,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&a.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Oo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&a.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&a.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Eo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Gt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&a.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&a.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Gt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&a.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(J,{icon:e.jsx(eo,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&a.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:_o,size:"40px",color:"var(--primary-color)"}),cluster:t,value:x[t.attributeLocalValue??0]})),i===770&&a.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(to,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&a.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(oe,{path:Ao,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&a.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(ro,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&a.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(oo,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&a.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(J,{icon:t.attributeValue==="true"?e.jsx(no,{}):e.jsx(io,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&a.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(J,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(so,{}):e.jsx(ao,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&a.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(J,{icon:e.jsx(lo,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&a.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(J,{icon:e.jsx(co,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(X,{sx:Rn,children:e.jsx(se,{sx:Hn,children:p})}),e.jsx(X,{sx:On,children:e.jsx(se,{sx:Vn,children:n.name})}),e.jsxs(X,{sx:En,children:[o&&e.jsx(se,{sx:Pt,children:d}),e.jsx(se,{sx:Pt,children:l}),o&&e.jsxs(se,{sx:Pt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Bn({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:x}=r.useContext(fe),[p,j]=r.useState([]),[t,I]=r.useState({}),[v,k]=r.useState({}),[O,E]=r.useState({}),T=r.useRef(x()),U=r.useCallback(f=>{(o||vt)&&console.log(`DevicesIcons received state_update "${f.response.cluster}.${f.response.attribute}" for "${f.response.id}:${f.response.number}": "${f.response.value}"`,f.response);const h=p.find(D=>D.pluginName===f.response.plugin&&D.serial===f.response.serialNumber);if(!h){(o||vt)&&console.warn(`DevicesIcons updater device of plugin "${f.response.plugin}" serial "${f.response.serialNumber}" number "${f.response.number}" id "${f.response.id}" not found in devices(${p.length})`);return}const H=O[h.serial]?.find(D=>D.endpoint===f.response.number.toString()&&D.clusterName===f.response.cluster&&D.attributeName===f.response.attribute);if(!H){(o||vt)&&console.warn(`DevicesIcons updater device "${h.name}" serial "${h.serial}" cluster "${f.response.cluster}" attribute "${f.response.attribute}" not found in clusters(${O[h.serial]?.length})`);return}H.attributeValue=String(f.response.value),H.attributeLocalValue=f.response.value,E({...O}),(o||vt)&&console.log(`DevicesIcons updated "${H.clusterName}.${H.attributeName}" for device "${h.name}" serial "${h.serial}" to "${H.attributeValue}"`)},[O,p]),$=r.useCallback(f=>{if(o&&console.log(`DevicesIcons received for device "${f.response.deviceName}" serial "${f.response.serialNumber}" deviceTypes (${f.response.deviceTypes.length}) "${f.response.deviceTypes.join(",")}" clusters (${f.response.clusters.length}):`,f.response),f.response.clusters.length===0)return;const h=f.response.serialNumber;t[h]=[],v[h]=f.response.deviceTypes,O[h]=[];for(const H of f.response.clusters)t[h].find(D=>D.endpoint===H.endpoint)||t[h].push({endpoint:H.endpoint,id:H.id,deviceTypes:H.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(H.clusterName)&&O[h].push(H);I({...t}),k({...v}),E({...O}),o&&console.log(`DevicesIcons endpoints for "${h}":`,t[h]),o&&console.log(`DevicesIcons deviceTypes for "${h}":`,v[h]),o&&console.log(`DevicesIcons clusters for "${h}":`,O[h])},[O,v,t]);r.useEffect(()=>{const f=h=>{if(o&&console.log("DevicesIcons received WebSocket Message:",h),h.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${h.response.changed} and sending api requests`),l({id:T.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(h.method==="state_update"&&h.response)U(h);else if(h.method==="/api/devices"&&h.response){o&&console.log(`DevicesIcons received ${h.response.length} devices:`,h.response),j(h.response),I({}),k({}),E({});for(const H of h.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:T.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:H.pluginName,endpoint:H.endpoint||0}})}else h.method==="/api/clusters"&&h.response&&$(h)};return i(f,T.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{a(f),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[p]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),d&&(o&&console.log("DevicesIcons useEffect online sending api requests"),l({id:T.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),o&&console.log("DevicesIcons useEffect online mounted"),()=>{o&&console.log("DevicesIcons useEffect online unmounted")}),[d,l]);const c=r.memo(Un);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:p.filter(f=>f.name.toLowerCase().includes(n)||f.serial.toLowerCase().includes(n)).map(f=>t[f.serial]&&t[f.serial].map(h=>h.deviceTypes.map(H=>e.jsx(c,{device:f,endpoint:h.endpoint,id:h.id,deviceType:H,clusters:O[f.serial].filter(D=>D.endpoint===h.endpoint)},`${f.pluginName}-${f.uniqueId}-${h.endpoint}-${h.id}-${H.toString()}`))))})}const Qn=r.memo(Bn),Gn=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(n,d,l,i)=>l.configUrl?e.jsx(Q,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(or,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Kn=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,d,l,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(a=>`0x${a.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,render:(n,d,l,i)=>e.jsx(V,{title:String(n),componentsProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("div",{style:{maxWidth:"500px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:String(n)})})}],Jn=n=>`${n.pluginName}::${n.uniqueId}`,Zn=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function Yn({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:a,getUniqueId:x}=r.useContext(fe),[p,j]=r.useState([]),[t,I]=r.useState(p),[v,k]=r.useState([]),[O,E]=r.useState(0),[T,U]=r.useState(null),[$,c]=r.useState(null),[f,h]=r.useState(null),[H,D]=r.useState(null),C=r.useRef(x()),q=r.useRef(t),N=r.useCallback(s=>{o&&console.log(`DevicesTable received state_update "${s.response.cluster}.${s.response.attribute}" for "${s.response.id}:${s.response.number}": "${s.response.value}"`,s.response);const u=q.current.find(b=>b.pluginName===s.response.plugin&&b.uniqueId===s.response.uniqueId);if(!u){o&&console.warn(`DevicesTable updater device of plugin "${s.response.plugin}" serial "${s.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(T&&$&&u.pluginName===T&&u.uniqueId===H&&s.response.number.toString()===$){const b=v.find(R=>R.endpoint===s.response.number.toString()&&R.clusterName===s.response.cluster&&R.attributeName===s.response.attribute);if(!b){o&&console.warn(`DevicesTable updater cluster ${s.response.cluster}.${s.response.attribute} for device "${u.name}" serial "${u.serial}" not found in clusters`);return}b.attributeValue=typeof s.response.value=="object"?JSON.stringify(s.response.value,void 0,1).replaceAll('"',""):String(s.response.value),b.attributeLocalValue=s.response.value,k([...v]),o&&console.log(`DevicesTable updated attribute ${b.clusterName}.${b.attributeName} for device "${u.name}" serial "${u.serial}" to "${b.attributeValue}"`)}},[v,$,T,H]);r.useEffect(()=>{const s=u=>{if(o&&console.log("DevicesTable received WebSocket Message:",u),u.method==="refresh_required"&&u.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${u.response.changed} and sending /api/devices request`),l({id:C.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(u.method==="state_update"&&u.response)N(u);else if(u.method==="/api/devices")o&&console.log(`DevicesTable received ${u.response.length} devices:`,u.response),j(u.response);else if(u.method==="/api/clusters"){o&&console.log(`DevicesTable received ${u.response.clusters.length} clusters for plugin ${u.response.plugin}:`,u.response),k(u.response.clusters);const b={};for(const R of u.response.clusters)o&&console.log("Cluster:",R.endpoint),b[R.endpoint]?b[R.endpoint]++:b[R.endpoint]=1;E(Object.keys(b).length)}};return i(s,C.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{a(s),o&&console.log("DevicesTable removed WebSocket listener")}},[l,i,a,N]),r.useEffect(()=>{d&&(o&&console.log("DevicesTable sending api requests with id ",C.current),l({id:C.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:C.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:C.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[d,l]),r.useEffect(()=>{T&&$&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:C.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:T,endpoint:Number($)}}))},[T,$,l]),r.useEffect(()=>{if(n===""){I(p),q.current=p;return}const s=p.filter(u=>u.name.toLowerCase().includes(n)||u.serial.toLowerCase().includes(n));I(s),q.current=s},[p,n]);const g=s=>{if(s.uniqueId===H){D(null),U(null),c(null),h(null);return}D(s.uniqueId),U(s.pluginName),c(s.endpoint?s.endpoint.toString():null),h(s.name)};return o&&console.log("DevicesTable rendering..."),d?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${T&&$?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(St,{name:"Registered devices",getRowKey:Jn,onRowClick:g,rows:t,columns:Gn,footerLeft:`Total devices: ${t.length.toString()}`})}),T&&$&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(St,{name:"Clusters",title:f||"",getRowKey:Zn,rows:v,columns:Kn,footerLeft:`Total child endpoints: ${O-1}`})})]}):e.jsx(De,{})}const Xn=r.memo(Yn);function ei(){const{online:n}=r.useContext(fe),[d,l]=r.useState(""),[i,a]=r.useState("icon");r.useEffect(()=>{const j=localStorage.getItem("devicesFilter");j&&l(j)},[]),r.useEffect(()=>{const j=localStorage.getItem("devicesViewMode");j&&a(j)},[]);const x=j=>{l(j.target.value.toLowerCase()),localStorage.setItem("devicesFilter",j.target.value.toLowerCase())},p=j=>{a(j),localStorage.setItem("devicesViewMode",j)};return o&&console.log("Devices rendering..."),n?e.jsxs(Mt,{name:"Devices",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(me,{variant:"outlined",value:d,onChange:x,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(se,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(Q,{onClick:()=>p("table"),"aria-label":"Table View",disabled:i==="table",children:e.jsx(V,{title:"Table View",children:e.jsx(po,{style:{color:i==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(Q,{onClick:()=>p("icon"),"aria-label":"Icon View",disabled:i==="icon",children:e.jsx(V,{title:"Icon View (beta)",children:e.jsx(uo,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(Xn,{filter:d}),i==="icon"&&e.jsx(Qn,{filter:d})]}):e.jsx(De,{})}const ti=r.memo(ei);function ri(){const[n,d]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[l,i]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[a,x]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:p,setLogFilters:j,online:t,setAutoScroll:I}=r.useContext(fe),v=T=>{d(T.target.value),j(T.target.value,l),localStorage.setItem("logFilterLevel",T.target.value),o&&console.log("handleChangeLevel called with value:",T.target.value)},k=T=>{i(T.target.value),j(n,T.target.value),localStorage.setItem("logFilterSearch",T.target.value),o&&console.log("handleChangeSearch called with value:",T.target.value)},O=T=>{x(T.target.checked),I(T.target.checked),localStorage.setItem("logAutoScroll",T.target.value?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",T.target.checked)},E=()=>{o&&console.log("handleClearLogsClick called"),p([])};return o&&console.log("Logs rendering..."),t?e.jsxs(Mt,{name:"Logs",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(qt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Ze,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:n,onChange:v,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(qt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(me,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:l,onChange:k,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Ve,{control:e.jsx(Ee,{checked:a,onChange:O}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(V,{title:"Clear the logs",children:e.jsx(ie,{onClick:E,endIcon:e.jsx(Lt,{}),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(lr,{})})]}):e.jsx(De,{})}const oi=r.memo(ri),ni=({open:n,ip:d,onClose:l,onSave:i})=>{const a=d?d.split(".").slice(0,3).join(".")+".1":"",[x,p]=r.useState("dhcp"),[j,t]=r.useState({ip:d??"",subnet:"255.255.255.0",gateway:a,dns:a}),I=O=>E=>{t({...j,[O]:E.target.value})},v=()=>{l()},k=()=>{i({type:x,...j}),l()};return e.jsxs(Ne,{open:n,onClose:(O,E)=>{E==="backdropClick"||E==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Le,{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(We,{dividers:!0,children:[e.jsxs(nr,{component:"fieldset",fullWidth:!0,children:[e.jsx(je,{component:"legend",children:"Select IP Configuration"}),e.jsxs(ir,{row:!0,value:x,onChange:O=>p(O.target.value),children:[e.jsx(Ve,{value:"dhcp",control:e.jsx(Ct,{}),label:"DHCP"}),e.jsx(Ve,{value:"static",control:e.jsx(Ct,{}),label:"Static"})]})]}),x==="static"&&e.jsxs(He,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(He,{size:6,children:e.jsx(me,{label:"IP Address",fullWidth:!0,value:j.ip,onChange:I("ip")})}),e.jsx(He,{size:6,children:e.jsx(me,{label:"Subnet Mask",fullWidth:!0,value:j.subnet,onChange:I("subnet")})}),e.jsx(He,{size:6,children:e.jsx(me,{label:"Gateway",fullWidth:!0,value:j.gateway,onChange:I("gateway")})}),e.jsx(He,{size:6,children:e.jsx(me,{label:"DNS Server",fullWidth:!0,value:j.dns,onChange:I("dns")})})]})]}),e.jsxs(Oe,{children:[e.jsx(ie,{onClick:v,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:k,children:"Save"})]})]})},ii=({open:n,onClose:d,onSave:l})=>{const[i,a]=r.useState(""),[x,p]=r.useState(""),j=E=>{a(E.target.value)},t=E=>{p(E.target.value)},I=i.length>0&&i===x,v=()=>{d()},k=()=>{I&&(l(i),d())},O=()=>{l(""),d()};return e.jsxs(Ne,{open:n,onClose:(E,T)=>{T==="backdropClick"||T==="escapeKeyDown"||d()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Le,{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(We,{dividers:!0,children:e.jsx(nr,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(He,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(He,{size:12,children:e.jsx(me,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:j})}),e.jsx(He,{size:12,children:e.jsx(me,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:x,onChange:t,error:x!==""&&i!==x,helperText:x!==""&&i!==x?"Passwords do not match":""})})]})})}),e.jsxs(Oe,{children:[e.jsx(ie,{onClick:v,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:k,disabled:!I,children:"Change"}),e.jsx(ie,{variant:"contained",onClick:O,children:"Reset"})]})]})};function Ke(n=1e3){let d=null;const l=(i=>{d!==null&&window.clearTimeout(d),d=window.setTimeout(()=>{i(),d=null},n)});return l.cancel=()=>{d!==null&&(window.clearTimeout(d),d=null)},l}const ue=500;function si(){const{online:n,addListener:d,removeListener:l,sendMessage:i,getUniqueId:a}=r.useContext(fe),[x,p]=r.useState(null),[j,t]=r.useState(null),I=r.useRef(a());return r.useEffect(()=>{const v=k=>{o&&console.log("Settings received WebSocket Message:",k),k.method==="refresh_required"&&k.response.changed==="settings"?(o&&console.log(`Settings received refresh_required: changed=${k.response.changed} and sending /api/settings request`),i({id:I.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):k.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",k.response),p(k.response.matterbridgeInformation),t(k.response.systemInformation))};return d(v,I.current),o&&console.log("Settings added WebSocket listener"),()=>{l(v),o&&console.log("Settings removed WebSocket listener")}},[d,l,i]),r.useEffect(()=>{n&&(o&&console.log("Settings received online"),i({id:I.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[n,i]),o&&console.log("Settings rendering..."),!n||!x||!j?e.jsx(De,{}):e.jsx(Mt,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(ai,{matterbridgeInfo:x,systemInfo:j}),e.jsx(li,{matterbridgeInfo:x}),e.jsx(di,{matterbridgeInfo:x}),e.jsx(ci,{systemInfo:j})]})})}function ai({matterbridgeInfo:n,systemInfo:d}){const{sendMessage:l,getUniqueId:i}=r.useContext(fe),[a,x]=r.useState("bridge"),[p,j]=r.useState("Info"),[t,I]=r.useState(!1),[v,k]=r.useState("dark"),[O,E]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[T,U]=r.useState(localStorage.getItem("homePageMode")??"devices"),[$,c]=r.useState(localStorage.getItem("virtualMode")??"outlet"),f=r.useRef(i()),[h,H]=r.useState(!1),D=()=>H(!1),C=F=>{o&&console.log("handleSaveNetConfig called with config:",F),l({id:f.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:F})},[q,N]=r.useState(!1),g=()=>N(!1),s=F=>{o&&console.log("handleSaveChangePassword called with password:",F),l({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:F}}),wi(F)};r.useEffect(()=>{n&&(x(n.bridgeMode==="bridge"?"bridge":"childbridge"),j(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),I(n.fileLogger),c(n.virtualMode))},[n]),r.useEffect(()=>{const F=localStorage.getItem("frontendTheme");F&&k(F)},[]);const u=F=>{o&&console.log("handleChangeBridgeMode called with value:",F.target.value),x(F.target.value),l({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:F.target.value}})},b=F=>{o&&console.log("handleChangeMbLoggerLevel called with value:",F.target.value),j(F.target.value),l({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:F.target.value}})},R=F=>{o&&console.log("handleLogOnFileMbChange called with value:",F.target.checked),I(F.target.checked),l({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:F.target.checked}})},ce=F=>{const z=F.target.value;o&&console.log("handleChangeTheme called with value:",z),k(z),localStorage.setItem("frontendTheme",z),document.body.setAttribute("frontend-theme",z)},xe=F=>{const z=F.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",z),E(z),localStorage.setItem("homePagePlugins",z?"true":"false")},ne=F=>{const z=F.target.value;o&&console.log("handleChangeHomePageMode called with value:",z),U(z),localStorage.setItem("homePageMode",z)},be=F=>{const z=F.target.value;o&&console.log("handleChangeVirtualMode called with value:",z),c(z),localStorage.setItem("virtualMode",z),l({id:f.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:z}})};return!n||!d?null:e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(ni,{open:h,ip:d.ipv4Address,onClose:D,onSave:C}),e.jsx(ii,{open:q,onClose:g,onSave:s}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:`${ue-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(ir,{row:!0,name:"mode-buttons-group",value:a,onChange:u,children:[e.jsx(Ve,{value:"bridge",control:e.jsx(Ct,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(Ve,{value:"childbridge",control:e.jsx(Ct,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Ze,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:p,onChange:b,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(Ve,{style:{padding:"0px",margin:"0px"},control:e.jsx(Ee,{checked:t,onChange:R,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Ze,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:v,onChange:ce,children:[e.jsx(P,{value:"classic",children:"Classic"}),e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Ee,{checked:O,onChange:xe,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Ze,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:T,onChange:ne,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(je,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Ze,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:$,onChange:be,children:[e.jsx(P,{value:"disabled",children:"Disabled"}),e.jsx(P,{value:"outlet",children:"Outlet"}),e.jsx(P,{value:"light",children:"Light"}),e.jsx(P,{value:"switch",children:"Switch"}),e.jsx(P,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>N(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>H(!0),children:"Configure IP"})})]})})]})}function li({matterbridgeInfo:n}){const{sendMessage:d,getUniqueId:l}=r.useContext(fe),[i,a]=r.useState("Info"),[x,p]=r.useState(!1),[j,t]=r.useState(""),[I,v]=r.useState(""),[k,O]=r.useState(""),[E,T]=r.useState(""),[U,$]=r.useState(""),[c,f]=r.useState(""),h=r.useRef(l()),H=r.useMemo(()=>Ke(1e3),[]),D=r.useMemo(()=>Ke(1e3),[]),C=r.useMemo(()=>Ke(1e3),[]),q=r.useMemo(()=>Ke(1e3),[]),N=r.useMemo(()=>Ke(1e3),[]),g=r.useMemo(()=>Ke(1e3),[]);r.useEffect(()=>{n&&(a(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),p(n.matterFileLogger),t(n.matterMdnsInterface||""),v(n.matterIpv4Address||""),O(n.matterIpv6Address||""),T(n.matterPort?n.matterPort.toString():""),$(n.matterDiscriminator?n.matterDiscriminator.toString():""),f(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>H.cancel(),[H]),r.useEffect(()=>()=>D.cancel(),[D]),r.useEffect(()=>()=>C.cancel(),[C]),r.useEffect(()=>()=>q.cancel(),[q]),r.useEffect(()=>()=>N.cancel(),[N]),r.useEffect(()=>()=>g.cancel(),[g]);const s=F=>{o&&console.log("handleChangeMjLoggerLevel called with value:",F.target.value),a(F.target.value),d({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:F.target.value}})},u=F=>{o&&console.log("handleLogOnFileMjChange called with value:",F.target.checked),p(F.target.checked),d({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:F.target.checked}})},b=F=>{o&&console.log("handleChangeMdnsInterface called with value:",F.target.value);const z=F.target.value;t(z),H(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",z),d({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:z}})})},R=F=>{o&&console.log("handleChangeIpv4Address called with value:",F.target.value);const z=F.target.value;v(z),D(()=>{o&&console.log("debounced sendMessage setipv4address with value:",z),d({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:z}})})},ce=F=>{o&&console.log("handleChangeIpv6Address called with value:",F.target.value);const z=F.target.value;O(z),C(()=>{o&&console.log("debounced sendMessage setipv6address with value:",z),d({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:z}})})},xe=F=>{o&&console.log("handleChangeMatterPort called with value:",F.target.value);const z=F.target.value;T(z),q(()=>{o&&console.log("debounced sendMessage setmatterport with value:",z),d({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:z}})})},ne=F=>{o&&console.log("handleChangeMatterDiscriminator called with value:",F.target.value);const z=F.target.value;$(z),N(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",z),d({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:z}})})},be=F=>{o&&console.log("handleChangemMatterPasscode called with value:",F.target.value);const z=F.target.value;f(z),g(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",z),d({id:h.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:z}})})};return n?e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"20px",margin:"0px",padding:"10px",width:`${ue-20}px`,backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(Ze,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:i,onChange:s,children:[e.jsx(P,{value:"Debug",children:"Debug"}),e.jsx(P,{value:"Info",children:"Info"}),e.jsx(P,{value:"Notice",children:"Notice"}),e.jsx(P,{value:"Warn",children:"Warn"}),e.jsx(P,{value:"Error",children:"Error"}),e.jsx(P,{value:"Fatal",children:"Fatal"})]}),e.jsx(Ve,{style:{padding:"0px",margin:"0px"},control:e.jsx(Ee,{checked:x,onChange:u,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(me,{value:j,onChange:b,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(me,{value:I,onChange:R,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(me,{value:k,onChange:ce,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(me,{value:E,onChange:xe,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(me,{value:U,onChange:ne,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"10px",gap:"15px"},children:[e.jsx(je,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(me,{value:c,onChange:be,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function di({matterbridgeInfo:n}){return n?e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(we,{value:n.matterbridgeVersion,label:"Current Version",width:ue}),e.jsx(we,{value:n.matterbridgeLatestVersion,label:"Latest Version",width:ue}),e.jsx(we,{value:n.rootDirectory,label:"Root Directory",width:ue}),e.jsx(we,{value:n.homeDirectory,label:"Home Directory",width:ue}),e.jsx(we,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory",width:ue}),e.jsx(we,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory",width:ue}),e.jsx(we,{value:n.globalModulesDirectory,label:"Global Module Directory",width:ue})]})})]}):null}function ci({systemInfo:n}){return n?e.jsxs(ke,{style:{width:`${ue}px`,maxWidth:`${ue}px`},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"System info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsx(we,{value:n.interfaceName,label:"Interface name",width:ue}),e.jsx(we,{value:n.macAddress,label:"MAC Address",width:ue}),e.jsx(we,{value:n.ipv4Address,label:"IPv4 Address",width:ue}),e.jsx(we,{value:n.ipv6Address,label:"IPv6 Address",width:ue}),e.jsx(we,{value:n.nodeVersion,label:"Node Version",width:ue}),e.jsx(we,{value:n.hostname,label:"Hostname",width:ue}),e.jsx(we,{value:n.user,label:"User",width:ue})]})})]}):null}function we({value:n,label:d,width:l}){return e.jsx(me,{focused:!0,value:n,size:"small",label:d,variant:"standard",sx:{width:l?`${l-20}px`:"400px","& .MuiInput-underline:before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},inputLabel:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}}})}const pi=r.memo(si);function ui(){const{online:n,sendMessage:d,addListener:l,removeListener:i,getUniqueId:a}=r.useContext(fe),{showSnackbarMessage:x}=r.useContext(_e),[p,j]=r.useState(null),[t,I]=r.useState([]),[v,k]=r.useState([]),[O,E]=r.useState(null),[T,U]=r.useState({cpuUsage:0}),[$,c]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[f,h]=r.useState({systemUptime:"",processUptime:""}),H=r.useRef(a());return o&&console.log("Test uniqueId:",H),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const D=C=>{if(C.method==="restart_required")o&&console.log("Test received restart_required"),x("Restart required",0);else if(C.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${C.response.changed} and sending api requests`),x("Refresh required",0),d({id:H.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:H.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:H.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(C.method==="memory_update")o&&console.log("Test received memory_update",C),c(C.response);else if(C.method==="cpu_update")o&&console.log("Test received cpu_update",C),U(C.response);else if(C.method==="uptime_update")o&&console.log("Test received uptime_update",C),h(C.response);else if(C.method==="/api/settings"&&C.response)o&&console.log("Test received /api/settings:",C.response),x("Test received /api/settings",0),j(C.response);else if(C.method==="/api/plugins"&&C.response)o&&console.log(`Test received ${C.response.length} plugins:`,C.response),x("Test received /api/plugins",0),I(C.response);else if(C.method==="/api/devices"&&C.response){o&&console.log(`Test received ${C.response.length} devices:`,C.response),x("Test received /api/devices",0),k(C.response);for(const q of C.response)o&&console.log("Test sending /api/clusters for device:",q.pluginName,q.name,q.endpoint),d({id:H.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:q.pluginName,endpoint:q.endpoint||0}})}else C.method==="/api/clusters"&&C.response&&(o&&console.log(`Test received ${C.response.clusters.length} clusters for device ${C.response.deviceName} endpoint ${C.response.id}:${C.response.number}:`,C),x(`Test received /api/clusters for ${C.response.plugin}::${C.response.deviceName}`,0),E(C.response))};return l(D,H.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(D),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,i,d,x]),r.useEffect(()=>(o&&console.log("Test useEffect online mounting"),n&&o&&console.log("Test useEffect online received online"),o&&console.log("Test useEffect online mounted"),()=>{o&&console.log("Test useEffect online unmounted")}),[n,d,x]),o&&console.log("Test rendering..."),n?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(De,{})}const gi=r.memo(ui);function mi(n,d){o&&console.log("getCssVariable:",n,"defaultValue",d);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||d}function hi(n){return go({palette:{primary:{main:n},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}function fi(){const{mobile:n,showSnackbarMessage:d,showConfirmCancelDialog:l}=r.useContext(_e),{online:i,sendMessage:a,logMessage:x,addListener:p,removeListener:j,getUniqueId:t}=r.useContext(fe),[I,v]=r.useState(!1),[k,O]=r.useState(!1),[E,T]=r.useState(!1),[U,$]=r.useState(!1),[c,f]=r.useState(null),h=r.useRef(t()),[H,D]=r.useState(null),[C,q]=r.useState(null),[N,g]=r.useState(null),[s,u]=r.useState(null),[b,R]=r.useState(null),ce=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},xe=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},ne=()=>{c?.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")},be=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},F=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},z=()=>{a({id:h.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},W=()=>{a({id:h.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},Z=()=>{a({id:h.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},L=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),x("Matterbridge","Installing system updates..."),a({id:h.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},S=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),x("Matterbridge","Installing software updates..."),a({id:h.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},w=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),a({id:h.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),x("Matterbridge","Downloading Shelly system log..."),d("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},_=()=>{c?.matterbridgeInformation.restartMode===""?a({id:h.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):a({id:h.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},K=()=>{a({id:h.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},pe=()=>{a({id:h.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},le=()=>{a({id:h.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},de=()=>{a({id:h.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},ge=y=>{D(y.currentTarget)},A=y=>{o&&console.log("Header: handleMenuClose",y),D(null),y==="download-mblog"?(x("Matterbridge","Downloading matterbridge log..."),d("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):y==="download-mjlog"?(x("Matterbridge","Downloading matter log..."),d("Downloading matter log...",5),window.location.href="./api/download-mjlog"):y==="view-mblog"?(x("Matterbridge","Loading matterbridge log..."),d("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):y==="view-mjlog"?(x("Matterbridge","Loading matter log..."),d("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):y==="view-diagnostic"?(x("Matterbridge","Loading diagnostic log..."),d("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):y==="download-diagnostic"?(x("Matterbridge","Downloading diagnostic log..."),d("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):y==="view-history"?a({id:h.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):y==="download-history"?a({id:h.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):y==="view-shellylog"?(x("Matterbridge","Loading shelly system log..."),d("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):y==="download-mbstorage"?(x("Matterbridge","Downloading matterbridge storage..."),d("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):y==="download-pluginstorage"?(x("Matterbridge","Downloading matterbridge plugins storage..."),d("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):y==="download-pluginconfig"?(x("Matterbridge","Downloading matterbridge plugins config..."),d("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):y==="download-mjstorage"?(x("Matterbridge","Downloading matter storage..."),d("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):y==="download-backup"?(x("Matterbridge","Downloading backup..."),d("Downloading backup...",10),window.location.href="./api/download-backup"):y==="update"?z():y==="updatedev"?W():y==="updatecheck"?Z():y==="shelly-sys-update"?L():y==="shelly-main-update"?S():y==="shelly-create-system-log"?w():y==="shelly-download-system-log"?M():y==="softreset"?le():y==="hardreset"?de():y==="restart"?_():y==="shutdown"?K():y==="reboot"?pe():y==="create-backup"?a({id:h.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):y==="unregister"?a({id:h.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):y==="reset"?a({id:h.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):y==="factoryreset"&&a({id:h.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},G=y=>{o&&console.log("Header: handleMenuCloseCancel:",y),D(null)},m=y=>{q(y.currentTarget)},he=()=>{q(null)},ye=y=>{g(y.currentTarget)},ae=()=>{g(null)},te=y=>{u(y.currentTarget)},re=()=>{u(null)},Pe=y=>{R(y.currentTarget)},$e=()=>{R(null)},tt=()=>{yi(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const y=Y=>{o&&console.log("Header received WebSocket Message:",Y),Y.method==="/api/settings"&&Y.id===h.current?(o&&console.log("Header received settings:",Y.response),f(Y.response),v(Y.response.matterbridgeInformation.restartRequired||Y.response.matterbridgeInformation.fixedRestartRequired),O(Y.response.matterbridgeInformation.fixedRestartRequired),T(Y.response.matterbridgeInformation.updateRequired)):Y.method==="refresh_required"&&Y.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${Y.response.changed} and sending /api/settings request`),a({id:h.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):Y.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${Y.response.fixed}`),v(!0),Y.response.fixed===!0&&O(!0)):Y.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),v(!1)):Y.method==="update_required"?(o&&console.log("Header received update_required"),Y.response.devVersion===!0?$(!0):T(!0),a({id:h.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):Y.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),f(Ce=>Ce?{matterbridgeInformation:{...Ce.matterbridgeInformation,shellySysUpdate:Y.response.available},systemInformation:Ce.systemInformation}:null)):Y.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),f(Ce=>Ce?{matterbridgeInformation:{...Ce.matterbridgeInformation,shellyMainUpdate:Y.response.available},systemInformation:Ce.systemInformation}:null)):Y.method==="/api/viewhistorypage"&&Y.id===h.current&&Y.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):Y.method==="/api/downloadhistorypage"&&Y.id===h.current&&Y.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return p(y,h.current),o&&console.log(`Header added WebSocket listener id ${h.current}`),()=>{j(y),o&&console.log("Header removed WebSocket listener")}},[p,j,a,d]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),a({id:h.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:h.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,a]),o&&console.log("Header rendering... mobile %s",n),!i||!c?null:e.jsxs("div",{className:"header",style:{},children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:tt}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(at,{to:"/",className:"nav-link",children:"Home"}),e.jsx(at,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(at,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(at,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!c.matterbridgeInformation.readOnly&&e.jsx(V,{title:`Matterbridge v.${c.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",c.matterbridgeInformation.matterbridgeVersion.split("-dev-")[0]+(c.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")]})}),c.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),c.matterbridgeInformation.bridgeMode!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.bridgeMode})}):null,c.matterbridgeInformation.restartMode!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.restartMode})}):null,c.matterbridgeInformation.profile&&c.matterbridgeInformation.profile!==""&&c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:c.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:be})}):null,c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Give a star to Matterbridge",children:e.jsx(Q,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:F,children:e.jsx(mo,{})})}):null,c.matterbridgeInformation.readOnly===!1?e.jsx(V,{title:"Sponsor Matterbridge",children:e.jsx(Q,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:ce,children:e.jsx(tr,{})})}):null,e.jsx(V,{title:"Matterbridge help",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:xe,children:e.jsx(er,{})})}),e.jsx(V,{title:"Matterbridge changelog",children:e.jsx(Q,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ne,children:e.jsx(Wt,{})})}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&E&&e.jsx(V,{title:`Update matterbridge to latest version v.${c.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(Q,{style:{color:E?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:z,children:e.jsx(Ie,{})})}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&U&&e.jsx(V,{title:`Update matterbridge to latest dev version v.${c.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(Q,{style:{color:U?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:W,children:e.jsx(Ie,{})})}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellySysUpdate&&e.jsx(V,{title:"Shelly system update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:L,children:e.jsx(Ie,{})})}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellyMainUpdate&&e.jsx(V,{title:"Shelly software update",children:e.jsx(Q,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:S,children:e.jsx(Ie,{})})}),e.jsx(V,{title:"Restart matterbridge",children:e.jsx(Q,{style:{color:I||k?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:_,children:e.jsx(jt,{})})}),c.matterbridgeInformation.restartMode===""?e.jsx(V,{title:"Shut down matterbridge",children:e.jsx(Q,{style:{color:I||k?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:K,children:e.jsx(Ae,{})})}):null,e.jsx(V,{title:"Download, backup and more",children:e.jsx(Q,{onClick:ge,children:e.jsx(ho,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(Je,{id:"command-menu",anchorEl:H,keepMounted:!0,open:!!H,onClose:()=>A(""),children:[c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>A("update"),children:[e.jsx(B,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>A("updatedev"),children:[e.jsx(B,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&!c.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>A("updatecheck"),children:[e.jsx(B,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellySysUpdate&&e.jsxs(P,{onClick:()=>A("shelly-sys-update"),children:[e.jsx(B,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&c.matterbridgeInformation.shellyMainUpdate&&e.jsxs(P,{onClick:()=>A("shelly-main-update"),children:[e.jsx(B,{children:e.jsx(Ie,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>A("restart"),children:[e.jsx(B,{children:e.jsx(jt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation.restartMode===""?e.jsxs(P,{onClick:()=>A("shutdown"),children:[e.jsx(B,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",A,G)},children:[e.jsx(B,{children:e.jsx(jt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(ut,{}),e.jsxs(P,{onClick:ye,children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Je,{id:"sub-menu-view",anchorEl:N,keepMounted:!0,open:!!N,onClose:ae,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{A("view-mblog"),ae()},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{A("view-mjlog"),ae()},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{A("view-diagnostic"),ae()},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{A("view-history"),ae()},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{A("view-shellylog"),ae()},children:[e.jsx(B,{children:e.jsx(qe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(ut,{}),e.jsxs(P,{onClick:te,children:[e.jsx(B,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Je,{id:"sub-menu-download",anchorEl:s,keepMounted:!0,open:!!s,onClose:re,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{A("download-mbstorage"),re()},children:[e.jsx(B,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{A("download-pluginstorage"),re()},children:[e.jsx(B,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{A("download-pluginconfig"),re()},children:[e.jsx(B,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{A("download-mblog"),re()},children:[e.jsx(B,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{A("download-mjstorage"),re()},children:[e.jsx(B,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{A("download-mjlog"),re()},children:[e.jsx(B,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{A("download-diagnostic"),re()},children:[e.jsx(B,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{A("download-history"),re()},children:[e.jsx(B,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{A("shelly-create-system-log"),re()},children:[e.jsx(B,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{A("shelly-download-system-log"),re()},children:[e.jsx(B,{children:e.jsx(Me,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(ut,{}),e.jsxs(P,{onClick:m,children:[e.jsx(B,{children:e.jsx(kt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Je,{id:"sub-menu-backup",anchorEl:C,keepMounted:!0,open:!!C,onClose:he,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{A("create-backup"),he()},children:[e.jsx(B,{children:e.jsx(kt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{A("download-backup"),he()},children:[e.jsx(B,{children:e.jsx(kt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(ut,{}),e.jsxs(P,{onClick:Pe,children:[e.jsx(B,{children:e.jsx(fo,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(Je,{id:"sub-menu-reset",anchorEl:b,keepMounted:!0,open:!!b,onClose:$e,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(P,{onClick:()=>{$e(),l("Reset all devices and shutdown","Are you sure you want to unregister all devices? This will temporarily remove all devices from the controller and you may loose the controller configuration.","unregister",A,G)},children:[e.jsx(B,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(P,{onClick:()=>{$e(),l("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",A,G)},children:[e.jsx(B,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!c.matterbridgeInformation.readOnly&&e.jsxs(P,{onClick:()=>{$e(),l("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",A,G)},children:[e.jsx(B,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{$e(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",A,G)},children:[e.jsx(B,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),c.matterbridgeInformation&&c.matterbridgeInformation.shellyBoard&&e.jsxs(P,{onClick:()=>{$e(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",A,G)},children:[e.jsx(B,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const xi=r.memo(fi),dr=1200,cr=800;let $t,Nt;function bi(){if(typeof window<"u"){$t=Math.floor(window.visualViewport?.width??window.innerWidth),Nt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=$t<dr||Nt<cr;return o&&console.log("Visual viewport width %i height %i mobile %s",$t,Nt,n),n}return!1}function vi({children:n}){const{mobile:d,setMobile:l}=r.useContext(_e);return r.useEffect(()=>{function i(){l(bi())}return window.addEventListener("resize",i),()=>window.removeEventListener("resize",i)},[l]),o&&console.log("MbfScreen rendering... mobile %s",d),e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:d?`${dr}px`:"calc(100vw - 40px)",height:d?`${cr}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(xi,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let o=!1;const yi=()=>{o=!o},ji=!1;let et;const wi=n=>{et=n};function Ci({setLoggedIn:n}){const[d,l]=r.useState(""),[i,a]=r.useState(""),x={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},p={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)"},j={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},t=async v=>{try{const k=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:v})});if(k.ok){const{valid:O}=await k.json();O?(n(!0),v!==""&&(et=v)):v!==""&&a("Incorrect password!")}else console.error("Failed to log in:",k.statusText)}catch(k){console.error("Failed to log in:",k)}},I=v=>{v.preventDefault(),t(d)};return t(""),e.jsx("div",{style:x,children:e.jsxs("form",{onSubmit:I,style:p,children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"64px",width:"64px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:d,onChange:v=>l(v.target.value),style:j,placeholder:"password",autoComplete:"current-password"}),e.jsx("button",{type:"submit",style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",borderColor:"var(--div-bg-color)"},children:"Log in"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:0,height:"30px"},children:i&&e.jsx("p",{style:{color:"red"},children:i})})]})})}function Si(){const[n,d]=r.useState(!1),l=localStorage.getItem("frontendTheme")||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const i=mi("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const a=hi(i);window.location.href.includes("/api/hassio_ingress/");const x=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return o&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${x}"`)),n?e.jsx(xo,{theme:a,children:e.jsx(Ir,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(en,{children:e.jsx(tn,{children:e.jsx(jr,{basename:x,children:e.jsx(vi,{children:e.jsxs(wr,{children:[e.jsx(ze,{path:"/",element:e.jsx(Wn,{})}),e.jsx(ze,{path:"/devices",element:e.jsx(ti,{})}),e.jsx(ze,{path:"/log",element:e.jsx(oi,{})}),e.jsx(ze,{path:"/settings",element:e.jsx(pi,{})}),e.jsx(ze,{path:"/test",element:e.jsx(gi,{})}),e.jsx(ze,{path:"*",element:e.jsx(Cr,{to:"/"})})]})})})})})})}):e.jsx(Ci,{setLoggedIn:d})}Sr.createRoot(document.getElementById("root")).render(e.jsx(Mr.StrictMode,{children:e.jsx(Si,{})}));