matterbridge 3.2.9 → 3.2.10-dev-20250928-30c21de
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/cli.js +2 -91
- package/dist/cliEmitter.js +0 -30
- package/dist/clusters/export.js +0 -2
- package/dist/defaultConfigSchema.js +0 -24
- package/dist/deviceManager.js +1 -94
- package/dist/devices/airConditioner.js +0 -57
- package/dist/devices/batteryStorage.js +1 -48
- package/dist/devices/cooktop.js +0 -55
- package/dist/devices/dishwasher.js +0 -57
- package/dist/devices/evse.js +10 -74
- package/dist/devices/export.js +0 -5
- package/dist/devices/extractorHood.js +0 -42
- package/dist/devices/heatPump.js +2 -50
- package/dist/devices/laundryDryer.js +3 -62
- package/dist/devices/laundryWasher.js +4 -70
- package/dist/devices/microwaveOven.js +5 -88
- package/dist/devices/oven.js +0 -85
- package/dist/devices/refrigerator.js +0 -102
- package/dist/devices/roboticVacuumCleaner.js +9 -100
- package/dist/devices/solarPower.js +0 -38
- package/dist/devices/speaker.js +0 -84
- package/dist/devices/temperatureControl.js +3 -25
- package/dist/devices/waterHeater.js +2 -82
- package/dist/dgram/coap.js +13 -126
- package/dist/dgram/dgram.js +2 -114
- package/dist/dgram/mb_coap.js +3 -41
- package/dist/dgram/mb_mdns.js +15 -80
- package/dist/dgram/mdns.js +137 -299
- package/dist/dgram/multicast.js +1 -62
- package/dist/dgram/unicast.js +0 -54
- package/dist/frontend.js +27 -417
- package/dist/frontendTypes.js +0 -45
- package/dist/globalMatterbridge.js +0 -47
- package/dist/helpers.js +0 -53
- package/dist/index.js +1 -30
- package/dist/logger/export.js +0 -1
- package/dist/matter/behaviors.js +0 -2
- package/dist/matter/clusters.js +0 -2
- package/dist/matter/devices.js +0 -2
- package/dist/matter/endpoints.js +0 -2
- package/dist/matter/export.js +0 -3
- package/dist/matter/types.js +0 -3
- package/dist/matterbridge.js +52 -785
- package/dist/matterbridgeAccessoryPlatform.js +0 -36
- package/dist/matterbridgeBehaviors.js +5 -65
- package/dist/matterbridgeDeviceTypes.js +17 -630
- package/dist/matterbridgeDynamicPlatform.js +0 -36
- package/dist/matterbridgeEndpoint.js +58 -1398
- package/dist/matterbridgeEndpointHelpers.js +12 -345
- package/dist/matterbridgePlatform.js +0 -304
- package/dist/matterbridgeTypes.js +0 -25
- package/dist/pluginManager.js +3 -249
- package/dist/shelly.js +7 -168
- package/dist/storage/export.js +0 -1
- package/dist/update.js +0 -69
- package/dist/utils/colorUtils.js +2 -97
- package/dist/utils/commandLine.js +0 -54
- package/dist/utils/copyDirectory.js +1 -38
- package/dist/utils/createDirectory.js +0 -33
- package/dist/utils/createZip.js +2 -47
- package/dist/utils/deepCopy.js +0 -39
- package/dist/utils/deepEqual.js +1 -72
- package/dist/utils/error.js +0 -41
- package/dist/utils/export.js +0 -1
- package/dist/utils/hex.js +0 -124
- package/dist/utils/isvalid.js +0 -101
- package/dist/utils/jestHelpers.js +3 -153
- package/dist/utils/network.js +5 -91
- package/dist/utils/spawn.js +0 -69
- package/dist/utils/wait.js +8 -60
- package/frontend/build/assets/index.js +7 -7
- package/frontend/build/assets/vendor_node_modules.js +19 -19
- package/frontend/package-lock.json +115 -100
- package/frontend/package.json +9 -9
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -2
- package/dist/cli.d.ts +0 -26
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cliEmitter.d.ts +0 -34
- package/dist/cliEmitter.d.ts.map +0 -1
- package/dist/cliEmitter.js.map +0 -1
- package/dist/clusters/export.d.ts +0 -2
- package/dist/clusters/export.d.ts.map +0 -1
- package/dist/clusters/export.js.map +0 -1
- package/dist/defaultConfigSchema.d.ts +0 -28
- package/dist/defaultConfigSchema.d.ts.map +0 -1
- package/dist/defaultConfigSchema.js.map +0 -1
- package/dist/deviceManager.d.ts +0 -112
- package/dist/deviceManager.d.ts.map +0 -1
- package/dist/deviceManager.js.map +0 -1
- package/dist/devices/airConditioner.d.ts +0 -98
- package/dist/devices/airConditioner.d.ts.map +0 -1
- package/dist/devices/airConditioner.js.map +0 -1
- package/dist/devices/batteryStorage.d.ts +0 -48
- package/dist/devices/batteryStorage.d.ts.map +0 -1
- package/dist/devices/batteryStorage.js.map +0 -1
- package/dist/devices/cooktop.d.ts +0 -60
- package/dist/devices/cooktop.d.ts.map +0 -1
- package/dist/devices/cooktop.js.map +0 -1
- package/dist/devices/dishwasher.d.ts +0 -71
- package/dist/devices/dishwasher.d.ts.map +0 -1
- package/dist/devices/dishwasher.js.map +0 -1
- package/dist/devices/evse.d.ts +0 -75
- package/dist/devices/evse.d.ts.map +0 -1
- package/dist/devices/evse.js.map +0 -1
- package/dist/devices/export.d.ts +0 -17
- package/dist/devices/export.d.ts.map +0 -1
- package/dist/devices/export.js.map +0 -1
- package/dist/devices/extractorHood.d.ts +0 -46
- package/dist/devices/extractorHood.d.ts.map +0 -1
- package/dist/devices/extractorHood.js.map +0 -1
- package/dist/devices/heatPump.d.ts +0 -47
- package/dist/devices/heatPump.d.ts.map +0 -1
- package/dist/devices/heatPump.js.map +0 -1
- package/dist/devices/laundryDryer.d.ts +0 -67
- package/dist/devices/laundryDryer.d.ts.map +0 -1
- package/dist/devices/laundryDryer.js.map +0 -1
- package/dist/devices/laundryWasher.d.ts +0 -81
- package/dist/devices/laundryWasher.d.ts.map +0 -1
- package/dist/devices/laundryWasher.js.map +0 -1
- package/dist/devices/microwaveOven.d.ts +0 -168
- package/dist/devices/microwaveOven.d.ts.map +0 -1
- package/dist/devices/microwaveOven.js.map +0 -1
- package/dist/devices/oven.d.ts +0 -105
- package/dist/devices/oven.d.ts.map +0 -1
- package/dist/devices/oven.js.map +0 -1
- package/dist/devices/refrigerator.d.ts +0 -118
- package/dist/devices/refrigerator.d.ts.map +0 -1
- package/dist/devices/refrigerator.js.map +0 -1
- package/dist/devices/roboticVacuumCleaner.d.ts +0 -112
- package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
- package/dist/devices/roboticVacuumCleaner.js.map +0 -1
- package/dist/devices/solarPower.d.ts +0 -40
- package/dist/devices/solarPower.d.ts.map +0 -1
- package/dist/devices/solarPower.js.map +0 -1
- package/dist/devices/speaker.d.ts +0 -87
- package/dist/devices/speaker.d.ts.map +0 -1
- package/dist/devices/speaker.js.map +0 -1
- package/dist/devices/temperatureControl.d.ts +0 -166
- package/dist/devices/temperatureControl.d.ts.map +0 -1
- package/dist/devices/temperatureControl.js.map +0 -1
- package/dist/devices/waterHeater.d.ts +0 -111
- package/dist/devices/waterHeater.d.ts.map +0 -1
- package/dist/devices/waterHeater.js.map +0 -1
- package/dist/dgram/coap.d.ts +0 -205
- package/dist/dgram/coap.d.ts.map +0 -1
- package/dist/dgram/coap.js.map +0 -1
- package/dist/dgram/dgram.d.ts +0 -141
- package/dist/dgram/dgram.d.ts.map +0 -1
- package/dist/dgram/dgram.js.map +0 -1
- package/dist/dgram/mb_coap.d.ts +0 -24
- package/dist/dgram/mb_coap.d.ts.map +0 -1
- package/dist/dgram/mb_coap.js.map +0 -1
- package/dist/dgram/mb_mdns.d.ts +0 -24
- package/dist/dgram/mb_mdns.d.ts.map +0 -1
- package/dist/dgram/mb_mdns.js.map +0 -1
- package/dist/dgram/mdns.d.ts +0 -290
- package/dist/dgram/mdns.d.ts.map +0 -1
- package/dist/dgram/mdns.js.map +0 -1
- package/dist/dgram/multicast.d.ts +0 -67
- package/dist/dgram/multicast.d.ts.map +0 -1
- package/dist/dgram/multicast.js.map +0 -1
- package/dist/dgram/unicast.d.ts +0 -56
- package/dist/dgram/unicast.d.ts.map +0 -1
- package/dist/dgram/unicast.js.map +0 -1
- package/dist/frontend.d.ts +0 -232
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/frontendTypes.d.ts +0 -514
- package/dist/frontendTypes.d.ts.map +0 -1
- package/dist/frontendTypes.js.map +0 -1
- package/dist/globalMatterbridge.d.ts +0 -59
- package/dist/globalMatterbridge.d.ts.map +0 -1
- package/dist/globalMatterbridge.js.map +0 -1
- package/dist/helpers.d.ts +0 -48
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts +0 -33
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger/export.d.ts +0 -2
- package/dist/logger/export.d.ts.map +0 -1
- package/dist/logger/export.js.map +0 -1
- package/dist/matter/behaviors.d.ts +0 -2
- package/dist/matter/behaviors.d.ts.map +0 -1
- package/dist/matter/behaviors.js.map +0 -1
- package/dist/matter/clusters.d.ts +0 -2
- package/dist/matter/clusters.d.ts.map +0 -1
- package/dist/matter/clusters.js.map +0 -1
- package/dist/matter/devices.d.ts +0 -2
- package/dist/matter/devices.d.ts.map +0 -1
- package/dist/matter/devices.js.map +0 -1
- package/dist/matter/endpoints.d.ts +0 -2
- package/dist/matter/endpoints.d.ts.map +0 -1
- package/dist/matter/endpoints.js.map +0 -1
- package/dist/matter/export.d.ts +0 -5
- package/dist/matter/export.d.ts.map +0 -1
- package/dist/matter/export.js.map +0 -1
- package/dist/matter/types.d.ts +0 -3
- package/dist/matter/types.d.ts.map +0 -1
- package/dist/matter/types.js.map +0 -1
- package/dist/matterbridge.d.ts +0 -444
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts +0 -1747
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts +0 -761
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts +0 -1534
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -407
- package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
- package/dist/matterbridgeEndpointHelpers.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts +0 -365
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts +0 -197
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/pluginManager.d.ts +0 -270
- package/dist/pluginManager.d.ts.map +0 -1
- package/dist/pluginManager.js.map +0 -1
- package/dist/shelly.d.ts +0 -174
- package/dist/shelly.d.ts.map +0 -1
- package/dist/shelly.js.map +0 -1
- package/dist/storage/export.d.ts +0 -2
- package/dist/storage/export.d.ts.map +0 -1
- package/dist/storage/export.js.map +0 -1
- package/dist/update.d.ts +0 -75
- package/dist/update.d.ts.map +0 -1
- package/dist/update.js.map +0 -1
- package/dist/utils/colorUtils.d.ts +0 -99
- package/dist/utils/colorUtils.d.ts.map +0 -1
- package/dist/utils/colorUtils.js.map +0 -1
- package/dist/utils/commandLine.d.ts +0 -59
- package/dist/utils/commandLine.d.ts.map +0 -1
- package/dist/utils/commandLine.js.map +0 -1
- package/dist/utils/copyDirectory.d.ts +0 -33
- package/dist/utils/copyDirectory.d.ts.map +0 -1
- package/dist/utils/copyDirectory.js.map +0 -1
- package/dist/utils/createDirectory.d.ts +0 -34
- package/dist/utils/createDirectory.d.ts.map +0 -1
- package/dist/utils/createDirectory.js.map +0 -1
- package/dist/utils/createZip.d.ts +0 -39
- package/dist/utils/createZip.d.ts.map +0 -1
- package/dist/utils/createZip.js.map +0 -1
- package/dist/utils/deepCopy.d.ts +0 -32
- package/dist/utils/deepCopy.d.ts.map +0 -1
- package/dist/utils/deepCopy.js.map +0 -1
- package/dist/utils/deepEqual.d.ts +0 -54
- package/dist/utils/deepEqual.d.ts.map +0 -1
- package/dist/utils/deepEqual.js.map +0 -1
- package/dist/utils/error.d.ts +0 -44
- package/dist/utils/error.d.ts.map +0 -1
- package/dist/utils/error.js.map +0 -1
- package/dist/utils/export.d.ts +0 -13
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/utils/hex.d.ts +0 -89
- package/dist/utils/hex.d.ts.map +0 -1
- package/dist/utils/hex.js.map +0 -1
- package/dist/utils/isvalid.d.ts +0 -103
- package/dist/utils/isvalid.d.ts.map +0 -1
- package/dist/utils/isvalid.js.map +0 -1
- package/dist/utils/jestHelpers.d.ts +0 -137
- package/dist/utils/jestHelpers.d.ts.map +0 -1
- package/dist/utils/jestHelpers.js.map +0 -1
- package/dist/utils/network.d.ts +0 -84
- package/dist/utils/network.d.ts.map +0 -1
- package/dist/utils/network.js.map +0 -1
- package/dist/utils/spawn.d.ts +0 -34
- package/dist/utils/spawn.d.ts.map +0 -1
- package/dist/utils/spawn.js.map +0 -1
- package/dist/utils/wait.d.ts +0 -54
- package/dist/utils/wait.d.ts.map +0 -1
- package/dist/utils/wait.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{B as e,y as
|
|
2
|
-
`).map((
|
|
3
|
-
`),
|
|
4
|
-
`)},[]),o
|
|
5
|
-
`)},[
|
|
6
|
-
`)},[
|
|
7
|
-
`)),["debug","info","notice","warn","error","fatal"].includes(h.response.level)&&(u.current==="info"&&h.response.level==="debug"||u.current==="notice"&&(h.response.level==="debug"||h.response.level==="info")||u.current==="warn"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice")||u.current==="error"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice"||h.response.level==="warn")||u.current==="fatal"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice"||h.response.level==="warn"||h.response.level==="error")))||L.current!=="*"&&L.current!==""&&!h.response.message.toLowerCase().includes(L.current.toLowerCase())&&!h.response.name.toLowerCase().includes(L.current.toLowerCase())||h.response.name==="Commissioning"&&h.response.message.includes("is uncommissioned"))return;g(be=>{const me=[...be,{level:h.response.level,time:h.response.time,name:h.response.name,message:h.response.message}];return me.length>t*2?me.slice(t):me})}else{if(s&&console.log(`WebSocket received message id ${h.id} method ${h.method}:`,h),h.id===0)H.current.forEach(fe=>fe.listener(h));else{const fe=H.current.find(be=>be.id===h.id);fe?fe.listener(h):s&&console.debug(`WebSocket no listener found for message id ${h.id}:`,h)}return}}catch(h){console.error(`WebSocketUse error parsing message: ${h}`)}},F.current.onopen=()=>{s&&console.log(`WebSocket: Connected to WebSocket: ${Y}`),M("WebSocket",`Connected to WebSocket: ${Y}`),V(!0),_(),E.current=1,d.current=setTimeout(()=>{a.current=setInterval(()=>{C({id:v.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{s&&console.error(`WebSocketUse: No pong response received from WebSocket: ${Y}`),M("WebSocket",`No pong response received from WebSocket: ${Y}`),V(!1)},1e3*$)},1e3*oe)},1e3*B)},F.current.onclose=()=>{s&&console.error(`WebSocket: Disconnected from WebSocket ${xe?"with Ingress":""}: ${Y}`),M("WebSocket",`Disconnected from WebSocket: ${Y}`),V(!1),_(),X(),d.current&&clearTimeout(d.current),o.current&&clearTimeout(o.current),a.current&&clearInterval(a.current),M("WebSocket",`Reconnecting (attempt ${E.current} of ${U}) to WebSocket${xe?" (Ingress)":""}: ${Y}`),xe?setTimeout(de,5e3):E.current===1?de():E.current<U?setTimeout(de,1e3*E.current):M("WebSocket",`Reconnect attempts exceeded limit of ${U} retries, refresh the page to reconnect to: ${Y}`),E.current=E.current+1},F.current.onerror=G=>{s&&console.error(`WebSocket: WebSocket error connecting to ${Y}:`,G),M("WebSocket",`WebSocket error connecting to ${Y}`)})},[Y]),de=r.useCallback(()=>{s&&console.log(`WebSocket attemptReconnect ${E.current}/${U} to:`,Y),le()},[le]);r.useEffect(()=>(le(),()=>{F.current&&F.current.readyState===WebSocket.OPEN&&F.current.close()}),[le]);const A=r.useMemo(()=>({messages:b,maxMessages:t,autoScroll:D,setMessages:g,setLogFilters:O,setMaxMessages:x,setAutoScroll:p}),[b,g,O]),se=r.useMemo(()=>({maxMessages:t,autoScroll:D,logFilterLevel:m,logFilterSearch:n,setMessages:g,setLogFilters:O,setMaxMessages:x,setAutoScroll:p,online:j,retry:E.current,getUniqueId:W,addListener:ee,removeListener:ce,sendMessage:C,logMessage:M}),[t,D,g,O,x,p,j,E.current,ee,ce,C,M]);return e.jsx(Ut.Provider,{value:A,children:e.jsx(ve.Provider,{value:se,children:i})})}function Vo(){const{showSnackbarMessage:i,showConfirmCancelDialog:m}=r.useContext(Be),{online:c,sendMessage:n,logMessage:l,addListener:b,removeListener:g,getUniqueId:t}=r.useContext(ve),[x,D]=r.useState(!1),[p,j]=r.useState(!1),[V,R]=r.useState(!1),[P,_]=r.useState(!1),[f,X]=r.useState(null),y=r.useRef(t()),[w,I]=r.useState(null),[H,F]=r.useState(null),[E,v]=r.useState(null),[a,o]=r.useState(null),[d,u]=r.useState(null),L=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},pe=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},te=()=>{f?.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")},Y=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},xe=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},U=()=>{n({id:y.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},oe=()=>{n({id:y.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},$=()=>{n({id:y.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},B=()=>{s&&console.log("Header: handleShellySystemUpdateClick"),l("Matterbridge","Installing system updates..."),n({id:y.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},N=()=>{s&&console.log("Header: handleShellyMainUpdateClick"),l("Matterbridge","Installing software updates..."),n({id:y.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},W=()=>{s&&console.log("Header: handleShellyCreateSystemLog"),n({id:y.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},C=()=>{s&&console.log("Header: handleShellyDownloadSystemLog"),l("Matterbridge","Downloading Shelly system log..."),i("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},M=()=>{f?.matterbridgeInformation.restartMode===""?n({id:y.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):n({id:y.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},O=()=>{n({id:y.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},ee=()=>{n({id:y.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},ce=()=>{n({id:y.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=()=>{n({id:y.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},de=Q=>{I(Q.currentTarget)},A=Q=>{s&&console.log("Header: handleMenuClose",Q),I(null),Q==="download-mblog"?(l("Matterbridge","Downloading matterbridge log..."),i("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):Q==="download-mjlog"?(l("Matterbridge","Downloading matter log..."),i("Downloading matter log...",5),window.location.href="./api/download-mjlog"):Q==="view-mblog"?(l("Matterbridge","Loading matterbridge log..."),i("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):Q==="view-mjlog"?(l("Matterbridge","Loading matter log..."),i("Loading matter log...",5),window.location.href="./api/view-mjlog"):Q==="view-shellylog"?(l("Matterbridge","Loading shelly system log..."),i("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):Q==="download-mbstorage"?(l("Matterbridge","Downloading matterbridge storage..."),i("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):Q==="download-pluginstorage"?(l("Matterbridge","Downloading matterbridge plugins storage..."),i("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):Q==="download-pluginconfig"?(l("Matterbridge","Downloading matterbridge plugins config..."),i("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):Q==="download-mjstorage"?(l("Matterbridge","Downloading matter storage..."),i("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):Q==="download-backup"?(l("Matterbridge","Downloading backup..."),i("Downloading backup...",10),window.location.href="./api/download-backup"):Q==="update"?U():Q==="updatedev"?oe():Q==="updatecheck"?$():Q==="shelly-sys-update"?B():Q==="shelly-main-update"?N():Q==="shelly-create-system-log"?W():Q==="shelly-download-system-log"?C():Q==="softreset"?ce():Q==="hardreset"?le():Q==="restart"?M():Q==="shutdown"?O():Q==="reboot"?ee():Q==="create-backup"?n({id:y.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="unregister"?n({id:y.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="reset"?n({id:y.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="factoryreset"&&n({id:y.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},se=Q=>{s&&console.log("Header: handleMenuCloseCancel:",Q),I(null)},G=Q=>{F(Q.currentTarget)},h=()=>{F(null)},fe=Q=>{v(Q.currentTarget)},be=()=>{v(null)},me=Q=>{o(Q.currentTarget)},J=()=>{o(null)},ue=Q=>{u(Q.currentTarget)},je=()=>{u(null)},Qe=()=>{Qn(),s&&console.log("Matterbridge logo clicked: debug is now",s)};return r.useEffect(()=>{const Q=S=>{s&&console.log("Header received WebSocket Message:",S),S.method==="/api/settings"&&S.id===y.current?(s&&console.log("Header received settings:",S.response),X(S.response),D(S.response.matterbridgeInformation.restartRequired||S.response.matterbridgeInformation.fixedRestartRequired),j(S.response.matterbridgeInformation.fixedRestartRequired),R(S.response.matterbridgeInformation.updateRequired)):S.method==="refresh_required"&&S.response.changed==="settings"?(s&&console.log(`Header received refresh_required: changed=${S.response.changed} and sending /api/settings request`),n({id:y.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):S.method==="restart_required"?(s&&console.log(`Header received restart_required with fixed: ${S.response.fixed}`),D(!0),S.response.fixed===!0&&j(!0)):S.method==="restart_not_required"?(s&&console.log("Header received restart_not_required"),D(!1)):S.method==="update_required"?(s&&console.log("Header received update_required"),S.response.devVersion===!0?_(!0):R(!0),n({id:y.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):S.method==="shelly_sys_update"?(s&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),X(he=>he?{matterbridgeInformation:{...he.matterbridgeInformation,shellySysUpdate:S.response.available},systemInformation:he.systemInformation}:null)):S.method==="shelly_main_update"&&(s&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),X(he=>he?{matterbridgeInformation:{...he.matterbridgeInformation,shellyMainUpdate:S.response.available},systemInformation:he.systemInformation}:null))};return b(Q,y.current),s&&console.log(`Header added WebSocket listener id ${y.current}`),()=>{g(Q),s&&console.log("Header removed WebSocket listener")}},[b,g,n,i]),r.useEffect(()=>{c&&(s&&console.log("Header sending /api/settings requests"),n({id:y.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,n]),s&&console.log("Header rendering..."),!c||!f?null:e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Qe}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(Xe,{to:"/",className:"nav-link",children:"Home"}),e.jsx(Xe,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(Xe,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(Xe,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!f.matterbridgeInformation.readOnly&&V&&e.jsx(T,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:U,children:["Update to v.",f.matterbridgeInformation.matterbridgeLatestVersion]})}),!f.matterbridgeInformation.readOnly&&P&&e.jsx(T,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:oe,children:["Update to new dev v.",f.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!f.matterbridgeInformation.readOnly&&e.jsx(T,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:te,children:["v.",f.matterbridgeInformation.matterbridgeVersion]})}),f.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),f.matterbridgeInformation.bridgeMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.bridgeMode})}):null,f.matterbridgeInformation.restartMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.restartMode})}):null,f.matterbridgeInformation.profile&&f.matterbridgeInformation.profile!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:Y})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Give a star to Matterbridge",children:e.jsx(K,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:xe,children:e.jsx(gr,{})})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(T,{title:"Sponsor Matterbridge",children:e.jsx(K,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:L,children:e.jsx(Vt,{})})}):null,e.jsx(T,{title:"Matterbridge help",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:pe,children:e.jsx(mr,{})})}),e.jsx(T,{title:"Matterbridge changelog",children:e.jsx(K,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:te,children:e.jsx(Et,{})})}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsx(T,{title:"Update matterbridge to latest version",children:e.jsx(K,{style:{color:V?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:U,children:e.jsx(We,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsx(T,{title:"Shelly system update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:B,children:e.jsx(We,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsx(T,{title:"Shelly software update",children:e.jsx(K,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:N,children:e.jsx(We,{})})}),e.jsx(T,{title:"Restart matterbridge",children:e.jsx(K,{style:{color:x||p?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:M,children:e.jsx(dt,{})})}),f.matterbridgeInformation.restartMode===""?e.jsx(T,{title:"Shut down matterbridge",children:e.jsx(K,{style:{color:x||p?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:O,children:e.jsx(He,{})})}):null,e.jsx(T,{title:"Download, backup and more",children:e.jsx(K,{onClick:de,children:e.jsx(hr,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(ze,{id:"command-menu",anchorEl:w,keepMounted:!0,open:!!w,onClose:()=>A(""),children:[f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>A("update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>A("updatedev"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>A("updatecheck"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsxs(k,{onClick:()=>A("shelly-sys-update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsxs(k,{onClick:()=>A("shelly-main-update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>A("restart"),children:[e.jsx(z,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation.restartMode===""?e.jsxs(k,{onClick:()=>A("shutdown"),children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{m("Reboot","Are you sure you want to reboot the Shelly board?","reboot",A,se)},children:[e.jsx(z,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(Ze,{}),e.jsxs(k,{onClick:fe,children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-view",anchorEl:E,keepMounted:!0,open:!!E,onClose:be,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{A("view-mblog"),be()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("view-mjlog"),be()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{A("view-shellylog"),be()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Ze,{}),e.jsxs(k,{onClick:me,children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-download",anchorEl:a,keepMounted:!0,open:!!a,onClose:J,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{A("download-mbstorage"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-pluginstorage"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-pluginconfig"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-mblog"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-mjstorage"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-mjlog"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{A("shelly-create-system-log"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{A("shelly-download-system-log"),J()},children:[e.jsx(z,{children:e.jsx(Se,{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(Ze,{}),e.jsxs(k,{onClick:G,children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-backup",anchorEl:H,keepMounted:!0,open:!!H,onClose:h,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{A("create-backup"),h()},children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-backup"),h()},children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Ze,{}),e.jsxs(k,{onClick:ue,children:[e.jsx(z,{children:e.jsx(fr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-reset",anchorEl:d,keepMounted:!0,open:!!d,onClose:je,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{je(),m("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,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{je(),m("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,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>{je(),m("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,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{je(),m("Network reset","Are you sure you want to factory reset the network parameters?","softreset",A,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{je(),m("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",A,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Eo=r.memo(Vo),Ao=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(s&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(s&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function _o(){const{messages:i,autoScroll:m}=r.useContext(Ut),[c,n]=r.useState(!1),l=r.useRef(null),b=r.useMemo(()=>Ao(),[]),g=p=>n(!0),t=p=>n(!1);r.useEffect(()=>{s&&console.log(`WebSocketLogs autoScroll: ${m} isHovering: ${c}`),m&&!c&&!b&&l.current?.scrollIntoView({behavior:"smooth"})},[i,c,m,b]);const x=p=>{switch(p.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"}},D=p=>{switch(p.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:g,onMouseLeave:t,children:[i.map((p,j)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:x(p.level),color:D(p.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:p.level}),p.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+p.time+"]"}),p.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+p.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:p.message})]},j)),e.jsx("div",{ref:l})]})})}const Bt=r.memo(_o);function Re(){const{retry:i}=r.useContext(ve),m=()=>{window.location.reload()};return e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"20px",flexDirection:"column",color:"var(--main-text-color)",height:"100vh",backgroundColor:"var(--main-bg-color)"},children:e.jsx(Z,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:i<100?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px",marginBottom:"20px"}}),e.jsx(xr,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+i+")","..."]})})]}):e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px",marginBottom:"20px"}}),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:m,style:{marginTop:"20px"},children:"Refresh the Page"})]})})})}function qo({value:i,maxChars:m}){let c=i;if(i.length>m&&m>3){const n=m-3,l=i.substring(0,Math.ceil(n/2)),b=i.substring(i.length-Math.floor(n/2),i.length);c=`${l} … ${b}`}return i!==c?e.jsx(T,{title:i,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:c})}):e.jsx("span",{children:c})}function zo({systemInfo:i,compact:m}){const{sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(ve),[g,t]=r.useState(i),x=r.useRef(b());if(s&&console.log("SystemInfoTable:",g,"compact:",m),i&&m&&g.totalMemory&&g.freeMemory){const D=g.totalMemory,p=g.freeMemory;g.freeMemory=`${p} / ${D}`,g.totalMemory=""}if(i&&m&&g.heapTotal&&g.heapUsed){const D=g.heapTotal,p=g.heapUsed;g.heapUsed=`${p} / ${D}`,g.heapTotal=""}if(i&&m&&g.osRelease&&g.osType){const D=g.osType,p=g.osRelease;g.osType=`${D} (${p})`,g.osRelease=""}if(i&&m&&g.osArch&&g.osPlatform){const D=g.osPlatform,p=g.osArch;g.osPlatform=`${D} (${p})`,g.osArch=""}return r.useEffect(()=>{const D=p=>{p.src==="Matterbridge"&&p.dst==="Frontend"&&(p.method==="memory_update"&&p.response&&p.response.totalMemory&&p.response.freeMemory&&p.response.heapTotal&&p.response.heapUsed&&p.response.rss&&(s&&console.log("SystemInfoTable received memory_update",p),(g.totalMemory!==p.response.totalMemory||g.freeMemory!==p.response.freeMemory||g.heapTotal!==p.response.heapTotal||g.heapUsed!==p.response.heapUsed||g.rss!==p.response.rss)&&t(j=>({...j,totalMemory:p.response.totalMemory,freeMemory:p.response.freeMemory,heapTotal:p.response.heapTotal,heapUsed:p.response.heapUsed,rss:p.response.rss}))),p.method==="cpu_update"&&p.response&&p.response.cpuUsage&&(s&&console.log("SystemInfoTable received cpu_update",p),g.cpuUsage!==(p.response.cpuUsage?p.response.cpuUsage.toFixed(2)+" %":"")&&t(j=>({...j,cpuUsage:p.response.cpuUsage.toFixed(2)+" %"}))),p.method==="uptime_update"&&p.response&&p.response.systemUptime&&p.response.processUptime&&(s&&console.log("SystemInfoTable received uptime_update",p),(g.systemUptime!==p.response.systemUptime||g.processUptime!==p.response.processUptime)&&t(j=>({...j,systemUptime:p.response.systemUptime,processUptime:p.response.processUptime}))))};return s&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),n(D,x.current),s&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),l(D),s&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[n,g.cpuUsage,g.freeMemory,g.heapTotal,g.heapUsed,g.processUptime,g.rss,g.systemUptime,g.totalMemory,l,c]),g?(s&&console.log("SystemInfoTable rendering..."),e.jsxs("div",{className:"MbfWindowDiv",style:{minWidth:"302px",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"System Information"})}),e.jsx("div",{className:"MbfWindowDivTable",children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(g).filter(([D,p])=>p!==void 0&&p!=="").map(([D,p],j)=>e.jsxs("tr",{className:j%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:D}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(qo,{value:typeof p!="string"?p.toString():p,maxChars:25})})]},D))})})})]})):null}const Uo=r.memo(zo),Tt={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"}},Bo=i=>{if(!i)return"";const m=i.toString().replace(/[^0-9]/g,"");if(m.length<5)return m;const c=m.slice(0,4),n=m.slice(4,7),l=m.slice(7,11);return[c,n,l].filter(Boolean).join("-")};function Qo({id:i}){const{online:m,sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(ve),[g,t]=r.useState(null),[x,D]=r.useState(null),p=r.useRef(null),j=r.useRef(b()),{showConfirmCancelDialog:V}=r.useContext(Be);s&&console.log(`QRDiv loading with id = "${i}" storeId "${g}" and matter:`,x),r.useEffect(()=>{s&&console.log(`QRDiv id effect "${i}"`),i&&(s&&console.log(`QRDiv sending data request for storeId "${i}"`),t(i),D(null),p.current&&clearTimeout(p.current),p.current=null,c({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:i,server:!0}}))},[i]),r.useEffect(()=>{s&&console.log(`QRDiv storeId effect "${g}"`)},[g]),r.useEffect(()=>{const y=w=>{w.method==="refresh_required"&&w.response.changed==="matter"&&w.response.matter&&(s&&console.log(`QRDiv received refresh_required: changed=${w.response.changed} for storeId "${w.response.matter.id}":`,w.response.matter),g===w.response.matter.id&&(s&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${w.response.matter.id}":`,w.response.matter),p.current&&clearTimeout(p.current),w.response.matter.advertising&&w.response.matter.advertiseTime&&w.response.matter.advertiseTime+9e5<=Date.now()&&(w.response.matter.advertising=!1),D(w.response.matter),w.response.matter.advertising&&(s&&console.log(`QRDiv setting matter advertise timeout for storeId "${w.response.matter.id}":`,w.response.matter.advertiseTime+9e5-Date.now()),p.current=setTimeout(()=>{p.current&&clearTimeout(p.current),s&&console.log(`QRDiv clearing advertising state for storeId "${g}" after 15 minutes`),D(I=>I&&{...I,advertising:!1})},w.response.matter.advertiseTime+9e5-Date.now()))))};return n(y,j.current),s&&console.log("QRDiv webSocket effect mounted"),()=>{l(y),p.current&&clearTimeout(p.current),p.current=null,s&&console.log("QRDiv webSocket effect unmounted")}},[n,l,g]);const R=()=>{s&&console.log(`QRDiv sent matter startCommission for node "${x?.id}"`),x&&c({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,startCommission:!0}})},P=()=>{s&&console.log(`QRDiv sent matter stopCommission for node "${x?.id}"`),x&&c({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,stopCommission:!0}})},_=()=>{s&&console.log(`QRDiv sent matter advertise for node "${x?.id}"`),x&&c({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,advertise:!0}})},f=y=>{s&&console.log(`QRDiv sent matter removeFabric for node "${x?.id}" and fabricIndex ${y}`),x&&c({id:j.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:x.id,removeFabric:y}})},X=async()=>{if(!x||!x.manualPairingCode)return;const y=x.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(y);else{const w=document.createElement("textarea");w.value=y,w.style.position="fixed",w.style.opacity="0",document.body.appendChild(w),w.focus(),w.select(),document.execCommand("copy"),document.body.removeChild(w)}s&&console.log("Manual pairing code copied to clipboard")}catch(w){console.error("Failed to copy manual pairing code",w)}};return!x||!m?(s&&console.log("QRDiv rendering undefined state"),null):x.online?x.advertising&&x.qrPairingCode&&x.manualPairingCode?(s&&console.log("QRDiv rendering advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(K,{"aria-label":"send advertising",size:"small",onClick:_,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Wt,size:"22px"})})}),e.jsx(K,{"aria-label":"stop pairing",size:"small",onClick:P,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Turn off pairing",arrow:!0,children:e.jsx(ne,{path:ro,size:"22px"})})})]})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),e.jsx(to,{value:x.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs("div",{className:"MbfWindowFooter",style:{justifyContent:"space-between"},children:[e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",Bo(x.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(T,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(K,{"aria-label":"copy manual pairing code",size:"small",onClick:X,sx:Tt,children:e.jsx(ne,{path:oo,size:.85})})})})]})]})):x.commissioned&&x.fabricInformations&&x.sessionInformations?(s&&console.log("QRDiv rendering commissioned state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Paired fabrics"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(K,{"aria-label":"send advertising",size:"small",onClick:_,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Wt,size:"22px"})})}),e.jsx(K,{"aria-label":"start pairing",size:"small",onClick:R,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(T,{title:"Turn on pairing",arrow:!0,children:e.jsx(ne,{path:$t,size:"22px"})})})]})]}),e.jsxs("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:[e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),x.fabricInformations.map((y,w)=>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: ",y.fabricIndex]}),e.jsx(T,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(K,{"aria-label":"remove the fabric",size:"small",onClick:()=>V("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>f(y.fabricIndex),()=>{}),sx:{...Tt,padding:"2px"},children:e.jsx(ne,{path:no,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",y.rootVendorId," ",y.rootVendorName]}),y.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",y.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",x.sessionInformations?x.sessionInformations.filter(I=>I.fabric?.fabricIndex===y.fabricIndex&&I.isPeerActive===!0).length:"0"," ","subscriptions: ",x.sessionInformations?x.sessionInformations.filter(I=>I.fabric?.fabricIndex===y.fabricIndex&&I.isPeerActive===!0&&I.numberOfActiveSubscriptions>0).length:"0"]})]},w))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",x.serialNumber]})})]})):!x.commissioned&&!x.advertising?(s&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsx("div",{className:"MbfWindowHeader",style:{height:"30px"},children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"})}),e.jsx("p",{className:"MbfWindowHeaderText thin-scroll",style:{overflowX:"auto",maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),e.jsx(ie,{onClick:R,endIcon:e.jsx(ne,{path:$t,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",x.serialNumber]})})]})):(s&&console.log("QRDiv rendering unknown state"),null):(s&&console.log("QRDiv rendering offline state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Server node"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons"})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{overflow:"hidden",maxWidth:"280px",textOverflow:"ellipsis",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:g}),e.jsx("p",{style:{textAlign:"center",fontSize:"14px",fontWeight:"normal"},children:"Server offline"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",x.serialNumber]})})]}))}const Ko=r.memo(Qo);function Jo(){const{logMessage:i,sendMessage:m,getUniqueId:c}=r.useContext(ve),[n,l]=r.useState("matterbridge-"),[b,g]=r.useState(!1),[t,x]=r.useState(null),D=r.useRef(c()),p=w=>{w.preventDefault(),g(!0)},j=()=>{g(!1)},V=w=>{w.preventDefault(),g(!1);const I=w.dataTransfer.files[0];if(I){i("Plugins",`Installing package ${I.name}. Please wait...`);const H=new FormData;H.append("file",I),H.append("filename",I.name),fetch("./api/uploadpackage",{method:"POST",body:H}).then(F=>F.text()).then(F=>{i("Plugins",`Server response: ${F}`)}).catch(F=>{console.error("Error uploading plugin file:",F),i("Plugins",`Error installing package ${F}`)})}},R=w=>{const I=w.target.files&&w.target.files[0];if(I){i("Plugins",`Uploading package ${I.name}`);const H=new FormData;H.append("file",I),H.append("filename",I.name),fetch("./api/uploadpackage",{method:"POST",body:H}).then(F=>F.text()).then(F=>{i("Plugins",`Server response: ${F}`)}).catch(F=>{console.error("Error uploading plugin file:",F),i("Plugins",`Error uploading package ${F}`)})}},P=()=>{m({id:D.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:n,restart:!1}})},_=()=>{document.getElementById("file-upload")?.click()},f=()=>{m({id:D.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:n}})},X=w=>{x(w.currentTarget)},y=w=>{w!==""&&l(w),x(null)};return s&&console.log("AddRemovePlugins rendering..."),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:p,onDragLeave:j,onDrop:V,children:[e.jsx(ge,{value:n,onChange:w=>{l(w.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(K,{onClick:X,children:e.jsx(br,{})}),e.jsxs(ze,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>y(""),children:[e.jsx(k,{onClick:()=>y("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(k,{onClick:()=>y("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(k,{onClick:()=>y("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(k,{onClick:()=>y("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(k,{onClick:()=>y("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(k,{onClick:()=>y("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(k,{onClick:()=>y("matterbridge-test"),children:"matterbridge-test"}),e.jsx(k,{onClick:()=>y("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(k,{onClick:()=>y("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(k,{onClick:()=>y("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(k,{onClick:()=>y("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(k,{onClick:()=>y("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(k,{onClick:()=>y("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(k,{onClick:()=>y("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(T,{title:"Install or update a plugin from npm",children:e.jsx(ie,{onClick:P,endIcon:e.jsx(Se,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx(T,{title:"Upload and install a plugin from a tarball",children:e.jsx(ie,{onClick:_,endIcon:e.jsx(vr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx(T,{title:"Add an installed plugin",children:e.jsx(ie,{onClick:f,endIcon:e.jsx(ct,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Add"})}),e.jsx("input",{id:"file-upload",type:"file",accept:".tgz",style:{display:"none"},onChange:R})]})}const Go=r.memo(Jo);function Ee({status:i,enabledText:m="Enabled",disabledText:c=void 0,tooltipText:n=void 0,onClick:l}){if(i===void 0)return null;{const b=e.jsx("div",{className:i?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:l,children:i?m:c??m});return n!==void 0?e.jsx(T,{title:n,children:b}):b}}function Rt(i){return i.id!==0&&i.src==="Matterbridge"&&i.dst==="Frontend"}const Ae={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},_e={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Yo={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},Xo={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Pe={padding:"0px",margin:"0px"},Zo="5px 10px 5px 10px",st={},ye={},at={},lt={};let qe=[],xt=[];const en=({open:i,onClose:m,plugin:c})=>{const{sendMessage:n,addListener:l,removeListener:b,getUniqueId:g}=r.useContext(ve),t=r.useRef(g()),[x,D]=r.useState(c.configJson),[p,j]=r.useState(null),[V,R]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[P,_]=r.useState("");let f={};r.useEffect(()=>{const W=C=>{C.src==="Matterbridge"&&C.dst==="Frontend"&&(Rt(C)&&C.id===t.current&&C.method==="/api/select/devices"&&C.response&&(s&&console.log(`ConfigPluginDialog (id: ${C.id}) received ${C.response.length} /api/select/devices:`,C.response),qe=C.response),Rt(C)&&C.id===t.current&&C.method==="/api/select/entities"&&C.response&&(s&&console.log(`ConfigPluginDialog (id: ${C.id}) received ${C.response.length} /api/select/entities:`,C.response),xt=C.response))};return l(W,t.current),s&&console.log("ConfigPluginDialog added WebSocket listener id:",t.current),x&&p&&p.properties&&(Object.keys(p.properties).forEach(C=>{Object.keys(p.properties[C]).forEach(M=>{M.startsWith("ui:")&&(V[C]={},V[C][M]=p.properties[C][M],delete p.properties[C][M])})}),R(V)),c.name&&c.configJson&&c.schemaJson&&(D(c.configJson),j(c.schemaJson),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name}}),n({id:t.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name}}),s&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',c.name)),()=>{b(W),s&&console.log("ConfigPluginDialog removed WebSocket listener")}},[l,x,c,b,p,n,V]);const X=(W,C)=>{f=W.formData},y=W=>{s&&console.log("ConfigPluginDialog handleSaveChanges:",W.formData),D(W.formData),c.configJson=W.formData,c.restartRequired=!0,n({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.formData.name,formData:W.formData}}),m()};function w(W){const{id:C,label:M,onKeyChange:O,onDropPropertyClick:ee,disabled:ce,schema:le,children:de,registry:A,readonly:se,required:G}=W,{templates:h}=A,{RemoveButton:fe}=h.ButtonTemplates;if(!(Fo in le))return e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:de});const me=({target:J})=>O(J&&J.value);return e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(ge,{id:`${C}-key`,name:`${C}-key`,required:G,disabled:ce||se,defaultValue:M,onBlur:se?void 0:me,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(Z,{sx:{flex:1},children:de}),e.jsx(fe,{disabled:ce||se,onClick:ee(M),registry:A})]})}function I(W){const{children:C,description:M,displayLabel:O,errors:ee,help:ce,hidden:le,registry:de,uiSchema:A}=W,se=$o(A),G=Lo("WrapIfAdditionalTemplate",de,se);return le?e.jsx("div",{style:{display:"none"},children:C}):e.jsx(Z,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(G,{...W,children:[O===!0&&M,C,ee,ce]})})}function H(W){const{description:C}=W;return C?e.jsx(ae,{sx:_e,children:C}):null}function F(W){const{required:C,title:M}=W;return M?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ae,{sx:Ae,children:["Title ",M," ",C&&e.jsx("mark",{children:"***"})]})}):null}function E(W){const{help:C}=W;return C?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ae,{sx:Yo,children:C})}):null}function v(W){const{errors:C}=W;return C?e.jsxs(Z,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ae,{color:"error",sx:Xo,children:"Please fix the following errors:"}),e.jsx(Je,{children:C.map((M,O)=>e.jsxs(yr,{children:[e.jsx(z,{children:e.jsx(jr,{color:"error"})}),e.jsx(re,{primary:M.stack})]},O))})]}):null}function a(W){const{errors:C}=W;return C?e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:C.map((M,O)=>e.jsxs(ae,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",M]},O))}):null}function o(W){const{id:C,name:M,_schema:O,_uiSchema:ee,value:ce,options:le,label:de,type:A,placeholder:se,required:G,disabled:h,readonly:fe,autofocus:be,onChange:me,onChangeOverride:J,onBlur:ue,onFocus:je,_rawErrors:Qe,_hideError:Q,_registry:S,_formContext:he}=W,Ke=({target:{value:Ce}})=>me(Ce===""?le.emptyValue:Ce),Ne=({target:Ce})=>ue(C,Ce&&Ce.value),Ye=({target:Ce})=>je(C,Ce&&Ce.value);return e.jsx(Z,{sx:{padding:"0px",margin:"0px"},children:e.jsx(ge,{id:C,name:C,label:se&&se!==""?de:void 0,variant:"outlined",placeholder:se&&se!==""?se:de,required:G,disabled:h||fe,autoFocus:be,value:ce||ce===0?ce:"",type:A,autoComplete:A==="password"?"current-password":M,onChange:J||Ke,onBlur:Ne,onFocus:Ye,fullWidth:!0})})}function d(W){return console.log("ArrayFieldTitleTemplate:",W),null}function u(W){return console.log("ArrayFieldDescriptionTemplate:",W),null}function L(W){return console.log("ArrayFieldItemTemplate:",W),null}function pe(W){const{canAdd:C,onAddClick:M,schema:O,title:ee}=W,[ce,le]=r.useState(!1),[de,A]=r.useState(!1),[se,G]=r.useState(!1),[h,fe]=r.useState(""),be=S=>{fe(S.target.value)},me=()=>{s&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",h,"selectDevices:",qe),le(!ce)},J=()=>{s&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",h,"selectEntities:",xt),A(!de)},ue=()=>{s&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",h,"selectDevices:",qe),G(!se)},je=S=>{le(!1),O.selectFrom==="serial"?O.items.default=S.serial:O.selectFrom==="name"&&(O.items.default=S.name),M()},Qe=S=>{A(!1),O.selectEntityFrom==="name"?O.items.default=S.name:O.selectEntityFrom==="description"&&(O.items.default=S.description),M()},Q=S=>{G(!1),O.selectDeviceEntityFrom==="name"?O.items.default=S.name:O.selectDeviceEntityFrom==="description"&&(O.items.default=S.description),M()};return e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[ee&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ee&&e.jsx(ae,{sx:Ae,children:ee}),C&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[O.selectFrom&&e.jsx(T,{title:"Add a device from the list",children:e.jsx(K,{onClick:me,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),O.selectEntityFrom&&e.jsx(T,{title:"Add an entity from the list",children:e.jsx(K,{onClick:J,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),O.selectDeviceEntityFrom&&e.jsx(T,{title:"Add a device entity from the list",children:e.jsx(K,{onClick:ue,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),e.jsx(T,{title:"Add a new item",children:e.jsx(K,{onClick:M,size:"small",color:"primary",sx:Pe,children:e.jsx(ct,{})})})]})]}),O.description&&e.jsx(ae,{sx:_e,children:O.description}),W.items.map(S=>e.jsxs(Z,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(Z,{sx:{flexGrow:1,marginRight:"10px"},children:S.children}),e.jsx(K,{disabled:!S.hasMoveUp,onClick:S.onReorderClick(S.index,S.index-1),size:"small",color:"primary",sx:Pe,children:e.jsx(Mt,{})}),e.jsx(K,{disabled:!S.hasMoveDown,onClick:S.onReorderClick(S.index,S.index+1),size:"small",color:"primary",sx:Pe,children:e.jsx(St,{})}),e.jsx(K,{onClick:S.onDropIndexClick(S.index),size:"small",color:"primary",sx:Pe,children:e.jsx(ut,{})})]},S.index)),e.jsxs(Me,{open:ce,onClose:me,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select a device"}),e.jsxs(Ie,{children:[e.jsxs(Z,{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(ge,{fullWidth:!0,variant:"outlined",value:h,onChange:be,placeholder:"Enter serial or name"})]}),e.jsx(Je,{dense:!0,children:qe.filter(S=>S.serial.toLowerCase().includes(h.toLowerCase())||S.name.toLowerCase().includes(h.toLowerCase())).map((S,he)=>e.jsxs(rt,{onClick:()=>je(S),sx:st,children:[S.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:ye})}),S.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),S.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),e.jsx(re,{primary:S.name,secondary:S.serial,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},he))})]}),e.jsx(Le,{children:e.jsx(ie,{onClick:me,children:"Close"})})]}),e.jsxs(Me,{open:de,onClose:J,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select an entity"}),e.jsxs(Ie,{children:[e.jsxs(Z,{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(ge,{fullWidth:!0,variant:"outlined",value:h,onChange:be,placeholder:"Enter name or description"})]}),e.jsx(Je,{dense:!0,children:xt.filter(S=>S.name.toLowerCase().includes(h.toLowerCase())||S.description.toLowerCase().includes(h.toLowerCase())).map((S,he)=>e.jsxs(rt,{onClick:()=>Qe(S),sx:st,children:[S.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:ye})}),S.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),S.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),S.icon==="component"&&e.jsx(z,{children:e.jsx(kt,{style:ye})}),S.icon==="matter"&&e.jsx(z,{children:e.jsx(It,{style:ye})}),e.jsx(re,{primary:S.name,secondary:S.description,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},he))})]}),e.jsx(Le,{children:e.jsx(ie,{onClick:J,children:"Close"})})]}),e.jsxs(Me,{open:se,onClose:ue,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(ke,{children:["Select an entity for ",ee]}),e.jsx(Ie,{children:e.jsx(Je,{dense:!0,children:qe.filter(S=>S.serial===ee||S.name===ee).map(S=>S.entities?.map((he,Ke)=>e.jsxs(rt,{onClick:()=>Q(he),sx:st,children:[he.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:ye})}),he.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),he.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),he.icon==="component"&&e.jsx(z,{children:e.jsx(kt,{style:ye})}),he.icon==="matter"&&e.jsx(z,{children:e.jsx(It,{style:ye})}),e.jsx(re,{primary:he.name,secondary:he.description,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},Ke)))})}),e.jsx(Le,{children:e.jsx(ie,{onClick:ue,children:"Close"})})]})]})}function te(W){const{onAddClick:C,schema:M,properties:O,title:ee,description:ce}=W,[le,de]=r.useState(!1),[A,se]=r.useState(""),G=J=>{se(J.target.value)},h=()=>{de(!le)},fe=J=>{s&&console.log(`ObjectFieldTemplate: handleSelectValue value "${J.serial}" for schema "${M.selectFrom}"`),de(!1);let ue="";M.selectFrom==="serial"?ue=J.serial:M.selectFrom==="name"&&(ue=J.name),_(ue),s&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${ue}"`),C(M)()},be=()=>{C(M)()},me=!M.additionalProperties;return s&&console.log(`ObjectFieldTemplate: isRoot ${me} newkey "${P}"`),!me&&P!==""&&(s&&console.log("ObjectFieldTemplate: newkey",P,"properties",O),O.forEach(J=>{if(J.name==="newKey"&&J.content.key==="newKey"&&J.content.props.name==="newKey"&&J.content.props.onKeyChange&&P!==""){s&&console.log("ObjectFieldTemplate: newkey onKeyChange",P);const ue=P;_(""),J.content.props.onKeyChange(ue)}})),e.jsxs(Z,{sx:{margin:"0px",padding:me?"10px":"5px 10px 0px 10px",border:me?"none":"1px solid grey"},children:[M.title&&me&&e.jsx(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ae,{sx:Ae,children:M.title})}),ee&&!me&&e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ae,{sx:Ae,children:ee}),e.jsxs(Z,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[M.selectFrom&&e.jsx(T,{title:"Add a device from the list",children:e.jsx(K,{onClick:h,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),e.jsx(T,{title:"Add a new item",children:e.jsx(K,{onClick:be,size:"small",color:"primary",sx:Pe,children:e.jsx(ct,{})})})]})]}),M.description&&e.jsx(Z,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ae,{sx:_e,children:M.description})}),O.map(({content:J,name:ue,hidden:je})=>!je&&e.jsxs(Z,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(M.properties[ue].type)?"0px":Zo,border:["object","array","boolean"].includes(M.properties[ue].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(M.properties[ue].type)&&e.jsx(ae,{sx:Ae,children:ue}),e.jsx(Z,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:J})]},ue)),e.jsxs(Me,{open:le,onClose:h,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select a device"}),e.jsxs(Ie,{children:[e.jsxs(Z,{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(ge,{fullWidth:!0,variant:"outlined",value:A,onChange:G,placeholder:"Enter serial or name"})]}),e.jsx(Je,{dense:!0,children:qe.filter(J=>J.serial.toLowerCase().includes(A.toLowerCase())||J.name.toLowerCase().includes(A.toLowerCase())).map((J,ue)=>e.jsxs(rt,{onClick:()=>fe(J),sx:st,children:[J.icon==="wifi"&&e.jsx(z,{children:e.jsx(Ge,{style:ye})}),J.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),J.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),e.jsx(re,{primary:J.name,secondary:J.serial,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},ue))})]}),e.jsx(Le,{children:e.jsx(ie,{onClick:h,children:"Close"})})]})]})}function Y(W){const{uiSchema:C}=W,{submitText:M,norender:O}=Wo(C);return O?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:m,children:"Cancel"})]})}function xe(W){const{className:C,disabled:M,onClick:O,registry:ee,style:ce,uiSchema:le,...de}=W;return e.jsx(T,{title:"Remove the item",children:e.jsx(K,{disabled:M,size:"small",color:"primary",onClick:O,children:e.jsx(ut,{})})})}function U(W){const{className:C,disabled:M,onClick:O,registry:ee,uiSchema:ce,...le}=W;return e.jsx(T,{title:"Add an item",children:e.jsx(K,{size:"small",color:"primary",onClick:O,children:e.jsx(ct,{})})})}function oe(W){const{disabled:C,onClick:M,registry:O,style:ee,uiSchema:ce,...le}=W;return e.jsx(T,{title:"Move up the item",children:e.jsx(K,{size:"small",color:"primary",onClick:M,children:e.jsx(Mt,{})})})}function $(W){const{disabled:C,onClick:M,registry:O,style:ee,uiSchema:ce,...le}=W;return e.jsx(T,{title:"Move down the item",children:e.jsx(K,{size:"small",color:"primary",onClick:M,children:e.jsx(St,{})})})}function B(W){const{id:C,name:M,value:O,schema:ee,readonly:ce,onChange:le}=W,[de,A]=r.useState(),se=h=>{s&&console.log(`CheckboxWidget ${M} onChangeField:`,h),A(h&&h!==""?h:void 0)},G=()=>{s&&console.log(`CheckboxWidget onClick plugin="${c.name}" action="${M}" value="${de}"`),n({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name,action:M,value:de,formData:f,id:C}}),ee.buttonClose===!0?m():ee.buttonSave===!0&&y({formData:x})};return ee.buttonText&&ee.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ae,{sx:_e,children:ee.description}),e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>G(),children:ee.buttonText})]}):ee.buttonField&&ee.description?e.jsxs(Z,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ae,{sx:_e,children:ee.description}),e.jsx(ge,{id:M+"-input",name:M,label:ee.textLabel,placeholder:ee.textPlaceholder,onChange:h=>se(h.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:ee.buttonField})]}):e.jsxs(Z,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[M&&e.jsxs(Z,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(ae,{sx:Ae,children:M}),e.jsx(Te,{checked:O,readOnly:ce,onChange:()=>le(!O),sx:{padding:"0px",margin:"0px"}})]}),ee.description&&e.jsx(ae,{sx:_e,children:ee.description})]})}function N({schema:W,id:C,name:M,options:O,label:ee,hideLabel:ce,required:le,disabled:de,placeholder:A,readonly:se,value:G,multiple:h,autofocus:fe,onChange:be,onBlur:me,onFocus:J,errorSchema:ue,rawErrors:je=[],registry:Qe,uiSchema:Q,hideError:S,formContext:he,...Ke}){const{enumOptions:Ne,enumDisabled:Ye,emptyValue:Ce}=O;h=typeof h>"u"?!1:!!h;const yt=h?[]:"",jt=typeof G>"u"||h&&G.length<1||!h&&G===yt,Kt=({target:{value:De}})=>be(ft(De,Ne,Ce)),Jt=({target:De})=>me(C,ft(De&&De.value,Ne,Ce)),Gt=({target:De})=>J(C,ft(De&&De.value,Ne,Ce)),wt=Po(G,Ne,h),{InputLabelProps:Yt,SelectProps:Xt,autocomplete:Zt,...er}=Ke,tr=!h&&W.default===void 0;return e.jsxs(ge,{id:C,name:C,value:!jt&&typeof wt<"u"?wt:yt,required:le,disabled:de||se,autoFocus:fe,autoComplete:Zt,placeholder:A,error:je.length>0,onChange:Kt,onBlur:Jt,onFocus:Gt,...er,select:!0,InputLabelProps:{...Yt,shrink:!jt},SelectProps:{...Xt,multiple:h},"aria-describedby":No(C),children:[tr&&e.jsx(k,{value:"",children:A}),Array.isArray(Ne)&&Ne.map(({value:De,label:rr},Ct)=>{const or=Array.isArray(Ye)&&Ye.indexOf(De)!==-1;return e.jsx(k,{value:String(Ct),disabled:or,children:rr},Ct)})]})}return s&&console.log("ConfigPluginDialog rendering..."),!i||!p||!x?null:e.jsxs(Me,{open:i,onClose:m,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(ke,{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(Ie,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Io,{schema:p,formData:x,uiSchema:V,validator:Do,templates:{FieldTemplate:I,BaseInputTemplate:o,TitleFieldTemplate:F,DescriptionFieldTemplate:H,FieldHelpTemplate:E,FieldErrorTemplate:a,ErrorListTemplate:v,WrapIfAdditionalTemplate:w,ArrayFieldTitleTemplate:d,ArrayFieldDescriptionTemplate:u,ArrayFieldItemTemplate:L,ArrayFieldTemplate:pe,ObjectFieldTemplate:te,ButtonTemplates:{SubmitButton:Y,RemoveButton:xe,AddButton:U,MoveUpButton:oe,MoveDownButton:$}},widgets:{CheckboxWidget:B,SelectWidget:N},onChange:X,onSubmit:y})})]})};function Qt(i){if(s&&console.log(`getQRColor (id: ${i?.id}) received matter:`,i??"undefined"),i===void 0||!i.online||!i.qrPairingCode&&!i.manualPairingCode&&!i.fabricInformations&&!i.sessionInformations)return"red";if(i.commissioned===!1&&i.qrPairingCode&&i.manualPairingCode)return"var(--primary-color)";let m=0,c=0;for(const n of i.sessionInformations??[])n.fabric&&n.isPeerActive===!0&&m++,n.numberOfActiveSubscriptions>0&&(c+=n.numberOfActiveSubscriptions);return i.commissioned===!0&&i.fabricInformations&&i.sessionInformations&&(m===0||c===0)?"var(--secondary-color)":"var(--div-text-color)"}function tn(i,m,c){const n=i?.[c],l=m?.[c];return n==null&&l==null?0:n==null?-1:l==null?1:typeof n=="boolean"&&typeof l=="boolean"?n===l?0:n?1:-1:typeof n=="number"&&typeof l=="number"?n-l:String(n).localeCompare(String(l))}function rn({name:i,title:m,columns:c,rows:n,getRowKey:l,footerLeft:b,footerRight:g,onRowClick:t}){const x=r.useRef(new WeakMap),D=r.useRef(1),p=a=>{if(typeof l=="string"&&a&&a[l]!=null)return a[l];if(typeof l=="function"){const u=l(a);if(u!=null)return u}const o=c?.[0]?.id;if(o&&a&&a[o]!=null)return a[o];console.warn(`MbfTable(${i}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let d=x.current.get(a);return d||(d=`rk_${D.current++}`,x.current.set(a,d)),d},[j,V]=r.useState(localStorage.getItem(`${i}_table_order_by`)||null),[R,P]=r.useState(localStorage.getItem(`${i}_table_order`)||null),[_,f]=r.useState(!1),[X,y]=r.useState(()=>{try{const a=localStorage.getItem(`${i}_column_visibility`);if(a)return JSON.parse(a)}catch{}return{}}),w=r.useMemo(()=>{const a={};for(const o of c)o.hidden||(a[o.id]=o.required?!0:X[o.id]!==!1);return a},[c,X]),I=r.useMemo(()=>{if(!j||!R)return n;const a=c.find(d=>d.id===j);if(!a||a.noSort)return n;const o=n.map((d,u)=>({el:d,index:u}));return o.sort((d,u)=>{let L;return typeof a.comparator=="function"?L=a.comparator(d.el,u.el):L=tn(d.el,u.el,j),L!==0?R==="asc"?L:-L:d.index-u.index}),o.map(d=>d.el)},[n,j,R,c]),H=a=>{if(j!==a||!j){V(a),P("asc"),localStorage.setItem(`${i}_table_order_by`,a),localStorage.setItem(`${i}_table_order`,"asc");return}if(R==="asc"){P("desc"),localStorage.setItem(`${i}_table_order`,"desc");return}V(null),P(null),localStorage.removeItem(`${i}_table_order_by`),localStorage.removeItem(`${i}_table_order`)},F=()=>{f(!_)},E=a=>{y(o=>{const d=c.find(pe=>pe.id===a);if(d&&d.required)return o;const u=w[a]!==!1,L={...o};u?L[a]=!1:delete L[a];try{localStorage.setItem(`${i}_column_visibility`,JSON.stringify(L))}catch{}return L})},v=()=>{y({});try{localStorage.removeItem(`${i}_column_visibility`)}catch{}f(!1)};return s&&console.log(`Rendering table ${i}${j&&R?` ordered by ${j}:${R}`:""}`),e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",height:"100%",minHeight:0,overflow:"hidden"},children:[e.jsxs(Me,{open:_,onClose:(a,o)=>{o==="backdropClick"||o==="escapeKeyDown"||F()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(ke,{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 ${i} columns`})]})}),e.jsx(Ie,{children:e.jsx(wr,{children:c.filter(a=>!a.hidden).map(a=>e.jsx(Fe,{control:e.jsx(Te,{disabled:!!a.required,checked:a.required?!0:w[a.id]!==!1,onChange:()=>E(a.id)}),label:a.label},a.id))})}),e.jsxs(Le,{children:[e.jsx(ie,{onClick:v,children:"Reset"}),e.jsx(ie,{variant:"contained",onClick:a=>{if(a?.currentTarget&&typeof a.currentTarget.blur=="function")try{a.currentTarget.blur()}catch{}const o=document.activeElement;if(o&&o instanceof HTMLElement&&typeof o.blur=="function")try{o.blur()}catch{}F()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:i}),m&&e.jsx("p",{className:"MbfWindowHeaderText",children:m}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(K,{onClick:a=>{if(a?.currentTarget?.blur)try{a.currentTarget.blur()}catch{}F()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(T,{title:`Configure ${i} columns`,children:e.jsx(ne,{path:io,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":`${i} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:c.map(a=>{if(a.hidden||!a.required&&w[a.id]===!1)return null;const o=!a.noSort,d=o&&j===a.id&&!!R;return e.jsxs("th",{onClick:o?()=>H(a.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:a.minWidth,maxWidth:a.maxWidth,textAlign:a.align||"left",cursor:o?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:a.maxWidth?"nowrap":void 0,overflow:a.maxWidth?"hidden":void 0,textOverflow:a.maxWidth?"ellipsis":void 0},"aria-sort":o?d?R==="asc"?"ascending":"descending":"none":void 0,children:[a.label,d&&e.jsxs("span",{style:{marginLeft:6},children:[R==="asc"&&e.jsx(ne,{path:so,size:"15px"}),R==="desc"&&e.jsx(ne,{path:ao,size:"15px"})]})]},a.id)})})}),e.jsx("tbody",{children:I.map((a,o)=>{const d=p(a);return e.jsx("tr",{className:o%2===0?"table-content-even":"table-content-odd",onClick:t?u=>t(a,d,u):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:t?"pointer":void 0},children:c.map(u=>{if(u.hidden||!u.required&&w[u.id]===!1)return null;const L=a[u.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:u.align||"left",padding:"5px 10px",margin:"0",maxWidth:u.maxWidth,whiteSpace:u.maxWidth?"nowrap":void 0,overflow:u.maxWidth?"hidden":void 0,textOverflow:u.maxWidth?"ellipsis":void 0},children:typeof u.render=="function"?u.render(L,d,a,u):typeof L=="boolean"?e.jsx(Te,{checked:L,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):u.format&&typeof L=="number"?u.format(L):L!=null?String(L):null},u.id)})},d)})})]})}),(b||g)&&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:b}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g})]})]})}function on(i){return r.memo(i)}const mt=on(rn);function nn({storeId:i,setStoreId:m}){const{online:c,sendMessage:n,addListener:l,removeListener:b,getUniqueId:g}=r.useContext(ve),{showConfirmCancelDialog:t}=r.useContext(Be),x=r.useRef(g()),[D,p]=r.useState(null),[j,V]=r.useState(null),[R,P]=r.useState([]),_=[{label:"Name",id:"name",required:!0,render:($,B,N,W)=>e.jsx(T,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>a(N),children:N.name})})},{label:"Description",id:"description",render:($,B,N,W)=>e.jsx(T,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>a(N),children:N.description})})},{label:"Version",id:"version",render:($,B,N,W)=>e.jsxs(e.Fragment,{children:[N.latestVersion!==void 0&&N.latestVersion!==N.version&&j&&!j.readOnly&&e.jsx(T,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>I(N),children:["Update to v.",N.latestVersion]})}),N.version.includes("-dev-")&&N.devVersion!==void 0&&N.devVersion!==N.version&&j&&!j.readOnly&&e.jsx(T,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>H(N),children:["Update to new dev v.",N.devVersion.split("-dev-")[0]]})}),e.jsx(T,{title:"Plugin version",children:e.jsx("span",{children:N.version})})]})},{label:"Author",id:"author",render:($,B,N,W)=>e.jsx(e.Fragment,{children:N.author?N.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:($,B,N,W)=>e.jsx(e.Fragment,{children:N.type?N.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:($,B,N,W)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[j&&j.bridgeMode==="childbridge"&&!N.error&&N.enabled&&e.jsx(T,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:Qt(N.matter)},onClick:()=>{N.matter?.id&&m(N.matter?.id)},size:"small",children:e.jsx(At,{})})}),j&&j.bridgeMode==="childbridge"&&!N.error&&N.enabled&&e.jsx(T,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>E(N),size:"small",children:e.jsx(dt,{})})}),e.jsx(T,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{disabled:N.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>xe(N),size:"small",children:e.jsx(vt,{})})}),j&&!j.readOnly&&e.jsx(T,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{X("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",N)},size:"small",children:e.jsx(ut,{})})}),N.enabled?e.jsx(T,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{X("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",N)},size:"small",children:e.jsx(Cr,{})})}):e.jsx(e.Fragment,{}),N.enabled?e.jsx(e.Fragment,{}):e.jsx(T,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>v(N),size:"small",children:e.jsx(Sr,{})})}),e.jsx(T,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>d(N),size:"small",children:e.jsx(Mr,{})})}),e.jsx(T,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>u(N),size:"small",children:e.jsx(kr,{})})}),j&&!j.readOnly&&e.jsx(T,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>o(N),size:"small",children:e.jsx(Vt,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:($,B,N,W)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:N.error?e.jsx(e.Fragment,{children:e.jsx(Ee,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:N.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ee,{status:N.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:N.loaded&&N.started&&N.configured?e.jsx(e.Fragment,{children:e.jsx(Ee,{status:N.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{status:N.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ee,{status:N.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ee,{status:N.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const $=B=>{B.src==="Matterbridge"&&B.dst==="Frontend"&&(B.method==="refresh_required"&&B.response.changed==="plugins"&&(s&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and sending /api/plugins request`),n({id:x.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),B.method==="refresh_required"&&B.response.changed==="matter"&&(s&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and setting matter id ${B.response.matter?.id}`),P(N=>{const W=N.findIndex(M=>M.matter?.id===B.response.matter?.id);if(W<0)return s&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and matter id ${B.response.matter?.id} not found`),N;s&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} set matter id ${B.response.matter?.id}`);const C=[...N];return C[W]={...C[W],matter:B.response.matter},C})),B.method==="refresh_required"&&B.response.changed==="settings"&&(s&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and sending /api/settings request`),n({id:x.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),B.id===x.current&&B.method==="/api/settings"&&(s&&console.log(`HomePlugins (id: ${B.id}) received settings:`,B.response),p(B.response.systemInformation),V(B.response.matterbridgeInformation)),B.id===x.current&&B.method==="/api/plugins"&&(s&&console.log(`HomePlugins (id: ${B.id}) received ${B.response.length} plugins:`,B.response),P(B.response)))};return l($,x.current),s&&console.log("HomePlugins added WebSocket listener id:",x.current),()=>{b($),s&&console.log("HomePlugins removed WebSocket listener")}},[l,b,n]),r.useEffect(()=>{c&&(s&&console.log("HomePlugins sending api requests"),n({id:x.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:x.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,n]);const f=r.useRef(null),X=($,B,N,W)=>{s&&console.log(`handleActionWithConfirmCancel ${N} ${W.name}`),f.current=W,t($,B,N,y,w)},y=$=>{s&&console.log(`handleConfirm action confirmed ${$} ${f.current?.name}`),$==="remove"&&f.current?F(f.current):$==="disable"&&f.current&&v(f.current),f.current=null},w=$=>{s&&console.log(`handleCancel action canceled ${$} ${f.current?.name}`),f.current=null},I=$=>{s&&console.log("handleUpdatePlugin plugin:",$.name),n({id:x.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:$.name,restart:!1}})},H=$=>{s&&console.log("handleUpdateDevPlugin plugin:",$.name),n({id:x.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:$.name+"@dev",restart:!1}})},F=$=>{s&&console.log("handleRemovePlugin plugin:",$.name),n({id:x.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:$.name}})},E=$=>{s&&console.log("handleRestartPlugin plugin:",$.name),n({id:x.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:$.name}})},v=$=>{s&&console.log("handleEnableDisablePlugin plugin:",$.name,"enabled:",$.enabled),$.enabled===!0?($.enabled=!1,n({id:x.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:$.name}})):($.enabled=!0,n({id:x.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:$.name}}))},a=$=>{s&&console.log(`handleHomepagePlugin plugin: ${$.name} homepage: ${$.homepage}`),$.homepage&&window.open($.homepage,"_blank")},o=$=>{s&&console.log("handleSponsorPlugin plugin:",$.name,"funding:",$.funding),$.funding&&window.open($.funding,"_blank")},d=$=>{s&&console.log("handleHelpPlugin plugin:",$.name,"help:",$.help),$.help&&window.open($.help,"_blank")},u=$=>{s&&console.log("handleChangelogPlugin plugin:",$.name,"changelog:",$.changelog),$.changelog&&window.open($.changelog,"_blank")},[L,pe]=r.useState(),[te,Y]=r.useState(!1),xe=$=>{s&&console.log("handleConfigPlugin plugin:",$.name),n({id:x.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:$.name}}),n({id:x.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:$.name}}),pe($),U()},U=()=>{Y(!0)},oe=()=>{Y(!1)};return s&&console.log("HomePlugins rendering..."),c?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[L&&e.jsx(en,{open:te,onClose:oe,plugin:L}),e.jsx(mt,{name:"Plugins",columns:_,rows:R,footerRight:"",footerLeft:""})]}):e.jsx(Re,{})}const sn=r.memo(nn),an=i=>`${i.pluginName}::${i.serial}`;function ln({storeId:i,setStoreId:m}){const{online:c,sendMessage:n,addListener:l,removeListener:b,getUniqueId:g}=r.useContext(ve),[t,x]=r.useState(!1),[D,p]=r.useState(!0),[j,V]=r.useState(null),[R,P]=r.useState([]),[_,f]=r.useState([]),[X,y]=r.useState([]),[w,I]=r.useState([]),H=r.useRef(g()),F=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(a,o,d,u)=>d.reachable===!0?"Online":d.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(a,o)=>{const d=a.reachable===!0?1:a.reachable===!1?0:-1,u=o.reachable===!0?1:o.reachable===!1?0:-1;return d-u}},{label:"Power",id:"powerSource",render:(a,o,d,u)=>d.powerSource==="ac"||d.powerSource==="dc"?e.jsx(_t,{fontSize:"small",sx:{color:"var(--primary-color)"}}):d.powerSource==="ok"?e.jsx(pt,{fontSize:"small",sx:{color:"green"}}):d.powerSource==="warning"?e.jsx(pt,{fontSize:"small",sx:{color:"yellow"}}):d.powerSource==="critical"?e.jsx(pt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl"},{label:"Actions",id:"selected",required:!0,render:(a,o,d,u)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[d.matter!==void 0?e.jsx(T,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>m(i===d.matter?.id?j?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:d.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:Qt(d.matter)},children:e.jsx(At,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),d.configUrl?e.jsx(T,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(K,{onClick:()=>window.open(d.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(vt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),d.selected!==void 0?e.jsx(T,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Te,{checked:d.selected,onChange:L=>v(L,d),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],E=r.useCallback(a=>{a.selected=void 0;const o=R.find(L=>L.name===a.pluginName);if(!o)return console.error(`HomeDevices isSelected: plugin ${a.pluginName} not found for device ${a.name} `),a.selected;const d=o.schemaJson?.properties?.whiteList?.selectFrom;let u=o.configJson.postfix;return u===""&&(u=void 0),o.hasWhiteList===!0&&o.hasBlackList===!0&&d&&(a.selected=!0,d==="serial"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&o.configJson.whiteList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!0),d==="serial"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&!o.configJson.whiteList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!1),d==="serial"&&o.configJson.blackList&&o.configJson.blackList.length>0&&o.configJson.blackList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!1),d==="name"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&o.configJson.whiteList.includes(a.name)&&(a.selected=!0),d==="name"&&o.configJson.whiteList&&o.configJson.whiteList.length>0&&!o.configJson.whiteList.includes(a.name)&&(a.selected=!1),d==="name"&&o.configJson.blackList&&o.configJson.blackList.length>0&&o.configJson.blackList.includes(a.name)&&(a.selected=!1)),a.selected},[R]);r.useEffect(()=>{const a=o=>{if(o.method==="refresh_required"&&o.response.changed!=="matter"?(s&&console.log(`HomeDevices received refresh_required: changed=${o.response.changed} and sending /api/plugins request`),n({id:H.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):o.method==="refresh_required"&&o.response.changed==="matter"?(s&&console.log(`HomeDevices received refresh_required: changed=${o.response.changed} and setting matter id ${o.response.matter?.id}`),I(d=>{const u=d.findIndex(pe=>pe.name.replaceAll(" ","")===o.response.matter?.id);if(u<0)return s&&console.debug(`HomeDevices: matter id ${o.response.matter?.id} not found`),d;const L=[...d];return L[u]={...L[u],matter:o.response.matter},s&&console.log(`HomeDevices received refresh_required: changed=${o.response.changed} and set matter id ${o.response.matter?.id}`),L})):o.method==="restart_required"?(s&&console.log("HomeDevices received restart_required"),x(!0)):o.method==="restart_not_required"?(s&&console.log("HomeDevices received restart_not_required"),x(!1)):o.method==="state_update"&&o.response.plugin&&o.response.serialNumber&&o.response.cluster.includes("BasicInformation")&&o.response.attribute==="reachable"&&(console.log(`HomeDevices updating device reachability for plugin ${o.response.plugin} serial ${o.response.serialNumber} value ${o.response.value}`),f(d=>{const u=d.findIndex(L=>L.pluginName===o.response.plugin&&L.serial===o.response.serialNumber);return u<0?(console.warn(`HomeDevices: device to update not found for plugin ${o.response.plugin} serial ${o.response.serialNumber}`),d):(d[u]={...d[u],reachable:o.response.value},[...d])})),o.id===H.current&&o.method==="/api/settings")s&&console.log(`HomeDevices (id: ${o.id}) received settings:`,o.response),V(o.response),x(o.response.matterbridgeInformation.restartRequired||o.response.matterbridgeInformation.fixedRestartRequired);else if(o.id===H.current&&o.method==="/api/plugins"){if(s&&console.log(`HomeDevices (id: ${o.id}) received ${o.response?.length} plugins:`,o.response),o.response){let d=!0;for(const u of o.response)u.enabled===!0&&(u.loaded!==!0||u.started!==!0||u.error===!0)&&(d=!1);if(!d)return;s&&console.log("HomeDevices reset plugins, devices and selectDevices"),p(!1),P(o.response),f([]),y([]),n({id:H.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),s&&console.log("HomeDevices sent /api/devices");for(const u of o.response)u.enabled===!0&&u.loaded===!0&&u.started===!0&&u.error!==!0&&(n({id:H.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:u.name}}),s&&console.log(`HomeDevices sent /api/select/devices for plugin: ${u.name}`))}}else if(o.id===H.current&&o.method==="/api/devices"){if(s&&console.log(`HomeDevices (id: ${o.id}) received ${o.response?.length} devices:`,o.response),o.response){for(const d of o.response)d.selected=E(d);f(o.response)}}else o.id===H.current&&o.method==="/api/select/devices"&&(s&&console.log(`HomeDevices (id: ${o.id}) received ${o.response?.length} selectDevices for plugin ${o.response&&o.response.length>0?o.response[0].pluginName:"without select devices"}:`,o.response),o.response&&o.response.length>0&&y(d=>{const u=d.filter(pe=>pe.pluginName!==o.response[0].pluginName),L=o.response.map(pe=>({...pe,selected:E(pe)}));return[...u,...L]}))};return l(a,H.current),s&&console.log(`HomeDevices added WebSocket listener id ${H.current}`),()=>{b(a),s&&console.log("HomeDevices removed WebSocket listener")}},[R,l,b,n,E]),r.useEffect(()=>{if(_.length===0&&X.length===0){I([]);return}s&&console.log(`HomeDevices mixing devices (${_.length}) and selectDevices (${X.length})`);const a=[];for(const o of _)a.push(o);for(const o of X)_.find(d=>d.pluginName===o.pluginName&&d.serial.includes(o.serial))||a.push(o);a.length>0&&(I(a),console.log(`HomeDevices mixed ${a.length} devices and selectDevices`))},[R,_,X,I]),r.useEffect(()=>{c&&(s&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),n({id:H.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),n({id:H.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,n]);const v=(a,o)=>{console.log(`handleCheckboxChange: checkbox changed to ${a.target.checked} for device ${o.name} serial ${o.serial}`),_.findIndex(d=>d.pluginName===o.pluginName&&d.serial===o.serial)<0?(s&&console.warn(`handleCheckboxChange: device ${o.name} serial ${o.serial} not found in devices, trying in mixedDevices`),I(d=>{const u=d.findIndex(L=>L.pluginName===o.pluginName&&L.serial===o.serial);return u<0?(console.error(`handleCheckboxChange: device ${o.name} serial ${o.serial} not found in mixedDevices`),d):(d[u]={...d[u],selected:a.target.checked},[...d])})):f(d=>{const u=d.findIndex(L=>L.pluginName===o.pluginName&&L.serial===o.serial);return u<0?(console.error(`handleCheckboxChange: device ${o.name} serial ${o.serial} not found in devices`),d):(d[u]={...d[u],selected:a.target.checked},[...d])}),a.target.checked?n({id:H.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:o.pluginName,serial:o.serial,name:o.name}}):n({id:H.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:o.pluginName,serial:o.serial,name:o.name}})};return s&&console.log("HomeDevices rendering..."),c?e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Devices",getRowKey:an,rows:w,columns:F,footerLeft:D?"Waiting for the plugins to fully load...":`Registered devices: ${_.length.toString()}/${w.length.toString()}`,footerRight:t?"Restart required":""})}):e.jsx(Re,{})}const dn=r.memo(ln);function cn(){const[i,m]=r.useState(null),[c,n]=r.useState(null),[l,b]=r.useState([]),[g]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,x]=r.useState(localStorage.getItem("homePageMode")??"devices"),[D,p]=r.useState(""),[j,V]=r.useState(!1),[R,P]=r.useState(!1),[_,f]=r.useState(null),{addListener:X,removeListener:y,online:w,sendMessage:I,logFilterLevel:H,logFilterSearch:F,autoScroll:E,getUniqueId:v}=r.useContext(ve),a=r.useRef(v());return r.useEffect(()=>{const o=d=>{d.method==="refresh_required"&&d.response.changed==="settings"&&(console.log(`Home received refresh_required: changed=${d.response.changed} and sending /api/settings request`),f(null),b([]),I({id:a.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),I({id:a.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),d.method==="/api/settings"&&d.id===a.current&&(console.log("Home received settings:",d.response),m(d.response.systemInformation),n(d.response.matterbridgeInformation),d.response.matterbridgeInformation.matterbridgeVersion&&p(`https://github.com/Luligu/matterbridge/blob/${d.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&d.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",d.response.matterbridgeInformation.frontendVersion):d.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&d.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",d.response.matterbridgeInformation.frontendVersion),P(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",d.response.matterbridgeInformation.matterbridgeVersion):d.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",d.response.matterbridgeInformation.matterbridgeVersion),V(!0)),d.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),x("devices")))),d.method==="/api/plugins"&&d.id===a.current&&(console.log("Home received plugins:",d.response),b(d.response))};return X(o,a.current),console.log(`Home added WebSocket listener id ${a.current}`),()=>{y(o),console.log("Home removed WebSocket listener")}},[X,y,I]),r.useEffect(()=>{if(console.log(`Home settings and plugins effect with storeId ${_}`),c?.bridgeMode==="bridge"&&!_&&(console.log(`Home set storeId from ${_} to Matterbridge`),f("Matterbridge")),c?.bridgeMode==="childbridge"&&!_&&l){for(const o of l)if(o.matter?.id){console.log(`Home set storeId from ${_} to ${o.matter.id}`),f(o.matter.id);break}}},[c,l,_]),r.useEffect(()=>{w&&(console.log("Home online effect, sending /api/settings and /api/plugins requests"),I({id:a.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),I({id:a.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[w,I]),console.log("Home rendering..."),!w||!i||!c?e.jsx(Re,{}):e.jsxs("div",{className:"MbfPageDiv",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(Ko,{id:_}),e.jsx(Uo,{systemInfo:i,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[R&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Ir,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),j&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(ie,{onClick:()=>window.open(D,"_blank"),endIcon:e.jsx(Et,{}),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(Dr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),g&&!c.readOnly&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Install plugins"})}),e.jsx(Go,{})]}),g&&e.jsx(sn,{storeId:_,setStoreId:f}),t==="devices"&&e.jsx(dn,{storeId:_,setStoreId:f}),t==="logs"&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"1 1 auto",width:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:"Logs"}),e.jsx("div",{className:"MbfWindowHeaderText",style:{display:"flex",justifyContent:"space-between"},children:e.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',H,'" and search "',F,'" Scroll: ',E?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(Bt,{})})]})]})]})}const pn=r.memo(cn),Ht={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},un={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},gn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Ot={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},mn={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)"},fn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},xn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},bn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},bt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},vn=[256,257,268,269],yn=[266,267],jn=[259,260,261,271,272],wn=[256,257,268,269,266,267,259,260,261,272];function q({icon:i,iconColor:m,cluster:c,value:n,unit:l,prefix:b}){return s&&console.log(`Render cluster "${c.clusterName}.${c.attributeName}" value(${typeof n}-${isNaN(n)}) "${n}" unit "${l}"`),b=b??!1,e.jsxs(Z,{sx:Ht,children:[i&&r.cloneElement(i,{key:`${c.clusterId}-${c.attributeId}-icon`,sx:{...un,color:m??"var(--primary-color)"}}),e.jsxs(Z,{sx:{...Ht,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[l&&b===!0&&e.jsx(ae,{sx:Ot,children:l},`${c.clusterId}-${c.attributeId}-unit`),e.jsx(ae,{sx:gn,children:n==null||typeof n=="number"&&isNaN(n)||n==="NaN"?"---":n},`${c.clusterId}-${c.attributeId}-value`),l&&b===!1&&e.jsx(ae,{sx:Ot,children:l},`${c.clusterId}-${c.attributeId}-unit`)]},`${c.clusterId}-${c.attributeId}-valueunitbox`)]},`${c.clusterId}-${c.attributeId}-box`)}function Cn({device:i,endpoint:m,id:c,deviceType:n,clusters:l}){const b=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let g="";return s&&console.log(`Device "${i.name}" endpoint "${m}" id "${c}" deviceType "0x${n.toString(16).padStart(4,"0")}" clusters (${l?.length}):`,l),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>g=`${t.attributeLocalValue} mV`),wn.includes(n)&&l.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>g=`Level ${t.attributeValue}`),n===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>g=`Position ${t.attributeLocalValue/100}%`),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>g=`Heat ${t.attributeLocalValue/100}°C `),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>g=g+`Cool ${t.attributeLocalValue/100}°C`),n===118&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>g=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>g=`${t.attributeLocalValue/1e3} V, `),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>g=g+`${t.attributeLocalValue/1e3} A, `),n===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>g=g+`${t.attributeLocalValue/1e3} W`),e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[n===19&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:t.attributeLocalValue===!0?e.jsx(Ge,{}):e.jsx(Pr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(q,{icon:e.jsx(pt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),n===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(q,{icon:e.jsx(_t,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),n===1293&&l.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),vn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(Nr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),yn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),jn.includes(n)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===115&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:uo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===124&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===117&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===123&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(Dt,{}),cluster:t,value:"Oven"})),n===112&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(Wr,{}),cluster:t,value:"Fridge"})),n===113&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===121&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(Dt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),n===122&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===120&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Lt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),n===119&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Lt,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),n===116&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),n===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(q,{icon:e.jsx($r,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===10&&l.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(q,{icon:t.attributeValue==="1"?e.jsx(Lr,{}):e.jsx(Fr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),n===43&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(q,{icon:e.jsx(Tr,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===15&&l.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),n===39&&l.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(q,{icon:e.jsx(Rr,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),n===771&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(Hr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),n===45&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(q,{icon:e.jsx(Pt,{}),cluster:t,value:t.attributeValue,unit:"%"})),n===114&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(q,{icon:e.jsx(Pt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),n===67&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Or,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),n===65&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Vr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),n===68&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Er,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),n===1292&&l.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),n===1295&&l.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),n===777&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),n===23&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),n===24&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),n===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Ft,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),n===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Ft,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),n===66&&l.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(q,{icon:e.jsx(Ar,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),n===44&&l.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:b[t.attributeLocalValue??0]})),n===770&&l.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(_r,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),n===775&&l.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),n===774&&l.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(qr,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),n===773&&l.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(zr,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),n===21&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:t.attributeValue==="true"?e.jsx(Ur,{}):e.jsx(Br,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),n===263&&l.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(q,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(Qr,{}):e.jsx(Kr,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),n===262&&l.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(Jr,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),n===1296&&l.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(q,{icon:e.jsx(Gr,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(Z,{sx:mn,children:e.jsx(ae,{sx:hn,children:g})}),e.jsx(Z,{sx:fn,children:e.jsx(ae,{sx:xn,children:i.name})}),e.jsxs(Z,{sx:bn,children:[s&&e.jsx(ae,{sx:bt,children:m}),e.jsx(ae,{sx:bt,children:c}),s&&e.jsxs(ae,{sx:bt,children:["0x",n.toString(16).padStart(4,"0")]})]})]})}function Sn({filter:i}){const{online:m,sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(ve),[g,t]=r.useState(null),[x,D]=r.useState([]),[p,j]=r.useState([]),[V,R]=r.useState(p),[P,_]=r.useState({}),[f,X]=r.useState({}),[y,w]=r.useState({}),I=r.useRef(b()),H=r.useRef(V),F=r.useCallback(v=>{console.log(`DevicesIcons received state_update "${v.response.cluster}.${v.response.attribute}" for "${v.response.id}:${v.response.number}": "${v.response.value}"`,v.response);const a=H.current.find(d=>d.pluginName===v.response.plugin&&d.uniqueId===v.response.uniqueId);if(!a){console.warn(`DevicesIcons updater device of plugin "${v.response.plugin}" serial "${v.response.serialNumber}" not found in filteredDevicesRef.current`);return}const o=y[a.serial].find(d=>d.endpoint===v.response.number.toString()&&d.clusterName===v.response.cluster&&d.attributeName===v.response.attribute);if(!o){console.warn(`DevicesIcons updater device "${a.name}" serial "${a.serial}" cluster "${v.response.cluster}" attribute "${v.response.attribute}" not found in clusters`);return}o.attributeValue=String(v.response.value),o.attributeLocalValue=v.response.value,w({...y}),console.log(`DevicesIcons updated "${o.clusterName}.${o.attributeName}" for device "${a.name}" serial "${a.serial}" to "${o.attributeValue}"`)},[y]);r.useEffect(()=>{const v=a=>{if(a.method==="refresh_required")s&&console.log(`DevicesIcons received refresh_required: changed=${a.response.changed} and sending api requests`),c({id:I.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:I.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:I.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(a.method==="state_update"&&a.response)F(a);else if(a.method==="/api/settings"&&a.response)s&&console.log("DevicesIcons received settings:",a.response),t(a.response);else if(a.method==="/api/plugins"&&a.response)s&&console.log("DevicesIcons received plugins:",a.response),D(a.response);else if(a.method==="/api/devices"&&a.response){s&&console.log(`DevicesIcons received ${a.response.length} devices:`,a.response),j(a.response);for(const o of a.response)s&&console.log("DevicesIcons sending /api/clusters"),c({id:I.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:o.pluginName,endpoint:o.endpoint||0}})}else if(a.method==="/api/clusters"&&a.response){if(s&&console.log(`DevicesIcons received for device "${a.response.deviceName}" serial "${a.response.serialNumber}" deviceTypes (${a.response.deviceTypes.length}) "${a.response.deviceTypes.join(",")}" clusters (${a.response.clusters.length}):`,a.response),a.response.clusters.length===0)return;const o=a.response.serialNumber;P[o]=[],f[o]=a.response.deviceTypes,y[o]=[];for(const d of a.response.clusters)P[o].find(u=>u.endpoint===d.endpoint)||P[o].push({endpoint:d.endpoint,id:d.id,deviceTypes:d.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(d.clusterName)&&y[o].push(d);_({...P}),X({...f}),w({...y}),s&&console.log(`DevicesIcons endpoints for "${o}":`,P[o]),s&&console.log(`DevicesIcons deviceTypes for "${o}":`,f[o]),s&&console.log(`DevicesIcons clusters for "${o}":`,y[o])}};return n(v,I.current),s&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{l(v),s&&console.log("DevicesIcons useEffect webSocket unmounted")}},[]),r.useEffect(()=>(s&&console.log("DevicesIcons useEffect online mounting"),m&&(s&&console.log("DevicesIcons useEffect online sending api requests"),c({id:I.current,sender:"DevicesIcons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:I.current,sender:"DevicesIcons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:I.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),s&&console.log("DevicesIcons useEffect online mounted"),()=>{s&&console.log("DevicesIcons useEffect online unmounted")}),[m,c]),r.useEffect(()=>{if(i===""){R(p),H.current=p;return}const v=p.filter(a=>a.name.toLowerCase().includes(i)||a.serial.toLowerCase().includes(i));R(v),H.current=v},[p,i]);const E=r.memo(Cn);return s&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:V.map(v=>P[v.serial]&&P[v.serial].map(a=>a.deviceTypes.map(o=>e.jsx(E,{device:v,endpoint:a.endpoint,id:a.id,deviceType:o,clusters:y[v.serial].filter(d=>d.endpoint===a.endpoint)},`${v.pluginName}-${v.uniqueId}-${a.id}-${o.toString()}`))))})}const Mn=r.memo(Sn),kn=[{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:(i,m,c,n)=>c.configUrl?e.jsx(K,{onClick:()=>window.open(c.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(vt,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],In=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(i,m,c,n)=>Array.isArray(i)?e.jsx(e.Fragment,{children:i.map(l=>`0x${l.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:i})},{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:(i,m,c,n)=>e.jsx(T,{title:String(i),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(i)})})}],Dn=i=>`${i.pluginName}::${i.uniqueId}`,Pn=i=>`${i.endpoint}::${i.clusterName}::${i.attributeName}`;function Nn({filter:i}){const{online:m,sendMessage:c,addListener:n,removeListener:l,getUniqueId:b}=r.useContext(ve),[g,t]=r.useState([]),[x,D]=r.useState(g),[p,j]=r.useState([]),[V,R]=r.useState(0),[P,_]=r.useState(null),[f,X]=r.useState(null),[y,w]=r.useState(null),[I,H]=r.useState(null),F=r.useRef(b()),E=r.useRef(x),v=r.useCallback(o=>{console.log(`DevicesTable received state_update "${o.response.cluster}.${o.response.attribute}" for "${o.response.id}:${o.response.number}": "${o.response.value}"`,o.response);const d=E.current.find(u=>u.pluginName===o.response.plugin&&u.uniqueId===o.response.uniqueId);if(!d){console.warn(`DevicesTable updater device of plugin "${o.response.plugin}" serial "${o.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(P&&f&&d.pluginName===P&&d.uniqueId===I&&o.response.number.toString()===f){const u=p.find(L=>L.endpoint===o.response.number.toString()&&L.clusterName===o.response.cluster&&L.attributeName===o.response.attribute);if(!u){console.warn(`DevicesTable updater cluster ${o.response.cluster}.${o.response.attribute} for device "${d.name}" serial "${d.serial}" not found in clusters`);return}u.attributeValue=String(o.response.value),u.attributeLocalValue=o.response.value,j([...p]),console.log(`DevicesTable updated attribute ${u.clusterName}.${u.attributeName} for device "${d.name}" serial "${d.serial}" to "${u.attributeValue}"`)}},[p,f,P,I]);r.useEffect(()=>{const o=d=>{if(s&&console.log("DevicesTable received WebSocket Message:",d),d.method==="refresh_required"&&d.response.changed==="devices")s&&console.log(`DevicesTable received refresh_required: changed=${d.response.changed} and sending /api/devices request`),c({id:F.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(d.method==="state_update"&&d.response)v(d);else if(d.method==="/api/devices")s&&console.log(`DevicesTable received ${d.response.length} devices:`,d.response),t(d.response);else if(d.method==="/api/clusters"){s&&console.log(`DevicesTable received ${d.response.clusters.length} clusters for plugin ${d.response.plugin}:`,d.response),j(d.response.clusters);const u={};for(const L of d.response.clusters)s&&console.log("Cluster:",L.endpoint),u[L.endpoint]?u[L.endpoint]++:u[L.endpoint]=1;R(Object.keys(u).length)}};return n(o,F.current),s&&console.log("DevicesTable added WebSocket listener"),()=>{l(o),s&&console.log("DevicesTable removed WebSocket listener")}},[c,n,l,v]),r.useEffect(()=>{m&&(s&&console.log("DevicesTable sending api requests with id ",F.current),c({id:F.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:F.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:F.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[m,c]),r.useEffect(()=>{P&&f&&(s&&console.log("DevicesTable sending /api/clusters"),c({id:F.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:P,endpoint:Number(f)}}))},[P,f,c]),r.useEffect(()=>{if(i===""){D(g),E.current=g;return}const o=g.filter(d=>d.name.toLowerCase().includes(i)||d.serial.toLowerCase().includes(i));D(o),E.current=o},[g,i]);const a=o=>{if(o.uniqueId===I){H(null),_(null),X(null),w(null);return}H(o.uniqueId),_(o.pluginName),X(o.endpoint?o.endpoint.toString():null),w(o.name)};return s&&console.log("DevicesTable rendering..."),m?e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${P&&f?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Registered devices",getRowKey:Dn,onRowClick:a,rows:x,columns:kn,footerLeft:`Total devices: ${x.length.toString()}`})}),P&&f&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",height:"50%",maxHeight:"50%",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Clusters",title:y||"",getRowKey:Pn,rows:p,columns:In,footerLeft:`Total child endpoints: ${V-1}`})})]}):e.jsx(Re,{})}const Wn=r.memo(Nn);function $n(){const{online:i}=r.useContext(ve),[m,c]=r.useState(""),[n,l]=r.useState("icon");r.useEffect(()=>{const t=localStorage.getItem("devicesFilter");t&&c(t)},[]),r.useEffect(()=>{const t=localStorage.getItem("devicesViewMode");t&&l(t)},[]);const b=t=>{c(t.target.value.toLowerCase()),localStorage.setItem("devicesFilter",t.target.value.toLowerCase())},g=t=>{l(t),localStorage.setItem("devicesViewMode",t)};return s&&console.log("Devices rendering..."),i?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ae,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ge,{variant:"outlined",value:m,onChange:b,placeholder:"Enter the device name or serial number",sx:{width:"320px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(Z,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ae,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(K,{onClick:()=>g("table"),"aria-label":"Table View",disabled:n==="table",children:e.jsx(T,{title:"Table View",children:e.jsx(Yr,{style:{color:n==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(K,{onClick:()=>g("icon"),"aria-label":"Icon View",disabled:n==="icon",children:e.jsx(T,{title:"Icon View (beta)",children:e.jsx(Xr,{style:{color:n==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),n==="table"&&e.jsx(Wn,{filter:m}),n==="icon"&&e.jsx(Mn,{filter:m})]}):e.jsx(Re,{})}const Ln=r.memo($n);function Fn(){const[i,m]=r.useState(localStorage.getItem("logFilterLevel")??"info"),[c,n]=r.useState(localStorage.getItem("logFilterSearch")??"*"),[l,b]=r.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:g,setLogFilters:t,online:x,setAutoScroll:D}=r.useContext(ve),p=P=>{m(P.target.value),t(P.target.value,c),localStorage.setItem("logFilterLevel",P.target.value),s&&console.log("handleChangeLevel called with value:",P.target.value)},j=P=>{n(P.target.value),t(i,P.target.value),localStorage.setItem("logFilterSearch",P.target.value),s&&console.log("handleChangeSearch called with value:",P.target.value)},V=P=>{b(P.target.checked),D(P.target.checked),localStorage.setItem("logAutoScroll",P.target.value?"true":"false"),s&&console.log("handleAutoScrollChange called with value:",P.target.checked)},R=()=>{s&&console.log("handleClearLogsClick called"),g([])};return s&&console.log("Logs rendering..."),x?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Nt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Ue,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:i,onChange:p,children:[e.jsx(k,{value:"debug",children:"Debug"}),e.jsx(k,{value:"info",children:"Info"}),e.jsx(k,{value:"notice",children:"Notice"}),e.jsx(k,{value:"warn",children:"Warn"}),e.jsx(k,{value:"error",children:"Error"}),e.jsx(k,{value:"fatal",children:"Fatal"})]}),e.jsx(Nt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(ge,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:c,onChange:j,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Fe,{control:e.jsx(Te,{checked:l,onChange:V}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(T,{title:"Clear the logs",children:e.jsx(ie,{onClick:R,endIcon:e.jsx(ut,{}),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(Bt,{})})]}):e.jsx(Re,{})}const Tn=r.memo(Fn),Rn=({open:i,ip:m,onClose:c,onSave:n})=>{const l=m?m.split(".").slice(0,3).join(".")+".1":"",[b,g]=r.useState("dhcp"),[t,x]=r.useState({ip:m??"",subnet:"255.255.255.0",gateway:l,dns:l}),D=V=>R=>{x({...t,[V]:R.target.value})},p=()=>{c()},j=()=>{n({type:b,...t}),c()};return e.jsxs(Me,{open:i,onClose:(V,R)=>{R==="backdropClick"||R==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(ke,{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(Ie,{dividers:!0,children:[e.jsxs(qt,{component:"fieldset",fullWidth:!0,children:[e.jsx(we,{component:"legend",children:"Select IP Configuration"}),e.jsxs(zt,{row:!0,value:b,onChange:V=>g(V.target.value),children:[e.jsx(Fe,{value:"dhcp",control:e.jsx(gt,{}),label:"DHCP"}),e.jsx(Fe,{value:"static",control:e.jsx(gt,{}),label:"Static"})]})]}),b==="static"&&e.jsxs($e,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx($e,{size:6,children:e.jsx(ge,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:D("ip")})}),e.jsx($e,{size:6,children:e.jsx(ge,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:D("subnet")})}),e.jsx($e,{size:6,children:e.jsx(ge,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:D("gateway")})}),e.jsx($e,{size:6,children:e.jsx(ge,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:D("dns")})})]})]}),e.jsxs(Le,{children:[e.jsx(ie,{onClick:p,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:j,children:"Save"})]})]})},Hn=({open:i,onClose:m,onSave:c})=>{const[n,l]=r.useState(""),[b,g]=r.useState(""),t=R=>{l(R.target.value)},x=R=>{g(R.target.value)},D=n.length>0&&n===b,p=()=>{m()},j=()=>{D&&(c(n),m())},V=()=>{c(""),m()};return e.jsxs(Me,{open:i,onClose:(R,P)=>{P==="backdropClick"||P==="escapeKeyDown"||m()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(ke,{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(Ie,{dividers:!0,children:e.jsx(qt,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs($e,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx($e,{size:12,children:e.jsx(ge,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:n,onChange:t})}),e.jsx($e,{size:12,children:e.jsx(ge,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:b,onChange:x,error:b!==""&&n!==b,helperText:b!==""&&n!==b?"Passwords do not match":""})})]})})}),e.jsxs(Le,{children:[e.jsx(ie,{onClick:p,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:j,disabled:!D,children:"Change"}),e.jsx(ie,{variant:"contained",onClick:V,children:"Reset"})]})]})};function On(){const{online:i,addListener:m,removeListener:c,sendMessage:n,getUniqueId:l}=r.useContext(ve),[b,g]=r.useState(null),[t,x]=r.useState(null),D=r.useRef(l());return r.useEffect(()=>{const p=j=>{j.src==="Matterbridge"&&j.dst==="Frontend"&&(j.method==="refresh_required"&&j.response.changed==="settings"&&(s&&console.log(`Settings received refresh_required: changed=${j.response.changed} and sending /api/settings request`),n({id:D.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),j.method==="/api/settings"&&(s&&console.log("Settings received /api/settings:",j.response),g(j.response.matterbridgeInformation),x(j.response.systemInformation)))};return m(p,D.current),s&&console.log("Settings added WebSocket listener"),()=>{c(p),s&&console.log("Settings removed WebSocket listener")}},[m,c,n]),r.useEffect(()=>{i&&(s&&console.log("Settings received online"),n({id:D.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,n]),b?(s&&console.log("Settings rendering..."),i?e.jsx("div",{className:"MbfPageDiv",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(Vn,{matterbridgeInfo:b,systemInfo:t}),e.jsx(En,{matterbridgeInfo:b}),e.jsx(An,{matterbridgeInfo:b})]})}):e.jsx(Re,{})):null}function Vn({matterbridgeInfo:i,systemInfo:m}){const{sendMessage:c,getUniqueId:n}=r.useContext(ve),[l,b]=r.useState("bridge"),[g,t]=r.useState("Info"),[x,D]=r.useState(!1),[p,j]=r.useState("dark"),[V,R]=r.useState(localStorage.getItem("homePagePlugins")!=="false"),[P,_]=r.useState(localStorage.getItem("homePageMode")??"devices"),[f,X]=r.useState(localStorage.getItem("virtualMode")??"outlet"),y=r.useRef(n()),[w,I]=r.useState(!1),H=()=>I(!1),F=U=>{s&&console.log("handleSaveNetConfig called with config:",U),c({id:y.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:U})},[E,v]=r.useState(!1),a=()=>v(!1),o=U=>{s&&console.log("handleSaveChangePassword called with password:",U),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:U}})};r.useEffect(()=>{i&&(b(i.bridgeMode==="bridge"?"bridge":"childbridge"),t(i.loggerLevel.charAt(0).toUpperCase()+i.loggerLevel.slice(1)),D(i.fileLogger),X(i.virtualMode))},[i]),r.useEffect(()=>{const U=localStorage.getItem("frontendTheme");U&&j(U)},[]);const d=U=>{s&&console.log("handleChangeBridgeMode called with value:",U.target.value),b(U.target.value),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:U.target.value}})},u=U=>{s&&console.log("handleChangeMbLoggerLevel called with value:",U.target.value),t(U.target.value),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:U.target.value}})},L=U=>{s&&console.log("handleLogOnFileMbChange called with value:",U.target.checked),D(U.target.checked),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:U.target.checked}})},pe=U=>{const oe=U.target.value;s&&console.log("handleChangeTheme called with value:",oe),j(oe),localStorage.setItem("frontendTheme",oe),document.body.setAttribute("frontend-theme",oe)},te=U=>{const oe=U.target.checked;s&&console.log("handleChangeHomePagePlugins called with value:",oe),R(oe),localStorage.setItem("homePagePlugins",oe?"true":"false")},Y=U=>{const oe=U.target.value;s&&console.log("handleChangeHomePageMode called with value:",oe),_(oe),localStorage.setItem("homePageMode",oe)},xe=U=>{const oe=U.target.value;s&&console.log("handleChangeVirtualMode called with value:",oe),X(oe),localStorage.setItem("virtualMode",oe),c({id:y.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:oe}})};return!i||!m?null:e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(Rn,{open:w,ip:m.ipv4Address,onClose:H,onSave:F}),e.jsx(Hn,{open:E,onClose:a,onSave:o}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(zt,{row:!0,name:"mode-buttons-group",value:l,onChange:d,children:[e.jsx(Fe,{value:"bridge",control:e.jsx(gt,{}),label:"Bridge",disabled:i.readOnly===!0}),e.jsx(Fe,{value:"childbridge",control:e.jsx(gt,{}),label:"Childbridge",disabled:i.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:g,onChange:u,children:[e.jsx(k,{value:"Debug",children:"Debug"}),e.jsx(k,{value:"Info",children:"Info"}),e.jsx(k,{value:"Notice",children:"Notice"}),e.jsx(k,{value:"Warn",children:"Warn"}),e.jsx(k,{value:"Error",children:"Error"}),e.jsx(k,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Te,{checked:x,onChange:L,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:p,onChange:pe,children:[e.jsx(k,{value:"classic",children:"Classic"}),e.jsx(k,{value:"light",children:"Light"}),e.jsx(k,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Te,{checked:V,onChange:te,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:P,onChange:Y,children:[e.jsx(k,{value:"logs",children:"Logs"}),e.jsx(k,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:f,onChange:xe,children:[e.jsx(k,{value:"disabled",children:"Disabled"}),e.jsx(k,{value:"outlet",children:"Outlet"}),e.jsx(k,{value:"light",children:"Light"}),e.jsx(k,{value:"switch",children:"Switch"}),e.jsx(k,{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:()=>v(!0),children:"Change password"})}),i.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>I(!0),children:"Configure IP"})})]})})]})}function En({matterbridgeInfo:i}){const{sendMessage:m,getUniqueId:c}=r.useContext(ve),[n,l]=r.useState("Info"),[b,g]=r.useState(!1),[t,x]=r.useState(""),[D,p]=r.useState(""),[j,V]=r.useState(""),[R,P]=r.useState(""),[_,f]=r.useState(""),[X,y]=r.useState(""),w=r.useRef(c());r.useEffect(()=>{i&&(l(["Debug","Info","Notice","Warn","Error","Fatal"][i.matterLoggerLevel]),g(i.matterFileLogger),x(i.matterMdnsInterface||""),p(i.matterIpv4Address||""),V(i.matterIpv6Address||""),P(i.matterPort?i.matterPort.toString():""),f(i.matterDiscriminator?i.matterDiscriminator.toString():""),y(i.matterPasscode?i.matterPasscode.toString():""))},[i]);const I=u=>{s&&console.log("handleChangeMjLoggerLevel called with value:",u.target.value),l(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:u.target.value}})},H=u=>{s&&console.log("handleLogOnFileMjChange called with value:",u.target.checked),g(u.target.checked),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:u.target.checked}})},F=u=>{s&&console.log("handleChangeMdnsInterface called with value:",u.target.value),x(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:u.target.value}})},E=u=>{s&&console.log("handleChangeIpv4Address called with value:",u.target.value),p(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:u.target.value}})},v=u=>{s&&console.log("handleChangeIpv6Address called with value:",u.target.value),V(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:u.target.value}})},a=u=>{s&&console.log("handleChangeMatterPort called with value:",u.target.value),P(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:u.target.value}})},o=u=>{s&&console.log("handleChangeMatterDiscriminator called with value:",u.target.value),f(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:u.target.value}})},d=u=>{s&&console.log("handleChangemMatterPasscode called with value:",u.target.value),y(u.target.value),m({id:w.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:u.target.value}})};return i?e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:n,onChange:I,children:[e.jsx(k,{value:"Debug",children:"Debug"}),e.jsx(k,{value:"Info",children:"Info"}),e.jsx(k,{value:"Notice",children:"Notice"}),e.jsx(k,{value:"Warn",children:"Warn"}),e.jsx(k,{value:"Error",children:"Error"}),e.jsx(k,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Te,{checked:b,onChange:H,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Mdns interface:"}),e.jsx(ge,{value:t,onChange:F,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Ipv4 address:"}),e.jsx(ge,{value:D,onChange:E,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Ipv6 address:"}),e.jsx(ge,{value:j,onChange:v,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Commissioning port:"}),e.jsx(ge,{value:R,onChange:a,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Commissioning discriminator:"}),e.jsx(ge,{value:_,onChange:o,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(we,{style:{padding:"0px",margin:"0px"},children:"Commissioning passcode:"}),e.jsx(ge,{value:X,onChange:d,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:i.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function An({matterbridgeInfo:i}){return i?e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(Z,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[" ",e.jsx(Oe,{value:i.matterbridgeVersion,label:"Current Version"}),e.jsx(Oe,{value:i.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Oe,{value:i.homeDirectory,label:"Home Directory"}),e.jsx(Oe,{value:i.rootDirectory,label:"Root Directory"}),e.jsx(Oe,{value:i.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Oe,{value:i.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Oe,{value:i.globalModulesDirectory,label:"Global Module Directory"})]})})]}):null}function Oe({value:i,label:m}){return e.jsx(ge,{focused:!0,value:i,size:"small",label:m,variant:"standard",sx:{width:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}const _n=r.memo(On);function qn(){const{online:i,sendMessage:m,addListener:c,removeListener:n,getUniqueId:l}=r.useContext(ve),{showSnackbarMessage:b,showInstallProgress:g,addInstallProgress:t}=r.useContext(Be),[x,D]=r.useState(null),[p,j]=r.useState([]),[V,R]=r.useState([]),[P,_]=r.useState(null),[f,X]=r.useState({cpuUsage:0}),[y,w]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[I,H]=r.useState({systemUptime:"",processUptime:""}),F=r.useRef(l());return console.log("Test uniqueId:",F),r.useEffect(()=>{console.log("Test useEffect WebSocketMessage mounting");const E=v=>{if(v.method==="restart_required")console.log("Test received restart_required"),b("Restart required",0);else if(v.method==="refresh_required")console.log(`Test received refresh_required: changed=${v.response.changed} and sending api requests`),b("Refresh required",0),m({id:F.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),m({id:F.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),m({id:F.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(v.method==="memory_update")console.log("Test received memory_update",v),w(v.response);else if(v.method==="cpu_update")console.log("Test received cpu_update",v),X(v.response);else if(v.method==="uptime_update")console.log("Test received uptime_update",v),H(v.response);else if(v.method==="/api/settings"&&v.response)console.log("Test received /api/settings:",v.response),b("Test received /api/settings",0),D(v.response);else if(v.method==="/api/plugins"&&v.response)console.log(`Test received ${v.response.length} plugins:`,v.response),b("Test received /api/plugins",0),j(v.response);else if(v.method==="/api/devices"&&v.response){console.log(`Test received ${v.response.length} devices:`,v.response),b("Test received /api/devices",0),R(v.response);for(const a of v.response)console.log("Test sending /api/clusters for device:",a.pluginName,a.name,a.endpoint),m({id:F.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:a.pluginName,endpoint:a.endpoint||0}})}else v.method==="/api/clusters"&&v.response&&(console.log(`Test received ${v.response.clusters.length} clusters for device ${v.response.deviceName} endpoint ${v.response.id}:${v.response.number}:`,v),b(`Test received /api/clusters for ${v.response.plugin}::${v.response.deviceName}`,0),_(v.response))};return c(E,F.current),console.log("Test useEffect WebSocketMessage mounted"),()=>{console.log("Test useEffect WebSocketMessage unmounting"),n(E),console.log("Test useEffect WebSocketMessage unmounted")}},[c,n,m,b]),r.useEffect(()=>(console.log("Test useEffect online mounting"),i&&console.log("Test useEffect online received online"),console.log("Test useEffect online mounted"),()=>{console.log("Test useEffect online unmounted")}),[i,m,b]),console.log("Test rendering..."),i?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(ie,{variant:"contained",onClick:()=>{g("example-package"),t("Starting installation...");for(const E of["Downloading package...","Extracting files...","Installing dependencies..."])t(E);for(let E=0;E<=500;E+=1)t(`Installing dependency package-dep${E}...`);t("Finalizing installation..."),t("Installation completed successfully.")},children:"Install"})]})}):e.jsx(Re,{})}const zn=r.memo(qn);function Un(i,m){s&&console.log("getCssVariable:",i,"defaultValue",m);const c=getComputedStyle(document.body).getPropertyValue(i).trim();return c||console.error("getCssVariable: undefined",c),c||m}function Bn(i){return Zr({palette:{primary:{main:i},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}let s=!1;const Qn=()=>{s=!s};function Kn({setLoggedIn:i}){const[m,c]=r.useState(""),[n,l]=r.useState(""),b={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},g={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)"},t={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)"},x=async p=>{try{const j=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:p})});if(j.ok){const{valid:V}=await j.json();V?i(!0):p!==""&&l("Incorrect password!")}else console.error("Failed to log in:",j.statusText)}catch(j){console.error("Failed to log in:",j)}},D=p=>{p.preventDefault(),x(m)};return x(""),e.jsx("div",{style:b,children:e.jsxs("form",{onSubmit:D,style:g,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:m,onChange:p=>c(p.target.value),style:t,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:n&&e.jsx("p",{style:{color:"red"},children:n})})]})})}function Jn(){const[i,m]=r.useState(!1);s&&console.log("Setting frontend theme");const c=localStorage.getItem("frontendTheme");s&&console.log("Saved theme:",c),c?document.body.setAttribute("frontend-theme",c):document.body.setAttribute("frontend-theme","dark");const n=Un("--primary-color","#1976d2");s&&console.log("Primary color from CSS:",n);const l=Bn(n),b=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return s&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${b}"`)),i?e.jsx(eo,{theme:l,children:e.jsx(cr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Ho,{children:e.jsx(Oo,{children:e.jsx(nr,{basename:b,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(Eo,{}),e.jsxs(ir,{children:[e.jsx(Ve,{path:"/",element:e.jsx(pn,{})}),e.jsx(Ve,{path:"/devices",element:e.jsx(Ln,{})}),e.jsx(Ve,{path:"/log",element:e.jsx(Tn,{})}),e.jsx(Ve,{path:"/settings",element:e.jsx(_n,{})}),e.jsx(Ve,{path:"/test",element:e.jsx(zn,{})}),e.jsx(Ve,{path:"*",element:e.jsx(sr,{to:"/"})})]})]})})})})})}):e.jsx(Kn,{setLoggedIn:m})}ar.createRoot(document.getElementById("root")).render(e.jsx(lr.StrictMode,{children:e.jsx(Jn,{})}));
|
|
1
|
+
import{B as e,y as o,Q as Ye,S as nr,U as ir,V as Ve,X as sr,Y as ar,H as lr}from"./vendor_node_modules.js";import{u as dr,S as cr}from"./vendor_notistack.js";import{D as Me,a as ke,b as Ie,B as ie,c as $e,d as X,A as pr,I as G,C as ur,T as F,S as gr,F as Vt,H as mr,e as Et,f as We,R as dt,P as He,M as hr,g as ze,h as k,L as z,i as re,j as Xe,V as et,k as Se,l as ht,m as fr,n as xr,o as ge,p as br,q as vr,r as ct,s as ae,t as Te,K as St,u as Mt,v as ut,w as tt,x as Ke,y as rt,W as Je,z as ot,E as nt,G as kt,J as It,N as yr,O as jr,Q as Cr,U as Fe,X as At,Y as vt,Z as wr,_ as Sr,$ as Mr,a0 as kr,a1 as _t,a2 as pt,a3 as Ir,a4 as Dr,a5 as Pr,a6 as Nr,a7 as Dt,a8 as Wr,a9 as Lr,aa as $r,ab as Fr,ac as Tr,ad as Rr,ae as Hr,af as Pt,ag as Or,ah as Vr,ai as Er,aj as Ar,ak as _r,al as qr,am as zr,an as Ur,ao as Br,ap as Qr,aq as Gr,ar as Kr,as as Jr,at as Zr,au as Yr,av as Nt,aw as Ue,ax as qt,ay as Ce,az as zt,aA as gt,aB as Le,aC as Xr,aD as eo}from"./vendor_mui.js";import{Q as to}from"./vendor_qrcode.js";import{I as ne,m as Wt,a as ro,b as oo,c as Lt,d as no,e as io,f as so,g as ao,h as lo,i as co,j as po,k as uo,l as go,n as mo,o as ho,p as fo,q as $t,r as xo,s as bo,t as vo,u as yo,v as jo,w as Co,x as wo,y as So,z as Ft,A as Mo,B as ko}from"./vendor_mdi.js";import{F as Io,v as Do,e as Po,a as No,g as Wo,b as Lo,c as $o,d as ft,A as Fo}from"./vendor_rjsf.js";import"./vendor_lodash.js";import"./vendor_emotion.js";(function(){const g=document.createElement("link").relList;if(g&&g.supports&&g.supports("modulepreload"))return;for(const l of document.querySelectorAll('link[rel="modulepreload"]'))i(l);new MutationObserver(l=>{for(const b of l)if(b.type==="childList")for(const p of b.addedNodes)p.tagName==="LINK"&&p.rel==="modulepreload"&&i(p)}).observe(document,{childList:!0,subtree:!0});function c(l){const b={};return l.integrity&&(b.integrity=l.integrity),l.referrerPolicy&&(b.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?b.credentials="include":l.crossOrigin==="anonymous"?b.credentials="omit":b.credentials="same-origin",b}function i(l){if(l.ep)return;l.ep=!0;const b=c(l);fetch(l.href,b)}})();function To({open:s,title:g,message:c,onConfirm:i,onCancel:l}){const b=t=>{r&&console.log("Confirmed"),t.preventDefault(),i()},p=t=>{r&&console.log("Canceled"),t.preventDefault(),l()};return e.jsxs(Me,{open:s,children:[e.jsx(ke,{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:g})]})}),e.jsxs(Ie,{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:c})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(ie,{onClick:b,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ie,{onClick:p,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const Ro=({open:s,output:g,packageName:c,onInstall:i,onClose:l})=>{const b=o.useRef(null);return o.useEffect(()=>{r&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${b.current}`),setTimeout(()=>{r&&console.log("Scrolling to bottom:",b.current),b.current?.scrollIntoView({behavior:"smooth"})},0)},[g]),e.jsxs(Me,{open:s,onClose:(p,t)=>{t==="backdropClick"||t==="escapeKeyDown"||l()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx(ke,{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.jsxs("h4",{style:{margin:0},children:["Install",i?"":"ing"," package ",c]})]})}),e.jsxs(Ie,{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:"Install log"}),e.jsxs("ul",{style:{width:"100%",height:"100%",fontFamily:"monospace",fontSize:"14px",padding:8,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:[g.split(`
|
|
2
|
+
`).map((p,t)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:p},t)),e.jsx("li",{ref:b,style:{padding:0,margin:0}})]})]}),e.jsxs($e,{children:[i&&e.jsx(ie,{variant:"contained",onClick:i,children:"Install"}),e.jsx(ie,{onClick:l,children:"Close"})]})]})},it=[],Be=o.createContext(null);function Ho({children:s}){const{enqueueSnackbar:g,closeSnackbar:c}=dr(),i=o.useCallback(te=>{r&&console.log(`UiProvider closeSnackbarMessage: message ${te}`);const Y=it.findIndex(xe=>xe.message===te);Y!==-1&&(c(it[Y].key),it.splice(Y,1),r&&console.log(`UiProvider closeSnackbarMessage: message ${te} removed from persistMessages`))},[c]),l=o.useCallback((te,Y,xe)=>{r&&console.log(`UiProvider showSnackbarMessage: message ${te} timeout ${Y}`);const U=g(te,{variant:"default",autoHideDuration:Y==null||Y>0?(Y??5)*1e3:null,persist:Y===0,content:oe=>e.jsx(X,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(pr,{severity:xe??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>c(oe),action:e.jsx(G,{size:"small",onClick:()=>c(oe),sx:{color:"#fff"},children:e.jsx(ur,{fontSize:"small"})}),children:te},oe)},oe)});Y===0&&(r&&console.log(`UiProvider showSnackbarMessage: message ${te} timeout ${Y} - persist key ${U}`),it.push({message:te,key:U}))},[g,c]),[b,p]=o.useState(!1),[t,w]=o.useState(""),[j,m]=o.useState(""),[y,V]=o.useState(""),H=o.useRef(null),I=o.useRef(null),K=()=>{r&&console.log(`UiProvider handle confirm action ${y}`),p(!1),H.current&&H.current(y)},f=()=>{r&&console.log(`UiProvider handle cancel action ${y}`),p(!1),I.current&&I.current(y)},O=o.useCallback((te,Y,xe,U,oe)=>{r&&console.log(`UiProvider showConfirmCancelDialog for command ${xe}`),w(te),m(Y),V(xe),H.current=U,I.current=oe,p(!0)},[]),[x,N]=o.useState(!1),[L,R]=o.useState(""),[v,_]=o.useState(""),T=o.useCallback(te=>{r&&console.log(`UiProvider show install progress for package ${te}`),R(te),_(`Starting installation of ${te}...
|
|
3
|
+
`),N(!0)},[]),a=o.useCallback(te=>{r&&console.log(`UiProvider addInstallProgress: output ${te}`),_(Y=>Y+te+`
|
|
4
|
+
`)},[]),n=o.useCallback(()=>{r&&console.log(`UiProvider exitInstallProgressSuccess: package ${L}`),_(te=>te+`Successfully installed ${L}
|
|
5
|
+
`)},[L]),d=o.useCallback(()=>{r&&console.log(`UiProvider exitInstallProgressError: package ${L}`),_(te=>te+`Failed to install ${L}
|
|
6
|
+
`)},[L]),u=o.useCallback(()=>{r&&console.log("UiProvider hide install progress"),N(!1)},[]),$=()=>{r&&console.log("UiProvider handle install close action"),N(!1),R(""),_("")},pe=o.useMemo(()=>({showSnackbarMessage:l,closeSnackbarMessage:i,closeSnackbar:c,showConfirmCancelDialog:O,showInstallProgress:T,exitInstallProgressSuccess:n,exitInstallProgressError:d,hideInstallProgress:u,addInstallProgress:a}),[l,i,c,O,T,n,d,u,a]);return e.jsxs(Be.Provider,{value:pe,children:[e.jsx(To,{open:b,title:t,message:j,onConfirm:K,onCancel:f}),e.jsx(Ro,{open:x,packageName:L,output:v,onClose:$}),s]})}const Ut=o.createContext(null),ve=o.createContext(null);function Oo({children:s}){const[g,c]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[i,l]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[b,p]=o.useState([]),[t,w]=o.useState(1e3),[j,m]=o.useState(!0),[y,V]=o.useState(!1),{showSnackbarMessage:H,closeSnackbarMessage:I,closeSnackbar:K,showInstallProgress:f,hideInstallProgress:O,exitInstallProgressSuccess:x,exitInstallProgressError:N,addInstallProgress:L}=o.useContext(Be),R=o.useRef([]),v=o.useRef(null),_=o.useRef(1),T=o.useRef(Math.floor(Math.random()*999e3)+1e3),a=o.useRef(null),n=o.useRef(null),d=o.useRef(null),u=o.useRef(g),$=o.useRef(i),pe=o.useRef(0),te=o.useRef(null),Y=o.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),xe=o.useMemo(()=>window.location.href.includes("api/hassio_ingress"),[]),U=100,oe=60,W=50,B=300,D=10;o.useEffect(()=>(r&&console.log("WebSocket messages started counter interval"),te.current=setInterval(()=>{pe.current>0&&(r&&console.log(`WebSocket messages received in the last ${D} seconds: ${pe.current*(60/D)} messages/minute`),pe.current=0)},D*1e3),()=>{r&&console.log("WebSocket messages stopped counter interval"),te.current&&clearInterval(te.current),te.current=null}),[]),o.useEffect(()=>{u.current=g},[g]),o.useEffect(()=>{$.current=i},[i]);const P=o.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),C=o.useCallback(Z=>{if(v.current&&v.current.readyState===WebSocket.OPEN)try{r&&console.log(`WebSocket sending message with id ${Z.id}:`,Z),Z.id===void 0&&(Z.id=T.current);const h=JSON.stringify(Z);v.current.send(h),r&&console.log("WebSocket sent message:",Z)}catch(h){r&&console.error(`WebSocket error sending message: ${h}`)}else r&&console.error("WebSocket message not sent, WebSocket not connected:",Z)},[]),M=o.useCallback((Z,h)=>{p(fe=>[...fe,{level:Z,time:"",name:"",message:h}])},[]),E=o.useCallback((Z,h)=>{c(Z),l(h),M("WebSocket",`Filtering by log level "${Z}" and log search "${h}"`)},[M]),ee=o.useCallback((Z,h)=>{r&&console.log(`WebSocket addListener id ${h}:`,Z),(h==null||isNaN(h)||h===0)&&console.error("WebSocket addListener called without id, listener not added:",Z),R.current=[...R.current,{listener:Z,id:h}],r&&console.log("WebSocket addListener total listeners:",R.current.length)},[]),ce=o.useCallback(Z=>{r&&console.log("WebSocket removeListener:",Z),R.current=R.current.filter(h=>h.listener!==Z),r&&console.log("WebSocket removeListener total listeners:",R.current.length)},[]),le=o.useCallback(()=>{Y===""||Y===null||Y===void 0||(M("WebSocket",`Connecting to WebSocket: ${Y}`),v.current=new WebSocket(Y),v.current.onmessage=Z=>{y||V(!0),pe.current+=1;try{const h=JSON.parse(Z.data);if(h.id===void 0||h.src===void 0||h.dst===void 0){r&&console.error("WebSocket undefined message id/src/dst:",h);return}if(h.src!=="Matterbridge"||h.dst!=="Frontend"){r&&console.error("WebSocket invalid message src/dst:",h);return}if(h.error){r&&console.error("WebSocket error message response:",h);return}if(h.id===T.current&&h.method==="pong"&&h.response==="pong"){r&&console.log(`WebSocket pong response message id ${h.id}:`,h),n.current&&clearTimeout(n.current),n.current=null;return}else if(h.method==="snackbar"&&h.response&&h.response.message){r&&console.log(`WebSocket message id ${h.id} method ${h.method}:`,h),H(h.response.message,h.response.timeout,h.response.severity);return}else if(h.method==="close_snackbar"&&h.response&&h.response.message){r&&console.log(`WebSocket message id ${h.id} method ${h.method}:`,h),I(h.response.message);return}else if(h.method==="log"){if(!h.response||!h.response.level||!h.response.time||!h.response.name||!h.response.message||(h.response.level==="spawn"&&(h.response.name==="Matterbridge:spawn-init"?f(h.response.message):h.response.name==="Matterbridge:spawn-exit-success"?x():h.response.name==="Matterbridge:spawn-exit-error"?N():L(h.response.message+`
|
|
7
|
+
`)),["debug","info","notice","warn","error","fatal"].includes(h.response.level)&&(u.current==="info"&&h.response.level==="debug"||u.current==="notice"&&(h.response.level==="debug"||h.response.level==="info")||u.current==="warn"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice")||u.current==="error"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice"||h.response.level==="warn")||u.current==="fatal"&&(h.response.level==="debug"||h.response.level==="info"||h.response.level==="notice"||h.response.level==="warn"||h.response.level==="error")))||$.current!=="*"&&$.current!==""&&!h.response.message.toLowerCase().includes($.current.toLowerCase())&&!h.response.name.toLowerCase().includes($.current.toLowerCase())||h.response.name==="Commissioning"&&h.response.message.includes("is uncommissioned"))return;p(be=>{const me=[...be,{level:h.response.level,time:h.response.time,name:h.response.name,message:h.response.message}];return me.length>t*2?me.slice(t):me})}else{if(r&&console.log(`WebSocket received message id ${h.id} method ${h.method}:`,h),h.id===0)R.current.forEach(fe=>fe.listener(h));else{const fe=R.current.find(be=>be.id===h.id);fe?fe.listener(h):r&&console.debug(`WebSocket no listener found for message id ${h.id}:`,h)}return}}catch(h){console.error(`WebSocketUse error parsing message: ${h}`)}},v.current.onopen=()=>{r&&console.log(`WebSocket: Connected to WebSocket: ${Y}`),M("WebSocket",`Connected to WebSocket: ${Y}`),V(!0),K(),_.current=1,d.current=setTimeout(()=>{a.current=setInterval(()=>{C({id:T.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),n.current&&clearTimeout(n.current),n.current=setTimeout(()=>{r&&console.error(`WebSocketUse: No pong response received from WebSocket: ${Y}`),M("WebSocket",`No pong response received from WebSocket: ${Y}`),V(!1)},1e3*W)},1e3*oe)},1e3*B)},v.current.onclose=()=>{r&&console.error(`WebSocket: Disconnected from WebSocket ${xe?"with Ingress":""}: ${Y}`),M("WebSocket",`Disconnected from WebSocket: ${Y}`),V(!1),K(),O(),d.current&&clearTimeout(d.current),n.current&&clearTimeout(n.current),a.current&&clearInterval(a.current),M("WebSocket",`Reconnecting (attempt ${_.current} of ${U}) to WebSocket${xe?" (Ingress)":""}: ${Y}`),xe?setTimeout(de,5e3):_.current===1?de():_.current<U?setTimeout(de,1e3*_.current):M("WebSocket",`Reconnect attempts exceeded limit of ${U} retries, refresh the page to reconnect to: ${Y}`),_.current=_.current+1},v.current.onerror=Z=>{r&&console.error(`WebSocket: WebSocket error connecting to ${Y}:`,Z),M("WebSocket",`WebSocket error connecting to ${Y}`)})},[Y]),de=o.useCallback(()=>{r&&console.log(`WebSocket attemptReconnect ${_.current}/${U} to:`,Y),le()},[le]);o.useEffect(()=>(le(),()=>{v.current&&v.current.readyState===WebSocket.OPEN&&v.current.close()}),[le]);const A=o.useMemo(()=>({messages:b,maxMessages:t,autoScroll:j,setMessages:p,setLogFilters:E,setMaxMessages:w,setAutoScroll:m}),[b,p,E]),se=o.useMemo(()=>({maxMessages:t,autoScroll:j,logFilterLevel:g,logFilterSearch:i,setMessages:p,setLogFilters:E,setMaxMessages:w,setAutoScroll:m,online:y,retry:_.current,getUniqueId:P,addListener:ee,removeListener:ce,sendMessage:C,logMessage:M}),[t,j,p,E,w,m,y,_.current,ee,ce,C,M]);return e.jsx(Ut.Provider,{value:A,children:e.jsx(ve.Provider,{value:se,children:s})})}function Vo(){const{showSnackbarMessage:s,showConfirmCancelDialog:g}=o.useContext(Be),{online:c,sendMessage:i,logMessage:l,addListener:b,removeListener:p,getUniqueId:t}=o.useContext(ve),[w,j]=o.useState(!1),[m,y]=o.useState(!1),[V,H]=o.useState(!1),[I,K]=o.useState(!1),[f,O]=o.useState(null),x=o.useRef(t()),[N,L]=o.useState(null),[R,v]=o.useState(null),[_,T]=o.useState(null),[a,n]=o.useState(null),[d,u]=o.useState(null),$=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},pe=()=>{window.open("https://github.com/Luligu/matterbridge/blob/main/README.md","_blank")},te=()=>{f?.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")},Y=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},xe=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},U=()=>{i({id:x.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}})},oe=()=>{i({id:x.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}})},W=()=>{i({id:x.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},B=()=>{r&&console.log("Header: handleShellySystemUpdateClick"),l("Matterbridge","Installing system updates..."),i({id:x.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},D=()=>{r&&console.log("Header: handleShellyMainUpdateClick"),l("Matterbridge","Installing software updates..."),i({id:x.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},P=()=>{r&&console.log("Header: handleShellyCreateSystemLog"),i({id:x.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},C=()=>{r&&console.log("Header: handleShellyDownloadSystemLog"),l("Matterbridge","Downloading Shelly system log..."),s("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},M=()=>{f?.matterbridgeInformation.restartMode===""?i({id:x.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):i({id:x.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},E=()=>{i({id:x.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},ee=()=>{i({id:x.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},ce=()=>{i({id:x.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},le=()=>{i({id:x.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},de=Q=>{L(Q.currentTarget)},A=Q=>{r&&console.log("Header: handleMenuClose",Q),L(null),Q==="download-mblog"?(l("Matterbridge","Downloading matterbridge log..."),s("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):Q==="download-mjlog"?(l("Matterbridge","Downloading matter log..."),s("Downloading matter log...",5),window.location.href="./api/download-mjlog"):Q==="view-mblog"?(l("Matterbridge","Loading matterbridge log..."),s("Loading matterbridge log...",5),window.location.href="./api/view-mblog"):Q==="view-mjlog"?(l("Matterbridge","Loading matter log..."),s("Loading matter log...",5),window.location.href="./api/view-mjlog"):Q==="view-shellylog"?(l("Matterbridge","Loading shelly system log..."),s("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):Q==="download-mbstorage"?(l("Matterbridge","Downloading matterbridge storage..."),s("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):Q==="download-pluginstorage"?(l("Matterbridge","Downloading matterbridge plugins storage..."),s("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):Q==="download-pluginconfig"?(l("Matterbridge","Downloading matterbridge plugins config..."),s("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):Q==="download-mjstorage"?(l("Matterbridge","Downloading matter storage..."),s("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):Q==="download-backup"?(l("Matterbridge","Downloading backup..."),s("Downloading backup...",10),window.location.href="./api/download-backup"):Q==="update"?U():Q==="updatedev"?oe():Q==="updatecheck"?W():Q==="shelly-sys-update"?B():Q==="shelly-main-update"?D():Q==="shelly-create-system-log"?P():Q==="shelly-download-system-log"?C():Q==="softreset"?ce():Q==="hardreset"?le():Q==="restart"?M():Q==="shutdown"?E():Q==="reboot"?ee():Q==="create-backup"?i({id:x.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="unregister"?i({id:x.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="reset"?i({id:x.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):Q==="factoryreset"&&i({id:x.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},se=Q=>{r&&console.log("Header: handleMenuCloseCancel:",Q),L(null)},Z=Q=>{v(Q.currentTarget)},h=()=>{v(null)},fe=Q=>{T(Q.currentTarget)},be=()=>{T(null)},me=Q=>{n(Q.currentTarget)},J=()=>{n(null)},ue=Q=>{u(Q.currentTarget)},je=()=>{u(null)},Qe=()=>{Gn(),r&&console.log("Matterbridge logo clicked: debug is now",r)};return o.useEffect(()=>{const Q=S=>{r&&console.log("Header received WebSocket Message:",S),S.method==="/api/settings"&&S.id===x.current?(r&&console.log("Header received settings:",S.response),O(S.response),j(S.response.matterbridgeInformation.restartRequired||S.response.matterbridgeInformation.fixedRestartRequired),y(S.response.matterbridgeInformation.fixedRestartRequired),H(S.response.matterbridgeInformation.updateRequired)):S.method==="refresh_required"&&S.response.changed==="settings"?(r&&console.log(`Header received refresh_required: changed=${S.response.changed} and sending /api/settings request`),i({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):S.method==="restart_required"?(r&&console.log(`Header received restart_required with fixed: ${S.response.fixed}`),j(!0),S.response.fixed===!0&&y(!0)):S.method==="restart_not_required"?(r&&console.log("Header received restart_not_required"),j(!1)):S.method==="update_required"?(r&&console.log("Header received update_required"),S.response.devVersion===!0?K(!0):H(!0),i({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):S.method==="shelly_sys_update"?(r&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),O(he=>he?{matterbridgeInformation:{...he.matterbridgeInformation,shellySysUpdate:S.response.available},systemInformation:he.systemInformation}:null)):S.method==="shelly_main_update"&&(r&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),O(he=>he?{matterbridgeInformation:{...he.matterbridgeInformation,shellyMainUpdate:S.response.available},systemInformation:he.systemInformation}:null))};return b(Q,x.current),r&&console.log(`Header added WebSocket listener id ${x.current}`),()=>{p(Q),r&&console.log("Header removed WebSocket listener")}},[b,p,i,s]),o.useEffect(()=>{c&&(r&&console.log("Header sending /api/settings requests"),i({id:x.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,i]),r&&console.log("Header rendering..."),!c||!f?null:e.jsxs("div",{className:"header",children:[e.jsxs("div",{className:"sub-header",children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:Qe}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"}),e.jsxs("nav",{children:[e.jsx(Ye,{to:"/",className:"nav-link",children:"Home"}),e.jsx(Ye,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(Ye,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(Ye,{to:"/settings",className:"nav-link",children:"Settings"})]})]}),e.jsxs("div",{className:"sub-header",children:[!f.matterbridgeInformation.readOnly&&V&&e.jsx(F,{title:"New Matterbridge version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:U,children:["Update to v.",f.matterbridgeInformation.matterbridgeLatestVersion]})}),!f.matterbridgeInformation.readOnly&&I&&e.jsx(F,{title:"New Matterbridge dev version available, click to install",children:e.jsxs("span",{className:"status-warning",onClick:oe,children:["Update to new dev v.",f.matterbridgeInformation.matterbridgeDevVersion.split("-dev-")[0]]})}),!f.matterbridgeInformation.readOnly&&e.jsx(F,{title:"Matterbridge version, click to see the changelog",children:e.jsxs("span",{className:"status-information",onClick:te,children:["v.",f.matterbridgeInformation.matterbridgeVersion]})}),f.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),f.matterbridgeInformation.bridgeMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(F,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.bridgeMode})}):null,f.matterbridgeInformation.restartMode!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(F,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.restartMode})}):null,f.matterbridgeInformation.profile&&f.matterbridgeInformation.profile!==""&&f.matterbridgeInformation.readOnly===!1?e.jsx(F,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.profile})}):null]}),e.jsxs("div",{className:"sub-header",style:{gap:"5px"},children:[f.matterbridgeInformation.readOnly===!1?e.jsx(F,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:Y})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(F,{title:"Give a star to Matterbridge",children:e.jsx(G,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:xe,children:e.jsx(gr,{})})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(F,{title:"Sponsor Matterbridge",children:e.jsx(G,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:$,children:e.jsx(Vt,{})})}):null,e.jsx(F,{title:"Matterbridge help",children:e.jsx(G,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:pe,children:e.jsx(mr,{})})}),e.jsx(F,{title:"Matterbridge changelog",children:e.jsx(G,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:te,children:e.jsx(Et,{})})}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsx(F,{title:"Update matterbridge to latest version",children:e.jsx(G,{style:{color:V?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:U,children:e.jsx(We,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsx(F,{title:"Shelly system update",children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:B,children:e.jsx(We,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsx(F,{title:"Shelly software update",children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:D,children:e.jsx(We,{})})}),e.jsx(F,{title:"Restart matterbridge",children:e.jsx(G,{style:{color:w||m?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:M,children:e.jsx(dt,{})})}),f.matterbridgeInformation.restartMode===""?e.jsx(F,{title:"Shut down matterbridge",children:e.jsx(G,{style:{color:w||m?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:E,children:e.jsx(He,{})})}):null,e.jsx(F,{title:"Download, backup and more",children:e.jsx(G,{onClick:de,children:e.jsx(hr,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(ze,{id:"command-menu",anchorEl:N,keepMounted:!0,open:!!N,onClose:()=>A(""),children:[f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>A("update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>A("updatedev"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>A("updatecheck"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsxs(k,{onClick:()=>A("shelly-sys-update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsxs(k,{onClick:()=>A("shelly-main-update"),children:[e.jsx(z,{children:e.jsx(We,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>A("restart"),children:[e.jsx(z,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation.restartMode===""?e.jsxs(k,{onClick:()=>A("shutdown"),children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{g("Reboot","Are you sure you want to reboot the Shelly board?","reboot",A,se)},children:[e.jsx(z,{children:e.jsx(dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(Xe,{}),e.jsxs(k,{onClick:fe,children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-view",anchorEl:_,keepMounted:!0,open:!!_,onClose:be,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{A("view-mblog"),be()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("view-mjlog"),be()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{A("view-shellylog"),be()},children:[e.jsx(z,{children:e.jsx(et,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Xe,{}),e.jsxs(k,{onClick:me,children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-download",anchorEl:a,keepMounted:!0,open:!!a,onClose:J,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{A("download-mbstorage"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-pluginstorage"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-pluginconfig"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-mblog"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-mjstorage"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-mjlog"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{A("shelly-create-system-log"),J()},children:[e.jsx(z,{children:e.jsx(Se,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{A("shelly-download-system-log"),J()},children:[e.jsx(z,{children:e.jsx(Se,{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(Xe,{}),e.jsxs(k,{onClick:Z,children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-backup",anchorEl:R,keepMounted:!0,open:!!R,onClose:h,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{A("create-backup"),h()},children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{A("download-backup"),h()},children:[e.jsx(z,{children:e.jsx(ht,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Xe,{}),e.jsxs(k,{onClick:ue,children:[e.jsx(z,{children:e.jsx(fr,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(ze,{id:"sub-menu-reset",anchorEl:d,keepMounted:!0,open:!!d,onClose:je,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(k,{onClick:()=>{je(),g("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,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(k,{onClick:()=>{je(),g("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,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!f.matterbridgeInformation.readOnly&&e.jsxs(k,{onClick:()=>{je(),g("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,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{je(),g("Network reset","Are you sure you want to factory reset the network parameters?","softreset",A,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(k,{onClick:()=>{je(),g("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",A,se)},children:[e.jsx(z,{children:e.jsx(He,{style:{color:"var(--main-icon-color)"}})}),e.jsx(re,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const Eo=o.memo(Vo),Ao=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(r&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(r&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function _o(){const{messages:s,autoScroll:g}=o.useContext(Ut),[c,i]=o.useState(!1),l=o.useRef(null),b=o.useMemo(()=>Ao(),[]),p=m=>i(!0),t=m=>i(!1);o.useEffect(()=>{r&&console.log(`WebSocketLogs autoScroll: ${g} isHovering: ${c}`),g&&!c&&!b&&l.current?.scrollIntoView({behavior:"smooth"})},[s,c,g,b]);const w=m=>{switch(m.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"}},j=m=>{switch(m.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:t,children:[s.map((m,y)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:w(m.level),color:j(m.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:m.level}),m.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+m.time+"]"}),m.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+m.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:m.message})]},y)),e.jsx("div",{ref:l})]})})}const Bt=o.memo(_o);function qo(s){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",...s,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 Re(){const{retry:s}=o.useContext(ve),g=()=>{window.location.reload()};return e.jsx("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",fontSize:"20px",flexDirection:"column",color:"var(--main-text-color)",height:"100vh",backgroundColor:"var(--main-bg-color)"},children:e.jsxs(X,{sx:{display:"flex",alignItems:"center",flexDirection:"column"},children:[e.jsx(qo,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),s<100?e.jsxs(e.Fragment,{children:[e.jsx(xr,{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 "+s+")","..."]})})]}):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:g,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})})}function zo({value:s,maxChars:g}){let c=s;if(s.length>g&&g>3){const i=g-3,l=s.substring(0,Math.ceil(i/2)),b=s.substring(s.length-Math.floor(i/2),s.length);c=`${l} … ${b}`}return s!==c?e.jsx(F,{title:s,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:c})}):e.jsx("span",{children:c})}function Uo({systemInfo:s,compact:g}){const{sendMessage:c,addListener:i,removeListener:l,getUniqueId:b}=o.useContext(ve),[p,t]=o.useState(s),w=o.useRef(b());if(r&&console.log("SystemInfoTable:",p,"compact:",g),s&&g&&p.totalMemory&&p.freeMemory){const j=p.totalMemory,m=p.freeMemory;p.freeMemory=`${m} / ${j}`,p.totalMemory=""}if(s&&g&&p.heapTotal&&p.heapUsed){const j=p.heapTotal,m=p.heapUsed;p.heapUsed=`${m} / ${j}`,p.heapTotal=""}if(s&&g&&p.osRelease&&p.osType){const j=p.osType,m=p.osRelease;p.osType=`${j} (${m})`,p.osRelease=""}if(s&&g&&p.osArch&&p.osPlatform){const j=p.osPlatform,m=p.osArch;p.osPlatform=`${j} (${m})`,p.osArch=""}return o.useEffect(()=>{const j=m=>{m.src==="Matterbridge"&&m.dst==="Frontend"&&(m.method==="memory_update"&&m.response&&m.response.totalMemory&&m.response.freeMemory&&m.response.heapTotal&&m.response.heapUsed&&m.response.rss&&(r&&console.log("SystemInfoTable received memory_update",m),(p.totalMemory!==m.response.totalMemory||p.freeMemory!==m.response.freeMemory||p.heapTotal!==m.response.heapTotal||p.heapUsed!==m.response.heapUsed||p.rss!==m.response.rss)&&t(y=>({...y,totalMemory:m.response.totalMemory,freeMemory:m.response.freeMemory,heapTotal:m.response.heapTotal,heapUsed:m.response.heapUsed,rss:m.response.rss}))),m.method==="cpu_update"&&m.response&&m.response.cpuUsage&&(r&&console.log("SystemInfoTable received cpu_update",m),p.cpuUsage!==(m.response.cpuUsage?m.response.cpuUsage.toFixed(2)+" %":"")&&t(y=>({...y,cpuUsage:m.response.cpuUsage.toFixed(2)+" %"}))),m.method==="uptime_update"&&m.response&&m.response.systemUptime&&m.response.processUptime&&(r&&console.log("SystemInfoTable received uptime_update",m),(p.systemUptime!==m.response.systemUptime||p.processUptime!==m.response.processUptime)&&t(y=>({...y,systemUptime:m.response.systemUptime,processUptime:m.response.processUptime}))))};return r&&console.log("SystemInfoTable useEffect WebSocketMessage mounting"),i(j,w.current),r&&console.log("SystemInfoTable useEffect WebSocketMessage mounted"),()=>{r&&console.log("SystemInfoTable useEffect WebSocketMessage unmounting"),l(j),r&&console.log("SystemInfoTable useEffect WebSocketMessage unmounted")}},[i,p.cpuUsage,p.freeMemory,p.heapTotal,p.heapUsed,p.processUptime,p.rss,p.systemUptime,p.totalMemory,l,c]),p?(r&&console.log("SystemInfoTable rendering..."),e.jsxs("div",{className:"MbfWindowDiv",style:{minWidth:"302px",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"System Information"})}),e.jsx("div",{className:"MbfWindowDivTable",children:e.jsx("table",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(p).filter(([j,m])=>m!==void 0&&m!=="").map(([j,m],y)=>e.jsxs("tr",{className:y%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:j}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse"},children:e.jsx(zo,{value:typeof m!="string"?m.toString():m,maxChars:25})})]},j))})})})]})):null}const Bo=o.memo(Uo),Tt={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"}},Qo=s=>{if(!s)return"";const g=s.toString().replace(/[^0-9]/g,"");if(g.length<5)return g;const c=g.slice(0,4),i=g.slice(4,7),l=g.slice(7,11);return[c,i,l].filter(Boolean).join("-")};function Go({id:s}){const{online:g,sendMessage:c,addListener:i,removeListener:l,getUniqueId:b}=o.useContext(ve),[p,t]=o.useState(null),w=o.useRef(null),j=o.useRef(null),m=o.useRef(b()),{showConfirmCancelDialog:y}=o.useContext(Be);r&&console.log(`QRDiv loading with id = "${s}" storeId = "${w.current}" timeout = ${j.current} and matter:`,p),o.useEffect(()=>{r&&console.log(`QRDiv id effect "${s}"`),w.current=s,j.current&&clearTimeout(j.current),j.current=null,s?(r&&console.log(`QRDiv id effect sending data request for storeId "${s}"`),c({id:m.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:s,server:!0}})):(r&&console.log("QRDiv id effect setting matter to null"),t(null))},[s,c]),o.useEffect(()=>{const O=x=>{x.method==="refresh_required"&&x.response.changed==="matter"&&x.response.matter&&(r&&console.log(`QRDiv received refresh_required: changed=${x.response.changed} for storeId "${x.response.matter.id}":`,x.response.matter),w.current===x.response.matter.id&&(r&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${x.response.matter.id}":`,x.response.matter),j.current&&clearTimeout(j.current),x.response.matter.advertising&&x.response.matter.advertiseTime&&x.response.matter.advertiseTime+9e5<=Date.now()&&(x.response.matter.advertising=!1),t(x.response.matter),x.response.matter.advertising&&(r&&console.log(`QRDiv setting matter advertise timeout for storeId "${x.response.matter.id}":`,x.response.matter.advertiseTime+9e5-Date.now()),j.current=setTimeout(()=>{j.current&&clearTimeout(j.current),r&&console.log(`QRDiv clearing advertising state for storeId "${w.current}" after 15 minutes`),t(N=>N&&{...N,advertising:!1})},x.response.matter.advertiseTime+9e5-Date.now()))))};return i(O,m.current),r&&console.log("QRDiv webSocket effect mounted"),()=>{l(O),j.current&&clearTimeout(j.current),j.current=null,r&&console.log("QRDiv webSocket effect unmounted")}},[i,l]);const V=()=>{r&&console.log(`QRDiv sent matter startCommission for node "${p?.id}"`),p&&c({id:m.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,startCommission:!0}})},H=()=>{r&&console.log(`QRDiv sent matter stopCommission for node "${p?.id}"`),p&&c({id:m.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,stopCommission:!0}})},I=()=>{r&&console.log(`QRDiv sent matter advertise for node "${p?.id}"`),p&&c({id:m.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,advertise:!0}})},K=O=>{r&&console.log(`QRDiv sent matter removeFabric for node "${p?.id}" and fabricIndex ${O}`),p&&c({id:m.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:p.id,removeFabric:O}})},f=async()=>{if(!p||!p.manualPairingCode)return;const O=p.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(O);else{const x=document.createElement("textarea");x.value=O,x.style.position="fixed",x.style.opacity="0",document.body.appendChild(x),x.focus(),x.select(),document.execCommand("copy"),document.body.removeChild(x)}r&&console.log("Manual pairing code copied to clipboard")}catch(x){console.error("Failed to copy manual pairing code",x)}};return!p||!g?(r&&console.log("QRDiv rendering undefined state"),null):p.online?p.advertising&&p.qrPairingCode&&p.manualPairingCode?(r&&console.log("QRDiv rendering advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(G,{"aria-label":"send advertising",size:"small",onClick:I,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(F,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Wt,size:"22px"})})}),e.jsx(G,{"aria-label":"stop pairing",size:"small",onClick:H,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(F,{title:"Turn off pairing",arrow:!0,children:e.jsx(ne,{path:ro,size:"22px"})})})]})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:w.current}),e.jsx(to,{value:p.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs("div",{className:"MbfWindowFooter",style:{justifyContent:"space-between"},children:[e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",Qo(p.manualPairingCode)]}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(F,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(G,{"aria-label":"copy manual pairing code",size:"small",onClick:f,sx:Tt,children:e.jsx(ne,{path:oo,size:.85})})})})]})]})):p.commissioned&&p.fabricInformations&&p.sessionInformations?(r&&console.log("QRDiv rendering commissioned state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Paired fabrics"}),e.jsxs("div",{className:"MbfWindowHeaderFooterIcons",children:[e.jsx(G,{"aria-label":"send advertising",size:"small",onClick:I,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(F,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(ne,{path:Wt,size:"22px"})})}),e.jsx(G,{"aria-label":"start pairing",size:"small",onClick:V,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(F,{title:"Turn on pairing",arrow:!0,children:e.jsx(ne,{path:Lt,size:"22px"})})})]})]}),e.jsxs("div",{className:"MbfWindowBodyColumn",style:{paddingTop:"0px"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:w.current}),p.fabricInformations.map((O,x)=>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: ",O.fabricIndex]}),e.jsx(F,{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:()=>y("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>K(O.fabricIndex),()=>{}),sx:{...Tt,padding:"2px"},children:e.jsx(ne,{path:no,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",O.rootVendorId," ",O.rootVendorName]}),O.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",O.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",p.sessionInformations?p.sessionInformations.filter(N=>N.fabric?.fabricIndex===O.fabricIndex&&N.isPeerActive===!0).length:"0"," ","subscriptions: ",p.sessionInformations?p.sessionInformations.filter(N=>N.fabric?.fabricIndex===O.fabricIndex&&N.isPeerActive===!0&&N.numberOfActiveSubscriptions>0).length:"0"]})]},x))]}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",p.serialNumber]})})]})):!p.commissioned&&!p.advertising?(r&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsx("div",{className:"MbfWindowHeader",style:{height:"30px"},children:e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"QR pairing code"})}),e.jsx("p",{className:"MbfWindowHeaderText",style:{maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:w.current}),e.jsx(ie,{onClick:V,endIcon:e.jsx(ne,{path:Lt,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",p.serialNumber]})})]})):(r&&console.log("QRDiv rendering unknown state"),null):(r&&console.log("QRDiv rendering offline state"),e.jsxs("div",{className:"MbfWindowDiv",style:{alignItems:"center",minWidth:"302px"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",style:{textAlign:"left"},children:"Server node"}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons"})]}),e.jsx("p",{className:"MbfWindowHeaderText",style:{maxWidth:"280px",textAlign:"center",fontSize:"14px",fontWeight:"bold",color:"var(--secondary-color)"},children:w.current}),e.jsx("p",{style:{textAlign:"center",fontSize:"14px",fontWeight:"normal"},children:"Server offline"}),e.jsx("div",{className:"MbfWindowFooter",children:e.jsxs("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"},children:["Serial number: ",p.serialNumber]})})]}))}const Ko=o.memo(Go);function Jo(){const{logMessage:s,sendMessage:g,getUniqueId:c}=o.useContext(ve),[i,l]=o.useState("matterbridge-"),[b,p]=o.useState(!1),[t,w]=o.useState(null),j=o.useRef(c()),m=N=>{N.preventDefault(),p(!0)},y=()=>{p(!1)},V=N=>{N.preventDefault(),p(!1);const L=N.dataTransfer.files[0];if(L){s("Plugins",`Installing package ${L.name}. Please wait...`);const R=new FormData;R.append("file",L),R.append("filename",L.name),fetch("./api/uploadpackage",{method:"POST",body:R}).then(v=>v.text()).then(v=>{s("Plugins",`Server response: ${v}`)}).catch(v=>{console.error("Error uploading plugin file:",v),s("Plugins",`Error installing package ${v}`)})}},H=N=>{const L=N.target.files&&N.target.files[0];if(L){s("Plugins",`Uploading package ${L.name}`);const R=new FormData;R.append("file",L),R.append("filename",L.name),fetch("./api/uploadpackage",{method:"POST",body:R}).then(v=>v.text()).then(v=>{s("Plugins",`Server response: ${v}`)}).catch(v=>{console.error("Error uploading plugin file:",v),s("Plugins",`Error uploading package ${v}`)})}},I=()=>{g({id:j.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:i,restart:!1}})},K=()=>{document.getElementById("file-upload")?.click()},f=()=>{g({id:j.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:i}})},O=N=>{w(N.currentTarget)},x=N=>{N!==""&&l(N),w(null)};return r&&console.log("AddRemovePlugins rendering..."),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",alignItems:"center",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"},onDragOver:m,onDragLeave:y,onDrop:V,children:[e.jsx(ge,{value:i,onChange:N=>{l(N.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(G,{onClick:O,children:e.jsx(br,{})}),e.jsxs(ze,{id:"simple-menu",anchorEl:t,keepMounted:!0,open:!!t,onClose:()=>x(""),children:[e.jsx(k,{onClick:()=>x("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(k,{onClick:()=>x("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(k,{onClick:()=>x("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(k,{onClick:()=>x("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(k,{onClick:()=>x("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(k,{onClick:()=>x("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(k,{onClick:()=>x("matterbridge-test"),children:"matterbridge-test"}),e.jsx(k,{onClick:()=>x("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(k,{onClick:()=>x("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(k,{onClick:()=>x("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(k,{onClick:()=>x("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(k,{onClick:()=>x("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(k,{onClick:()=>x("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(k,{onClick:()=>x("matterbridge-eve-room"),children:"matterbridge-eve-room"})]}),e.jsx(F,{title:"Install or update a plugin from npm",children:e.jsx(ie,{onClick:I,endIcon:e.jsx(Se,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Install"})}),e.jsx(F,{title:"Upload and install a plugin from a tarball",children:e.jsx(ie,{onClick:K,endIcon:e.jsx(vr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:" Upload"})}),e.jsx(F,{title:"Add an installed plugin",children:e.jsx(ie,{onClick:f,endIcon:e.jsx(ct,{}),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:H})]})}const Zo=o.memo(Jo);function Ee({status:s,enabledText:g="Enabled",disabledText:c=void 0,tooltipText:i=void 0,onClick:l}){if(s===void 0)return null;{const b=e.jsx("div",{className:s?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:l,children:s?g:c??g});return i!==void 0?e.jsx(F,{title:i,children:b}):b}}function Rt(s){return s.id!==0&&s.src==="Matterbridge"&&s.dst==="Frontend"}const Ae={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},_e={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Yo={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},Xo={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Pe={padding:"0px",margin:"0px"},en="5px 10px 5px 10px",st={},ye={},at={},lt={};let qe=[],xt=[];const tn=({open:s,onClose:g,plugin:c})=>{const{sendMessage:i,addListener:l,removeListener:b,getUniqueId:p}=o.useContext(ve),t=o.useRef(p()),[w,j]=o.useState(c.configJson),[m,y]=o.useState(null),[V,H]=o.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[I,K]=o.useState("");let f={};o.useEffect(()=>{const P=C=>{C.src==="Matterbridge"&&C.dst==="Frontend"&&(Rt(C)&&C.id===t.current&&C.method==="/api/select/devices"&&C.response&&(r&&console.log(`ConfigPluginDialog (id: ${C.id}) received ${C.response.length} /api/select/devices:`,C.response),qe=C.response),Rt(C)&&C.id===t.current&&C.method==="/api/select/entities"&&C.response&&(r&&console.log(`ConfigPluginDialog (id: ${C.id}) received ${C.response.length} /api/select/entities:`,C.response),xt=C.response))};return l(P,t.current),r&&console.log("ConfigPluginDialog added WebSocket listener id:",t.current),w&&m&&m.properties&&(Object.keys(m.properties).forEach(C=>{Object.keys(m.properties[C]).forEach(M=>{M.startsWith("ui:")&&(V[C]={},V[C][M]=m.properties[C][M],delete m.properties[C][M])})}),H(V)),c.name&&c.configJson&&c.schemaJson&&(j(c.configJson),y(c.schemaJson),i({id:t.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name}}),i({id:t.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name}}),r&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',c.name)),()=>{b(P),r&&console.log("ConfigPluginDialog removed WebSocket listener")}},[l,w,c,b,m,i,V]);const O=(P,C)=>{f=P.formData},x=P=>{r&&console.log("ConfigPluginDialog handleSaveChanges:",P.formData),j(P.formData),c.configJson=P.formData,c.restartRequired=!0,i({id:t.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:P.formData.name,formData:P.formData}}),g()};function N(P){const{id:C,label:M,onKeyChange:E,onDropPropertyClick:ee,disabled:ce,schema:le,children:de,registry:A,readonly:se,required:Z}=P,{templates:h}=A,{RemoveButton:fe}=h.ButtonTemplates;if(!(Fo in le))return e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:de});const me=({target:J})=>E(J&&J.value);return e.jsxs(X,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(ge,{id:`${C}-key`,name:`${C}-key`,required:Z,disabled:ce||se,defaultValue:M,onBlur:se?void 0:me,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(X,{sx:{flex:1},children:de}),e.jsx(fe,{disabled:ce||se,onClick:ee(M),registry:A})]})}function L(P){const{children:C,description:M,displayLabel:E,errors:ee,help:ce,hidden:le,registry:de,uiSchema:A}=P,se=Lo(A),Z=$o("WrapIfAdditionalTemplate",de,se);return le?e.jsx("div",{style:{display:"none"},children:C}):e.jsx(X,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(Z,{...P,children:[E===!0&&M,C,ee,ce]})})}function R(P){const{description:C}=P;return C?e.jsx(ae,{sx:_e,children:C}):null}function v(P){const{required:C,title:M}=P;return M?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ae,{sx:Ae,children:["Title ",M," ",C&&e.jsx("mark",{children:"***"})]})}):null}function _(P){const{help:C}=P;return C?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ae,{sx:Yo,children:C})}):null}function T(P){const{errors:C}=P;return C?e.jsxs(X,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ae,{color:"error",sx:Xo,children:"Please fix the following errors:"}),e.jsx(Ke,{children:C.map((M,E)=>e.jsxs(yr,{children:[e.jsx(z,{children:e.jsx(jr,{color:"error"})}),e.jsx(re,{primary:M.stack})]},E))})]}):null}function a(P){const{errors:C}=P;return C?e.jsx(X,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:C.map((M,E)=>e.jsxs(ae,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",M]},E))}):null}function n(P){const{id:C,name:M,_schema:E,_uiSchema:ee,value:ce,options:le,label:de,type:A,placeholder:se,required:Z,disabled:h,readonly:fe,autofocus:be,onChange:me,onChangeOverride:J,onBlur:ue,onFocus:je,_rawErrors:Qe,_hideError:Q,_registry:S,_formContext:he}=P,Ge=({target:{value:we}})=>me(we===""?le.emptyValue:we),Ne=({target:we})=>ue(C,we&&we.value),Ze=({target:we})=>je(C,we&&we.value);return e.jsx(X,{sx:{padding:"0px",margin:"0px"},children:e.jsx(ge,{id:C,name:C,label:se&&se!==""?de:void 0,variant:"outlined",placeholder:se&&se!==""?se:de,required:Z,disabled:h||fe,autoFocus:be,value:ce||ce===0?ce:"",type:A,autoComplete:A==="password"?"current-password":M,onChange:J||Ge,onBlur:Ne,onFocus:Ze,fullWidth:!0})})}function d(P){return console.log("ArrayFieldTitleTemplate:",P),null}function u(P){return console.log("ArrayFieldDescriptionTemplate:",P),null}function $(P){return console.log("ArrayFieldItemTemplate:",P),null}function pe(P){const{canAdd:C,onAddClick:M,schema:E,title:ee}=P,[ce,le]=o.useState(!1),[de,A]=o.useState(!1),[se,Z]=o.useState(!1),[h,fe]=o.useState(""),be=S=>{fe(S.target.value)},me=()=>{r&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",h,"selectDevices:",qe),le(!ce)},J=()=>{r&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",h,"selectEntities:",xt),A(!de)},ue=()=>{r&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",h,"selectDevices:",qe),Z(!se)},je=S=>{le(!1),E.selectFrom==="serial"?E.items.default=S.serial:E.selectFrom==="name"&&(E.items.default=S.name),M()},Qe=S=>{A(!1),E.selectEntityFrom==="name"?E.items.default=S.name:E.selectEntityFrom==="description"&&(E.items.default=S.description),M()},Q=S=>{Z(!1),E.selectDeviceEntityFrom==="name"?E.items.default=S.name:E.selectDeviceEntityFrom==="description"&&(E.items.default=S.description),M()};return e.jsxs(X,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[ee&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[ee&&e.jsx(ae,{sx:Ae,children:ee}),C&&e.jsxs(X,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[E.selectFrom&&e.jsx(F,{title:"Add a device from the list",children:e.jsx(G,{onClick:me,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),E.selectEntityFrom&&e.jsx(F,{title:"Add an entity from the list",children:e.jsx(G,{onClick:J,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),E.selectDeviceEntityFrom&&e.jsx(F,{title:"Add a device entity from the list",children:e.jsx(G,{onClick:ue,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),e.jsx(F,{title:"Add a new item",children:e.jsx(G,{onClick:M,size:"small",color:"primary",sx:Pe,children:e.jsx(ct,{})})})]})]}),E.description&&e.jsx(ae,{sx:_e,children:E.description}),P.items.map(S=>e.jsxs(X,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(X,{sx:{flexGrow:1,marginRight:"10px"},children:S.children}),e.jsx(G,{disabled:!S.hasMoveUp,onClick:S.onReorderClick(S.index,S.index-1),size:"small",color:"primary",sx:Pe,children:e.jsx(Mt,{})}),e.jsx(G,{disabled:!S.hasMoveDown,onClick:S.onReorderClick(S.index,S.index+1),size:"small",color:"primary",sx:Pe,children:e.jsx(St,{})}),e.jsx(G,{onClick:S.onDropIndexClick(S.index),size:"small",color:"primary",sx:Pe,children:e.jsx(ut,{})})]},S.index)),e.jsxs(Me,{open:ce,onClose:me,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select a device"}),e.jsxs(Ie,{children:[e.jsxs(X,{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(ge,{fullWidth:!0,variant:"outlined",value:h,onChange:be,placeholder:"Enter serial or name"})]}),e.jsx(Ke,{dense:!0,children:qe.filter(S=>S.serial.toLowerCase().includes(h.toLowerCase())||S.name.toLowerCase().includes(h.toLowerCase())).map((S,he)=>e.jsxs(rt,{onClick:()=>je(S),sx:st,children:[S.icon==="wifi"&&e.jsx(z,{children:e.jsx(Je,{style:ye})}),S.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),S.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),e.jsx(re,{primary:S.name,secondary:S.serial,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},he))})]}),e.jsx($e,{children:e.jsx(ie,{onClick:me,children:"Close"})})]}),e.jsxs(Me,{open:de,onClose:J,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select an entity"}),e.jsxs(Ie,{children:[e.jsxs(X,{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(ge,{fullWidth:!0,variant:"outlined",value:h,onChange:be,placeholder:"Enter name or description"})]}),e.jsx(Ke,{dense:!0,children:xt.filter(S=>S.name.toLowerCase().includes(h.toLowerCase())||S.description.toLowerCase().includes(h.toLowerCase())).map((S,he)=>e.jsxs(rt,{onClick:()=>Qe(S),sx:st,children:[S.icon==="wifi"&&e.jsx(z,{children:e.jsx(Je,{style:ye})}),S.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),S.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),S.icon==="component"&&e.jsx(z,{children:e.jsx(kt,{style:ye})}),S.icon==="matter"&&e.jsx(z,{children:e.jsx(It,{style:ye})}),e.jsx(re,{primary:S.name,secondary:S.description,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},he))})]}),e.jsx($e,{children:e.jsx(ie,{onClick:J,children:"Close"})})]}),e.jsxs(Me,{open:se,onClose:ue,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(ke,{children:["Select an entity for ",ee]}),e.jsx(Ie,{children:e.jsx(Ke,{dense:!0,children:qe.filter(S=>S.serial===ee||S.name===ee).map(S=>S.entities?.map((he,Ge)=>e.jsxs(rt,{onClick:()=>Q(he),sx:st,children:[he.icon==="wifi"&&e.jsx(z,{children:e.jsx(Je,{style:ye})}),he.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),he.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),he.icon==="component"&&e.jsx(z,{children:e.jsx(kt,{style:ye})}),he.icon==="matter"&&e.jsx(z,{children:e.jsx(It,{style:ye})}),e.jsx(re,{primary:he.name,secondary:he.description,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},Ge)))})}),e.jsx($e,{children:e.jsx(ie,{onClick:ue,children:"Close"})})]})]})}function te(P){const{onAddClick:C,schema:M,properties:E,title:ee,description:ce}=P,[le,de]=o.useState(!1),[A,se]=o.useState(""),Z=J=>{se(J.target.value)},h=()=>{de(!le)},fe=J=>{r&&console.log(`ObjectFieldTemplate: handleSelectValue value "${J.serial}" for schema "${M.selectFrom}"`),de(!1);let ue="";M.selectFrom==="serial"?ue=J.serial:M.selectFrom==="name"&&(ue=J.name),K(ue),r&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${ue}"`),C(M)()},be=()=>{C(M)()},me=!M.additionalProperties;return r&&console.log(`ObjectFieldTemplate: isRoot ${me} newkey "${I}"`),!me&&I!==""&&(r&&console.log("ObjectFieldTemplate: newkey",I,"properties",E),E.forEach(J=>{if(J.name==="newKey"&&J.content.key==="newKey"&&J.content.props.name==="newKey"&&J.content.props.onKeyChange&&I!==""){r&&console.log("ObjectFieldTemplate: newkey onKeyChange",I);const ue=I;K(""),J.content.props.onKeyChange(ue)}})),e.jsxs(X,{sx:{margin:"0px",padding:me?"10px":"5px 10px 0px 10px",border:me?"none":"1px solid grey"},children:[M.title&&me&&e.jsx(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ae,{sx:Ae,children:M.title})}),ee&&!me&&e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ae,{sx:Ae,children:ee}),e.jsxs(X,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[M.selectFrom&&e.jsx(F,{title:"Add a device from the list",children:e.jsx(G,{onClick:h,size:"small",color:"primary",sx:Pe,children:e.jsx(tt,{})})}),e.jsx(F,{title:"Add a new item",children:e.jsx(G,{onClick:be,size:"small",color:"primary",sx:Pe,children:e.jsx(ct,{})})})]})]}),M.description&&e.jsx(X,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ae,{sx:_e,children:M.description})}),E.map(({content:J,name:ue,hidden:je})=>!je&&e.jsxs(X,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(M.properties[ue].type)?"0px":en,border:["object","array","boolean"].includes(M.properties[ue].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(M.properties[ue].type)&&e.jsx(ae,{sx:Ae,children:ue}),e.jsx(X,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:J})]},ue)),e.jsxs(Me,{open:le,onClose:h,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(ke,{children:"Select a device"}),e.jsxs(Ie,{children:[e.jsxs(X,{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(ge,{fullWidth:!0,variant:"outlined",value:A,onChange:Z,placeholder:"Enter serial or name"})]}),e.jsx(Ke,{dense:!0,children:qe.filter(J=>J.serial.toLowerCase().includes(A.toLowerCase())||J.name.toLowerCase().includes(A.toLowerCase())).map((J,ue)=>e.jsxs(rt,{onClick:()=>fe(J),sx:st,children:[J.icon==="wifi"&&e.jsx(z,{children:e.jsx(Je,{style:ye})}),J.icon==="ble"&&e.jsx(z,{children:e.jsx(ot,{style:ye})}),J.icon==="hub"&&e.jsx(z,{children:e.jsx(nt,{style:ye})}),e.jsx(re,{primary:J.name,secondary:J.serial,primaryTypographyProps:{style:at},secondaryTypographyProps:{style:lt}})]},ue))})]}),e.jsx($e,{children:e.jsx(ie,{onClick:h,children:"Close"})})]})]})}function Y(P){const{uiSchema:C}=P,{submitText:M,norender:E}=Wo(C);return E?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:g,children:"Cancel"})]})}function xe(P){const{className:C,disabled:M,onClick:E,registry:ee,style:ce,uiSchema:le,...de}=P;return e.jsx(F,{title:"Remove the item",children:e.jsx(G,{disabled:M,size:"small",color:"primary",onClick:E,children:e.jsx(ut,{})})})}function U(P){const{className:C,disabled:M,onClick:E,registry:ee,uiSchema:ce,...le}=P;return e.jsx(F,{title:"Add an item",children:e.jsx(G,{size:"small",color:"primary",onClick:E,children:e.jsx(ct,{})})})}function oe(P){const{disabled:C,onClick:M,registry:E,style:ee,uiSchema:ce,...le}=P;return e.jsx(F,{title:"Move up the item",children:e.jsx(G,{size:"small",color:"primary",onClick:M,children:e.jsx(Mt,{})})})}function W(P){const{disabled:C,onClick:M,registry:E,style:ee,uiSchema:ce,...le}=P;return e.jsx(F,{title:"Move down the item",children:e.jsx(G,{size:"small",color:"primary",onClick:M,children:e.jsx(St,{})})})}function B(P){const{id:C,name:M,value:E,schema:ee,readonly:ce,onChange:le}=P,[de,A]=o.useState(),se=h=>{r&&console.log(`CheckboxWidget ${M} onChangeField:`,h),A(h&&h!==""?h:void 0)},Z=()=>{r&&console.log(`CheckboxWidget onClick plugin="${c.name}" action="${M}" value="${de}"`),i({id:t.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:c.name,action:M,value:de,formData:f,id:C}}),ee.buttonClose===!0?g():ee.buttonSave===!0&&x({formData:w})};return ee.buttonText&&ee.description?e.jsxs(X,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ae,{sx:_e,children:ee.description}),e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>Z(),children:ee.buttonText})]}):ee.buttonField&&ee.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(ae,{sx:_e,children:ee.description}),e.jsx(ge,{id:M+"-input",name:M,label:ee.textLabel,placeholder:ee.textPlaceholder,onChange:h=>se(h.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ie,{id:M+"-button",variant:"contained",color:"primary",disabled:de===void 0,onClick:()=>Z(),children:ee.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(ae,{sx:Ae,children:M}),e.jsx(Te,{checked:E,readOnly:ce,onChange:()=>le(!E),sx:{padding:"0px",margin:"0px"}})]}),ee.description&&e.jsx(ae,{sx:_e,children:ee.description})]})}function D({schema:P,id:C,name:M,options:E,label:ee,hideLabel:ce,required:le,disabled:de,placeholder:A,readonly:se,value:Z,multiple:h,autofocus:fe,onChange:be,onBlur:me,onFocus:J,errorSchema:ue,rawErrors:je=[],registry:Qe,uiSchema:Q,hideError:S,formContext:he,...Ge}){const{enumOptions:Ne,enumDisabled:Ze,emptyValue:we}=E;h=typeof h>"u"?!1:!!h;const yt=h?[]:"",jt=typeof Z>"u"||h&&Z.length<1||!h&&Z===yt,Gt=({target:{value:De}})=>be(ft(De,Ne,we)),Kt=({target:De})=>me(C,ft(De&&De.value,Ne,we)),Jt=({target:De})=>J(C,ft(De&&De.value,Ne,we)),Ct=Po(Z,Ne,h),{InputLabelProps:Zt,SelectProps:Yt,autocomplete:Xt,...er}=Ge,tr=!h&&P.default===void 0;return e.jsxs(ge,{id:C,name:C,value:!jt&&typeof Ct<"u"?Ct:yt,required:le,disabled:de||se,autoFocus:fe,autoComplete:Xt,placeholder:A,error:je.length>0,onChange:Gt,onBlur:Kt,onFocus:Jt,...er,select:!0,InputLabelProps:{...Zt,shrink:!jt},SelectProps:{...Yt,multiple:h},"aria-describedby":No(C),children:[tr&&e.jsx(k,{value:"",children:A}),Array.isArray(Ne)&&Ne.map(({value:De,label:rr},wt)=>{const or=Array.isArray(Ze)&&Ze.indexOf(De)!==-1;return e.jsx(k,{value:String(wt),disabled:or,children:rr},wt)})]})}return r&&console.log("ConfigPluginDialog rendering..."),!s||!m||!w?null:e.jsxs(Me,{open:s,onClose:g,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(ke,{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(Ie,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(Io,{schema:m,formData:w,uiSchema:V,validator:Do,templates:{FieldTemplate:L,BaseInputTemplate:n,TitleFieldTemplate:v,DescriptionFieldTemplate:R,FieldHelpTemplate:_,FieldErrorTemplate:a,ErrorListTemplate:T,WrapIfAdditionalTemplate:N,ArrayFieldTitleTemplate:d,ArrayFieldDescriptionTemplate:u,ArrayFieldItemTemplate:$,ArrayFieldTemplate:pe,ObjectFieldTemplate:te,ButtonTemplates:{SubmitButton:Y,RemoveButton:xe,AddButton:U,MoveUpButton:oe,MoveDownButton:W}},widgets:{CheckboxWidget:B,SelectWidget:D},onChange:O,onSubmit:x})})]})};function Qt(s){if(r&&console.log(`getQRColor (id: ${s?.id}) received matter:`,s??"undefined"),s===void 0||!s.online||!s.qrPairingCode&&!s.manualPairingCode&&!s.fabricInformations&&!s.sessionInformations)return"red";if(s.commissioned===!1&&s.qrPairingCode&&s.manualPairingCode)return"var(--primary-color)";let g=0,c=0;for(const i of s.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&g++,i.numberOfActiveSubscriptions>0&&(c+=i.numberOfActiveSubscriptions);return s.commissioned===!0&&s.fabricInformations&&s.sessionInformations&&(g===0||c===0)?"var(--secondary-color)":"var(--div-text-color)"}function rn(s,g,c){const i=s?.[c],l=g?.[c];return i==null&&l==null?0:i==null?-1:l==null?1:typeof i=="boolean"&&typeof l=="boolean"?i===l?0:i?1:-1:typeof i=="number"&&typeof l=="number"?i-l:String(i).localeCompare(String(l))}function on({name:s,title:g,columns:c,rows:i,getRowKey:l,footerLeft:b,footerRight:p,onRowClick:t}){const w=o.useRef(new WeakMap),j=o.useRef(1),m=a=>{if(typeof l=="string"&&a&&a[l]!=null)return a[l];if(typeof l=="function"){const u=l(a);if(u!=null)return u}const n=c?.[0]?.id;if(n&&a&&a[n]!=null)return a[n];console.warn(`MbfTable(${s}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let d=w.current.get(a);return d||(d=`rk_${j.current++}`,w.current.set(a,d)),d},[y,V]=o.useState(localStorage.getItem(`${s}_table_order_by`)||null),[H,I]=o.useState(localStorage.getItem(`${s}_table_order`)||null),[K,f]=o.useState(!1),[O,x]=o.useState(()=>{try{const a=localStorage.getItem(`${s}_column_visibility`);if(a)return JSON.parse(a)}catch{}return{}}),N=o.useMemo(()=>{const a={};for(const n of c)n.hidden||(a[n.id]=n.required?!0:O[n.id]!==!1);return a},[c,O]),L=o.useMemo(()=>{if(!y||!H)return i;const a=c.find(d=>d.id===y);if(!a||a.noSort)return i;const n=i.map((d,u)=>({el:d,index:u}));return n.sort((d,u)=>{let $;return typeof a.comparator=="function"?$=a.comparator(d.el,u.el):$=rn(d.el,u.el,y),$!==0?H==="asc"?$:-$:d.index-u.index}),n.map(d=>d.el)},[i,y,H,c]),R=a=>{if(y!==a||!y){V(a),I("asc"),localStorage.setItem(`${s}_table_order_by`,a),localStorage.setItem(`${s}_table_order`,"asc");return}if(H==="asc"){I("desc"),localStorage.setItem(`${s}_table_order`,"desc");return}V(null),I(null),localStorage.removeItem(`${s}_table_order_by`),localStorage.removeItem(`${s}_table_order`)},v=()=>{f(!K)},_=a=>{x(n=>{const d=c.find(pe=>pe.id===a);if(d&&d.required)return n;const u=N[a]!==!1,$={...n};u?$[a]=!1:delete $[a];try{localStorage.setItem(`${s}_column_visibility`,JSON.stringify($))}catch{}return $})},T=()=>{x({});try{localStorage.removeItem(`${s}_column_visibility`)}catch{}f(!1)};return r&&console.log(`Rendering table ${s}${y&&H?` ordered by ${y}:${H}`:""}`),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(Me,{open:K,onClose:(a,n)=>{n==="backdropClick"||n==="escapeKeyDown"||v()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(ke,{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 ${s} columns`})]})}),e.jsx(Ie,{children:e.jsx(Cr,{children:c.filter(a=>!a.hidden).map(a=>e.jsx(Fe,{control:e.jsx(Te,{disabled:!!a.required,checked:a.required?!0:N[a.id]!==!1,onChange:()=>_(a.id)}),label:a.label},a.id))})}),e.jsxs($e,{children:[e.jsx(ie,{onClick:T,children:"Reset"}),e.jsx(ie,{variant:"contained",onClick:a=>{if(a?.currentTarget&&typeof a.currentTarget.blur=="function")try{a.currentTarget.blur()}catch{}const n=document.activeElement;if(n&&n instanceof HTMLElement&&typeof n.blur=="function")try{n.blur()}catch{}v()},children:"Close"})]})]}),e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:s}),g&&e.jsx("p",{className:"MbfWindowHeaderText",children:g}),e.jsx("div",{className:"MbfWindowHeaderFooterIcons",children:e.jsx(G,{onClick:a=>{if(a?.currentTarget?.blur)try{a.currentTarget.blur()}catch{}v()},"aria-label":"Configure Columns",style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},children:e.jsx(F,{title:`Configure ${s} columns`,children:e.jsx(ne,{path:io,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":`${s} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:c.map(a=>{if(a.hidden||!a.required&&N[a.id]===!1)return null;const n=!a.noSort,d=n&&y===a.id&&!!H;return e.jsxs("th",{onClick:n?()=>R(a.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:a.minWidth,maxWidth:a.maxWidth,textAlign:a.align||"left",cursor:n?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:a.maxWidth?"nowrap":void 0,overflow:a.maxWidth?"hidden":void 0,textOverflow:a.maxWidth?"ellipsis":void 0},"aria-sort":n?d?H==="asc"?"ascending":"descending":"none":void 0,children:[a.label,d&&e.jsxs("span",{style:{marginLeft:6},children:[H==="asc"&&e.jsx(ne,{path:so,size:"15px"}),H==="desc"&&e.jsx(ne,{path:ao,size:"15px"})]})]},a.id)})})}),e.jsx("tbody",{children:L.map((a,n)=>{const d=m(a);return e.jsx("tr",{className:n%2===0?"table-content-even":"table-content-odd",onClick:t?u=>t(a,d,u):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:t?"pointer":void 0},children:c.map(u=>{if(u.hidden||!u.required&&N[u.id]===!1)return null;const $=a[u.id];return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:u.align||"left",padding:"5px 10px",margin:"0",maxWidth:u.maxWidth,whiteSpace:u.maxWidth?"nowrap":void 0,overflow:u.maxWidth?"hidden":void 0,textOverflow:u.maxWidth?"ellipsis":void 0},children:typeof u.render=="function"?u.render($,d,a,u):typeof $=="boolean"?e.jsx(Te,{checked:$,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):u.format&&typeof $=="number"?u.format($):$!=null?String($):null},u.id)})},d)})})]})}),(b||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:b}),e.jsx("p",{className:"MbfWindowFooterText",style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:p})]})]})}function nn(s){return o.memo(s)}const mt=nn(on);function sn({storeId:s,setStoreId:g}){const{online:c,sendMessage:i,addListener:l,removeListener:b,getUniqueId:p}=o.useContext(ve),{showConfirmCancelDialog:t}=o.useContext(Be),w=o.useRef(p()),[j,m]=o.useState(null),[y,V]=o.useState(null),[H,I]=o.useState([]),K=[{label:"Name",id:"name",required:!0,render:(W,B,D,P)=>e.jsx(F,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>a(D),children:D.name})})},{label:"Description",id:"description",render:(W,B,D,P)=>e.jsx(F,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>a(D),children:D.description})})},{label:"Version",id:"version",render:(W,B,D,P)=>e.jsxs(e.Fragment,{children:[D.latestVersion!==void 0&&D.latestVersion!==D.version&&y&&!y.readOnly&&e.jsx(F,{title:"New plugin stable version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>L(D),children:["Update to v.",D.latestVersion]})}),D.version.includes("-dev-")&&D.devVersion!==void 0&&D.devVersion!==D.version&&y&&!y.readOnly&&e.jsx(F,{title:"New plugin dev version available, click to install",children:e.jsxs("span",{className:"status-warning",style:{marginRight:"10px"},onClick:()=>R(D),children:["Update to new dev v.",D.devVersion.split("-dev-")[0]]})}),e.jsx(F,{title:"Plugin version",children:e.jsx("span",{children:D.version})})]})},{label:"Author",id:"author",render:(W,B,D,P)=>e.jsx(e.Fragment,{children:D.author?D.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(W,B,D,P)=>e.jsx(e.Fragment,{children:D.type?D.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(W,B,D,P)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[y&&y.bridgeMode==="childbridge"&&!D.error&&D.enabled&&e.jsx(F,{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:Qt(D.matter)},onClick:()=>{D.matter?.id&&g(D.matter?.id)},size:"small",children:e.jsx(At,{})})}),y&&y.bridgeMode==="childbridge"&&!D.error&&D.enabled&&e.jsx(F,{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:()=>_(D),size:"small",children:e.jsx(dt,{})})}),e.jsx(F,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{disabled:D.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>xe(D),size:"small",children:e.jsx(vt,{})})}),y&&!y.readOnly&&e.jsx(F,{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:()=>{O("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",D)},size:"small",children:e.jsx(ut,{})})}),D.enabled?e.jsx(F,{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:()=>{O("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",D)},size:"small",children:e.jsx(wr,{})})}):e.jsx(e.Fragment,{}),D.enabled?e.jsx(e.Fragment,{}):e.jsx(F,{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:()=>T(D),size:"small",children:e.jsx(Sr,{})})}),e.jsx(F,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>d(D),size:"small",children:e.jsx(Mr,{})})}),e.jsx(F,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>u(D),size:"small",children:e.jsx(kr,{})})}),y&&!y.readOnly&&e.jsx(F,{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:()=>n(D),size:"small",children:e.jsx(Vt,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(W,B,D,P)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:D.error?e.jsx(e.Fragment,{children:e.jsx(Ee,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:D.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(Ee,{status:D.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:D.loaded&&D.started&&D.configured?e.jsx(e.Fragment,{children:e.jsx(Ee,{status:D.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(Ee,{status:D.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(Ee,{status:D.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(Ee,{status:D.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];o.useEffect(()=>{const W=B=>{B.src==="Matterbridge"&&B.dst==="Frontend"&&(B.method==="refresh_required"&&B.response.changed==="plugins"&&(r&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and sending /api/plugins request`),i({id:w.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),B.method==="refresh_required"&&B.response.changed==="matter"&&(r&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and setting matter id ${B.response.matter?.id}`),I(D=>{const P=D.findIndex(M=>M.matter?.id===B.response.matter?.id);if(P<0)return r&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and matter id ${B.response.matter?.id} not found`),D;r&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} set matter id ${B.response.matter?.id}`);const C=[...D];return C[P]={...C[P],matter:B.response.matter},C})),B.method==="refresh_required"&&B.response.changed==="settings"&&(r&&console.log(`HomePlugins received refresh_required: changed=${B.response.changed} and sending /api/settings request`),i({id:w.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),B.id===w.current&&B.method==="/api/settings"&&(r&&console.log(`HomePlugins (id: ${B.id}) received settings:`,B.response),m(B.response.systemInformation),V(B.response.matterbridgeInformation)),B.id===w.current&&B.method==="/api/plugins"&&(r&&console.log(`HomePlugins (id: ${B.id}) received ${B.response.length} plugins:`,B.response),I(B.response)))};return l(W,w.current),r&&console.log("HomePlugins added WebSocket listener id:",w.current),()=>{b(W),r&&console.log("HomePlugins removed WebSocket listener")}},[l,b,i]),o.useEffect(()=>{c&&(r&&console.log("HomePlugins sending api requests"),i({id:w.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:w.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,i]);const f=o.useRef(null),O=(W,B,D,P)=>{r&&console.log(`handleActionWithConfirmCancel ${D} ${P.name}`),f.current=P,t(W,B,D,x,N)},x=W=>{r&&console.log(`handleConfirm action confirmed ${W} ${f.current?.name}`),W==="remove"&&f.current?v(f.current):W==="disable"&&f.current&&T(f.current),f.current=null},N=W=>{r&&console.log(`handleCancel action canceled ${W} ${f.current?.name}`),f.current=null},L=W=>{r&&console.log("handleUpdatePlugin plugin:",W.name),i({id:w.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:W.name,restart:!1}})},R=W=>{r&&console.log("handleUpdateDevPlugin plugin:",W.name),i({id:w.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:W.name+"@dev",restart:!1}})},v=W=>{r&&console.log("handleRemovePlugin plugin:",W.name),i({id:w.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}})},_=W=>{r&&console.log("handleRestartPlugin plugin:",W.name),i({id:w.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}})},T=W=>{r&&console.log("handleEnableDisablePlugin plugin:",W.name,"enabled:",W.enabled),W.enabled===!0?(W.enabled=!1,i({id:w.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}})):(W.enabled=!0,i({id:w.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:W.name}}))},a=W=>{r&&console.log(`handleHomepagePlugin plugin: ${W.name} homepage: ${W.homepage}`),W.homepage&&window.open(W.homepage,"_blank")},n=W=>{r&&console.log("handleSponsorPlugin plugin:",W.name,"funding:",W.funding),W.funding&&window.open(W.funding,"_blank")},d=W=>{r&&console.log("handleHelpPlugin plugin:",W.name,"help:",W.help),W.help&&window.open(W.help,"_blank")},u=W=>{r&&console.log("handleChangelogPlugin plugin:",W.name,"changelog:",W.changelog),W.changelog&&window.open(W.changelog,"_blank")},[$,pe]=o.useState(),[te,Y]=o.useState(!1),xe=W=>{r&&console.log("handleConfigPlugin plugin:",W.name),i({id:w.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:W.name}}),i({id:w.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:W.name}}),pe(W),U()},U=()=>{Y(!0)},oe=()=>{Y(!1)};return r&&console.log("HomePlugins rendering..."),c?e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"0 0 auto",overflow:"hidden"},children:[$&&e.jsx(tn,{open:te,onClose:oe,plugin:$}),e.jsx(mt,{name:"Plugins",columns:K,rows:H,footerRight:"",footerLeft:""})]}):e.jsx(Re,{})}const an=o.memo(sn),ln=s=>`${s.pluginName}::${s.serial}`;function dn({storeId:s,setStoreId:g}){const{online:c,sendMessage:i,addListener:l,removeListener:b,getUniqueId:p}=o.useContext(ve),[t,w]=o.useState(!1),[j,m]=o.useState(!0),[y,V]=o.useState(null),[H,I]=o.useState([]),[K,f]=o.useState([]),[O,x]=o.useState([]),[N,L]=o.useState([]),R=o.useRef(p()),v=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(a,n,d,u)=>d.reachable===!0?"Online":d.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(a,n)=>{const d=a.reachable===!0?1:a.reachable===!1?0:-1,u=n.reachable===!0?1:n.reachable===!1?0:-1;return d-u}},{label:"Power",id:"powerSource",render:(a,n,d,u)=>d.powerSource==="ac"||d.powerSource==="dc"?e.jsx(_t,{fontSize:"small",sx:{color:"var(--primary-color)"}}):d.powerSource==="ok"?e.jsx(pt,{fontSize:"small",sx:{color:"green"}}):d.powerSource==="warning"?e.jsx(pt,{fontSize:"small",sx:{color:"yellow"}}):d.powerSource==="critical"?e.jsx(pt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Url",id:"configUrl"},{label:"Actions",id:"selected",required:!0,render:(a,n,d,u)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[d.matter!==void 0?e.jsx(F,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{onClick:()=>g(s===d.matter?.id?y?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:d.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:Qt(d.matter)},children:e.jsx(At,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),d.configUrl?e.jsx(F,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{onClick:()=>window.open(d.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(vt,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),d.selected!==void 0?e.jsx(F,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Te,{checked:d.selected,onChange:$=>T($,d),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],_=o.useCallback(a=>{a.selected=void 0;const n=H.find($=>$.name===a.pluginName);if(!n)return console.error(`HomeDevices isSelected: plugin ${a.pluginName} not found for device ${a.name} `),a.selected;const d=n.schemaJson?.properties?.whiteList?.selectFrom;let u=n.configJson.postfix;return u===""&&(u=void 0),n.hasWhiteList===!0&&n.hasBlackList===!0&&d&&(a.selected=!0,d==="serial"&&n.configJson.whiteList&&n.configJson.whiteList.length>0&&n.configJson.whiteList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!0),d==="serial"&&n.configJson.whiteList&&n.configJson.whiteList.length>0&&!n.configJson.whiteList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!1),d==="serial"&&n.configJson.blackList&&n.configJson.blackList.length>0&&n.configJson.blackList.includes(u?a.serial.replace("-"+u,""):a.serial)&&(a.selected=!1),d==="name"&&n.configJson.whiteList&&n.configJson.whiteList.length>0&&n.configJson.whiteList.includes(a.name)&&(a.selected=!0),d==="name"&&n.configJson.whiteList&&n.configJson.whiteList.length>0&&!n.configJson.whiteList.includes(a.name)&&(a.selected=!1),d==="name"&&n.configJson.blackList&&n.configJson.blackList.length>0&&n.configJson.blackList.includes(a.name)&&(a.selected=!1)),a.selected},[H]);o.useEffect(()=>{const a=n=>{if(n.method==="refresh_required"&&n.response.changed!=="matter"?(r&&console.log(`HomeDevices received refresh_required: changed=${n.response.changed} and sending /api/plugins request`),i({id:R.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):n.method==="refresh_required"&&n.response.changed==="matter"?(r&&console.log(`HomeDevices received refresh_required: changed=${n.response.changed} and setting matter id ${n.response.matter?.id}`),L(d=>{const u=d.findIndex(pe=>pe.name.replaceAll(" ","")===n.response.matter?.id);if(u<0)return r&&console.debug(`HomeDevices: matter id ${n.response.matter?.id} not found`),d;const $=[...d];return $[u]={...$[u],matter:n.response.matter},r&&console.log(`HomeDevices received refresh_required: changed=${n.response.changed} and set matter id ${n.response.matter?.id}`),$})):n.method==="restart_required"?(r&&console.log("HomeDevices received restart_required"),w(!0)):n.method==="restart_not_required"?(r&&console.log("HomeDevices received restart_not_required"),w(!1)):n.method==="state_update"&&n.response.plugin&&n.response.serialNumber&&n.response.cluster.includes("BasicInformation")&&n.response.attribute==="reachable"&&(r&&console.log(`HomeDevices updating device reachability for plugin ${n.response.plugin} serial ${n.response.serialNumber} value ${n.response.value}`),f(d=>{const u=d.findIndex($=>$.pluginName===n.response.plugin&&$.serial===n.response.serialNumber);return u<0?(r&&console.warn(`HomeDevices: device to update not found for plugin ${n.response.plugin} serial ${n.response.serialNumber}`),d):(d[u]={...d[u],reachable:n.response.value},[...d])})),n.id===R.current&&n.method==="/api/settings")r&&console.log(`HomeDevices (id: ${n.id}) received settings:`,n.response),V(n.response),w(n.response.matterbridgeInformation.restartRequired||n.response.matterbridgeInformation.fixedRestartRequired);else if(n.id===R.current&&n.method==="/api/plugins"){if(r&&console.log(`HomeDevices (id: ${n.id}) received ${n.response?.length} plugins:`,n.response),n.response){let d=!0;for(const u of n.response)u.enabled===!0&&(u.loaded!==!0||u.started!==!0||u.error===!0)&&(d=!1);if(!d)return;r&&console.log("HomeDevices reset plugins, devices and selectDevices"),m(!1),I(n.response),f([]),x([]),i({id:R.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),r&&console.log("HomeDevices sent /api/devices");for(const u of n.response)u.enabled===!0&&u.loaded===!0&&u.started===!0&&u.error!==!0&&(i({id:R.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:u.name}}),r&&console.log(`HomeDevices sent /api/select/devices for plugin: ${u.name}`))}}else if(n.id===R.current&&n.method==="/api/devices"){if(r&&console.log(`HomeDevices (id: ${n.id}) received ${n.response?.length} devices:`,n.response),n.response){for(const d of n.response)d.selected=_(d);f(n.response)}}else n.id===R.current&&n.method==="/api/select/devices"&&(r&&console.log(`HomeDevices (id: ${n.id}) received ${n.response?.length} selectDevices for plugin ${n.response&&n.response.length>0?n.response[0].pluginName:"without select devices"}:`,n.response),n.response&&n.response.length>0&&x(d=>{const u=d.filter(pe=>pe.pluginName!==n.response[0].pluginName),$=n.response.map(pe=>({...pe,selected:_(pe)}));return[...u,...$]}))};return l(a,R.current),r&&console.log(`HomeDevices added WebSocket listener id ${R.current}`),()=>{b(a),r&&console.log("HomeDevices removed WebSocket listener")}},[H,l,b,i,_]),o.useEffect(()=>{if(K.length===0&&O.length===0){L([]);return}r&&console.log(`HomeDevices mixing devices (${K.length}) and selectDevices (${O.length})`);const a=[];for(const n of K)a.push(n);for(const n of O)K.find(d=>d.pluginName===n.pluginName&&d.serial.includes(n.serial))||a.push(n);a.length>0&&(L(a),r&&console.log(`HomeDevices mixed ${a.length} devices and selectDevices`))},[H,K,O,L]),o.useEffect(()=>{c&&(r&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:R.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:R.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[c,i]);const T=(a,n)=>{r&&console.log(`handleCheckboxChange: checkbox changed to ${a.target.checked} for device ${n.name} serial ${n.serial}`),K.findIndex(d=>d.pluginName===n.pluginName&&d.serial===n.serial)<0?(r&&console.warn(`handleCheckboxChange: device ${n.name} serial ${n.serial} not found in devices, trying in mixedDevices`),L(d=>{const u=d.findIndex($=>$.pluginName===n.pluginName&&$.serial===n.serial);return u<0?(console.error(`handleCheckboxChange: device ${n.name} serial ${n.serial} not found in mixedDevices`),d):(d[u]={...d[u],selected:a.target.checked},[...d])})):f(d=>{const u=d.findIndex($=>$.pluginName===n.pluginName&&$.serial===n.serial);return u<0?(console.error(`handleCheckboxChange: device ${n.name} serial ${n.serial} not found in devices`),d):(d[u]={...d[u],selected:a.target.checked},[...d])}),a.target.checked?i({id:R.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:n.pluginName,serial:n.serial,name:n.name}}):i({id:R.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:n.pluginName,serial:n.serial,name:n.name}})};return r&&console.log("HomeDevices rendering..."),c?e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Devices",getRowKey:ln,rows:N,columns:v,footerLeft:j?"Waiting for the plugins to fully load...":`Registered devices: ${K.length.toString()}/${N.length.toString()}`,footerRight:t?"Restart required":""})}):e.jsx(Re,{})}const cn=o.memo(dn);function pn(){const[s,g]=o.useState(null),[c,i]=o.useState(null),[l,b]=o.useState([]),[p]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[t,w]=o.useState(localStorage.getItem("homePageMode")??"devices"),[j,m]=o.useState(""),[y,V]=o.useState(!1),[H,I]=o.useState(!1),[K,f]=o.useState(null),{addListener:O,removeListener:x,online:N,sendMessage:L,logFilterLevel:R,logFilterSearch:v,autoScroll:_,getUniqueId:T}=o.useContext(ve),a=o.useRef(T());return o.useEffect(()=>{const n=d=>{d.method==="refresh_required"&&d.response.changed==="settings"&&(r&&console.log(`Home received refresh_required: changed=${d.response.changed} and sending /api/settings request`),f(null),b([]),L({id:a.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),L({id:a.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),d.method==="/api/settings"&&d.id===a.current&&(r&&console.log("Home received settings:",d.response),g(d.response.systemInformation),i(d.response.matterbridgeInformation),d.response.matterbridgeInformation.matterbridgeVersion&&m(`https://github.com/Luligu/matterbridge/blob/${d.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem("frontendVersion")===null&&d.response.matterbridgeInformation.frontendVersion?localStorage.setItem("frontendVersion",d.response.matterbridgeInformation.frontendVersion):d.response.matterbridgeInformation.frontendVersion!==localStorage.getItem("frontendVersion")&&d.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem("frontendVersion",d.response.matterbridgeInformation.frontendVersion),I(!0)),localStorage.getItem("matterbridgeVersion")===null?localStorage.setItem("matterbridgeVersion",d.response.matterbridgeInformation.matterbridgeVersion):d.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem("matterbridgeVersion")&&(localStorage.setItem("matterbridgeVersion",d.response.matterbridgeInformation.matterbridgeVersion),V(!0)),d.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem("homePageMode")||(localStorage.setItem("homePageMode","devices"),w("devices")))),d.method==="/api/plugins"&&d.id===a.current&&(r&&console.log("Home received plugins:",d.response),b(d.response))};return O(n,a.current),r&&console.log(`Home added WebSocket listener id ${a.current}`),()=>{x(n),r&&console.log("Home removed WebSocket listener")}},[O,x,L]),o.useEffect(()=>{if(r&&console.log(`Home storeId effect with storeId ${K}`),c?.bridgeMode==="bridge"&&!K&&(r&&console.log("Home storeId effect set storeId to Matterbridge"),f("Matterbridge")),c?.bridgeMode==="childbridge"&&!K&&l){for(const n of l)if(n.matter?.id){r&&console.log(`Home storeId effect set storeId to ${n.matter.id}`),f(n.matter.id);break}}},[c,l,K]),o.useEffect(()=>{N&&(r&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),L({id:a.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),L({id:a.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[N,L]),r&&console.log("Home rendering..."),!N||!s||!c?e.jsx(Re,{}):e.jsxs("div",{className:"MbfPageDiv",style:{flexDirection:"row"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(Ko,{id:K}),e.jsx(Bo,{systemInfo:s,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:"20px"},children:[H&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Frontend Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(ie,{onClick:()=>window.location.reload(),endIcon:e.jsx(Ir,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}),y&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge Update"})}),e.jsxs("div",{className:"MbfWindowBody",style:{flexDirection:"row",justifyContent:"space-between"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{children:[e.jsx(ie,{onClick:()=>window.open(j,"_blank"),endIcon:e.jsx(Et,{}),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(Dr,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}),p&&!c.readOnly&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Install plugins"})}),e.jsx(Zo,{})]}),p&&e.jsx(an,{storeId:K,setStoreId:f}),t==="devices"&&e.jsx(cn,{storeId:K,setStoreId:f}),t==="logs"&&e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"1 1 auto",width:"100%",overflow:"hidden"},children:[e.jsxs("div",{className:"MbfWindowHeader",style:{height:"30px",minHeight:"30px",justifyContent:"space-between"},children:[e.jsx("p",{className:"MbfWindowHeaderText",children:"Logs"}),e.jsx("div",{className:"MbfWindowHeaderText",style:{display:"flex",justifyContent:"space-between"},children:e.jsxs("span",{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',R,'" and search "',v,'" Scroll: ',_?"auto":"manual"]})})]}),e.jsx("div",{style:{flex:"1 1 auto",margin:"0px",padding:"10px",overflow:"auto"},children:e.jsx(Bt,{})})]})]})]})}const un=o.memo(pn),Ht={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},gn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},mn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},Ot={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},hn={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},fn={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},xn={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},bn={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},vn={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},bt={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},yn=[256,257,268,269],jn=[266,267],Cn=[259,260,261,271,272],wn=[256,257,268,269,266,267,259,260,261,272];function q({icon:s,iconColor:g,cluster:c,value:i,unit:l,prefix:b}){return r&&console.log(`Render cluster "${c.clusterName}.${c.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${l}"`),b=b??!1,e.jsxs(X,{sx:Ht,children:[s&&o.cloneElement(s,{key:`${c.clusterId}-${c.attributeId}-icon`,sx:{...gn,color:g??"var(--primary-color)"}}),e.jsxs(X,{sx:{...Ht,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[l&&b===!0&&e.jsx(ae,{sx:Ot,children:l},`${c.clusterId}-${c.attributeId}-unit`),e.jsx(ae,{sx:mn,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${c.clusterId}-${c.attributeId}-value`),l&&b===!1&&e.jsx(ae,{sx:Ot,children:l},`${c.clusterId}-${c.attributeId}-unit`)]},`${c.clusterId}-${c.attributeId}-valueunitbox`)]},`${c.clusterId}-${c.attributeId}-box`)}function Sn({device:s,endpoint:g,id:c,deviceType:i,clusters:l}){const b=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let p="";return r&&console.log(`Device "${s.name}" endpoint "${g}" id "${c}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${l?.length}):`,l),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>p=`${t.attributeLocalValue} mV`),wn.includes(i)&&l.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>p=`Level ${t.attributeValue}`),i===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>p=`Position ${t.attributeLocalValue/100}%`),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>p=`Heat ${t.attributeLocalValue/100}°C `),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>p=p+`Cool ${t.attributeLocalValue/100}°C`),i===118&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>p=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>p=`${t.attributeLocalValue/1e3} V, `),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>p=p+`${t.attributeLocalValue/1e3} A, `),i===1296&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>p=p+`${t.attributeLocalValue/1e3} W`),e.jsxs("div",{className:"MbfWindowDiv",style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:t.attributeLocalValue===!0?e.jsx(Je,{}):e.jsx(Pr,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(q,{icon:e.jsx(pt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(q,{icon:e.jsx(_t,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&l.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:lo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),yn.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(Nr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),jn.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),Cn.includes(i)&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:po,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:uo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(Dt,{}),cluster:t,value:"Oven"})),i===112&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(Wr,{}),cluster:t,value:"Fridge"})),i===113&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:ho,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&l.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(q,{icon:e.jsx(Dt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:$t,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&l.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:$t,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===116&&l.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Robot"})),i===514&&l.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(q,{icon:e.jsx(Lr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&l.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(q,{icon:t.attributeValue==="1"?e.jsx($r,{}):e.jsx(Fr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(q,{icon:e.jsx(Tr,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&l.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:vo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&l.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(q,{icon:e.jsx(Rr,{}),cluster:t,value:t.attributeValue,unit:"mode",prefix:!0})),i===771&&l.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(q,{icon:e.jsx(Hr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&l.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(q,{icon:e.jsx(Pt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&l.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(q,{icon:e.jsx(Pt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Or,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Vr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:e.jsx(Er,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===1292&&l.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&l.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Co,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&l.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:wo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&l.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:So,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Ft,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&l.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&l.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Ft,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&l.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(q,{icon:e.jsx(Ar,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&l.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:Mo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:b[t.attributeLocalValue??0]})),i===770&&l.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(_r,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&l.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(ne,{path:ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&l.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(qr,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&l.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(zr,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&l.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(q,{icon:t.attributeValue==="true"?e.jsx(Ur,{}):e.jsx(Br,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&l.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(q,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(Qr,{}):e.jsx(Gr,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&l.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(q,{icon:e.jsx(Kr,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&l.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(q,{icon:e.jsx(Jr,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(X,{sx:hn,children:e.jsx(ae,{sx:fn,children:p})}),e.jsx(X,{sx:xn,children:e.jsx(ae,{sx:bn,children:s.name})}),e.jsxs(X,{sx:vn,children:[r&&e.jsx(ae,{sx:bt,children:g}),e.jsx(ae,{sx:bt,children:c}),r&&e.jsxs(ae,{sx:bt,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Mn({filter:s}){const{online:g,sendMessage:c,addListener:i,removeListener:l,getUniqueId:b}=o.useContext(ve),[p,t]=o.useState(null),[w,j]=o.useState([]),[m,y]=o.useState([]),[V,H]=o.useState(m),[I,K]=o.useState({}),[f,O]=o.useState({}),[x,N]=o.useState({}),L=o.useRef(b()),R=o.useRef(V),v=o.useCallback(T=>{r&&console.log(`DevicesIcons received state_update "${T.response.cluster}.${T.response.attribute}" for "${T.response.id}:${T.response.number}": "${T.response.value}"`,T.response);const a=R.current.find(d=>d.pluginName===T.response.plugin&&d.uniqueId===T.response.uniqueId);if(!a){r&&console.warn(`DevicesIcons updater device of plugin "${T.response.plugin}" serial "${T.response.serialNumber}" not found in filteredDevicesRef.current`);return}const n=x[a.serial].find(d=>d.endpoint===T.response.number.toString()&&d.clusterName===T.response.cluster&&d.attributeName===T.response.attribute);if(!n){r&&console.warn(`DevicesIcons updater device "${a.name}" serial "${a.serial}" cluster "${T.response.cluster}" attribute "${T.response.attribute}" not found in clusters`);return}n.attributeValue=String(T.response.value),n.attributeLocalValue=T.response.value,N({...x}),r&&console.log(`DevicesIcons updated "${n.clusterName}.${n.attributeName}" for device "${a.name}" serial "${a.serial}" to "${n.attributeValue}"`)},[x]);o.useEffect(()=>{const T=a=>{if(a.method==="refresh_required")r&&console.log(`DevicesIcons received refresh_required: changed=${a.response.changed} and sending api requests`),c({id:L.current,sender:"Icons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:L.current,sender:"Icons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:L.current,sender:"Icons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(a.method==="state_update"&&a.response)v(a);else if(a.method==="/api/settings"&&a.response)r&&console.log("DevicesIcons received settings:",a.response),t(a.response);else if(a.method==="/api/plugins"&&a.response)r&&console.log("DevicesIcons received plugins:",a.response),j(a.response);else if(a.method==="/api/devices"&&a.response){r&&console.log(`DevicesIcons received ${a.response.length} devices:`,a.response),y(a.response);for(const n of a.response)r&&console.log("DevicesIcons sending /api/clusters"),c({id:L.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:n.pluginName,endpoint:n.endpoint||0}})}else if(a.method==="/api/clusters"&&a.response){if(r&&console.log(`DevicesIcons received for device "${a.response.deviceName}" serial "${a.response.serialNumber}" deviceTypes (${a.response.deviceTypes.length}) "${a.response.deviceTypes.join(",")}" clusters (${a.response.clusters.length}):`,a.response),a.response.clusters.length===0)return;const n=a.response.serialNumber;I[n]=[],f[n]=a.response.deviceTypes,x[n]=[];for(const d of a.response.clusters)I[n].find(u=>u.endpoint===d.endpoint)||I[n].push({endpoint:d.endpoint,id:d.id,deviceTypes:d.deviceTypes}),!["FixedLabel","Descriptor","Identify","Groups","PowerTopology"].includes(d.clusterName)&&x[n].push(d);K({...I}),O({...f}),N({...x}),r&&console.log(`DevicesIcons endpoints for "${n}":`,I[n]),r&&console.log(`DevicesIcons deviceTypes for "${n}":`,f[n]),r&&console.log(`DevicesIcons clusters for "${n}":`,x[n])}};return i(T,L.current),r&&console.log("DevicesIcons useEffect webSocket mounted"),()=>{l(T),r&&console.log("DevicesIcons useEffect webSocket unmounted")}},[]),o.useEffect(()=>(r&&console.log("DevicesIcons useEffect online mounting"),g&&(r&&console.log("DevicesIcons useEffect online sending api requests"),c({id:L.current,sender:"DevicesIcons",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:L.current,sender:"DevicesIcons",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:L.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),r&&console.log("DevicesIcons useEffect online mounted"),()=>{r&&console.log("DevicesIcons useEffect online unmounted")}),[g,c]),o.useEffect(()=>{if(s===""){H(m),R.current=m;return}const T=m.filter(a=>a.name.toLowerCase().includes(s)||a.serial.toLowerCase().includes(s));H(T),R.current=T},[m,s]);const _=o.memo(Sn);return r&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:V.map(T=>I[T.serial]&&I[T.serial].map(a=>a.deviceTypes.map(n=>e.jsx(_,{device:T,endpoint:a.endpoint,id:a.id,deviceType:n,clusters:x[T.serial].filter(d=>d.endpoint===a.endpoint)},`${T.pluginName}-${T.uniqueId}-${a.id}-${n.toString()}`))))})}const kn=o.memo(Mn),In=[{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:(s,g,c,i)=>c.configUrl?e.jsx(G,{onClick:()=>window.open(c.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(vt,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Dn=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(s,g,c,i)=>Array.isArray(s)?e.jsx(e.Fragment,{children:s.map(l=>`0x${l.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:s})},{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:(s,g,c,i)=>e.jsx(F,{title:String(s),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(s)})})}],Pn=s=>`${s.pluginName}::${s.uniqueId}`,Nn=s=>`${s.endpoint}::${s.clusterName}::${s.attributeName}`;function Wn({filter:s}){const{online:g,sendMessage:c,addListener:i,removeListener:l,getUniqueId:b}=o.useContext(ve),[p,t]=o.useState([]),[w,j]=o.useState(p),[m,y]=o.useState([]),[V,H]=o.useState(0),[I,K]=o.useState(null),[f,O]=o.useState(null),[x,N]=o.useState(null),[L,R]=o.useState(null),v=o.useRef(b()),_=o.useRef(w),T=o.useCallback(n=>{r&&console.log(`DevicesTable received state_update "${n.response.cluster}.${n.response.attribute}" for "${n.response.id}:${n.response.number}": "${n.response.value}"`,n.response);const d=_.current.find(u=>u.pluginName===n.response.plugin&&u.uniqueId===n.response.uniqueId);if(!d){r&&console.warn(`DevicesTable updater device of plugin "${n.response.plugin}" serial "${n.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(I&&f&&d.pluginName===I&&d.uniqueId===L&&n.response.number.toString()===f){const u=m.find($=>$.endpoint===n.response.number.toString()&&$.clusterName===n.response.cluster&&$.attributeName===n.response.attribute);if(!u){r&&console.warn(`DevicesTable updater cluster ${n.response.cluster}.${n.response.attribute} for device "${d.name}" serial "${d.serial}" not found in clusters`);return}u.attributeValue=String(n.response.value),u.attributeLocalValue=n.response.value,y([...m]),r&&console.log(`DevicesTable updated attribute ${u.clusterName}.${u.attributeName} for device "${d.name}" serial "${d.serial}" to "${u.attributeValue}"`)}},[m,f,I,L]);o.useEffect(()=>{const n=d=>{if(r&&console.log("DevicesTable received WebSocket Message:",d),d.method==="refresh_required"&&d.response.changed==="devices")r&&console.log(`DevicesTable received refresh_required: changed=${d.response.changed} and sending /api/devices request`),c({id:v.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(d.method==="state_update"&&d.response)T(d);else if(d.method==="/api/devices")r&&console.log(`DevicesTable received ${d.response.length} devices:`,d.response),t(d.response);else if(d.method==="/api/clusters"){r&&console.log(`DevicesTable received ${d.response.clusters.length} clusters for plugin ${d.response.plugin}:`,d.response),y(d.response.clusters);const u={};for(const $ of d.response.clusters)r&&console.log("Cluster:",$.endpoint),u[$.endpoint]?u[$.endpoint]++:u[$.endpoint]=1;H(Object.keys(u).length)}};return i(n,v.current),r&&console.log("DevicesTable added WebSocket listener"),()=>{l(n),r&&console.log("DevicesTable removed WebSocket listener")}},[c,i,l,T]),o.useEffect(()=>{g&&(r&&console.log("DevicesTable sending api requests with id ",v.current),c({id:v.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:v.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),c({id:v.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[g,c]),o.useEffect(()=>{I&&f&&(r&&console.log("DevicesTable sending /api/clusters"),c({id:v.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:I,endpoint:Number(f)}}))},[I,f,c]),o.useEffect(()=>{if(s===""){j(p),_.current=p;return}const n=p.filter(d=>d.name.toLowerCase().includes(s)||d.serial.toLowerCase().includes(s));j(n),_.current=n},[p,s]);const a=n=>{if(n.uniqueId===L){R(null),K(null),O(null),N(null);return}R(n.uniqueId),K(n.pluginName),O(n.endpoint?n.endpoint.toString():null),N(n.name)};return r&&console.log("DevicesTable rendering..."),g?e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",maxHeight:`${I&&f?"50%":"100%"}`,width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Registered devices",getRowKey:Pn,onRowClick:a,rows:w,columns:In,footerLeft:`Total devices: ${w.length.toString()}`})}),I&&f&&e.jsx("div",{className:"MbfWindowDiv",style:{margin:"0",padding:"0",gap:"0",height:"50%",maxHeight:"50%",width:"100%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(mt,{name:"Clusters",title:x||"",getRowKey:Nn,rows:m,columns:Dn,footerLeft:`Total child endpoints: ${V-1}`})})]}):e.jsx(Re,{})}const Ln=o.memo(Wn);function $n(){const{online:s}=o.useContext(ve),[g,c]=o.useState(""),[i,l]=o.useState("icon");o.useEffect(()=>{const t=localStorage.getItem("devicesFilter");t&&c(t)},[]),o.useEffect(()=>{const t=localStorage.getItem("devicesViewMode");t&&l(t)},[]);const b=t=>{c(t.target.value.toLowerCase()),localStorage.setItem("devicesFilter",t.target.value.toLowerCase())},p=t=>{l(t),localStorage.setItem("devicesViewMode",t)};return r&&console.log("Devices rendering..."),s?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{className:"MbfWindowBodyRow",style:{justifyContent:"space-between",padding:0,gap:"20px",width:"100%",height:"45px",minHeight:"45px",maxHeight:"45px"},children:[e.jsxs(X,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ae,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(ge,{variant:"outlined",value:g,onChange:b,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(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(F,{title:"Table View",children:e.jsx(Zr,{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(F,{title:"Icon View (beta)",children:e.jsx(Yr,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(Ln,{filter:g}),i==="icon"&&e.jsx(kn,{filter:g})]}):e.jsx(Re,{})}const Fn=o.memo($n);function Tn(){const[s,g]=o.useState(localStorage.getItem("logFilterLevel")??"info"),[c,i]=o.useState(localStorage.getItem("logFilterSearch")??"*"),[l,b]=o.useState(localStorage.getItem("logAutoScroll")!=="false"),{setMessages:p,setLogFilters:t,online:w,setAutoScroll:j}=o.useContext(ve),m=I=>{g(I.target.value),t(I.target.value,c),localStorage.setItem("logFilterLevel",I.target.value),r&&console.log("handleChangeLevel called with value:",I.target.value)},y=I=>{i(I.target.value),t(s,I.target.value),localStorage.setItem("logFilterSearch",I.target.value),r&&console.log("handleChangeSearch called with value:",I.target.value)},V=I=>{b(I.target.checked),j(I.target.checked),localStorage.setItem("logAutoScroll",I.target.value?"true":"false"),r&&console.log("handleAutoScrollChange called with value:",I.target.checked)},H=()=>{r&&console.log("handleClearLogsClick called"),p([])};return r&&console.log("Logs rendering..."),w?e.jsxs("div",{className:"MbfPageDiv",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",justifyContent:"space-between",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Nt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Ue,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:s,onChange:m,children:[e.jsx(k,{value:"debug",children:"Debug"}),e.jsx(k,{value:"info",children:"Info"}),e.jsx(k,{value:"notice",children:"Notice"}),e.jsx(k,{value:"warn",children:"Warn"}),e.jsx(k,{value:"error",children:"Error"}),e.jsx(k,{value:"fatal",children:"Fatal"})]}),e.jsx(Nt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(ge,{style:{width:"300px"},size:"small",id:"logsearch",variant:"outlined",value:c,onChange:y,InputProps:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}),e.jsx(Fe,{control:e.jsx(Te,{checked:l,onChange:V}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:e.jsx(F,{title:"Clear the logs",children:e.jsx(ie,{onClick:H,endIcon:e.jsx(ut,{}),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(Bt,{})})]}):e.jsx(Re,{})}const Rn=o.memo(Tn),Hn=({open:s,ip:g,onClose:c,onSave:i})=>{const l=g?g.split(".").slice(0,3).join(".")+".1":"",[b,p]=o.useState("dhcp"),[t,w]=o.useState({ip:g??"",subnet:"255.255.255.0",gateway:l,dns:l}),j=V=>H=>{w({...t,[V]:H.target.value})},m=()=>{c()},y=()=>{i({type:b,...t}),c()};return e.jsxs(Me,{open:s,onClose:(V,H)=>{H==="backdropClick"||H==="escapeKeyDown"||c()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(ke,{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(Ie,{dividers:!0,children:[e.jsxs(qt,{component:"fieldset",fullWidth:!0,children:[e.jsx(Ce,{component:"legend",children:"Select IP Configuration"}),e.jsxs(zt,{row:!0,value:b,onChange:V=>p(V.target.value),children:[e.jsx(Fe,{value:"dhcp",control:e.jsx(gt,{}),label:"DHCP"}),e.jsx(Fe,{value:"static",control:e.jsx(gt,{}),label:"Static"})]})]}),b==="static"&&e.jsxs(Le,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Le,{size:6,children:e.jsx(ge,{label:"IP Address",fullWidth:!0,value:t.ip,onChange:j("ip")})}),e.jsx(Le,{size:6,children:e.jsx(ge,{label:"Subnet Mask",fullWidth:!0,value:t.subnet,onChange:j("subnet")})}),e.jsx(Le,{size:6,children:e.jsx(ge,{label:"Gateway",fullWidth:!0,value:t.gateway,onChange:j("gateway")})}),e.jsx(Le,{size:6,children:e.jsx(ge,{label:"DNS Server",fullWidth:!0,value:t.dns,onChange:j("dns")})})]})]}),e.jsxs($e,{children:[e.jsx(ie,{onClick:m,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:y,children:"Save"})]})]})},On=({open:s,onClose:g,onSave:c})=>{const[i,l]=o.useState(""),[b,p]=o.useState(""),t=H=>{l(H.target.value)},w=H=>{p(H.target.value)},j=i.length>0&&i===b,m=()=>{g()},y=()=>{j&&(c(i),g())},V=()=>{c(""),g()};return e.jsxs(Me,{open:s,onClose:(H,I)=>{I==="backdropClick"||I==="escapeKeyDown"||g()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(ke,{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(Ie,{dividers:!0,children:e.jsx(qt,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(Le,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Le,{size:12,children:e.jsx(ge,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:t})}),e.jsx(Le,{size:12,children:e.jsx(ge,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:b,onChange:w,error:b!==""&&i!==b,helperText:b!==""&&i!==b?"Passwords do not match":""})})]})})}),e.jsxs($e,{children:[e.jsx(ie,{onClick:m,children:"Cancel"}),e.jsx(ie,{variant:"contained",onClick:y,disabled:!j,children:"Change"}),e.jsx(ie,{variant:"contained",onClick:V,children:"Reset"})]})]})};function Vn(){const{online:s,addListener:g,removeListener:c,sendMessage:i,getUniqueId:l}=o.useContext(ve),[b,p]=o.useState(null),[t,w]=o.useState(null),j=o.useRef(l());return o.useEffect(()=>{const m=y=>{y.src==="Matterbridge"&&y.dst==="Frontend"&&(y.method==="refresh_required"&&y.response.changed==="settings"&&(r&&console.log(`Settings received refresh_required: changed=${y.response.changed} and sending /api/settings request`),i({id:j.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),y.method==="/api/settings"&&(r&&console.log("Settings received /api/settings:",y.response),p(y.response.matterbridgeInformation),w(y.response.systemInformation)))};return g(m,j.current),r&&console.log("Settings added WebSocket listener"),()=>{c(m),r&&console.log("Settings removed WebSocket listener")}},[g,c,i]),o.useEffect(()=>{s&&(r&&console.log("Settings received online"),i({id:j.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[s,i]),b?(r&&console.log("Settings rendering..."),s?e.jsx("div",{className:"MbfPageDiv",children:e.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"20px",width:"100%"},children:[e.jsx(En,{matterbridgeInfo:b,systemInfo:t}),e.jsx(An,{matterbridgeInfo:b}),e.jsx(_n,{matterbridgeInfo:b})]})}):e.jsx(Re,{})):null}function En({matterbridgeInfo:s,systemInfo:g}){const{sendMessage:c,getUniqueId:i}=o.useContext(ve),[l,b]=o.useState("bridge"),[p,t]=o.useState("Info"),[w,j]=o.useState(!1),[m,y]=o.useState("dark"),[V,H]=o.useState(localStorage.getItem("homePagePlugins")!=="false"),[I,K]=o.useState(localStorage.getItem("homePageMode")??"devices"),[f,O]=o.useState(localStorage.getItem("virtualMode")??"outlet"),x=o.useRef(i()),[N,L]=o.useState(!1),R=()=>L(!1),v=U=>{r&&console.log("handleSaveNetConfig called with config:",U),c({id:x.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:U})},[_,T]=o.useState(!1),a=()=>T(!1),n=U=>{r&&console.log("handleSaveChangePassword called with password:",U),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:U}})};o.useEffect(()=>{s&&(b(s.bridgeMode==="bridge"?"bridge":"childbridge"),t(s.loggerLevel.charAt(0).toUpperCase()+s.loggerLevel.slice(1)),j(s.fileLogger),O(s.virtualMode))},[s]),o.useEffect(()=>{const U=localStorage.getItem("frontendTheme");U&&y(U)},[]);const d=U=>{r&&console.log("handleChangeBridgeMode called with value:",U.target.value),b(U.target.value),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:U.target.value}})},u=U=>{r&&console.log("handleChangeMbLoggerLevel called with value:",U.target.value),t(U.target.value),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:U.target.value}})},$=U=>{r&&console.log("handleLogOnFileMbChange called with value:",U.target.checked),j(U.target.checked),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:U.target.checked}})},pe=U=>{const oe=U.target.value;r&&console.log("handleChangeTheme called with value:",oe),y(oe),localStorage.setItem("frontendTheme",oe),document.body.setAttribute("frontend-theme",oe)},te=U=>{const oe=U.target.checked;r&&console.log("handleChangeHomePagePlugins called with value:",oe),H(oe),localStorage.setItem("homePagePlugins",oe?"true":"false")},Y=U=>{const oe=U.target.value;r&&console.log("handleChangeHomePageMode called with value:",oe),K(oe),localStorage.setItem("homePageMode",oe)},xe=U=>{const oe=U.target.value;r&&console.log("handleChangeVirtualMode called with value:",oe),O(oe),localStorage.setItem("virtualMode",oe),c({id:x.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:oe}})};return!s||!g?null:e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge settings"})}),e.jsx(Hn,{open:N,ip:g.ipv4Address,onClose:R,onSave:v}),e.jsx(On,{open:_,onClose:a,onSave:n}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Matterbridge mode:"}),e.jsxs(zt,{row:!0,name:"mode-buttons-group",value:l,onChange:d,children:[e.jsx(Fe,{value:"bridge",control:e.jsx(gt,{}),label:"Bridge",disabled:s.readOnly===!0}),e.jsx(Fe,{value:"childbridge",control:e.jsx(gt,{}),label:"Childbridge",disabled:s.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:p,onChange:u,children:[e.jsx(k,{value:"Debug",children:"Debug"}),e.jsx(k,{value:"Info",children:"Info"}),e.jsx(k,{value:"Notice",children:"Notice"}),e.jsx(k,{value:"Warn",children:"Warn"}),e.jsx(k,{value:"Error",children:"Error"}),e.jsx(k,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Te,{checked:w,onChange:$,name:"logOnFileMb"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:m,onChange:pe,children:[e.jsx(k,{value:"classic",children:"Classic"}),e.jsx(k,{value:"light",children:"Light"}),e.jsx(k,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(Te,{checked:V,onChange:te,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:I,onChange:Y,children:[e.jsx(k,{value:"logs",children:"Logs"}),e.jsx(k,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:f,onChange:xe,children:[e.jsx(k,{value:"disabled",children:"Disabled"}),e.jsx(k,{value:"outlet",children:"Outlet"}),e.jsx(k,{value:"light",children:"Light"}),e.jsx(k,{value:"switch",children:"Switch"}),e.jsx(k,{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:()=>T(!0),children:"Change password"})}),s.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ie,{variant:"contained",color:"primary",onClick:()=>L(!0),children:"Configure IP"})})]})})]})}function An({matterbridgeInfo:s}){const{sendMessage:g,getUniqueId:c}=o.useContext(ve),[i,l]=o.useState("Info"),[b,p]=o.useState(!1),[t,w]=o.useState(""),[j,m]=o.useState(""),[y,V]=o.useState(""),[H,I]=o.useState(""),[K,f]=o.useState(""),[O,x]=o.useState(""),N=o.useRef(c());o.useEffect(()=>{s&&(l(["Debug","Info","Notice","Warn","Error","Fatal"][s.matterLoggerLevel]),p(s.matterFileLogger),w(s.matterMdnsInterface||""),m(s.matterIpv4Address||""),V(s.matterIpv6Address||""),I(s.matterPort?s.matterPort.toString():""),f(s.matterDiscriminator?s.matterDiscriminator.toString():""),x(s.matterPasscode?s.matterPasscode.toString():""))},[s]);const L=u=>{r&&console.log("handleChangeMjLoggerLevel called with value:",u.target.value),l(u.target.value),g({id:N.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:u.target.value}})},R=u=>{r&&console.log("handleLogOnFileMjChange called with value:",u.target.checked),p(u.target.checked),g({id:N.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:u.target.checked}})},v=u=>{r&&console.log("handleChangeMdnsInterface called with value:",u.target.value),w(u.target.value),g({id:N.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:u.target.value}})},_=u=>{r&&console.log("handleChangeIpv4Address called with value:",u.target.value),m(u.target.value),g({id:N.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:u.target.value}})},T=u=>{r&&console.log("handleChangeIpv6Address called with value:",u.target.value),V(u.target.value),g({id:N.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:u.target.value}})},a=u=>{r&&console.log("handleChangeMatterPort called with value:",u.target.value),I(u.target.value),g({id:N.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:u.target.value}})},n=u=>{r&&console.log("handleChangeMatterDiscriminator called with value:",u.target.value),f(u.target.value),g({id:N.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:u.target.value}})},d=u=>{r&&console.log("handleChangemMatterPasscode called with value:",u.target.value),x(u.target.value),g({id:N.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:u.target.value}})};return s?e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matter settings"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},id:"mjdebug-info",children:"Logger level:"}),e.jsxs(Ue,{style:{height:"30px"},labelId:"select-mjlevel",id:"mjdebug-level",value:i,onChange:L,children:[e.jsx(k,{value:"Debug",children:"Debug"}),e.jsx(k,{value:"Info",children:"Info"}),e.jsx(k,{value:"Notice",children:"Notice"}),e.jsx(k,{value:"Warn",children:"Warn"}),e.jsx(k,{value:"Error",children:"Error"}),e.jsx(k,{value:"Fatal",children:"Fatal"})]}),e.jsx(Fe,{style:{padding:"0px",margin:"0px"},control:e.jsx(Te,{checked:b,onChange:R,name:"logOnFileMj"}),label:"Log on file:",labelPlacement:"start"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Mdns interface:"}),e.jsx(ge,{value:t,onChange:v,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:s.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Ipv4 address:"}),e.jsx(ge,{value:j,onChange:_,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:s.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Ipv6 address:"}),e.jsx(ge,{value:y,onChange:T,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:s.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Commissioning port:"}),e.jsx(ge,{value:H,onChange:a,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:s.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Commissioning discriminator:"}),e.jsx(ge,{value:K,onChange:n,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:s.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(Ce,{style:{padding:"0px",margin:"0px"},children:"Commissioning passcode:"}),e.jsx(ge,{value:O,onChange:d,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:s.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})})]}):null}function _n({matterbridgeInfo:s}){return s?e.jsxs("div",{className:"MbfWindowDiv",style:{flex:"0 0 auto"},children:[e.jsx("div",{className:"MbfWindowHeader",children:e.jsx("p",{className:"MbfWindowHeaderText",children:"Matterbridge info"})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px",flex:"0 0 auto"},children:e.jsxs(X,{sx:{gap:"10px",margin:"0px",padding:"10px",width:"400px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[" ",e.jsx(Oe,{value:s.matterbridgeVersion,label:"Current Version"}),e.jsx(Oe,{value:s.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Oe,{value:s.homeDirectory,label:"Home Directory"}),e.jsx(Oe,{value:s.rootDirectory,label:"Root Directory"}),e.jsx(Oe,{value:s.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Oe,{value:s.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Oe,{value:s.globalModulesDirectory,label:"Global Module Directory"})]})})]}):null}function Oe({value:s,label:g}){return e.jsx(ge,{focused:!0,value:s,size:"small",label:g,variant:"standard",sx:{width:"400px"},InputProps:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},InputLabelProps:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}})}const qn=o.memo(Vn);function zn(){const{online:s,sendMessage:g,addListener:c,removeListener:i,getUniqueId:l}=o.useContext(ve),{showSnackbarMessage:b}=o.useContext(Be),[p,t]=o.useState(null),[w,j]=o.useState([]),[m,y]=o.useState([]),[V,H]=o.useState(null),[I,K]=o.useState({cpuUsage:0}),[f,O]=o.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[x,N]=o.useState({systemUptime:"",processUptime:""}),L=o.useRef(l());return r&&console.log("Test uniqueId:",L),o.useEffect(()=>{r&&console.log("Test useEffect WebSocketMessage mounting");const R=v=>{if(v.method==="restart_required")r&&console.log("Test received restart_required"),b("Restart required",0);else if(v.method==="refresh_required")r&&console.log(`Test received refresh_required: changed=${v.response.changed} and sending api requests`),b("Refresh required",0),g({id:L.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),g({id:L.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),g({id:L.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(v.method==="memory_update")r&&console.log("Test received memory_update",v),O(v.response);else if(v.method==="cpu_update")r&&console.log("Test received cpu_update",v),K(v.response);else if(v.method==="uptime_update")r&&console.log("Test received uptime_update",v),N(v.response);else if(v.method==="/api/settings"&&v.response)r&&console.log("Test received /api/settings:",v.response),b("Test received /api/settings",0),t(v.response);else if(v.method==="/api/plugins"&&v.response)r&&console.log(`Test received ${v.response.length} plugins:`,v.response),b("Test received /api/plugins",0),j(v.response);else if(v.method==="/api/devices"&&v.response){r&&console.log(`Test received ${v.response.length} devices:`,v.response),b("Test received /api/devices",0),y(v.response);for(const _ of v.response)r&&console.log("Test sending /api/clusters for device:",_.pluginName,_.name,_.endpoint),g({id:L.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:_.pluginName,endpoint:_.endpoint||0}})}else v.method==="/api/clusters"&&v.response&&(r&&console.log(`Test received ${v.response.clusters.length} clusters for device ${v.response.deviceName} endpoint ${v.response.id}:${v.response.number}:`,v),b(`Test received /api/clusters for ${v.response.plugin}::${v.response.deviceName}`,0),H(v.response))};return c(R,L.current),r&&console.log("Test useEffect WebSocketMessage mounted"),()=>{r&&console.log("Test useEffect WebSocketMessage unmounting"),i(R),r&&console.log("Test useEffect WebSocketMessage unmounted")}},[c,i,g,b]),o.useEffect(()=>(r&&console.log("Test useEffect online mounting"),s&&r&&console.log("Test useEffect online received online"),r&&console.log("Test useEffect online mounted"),()=>{r&&console.log("Test useEffect online unmounted")}),[s,g,b]),r&&console.log("Test rendering..."),s?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(Re,{})}const Un=o.memo(zn);function Bn(s,g){r&&console.log("getCssVariable:",s,"defaultValue",g);const c=getComputedStyle(document.body).getPropertyValue(s).trim();return c||console.error("getCssVariable: undefined",c),c||g}function Qn(s){return Xr({palette:{primary:{main:s},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}let r=!1;const Gn=()=>{r=!r};function Kn({setLoggedIn:s}){const[g,c]=o.useState(""),[i,l]=o.useState(""),b={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)"},t={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)"},w=async m=>{try{const y=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:m})});if(y.ok){const{valid:V}=await y.json();V?s(!0):m!==""&&l("Incorrect password!")}else console.error("Failed to log in:",y.statusText)}catch(y){console.error("Failed to log in:",y)}},j=m=>{m.preventDefault(),w(g)};return w(""),e.jsx("div",{style:b,children:e.jsxs("form",{onSubmit:j,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:g,onChange:m=>c(m.target.value),style:t,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 Jn(){const[s,g]=o.useState(!1);r&&console.log("Setting frontend theme");const c=localStorage.getItem("frontendTheme");r&&console.log("Saved theme:",c),c?document.body.setAttribute("frontend-theme",c):document.body.setAttribute("frontend-theme","dark");const i=Bn("--primary-color","#1976d2");r&&console.log("Primary color from CSS:",i);const l=Qn(i),b=window.location.pathname.includes("/matterbridge/")?"/matterbridge":window.location.href.includes("/api/hassio_ingress/")?window.location.pathname:"/";return r&&(console.log("Loading App..."),console.log(`- with href = "${window.location.href}"`),console.log(`- pathname = "${window.location.pathname}"`),console.log(`- baseName = "${b}"`)),s?e.jsx(eo,{theme:l,children:e.jsx(cr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(Ho,{children:e.jsx(Oo,{children:e.jsx(nr,{basename:b,children:e.jsxs("div",{className:"MbfScreen",children:[e.jsx(Eo,{}),e.jsxs(ir,{children:[e.jsx(Ve,{path:"/",element:e.jsx(un,{})}),e.jsx(Ve,{path:"/devices",element:e.jsx(Fn,{})}),e.jsx(Ve,{path:"/log",element:e.jsx(Rn,{})}),e.jsx(Ve,{path:"/settings",element:e.jsx(qn,{})}),e.jsx(Ve,{path:"/test",element:e.jsx(Un,{})}),e.jsx(Ve,{path:"*",element:e.jsx(sr,{to:"/"})})]})]})})})})})}):e.jsx(Kn,{setLoggedIn:g})}ar.createRoot(document.getElementById("root")).render(e.jsx(lr.StrictMode,{children:e.jsx(Jn,{})}));
|