matterbridge 3.5.2 → 3.5.3-dev-20260202-e19e9b6
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 +30 -1
- package/README-DOCKER.md +2 -2
- package/README.md +14 -9
- package/dist/broadcastServer.d.ts +0 -115
- package/dist/broadcastServer.js +0 -117
- package/dist/broadcastServerTypes.d.ts +0 -43
- package/dist/broadcastServerTypes.js +0 -24
- package/dist/checkUpdates.d.ts +0 -75
- package/dist/checkUpdates.js +1 -91
- package/dist/cli.d.ts +0 -24
- package/dist/cli.js +1 -97
- package/dist/cliEmitter.d.ts +0 -36
- package/dist/cliEmitter.js +0 -37
- package/dist/cliHistory.d.ts +0 -42
- package/dist/cliHistory.js +0 -38
- package/dist/clusters/export.d.ts +0 -1
- package/dist/clusters/export.js +0 -2
- package/dist/deviceManager.d.ts +0 -108
- package/dist/deviceManager.js +1 -114
- package/dist/devices/airConditioner.d.ts +0 -75
- package/dist/devices/airConditioner.js +0 -57
- package/dist/devices/basicVideoPlayer.d.ts +0 -58
- package/dist/devices/basicVideoPlayer.js +1 -56
- package/dist/devices/batteryStorage.d.ts +0 -43
- package/dist/devices/batteryStorage.js +1 -48
- package/dist/devices/castingVideoPlayer.d.ts +0 -63
- package/dist/devices/castingVideoPlayer.js +2 -65
- package/dist/devices/cooktop.d.ts +0 -55
- package/dist/devices/cooktop.js +0 -56
- package/dist/devices/dishwasher.d.ts +0 -55
- package/dist/devices/dishwasher.js +0 -57
- package/dist/devices/evse.d.ts +0 -57
- package/dist/devices/evse.js +10 -74
- package/dist/devices/export.d.ts +0 -1
- package/dist/devices/export.js +0 -5
- package/dist/devices/extractorHood.d.ts +0 -41
- package/dist/devices/extractorHood.js +0 -43
- package/dist/devices/heatPump.d.ts +0 -43
- package/dist/devices/heatPump.js +2 -50
- package/dist/devices/laundryDryer.d.ts +0 -58
- package/dist/devices/laundryDryer.js +3 -62
- package/dist/devices/laundryWasher.d.ts +0 -64
- package/dist/devices/laundryWasher.js +4 -70
- package/dist/devices/microwaveOven.d.ts +1 -77
- package/dist/devices/microwaveOven.js +5 -88
- package/dist/devices/oven.d.ts +0 -82
- package/dist/devices/oven.js +0 -85
- package/dist/devices/refrigerator.d.ts +0 -100
- package/dist/devices/refrigerator.js +0 -102
- package/dist/devices/roboticVacuumCleaner.d.ts +0 -83
- package/dist/devices/roboticVacuumCleaner.js +9 -100
- package/dist/devices/solarPower.d.ts +0 -36
- package/dist/devices/solarPower.js +0 -38
- package/dist/devices/speaker.d.ts +0 -79
- package/dist/devices/speaker.js +0 -84
- package/dist/devices/temperatureControl.d.ts +0 -21
- package/dist/devices/temperatureControl.js +3 -24
- package/dist/devices/waterHeater.d.ts +0 -74
- package/dist/devices/waterHeater.js +2 -82
- package/dist/dgram/export.d.ts +0 -1
- package/dist/dgram/export.js +0 -1
- package/dist/frontend.d.ts +0 -187
- package/dist/frontend.js +37 -498
- package/dist/frontendTypes.d.ts +0 -57
- package/dist/frontendTypes.js +0 -45
- package/dist/helpers.d.ts +0 -43
- package/dist/helpers.js +0 -54
- package/dist/index.d.ts +0 -23
- package/dist/index.js +0 -25
- package/dist/jestutils/export.d.ts +0 -1
- package/dist/jestutils/export.js +0 -1
- package/dist/jestutils/jestHelpers.d.ts +0 -255
- package/dist/jestutils/jestHelpers.js +15 -371
- package/dist/logger/export.d.ts +0 -1
- package/dist/logger/export.js +0 -1
- package/dist/matter/behaviors.d.ts +0 -1
- package/dist/matter/behaviors.js +0 -2
- package/dist/matter/clusters.d.ts +0 -1
- package/dist/matter/clusters.js +0 -2
- package/dist/matter/devices.d.ts +0 -1
- package/dist/matter/devices.js +0 -2
- package/dist/matter/endpoints.d.ts +0 -1
- package/dist/matter/endpoints.js +0 -2
- package/dist/matter/export.d.ts +0 -1
- package/dist/matter/export.js +0 -2
- package/dist/matter/types.d.ts +0 -1
- package/dist/matter/types.js +0 -2
- package/dist/matterNode.d.ts +0 -258
- package/dist/matterNode.js +8 -359
- package/dist/matterbridge.d.ts +0 -373
- package/dist/matterbridge.js +46 -854
- package/dist/matterbridgeAccessoryPlatform.d.ts +0 -42
- package/dist/matterbridgeAccessoryPlatform.js +0 -50
- package/dist/matterbridgeBehaviors.d.ts +0 -24
- package/dist/matterbridgeBehaviors.js +5 -65
- package/dist/matterbridgeDeviceTypes.d.ts +0 -649
- package/dist/matterbridgeDeviceTypes.js +6 -673
- package/dist/matterbridgeDynamicPlatform.d.ts +0 -42
- package/dist/matterbridgeDynamicPlatform.js +0 -50
- package/dist/matterbridgeEndpoint.d.ts +0 -1369
- package/dist/matterbridgeEndpoint.js +54 -1507
- package/dist/matterbridgeEndpointHelpers.d.ts +0 -425
- package/dist/matterbridgeEndpointHelpers.js +20 -482
- package/dist/matterbridgeEndpointTypes.d.ts +0 -70
- package/dist/matterbridgeEndpointTypes.js +0 -25
- package/dist/matterbridgePlatform.d.ts +0 -434
- package/dist/matterbridgePlatform.js +1 -472
- package/dist/matterbridgePlatformTypes.d.ts +0 -29
- package/dist/matterbridgePlatformTypes.js +0 -24
- package/dist/matterbridgeTypes.d.ts +0 -46
- package/dist/matterbridgeTypes.js +0 -26
- package/dist/mb_coap.d.ts +0 -23
- package/dist/mb_coap.js +3 -41
- package/dist/mb_health.d.ts +0 -67
- package/dist/mb_health.js +0 -70
- package/dist/mb_mdns.d.ts +0 -23
- package/dist/mb_mdns.js +36 -94
- package/dist/pluginManager.d.ts +0 -305
- package/dist/pluginManager.js +5 -342
- package/dist/shelly.d.ts +0 -157
- package/dist/shelly.js +7 -178
- package/dist/spawn.d.ts +0 -32
- package/dist/spawn.js +1 -71
- package/dist/storage/export.d.ts +0 -1
- package/dist/storage/export.js +0 -1
- package/dist/utils/export.d.ts +0 -1
- package/dist/utils/export.js +0 -1
- package/dist/worker.d.ts +0 -61
- package/dist/worker.js +4 -65
- package/dist/workerCheckUpdates.d.ts +0 -24
- package/dist/workerCheckUpdates.js +5 -36
- package/dist/workerGlobalPrefix.d.ts +0 -24
- package/dist/workerGlobalPrefix.js +5 -36
- package/dist/workerTypes.d.ts +0 -25
- package/dist/workerTypes.js +0 -24
- package/frontend/build/assets/index.js +4 -4
- package/frontend/build/assets/vendor_emotion.js +1 -1
- package/frontend/build/assets/vendor_lodash.js +1 -1
- package/frontend/build/assets/vendor_mdi.js +1 -1
- package/frontend/build/assets/vendor_mui.js +22 -22
- package/frontend/build/assets/vendor_node_modules.js +20 -20
- package/frontend/build/assets/vendor_notistack.js +2 -2
- package/frontend/build/assets/vendor_qrcode.js +1 -1
- package/frontend/build/assets/vendor_rjsf.js +8 -8
- package/frontend/build/index.html +1 -1
- package/frontend/package.json +48 -47
- package/npm-shrinkwrap.json +77 -47
- package/package.json +7 -7
- package/dist/broadcastServer.d.ts.map +0 -1
- package/dist/broadcastServer.js.map +0 -1
- package/dist/broadcastServerTypes.d.ts.map +0 -1
- package/dist/broadcastServerTypes.js.map +0 -1
- package/dist/checkUpdates.d.ts.map +0 -1
- package/dist/checkUpdates.js.map +0 -1
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/cliEmitter.d.ts.map +0 -1
- package/dist/cliEmitter.js.map +0 -1
- package/dist/cliHistory.d.ts.map +0 -1
- package/dist/cliHistory.js.map +0 -1
- package/dist/clusters/export.d.ts.map +0 -1
- package/dist/clusters/export.js.map +0 -1
- package/dist/deviceManager.d.ts.map +0 -1
- package/dist/deviceManager.js.map +0 -1
- package/dist/devices/airConditioner.d.ts.map +0 -1
- package/dist/devices/airConditioner.js.map +0 -1
- package/dist/devices/basicVideoPlayer.d.ts.map +0 -1
- package/dist/devices/basicVideoPlayer.js.map +0 -1
- package/dist/devices/batteryStorage.d.ts.map +0 -1
- package/dist/devices/batteryStorage.js.map +0 -1
- package/dist/devices/castingVideoPlayer.d.ts.map +0 -1
- package/dist/devices/castingVideoPlayer.js.map +0 -1
- package/dist/devices/cooktop.d.ts.map +0 -1
- package/dist/devices/cooktop.js.map +0 -1
- package/dist/devices/dishwasher.d.ts.map +0 -1
- package/dist/devices/dishwasher.js.map +0 -1
- package/dist/devices/evse.d.ts.map +0 -1
- package/dist/devices/evse.js.map +0 -1
- package/dist/devices/export.d.ts.map +0 -1
- package/dist/devices/export.js.map +0 -1
- package/dist/devices/extractorHood.d.ts.map +0 -1
- package/dist/devices/extractorHood.js.map +0 -1
- package/dist/devices/heatPump.d.ts.map +0 -1
- package/dist/devices/heatPump.js.map +0 -1
- package/dist/devices/laundryDryer.d.ts.map +0 -1
- package/dist/devices/laundryDryer.js.map +0 -1
- package/dist/devices/laundryWasher.d.ts.map +0 -1
- package/dist/devices/laundryWasher.js.map +0 -1
- package/dist/devices/microwaveOven.d.ts.map +0 -1
- package/dist/devices/microwaveOven.js.map +0 -1
- package/dist/devices/oven.d.ts.map +0 -1
- package/dist/devices/oven.js.map +0 -1
- package/dist/devices/refrigerator.d.ts.map +0 -1
- package/dist/devices/refrigerator.js.map +0 -1
- package/dist/devices/roboticVacuumCleaner.d.ts.map +0 -1
- package/dist/devices/roboticVacuumCleaner.js.map +0 -1
- package/dist/devices/solarPower.d.ts.map +0 -1
- package/dist/devices/solarPower.js.map +0 -1
- package/dist/devices/speaker.d.ts.map +0 -1
- package/dist/devices/speaker.js.map +0 -1
- package/dist/devices/temperatureControl.d.ts.map +0 -1
- package/dist/devices/temperatureControl.js.map +0 -1
- package/dist/devices/waterHeater.d.ts.map +0 -1
- package/dist/devices/waterHeater.js.map +0 -1
- package/dist/dgram/export.d.ts.map +0 -1
- package/dist/dgram/export.js.map +0 -1
- package/dist/frontend.d.ts.map +0 -1
- package/dist/frontend.js.map +0 -1
- package/dist/frontendTypes.d.ts.map +0 -1
- package/dist/frontendTypes.js.map +0 -1
- package/dist/helpers.d.ts.map +0 -1
- package/dist/helpers.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/jestutils/export.d.ts.map +0 -1
- package/dist/jestutils/export.js.map +0 -1
- package/dist/jestutils/jestHelpers.d.ts.map +0 -1
- package/dist/jestutils/jestHelpers.js.map +0 -1
- package/dist/logger/export.d.ts.map +0 -1
- package/dist/logger/export.js.map +0 -1
- package/dist/matter/behaviors.d.ts.map +0 -1
- package/dist/matter/behaviors.js.map +0 -1
- package/dist/matter/clusters.d.ts.map +0 -1
- package/dist/matter/clusters.js.map +0 -1
- package/dist/matter/devices.d.ts.map +0 -1
- package/dist/matter/devices.js.map +0 -1
- package/dist/matter/endpoints.d.ts.map +0 -1
- package/dist/matter/endpoints.js.map +0 -1
- package/dist/matter/export.d.ts.map +0 -1
- package/dist/matter/export.js.map +0 -1
- package/dist/matter/types.d.ts.map +0 -1
- package/dist/matter/types.js.map +0 -1
- package/dist/matterNode.d.ts.map +0 -1
- package/dist/matterNode.js.map +0 -1
- package/dist/matterbridge.d.ts.map +0 -1
- package/dist/matterbridge.js.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
- package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
- package/dist/matterbridgeBehaviors.d.ts.map +0 -1
- package/dist/matterbridgeBehaviors.js.map +0 -1
- package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
- package/dist/matterbridgeDeviceTypes.js.map +0 -1
- package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
- package/dist/matterbridgeDynamicPlatform.js.map +0 -1
- package/dist/matterbridgeEndpoint.d.ts.map +0 -1
- package/dist/matterbridgeEndpoint.js.map +0 -1
- package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
- package/dist/matterbridgeEndpointHelpers.js.map +0 -1
- package/dist/matterbridgeEndpointTypes.d.ts.map +0 -1
- package/dist/matterbridgeEndpointTypes.js.map +0 -1
- package/dist/matterbridgePlatform.d.ts.map +0 -1
- package/dist/matterbridgePlatform.js.map +0 -1
- package/dist/matterbridgePlatformTypes.d.ts.map +0 -1
- package/dist/matterbridgePlatformTypes.js.map +0 -1
- package/dist/matterbridgeTypes.d.ts.map +0 -1
- package/dist/matterbridgeTypes.js.map +0 -1
- package/dist/mb_coap.d.ts.map +0 -1
- package/dist/mb_coap.js.map +0 -1
- package/dist/mb_health.d.ts.map +0 -1
- package/dist/mb_health.js.map +0 -1
- package/dist/mb_mdns.d.ts.map +0 -1
- package/dist/mb_mdns.js.map +0 -1
- package/dist/pluginManager.d.ts.map +0 -1
- package/dist/pluginManager.js.map +0 -1
- package/dist/shelly.d.ts.map +0 -1
- package/dist/shelly.js.map +0 -1
- package/dist/spawn.d.ts.map +0 -1
- package/dist/spawn.js.map +0 -1
- package/dist/storage/export.d.ts.map +0 -1
- package/dist/storage/export.js.map +0 -1
- package/dist/utils/export.d.ts.map +0 -1
- package/dist/utils/export.js.map +0 -1
- package/dist/worker.d.ts.map +0 -1
- package/dist/worker.js.map +0 -1
- package/dist/workerCheckUpdates.d.ts.map +0 -1
- package/dist/workerCheckUpdates.js.map +0 -1
- package/dist/workerGlobalPrefix.d.ts.map +0 -1
- package/dist/workerGlobalPrefix.js.map +0 -1
- package/dist/workerTypes.d.ts.map +0 -1
- package/dist/workerTypes.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
2
|
-
`).map((
|
|
3
|
-
`)},[]),
|
|
4
|
-
`)),["debug","info","notice","warn","error","fatal"].includes(f.response.level)&&(oe.current==="info"&&f.response.level==="debug"||oe.current==="notice"&&(f.response.level==="debug"||f.response.level==="info")||oe.current==="warn"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice")||oe.current==="error"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice"||f.response.level==="warn")||oe.current==="fatal"&&(f.response.level==="debug"||f.response.level==="info"||f.response.level==="notice"||f.response.level==="warn"||f.response.level==="error")))||v.current!=="*"&&v.current!==""&&!v.current.startsWith("/")&&!v.current.endsWith("/")&&!f.response.message.toLowerCase().includes(v.current.toLowerCase())&&!f.response.name.toLowerCase().includes(v.current.toLowerCase())||v.current.startsWith("/")&&v.current.endsWith("/")&&(()=>{try{const Z=new RegExp(v.current.slice(1,-1),"i");return!Z.test(f.response.message)&&!Z.test(f.response.name)}catch(Z){return console.error(`WebSocket log search invalid regex filter "${v.current}":`,Z),!1}})()||f.response.name==="Commissioning"&&f.response.message.includes("is uncommissioned"))return;l(Z=>{const D=[...Z,{level:f.response.level,time:f.response.time,name:f.response.name,message:f.response.message}];return o&&console.log(`WebSocket new log message added (${D.length}/${x.current}):`,D[D.length-1]),D.length>x.current+x.current*10/100?(o&&console.log(`WebSocket sliced log messages to the last ${x.current} entries`),D.slice(D.length-x.current)):D})}else{if(o&&console.log(`WebSocket received message id ${f.id} method ${f.method}:`,f),f.id===0)h.current.forEach(ce=>ce.listener(f));else{const ce=h.current.find(Z=>Z.id===f.id);ce?ce.listener(f):console.warn(`WebSocket no listener found for message id ${f.id}:`,f)}return}}catch(f){console.error(`WebSocket error parsing message: ${f}`,f instanceof Error?f.stack:null)}},p.current.onopen=()=>{o&&console.log(`WebSocket: Connected to WebSocket: ${N}`),$("WebSocket",`Connected to WebSocket: ${N}`),t(!0),w(),u.current=1,H.current=setTimeout(()=>{S.current=setInterval(()=>{F({id:I.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>{o&&console.error(`WebSocketUse: No pong response received from WebSocket: ${N}`),$("WebSocket",`No pong response received from WebSocket: ${N}`),t(!1)},1e3*Ie)},1e3*be)},1e3*O)},p.current.onclose=()=>{o&&console.error(`WebSocket: Disconnected from WebSocket ${mt?"with Ingress":""}: ${N}`),$("WebSocket",`Disconnected from WebSocket: ${N}`),t(!1),w(),V(),H.current&&clearTimeout(H.current),P.current&&clearTimeout(P.current),S.current&&clearInterval(S.current),$("WebSocket",`Reconnecting (attempt ${u.current} of ${re}) to WebSocket${mt?" (Ingress)":""}: ${N}`),mt?setTimeout(Y,5e3):u.current===1?Y():u.current<re?setTimeout(Y,1e3*u.current):$("WebSocket",`Reconnect attempts exceeded limit of ${re} retries, refresh the page to reconnect to: ${N}`),u.current=u.current+1},p.current.onerror=J=>{o&&console.error(`WebSocket: WebSocket error connecting to ${N}:`,J),$("WebSocket",`WebSocket error connecting to ${N}`)})},[N]),Y=r.useCallback(()=>{o&&console.log(`WebSocket attemptReconnect ${u.current}/${re} to:`,N),R()},[R]);r.useEffect(()=>(R(),()=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.close()}),[R]);const ue=r.useMemo(()=>({messages:d,logLength:x,logAutoScroll:k,logFilterLevel:i,logFilterSearch:m,setMessages:l,setLogFilterLevel:s,setLogFilterSearch:g,filterLogMessages:K}),[d,x,k,i,m,l,s,g,K]),de=r.useMemo(()=>({logLength:x,logAutoScroll:k,logFilterLevel:i,logFilterSearch:m,setMessages:l,setLogFilterLevel:s,setLogFilterSearch:g,filterLogMessages:K,online:b,retry:u.current,getUniqueId:T,addListener:L,removeListener:M,sendMessage:F,logMessage:$}),[x,k,l,s,g,b,u.current,L,M,F,$]);return e.jsx(jr.Provider,{value:ue,children:e.jsx(xe.Provider,{value:de,children:n})})}function jn(n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 296.2 296.2",...n,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"lg1",x1:"16.6",y1:"16.6",x2:"279.6",y2:"279.6",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".1",stopColor:"#3faa77"}),e.jsx("stop",{offset:".3",stopColor:"#234148"}),e.jsx("stop",{offset:".7",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#ad2e6e"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg2",x1:"31.1",y1:"31.1",x2:"265.1",y2:"265.1",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".2",stopColor:"#285251"}),e.jsx("stop",{offset:".4",stopColor:"#234148"}),e.jsx("stop",{offset:".8",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#a8316c"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg3",x1:"116.2",y1:"143.9",x2:"139.8",y2:"143.9",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#8bc751"}),e.jsx("stop",{offset:"1",stopColor:"#0db14b"})]}),e.jsx("linearGradient",{id:"lg4",x1:"136.1",y1:"100.8",x2:"159.6",y2:"100.8",xlinkHref:"#lg3"}),e.jsx("linearGradient",{id:"lg5",x1:"155.3",y1:"143.9",x2:"178.9",y2:"143.9",xlinkHref:"#lg3"}),e.jsxs("linearGradient",{id:"lg6",x1:"46.8",y1:"25.7",x2:"89.6",y2:"74.8",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#b1d34a"}),e.jsx("stop",{offset:"1",stopColor:"#50b848"})]})]}),e.jsx("rect",{width:"296.2",height:"296.2",rx:"56.7",ry:"56.7",style:{fill:"url(#lg1)"}}),e.jsx("rect",{x:"16.3",y:"16.3",width:"263.6",height:"263.6",rx:"50.5",ry:"50.5",style:{fill:"url(#lg2)"}}),e.jsx("circle",{cx:"128",cy:"143.9",r:"11.8",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"147.8",cy:"100.8",r:"11.8",style:{fill:"url(#lg4)"}}),e.jsx("path",{d:"m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"167.1",cy:"143.9",r:"11.8",style:{fill:"url(#lg5)"}}),e.jsx("path",{fill:"#fff",d:"M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z"}),e.jsx("path",{d:"M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z",style:{fill:"url(#lg6)"}}),e.jsx("path",{d:"M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z",fill:"#1e5857"}),e.jsx("path",{fill:"#fff",d:"M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z"})]})}function _e(){const{retry:n}=r.useContext(xe),d=()=>{window.location.reload()};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center",fontSize:"20px",color:"var(--main-text-color)",backgroundColor:"var(--main-bg-color)"},children:[e.jsx(jn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(Qr,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+n+")","..."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{})]}),e.jsx(ae,{variant:"contained",color:"primary",onClick:d,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function Cr({value:n,maxChars:d}){let l=n;if(n.length>d&&d>3){const i=d-3,s=n.substring(0,Math.ceil(i/2)),m=n.substring(n.length-Math.floor(i/2),n.length);l=`${s} … ${m}`}return n!==l?e.jsx(_,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:l})}):e.jsx("span",{children:l})}function je({children:n,style:d}){const l={display:"flex",flexDirection:"column",flex:"0 0 auto",width:"100%",overflow:"hidden",margin:"0px",padding:"0px",gap:"0px",backgroundColor:"var(--div-bg-color)",boxShadow:"5px 5px 10px var(--div-shadow-color)",border:"1px solid var(--table-border-color)",borderRadius:"var(--div-border-radius)",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function De({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",borderBottom:"1px solid var(--table-border-color)",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function Ce({children:n,style:d}){const l={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function gt({children:n,style:d}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...d},children:n})}function lt({children:n,style:d}){const l={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function pt({children:n,style:d}){const l={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...d},children:n})}function Ne({children:n,style:d,onDragOver:l,onDragLeave:i,onDrop:s}){const m={flex:"0 0 auto",display:"flex",flexDirection:"row",overflow:"hidden",alignItems:"start",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"};return e.jsx("div",{style:{...m,...d},onDragOver:l,onDragLeave:i,onDrop:s,children:n})}function Ze({children:n,style:d,close:l}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...d},children:[n,Oi]})}function Cn({systemInfo:n,compact:d}){const{mobile:l}=r.useContext(Le),{addListener:i,removeListener:s,getUniqueId:m,sendMessage:g}=r.useContext(xe),[b,t]=r.useState(n),W=r.useRef(m());if(o&&console.log("SystemInfoTable loading with systemInfo:",b,"compact:",d),n&&d&&b.totalMemory&&b.freeMemory){const h=b.totalMemory,p=b.freeMemory;b.freeMemory=`${p} / ${h}`,b.totalMemory=""}if(n&&d&&b.heapTotal&&b.heapUsed){const h=b.heapTotal,p=b.heapUsed;b.heapUsed=`${p} / ${h}`,b.heapTotal=""}if(n&&d&&b.osRelease&&b.osType){const h=b.osType,p=b.osRelease;b.osType=`${h} (${p})`,b.osRelease=""}if(n&&d&&b.osArch&&b.osPlatform){const h=b.osPlatform,p=b.osArch;b.osPlatform=`${h} (${p})`,b.osArch=""}const y=(h,p,u,I,S)=>{t(P=>({...P,totalMemory:h,freeMemory:p,heapTotal:u,heapUsed:I,rss:S}))},w=h=>{t(p=>({...p,cpuUsage:h.toFixed(2)+" %"}))},j=h=>{t(p=>({...p,processCpuUsage:h.toFixed(2)+" %"}))},V=(h,p)=>{t(u=>({...u,systemUptime:h,processUptime:p}))},q=()=>{o&&console.log("SystemInfoTable handleViewHistory clicked"),g({id:W.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};r.useEffect(()=>{const h=p=>{o&&console.log("SystemInfoTable received WebSocket Message:",p),p.method==="memory_update"&&p.response&&p.response.totalMemory&&p.response.freeMemory&&p.response.heapTotal&&p.response.heapUsed&&p.response.rss?(o&&console.log("SystemInfoTable received memory_update",p),y(p.response.totalMemory,p.response.freeMemory,p.response.heapTotal,p.response.heapUsed,p.response.rss)):p.method==="cpu_update"&&p.response&&p.response.cpuUsage?(o&&console.log("SystemInfoTable received cpu_update",p),w(p.response.cpuUsage),j(p.response.processCpuUsage)):p.method==="uptime_update"&&p.response&&p.response.systemUptime&&p.response.processUptime?(o&&console.log("SystemInfoTable received uptime_update",p),V(p.response.systemUptime,p.response.processUptime)):p.method==="/api/viewhistorypage"&&p.id===W.current&&p.success===!0&&(o&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return i(h,W.current),o&&console.log(`SystemInfoTable added WebSocket listener id ${W.current}`),()=>{s(h),o&&console.log("SystemInfoTable removed WebSocket listener")}},[i,s]);const[Q,A]=r.useState(!1);return!b||Q?null:(o&&console.log("SystemInfoTable rendering..."),e.jsxs(je,{style:he&&l?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(De,{children:[e.jsx(Ce,{children:"System info"}),e.jsx(Ze,{close:()=>A(!0),children:e.jsx(G,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:q,children:e.jsx(_,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(le,{path:To,size:"22px"})})})})]}),e.jsx(Ne,{style:he&&l?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(b).filter(([h,p])=>p!==void 0&&p!=="").map(([h,p],u)=>e.jsxs("tr",{className:u%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:h.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:he&&l?typeof p!="string"?p.toString():p:e.jsx(Cr,{value:typeof p!="string"?p.toString():p,maxChars:22})})]},h))})]})})]}))}const or=r.memo(Cn),nr={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"}},wn=n=>{if(!n)return"";const d=n.toString().replace(/[^0-9]/g,"");if(d.length<5)return d;const l=d.slice(0,4),i=d.slice(4,7),s=d.slice(7,11);return[l,i,s].filter(Boolean).join("-")};function Sn({id:n}){const{online:d,sendMessage:l,addListener:i,removeListener:s,getUniqueId:m}=r.useContext(xe),[g,b]=r.useState(null),t=r.useRef(null),W=r.useRef(null),y=r.useRef(m()),{mobile:w,showConfirmCancelDialog:j}=r.useContext(Le);o&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${W.current} and matter:`,g),r.useEffect(()=>{o&&console.log(`QRDiv id effect "${n}"`),t.current=n,W.current&&clearTimeout(W.current),W.current=null,n?(o&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:n,server:!0}})):(o&&console.log("QRDiv id effect setting matter to null"),b(null))},[n,l]),r.useEffect(()=>{const p=u=>{o&&console.log("QRDiv received WebSocket Message:",u),u.method==="refresh_required"&&u.response.changed==="matter"&&u.response.matter&&(o&&console.log(`QRDiv received refresh_required: changed=${u.response.changed} for storeId "${u.response.matter.id}":`,u.response.matter),t.current===u.response.matter.id&&(o&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${u.response.matter.id}":`,u.response.matter),W.current&&clearTimeout(W.current),u.response.matter.advertising&&u.response.matter.advertiseTime&&u.response.matter.advertiseTime+9e5<=Date.now()&&(u.response.matter.advertising=!1),b(u.response.matter),u.response.matter.advertising&&(o&&console.log(`QRDiv setting matter advertise timeout for storeId "${u.response.matter.id}":`,u.response.matter.advertiseTime+9e5-Date.now()),W.current=setTimeout(()=>{W.current&&clearTimeout(W.current),o&&console.log(`QRDiv clearing advertising state for storeId "${t.current}" after 15 minutes`),b(I=>I&&{...I,advertising:!1})},u.response.matter.advertiseTime+9e5-Date.now()))))};return i(p,y.current),o&&console.log("QRDiv webSocket effect mounted"),()=>{s(p),W.current&&clearTimeout(W.current),W.current=null,o&&console.log("QRDiv webSocket effect unmounted")}},[i,s]);const V=()=>{o&&console.log(`QRDiv sent matter startCommission for node "${g?.id}"`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,startCommission:!0}})},q=()=>{o&&console.log(`QRDiv sent matter stopCommission for node "${g?.id}"`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,stopCommission:!0}})},Q=()=>{o&&console.log(`QRDiv sent matter advertise for node "${g?.id}"`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,advertise:!0}})},A=p=>{o&&console.log(`QRDiv sent matter removeFabric for node "${g?.id}" and fabricIndex ${p}`),g&&l({id:y.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:g.id,removeFabric:p}})},h=async()=>{if(!g||!g.manualPairingCode)return;const p=g.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(p);else{const u=document.createElement("textarea");u.value=p,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.focus(),u.select(),document.execCommand("copy"),document.body.removeChild(u)}o&&console.log("Manual pairing code copied to clipboard")}catch(u){console.error("Failed to copy manual pairing code",u)}};return!g||!d?(o&&console.log("QRDiv rendering undefined state"),null):g.online?g.advertising&&g.qrPairingCode&&g.manualPairingCode?(o&&console.log("QRDiv rendering advertising state"),e.jsxs(je,{style:he&&w?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsxs(De,{children:[e.jsx(Ce,{children:"QR pairing code"}),e.jsxs(Ze,{children:[e.jsx(G,{"aria-label":"send advertising",size:"small",onClick:Q,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(_,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(le,{path:Xt,size:"22px"})})}),e.jsx(G,{"aria-label":"stop pairing",size:"small",onClick:q,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(_,{title:"Turn off pairing",arrow:!0,children:e.jsx(le,{path:No,size:"22px"})})})]})]}),e.jsx(pt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(sn,{value:g.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(gt,{style:{justifyContent:"space-between"},children:[e.jsxs(lt,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",wn(g.manualPairingCode)]}),e.jsx(Ze,{children:e.jsx(_,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(G,{"aria-label":"copy manual pairing code",size:"small",onClick:h,sx:nr,children:e.jsx(le,{path:Ro,size:.85})})})})]})]})):g.commissioned&&g.fabricInformations&&g.sessionInformations?(o&&console.log("QRDiv rendering commissioned state"),e.jsxs(je,{style:he&&w?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(De,{children:[e.jsx(Ce,{children:"Paired fabrics"}),e.jsxs(Ze,{children:[e.jsx(G,{"aria-label":"send advertising",size:"small",onClick:Q,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(_,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(le,{path:Xt,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(_,{title:"Turn on pairing",arrow:!0,children:e.jsx(le,{path:er,size:"22px"})})})]})]}),e.jsx(pt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Ne,{style:{flexDirection:"column",justifyContent:"flex-start",flex:"1 1 auto",overflow:"auto",padding:"0px 0px 10px 0px",gap:"0px"},children:g.fabricInformations.map((p,u)=>e.jsxs("div",{style:{margin:"0px",padding:"10px",gap:"0px",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",textAlign:"left",fontSize:"14px"},children:[e.jsxs("div",{style:{marginLeft:"20px",marginBottom:"10px",display:"flex",flexDirection:"row",justifyContent:"space-between",gap:"20px",alignItems:"center"},children:[e.jsxs("p",{className:"status-blue",style:{margin:"0px",padding:"3px 10px",width:"200px",fontSize:"14px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},children:["Fabric: ",p.fabricIndex]}),e.jsx(_,{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:()=>j("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>A(p.fabricIndex),()=>{}),sx:{...nr,padding:"2px"},children:e.jsx(le,{path:Oo,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",p.rootVendorId," ",p.rootVendorName]}),p.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",p.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",g.sessionInformations?g.sessionInformations.filter(I=>I.fabric?.fabricIndex===p.fabricIndex&&I.isPeerActive===!0).length:"0"," ","subscriptions: ",g.sessionInformations?g.sessionInformations.filter(I=>I.fabric?.fabricIndex===p.fabricIndex&&I.isPeerActive===!0&&I.numberOfActiveSubscriptions>0).length:"0"]})]},u))}),e.jsx(gt,{style:{justifyContent:"center"},children:e.jsxs(lt,{style:{fontWeight:"normal"},children:["Serial number: ",g.serialNumber]})})]})):!g.commissioned&&!g.advertising?(o&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(je,{style:he&&w?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(De,{children:e.jsx(Ce,{children:"QR pairing code"})}),e.jsx(pt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(ae,{onClick:V,endIcon:e.jsx(le,{path:er,size:1}),style:{margin:"20px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:"Turn on pairing"}),e.jsx(gt,{style:{justifyContent:"center"},children:e.jsxs(lt,{style:{fontWeight:"normal"},children:["Serial number: ",g.serialNumber]})})]})):(o&&console.log("QRDiv rendering unknown state"),null):(o&&console.log("QRDiv rendering offline state"),e.jsxs(je,{style:he&&w?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(De,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(Ce,{children:"Server node"})}),e.jsx(pt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(pt,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(gt,{style:{justifyContent:"center"},children:e.jsxs(lt,{style:{fontWeight:"normal"},children:["Serial number: ",g.serialNumber]})})]}))}const ir=r.memo(Sn),sr=["matterbridge-","matterbridge-plugin-template","matterbridge-dyson","matterbridge-irobot","matterbridge-tuya","matterbridge-mqtt","matterbridge-matter","matterbridge-security","matterbridge-automations","matterbridge-securitysystem"];function kn(){const{mobile:n,showSnackbarMessage:d}=r.useContext(Le),{logMessage:l,sendMessage:i,getUniqueId:s}=r.useContext(xe),[m,g]=r.useState("matterbridge-"),[b,t]=r.useState(!1),[W,y]=r.useState(null),w=r.useRef(s()),j=c=>{c.preventDefault(),t(!0)},V=()=>{t(!1)},q=c=>{c.preventDefault(),t(!1);const a=c.dataTransfer.files[0];if(a){l("Plugins",`Installing package ${a.name}. Please wait...`);const x=new FormData;x.append("file",a),x.append("filename",a.name),fetch("./api/uploadpackage",{method:"POST",body:x}).then(k=>k.text()).then(k=>{l("Plugins",`Server response: ${k}`)}).catch(k=>{console.error("Error uploading plugin file:",k),l("Plugins",`Error installing package ${k}`)})}},Q=c=>{const a=c.target.files&&c.target.files[0];if(a){l("Plugins",`Uploading package ${a.name}`);const x=new FormData;x.append("file",a),x.append("filename",a.name),fetch("./api/uploadpackage",{method:"POST",body:x}).then(k=>k.text()).then(k=>{l("Plugins",`Server response: ${k}`)}).catch(k=>{console.error("Error uploading plugin file:",k),l("Plugins",`Error uploading package ${k}`)})}},A=()=>{if(sr.includes(m.split("@")[0])){d(`Installation of plugin "${m}" is blocked by the ignore list.`);return}i({id:w.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:m,restart:!1}})},h=()=>{i({id:w.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:m}})},p=()=>{document.getElementById("file-upload")?.click()},u=()=>{if(sr.includes(m.split("@")[0])){d(`Addition of plugin "${m}" is blocked by the ignore list.`);return}i({id:w.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:m}})},I=c=>{c.preventDefault(),console.log("Right-clicked Upload button")},S=c=>{c.preventDefault(),console.log("Right-clicked Add button")},P=c=>{y(c.currentTarget)},H=c=>{c!==""&&g(c),y(null)},[oe,v]=r.useState(!1);return o&&console.log("HomeInstallAddPlugins rendering..."),oe?null:e.jsxs(je,{children:[e.jsxs(De,{children:[e.jsx(Ce,{children:"Install plugins"}),e.jsx(Ze,{close:()=>v(!0)})]}),e.jsxs(Ne,{onDragOver:j,onDragLeave:V,onDrop:q,style:he&&n?{flexWrap:"wrap",alignItems:"center",gap:"10px"}:{flexWrap:"wrap",alignItems:"center",gap:"20px"},children:[e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(fe,{value:m,onChange:c=>{g(c.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0}),e.jsx(G,{onClick:P,children:e.jsx(Gr,{})}),e.jsxs(st,{id:"simple-menu",anchorEl:W,keepMounted:!0,open:!!W,onClose:()=>H(""),children:[e.jsx(C,{onClick:()=>H("matterbridge-zigbee2mqtt"),children:"matterbridge-zigbee2mqtt"}),e.jsx(C,{onClick:()=>H("matterbridge-somfy-tahoma"),children:"matterbridge-somfy-tahoma"}),e.jsx(C,{onClick:()=>H("matterbridge-shelly"),children:"matterbridge-shelly"}),e.jsx(C,{onClick:()=>H("matterbridge-hass"),children:"matterbridge-hass"}),e.jsx(C,{onClick:()=>H("matterbridge-webhooks"),children:"matterbridge-webhooks"}),e.jsx(C,{onClick:()=>H("matterbridge-bthome"),children:"matterbridge-bthome"}),e.jsx(C,{onClick:()=>H("matterbridge-test"),children:"matterbridge-test"}),e.jsx(C,{onClick:()=>H("matterbridge-example-accessory-platform"),children:"matterbridge-example-accessory-platform"}),e.jsx(C,{onClick:()=>H("matterbridge-example-dynamic-platform"),children:"matterbridge-example-dynamic-platform"}),e.jsx(C,{onClick:()=>H("matterbridge-eve-door"),children:"matterbridge-eve-door"}),e.jsx(C,{onClick:()=>H("matterbridge-eve-motion"),children:"matterbridge-eve-motion"}),e.jsx(C,{onClick:()=>H("matterbridge-eve-energy"),children:"matterbridge-eve-energy"}),e.jsx(C,{onClick:()=>H("matterbridge-eve-weather"),children:"matterbridge-eve-weather"}),e.jsx(C,{onClick:()=>H("matterbridge-eve-room"),children:"matterbridge-eve-room"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(_,{title:"Install or update a plugin from npm",children:e.jsxs(ae,{onClick:A,endIcon:e.jsx(Te,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(_,{title:"Uninstall and remove a plugin",children:e.jsxs(ae,{onClick:h,endIcon:e.jsx(gr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Uninstall"]})}),e.jsx(_,{title:"Upload and install a plugin from a tarball",children:e.jsxs(ae,{onClick:p,onContextMenu:I,endIcon:e.jsx(Kr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(_,{title:"Add an installed plugin",children:e.jsxs(ae,{onClick:u,onContextMenu:S,endIcon:e.jsx(Mt,{}),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:Q})]})]})]})}const In=r.memo(kn);function et({status:n,enabledText:d="Enabled",disabledText:l=void 0,tooltipText:i=void 0,onClick:s}){if(n===void 0)return null;{const m=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:n?d:l??d});return i!==void 0?e.jsx(_,{title:i,children:m}):m}}function Mn({title:n,children:d}){const l=r.useRef(null),[i,s]=r.useState(!1),m=()=>{const t=l.current;if(!t){s(!1);return}s(t.scrollWidth>t.clientWidth)},g=()=>{s(!1)},b={display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};return e.jsx(_,{title:n,open:i,disableHoverListener:!0,disableFocusListener:!0,disableTouchListener:!0,slotProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("span",{ref:l,onMouseEnter:m,onMouseLeave:g,style:b,children:d})})}function Dn(n,d,l){const i=n?.[l],s=d?.[l];return i==null&&s==null?0:i==null?-1:s==null?1:typeof i=="boolean"&&typeof s=="boolean"?i===s?0:i?1:-1:typeof i=="number"&&typeof s=="number"?i-s:String(i).localeCompare(String(s))}function Pn({name:n,title:d,columns:l,rows:i,getRowKey:s,footerLeft:m,footerRight:g,onRowClick:b}){const t=r.useRef(new WeakMap),W=r.useRef(1),y=a=>{if(typeof s=="string"&&a&&a[s]!=null)return a[s];if(typeof s=="function"){const N=s(a);if(N!=null)return N}const x=l?.[0]?.id;if(x&&a&&a[x]!=null)return a[x];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let k=t.current.get(a);return k||(k=`rk_${W.current++}`,t.current.set(a,k)),k},[w,j]=r.useState(localStorage.getItem(`${n}_table_order_by`)||null),[V,q]=r.useState(localStorage.getItem(`${n}_table_order`)||null),[Q,A]=r.useState(!1),[h,p]=r.useState(()=>{try{const a=localStorage.getItem(`${n}_column_visibility`);if(a)return JSON.parse(a)}catch{}return{}}),u=r.useMemo(()=>{const a={};for(const x of l)x.hidden||(a[x.id]=x.required?!0:h[x.id]!==!1);return a},[l,h]),I=r.useMemo(()=>{if(!w||!V)return i;const a=l.find(k=>k.id===w);if(!a||a.noSort)return i;const x=i.map((k,N)=>({el:k,index:N}));return x.sort((k,N)=>{let re;return typeof a.comparator=="function"?re=a.comparator(k.el,N.el):re=Dn(k.el,N.el,w),re!==0?V==="asc"?re:-re:k.index-N.index}),x.map(k=>k.el)},[i,w,V,l]),S=a=>{if(w!==a||!w){j(a),q("asc"),localStorage.setItem(`${n}_table_order_by`,a),localStorage.setItem(`${n}_table_order`,"asc");return}if(V==="asc"){q("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}j(null),q(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},P=()=>{A(!Q)},H=a=>{p(x=>{const k=l.find(be=>be.id===a);if(k&&k.required)return x;const N=u[a]!==!1,re={...x};N?re[a]=!1:delete re[a];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(re))}catch{}return re})},oe=()=>{p({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}A(!1)},[v,c]=r.useState(!1);return v?null:(o&&console.log(`Rendering table ${n}${w&&V?` ordered by ${w}:${V}`:""}`),e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",height:"100%",overflow:"hidden"},children:[e.jsxs(Ve,{open:Q,onClose:(a,x)=>{x==="backdropClick"||x==="escapeKeyDown"||P()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Ee,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${n} columns`})]})}),e.jsx(Ae,{children:e.jsx(Jr,{children:l.filter(a=>!a.hidden).map(a=>e.jsx(Ye,{control:e.jsx(qe,{disabled:!!a.required,checked:a.required?!0:u[a.id]!==!1,onChange:()=>H(a.id)}),label:a.label},a.id))})}),e.jsxs(Ge,{children:[e.jsx(ae,{onClick:oe,children:"Reset"}),e.jsx(ae,{variant:"contained",onClick:a=>{if(a?.currentTarget&&typeof a.currentTarget.blur=="function")try{a.currentTarget.blur()}catch{}const x=document.activeElement;if(x&&x instanceof HTMLElement&&typeof x.blur=="function")try{x.blur()}catch{}P()},children:"Close"})]})]}),e.jsxs(De,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx(Ce,{children:n}),d&&e.jsx(Ce,{children:d}),e.jsx(Ze,{close:()=>c(!0),children:e.jsx(G,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:a=>{if(a?.currentTarget?.blur)try{a.currentTarget.blur()}catch{}P()},"aria-label":"Configure Columns",children:e.jsx(_,{title:`Configure ${n} columns`,children:e.jsx(le,{path:_o,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx(Ne,{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:l.map(a=>{if(a.hidden||!a.required&&u[a.id]===!1)return null;const x=!a.noSort,k=x&&w===a.id&&!!V;return e.jsxs("th",{onClick:x?()=>S(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:x?"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":x?k?V==="asc"?"ascending":"descending":"none":void 0,children:[a.label,k&&e.jsxs("span",{style:{marginLeft:6},children:[V==="asc"&&e.jsx(le,{path:Ho,size:"15px"}),V==="desc"&&e.jsx(le,{path:Vo,size:"15px"})]})]},a.id)})})}),e.jsx("tbody",{children:I.map((a,x)=>{const k=y(a);return e.jsx("tr",{className:x%2===0?"table-content-even":"table-content-odd",onClick:b?N=>b(a,k,N):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:b?"pointer":void 0},children:l.map(N=>{if(N.hidden||!N.required&&u[N.id]===!1)return null;const re=a[N.id],be=typeof N.render=="function"?N.render(re,k,a,N):typeof re=="boolean"?e.jsx(qe,{checked:re,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):N.format&&typeof re=="number"?N.format(re):re!=null?String(re):null,O=!!N.tooltip&&N.maxWidth!==void 0&&N.maxWidth!==null&&re!==void 0&&re!==null&&be!==null?e.jsx(Mn,{title:String(re),children:be}):be;return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:N.align||"left",padding:"5px 10px",margin:"0",maxWidth:N.maxWidth,whiteSpace:N.maxWidth?"nowrap":void 0,overflow:N.maxWidth?"hidden":void 0,textOverflow:N.maxWidth?"ellipsis":void 0},children:O},N.id)})},k)})})]})}),(m||g)&&e.jsxs(gt,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx(lt,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:m}),e.jsx(lt,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g})]})]}))}function Ln(n){return r.memo(n)}const Wt=Ln(Pn);function lr(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const tt={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},rt={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},$n={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},Wn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},ze={padding:"0px",margin:"0px"},Fn="5px 10px 5px 10px",wt={},Se={},St={},kt={};let ot=[],Ot=[];const Tn=({open:n,onClose:d,plugin:l})=>{const{sendMessage:i,addListener:s,removeListener:m,getUniqueId:g}=r.useContext(xe),b=r.useRef(g()),[t,W]=r.useState(l.configJson),[y,w]=r.useState(null),[j,V]=r.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[q,Q]=r.useState("");let A={};r.useEffect(()=>{const $=L=>{L.src==="Matterbridge"&&L.dst==="Frontend"&&(lr(L)&&L.id===b.current&&L.method==="/api/select/devices"&&L.response&&(o&&console.log(`ConfigPluginDialog (id: ${L.id}) received ${L.response.length} /api/select/devices:`,L.response),ot=L.response),lr(L)&&L.id===b.current&&L.method==="/api/select/entities"&&L.response&&(o&&console.log(`ConfigPluginDialog (id: ${L.id}) received ${L.response.length} /api/select/entities:`,L.response),Ot=L.response))};return s($,b.current),o&&console.log("ConfigPluginDialog added WebSocket listener id:",b.current),t&&y&&y.properties&&(Object.keys(y.properties).forEach(L=>{Object.keys(y.properties[L]).forEach(M=>{M.startsWith("ui:")&&(j[L]={},j[L][M]=y.properties[L][M],delete y.properties[L][M])})}),V(j)),l.name&&l.configJson&&l.schemaJson&&(W(l.configJson),w(l.schemaJson),i({id:b.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),i({id:b.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),o&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',l.name)),()=>{m($),o&&console.log("ConfigPluginDialog removed WebSocket listener")}},[s,t,l,m,y,i,j]);const h=($,L)=>{A=$.formData},p=$=>{o&&console.log("ConfigPluginDialog handleSaveChanges:",$.formData),W($.formData),l.configJson=$.formData,l.restartRequired=!0,i({id:b.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:$.formData.name,formData:$.formData}}),d()};function u($){const{id:L,label:M,onKeyChange:R,onDropPropertyClick:Y,disabled:ue,schema:de,children:J,registry:f,readonly:ce,required:Z}=$,{templates:D}=f,{RemoveButton:ye}=D.ButtonTemplates;if(!(mn in de))return e.jsx(se,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:J});const ve=({target:ne})=>R(ne&&ne.value);return e.jsxs(se,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(fe,{id:`${L}-key`,name:`${L}-key`,required:Z,disabled:ue||ce,defaultValue:M,onBlur:ce?void 0:ve,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(se,{sx:{flex:1},children:J}),e.jsx(ye,{disabled:ue||ce,onClick:Y(M),registry:f})]})}function I($){const{children:L,description:M,displayLabel:R,errors:Y,help:ue,hidden:de,registry:J,uiSchema:f}=$,ce=un(f),Z=gn("WrapIfAdditionalTemplate",J,ce);return de?e.jsx("div",{style:{display:"none"},children:L}):e.jsx(se,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(Z,{...$,children:[R===!0&&M,L,Y,ue]})})}function S($){const{description:L}=$;return L?e.jsx(ge,{sx:rt,children:L}):null}function P($){const{required:L,title:M}=$;return M?e.jsx(se,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ge,{sx:tt,children:["Title ",M," ",L&&e.jsx("mark",{children:"***"})]})}):null}function H($){const{help:L}=$;return L?e.jsx(se,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ge,{sx:$n,children:L})}):null}function oe($){const{errors:L}=$;return L?e.jsxs(se,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ge,{color:"error",sx:Wn,children:"Please fix the following errors:"}),e.jsx(dt,{children:L.map((M,R)=>e.jsxs(Zr,{children:[e.jsx(z,{children:e.jsx(Yr,{color:"error"})}),e.jsx(ee,{primary:M.stack})]},R))})]}):null}function v($){const{errors:L}=$;return L?e.jsx(se,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:L.map((M,R)=>e.jsxs(ge,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",M]},R))}):null}function c($){const{id:L,name:M,_schema:R,_uiSchema:Y,value:ue,options:de,label:J,type:f,placeholder:ce,required:Z,disabled:D,readonly:ye,autofocus:Re,onChange:ve,onChangeOverride:ne,onBlur:pe,onFocus:He,_rawErrors:Me,_hideError:ct,_registry:E,_formContext:we}=$,U=({target:{value:We}})=>ve(We===""?de.emptyValue:We),ie=({target:We})=>pe(L,We&&We.value),$e=({target:We})=>He(L,We&&We.value);return e.jsx(se,{sx:{padding:"0px",margin:"0px"},children:e.jsx(fe,{id:L,name:L,label:ce&&ce!==""?J:void 0,variant:"outlined",placeholder:ce&&ce!==""?ce:J,required:Z,disabled:D||ye,autoFocus:Re,value:ue||ue===0?ue:"",type:f,autoComplete:f==="password"?"current-password":M,onChange:ne||U,onBlur:ie,onFocus:$e,fullWidth:!0})})}function a($){return console.log("ArrayFieldTitleTemplate:",$),null}function x($){return console.log("ArrayFieldDescriptionTemplate:",$),null}function k($){return console.log("ArrayFieldItemTemplate:",$),null}function N($){const{canAdd:L,onAddClick:M,schema:R,title:Y}=$,[ue,de]=r.useState(!1),[J,f]=r.useState(!1),[ce,Z]=r.useState(!1),[D,ye]=r.useState(""),Re=E=>{ye(E.target.value)},ve=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",D,"selectDevices:",ot),de(!ue)},ne=()=>{o&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",D,"selectEntities:",Ot),f(!J)},pe=()=>{o&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",D,"selectDevices:",ot),Z(!ce)},He=E=>{de(!1),R.selectFrom==="serial"?R.items.default=E.serial:R.selectFrom==="name"&&(R.items.default=E.name),M()},Me=E=>{f(!1),R.selectEntityFrom==="name"?R.items.default=E.name:R.selectEntityFrom==="description"&&(R.items.default=E.description),M()},ct=E=>{Z(!1),R.selectDeviceEntityFrom==="name"?R.items.default=E.name:R.selectDeviceEntityFrom==="description"&&(R.items.default=E.description),M()};return e.jsxs(se,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[Y&&e.jsxs(se,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Y&&e.jsx(ge,{sx:tt,children:Y}),L&&e.jsxs(se,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[R.selectFrom&&e.jsx(_,{title:"Add a device from the list",children:e.jsx(G,{onClick:ve,size:"small",color:"primary",sx:ze,children:e.jsx(xt,{})})}),R.selectEntityFrom&&e.jsx(_,{title:"Add an entity from the list",children:e.jsx(G,{onClick:ne,size:"small",color:"primary",sx:ze,children:e.jsx(xt,{})})}),R.selectDeviceEntityFrom&&e.jsx(_,{title:"Add a device entity from the list",children:e.jsx(G,{onClick:pe,size:"small",color:"primary",sx:ze,children:e.jsx(xt,{})})}),e.jsx(_,{title:"Add a new item",children:e.jsx(G,{onClick:M,size:"small",color:"primary",sx:ze,children:e.jsx(Mt,{})})})]})]}),R.description&&e.jsx(ge,{sx:rt,children:R.description}),$.items.map(E=>e.jsxs(se,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(se,{sx:{flexGrow:1,marginRight:"10px"},children:E.children}),e.jsx(G,{disabled:!E.hasMoveUp,onClick:E.onReorderClick(E.index,E.index-1),size:"small",color:"primary",sx:ze,children:e.jsx(Gt,{})}),e.jsx(G,{disabled:!E.hasMoveDown,onClick:E.onReorderClick(E.index,E.index+1),size:"small",color:"primary",sx:ze,children:e.jsx(Qt,{})}),e.jsx(G,{onClick:E.onDropIndexClick(E.index),size:"small",color:"primary",sx:ze,children:e.jsx(Vt,{})})]},E.index)),e.jsxs(Ve,{open:ue,onClose:ve,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ee,{children:"Select a device"}),e.jsxs(Ae,{children:[e.jsxs(se,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ge,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(fe,{fullWidth:!0,variant:"outlined",value:D,onChange:Re,placeholder:"Enter serial or name"})]}),e.jsx(dt,{dense:!0,children:ot.filter(E=>E.serial.toLowerCase().includes(D.toLowerCase())||E.name.toLowerCase().includes(D.toLowerCase())).map((E,we)=>e.jsxs(bt,{onClick:()=>He(E),sx:wt,children:[E.icon==="wifi"&&e.jsx(z,{children:e.jsx(ut,{style:Se})}),E.icon==="ble"&&e.jsx(z,{children:e.jsx(vt,{style:Se})}),E.icon==="hub"&&e.jsx(z,{children:e.jsx(yt,{style:Se})}),e.jsx(ee,{primary:E.name,secondary:E.serial,primaryTypographyProps:{style:St},secondaryTypographyProps:{style:kt}})]},we))})]}),e.jsx(Ge,{children:e.jsx(ae,{onClick:ve,children:"Close"})})]}),e.jsxs(Ve,{open:J,onClose:ne,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ee,{children:"Select an entity"}),e.jsxs(Ae,{children:[e.jsxs(se,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ge,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(fe,{fullWidth:!0,variant:"outlined",value:D,onChange:Re,placeholder:"Enter name or description"})]}),e.jsx(dt,{dense:!0,children:Ot.filter(E=>E.name.toLowerCase().includes(D.toLowerCase())||E.description.toLowerCase().includes(D.toLowerCase())).map((E,we)=>e.jsxs(bt,{onClick:()=>Me(E),sx:wt,children:[E.icon==="wifi"&&e.jsx(z,{children:e.jsx(ut,{style:Se})}),E.icon==="ble"&&e.jsx(z,{children:e.jsx(vt,{style:Se})}),E.icon==="hub"&&e.jsx(z,{children:e.jsx(yt,{style:Se})}),E.icon==="component"&&e.jsx(z,{children:e.jsx(Kt,{style:Se})}),E.icon==="matter"&&e.jsx(z,{children:e.jsx(Jt,{style:Se})}),e.jsx(ee,{primary:E.name,secondary:E.description,primaryTypographyProps:{style:St},secondaryTypographyProps:{style:kt}})]},we))})]}),e.jsx(Ge,{children:e.jsx(ae,{onClick:ne,children:"Close"})})]}),e.jsxs(Ve,{open:ce,onClose:pe,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Ee,{children:["Select an entity for ",Y]}),e.jsx(Ae,{children:e.jsx(dt,{dense:!0,children:ot.filter(E=>E.serial===Y||E.name===Y).map(E=>E.entities?.map((we,U)=>e.jsxs(bt,{onClick:()=>ct(we),sx:wt,children:[we.icon==="wifi"&&e.jsx(z,{children:e.jsx(ut,{style:Se})}),we.icon==="ble"&&e.jsx(z,{children:e.jsx(vt,{style:Se})}),we.icon==="hub"&&e.jsx(z,{children:e.jsx(yt,{style:Se})}),we.icon==="component"&&e.jsx(z,{children:e.jsx(Kt,{style:Se})}),we.icon==="matter"&&e.jsx(z,{children:e.jsx(Jt,{style:Se})}),e.jsx(ee,{primary:we.name,secondary:we.description,primaryTypographyProps:{style:St},secondaryTypographyProps:{style:kt}})]},U)))})}),e.jsx(Ge,{children:e.jsx(ae,{onClick:pe,children:"Close"})})]})]})}function re($){const{onAddClick:L,schema:M,properties:R,title:Y,description:ue}=$,[de,J]=r.useState(!1),[f,ce]=r.useState(""),Z=ne=>{ce(ne.target.value)},D=()=>{J(!de)},ye=ne=>{o&&console.log(`ObjectFieldTemplate: handleSelectValue value "${ne.serial}" for schema "${M.selectFrom}"`),J(!1);let pe="";M.selectFrom==="serial"?pe=ne.serial:M.selectFrom==="name"&&(pe=ne.name),Q(pe),o&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${pe}"`),L(M)()},Re=()=>{L(M)()},ve=!M.additionalProperties;return o&&console.log(`ObjectFieldTemplate: isRoot ${ve} newkey "${q}"`),!ve&&q!==""&&(o&&console.log("ObjectFieldTemplate: newkey",q,"properties",R),R.forEach(ne=>{if(ne.name==="newKey"&&ne.content.key==="newKey"&&ne.content.props.name==="newKey"&&ne.content.props.onKeyChange&&q!==""){o&&console.log("ObjectFieldTemplate: newkey onKeyChange",q);const pe=q;Q(""),ne.content.props.onKeyChange(pe)}})),e.jsxs(se,{sx:{margin:"0px",padding:ve?"10px":"5px 10px 0px 10px",border:ve?"none":"1px solid grey"},children:[M.title&&ve&&e.jsx(se,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ge,{sx:tt,children:M.title})}),Y&&!ve&&e.jsxs(se,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ge,{sx:tt,children:Y}),e.jsxs(se,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[M.selectFrom&&e.jsx(_,{title:"Add a device from the list",children:e.jsx(G,{onClick:D,size:"small",color:"primary",sx:ze,children:e.jsx(xt,{})})}),e.jsx(_,{title:"Add a new item",children:e.jsx(G,{onClick:Re,size:"small",color:"primary",sx:ze,children:e.jsx(Mt,{})})})]})]}),M.description&&e.jsx(se,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ge,{sx:rt,children:M.description})}),R.map(({content:ne,name:pe,hidden:He})=>!He&&e.jsxs(se,{sx:{margin:"0px",marginBottom:"10px",padding:["object","array","boolean"].includes(M.properties[pe].type)?"0px":Fn,border:["object","array","boolean"].includes(M.properties[pe].type)?"none":"1px solid grey"},children:[!["object","array","boolean"].includes(M.properties[pe].type)&&e.jsx(ge,{sx:tt,children:pe}),e.jsx(se,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:ne})]},pe)),e.jsxs(Ve,{open:de,onClose:D,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Ee,{children:"Select a device"}),e.jsxs(Ae,{children:[e.jsxs(se,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ge,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(fe,{fullWidth:!0,variant:"outlined",value:f,onChange:Z,placeholder:"Enter serial or name"})]}),e.jsx(dt,{dense:!0,children:ot.filter(ne=>ne.serial.toLowerCase().includes(f.toLowerCase())||ne.name.toLowerCase().includes(f.toLowerCase())).map((ne,pe)=>e.jsxs(bt,{onClick:()=>ye(ne),sx:wt,children:[ne.icon==="wifi"&&e.jsx(z,{children:e.jsx(ut,{style:Se})}),ne.icon==="ble"&&e.jsx(z,{children:e.jsx(vt,{style:Se})}),ne.icon==="hub"&&e.jsx(z,{children:e.jsx(yt,{style:Se})}),e.jsx(ee,{primary:ne.name,secondary:ne.serial,primaryTypographyProps:{style:St},secondaryTypographyProps:{style:kt}})]},pe))})]}),e.jsx(Ge,{children:e.jsx(ae,{onClick:D,children:"Close"})})]})]})}function be($){const{uiSchema:L}=$,{submitText:M,norender:R}=pn(L);return R?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ae,{type:"submit",variant:"contained",color:"primary",children:M}),e.jsx(ae,{variant:"contained",color:"primary",onClick:d,children:"Cancel"})]})}function Ie($){const{className:L,disabled:M,onClick:R,registry:Y,style:ue,uiSchema:de,...J}=$;return e.jsx(_,{title:"Remove the item",children:e.jsx(G,{disabled:M,size:"small",color:"primary",onClick:R,children:e.jsx(Vt,{})})})}function O($){const{className:L,disabled:M,onClick:R,registry:Y,uiSchema:ue,...de}=$;return e.jsx(_,{title:"Add an item",children:e.jsx(G,{size:"small",color:"primary",onClick:R,children:e.jsx(Mt,{})})})}function B($){const{disabled:L,onClick:M,registry:R,style:Y,uiSchema:ue,...de}=$;return e.jsx(_,{title:"Move up the item",children:e.jsx(G,{size:"small",color:"primary",onClick:M,children:e.jsx(Gt,{})})})}function T($){const{disabled:L,onClick:M,registry:R,style:Y,uiSchema:ue,...de}=$;return e.jsx(_,{title:"Move down the item",children:e.jsx(G,{size:"small",color:"primary",onClick:M,children:e.jsx(Qt,{})})})}function K($){const{id:L,name:M,value:R,schema:Y,readonly:ue,onChange:de}=$,[J,f]=r.useState(),ce=D=>{o&&console.log(`CheckboxWidget ${M} onChangeField:`,D),f(D&&D!==""?D:void 0)},Z=()=>{o&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${M}" value="${J}"`),i({id:b.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:M,value:J,formData:A,id:L}}),Y.buttonClose===!0?d():Y.buttonSave===!0&&p({formData:t})};return Y.buttonText&&Y.description?e.jsxs(se,{sx:{margin:"0px",padding:"10px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ge,{sx:rt,children:Y.description}),e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>Z(),children:Y.buttonText})]}):Y.buttonField&&Y.description?e.jsxs(se,{sx:{margin:"0px",padding:"10px",gap:"20px",border:"1px solid grey",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ge,{sx:rt,children:Y.description}),e.jsx(fe,{id:M+"-input",name:M,label:Y.textLabel,placeholder:Y.textPlaceholder,onChange:D=>ce(D.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ae,{id:M+"-button",variant:"contained",color:"primary",disabled:J===void 0,onClick:()=>Z(),children:Y.buttonField})]}):e.jsxs(se,{sx:{margin:"0px",padding:"5px 10px",border:"1px solid grey"},children:[M&&e.jsxs(se,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(ge,{sx:tt,children:M}),e.jsx(qe,{checked:R,readOnly:ue,onChange:()=>de(!R),sx:{padding:"0px",margin:"0px"}})]}),Y.description&&e.jsx(ge,{sx:rt,children:Y.description})]})}function F({schema:$,id:L,name:M,options:R,label:Y,hideLabel:ue,required:de,disabled:J,placeholder:f,readonly:ce,value:Z,multiple:D,autofocus:ye,onChange:Re,onBlur:ve,onFocus:ne,errorSchema:pe,rawErrors:He=[],registry:Me,uiSchema:ct,hideError:E,formContext:we,...U}){const{enumOptions:ie,enumDisabled:$e,emptyValue:We}=R;D=typeof D>"u"?!1:!!D;const Ut=D?[]:"",zt=typeof Z>"u"||D&&Z.length<1||!D&&Z===Ut,Mr=({target:{value:Ue}})=>Re(Rt(Ue,ie,We)),Dr=({target:Ue})=>ve(L,Rt(Ue&&Ue.value,ie,We)),Pr=({target:Ue})=>ne(L,Rt(Ue&&Ue.value,ie,We)),qt=cn(Z,ie,D),{InputLabelProps:Lr,SelectProps:$r,autocomplete:Wr,...Fr}=U,Tr=!D&&$.default===void 0;return e.jsxs(fe,{id:L,name:L,value:!zt&&typeof qt<"u"?qt:Ut,required:de,disabled:J||ce,autoFocus:ye,autoComplete:Wr,placeholder:f,error:He.length>0,onChange:Mr,onBlur:Dr,onFocus:Pr,...Fr,select:!0,InputLabelProps:{...Lr,shrink:!zt},SelectProps:{...$r,multiple:D},"aria-describedby":dn(L),children:[Tr&&e.jsx(C,{value:"",children:f}),Array.isArray(ie)&&ie.map(({value:Ue,label:Nr},Bt)=>{const Rr=Array.isArray($e)&&$e.indexOf(Ue)!==-1;return e.jsx(C,{value:String(Bt),disabled:Rr,children:Nr},Bt)})]})}return o&&console.log("ConfigPluginDialog rendering..."),!n||!y||!t?null:e.jsxs(Ve,{open:n,onClose:d,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Ee,{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(Ae,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(ln,{schema:y,formData:t,uiSchema:j,validator:an,templates:{FieldTemplate:I,BaseInputTemplate:c,TitleFieldTemplate:P,DescriptionFieldTemplate:S,FieldHelpTemplate:H,FieldErrorTemplate:v,ErrorListTemplate:oe,WrapIfAdditionalTemplate:u,ArrayFieldTitleTemplate:a,ArrayFieldDescriptionTemplate:x,ArrayFieldItemTemplate:k,ArrayFieldTemplate:N,ObjectFieldTemplate:re,ButtonTemplates:{SubmitButton:be,RemoveButton:Ie,AddButton:O,MoveUpButton:B,MoveDownButton:T}},widgets:{CheckboxWidget:K,SelectWidget:F},onChange:h,onSubmit:p})})]})};function wr(n){if(o&&console.log(`getQRColor (id: ${n?.id}) received matter:`,n??"undefined"),n===void 0||!n.online||!n.qrPairingCode&&!n.manualPairingCode&&!n.fabricInformations&&!n.sessionInformations)return"red";if(n.commissioned===!1&&n.qrPairingCode&&n.manualPairingCode)return"var(--primary-color)";let d=0,l=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&d++,i.numberOfActiveSubscriptions>0&&(l+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(d===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function Nn({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:s,removeListener:m,getUniqueId:g}=r.useContext(xe),{showConfirmCancelDialog:b}=r.useContext(Le),t=r.useRef(g()),[W,y]=r.useState(null),[w,j]=r.useState(null),[V,q]=r.useState([]),Q=[{label:"Name",id:"name",required:!0,render:(T,K,F,$)=>e.jsx(_,{title:`Plugin path ${F.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>v(F),children:F.name})})},{label:"Description",id:"description",render:(T,K,F,$)=>e.jsx(_,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>v(F),children:F.description})})},{label:"Version",id:"version",render:(T,K,F,$)=>e.jsx(e.Fragment,{children:e.jsx(_,{title:`Plugin v.${F.version}`,children:e.jsx("span",{children:F.version.split("-")[0]+(F.version.includes("-dev-")?"@dev":"")+(F.version.includes("-git-")?"@git":"")})})})},{label:"Author",id:"author",render:(T,K,F,$)=>e.jsx(e.Fragment,{children:F.author?F.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(T,K,F,$)=>e.jsx(e.Fragment,{children:F.type?F.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(T,K,F,$)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[w&&w.bridgeMode==="childbridge"&&!F.error&&F.enabled&&e.jsx(_,{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:wr(F.matter)},onClick:()=>{F.matter?.id&&d(F.matter?.id)},size:"small",children:e.jsx(mr,{})})}),w&&w.bridgeMode==="childbridge"&&!F.error&&F.enabled&&e.jsx(_,{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:()=>H(F),size:"small",children:e.jsx(Dt,{})})}),e.jsx(_,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{disabled:F.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>Ie(F),size:"small",children:e.jsx(Xr,{})})}),w&&!w.readOnly&&e.jsx(_,{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:()=>{h("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",F)},size:"small",children:e.jsx(gr,{})})}),F.enabled?e.jsx(_,{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:()=>{h("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",F)},size:"small",children:e.jsx(eo,{})})}):e.jsx(e.Fragment,{}),F.enabled?e.jsx(e.Fragment,{}):e.jsx(_,{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:()=>oe(F),size:"small",children:e.jsx(to,{})})}),e.jsx(_,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>a(F),size:"small",children:e.jsx(hr,{})})}),e.jsx(_,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>x(F),size:"small",children:e.jsx(Et,{})})}),F.latestVersion!==void 0&&F.latestVersion!==F.version&&w&&!w.readOnly&&e.jsx(_,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>I(F),size:"small",children:e.jsx(Oe,{})})}),(F.version.includes("-dev-")||F.version.includes("-git-"))&&F.devVersion!==void 0&&F.devVersion!==F.version&&w&&!w.readOnly&&e.jsx(_,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{style:{color:"var(--secondary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>S(F),size:"small",children:e.jsx(Oe,{})})}),w&&!w.readOnly&&e.jsx(_,{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:()=>c(F),size:"small",children:e.jsx(At,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(T,K,F,$)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:F.error?e.jsx(e.Fragment,{children:e.jsx(et,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:F.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(et,{status:F.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:F.loaded&&F.started&&F.configured?e.jsx(e.Fragment,{children:e.jsx(et,{status:F.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(et,{status:F.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(et,{status:F.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(et,{status:F.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];r.useEffect(()=>{const T=K=>{o&&console.log("HomePlugins received WebSocket Message:",K),K.method==="refresh_required"&&K.response.changed==="plugins"?(o&&console.log(`HomePlugins received refresh_required: changed=${K.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):K.method==="refresh_required"&&K.response.changed==="matter"?(o&&console.log(`HomePlugins received refresh_required: changed=${K.response.changed} and setting matter id ${K.response.matter?.id}`),q(F=>{const $=F.findIndex(M=>M.matter?.id===K.response.matter?.id);if($<0)return o&&console.log(`HomePlugins received refresh_required: changed=${K.response.changed} and matter id ${K.response.matter?.id} not found`),F;o&&console.log(`HomePlugins received refresh_required: changed=${K.response.changed} set matter id ${K.response.matter?.id}`);const L=[...F];return L[$]={...L[$],matter:K.response.matter},L})):K.method==="refresh_required"&&K.response.changed==="settings"&&(o&&console.log(`HomePlugins received refresh_required: changed=${K.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),K.id===t.current&&K.method==="/api/settings"?(o&&console.log(`HomePlugins (id: ${K.id}) received settings:`,K.response),y(K.response.systemInformation),j(K.response.matterbridgeInformation)):K.id===t.current&&K.method==="/api/plugins"&&(o&&console.log(`HomePlugins (id: ${K.id}) received ${K.response.length} plugins:`,K.response),q(K.response))};return s(T,t.current),o&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{m(T),o&&console.log("HomePlugins removed WebSocket listener")}},[s,m,i]),r.useEffect(()=>{l&&(o&&console.log("HomePlugins sending api requests"),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const A=r.useRef(null),h=(T,K,F,$)=>{o&&console.log(`handleActionWithConfirmCancel ${F} ${$.name}`),A.current=$,b(T,K,F,p,u)},p=T=>{o&&console.log(`handleConfirm action confirmed ${T} ${A.current?.name}`),T==="remove"&&A.current?P(A.current):T==="disable"&&A.current&&oe(A.current),A.current=null},u=T=>{o&&console.log(`handleCancel action canceled ${T} ${A.current?.name}`),A.current=null},I=T=>{o&&console.log("handleUpdatePlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:T.name,restart:!1}})},S=T=>{o&&console.log("handleUpdateDevPlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:T.name+"@dev",restart:!1}})},P=T=>{o&&console.log("handleRemovePlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}})},H=T=>{o&&console.log("handleRestartPlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}})},oe=T=>{o&&console.log("handleEnableDisablePlugin plugin:",T.name,"enabled:",T.enabled),T.enabled===!0?(T.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}})):(T.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.name}}))},v=T=>{o&&console.log(`handleHomepagePlugin plugin: ${T.name} homepage: ${T.homepage}`),T.homepage&&window.open(T.homepage,"_blank")},c=T=>{o&&console.log("handleSponsorPlugin plugin:",T.name,"funding:",T.funding),T.funding&&window.open(T.funding,"_blank")},a=T=>{o&&console.log("handleHelpPlugin plugin:",T.name,"help:",T.help),T.help&&window.open(T.help,"_blank")},x=T=>{o&&console.log("handleChangelogPlugin plugin:",T.name,"changelog:",T.changelog),T.changelog&&window.open(T.changelog,"_blank")},[k,N]=r.useState(),[re,be]=r.useState(!1),Ie=T=>{o&&console.log("handleConfigPlugin plugin:",T.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:T.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:T.name}}),N(T),O()},O=()=>{be(!0)},B=()=>{be(!1)};return o&&console.log("HomePlugins rendering..."),l?e.jsxs(je,{children:[k&&e.jsx(Tn,{open:re,onClose:B,plugin:k}),e.jsx(Wt,{name:"Plugins",columns:Q,rows:V,footerRight:"",footerLeft:""})]}):e.jsx(_e,{})}const Rn=r.memo(Nn),On=n=>`${n.pluginName}::${n.serial}`;function _n({storeId:n,setStoreId:d}){const{online:l,sendMessage:i,addListener:s,removeListener:m,getUniqueId:g}=r.useContext(xe),[b,t]=r.useState(!1),[W,y]=r.useState(!0),[w,j]=r.useState(null),[V,q]=r.useState([]),[Q,A]=r.useState([]),[h,p]=r.useState([]),[u,I]=r.useState([]),S=r.useRef(g()),P=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(v,c,a,x)=>a.reachable===!0?"Online":a.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(v,c)=>{const a=v.reachable===!0?1:v.reachable===!1?0:-1,x=c.reachable===!0?1:c.reachable===!1?0:-1;return a-x}},{label:"Power",id:"powerSource",render:(v,c,a,x)=>a.powerSource==="ac"||a.powerSource==="dc"?e.jsx(fr,{fontSize:"small",sx:{color:"var(--primary-color)"}}):a.powerSource==="ok"?a.batteryLevel?e.jsx(_,{title:`Battery level: ${a.batteryLevel}%`,children:e.jsx(Ke,{fontSize:"small",sx:{color:"green"}})}):e.jsx(Ke,{fontSize:"small",sx:{color:"gray"}}):a.powerSource==="warning"?a.batteryLevel?e.jsx(_,{title:`Battery level: ${a.batteryLevel}%`,children:e.jsx(Ke,{fontSize:"small",sx:{color:"yellow"}})}):e.jsx(Ke,{fontSize:"small",sx:{color:"yellow"}}):a.powerSource==="critical"?a.batteryLevel?e.jsx(_,{title:`Battery level: ${a.batteryLevel}%`,children:e.jsx(Ke,{fontSize:"small",sx:{color:"red"}})}):e.jsx(Ke,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Actions",id:"selected",required:!0,render:(v,c,a,x)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[a.matter!==void 0?e.jsx(_,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{onClick:()=>d(n===a.matter?.id?w?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:a.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:wr(a.matter)},children:e.jsx(mr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),a.configUrl?e.jsx(_,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(G,{onClick:()=>window.open(a.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(xr,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),a.selected!==void 0?e.jsx(_,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(qe,{checked:a.selected,onChange:k=>oe(k,a),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],H=r.useCallback(v=>{v.selected=void 0;const c=V.find(k=>k.name===v.pluginName);if(!c)return console.error(`HomeDevices isSelected: plugin ${v.pluginName} not found for device ${v.name} `),v.selected;const a=c.schemaJson?.properties?.whiteList?.selectFrom;let x=c.configJson.postfix;return x===""&&(x=void 0),c.hasWhiteList===!0&&c.hasBlackList===!0&&a&&(v.selected=!0,a==="serial"&&c.configJson.whiteList&&c.configJson.whiteList.length>0&&c.configJson.whiteList.includes(x?v.serial.replace("-"+x,""):v.serial)&&(v.selected=!0),a==="serial"&&c.configJson.whiteList&&c.configJson.whiteList.length>0&&!c.configJson.whiteList.includes(x?v.serial.replace("-"+x,""):v.serial)&&(v.selected=!1),a==="serial"&&c.configJson.blackList&&c.configJson.blackList.length>0&&c.configJson.blackList.includes(x?v.serial.replace("-"+x,""):v.serial)&&(v.selected=!1),a==="name"&&c.configJson.whiteList&&c.configJson.whiteList.length>0&&c.configJson.whiteList.includes(v.name)&&(v.selected=!0),a==="name"&&c.configJson.whiteList&&c.configJson.whiteList.length>0&&!c.configJson.whiteList.includes(v.name)&&(v.selected=!1),a==="name"&&c.configJson.blackList&&c.configJson.blackList.length>0&&c.configJson.blackList.includes(v.name)&&(v.selected=!1)),v.selected},[V]);r.useEffect(()=>{const v=c=>{if(o&&console.log("HomeDevices received WebSocket Message:",c),c.method==="refresh_required"&&c.response.changed!=="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${c.response.changed} and sending /api/plugins request`),i({id:S.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):c.method==="refresh_required"&&c.response.changed==="matter"?(o&&console.log(`HomeDevices received refresh_required: changed=${c.response.changed} and setting matter id ${c.response.matter?.id}`),I(a=>{const x=a.findIndex(N=>N.name.replaceAll(" ","")===c.response.matter?.id);if(x<0)return o&&console.debug(`HomeDevices: matter id ${c.response.matter?.id} not found`),a;const k=[...a];return k[x]={...k[x],matter:c.response.matter},o&&console.log(`HomeDevices received refresh_required: changed=${c.response.changed} and set matter id ${c.response.matter?.id}`),k})):c.method==="restart_required"?(o&&console.log("HomeDevices received restart_required"),t(!0)):c.method==="restart_not_required"?(o&&console.log("HomeDevices received restart_not_required"),t(!1)):c.method==="state_update"&&c.response.plugin&&c.response.serialNumber&&c.response.cluster.includes("BasicInformation")&&c.response.attribute==="reachable"&&(o&&console.log(`HomeDevices updating device reachability for plugin ${c.response.plugin} serial ${c.response.serialNumber} value ${c.response.value}`),A(a=>{const x=a.findIndex(k=>k.pluginName===c.response.plugin&&k.serial===c.response.serialNumber);return x<0?(o&&console.warn(`HomeDevices: device to update not found for plugin ${c.response.plugin} serial ${c.response.serialNumber}`),a):(a[x]={...a[x],reachable:c.response.value},[...a])})),c.id===S.current&&c.method==="/api/settings")o&&console.log(`HomeDevices (id: ${c.id}) received settings:`,c.response),j(c.response),t(c.response.matterbridgeInformation.restartRequired||c.response.matterbridgeInformation.fixedRestartRequired);else if(c.id===S.current&&c.method==="/api/plugins"){if(o&&console.log(`HomeDevices (id: ${c.id}) received ${c.response?.length} plugins:`,c.response),c.response){let a=!0;for(const x of c.response)x.enabled===!0&&(x.loaded!==!0||x.started!==!0||x.error===!0)&&(a=!1);if(!a)return;o&&console.log("HomeDevices reset plugins, devices and selectDevices"),y(!1),q(c.response),A([]),p([]),i({id:S.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),o&&console.log("HomeDevices sent /api/devices");for(const x of c.response)x.enabled===!0&&x.loaded===!0&&x.started===!0&&x.error!==!0&&(i({id:S.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:x.name}}),o&&console.log(`HomeDevices sent /api/select/devices for plugin: ${x.name}`))}}else if(c.id===S.current&&c.method==="/api/devices"){if(o&&console.log(`HomeDevices (id: ${c.id}) received ${c.response?.length} devices:`,c.response),c.response){for(const a of c.response)a.selected=H(a);A(c.response)}}else c.id===S.current&&c.method==="/api/select/devices"&&(o&&console.log(`HomeDevices (id: ${c.id}) received ${c.response?.length} selectDevices for plugin ${c.response&&c.response.length>0?c.response[0].pluginName:"without select devices"}:`,c.response),c.response&&c.response.length>0&&p(a=>{const x=a.filter(N=>N.pluginName!==c.response[0].pluginName),k=c.response.map(N=>({...N,selected:H(N)}));return[...x,...k]}))};return s(v,S.current),o&&console.log(`HomeDevices added WebSocket listener id ${S.current}`),()=>{m(v),o&&console.log("HomeDevices removed WebSocket listener")}},[V,s,m,i,H]),r.useEffect(()=>{if(Q.length===0&&h.length===0){I([]);return}o&&console.log(`HomeDevices mixing devices (${Q.length}) and selectDevices (${h.length})`);const v=[];for(const c of Q)v.push(c);for(const c of h)Q.find(a=>a.pluginName===c.pluginName&&a.serial.includes(c.serial))||v.push(c);v.length>0&&(I(v),o&&console.log(`HomeDevices mixed ${v.length} devices and selectDevices`))},[V,Q,h,I]),r.useEffect(()=>{l&&(o&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:S.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:S.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const oe=(v,c)=>{o&&console.log(`handleCheckboxChange: checkbox changed to ${v.target.checked} for device ${c.name} serial ${c.serial}`),Q.findIndex(a=>a.pluginName===c.pluginName&&a.serial===c.serial)<0?(o&&console.warn(`handleCheckboxChange: device ${c.name} serial ${c.serial} not found in devices, trying in mixedDevices`),I(a=>{const x=a.findIndex(k=>k.pluginName===c.pluginName&&k.serial===c.serial);return x<0?(console.error(`handleCheckboxChange: device ${c.name} serial ${c.serial} not found in mixedDevices`),a):(a[x]={...a[x],selected:v.target.checked},[...a])})):A(a=>{const x=a.findIndex(k=>k.pluginName===c.pluginName&&k.serial===c.serial);return x<0?(console.error(`handleCheckboxChange: device ${c.name} serial ${c.serial} not found in devices`),a):(a[x]={...a[x],selected:v.target.checked},[...a])}),v.target.checked?i({id:S.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:c.pluginName,serial:c.serial,name:c.name}}):i({id:S.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:c.pluginName,serial:c.serial,name:c.name}})};return o&&console.log("HomeDevices rendering..."),l?e.jsx(je,{style:{flex:"1 1 auto"},children:e.jsx(Wt,{name:"Devices",getRowKey:On,rows:u,columns:P,footerLeft:W?"Waiting for the plugins to fully load...":`Registered devices: ${Q.length.toString()}/${u.length.toString()}`,footerRight:b?"Restart required":""})}):e.jsx(_e,{})}const Hn=r.memo(_n);function ht({children:n,style:d,name:l}){const{setCurrentPage:i}=r.useContext(Le);i(l),o&&console.log(`MbfPage: current page set to ${l}`);const s={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...s,...d},children:n})}const Vn=()=>"ontouchstart"in window||typeof window.DocumentTouch<"u"&&document instanceof window.DocumentTouch?(o&&console.log("WebSocketLogs detectTouchscreen = true"),!0):(o&&console.log("WebSocketLogs detectTouchscreen = false"),!1);function En(){const{messages:n,logAutoScroll:d}=r.useContext(jr),[l,i]=r.useState(!1),s=r.useRef(null),m=r.useRef(0),g=r.useRef(null),b=r.useMemo(()=>Vn(),[]),t=j=>i(!0),W=j=>i(!1);r.useEffect(()=>{if(o&&console.log(`WebSocketLogs logAutoScroll: ${d.current} isHovering: ${l}`),d.current&&!l&&!b){const j=Date.now();j-m.current>=500?(o&&console.log("WebSocketLogs auto-scroll to bottom"),m.current=j,s.current?.scrollIntoView({behavior:"smooth",block:"end"})):(o&&console.log("WebSocketLogs auto-scroll skipped to avoid flicker"),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{s.current?.scrollIntoView({behavior:"smooth"}),m.current=Date.now()},1e3))}},[n,d,l,b]);const y=j=>{switch(j.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"}},w=j=>{switch(j.toLowerCase()){case"warn":return"black";default:return"white"}};return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:t,onMouseLeave:W,children:[n.map((j,V)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:y(j.level),color:w(j.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:j.level}),j.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+j.time+"]"}),j.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+j.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:j.message})]},V)),e.jsx("div",{ref:s})]})})}const Sr=r.memo(En);function An(){const[n,d]=r.useState(localStorage.getItem(te.logFilterLevel)??"info"),[l,i]=r.useState(localStorage.getItem(te.logFilterSearch)??"*"),{online:s,logAutoScroll:m}=r.useContext(xe);return o&&console.log("HomeLogs rendering..."),s?e.jsxs(je,{style:{flex:"1 1 auto"},children:[e.jsxs(De,{children:[e.jsx(Ce,{children:"Logs"}),e.jsxs(Ce,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',l===""?"*":l,'" Scroll: ',m.current?"auto":"manual"]})]}),e.jsx(Ne,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(Sr,{})})]}):e.jsx(_e,{})}const Un=r.memo(An);function zn(){const{online:n}=r.useContext(xe);return o&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(je,{children:[e.jsx(De,{children:e.jsx(Ce,{children:"Frontend Update"})}),e.jsxs(Ne,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h4",{style:{margin:0},children:"The frontend has been updated. You are viewing an outdated web UI. Please refresh the page now."}),e.jsx("div",{children:e.jsx(ae,{onClick:()=>window.location.reload(),endIcon:e.jsx(ro,{}),style:{marginLeft:"10px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Refresh"})})]})]}):e.jsx(_e,{})}const qn=r.memo(zn);function Bn({changelog:n}){const{online:d}=r.useContext(xe);return o&&console.log("HomeShowChangelog rendering..."),d?e.jsxs(je,{children:[e.jsx(De,{children:e.jsx(Ce,{children:"Matterbridge Update"})}),e.jsxs(Ne,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(ae,{onClick:()=>window.open("https://github.com/Luligu/matterbridge","_blank"),endIcon:e.jsx(br,{style:{color:"#FFD700"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Star"}),e.jsx(ae,{onClick:()=>window.open("https://www.buymeacoffee.com/luligugithub","_blank"),endIcon:e.jsx(At,{style:{color:"#b6409c"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Sponsor"}),e.jsx(ae,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Et,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ae,{onClick:()=>window.location.reload(),endIcon:e.jsx(oo,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(_e,{})}const Qn=r.memo(Bn);function Gn({matterbridgeInfo:n}){const{mobile:d}=r.useContext(Le);o&&console.log("MatterbridgeInfoTable:",n);const l=["matterbridgeLatestVersion","matterbridgeDevVersion","--matterFileLogger","--fileLogger","--matterLoggerLevel","--loggerLevel","--virtualMode","--bridgeMode","--restartMode","--restartRequired","fixedRestartRequired","--updateRequired","matterMdnsInterface","matterIpv4Address","matterIpv6Address","readOnly","shellyBoard","shellySysUpdate","shellyMainUpdate","matterPort","matterDiscriminator","matterPasscode"],[i,s]=r.useState(!1);return!n||i?null:(o&&console.log("MatterbridgeInfoTable rendering..."),e.jsxs(je,{style:he&&d?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(De,{children:[e.jsx(Ce,{children:"Matterbridge info"}),e.jsx(Ze,{close:()=>s(!0)})]}),e.jsx(Ne,{style:he&&d?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(n).filter(([m,g])=>!l.includes(m)&&g!==null&&g!==void 0&&g!=="").map(([m,g],b)=>e.jsxs("tr",{className:b%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:m.replace("matterbridgeVersion","Matterbridge version").replace("matterbridgeLatestVersion","Matterbridge latest v.").replace("matterbridgeDevVersion","Matterbridge dev v.").replace("frontendVersion","Frontend version").replace("homeDirectory","Home").replace("rootDirectory","Root").replace("matterbridgeDirectory","Storage").replace("matterbridgeCertDirectory","Cert").replace("matterbridgePluginDirectory","Plugins").replace("globalModulesDirectory","Modules").replace("bridgeMode","Bridge mode").replace("restartMode","Restart mode").replace("virtualMode","Virtual mode").replace("profile","Profile").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("matterLoggerLevel","Matter logger level").replace("matterFileLogger","Matter file logger").replace("restartRequired","Restart required").replace("updateRequired","Update required")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:he&&d?typeof g!="string"?g.toString():g:e.jsx(Cr,{value:typeof g!="string"?g.toString():g,maxChars:24})})]},m))})]})})]}))}const Kn=r.memo(Gn);function Jn(){const[n,d]=r.useState(null),[l,i]=r.useState(null),[s,m]=r.useState([]),[g]=r.useState(localStorage.getItem(te.homePagePlugins)!=="false"),[b,t]=r.useState(localStorage.getItem(te.homePageMode)??"devices"),[W,y]=r.useState(""),[w,j]=r.useState(!1),[V,q]=r.useState(!1),[Q,A]=r.useState(null),{mobile:h}=r.useContext(Le),{addListener:p,removeListener:u,online:I,sendMessage:S,getUniqueId:P}=r.useContext(xe),H=r.useRef(P());return r.useEffect(()=>{const oe=v=>{o&&console.log("Home received WebSocket Message:",v),v.method==="refresh_required"&&v.response.changed==="settings"&&(o&&console.log(`Home received refresh_required: changed=${v.response.changed} and sending /api/settings request`),A(null),m([]),S({id:H.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),S({id:H.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),v.method==="/api/settings"&&v.id===H.current&&(o&&console.log("Home received settings:",v.response),d(v.response.systemInformation),i(v.response.matterbridgeInformation),v.response.matterbridgeInformation.matterbridgeVersion&&y(`https://github.com/Luligu/matterbridge/blob/${v.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem(te.frontendVersion)===null&&v.response.matterbridgeInformation.frontendVersion?localStorage.setItem(te.frontendVersion,v.response.matterbridgeInformation.frontendVersion):v.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(te.frontendVersion)&&v.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(te.frontendVersion,v.response.matterbridgeInformation.frontendVersion),q(!0)),localStorage.getItem(te.matterbridgeVersion)===null?localStorage.setItem(te.matterbridgeVersion,v.response.matterbridgeInformation.matterbridgeVersion):v.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(te.matterbridgeVersion)&&(localStorage.setItem(te.matterbridgeVersion,v.response.matterbridgeInformation.matterbridgeVersion),j(!0)),v.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(te.homePageMode)||(localStorage.setItem(te.homePageMode,"devices"),t("devices")))),v.method==="/api/plugins"&&v.id===H.current&&(o&&console.log("Home received plugins:",v.response),m(v.response))};return p(oe,H.current),o&&console.log(`Home added WebSocket listener id ${H.current}`),()=>{u(oe),o&&console.log("Home removed WebSocket listener")}},[p,u,S]),r.useEffect(()=>{if(o&&console.log(`Home storeId effect with storeId ${Q}`),l?.bridgeMode==="bridge"&&!Q&&(o&&console.log("Home storeId effect set storeId to Matterbridge"),A("Matterbridge")),l?.bridgeMode==="childbridge"&&!Q&&s){for(const oe of s)if(oe.matter?.id){o&&console.log(`Home storeId effect set storeId to ${oe.matter.id}`),A(oe.matter.id);break}}},[l,s,Q]),r.useEffect(()=>{I&&(o&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),S({id:H.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),S({id:H.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[I,S]),o&&console.log("Home rendering..."),!I||!n||!l?e.jsx(_e,{}):e.jsxs(ht,{name:"Home",style:he&&h?{alignItems:"center",gap:"10px"}:{flexDirection:"row"},children:[(he&&!h||!he)&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(ir,{id:Q}),e.jsx(or,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:he&&h?"10px":"20px"},children:[V&&e.jsx(qn,{}),w&&e.jsx(Qn,{changelog:W}),he&&h&&e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(ir,{id:Q}),e.jsx(or,{systemInfo:n,compact:!0}),e.jsx(Kn,{matterbridgeInfo:l})]}),g&&!l.readOnly&&e.jsx(In,{}),g&&e.jsx(Rn,{storeId:Q,setStoreId:A}),b==="devices"&&e.jsx(Hn,{storeId:Q,setStoreId:A}),b==="logs"&&e.jsx(Un,{})]})]})}const Zn=r.memo(Jn),It=!1,ar={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},Yn={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},Xn={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},cr={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},ei={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},ti={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},ri={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},oi={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},ni={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},_t={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},ii=[256,257,268,269],si=[266,267],li=[259,260,261,271,272],ai=[256,257,268,269,266,267,259,260,261,272];function X({icon:n,iconColor:d,cluster:l,value:i,unit:s,prefix:m}){return o&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${s}"`),m=m??!1,e.jsxs(se,{sx:ar,children:[n&&r.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...Yn,color:d??"var(--primary-color)"}}),e.jsxs(se,{sx:{...ar,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&m===!0&&e.jsx(ge,{sx:cr,children:s},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(ge,{sx:Xn,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${l.clusterId}-${l.attributeId}-value`),s&&m===!1&&e.jsx(ge,{sx:cr,children:s},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function ci({device:n,endpoint:d,id:l,deviceType:i,clusters:s}){const m=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let g="";o&&console.log(`Device "${n.name}" endpoint "${d}" id "${l}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${s?.length})`);const b=s.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(b){let t="";b.map(W=>{W.label&&(t+=W.label+" ")}),g=t.trim()}if(i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>g=`${t.attributeLocalValue} mV`),ai.includes(i)&&s.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>g=`Level ${t.attributeValue}`),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>g=`Position ${t.attributeLocalValue/100}%`),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>g=`Heat ${t.attributeLocalValue/100}°C `),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>g=g+`Cool ${t.attributeLocalValue/100}°C`),i===118&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>g=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>g=`${t.attributeLocalValue/1e3} V, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>g=g+`${t.attributeLocalValue/1e3} A, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>g=g+`${t.attributeLocalValue/1e3} W`),i===39){const t=s.find(y=>y.clusterName==="ModeSelect"&&y.attributeName==="currentMode")?.attributeLocalValue;g=s.find(y=>y.clusterName==="ModeSelect"&&y.attributeName==="supportedModes")?.attributeLocalValue?.find(y=>y.mode===t)?.label||"Unknown"}if(i===116){const t=s.find(y=>y.clusterName==="RvcRunMode"&&y.attributeName==="currentMode")?.attributeLocalValue;g=s.find(y=>y.clusterName==="RvcRunMode"&&y.attributeName==="supportedModes")?.attributeLocalValue?.find(y=>y.mode===t)?.label||"Unknown"}return e.jsxs(je,{style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(X,{icon:t.attributeLocalValue===!0?e.jsx(ut,{}):e.jsx(no,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(X,{icon:e.jsx(Ke,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(X,{icon:e.jsx(fr,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&s.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(X,{icon:e.jsx(le,{path:Eo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),ii.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(X,{icon:e.jsx(io,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),si.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(X,{icon:e.jsx(le,{path:Ao,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),li.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(X,{icon:e.jsx(le,{path:Uo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(X,{icon:e.jsx(le,{path:zo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(X,{icon:e.jsx(le,{path:qo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(X,{icon:e.jsx(le,{path:Bo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(X,{icon:e.jsx(Zt,{}),cluster:t,value:"Oven"})),i===112&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(X,{icon:e.jsx(so,{}),cluster:t,value:"Fridge"})),i===113&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(X,{icon:e.jsx(le,{path:Qo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(X,{icon:e.jsx(Zt,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(X,{icon:e.jsx(le,{path:Go,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(X,{icon:e.jsx(le,{path:tr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(X,{icon:e.jsx(le,{path:tr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(X,{icon:e.jsx(lo,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(X,{icon:e.jsx(le,{path:Ko,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&s.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(X,{icon:t.attributeValue==="1"?e.jsx(ao,{}):e.jsx(co,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(X,{icon:e.jsx(po,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&s.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(X,{icon:e.jsx(le,{path:Jo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&s.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(X,{icon:e.jsx(uo,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(X,{icon:e.jsx(go,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(X,{icon:e.jsx(Yt,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(X,{icon:e.jsx(Yt,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(X,{icon:e.jsx(mo,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(X,{icon:e.jsx(ho,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(X,{icon:e.jsx(fo,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&s.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(X,{icon:e.jsx(le,{path:Zo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&s.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(X,{icon:e.jsx(le,{path:Yo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&s.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(X,{icon:e.jsx(le,{path:Xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(X,{icon:e.jsx(le,{path:en,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(X,{icon:e.jsx(le,{path:tn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(X,{icon:e.jsx(le,{path:rn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(X,{icon:e.jsx(le,{path:rr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(X,{icon:e.jsx(le,{path:rr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&s.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(X,{icon:e.jsx(xo,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&s.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(X,{icon:e.jsx(le,{path:on,size:"40px",color:"var(--primary-color)"}),cluster:t,value:m[t.attributeLocalValue??0]})),i===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(X,{icon:e.jsx(bo,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&s.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(X,{icon:e.jsx(le,{path:nn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&s.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(X,{icon:e.jsx(vo,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&s.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(X,{icon:e.jsx(yo,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(X,{icon:t.attributeValue==="true"?e.jsx(jo,{}):e.jsx(Co,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&s.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(X,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(wo,{}):e.jsx(So,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&s.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(X,{icon:e.jsx(ko,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&s.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(X,{icon:e.jsx(Io,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(se,{sx:ei,children:e.jsx(ge,{sx:ti,children:g})}),e.jsx(se,{sx:ri,children:e.jsx(ge,{sx:oi,children:n.name})}),e.jsxs(se,{sx:ni,children:[o&&e.jsx(ge,{sx:_t,children:d}),e.jsx(ge,{sx:_t,children:l}),o&&e.jsxs(ge,{sx:_t,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function di({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:s,getUniqueId:m}=r.useContext(xe),[g,b]=r.useState([]),[t,W]=r.useState({}),[y,w]=r.useState({}),[j,V]=r.useState({}),q=r.useRef(m()),Q=r.useCallback(p=>{(o||It)&&console.log(`DevicesIcons received state_update "${p.response.cluster}.${p.response.attribute}" for "${p.response.id}:${p.response.number}": "${p.response.value}"`,p.response);const u=g.find(S=>S.pluginName===p.response.plugin&&S.serial===p.response.serialNumber);if(!u){(o||It)&&console.warn(`DevicesIcons updater device of plugin "${p.response.plugin}" serial "${p.response.serialNumber}" number "${p.response.number}" id "${p.response.id}" not found in devices(${g.length})`);return}const I=j[u.serial]?.find(S=>S.endpoint===p.response.number.toString()&&S.clusterName===p.response.cluster&&S.attributeName===p.response.attribute);if(!I){(o||It)&&console.warn(`DevicesIcons updater device "${u.name}" serial "${u.serial}" cluster "${p.response.cluster}" attribute "${p.response.attribute}" not found in clusters(${j[u.serial]?.length})`);return}I.attributeValue=String(p.response.value),I.attributeLocalValue=p.response.value,V({...j}),(o||It)&&console.log(`DevicesIcons updated "${I.clusterName}.${I.attributeName}" for device "${u.name}" serial "${u.serial}" to "${I.attributeValue}"`)},[j,g]),A=r.useCallback(p=>{if(o&&console.log(`DevicesIcons received for device "${p.response.deviceName}" serial "${p.response.serialNumber}" deviceTypes (${p.response.deviceTypes.length}) "${p.response.deviceTypes.join(",")}" clusters (${p.response.clusters.length}):`,p.response),p.response.clusters.length===0)return;const u=p.response.serialNumber;t[u]=[],y[u]=p.response.deviceTypes,j[u]=[];for(const I of p.response.clusters)t[u].find(S=>S.endpoint===I.endpoint)||t[u].push({endpoint:I.endpoint,id:I.id,deviceTypes:I.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(I.clusterName)&&j[u].push(I);W({...t}),w({...y}),V({...j}),o&&console.log(`DevicesIcons endpoints for "${u}":`,t[u]),o&&console.log(`DevicesIcons deviceTypes for "${u}":`,y[u]),o&&console.log(`DevicesIcons clusters for "${u}":`,j[u])},[j,y,t]);r.useEffect(()=>{const p=u=>{if(o&&console.log("DevicesIcons received WebSocket Message:",u),u.method==="refresh_required")o&&console.log(`DevicesIcons received refresh_required: changed=${u.response.changed} and sending api requests`),l({id:q.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(u.method==="state_update"&&u.response)Q(u);else if(u.method==="/api/devices"&&u.response){o&&console.log(`DevicesIcons received ${u.response.length} devices:`,u.response),b(u.response),W({}),w({}),V({});for(const I of u.response)o&&console.log("DevicesIcons sending /api/clusters"),l({id:q.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:I.pluginName,endpoint:I.endpoint||0}})}else u.method==="/api/clusters"&&u.response&&A(u)};return i(p,q.current),o&&console.log("DevicesIcons WebSocket effect mounted"),()=>{s(p),o&&console.log("DevicesIcons WebSocket effect unmounted")}},[g]),r.useEffect(()=>(o&&console.log("DevicesIcons useEffect online mounting"),d&&(o&&console.log("DevicesIcons useEffect online sending api requests"),l({id:q.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}})),o&&console.log("DevicesIcons useEffect online mounted"),()=>{o&&console.log("DevicesIcons useEffect online unmounted")}),[d,l]);const h=r.memo(ci);return o&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:g.filter(p=>p.name.toLowerCase().includes(n)||p.serial.toLowerCase().includes(n)).map(p=>t[p.serial]&&t[p.serial].map(u=>u.deviceTypes.map(I=>e.jsx(h,{device:p,endpoint:u.endpoint,id:u.id,deviceType:I,clusters:j[p.serial].filter(S=>S.endpoint===u.endpoint)},`${p.pluginName}-${p.uniqueId}-${u.endpoint}-${u.id}-${I.toString()}`))))})}const pi=r.memo(di),ui=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(n,d,l,i)=>l.configUrl?e.jsx(G,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(xr,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],gi=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,d,l,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(s=>`0x${s.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,maxWidth:350,tooltip:!0}],mi=n=>`${n.pluginName}::${n.uniqueId}`,hi=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function fi({filter:n}){const{online:d,sendMessage:l,addListener:i,removeListener:s,getUniqueId:m}=r.useContext(xe),[g,b]=r.useState([]),[t,W]=r.useState(g),[y,w]=r.useState([]),[j,V]=r.useState(0),[q,Q]=r.useState(null),[A,h]=r.useState(null),[p,u]=r.useState(null),[I,S]=r.useState(null),P=r.useRef(m()),H=r.useRef(t),oe=r.useCallback(c=>{o&&console.log(`DevicesTable received state_update "${c.response.cluster}.${c.response.attribute}" for "${c.response.id}:${c.response.number}": "${c.response.value}"`,c.response);const a=H.current.find(x=>x.pluginName===c.response.plugin&&x.uniqueId===c.response.uniqueId);if(!a){o&&console.warn(`DevicesTable updater device of plugin "${c.response.plugin}" serial "${c.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(q&&A&&a.pluginName===q&&a.uniqueId===I&&c.response.number.toString()===A){const x=y.find(k=>k.endpoint===c.response.number.toString()&&k.clusterName===c.response.cluster&&k.attributeName===c.response.attribute);if(!x){o&&console.warn(`DevicesTable updater cluster ${c.response.cluster}.${c.response.attribute} for device "${a.name}" serial "${a.serial}" not found in clusters`);return}x.attributeValue=typeof c.response.value=="object"?JSON.stringify(c.response.value,void 0,1).replaceAll('"',""):String(c.response.value),x.attributeLocalValue=c.response.value,w([...y]),o&&console.log(`DevicesTable updated attribute ${x.clusterName}.${x.attributeName} for device "${a.name}" serial "${a.serial}" to "${x.attributeValue}"`)}},[y,A,q,I]);r.useEffect(()=>{const c=a=>{if(o&&console.log("DevicesTable received WebSocket Message:",a),a.method==="refresh_required"&&a.response.changed==="devices")o&&console.log(`DevicesTable received refresh_required: changed=${a.response.changed} and sending /api/devices request`),l({id:P.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(a.method==="state_update"&&a.response)oe(a);else if(a.method==="/api/devices")o&&console.log(`DevicesTable received ${a.response.length} devices:`,a.response),b(a.response);else if(a.method==="/api/clusters"){o&&console.log(`DevicesTable received ${a.response.clusters.length} clusters for plugin ${a.response.plugin}:`,a.response),w(a.response.clusters);const x={};for(const k of a.response.clusters)o&&console.log("Cluster:",k.endpoint),x[k.endpoint]?x[k.endpoint]++:x[k.endpoint]=1;V(Object.keys(x).length)}};return i(c,P.current),o&&console.log("DevicesTable added WebSocket listener"),()=>{s(c),o&&console.log("DevicesTable removed WebSocket listener")}},[l,i,s,oe]),r.useEffect(()=>{d&&(o&&console.log("DevicesTable sending api requests with id ",P.current),l({id:P.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:P.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:P.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[d,l]),r.useEffect(()=>{q&&A&&(o&&console.log("DevicesTable sending /api/clusters"),l({id:P.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:q,endpoint:Number(A)}}))},[q,A,l]),r.useEffect(()=>{if(n===""){W(g),H.current=g;return}const c=g.filter(a=>a.name.toLowerCase().includes(n)||a.serial.toLowerCase().includes(n));W(c),H.current=c},[g,n]);const v=c=>{if(c.uniqueId===I){S(null),Q(null),h(null),u(null);return}S(c.uniqueId),Q(c.pluginName),h(c.endpoint?c.endpoint.toString():null),u(c.name)};return o&&console.log("DevicesTable rendering..."),d?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx(je,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${q&&A?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Wt,{name:"Registered devices",getRowKey:mi,onRowClick:v,rows:t,columns:ui,footerLeft:`Total devices: ${t.length.toString()}`})}),q&&A&&e.jsx(je,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(Wt,{name:"Clusters",title:p||"",getRowKey:hi,rows:y,columns:gi,footerLeft:`Total child endpoints: ${j-1}`})})]}):e.jsx(_e,{})}const xi=r.memo(fi);function bi(){const{online:n}=r.useContext(xe),[d,l]=r.useState(""),[i,s]=r.useState("icon");r.useEffect(()=>{const b=localStorage.getItem(te.devicesFilter);b&&l(b)},[]),r.useEffect(()=>{const b=localStorage.getItem(te.devicesViewMode);b&&s(b)},[]);const m=b=>{l(b.target.value.toLowerCase()),localStorage.setItem(te.devicesFilter,b.target.value.toLowerCase())},g=b=>{s(b),localStorage.setItem(te.devicesViewMode,b)};return o&&console.log("Devices rendering..."),n?e.jsxs(ht,{name:"Devices",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",padding:0,margin:0,gap:"20px",width:"100%"},children:[e.jsxs(se,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ge,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(fe,{variant:"outlined",value:d,onChange:m,placeholder:"Enter the device name or serial",sx:{width:"260px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(se,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ge,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(G,{onClick:()=>g("table"),"aria-label":"Table View",disabled:i==="table",children:e.jsx(_,{title:"Table View",children:e.jsx(Mo,{style:{color:i==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(G,{onClick:()=>g("icon"),"aria-label":"Icon View",disabled:i==="icon",children:e.jsx(_,{title:"Icon View (beta)",children:e.jsx(Do,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(xi,{filter:d}),i==="icon"&&e.jsx(pi,{filter:d})]}):e.jsx(_e,{})}const vi=r.memo(bi);function yi(){const{logLength:n,logAutoScroll:d,setMessages:l,setLogFilterLevel:i,setLogFilterSearch:s,online:m,filterLogMessages:g}=r.useContext(xe),[b,t]=r.useState(localStorage.getItem(te.logFilterLevel)??"info"),[W,y]=r.useState(localStorage.getItem(te.logFilterSearch)??"*"),[w,j]=r.useState(n.current.toString()),[V,q]=r.useState(d.current),Q=I=>{const S=I.target.value;t(S),i(S),g(S,W),localStorage.setItem(te.logFilterLevel,S),o&&console.log("handleLogFilterLevelChange called with value:",S)},A=I=>{const S=I.target.value;y(S),s(S),g(b,S),localStorage.setItem(te.logFilterSearch,S),o&&console.log("handleLogFilterSearchChange called with value:",S)},h=I=>{const S=I.target.checked;q(S),d.current=S,g(b,W),localStorage.setItem(te.logAutoScroll,S?"true":"false"),o&&console.log("handleAutoScrollChange called with value:",S)},p=I=>{const S=I.target.value;j(S),n.current=Number(S),localStorage.setItem(te.logLength,S),o&&console.log("handleLogLengthChange called with value:",S)},u=()=>{o&&console.log("handleClearLogsClick called"),l([])};return o&&console.log("Logs rendering..."),m?e.jsxs(ht,{name:"Logs",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(Tt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(Je,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:b,onChange:Q,children:[e.jsx(C,{value:"debug",children:"Debug"}),e.jsx(C,{value:"info",children:"Info"}),e.jsx(C,{value:"notice",children:"Notice"}),e.jsx(C,{value:"warn",children:"Warn"}),e.jsx(C,{value:"error",children:"Error"}),e.jsx(C,{value:"fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"5px"},children:[e.jsx(Tt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(_,{title:"Use /text/ for case-insensitive regex search",children:e.jsx(fe,{style:{width:"210px"},size:"small",id:"logsearch",variant:"outlined",value:W,onChange:A,slotProps:{input:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}})})]}),e.jsx(Ye,{control:e.jsx(qe,{checked:V,onChange:h}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(Tt,{id:"select-size-label",style:{color:"var(--div-text-color)"},children:"Log length:"}),e.jsxs(Je,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-size-label",id:"select-size",value:w,onChange:p,children:[e.jsx(C,{value:100,children:"100"}),e.jsx(C,{value:200,children:"200"}),e.jsx(C,{value:500,children:"500"}),e.jsx(C,{value:1e3,children:"1000"})]}),e.jsx(_,{title:"Clear the logs",children:e.jsx(ae,{onClick:u,endIcon:e.jsx(Vt,{}),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(Sr,{})})]}):e.jsx(_e,{})}const ji=r.memo(yi),Ci=({open:n,ip:d,onClose:l,onSave:i})=>{const s=d?d.split(".").slice(0,3).join(".")+".1":"",[m,g]=r.useState("dhcp"),[b,t]=r.useState({ip:d??"",subnet:"255.255.255.0",gateway:s,dns:s}),W=j=>V=>{t({...b,[j]:V.target.value})},y=()=>{l()},w=()=>{i({type:m,...b}),l()};return e.jsxs(Ve,{open:n,onClose:(j,V)=>{V==="backdropClick"||V==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Ee,{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(Ae,{dividers:!0,children:[e.jsxs(vr,{component:"fieldset",fullWidth:!0,children:[e.jsx(ke,{component:"legend",children:"Select IP Configuration"}),e.jsxs(yr,{row:!0,value:m,onChange:j=>g(j.target.value),children:[e.jsx(Ye,{value:"dhcp",control:e.jsx($t,{}),label:"DHCP"}),e.jsx(Ye,{value:"static",control:e.jsx($t,{}),label:"Static"})]})]}),m==="static"&&e.jsxs(Qe,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Qe,{size:6,children:e.jsx(fe,{label:"IP Address",fullWidth:!0,value:b.ip,onChange:W("ip")})}),e.jsx(Qe,{size:6,children:e.jsx(fe,{label:"Subnet Mask",fullWidth:!0,value:b.subnet,onChange:W("subnet")})}),e.jsx(Qe,{size:6,children:e.jsx(fe,{label:"Gateway",fullWidth:!0,value:b.gateway,onChange:W("gateway")})}),e.jsx(Qe,{size:6,children:e.jsx(fe,{label:"DNS Server",fullWidth:!0,value:b.dns,onChange:W("dns")})})]})]}),e.jsxs(Ge,{children:[e.jsx(ae,{onClick:y,children:"Cancel"}),e.jsx(ae,{variant:"contained",onClick:w,children:"Save"})]})]})},wi=({open:n,onClose:d,onSave:l})=>{const[i,s]=r.useState(""),[m,g]=r.useState(""),b=V=>{s(V.target.value)},t=V=>{g(V.target.value)},W=i.length>0&&i===m,y=()=>{d()},w=()=>{W&&(l(i),d())},j=()=>{l(""),d()};return e.jsxs(Ve,{open:n,onClose:(V,q)=>{q==="backdropClick"||q==="escapeKeyDown"||d()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Ee,{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(Ae,{dividers:!0,children:e.jsx(vr,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(Qe,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(Qe,{size:12,children:e.jsx(fe,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:b})}),e.jsx(Qe,{size:12,children:e.jsx(fe,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:m,onChange:t,error:m!==""&&i!==m,helperText:m!==""&&i!==m?"Passwords do not match":""})})]})})}),e.jsxs(Ge,{children:[e.jsx(ae,{onClick:y,children:"Cancel"}),e.jsx(ae,{variant:"contained",onClick:w,disabled:!W,children:"Change"}),e.jsx(ae,{variant:"contained",onClick:j,children:"Reset"})]})]})};function nt(n=1e3){let d=null;const l=(i=>{d!==null&&window.clearTimeout(d),d=window.setTimeout(()=>{i(),d=null},n)});return l.cancel=()=>{d!==null&&(window.clearTimeout(d),d=null)},l}const Ft=330;function Si(){const{mobile:n}=r.useContext(Le),{online:d,addListener:l,removeListener:i,sendMessage:s,getUniqueId:m}=r.useContext(xe),[g,b]=r.useState(null),[t,W]=r.useState(null),y=r.useRef(m());return r.useEffect(()=>{const w=j=>{o&&console.log("Settings received WebSocket Message:",j),j.method==="refresh_required"&&j.response.changed==="settings"?(o&&console.log(`Settings received refresh_required: changed=${j.response.changed} and sending /api/settings request`),s({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):j.method==="/api/settings"&&(o&&console.log("Settings received /api/settings:",j.response),b(j.response.matterbridgeInformation),W(j.response.systemInformation))};return l(w,y.current),o&&console.log("Settings added WebSocket listener"),()=>{i(w),o&&console.log("Settings removed WebSocket listener")}},[l,i,s]),r.useEffect(()=>{d&&(o&&console.log("Settings received online"),s({id:y.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[d,s]),o&&console.log("Settings rendering..."),!d||!g||!t?e.jsx(_e,{}):e.jsx(ht,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:he&&n?"10px":"20px"},children:[e.jsx(ki,{matterbridgeInfo:g,systemInfo:t}),e.jsx(Ii,{matterbridgeInfo:g}),e.jsx(Mi,{matterbridgeInfo:g}),e.jsx(Di,{systemInfo:t})]})})}function ki({matterbridgeInfo:n,systemInfo:d}){const{sendMessage:l,getUniqueId:i}=r.useContext(xe),[s,m]=r.useState("bridge"),[g,b]=r.useState("Info"),[t,W]=r.useState(!1),[y,w]=r.useState("dark"),[j,V]=r.useState(localStorage.getItem(te.homePagePlugins)!=="false"),[q,Q]=r.useState(localStorage.getItem(te.homePageMode)??"devices"),[A,h]=r.useState(localStorage.getItem(te.virtualMode)??"outlet"),p=r.useRef(i()),[u,I]=r.useState(!1),S=()=>I(!1),P=O=>{o&&console.log("handleSaveNetConfig called with config:",O),l({id:p.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:O})},[H,oe]=r.useState(!1),v=()=>oe(!1),c=O=>{o&&console.log("handleSaveChangePassword called with password:",O),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:O}}),Vi(O)};r.useEffect(()=>{n&&(m(n.bridgeMode==="bridge"?"bridge":"childbridge"),b(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),W(n.fileLogger),h(n.virtualMode))},[n]),r.useEffect(()=>{const O=localStorage.getItem(te.frontendTheme);O&&w(O)},[]);const a=O=>{o&&console.log("handleChangeBridgeMode called with value:",O.target.value),m(O.target.value),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:O.target.value}})},x=O=>{o&&console.log("handleChangeMbLoggerLevel called with value:",O.target.value),b(O.target.value),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:O.target.value}})},k=O=>{o&&console.log("handleLogOnFileMbChange called with value:",O.target.checked),W(O.target.checked),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:O.target.checked}})},N=O=>{const B=O.target.value;o&&console.log("handleChangeTheme called with value:",B),w(B),localStorage.setItem(te.frontendTheme,B),document.body.setAttribute("frontend-theme",B)},re=O=>{const B=O.target.checked;o&&console.log("handleChangeHomePagePlugins called with value:",B),V(B),localStorage.setItem(te.homePagePlugins,B?"true":"false")},be=O=>{const B=O.target.value;o&&console.log("handleChangeHomePageMode called with value:",B),Q(B),localStorage.setItem(te.homePageMode,B)},Ie=O=>{const B=O.target.value;o&&console.log("handleChangeVirtualMode called with value:",B),h(B),localStorage.setItem(te.virtualMode,B),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:B}})};return!n||!d?null:e.jsxs(je,{style:{flex:`1 1 ${Ft}px`},children:[e.jsx(De,{children:e.jsx(Ce,{children:"Matterbridge settings"})}),e.jsx(Ci,{open:u,ip:d.ipv4Address,onClose:S,onSave:P}),e.jsx(wi,{open:H,onClose:v,onSave:c}),e.jsxs(Ne,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"matterbridgeInfo-mode",children:"Mode:"}),e.jsxs(yr,{row:!0,name:"mode-buttons-group",value:s,onChange:a,children:[e.jsx(Ye,{value:"bridge",control:e.jsx($t,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(Ye,{value:"childbridge",control:e.jsx($t,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(Je,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:g,onChange:x,children:[e.jsx(C,{value:"Debug",children:"Debug"}),e.jsx(C,{value:"Info",children:"Info"}),e.jsx(C,{value:"Notice",children:"Notice"}),e.jsx(C,{value:"Warn",children:"Warn"}),e.jsx(C,{value:"Error",children:"Error"}),e.jsx(C,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mblogger-file-label",children:"Log on file:"}),e.jsx(qe,{checked:t,onChange:k,id:"mblogger-file",name:"logOnFileMb"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-theme-label",children:"Frontend theme:"}),e.jsxs(Je,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:y,onChange:N,children:[e.jsx(C,{value:"classic",children:"Classic"}),e.jsx(C,{value:"light",children:"Light"}),e.jsx(C,{value:"dark",children:"Dark"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-home-plugin-label",children:"Home page plugins:"}),e.jsx(qe,{checked:j,onChange:re,name:"showPlugins"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"5px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-home-label",children:"Home page bottom panel:"}),e.jsxs(Je,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:q,onChange:be,children:[e.jsx(C,{value:"logs",children:"Logs"}),e.jsx(C,{value:"devices",children:"Devices"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"10px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"frontend-virtual-label",children:"Virtual devices:"}),e.jsxs(Je,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:A,onChange:Ie,children:[e.jsx(C,{value:"disabled",children:"Disabled"}),e.jsx(C,{value:"outlet",children:"Outlet"}),e.jsx(C,{value:"light",children:"Light"}),e.jsx(C,{value:"switch",children:"Switch"}),e.jsx(C,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>oe(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ae,{variant:"contained",color:"primary",onClick:()=>I(!0),children:"Configure IP"})})]})]})}function Ii({matterbridgeInfo:n}){const{sendMessage:d,getUniqueId:l}=r.useContext(xe),[i,s]=r.useState("Info"),[m,g]=r.useState(!1),[b,t]=r.useState(""),[W,y]=r.useState(""),[w,j]=r.useState(""),[V,q]=r.useState(""),[Q,A]=r.useState(""),[h,p]=r.useState(""),u=r.useRef(l()),I=r.useMemo(()=>nt(1e3),[]),S=r.useMemo(()=>nt(1e3),[]),P=r.useMemo(()=>nt(1e3),[]),H=r.useMemo(()=>nt(1e3),[]),oe=r.useMemo(()=>nt(1e3),[]),v=r.useMemo(()=>nt(1e3),[]);r.useEffect(()=>{n&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),g(n.matterFileLogger),t(n.matterMdnsInterface||""),y(n.matterIpv4Address||""),j(n.matterIpv6Address||""),q(n.matterPort?n.matterPort.toString():""),A(n.matterDiscriminator?n.matterDiscriminator.toString():""),p(n.matterPasscode?n.matterPasscode.toString():""))},[n]),r.useEffect(()=>()=>I.cancel(),[I]),r.useEffect(()=>()=>S.cancel(),[S]),r.useEffect(()=>()=>P.cancel(),[P]),r.useEffect(()=>()=>H.cancel(),[H]),r.useEffect(()=>()=>oe.cancel(),[oe]),r.useEffect(()=>()=>v.cancel(),[v]);const c=O=>{o&&console.log("handleChangeMjLoggerLevel called with value:",O.target.value),s(O.target.value),d({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:O.target.value}})},a=O=>{o&&console.log("handleLogOnFileMjChange called with value:",O.target.checked),g(O.target.checked),d({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:O.target.checked}})},x=O=>{o&&console.log("handleChangeMdnsInterface called with value:",O.target.value);const B=O.target.value;t(B),I(()=>{o&&console.log("debounced sendMessage setmdnsinterface with value:",B),d({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:B}})})},k=O=>{o&&console.log("handleChangeIpv4Address called with value:",O.target.value);const B=O.target.value;y(B),S(()=>{o&&console.log("debounced sendMessage setipv4address with value:",B),d({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:B}})})},N=O=>{o&&console.log("handleChangeIpv6Address called with value:",O.target.value);const B=O.target.value;j(B),P(()=>{o&&console.log("debounced sendMessage setipv6address with value:",B),d({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:B}})})},re=O=>{o&&console.log("handleChangeMatterPort called with value:",O.target.value);const B=O.target.value;q(B),H(()=>{o&&console.log("debounced sendMessage setmatterport with value:",B),d({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:B}})})},be=O=>{o&&console.log("handleChangeMatterDiscriminator called with value:",O.target.value);const B=O.target.value;A(B),oe(()=>{o&&console.log("debounced sendMessage setmatterdiscriminator with value:",B),d({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:B}})})},Ie=O=>{o&&console.log("handleChangemMatterPasscode called with value:",O.target.value);const B=O.target.value;p(B),v(()=>{o&&console.log("debounced sendMessage setmatterpasscode with value:",B),d({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:B}})})};return n?e.jsxs(je,{style:{flex:`1 1 ${Ft}px`},children:[e.jsx(De,{children:e.jsx(Ce,{children:"Matter settings"})}),e.jsxs(Ne,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mjlogger-level-label",children:"Logger level:"}),e.jsxs(Je,{style:{height:"30px"},labelId:"mjlogger-level-label",id:"mjlogger-level",value:i,onChange:c,children:[e.jsx(C,{value:"Debug",children:"Debug"}),e.jsx(C,{value:"Info",children:"Info"}),e.jsx(C,{value:"Notice",children:"Notice"}),e.jsx(C,{value:"Warn",children:"Warn"}),e.jsx(C,{value:"Error",children:"Error"}),e.jsx(C,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"10px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px"},id:"mjlogger-file-label",children:"Log on file:"}),e.jsx(qe,{checked:m,onChange:a,id:"mjlogger-file",name:"logOnFileMj"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(fe,{value:b,onChange:x,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(fe,{value:W,onChange:k,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(fe,{value:w,onChange:N,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(fe,{value:V,onChange:re,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(fe,{value:Q,onChange:be,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(ke,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(fe,{value:h,onChange:Ie,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})]}):null}function Mi({matterbridgeInfo:n}){return n?e.jsxs(je,{style:{flex:`1 1 ${Ft}px`},children:[e.jsx(De,{children:e.jsx(Ce,{children:"Matterbridge info"})}),e.jsxs(Ne,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Pe,{value:n.matterbridgeVersion,label:"Current Version"}),e.jsx(Pe,{value:n.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Pe,{value:n.rootDirectory,label:"Root Directory"}),e.jsx(Pe,{value:n.homeDirectory,label:"Home Directory"}),e.jsx(Pe,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Pe,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Pe,{value:n.globalModulesDirectory,label:"Global Module Directory"})]})]}):null}function Di({systemInfo:n}){return n?e.jsxs(je,{style:{flex:`1 1 ${Ft}px`},children:[e.jsx(De,{children:e.jsx(Ce,{children:"System info"})}),e.jsxs(Ne,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Pe,{value:n.interfaceName,label:"Interface name"}),e.jsx(Pe,{value:n.macAddress,label:"MAC Address"}),e.jsx(Pe,{value:n.ipv4Address,label:"IPv4 Address"}),e.jsx(Pe,{value:n.ipv6Address,label:"IPv6 Address"}),e.jsx(Pe,{value:n.nodeVersion,label:"Node Version"}),e.jsx(Pe,{value:n.hostname,label:"Hostname"}),e.jsx(Pe,{value:n.user,label:"User"})]})]}):null}function Pe({value:n,label:d,width:l}){return e.jsx(fe,{focused:!0,value:n,size:"small",label:d,variant:"standard",sx:{width:l?`${l-20}px`:"100%","& .MuiInput-underline:before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},inputLabel:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}}})}const Pi=r.memo(Si);function Li(){const{online:n,sendMessage:d,addListener:l,removeListener:i,getUniqueId:s}=r.useContext(xe),{showSnackbarMessage:m}=r.useContext(Le),[g,b]=r.useState(null),[t,W]=r.useState([]),[y,w]=r.useState([]),[j,V]=r.useState(null),[q,Q]=r.useState({cpuUsage:0}),[A,h]=r.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[p,u]=r.useState({systemUptime:"",processUptime:""}),I=r.useRef(s());return o&&console.log("Test uniqueId:",I),r.useEffect(()=>{o&&console.log("Test useEffect WebSocketMessage mounting");const S=P=>{if(P.method==="restart_required")o&&console.log("Test received restart_required"),m("Restart required",0);else if(P.method==="refresh_required")o&&console.log(`Test received refresh_required: changed=${P.response.changed} and sending api requests`),m("Refresh required",0),d({id:I.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:I.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),d({id:I.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(P.method==="memory_update")o&&console.log("Test received memory_update",P),h(P.response);else if(P.method==="cpu_update")o&&console.log("Test received cpu_update",P),Q(P.response);else if(P.method==="uptime_update")o&&console.log("Test received uptime_update",P),u(P.response);else if(P.method==="/api/settings"&&P.response)o&&console.log("Test received /api/settings:",P.response),m("Test received /api/settings",0),b(P.response);else if(P.method==="/api/plugins"&&P.response)o&&console.log(`Test received ${P.response.length} plugins:`,P.response),m("Test received /api/plugins",0),W(P.response);else if(P.method==="/api/devices"&&P.response){o&&console.log(`Test received ${P.response.length} devices:`,P.response),m("Test received /api/devices",0),w(P.response);for(const H of P.response)o&&console.log("Test sending /api/clusters for device:",H.pluginName,H.name,H.endpoint),d({id:I.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:H.pluginName,endpoint:H.endpoint||0}})}else P.method==="/api/clusters"&&P.response&&(o&&console.log(`Test received ${P.response.clusters.length} clusters for device ${P.response.deviceName} endpoint ${P.response.id}:${P.response.number}:`,P),m(`Test received /api/clusters for ${P.response.plugin}::${P.response.deviceName}`,0),V(P.response))};return l(S,I.current),o&&console.log("Test useEffect WebSocketMessage mounted"),()=>{o&&console.log("Test useEffect WebSocketMessage unmounting"),i(S),o&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,i,d,m]),r.useEffect(()=>(o&&console.log("Test useEffect online mounting"),n&&o&&console.log("Test useEffect online received online"),o&&console.log("Test useEffect online mounted"),()=>{o&&console.log("Test useEffect online unmounted")}),[n,d,m]),o&&console.log("Test rendering..."),n?e.jsx(ht,{name:"Test",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",gap:"20px",height:"100vh",width:"100vw"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"})]})}):e.jsx(_e,{})}const $i=r.memo(Li);function Wi(n,d){o&&console.log("getCssVariable:",n,"defaultValue",d);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||d}function Fi(n){return Po({palette:{primary:{main:n},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}function Ti(){const{mobile:n,showSnackbarMessage:d,showConfirmCancelDialog:l}=r.useContext(Le),{online:i,sendMessage:s,logMessage:m,addListener:g,removeListener:b,getUniqueId:t}=r.useContext(xe),[W,y]=r.useState(!1),[w,j]=r.useState(!1),[V,q]=r.useState(!1),[Q,A]=r.useState(!1),[h,p]=r.useState(null),u=r.useRef(t()),[I,S]=r.useState(null),[P,H]=r.useState(null),[oe,v]=r.useState(null),[c,a]=r.useState(null),[x,k]=r.useState(null),N=Or(),re=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},be=()=>{window.open("https://matterbridge.io/")},Ie=()=>{window.open("https://matterbridge.io/README.html")},O=()=>{window.open("https://matterbridge.io/CHANGELOG.html")},B=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},T=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},K=()=>{s({id:u.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}}),q(!1)},F=()=>{s({id:u.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}}),A(!1)},$=()=>{s({id:u.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},L=()=>{o&&console.log("Header: handleShellySystemUpdateClick"),m("Matterbridge","Installing system updates..."),s({id:u.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},M=()=>{o&&console.log("Header: handleShellyMainUpdateClick"),m("Matterbridge","Installing software updates..."),s({id:u.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},R=()=>{o&&console.log("Header: handleShellyCreateSystemLog"),s({id:u.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},Y=()=>{o&&console.log("Header: handleShellyDownloadSystemLog"),m("Matterbridge","Downloading Shelly system log..."),d("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},ue=()=>{h?.matterbridgeInformation.restartMode===""?s({id:u.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):s({id:u.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},de=()=>{s({id:u.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},J=()=>{s({id:u.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},f=()=>{s({id:u.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ce=()=>{s({id:u.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},Z=U=>{S(U.currentTarget)},D=U=>{o&&console.log("Header: handleMenuClose",U),S(null),U==="/"||U==="/devices"||U==="/log"||U==="/settings"?N(U):U==="reset_frontend"?(m("Matterbridge","Resetting frontend UI..."),d("Resetting frontend UI...",5),xn(),window.location.reload()):U==="download-mblog"?(m("Matterbridge","Downloading matterbridge log..."),d("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):U==="download-mjlog"?(m("Matterbridge","Downloading matter log..."),d("Downloading matter log...",5),window.location.href="./api/download-mjlog"):U==="view-mblog"?(m("Matterbridge","Loading matterbridge log..."),d("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):U==="view-mjlog"?(m("Matterbridge","Loading matter log..."),d("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):U==="view-diagnostic"?(m("Matterbridge","Loading diagnostic log..."),d("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):U==="download-diagnostic"?(m("Matterbridge","Downloading diagnostic log..."),d("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):U==="view-history"?s({id:u.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):U==="download-history"?s({id:u.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):U==="view-shellylog"?(m("Matterbridge","Loading shelly system log..."),d("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):U==="download-mbstorage"?(m("Matterbridge","Downloading matterbridge storage..."),d("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):U==="download-pluginstorage"?(m("Matterbridge","Downloading matterbridge plugins storage..."),d("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):U==="download-pluginconfig"?(m("Matterbridge","Downloading matterbridge plugins config..."),d("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):U==="download-mjstorage"?(m("Matterbridge","Downloading matter storage..."),d("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):U==="download-backup"?(m("Matterbridge","Downloading backup..."),d("Downloading backup...",10),window.location.href="./api/download-backup"):U==="update"?K():U==="updatedev"?F():U==="updatecheck"?$():U==="shelly-sys-update"?L():U==="shelly-main-update"?M():U==="shelly-create-system-log"?R():U==="shelly-download-system-log"?Y():U==="softreset"?f():U==="hardreset"?ce():U==="restart"?ue():U==="shutdown"?de():U==="reboot"?J():U==="create-backup"?s({id:u.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):U==="unregister"?s({id:u.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):U==="reset"?s({id:u.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):U==="factoryreset"&&s({id:u.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},ye=U=>{o&&console.log("Header: handleMenuCloseCancel:",U),S(null)},Re=U=>{H(U.currentTarget)},ve=()=>{H(null)},ne=U=>{v(U.currentTarget)},pe=()=>{v(null)},He=U=>{a(U.currentTarget)},Me=()=>{a(null)},ct=U=>{k(U.currentTarget)},E=()=>{k(null)},we=()=>{Ri(),o&&console.log("Matterbridge logo clicked: debug is now",o)};return r.useEffect(()=>{const U=ie=>{o&&console.log("Header received WebSocket Message:",ie),ie.method==="/api/settings"&&ie.id===u.current?(o&&console.log("Header received settings:",ie.response),p(ie.response),y(ie.response.matterbridgeInformation.restartRequired||ie.response.matterbridgeInformation.fixedRestartRequired),j(ie.response.matterbridgeInformation.fixedRestartRequired),q(ie.response.matterbridgeInformation.updateRequired)):ie.method==="refresh_required"&&ie.response.changed==="settings"?(o&&console.log(`Header received refresh_required: changed=${ie.response.changed} and sending /api/settings request`),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):ie.method==="restart_required"?(o&&console.log(`Header received restart_required with fixed: ${ie.response.fixed}`),y(!0),ie.response.fixed===!0&&j(!0)):ie.method==="restart_not_required"?(o&&console.log("Header received restart_not_required"),y(!1)):ie.method==="update_required"?(o&&console.log("Header received update_required"),ie.response.devVersion===!0?A(!0):q(!0),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):ie.method==="shelly_sys_update"?(o&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),p($e=>$e?{matterbridgeInformation:{...$e.matterbridgeInformation,shellySysUpdate:ie.response.available},systemInformation:$e.systemInformation}:null)):ie.method==="shelly_main_update"?(o&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),p($e=>$e?{matterbridgeInformation:{...$e.matterbridgeInformation,shellyMainUpdate:ie.response.available},systemInformation:$e.systemInformation}:null)):ie.method==="/api/viewhistorypage"&&ie.id===u.current&&ie.success===!0?(o&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):ie.method==="/api/downloadhistorypage"&&ie.id===u.current&&ie.success===!0&&(o&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return g(U,u.current),o&&console.log(`Header added WebSocket listener id ${u.current}`),()=>{b(U),o&&console.log("Header removed WebSocket listener")}},[g,b,s,d]),r.useEffect(()=>{i&&(o&&console.log("Header sending /api/settings and /api/checkupdates requests"),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:u.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,s]),o&&console.log("Header rendering... mobile %s",n),!i||!h?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",width:"100%",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:we}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:e.jsxs("nav",{children:[e.jsx(ft,{to:"/",className:"nav-link",children:"Home"}),e.jsx(ft,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(ft,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(ft,{to:"/settings",className:"nav-link",children:"Settings"})]})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[!h.matterbridgeInformation.readOnly&&e.jsx(_,{title:`Matterbridge v.${h.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",h.matterbridgeInformation.matterbridgeVersion.split("-")[0]+(h.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")+(h.matterbridgeInformation.matterbridgeVersion.includes("-git-")?"@git":"")]})}),h.matterbridgeInformation.shellyBoard&&e.jsx("img",{src:"Shelly.svg",alt:"Shelly Icon",style:{height:"30px",padding:"0px",margin:"0px",marginRight:"30px"}}),h.matterbridgeInformation.bridgeMode!==""&&h.matterbridgeInformation.readOnly===!1?e.jsx(_,{title:"Bridge mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:h.matterbridgeInformation.bridgeMode})}):null,h.matterbridgeInformation.restartMode!==""&&h.matterbridgeInformation.readOnly===!1?e.jsx(_,{title:"Restart mode",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:h.matterbridgeInformation.restartMode})}):null,h.matterbridgeInformation.profile&&h.matterbridgeInformation.profile!==""&&h.matterbridgeInformation.readOnly===!1?e.jsx(_,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:h.matterbridgeInformation.profile})}):null,o&&e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:[n?"Mobile ":"Desktop ",`${Pt}x${Lt}`,` enabled ${localStorage.getItem(te.enableMobile)!=="false"}`]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"5px"},children:[h.matterbridgeInformation.readOnly===!1?e.jsx(_,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:B})}):null,h.matterbridgeInformation.readOnly===!1?e.jsx(_,{title:"Give a star to Matterbridge",children:e.jsx(G,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:T,children:e.jsx(br,{})})}):null,h.matterbridgeInformation.readOnly===!1?e.jsx(_,{title:"Sponsor Matterbridge",children:e.jsx(G,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:re,children:e.jsx(At,{})})}):null,e.jsx(_,{title:"Matterbridge homepage",children:e.jsx(G,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:be,children:e.jsx(Lo,{})})}),e.jsx(_,{title:"Matterbridge help",children:e.jsx(G,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:Ie,children:e.jsx(hr,{})})}),e.jsx(_,{title:"Matterbridge changelog",children:e.jsx(G,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:O,children:e.jsx(Et,{})})}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&V&&e.jsx(_,{title:`Update matterbridge to latest version v.${h.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:K,children:e.jsx(Oe,{})})}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&Q&&e.jsx(_,{title:`Update matterbridge to latest dev version v.${h.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(G,{style:{color:"var(--secondary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:F,children:e.jsx(Oe,{})})}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellySysUpdate&&e.jsx(_,{title:"Shelly system update",children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:L,children:e.jsx(Oe,{})})}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellyMainUpdate&&e.jsx(_,{title:"Shelly software update",children:e.jsx(G,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:M,children:e.jsx(Oe,{})})}),e.jsx(_,{title:"Restart matterbridge",children:e.jsx(G,{style:{color:W||w?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:ue,children:e.jsx(Dt,{})})}),h.matterbridgeInformation.restartMode===""?e.jsx(_,{title:"Shut down matterbridge",children:e.jsx(G,{style:{color:W||w?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:de,children:e.jsx(Be,{})})}):null,e.jsx(_,{title:"Download, backup and more",children:e.jsx(G,{onClick:Z,children:e.jsx($o,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(st,{id:"command-menu",anchorEl:I,keepMounted:!0,open:!!I,onClose:()=>D(""),children:[he&&n&&e.jsxs(C,{onClick:()=>D("/"),children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Home page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),he&&n&&e.jsxs(C,{onClick:()=>D("/devices"),children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Devices page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),he&&n&&e.jsxs(C,{onClick:()=>D("/log"),children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Logs page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),he&&n&&e.jsxs(C,{onClick:()=>D("/settings"),children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Settings page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&e.jsxs(C,{onClick:()=>D("update"),children:[e.jsx(z,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&e.jsxs(C,{onClick:()=>D("updatedev"),children:[e.jsx(z,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&!h.matterbridgeInformation.readOnly&&e.jsxs(C,{onClick:()=>D("updatecheck"),children:[e.jsx(z,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellySysUpdate&&e.jsxs(C,{onClick:()=>D("shelly-sys-update"),children:[e.jsx(z,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&h.matterbridgeInformation.shellyMainUpdate&&e.jsxs(C,{onClick:()=>D("shelly-main-update"),children:[e.jsx(z,{children:e.jsx(Oe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>D("restart"),children:[e.jsx(z,{children:e.jsx(Dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation.restartMode===""?e.jsxs(C,{onClick:()=>D("shutdown"),children:[e.jsx(z,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",D,ye)},children:[e.jsx(z,{children:e.jsx(Dt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(jt,{}),e.jsxs(C,{onClick:ne,children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(st,{id:"sub-menu-view",anchorEl:oe,keepMounted:!0,open:!!oe,onClose:pe,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(C,{onClick:()=>{Hi(),pe(),ye(""),window.open("/home","_self")},children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Desktop site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{_i(),pe(),ye(""),window.open("/home","_self")},children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Mobile site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("view-mblog"),pe()},children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("view-mjlog"),pe()},children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("view-diagnostic"),pe()},children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("view-history"),pe()},children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{D("view-shellylog"),pe()},children:[e.jsx(z,{children:e.jsx(Fe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(jt,{}),e.jsxs(C,{onClick:He,children:[e.jsx(z,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(st,{id:"sub-menu-download",anchorEl:c,keepMounted:!0,open:!!c,onClose:Me,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(C,{onClick:()=>{D("download-mbstorage"),Me()},children:[e.jsx(z,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-pluginstorage"),Me()},children:[e.jsx(z,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-pluginconfig"),Me()},children:[e.jsx(z,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-mblog"),Me()},children:[e.jsx(z,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-mjstorage"),Me()},children:[e.jsx(z,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-mjlog"),Me()},children:[e.jsx(z,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-diagnostic"),Me()},children:[e.jsx(z,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-history"),Me()},children:[e.jsx(z,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{D("shelly-create-system-log"),Me()},children:[e.jsx(z,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{D("shelly-download-system-log"),Me()},children:[e.jsx(z,{children:e.jsx(Te,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(jt,{}),e.jsxs(C,{onClick:Re,children:[e.jsx(z,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(st,{id:"sub-menu-backup",anchorEl:P,keepMounted:!0,open:!!P,onClose:ve,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(C,{onClick:()=>{D("create-backup"),ve()},children:[e.jsx(z,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{D("download-backup"),ve()},children:[e.jsx(z,{children:e.jsx(Nt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(jt,{}),e.jsxs(C,{onClick:ct,children:[e.jsx(z,{children:e.jsx(Wo,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(st,{id:"sub-menu-reset",anchorEl:x,keepMounted:!0,open:!!x,onClose:E,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(C,{onClick:()=>{E(),l("Reset the frontend UI","Are you sure you want to reset the frontend UI? This will reset all local settings and reload the page.","reset_frontend",D,ye)},children:[e.jsx(z,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset the frontend UI...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{E(),l("Reset all devices and shutdown","Are you sure you want to unregister all devices? This will temporarily remove all devices from the controller and you may loose the controller configuration.","unregister",D,ye)},children:[e.jsx(z,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(C,{onClick:()=>{E(),l("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",D,ye)},children:[e.jsx(z,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!h.matterbridgeInformation.readOnly&&e.jsxs(C,{onClick:()=>{E(),l("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",D,ye)},children:[e.jsx(z,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{E(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",D,ye)},children:[e.jsx(z,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),h.matterbridgeInformation&&h.matterbridgeInformation.shellyBoard&&e.jsxs(C,{onClick:()=>{E(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",D,ye)},children:[e.jsx(z,{children:e.jsx(Be,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ee,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const dr=r.memo(Ti),kr=1200,Ir=900;let Pt,Lt;function pr(){if(typeof window<"u"){Pt=Math.floor(window.visualViewport?.width??window.innerWidth),Lt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=Pt<kr||Lt<Ir;return o&&console.log("Visual viewport (%s) width %i height %i mobile %s",window.visualViewport!==void 0,Pt,Lt,n),n}return!1}function Ni({children:n}){const{mobile:d,setMobile:l}=r.useContext(Le),{logAutoScroll:i}=r.useContext(xe);return r.useEffect(()=>{function s(){const m=pr();m&&(i.current=!1,localStorage.setItem(te.logAutoScroll,"false")),l(m)}return window.addEventListener("resize",s),l(pr()),()=>window.removeEventListener("resize",s)},[i,l]),o&&console.log("MbfScreen rendering... mobile %s",d),he&&d?e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"visible",margin:"0px",padding:"10px",gap:"10px"},children:[e.jsx(dr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"10px"},children:n})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:d?`${kr}px`:"calc(100vw - 40px)",height:d?`${Ir}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(dr,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let o=!1;const Ri=()=>{o=!o},Oi=!1;let he=localStorage.getItem(te.enableMobile)!=="false";const _i=()=>{he=!0,localStorage.setItem(te.enableMobile,"true")},Hi=()=>{he=!1,localStorage.setItem(te.enableMobile,"false")};let at;const Vi=n=>{at=n};let mt=!1,ur="/",it="/",Ht="/";function Ei({setLoggedIn:n}){const[d,l]=r.useState(""),[i,s]=r.useState(""),m={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)"},b={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},t=async y=>{try{const w=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:y})});if(w.ok){const{valid:j}=await w.json();j?(n(!0),y!==""&&(at=y)):y!==""&&s("Incorrect password!")}else console.error("Failed to log in:",w.statusText)}catch(w){console.error("Failed to log in:",w)}},W=y=>{y.preventDefault(),t(d)};return t(""),e.jsx("div",{style:m,children:e.jsxs("form",{onSubmit:W,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:"32px",width:"32px"}}),e.jsx("h3",{style:{color:"var(--div-text-color)"},children:"Welcome to Matterbridge"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:"20px"},children:[e.jsx("input",{type:"text",name:"username",autoComplete:"username",style:{display:"none"},tabIndex:-1}),e.jsx("input",{type:"password",value:d,onChange:y=>l(y.target.value),style:b,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 Ai(){const[n,d]=r.useState(!1),l=localStorage.getItem(te.frontendTheme)||"dark";o&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const i=Wi("--primary-color","#1976d2");o&&console.log('Primary color from CSS "%s"',i);const s=Fi(i);return ur=window.location.href,it=window.location.pathname,Ht=it.includes("/matterbridge/")?"/matterbridge/":it.includes("/api/hassio_ingress/")?it:"/",mt=it.includes("/api/hassio_ingress/"),console.log("Loading App..."),console.log(`- href = "${ur}"`),console.log(`- pathname = "${it}"`),console.log(`- baseName = "${Ht}"`),console.log(`- isIngress = "${mt}"`),n?e.jsx(Fo,{theme:s,children:e.jsx(zr,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(vn,{children:e.jsx(yn,{children:e.jsx(_r,{basename:Ht,children:e.jsx(Ni,{children:e.jsxs(Hr,{children:[e.jsx(Xe,{path:"/",element:e.jsx(Zn,{})}),e.jsx(Xe,{path:"/devices",element:e.jsx(vi,{})}),e.jsx(Xe,{path:"/log",element:e.jsx(ji,{})}),e.jsx(Xe,{path:"/settings",element:e.jsx(Pi,{})}),e.jsx(Xe,{path:"/test",element:e.jsx($i,{})}),e.jsx(Xe,{path:"*",element:e.jsx(Vr,{to:"/"})})]})})})})})})}):e.jsx(Ei,{setLoggedIn:d})}Er.createRoot(document.getElementById("root")).render(e.jsx(Ar.StrictMode,{children:e.jsx(Ai,{})}));
|
|
1
|
+
import{j as e,r as o,U as qo,V as Pt,X as Bo,Y as Qo,Z as ct,$ as Go,a0 as Ko,F as Jo}from"./vendor_node_modules.js";import{u as Yo,S as Zo}from"./vendor_notistack.js";import{D as qe,a as Be,b as Qe,B as ge,c as Ye,F as st,C as Ze,d as he,A as Xo,I as X,e as er,f as tr,T as E,g as or,H as Do,h as no,i as Bt,j as Ce,M as rr,k as Ae,l as Po,m as nr,n as At,o as R,p as ye,K as lo,q as ao,r as oo,L as Lt,s as yt,t as $t,u as K,W as Ct,v as Wt,w as Tt,x as ie,V as co,y as po,z as ir,E as sr,Q as Lo,R as Vt,S as lr,U as ar,P as cr,G as ze,J as io,N as $o,O as rt,X as Wo,Y as dr,Z as To,_ as pr,$ as ur,a0 as gr,a1 as uo,a2 as hr,a3 as mr,a4 as fr,a5 as xr,a6 as br,a7 as vr,a8 as yr,a9 as go,aa as jr,ab as wr,ac as Cr,ad as Sr,ae as kr,af as Ir,ag as Mr,ah as Dr,ai as Pr,aj as Lr,ak as $r,al as Wr,am as Tr,an as Fr,ao as Nr,ap as Kt,aq as nt,ar as Fo,as as We,at as No,au as qt,av as et,aw as Rr,ax as Xe,ay as Or,az as jt,aA as Ee,aB as Ft,aC as Jt,aD as _r,aE as Hr}from"./vendor_mui.js";import{I as be,m as Er,a as ho,b as Ar,c as Vr,d as mo,e as Ur,f as zr,g as qr,h as Br,i as Qr,j as Gr,k as Kr,l as Jr,n as Yr,o as Zr,p as Xr,q as en,r as fo,s as tn,t as on,u as rn,v as nn,w as sn,x as ln,y as an,z as cn,A as xo,B as dn,C as pn}from"./vendor_mdi.js";import{Q as un}from"./vendor_qrcode.js";import{F as gn,v as hn,e as mn,a as fn,g as xn,b as bn,c as vn,d as Yt,A as yn}from"./vendor_rjsf.js";import"./vendor_emotion.js";import"./vendor_lodash.js";(function(){const a=document.createElement("link").relList;if(a&&a.supports&&a.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const g of s)if(g.type==="childList")for(const h of g.addedNodes)h.tagName==="LINK"&&h.rel==="modulepreload"&&i(h)}).observe(document,{childList:!0,subtree:!0});function l(s){const g={};return s.integrity&&(g.integrity=s.integrity),s.referrerPolicy&&(g.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?g.credentials="include":s.crossOrigin==="anonymous"?g.credentials="omit":g.credentials="same-origin",g}function i(s){if(s.ep)return;s.ep=!0;const g=l(s);fetch(s.href,g)}})();function jn({open:n,title:a,message:l,onConfirm:i,onCancel:s}){const g=x=>{r&&console.log("Confirmed"),x.preventDefault(),i()},h=x=>{r&&console.log("Canceled"),x.preventDefault(),s()};return e.jsxs(qe,{open:n,children:[e.jsx(Be,{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:a})]})}),e.jsxs(Qe,{children:[e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center",margin:"0",marginBottom:"20px",maxHeight:"350px",maxWidth:"350px"},children:e.jsx("p",{style:{flex:1,margin:"0"},children:l})}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"space-around"},children:[e.jsx(ge,{onClick:g,variant:"contained",color:"primary",size:"small",children:"Confirm"}),e.jsx(ge,{onClick:h,variant:"contained",color:"primary",size:"small",children:"Cancel"})]})]})]})}const je="",oe={enableMobile:`${je}enableMobile`,devicesFilter:`${je}devicesFilter`,devicesViewMode:`${je}devicesViewMode`,frontendVersion:`${je}frontendVersion`,matterbridgeVersion:`${je}matterbridgeVersion`,homePageMode:`${je}homePageMode`,logFilterLevel:`${je}logFilterLevel`,logFilterSearch:`${je}logFilterSearch`,logAutoScroll:`${je}logAutoScroll`,logLength:`${je}logLength`,frontendTheme:`${je}frontendTheme`,homePagePlugins:`${je}homePagePlugins`,virtualMode:`${je}virtualMode`,installAutoExit:`${je}installAutoExit`,searchPluginsTotal:`${je}searchPluginsTotal`,searchPluginsMeta:`${je}searchPluginsMeta`},wn={Devices_table_order_by:`${je}Devices_table_order_by`,Devices_table_order:`${je}Devices_table_order`,Devices_column_visibility:`${je}Devices_column_visibility`,Plugins_table_order_by:`${je}Plugins_table_order_by`,Plugins_table_order:`${je}Plugins_table_order`,Plugins_column_visibility:`${je}Plugins_column_visibility`,"Registered devices_table_order_by":`${je}Registered devices_table_order_by`,"Registered devices_table_order":`${je}Registered devices_table_order`,"Registered devices_column_visibility":`${je}Registered devices_column_visibility`,Clusters_table_order_by:`${je}Clusters_table_order_by`,Clusters_table_order:`${je}Clusters_table_order`,Clusters_column_visibility:`${je}Clusters_column_visibility`};function Cn(){Object.values(oe).forEach(n=>{localStorage.removeItem(n)}),Object.values(wn).forEach(n=>{localStorage.removeItem(n)})}const Sn=({open:n,output:a,title:l,_command:i,_packageName:s,onInstall:g,onClose:h})=>{const{installAutoExit:x,setInstallAutoExit:t}=o.useContext(Re),$=o.useRef(null),k=P=>{t(P.target.checked),localStorage.setItem(oe.installAutoExit,P.target.checked?"true":"false"),r&&console.log("handleInstallAutoExitChange called with value:",P.target.checked)};return o.useEffect(()=>{r&&console.log(`InstallProgressDialog output effect mounted, scrolling to bottom: ${$.current}`),setTimeout(()=>{r&&console.log("Scrolling to bottom:",$.current),$.current?.scrollIntoView({behavior:"smooth",block:"end"})},0)},[a]),e.jsxs(qe,{open:n,onClose:(P,S)=>{S==="backdropClick"||S==="escapeKeyDown"||h()},slotProps:{paper:{sx:{width:"70vw",maxWidth:"70vw",height:"70vw",maxHeight:"70vh",overflow:"hidden"}}},children:[e.jsx(Be,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:l})]})}),e.jsxs(Qe,{dividers:!0,style:{overflow:"hidden",display:"flex",flexDirection:"column",height:400,paddingBottom:0},children:[e.jsx("label",{style:{display:"block",marginBottom:"10px",fontSize:"16px",fontWeight:"bold",color:"var(--primary-color)"},children:"Process log"}),e.jsxs("ul",{style:{width:"100%",height:"100%",fontFamily:"monospace",fontSize:"14px",padding:"10px",margin:0,marginBottom:"10px",color:"var(--div-text-color)",background:"var(--div-bg-color)",overflow:"auto",listStyle:"none",boxSizing:"border-box",borderRadius:4,border:"4px solid var(--primary-color)",whiteSpace:"pre-wrap",display:"block"},children:[a.split(`
|
|
2
|
+
`).map((P,S)=>e.jsx("li",{style:{padding:0,margin:0,wordBreak:"break-all"},children:P},S)),e.jsx("li",{ref:$,style:{padding:0,margin:0}})]})]}),e.jsxs(Ye,{sx:{justifyContent:"space-evenly"},children:[g&&e.jsx(ge,{variant:"contained",onClick:g,children:"Install"}),e.jsx(ge,{onClick:h,children:"Close"}),e.jsx(st,{control:e.jsx(Ze,{checked:x,onChange:P=>k(P)}),label:"Close on success",style:{color:"var(--div-text-color)"}})]})]})},Nt=[],Re=o.createContext(null);function kn({children:n}){const[a,l]=o.useState(!1),[i,s]=o.useState(null),{enqueueSnackbar:g,closeSnackbar:h}=Yo(),x=o.useCallback(T=>{r&&console.log(`UiProvider closeSnackbarMessage: message ${T}`);const w=Nt.findIndex(D=>D.message===T);w!==-1&&(h(Nt[w].key),Nt.splice(w,1),r&&console.log(`UiProvider closeSnackbarMessage: message ${T} removed from persistMessages`))},[h]),t=o.useCallback((T,w,D)=>{r&&console.log(`UiProvider showSnackbarMessage: message ${T} timeout ${w}`);const A=g(T,{variant:"default",autoHideDuration:w==null||w>0?(w??5)*1e3:null,persist:w===0,content:Q=>e.jsx(he,{sx:{margin:"0",padding:"0",width:"300px",marginRight:"30px"},children:e.jsx(Xo,{severity:D??"info",variant:"filled",sx:{color:"#fff",fontWeight:"normal",width:"100%",cursor:"pointer",padding:"0px 10px"},onClick:()=>h(Q),action:e.jsx(X,{size:"small",onClick:()=>h(Q),sx:{color:"#fff"},children:e.jsx(er,{fontSize:"small"})}),children:T},Q)},Q)});w===0&&(r&&console.log(`UiProvider showSnackbarMessage: message ${T} timeout ${w} - persist key ${A}`),Nt.push({message:T,key:A}))},[g,h]),[$,k]=o.useState(!1),[P,S]=o.useState(""),[z,q]=o.useState(""),[Y,U]=o.useState(""),f=o.useRef(null),p=o.useRef(null),u=()=>{r&&console.log(`UiProvider handle confirm action ${Y}`),k(!1),f.current&&f.current(Y)},M=()=>{r&&console.log(`UiProvider handle cancel action ${Y}`),k(!1),p.current&&p.current(Y)},I=o.useCallback((T,w,D,A,Q)=>{r&&console.log(`UiProvider showConfirmCancelDialog for command ${D}`),S(T),q(w),U(D),f.current=A,p.current=Q,k(!0)},[]),[W,te]=o.useState(!1),[le,j]=o.useState(""),[d,c]=o.useState(""),[v,C]=o.useState(""),[b,B]=o.useState(""),[ee,Me]=o.useState(localStorage.getItem(oe.installAutoExit)!=="false"),F=o.useCallback((T,w,D)=>{r&&console.log(`UiProvider show install progress for package ${T}`),j(T),c(w),C(D),te(!0)},[]),V=o.useCallback(T=>{r&&console.log(`UiProvider addInstallProgress: output ${T}`),B(w=>w+T+`
|
|
3
|
+
`)},[]),O=o.useCallback(()=>{r&&console.log(`UiProvider exitInstallProgressSuccess: package ${v}`),localStorage.getItem(oe.installAutoExit)!=="false"&&te(!1)},[v]),H=o.useCallback(()=>{r&&console.log(`UiProvider exitInstallProgressError: package ${v}`)},[v]),L=o.useCallback(()=>{r&&console.log("UiProvider hide install progress"),te(!1)},[]),pe=()=>{r&&console.log("UiProvider handle install close action"),te(!1),C(""),B("")},Se=o.useMemo(()=>({mobile:a,setMobile:l,currentPage:i,setCurrentPage:s,showSnackbarMessage:t,closeSnackbarMessage:x,closeSnackbar:h,showConfirmCancelDialog:I,showInstallProgress:F,exitInstallProgressSuccess:O,exitInstallProgressError:H,hideInstallProgress:L,addInstallProgress:V,installAutoExit:ee,setInstallAutoExit:Me}),[a,i,l,s,t,x,h,I,F,O,H,L,V,ee,Me]);return e.jsxs(Re.Provider,{value:Se,children:[e.jsx(jn,{open:$,title:P,message:z,onConfirm:u,onCancel:M}),e.jsx(Sn,{open:W,title:le,_command:d,_packageName:v,output:b,onClose:pe}),n]})}const Ro=o.createContext(null),ke=o.createContext(null);function In({children:n}){const[a,l]=o.useState([]),[i,s]=o.useState(localStorage.getItem(oe.logFilterLevel)??"info"),[g,h]=o.useState(localStorage.getItem(oe.logFilterSearch)??"*"),[x,t]=o.useState(!1),{showSnackbarMessage:$,closeSnackbarMessage:k,closeSnackbar:P,showInstallProgress:S,hideInstallProgress:z,exitInstallProgressSuccess:q,exitInstallProgressError:Y,addInstallProgress:U}=o.useContext(Re),f=o.useRef([]),p=o.useRef(null),u=o.useRef(1),M=o.useRef(Math.floor(Math.random()*999e3)+1e3),I=o.useRef(null),W=o.useRef(null),te=o.useRef(null),le=o.useRef(i),j=o.useRef(g),d=o.useRef(0),c=o.useRef(null),v=o.useRef(Number(localStorage.getItem(oe.logLength)??200)),C=o.useRef(localStorage.getItem(oe.logAutoScroll)!=="false"),b=o.useMemo(()=>window.location.href.replace(/^http/,"ws"),[]),B=100,ee=60,Me=50,F=300,V=10;o.useEffect(()=>(r&&console.log("WebSocket messages started counter interval"),c.current=setInterval(()=>{d.current>0&&(r&&console.log(`WebSocket messages received in the last ${V} seconds: ${d.current*(60/V)} messages/minute`),d.current=0)},V*1e3),()=>{r&&console.log("WebSocket messages stopped counter interval"),c.current&&clearInterval(c.current),c.current=null}),[]),o.useEffect(()=>{le.current=i},[i]),o.useEffect(()=>{j.current=g},[g]);const O=o.useCallback(()=>Math.floor(Math.random()*999e3)+1e3,[]),H=o.useCallback((J,m)=>{r&&console.log(`WebSocket filterLogMessages called with level "${J}" and search "${m}"...`),l(ce=>ce.filter(G=>!(["debug","info","notice","warn","error","fatal"].includes(G.level)&&(J==="info"&&G.level==="debug"||J==="notice"&&(G.level==="debug"||G.level==="info")||J==="warn"&&(G.level==="debug"||G.level==="info"||G.level==="notice")||J==="error"&&(G.level==="debug"||G.level==="info"||G.level==="notice"||G.level==="warn")||J==="fatal"&&(G.level==="debug"||G.level==="info"||G.level==="notice"||G.level==="warn"||G.level==="error"))||m!=="*"&&m!==""&&!m.startsWith("/")&&!m.endsWith("/")&&!G.message.toLowerCase().includes(m.toLowerCase())&&!G.name.toLowerCase().includes(m.toLowerCase())||m.startsWith("/")&&m.endsWith("/")&&(()=>{try{const N=new RegExp(m.slice(1,-1),"i");return!N.test(G.message)&&!N.test(G.name)}catch(N){return console.error(`WebSocket log search invalid regex filter "${m}":`,N),!1}})())))},[]),L=o.useCallback(J=>{if(p.current&&p.current.readyState===WebSocket.OPEN)try{r&&console.log(`WebSocket sending message with id ${J.id}:`,J),J.id===void 0&&(J.id=M.current);const m=JSON.stringify(J);p.current.send(m),r&&console.log("WebSocket sent message:",J)}catch(m){r&&console.error(`WebSocket error sending message: ${m}`)}else r&&console.error("WebSocket message not sent, WebSocket not connected:",J)},[]),pe=o.useCallback((J,m)=>{l(ce=>[...ce,{level:J,time:"",name:"",message:m}])},[]),Se=o.useCallback((J,m)=>{r&&console.log(`WebSocket addListener id ${m}:`,J),(m==null||isNaN(m)||m===0)&&console.error("WebSocket addListener called without id, listener not added:",J),f.current=[...f.current,{listener:J,id:m}],r&&console.log("WebSocket addListener total listeners:",f.current.length)},[]),T=o.useCallback(J=>{r&&console.log("WebSocket removeListener:",J),f.current=f.current.filter(m=>m.listener!==J),r&&console.log("WebSocket removeListener total listeners:",f.current.length)},[]),w=o.useCallback(()=>{b===""||b===null||b===void 0||(pe("WebSocket",`Connecting ${xt?"with password":""} to WebSocket: ${b}`),r&&console.log(`WebSocket connecting to: ${b}${xt?"?password=[redacted]":""}`),p.current=new WebSocket(b+(xt?`?password=${encodeURIComponent(xt)}`:"")),p.current.onmessage=J=>{x||t(!0),d.current+=1;try{const m=JSON.parse(J.data);if(m.id===void 0||m.src===void 0||m.dst===void 0){r&&console.error("WebSocket undefined message id/src/dst:",m);return}if(m.src!=="Matterbridge"||m.dst!=="Frontend"){r&&console.error("WebSocket invalid message src/dst:",m);return}if(m.error){r&&console.error("WebSocket error message response:",m);return}if(m.id===M.current&&m.method==="pong"&&m.response==="pong"){r&&console.log(`WebSocket pong response message id ${m.id}:`,m),W.current&&clearTimeout(W.current),W.current=null;return}else if(m.method==="snackbar"&&m.response&&m.response.message){r&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),$(m.response.message,m.response.timeout,m.response.severity);return}else if(m.method==="close_snackbar"&&m.response&&m.response.message){r&&console.log(`WebSocket message id ${m.id} method ${m.method}:`,m),k(m.response.message);return}else if(m.method==="log"){if(!m.response||!m.response.level||!m.response.time||!m.response.name||!m.response.message||(m.response.level==="spawn"&&(m.response.name==="Matterbridge:spawn-init"?S(m.response.message,"",""):m.response.name==="Matterbridge:spawn-exit-success"?q():m.response.name==="Matterbridge:spawn-exit-error"?Y():U(m.response.message+`
|
|
4
|
+
`)),["debug","info","notice","warn","error","fatal"].includes(m.response.level)&&(le.current==="info"&&m.response.level==="debug"||le.current==="notice"&&(m.response.level==="debug"||m.response.level==="info")||le.current==="warn"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice")||le.current==="error"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn")||le.current==="fatal"&&(m.response.level==="debug"||m.response.level==="info"||m.response.level==="notice"||m.response.level==="warn"||m.response.level==="error")))||j.current!=="*"&&j.current!==""&&!j.current.startsWith("/")&&!j.current.endsWith("/")&&!m.response.message.toLowerCase().includes(j.current.toLowerCase())&&!m.response.name.toLowerCase().includes(j.current.toLowerCase())||j.current.startsWith("/")&&j.current.endsWith("/")&&(()=>{try{const G=new RegExp(j.current.slice(1,-1),"i");return!G.test(m.response.message)&&!G.test(m.response.name)}catch(G){return console.error(`WebSocket log search invalid regex filter "${j.current}":`,G),!1}})()||m.response.name==="Commissioning"&&m.response.message.includes("is uncommissioned"))return;l(G=>{const N=[...G,{level:m.response.level,time:m.response.time,name:m.response.name,message:m.response.message}];return r&&console.log(`WebSocket new log message added (${N.length}/${v.current}):`,N[N.length-1]),N.length>v.current+v.current*10/100?(r&&console.log(`WebSocket sliced log messages to the last ${v.current} entries`),N.slice(N.length-v.current)):N})}else{if(r&&console.log(`WebSocket received message id ${m.id} method ${m.method}:`,m),m.id===0)f.current.forEach(ce=>ce.listener(m));else{const ce=f.current.find(G=>G.id===m.id);ce?ce.listener(m):console.warn(`WebSocket no listener found for message id ${m.id}:`,m)}return}}catch(m){console.error(`WebSocket error parsing message: ${m}`,m instanceof Error?m.stack:null)}},p.current.onopen=()=>{r&&console.log(`WebSocket: Connected to WebSocket: ${b}`),pe("WebSocket",`Connected to WebSocket: ${b}`),t(!0),P(),u.current=1,te.current=setTimeout(()=>{I.current=setInterval(()=>{L({id:M.current,method:"ping",src:"Frontend",dst:"Matterbridge",params:{}}),W.current&&clearTimeout(W.current),W.current=setTimeout(()=>{r&&console.error(`WebSocketUse: No pong response received from WebSocket: ${b}`),pe("WebSocket",`No pong response received from WebSocket: ${b}`),t(!1)},1e3*Me)},1e3*ee)},1e3*F)},p.current.onclose=()=>{r&&console.error(`WebSocket: Disconnected from WebSocket ${kt?"with Ingress":""}: ${b}`),pe("WebSocket",`Disconnected from WebSocket: ${b}`),t(!1),P(),z(),te.current&&clearTimeout(te.current),W.current&&clearTimeout(W.current),I.current&&clearInterval(I.current),pe("WebSocket",`Reconnecting (attempt ${u.current} of ${B}) to WebSocket${kt?" (Ingress)":""}: ${b}`),kt?setTimeout(D,5e3):u.current===1?D():u.current<B?setTimeout(D,1e3*u.current):pe("WebSocket",`Reconnect attempts exceeded limit of ${B} retries, refresh the page to reconnect to: ${b}`),u.current=u.current+1},p.current.onerror=J=>{r&&console.error(`WebSocket: WebSocket error connecting to ${b}:`,J),pe("WebSocket",`WebSocket error connecting to ${b}`)})},[b]),D=o.useCallback(()=>{r&&console.log(`WebSocket attemptReconnect ${u.current}/${B} to:`,b),w()},[w]);o.useEffect(()=>(w(),()=>{p.current&&p.current.readyState===WebSocket.OPEN&&p.current.close()}),[w]);const A=o.useMemo(()=>({messages:a,logLength:v,logAutoScroll:C,logFilterLevel:i,logFilterSearch:g,setMessages:l,setLogFilterLevel:s,setLogFilterSearch:h,filterLogMessages:H}),[a,v,C,i,g,l,s,h,H]),Q=o.useMemo(()=>({logLength:v,logAutoScroll:C,logFilterLevel:i,logFilterSearch:g,setMessages:l,setLogFilterLevel:s,setLogFilterSearch:h,filterLogMessages:H,online:x,retry:u.current,getUniqueId:O,addListener:Se,removeListener:T,sendMessage:L,logMessage:pe}),[v,C,l,s,h,x,u.current,Se,T,L,pe]);return e.jsx(Ro.Provider,{value:A,children:e.jsx(ke.Provider,{value:Q,children:n})})}function Mn(n){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 296.2 296.2",...n,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"lg1",x1:"16.6",y1:"16.6",x2:"279.6",y2:"279.6",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".1",stopColor:"#3faa77"}),e.jsx("stop",{offset:".3",stopColor:"#234148"}),e.jsx("stop",{offset:".7",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#ad2e6e"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg2",x1:"31.1",y1:"31.1",x2:"265.1",y2:"265.1",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#00b48d"}),e.jsx("stop",{offset:".2",stopColor:"#285251"}),e.jsx("stop",{offset:".4",stopColor:"#234148"}),e.jsx("stop",{offset:".8",stopColor:"#203b44"}),e.jsx("stop",{offset:".9",stopColor:"#a8316c"}),e.jsx("stop",{offset:"1",stopColor:"#c81b74"})]}),e.jsxs("linearGradient",{id:"lg3",x1:"116.2",y1:"143.9",x2:"139.8",y2:"143.9",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#8bc751"}),e.jsx("stop",{offset:"1",stopColor:"#0db14b"})]}),e.jsx("linearGradient",{id:"lg4",x1:"136.1",y1:"100.8",x2:"159.6",y2:"100.8",xlinkHref:"#lg3"}),e.jsx("linearGradient",{id:"lg5",x1:"155.3",y1:"143.9",x2:"178.9",y2:"143.9",xlinkHref:"#lg3"}),e.jsxs("linearGradient",{id:"lg6",x1:"46.8",y1:"25.7",x2:"89.6",y2:"74.8",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:"0",stopColor:"#b1d34a"}),e.jsx("stop",{offset:"1",stopColor:"#50b848"})]})]}),e.jsx("rect",{width:"296.2",height:"296.2",rx:"56.7",ry:"56.7",style:{fill:"url(#lg1)"}}),e.jsx("rect",{x:"16.3",y:"16.3",width:"263.6",height:"263.6",rx:"50.5",ry:"50.5",style:{fill:"url(#lg2)"}}),e.jsx("circle",{cx:"128",cy:"143.9",r:"11.8",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"147.8",cy:"100.8",r:"11.8",style:{fill:"url(#lg4)"}}),e.jsx("path",{d:"m244.6 114.5.4-.5L160 33a17 17 0 0 0-24.7-.5l-86.4 83.3a15 15 0 0 0 9.2 26.9h19.3v-4.7l-13.7-12.7v-.1l83.7-80.8 84.2 81-13.9 12.8v4.5h19.5a15 15 0 0 0 7.4-28.1Z",style:{fill:"url(#lg3)"}}),e.jsx("circle",{cx:"167.1",cy:"143.9",r:"11.8",style:{fill:"url(#lg5)"}}),e.jsx("path",{fill:"#fff",d:"M219 89.3V35.5a10.5 10.5 0 1 0-21 0v33.7l21 20Z"}),e.jsx("path",{d:"M91.4 73.3H83a37 37 0 0 0-14.5-28.4L65 50.2c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.8-7.8-16-23.7-11.9-46 8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2Z",style:{fill:"url(#lg6)"}}),e.jsx("path",{d:"M65.9 80a49.6 49.6 0 0 0 17.8 2.2l16.6-16c1.6-8.3.5-15.7-3.3-22.4C84.6 22 47.8 17.5 46.2 17.4l-3-.4-.6 3c-3.8 18.4-5.9 50.6 23.2 60ZM48.4 24.4c8.7 1.5 34 7 43 22.8 4.1 7.3 4.1 16.1 0 26.2H83a37 37 0 0 0-14.5-28.4l-3.7 5.3c.1 0 12.6 9 11.7 25.4-5.3-.4-11.2-1.9-16.3-5.3-11.9-7.8-16-23.7-11.9-46Z",fill:"#1e5857"}),e.jsx("path",{fill:"#fff",d:"M250.5 90.5a17.4 17.4 0 1 1 0-34.8 17.4 17.4 0 0 1 0 34.8Zm0-22.7a5.4 5.4 0 0 0 0 10.7 5.3 5.3 0 0 0 0-10.7ZM258.8 148.2a15.9 15.9 0 0 0-9.6 28.5c-.8 4.2-5.4 4.6-5.4 4.6h-26v-43l13.6-13-1.8-2-82.2-79-81.2 78.3-2.5 2.6 13.7 13v42.9H53a21.5 21.5 0 1 0 11.7 15h12.6v18.8c0 7.8 6.4 14.1 14.1 14.1h29.3v14.8H64a10.6 10.6 0 0 0-17.7 8 10.6 10.6 0 0 0 17.6 8h157.6a16.3 16.3 0 1 0 0-16h-84.8V229h66.8c7.8 0 14.2-6.3 14.2-14.1v-19.2h27.6c14.3 0 17.8-12.8 18.5-16.6a15.9 15.9 0 0 0-5-30.9ZM43.7 210.8a10.3 10.3 0 1 1 0-20.6 10.3 10.3 0 0 1 0 20.6Zm192 36a5 5 0 1 1 0 10 5 5 0 0 1 0-10Zm-77-34.8h-22v-34h22v34Zm8.4-79.8c2.7 0 5.2 1 7.2 2.5v-10.4L188 137s2.6 1.3 4.6 1.3h6.7v68c0 3.2-2.6 5.7-5.7 5.7h-19v-34h1.4a7.5 7.5 0 0 0 0-15H120a7.5 7.5 0 0 0 0 15h.7v34h-19.3a5.7 5.7 0 0 1-5.7-5.6v-68.1h6.7c2 0 4.6-1.3 4.6-1.3l13.7-12.7v10.4a11.7 11.7 0 0 1 16 1.6v-13a14.9 14.9 0 0 0-25-10.8s-.1.2-.1.2l-.5.5-6.9 7H92.5l55-53.2 55.1 53.2h-11.8l-7-7c0-.2-.2-.3-.4-.5l-.2-.2a14.8 14.8 0 0 0-25 10.9v12.9c2.2-2.5 5.3-4.1 8.9-4.1Zm91.7 36.7a4.9 4.9 0 1 1 0-9.7 4.9 4.9 0 0 1 0 9.7Z"})]})}function Ge(){const{retry:n}=o.useContext(ke),a=()=>{window.location.reload()};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100vw",height:"100vh",justifyContent:"center",alignItems:"center",fontSize:"20px",color:"var(--main-text-color)",backgroundColor:"var(--main-bg-color)"},children:[e.jsx(Mn,{style:{height:"128px",width:"128px",margin:"10px",marginBottom:"20px"}}),n<100?e.jsxs(e.Fragment,{children:[e.jsx(tr,{style:{color:"var(--primary-color)"}}),e.jsx("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:e.jsxs("span",{children:["Reconnecting to Matterbridge ","(attempt "+n+")","..."]})})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginTop:"20px",color:"var(--primary-color)",textAlign:"center"},children:[e.jsx("span",{children:"Unable to connect to Matterbridge after multiple attempts."}),e.jsx("br",{}),e.jsx("span",{children:"Please check your network connection."}),e.jsx("br",{})]}),e.jsx(ge,{variant:"contained",color:"primary",onClick:a,style:{marginTop:"20px"},children:"Refresh the Page"})]})]})}function Oo({value:n,maxChars:a}){let l=n;if(n.length>a&&a>3){const i=a-3,s=n.substring(0,Math.ceil(i/2)),g=n.substring(n.length-Math.floor(i/2),n.length);l=`${s} … ${g}`}return n!==l?e.jsx(E,{title:n,placement:"top",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[0,12]}}]}},children:e.jsx("span",{children:l})}):e.jsx("span",{children:l})}function Ie({children:n,style:a}){const l={display:"flex",flexDirection:"column",flex:"0 0 auto",width:"100%",overflow:"hidden",margin:"0px",padding:"0px",gap:"0px",backgroundColor:"var(--div-bg-color)",boxShadow:"5px 5px 10px var(--div-shadow-color)",border:"1px solid var(--table-border-color)",borderRadius:"var(--div-border-radius)",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...a},children:n})}function Te({children:n,style:a}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",borderBottom:"1px solid var(--table-border-color)",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...a},children:n})}function Pe({children:n,style:a}){const l={color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",fontSize:"16px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...a},children:n})}function St({children:n,style:a}){const l={display:"flex",flexDirection:"row",justifyContent:"space-between",width:"100%",height:"30px",color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",margin:"0px",padding:"0px",boxSizing:"border-box"};return e.jsx("div",{style:{...l,...a},children:n})}function ft({children:n,style:a}){const l={color:"var(--footer-text-color)",backgroundColor:"var(--footer-bg-color)",fontSize:"14px",fontWeight:"bold",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...a},children:n})}function wt({children:n,style:a}){const l={color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",fontSize:"14px",fontWeight:"normal",margin:"0px",padding:"5px 10px"};return e.jsx("div",{style:{...l,...a},children:n})}function Ve({children:n,style:a,onDragOver:l,onDragLeave:i,onDrop:s}){const g={flex:"0 0 auto",display:"flex",flexDirection:"row",overflow:"hidden",alignItems:"start",justifyContent:"space-between",margin:"0px",padding:"10px",gap:"20px"};return e.jsx("div",{style:{...g,...a},onDragOver:l,onDragLeave:i,onDrop:s,children:n})}function it({children:n,style:a,close:l}){const i={display:"flex",flexDirection:"row",margin:"0px",padding:"0px",paddingRight:"10px",gap:"10px"};return e.jsxs("div",{style:{...i,...a},children:[n,Ji]})}function Dn({systemInfo:n,compact:a}){const{mobile:l}=o.useContext(Re),{addListener:i,removeListener:s,getUniqueId:g,sendMessage:h}=o.useContext(ke),[x,t]=o.useState(n),$=o.useRef(g());if(r&&console.log("SystemInfoTable loading with systemInfo:",x,"compact:",a),n&&a&&x.totalMemory&&x.freeMemory){const f=x.totalMemory,p=x.freeMemory;x.freeMemory=`${p} / ${f}`,x.totalMemory=""}if(n&&a&&x.heapTotal&&x.heapUsed){const f=x.heapTotal,p=x.heapUsed;x.heapUsed=`${p} / ${f}`,x.heapTotal=""}if(n&&a&&x.osRelease&&x.osType){const f=x.osType,p=x.osRelease;x.osType=`${f} (${p})`,x.osRelease=""}if(n&&a&&x.osArch&&x.osPlatform){const f=x.osPlatform,p=x.osArch;x.osPlatform=`${f} (${p})`,x.osArch=""}const k=(f,p,u,M,I)=>{t(W=>({...W,totalMemory:f,freeMemory:p,heapTotal:u,heapUsed:M,rss:I}))},P=f=>{t(p=>({...p,cpuUsage:f.toFixed(2)+" %"}))},S=f=>{t(p=>({...p,processCpuUsage:f.toFixed(2)+" %"}))},z=(f,p)=>{t(u=>({...u,systemUptime:f,processUptime:p}))},q=()=>{r&&console.log("SystemInfoTable handleViewHistory clicked"),h({id:$.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}})};o.useEffect(()=>{const f=p=>{r&&console.log("SystemInfoTable received WebSocket Message:",p),p.method==="memory_update"&&p.response&&p.response.totalMemory&&p.response.freeMemory&&p.response.heapTotal&&p.response.heapUsed&&p.response.rss?(r&&console.log("SystemInfoTable received memory_update",p),k(p.response.totalMemory,p.response.freeMemory,p.response.heapTotal,p.response.heapUsed,p.response.rss)):p.method==="cpu_update"&&p.response&&p.response.cpuUsage?(r&&console.log("SystemInfoTable received cpu_update",p),P(p.response.cpuUsage),S(p.response.processCpuUsage)):p.method==="uptime_update"&&p.response&&p.response.systemUptime&&p.response.processUptime?(r&&console.log("SystemInfoTable received uptime_update",p),z(p.response.systemUptime,p.response.processUptime)):p.method==="/api/viewhistorypage"&&p.id===$.current&&p.success===!0&&(r&&console.log("SystemInfoTable received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer"))};return i(f,$.current),r&&console.log(`SystemInfoTable added WebSocket listener id ${$.current}`),()=>{s(f),r&&console.log("SystemInfoTable removed WebSocket listener")}},[i,s]);const[Y,U]=o.useState(!1);return!x||Y?null:(r&&console.log("SystemInfoTable rendering..."),e.jsxs(Ie,{style:we&&l?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Te,{children:[e.jsx(Pe,{children:"System info"}),e.jsx(it,{close:()=>U(!0),children:e.jsx(X,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:q,children:e.jsx(E,{title:"Open the cpu and memory usage page",arrow:!0,children:e.jsx(be,{path:Er,size:"22px"})})})})]}),e.jsx(Ve,{style:we&&l?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(x).filter(([f,p])=>p!==void 0&&p!=="").map(([f,p],u)=>e.jsxs("tr",{className:u%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:f.replace("interfaceName","Interface name").replace("macAddress","Mac address").replace("ipv4Address","IPv4 address").replace("ipv6Address","IPv6 address").replace("nodeVersion","Node version").replace("hostname","Hostname").replace("user","User").replace("osType","Os").replace("osPlatform","Platform").replace("freeMemory","Memory").replace("systemUptime","System uptime").replace("processUptime","Process uptime").replace("cpuUsage","Host CPU").replace("processCpuUsage","Process CPU").replace("rss","Rss").replace("heapUsed","Heap")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:we&&l?typeof p!="string"?p.toString():p:e.jsx(Oo,{value:typeof p!="string"?p.toString():p,maxChars:22})})]},f))})]})})]}))}const bo=o.memo(Dn),vo={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"}},Pn=n=>{if(!n)return"";const a=n.toString().replace(/[^0-9]/g,"");if(a.length<5)return a;const l=a.slice(0,4),i=a.slice(4,7),s=a.slice(7,11);return[l,i,s].filter(Boolean).join("-")};function Ln({id:n}){const{online:a,sendMessage:l,addListener:i,removeListener:s,getUniqueId:g}=o.useContext(ke),[h,x]=o.useState(null),t=o.useRef(null),$=o.useRef(null),k=o.useRef(g()),{mobile:P,showConfirmCancelDialog:S}=o.useContext(Re);r&&console.log(`QRDiv loading with id = "${n}" storeId = "${t.current}" timeout = ${$.current} and matter:`,h),o.useEffect(()=>{r&&console.log(`QRDiv id effect "${n}"`),t.current=n,$.current&&clearTimeout($.current),$.current=null,n?(r&&console.log(`QRDiv id effect sending data request for storeId "${n}"`),l({id:k.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:n,server:!0}})):(r&&console.log("QRDiv id effect setting matter to null"),x(null))},[n,l]),o.useEffect(()=>{const p=u=>{r&&console.log("QRDiv received WebSocket Message:",u),u.method==="refresh_required"&&u.response.changed==="matter"&&u.response.matter&&(r&&console.log(`QRDiv received refresh_required: changed=${u.response.changed} for storeId "${u.response.matter.id}":`,u.response.matter),t.current===u.response.matter.id&&(r&&console.log(`QRDiv received refresh_required/matter: setting matter data for storeId "${u.response.matter.id}":`,u.response.matter),$.current&&clearTimeout($.current),u.response.matter.advertising&&u.response.matter.advertiseTime&&u.response.matter.advertiseTime+9e5<=Date.now()&&(u.response.matter.advertising=!1),x(u.response.matter),u.response.matter.advertising&&(r&&console.log(`QRDiv setting matter advertise timeout for storeId "${u.response.matter.id}":`,u.response.matter.advertiseTime+9e5-Date.now()),$.current=setTimeout(()=>{$.current&&clearTimeout($.current),r&&console.log(`QRDiv clearing advertising state for storeId "${t.current}" after 15 minutes`),x(M=>M&&{...M,advertising:!1})},u.response.matter.advertiseTime+9e5-Date.now()))))};return i(p,k.current),r&&console.log("QRDiv webSocket effect mounted"),()=>{s(p),$.current&&clearTimeout($.current),$.current=null,r&&console.log("QRDiv webSocket effect unmounted")}},[i,s]);const z=()=>{r&&console.log(`QRDiv sent matter startCommission for node "${h?.id}"`),h&&l({id:k.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,startCommission:!0}})},q=()=>{r&&console.log(`QRDiv sent matter stopCommission for node "${h?.id}"`),h&&l({id:k.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,stopCommission:!0}})},Y=()=>{r&&console.log(`QRDiv sent matter advertise for node "${h?.id}"`),h&&l({id:k.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,advertise:!0}})},U=p=>{r&&console.log(`QRDiv sent matter removeFabric for node "${h?.id}" and fabricIndex ${p}`),h&&l({id:k.current,sender:"QRDiv",method:"/api/matter",src:"Frontend",dst:"Matterbridge",params:{id:h.id,removeFabric:p}})},f=async()=>{if(!h||!h.manualPairingCode)return;const p=h.manualPairingCode.toString();try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(p);else{const u=document.createElement("textarea");u.value=p,u.style.position="fixed",u.style.opacity="0",document.body.appendChild(u),u.focus(),u.select(),document.execCommand("copy"),document.body.removeChild(u)}r&&console.log("Manual pairing code copied to clipboard")}catch(u){console.error("Failed to copy manual pairing code",u)}};return!h||!a?(r&&console.log("QRDiv rendering undefined state"),null):h.online?h.advertising&&h.qrPairingCode&&h.manualPairingCode?(r&&console.log("QRDiv rendering advertising state"),e.jsxs(Ie,{style:we&&P?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsxs(Te,{children:[e.jsx(Pe,{children:"QR pairing code"}),e.jsxs(it,{children:[e.jsx(X,{"aria-label":"send advertising",size:"small",onClick:Y,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(be,{path:ho,size:"22px"})})}),e.jsx(X,{"aria-label":"stop pairing",size:"small",onClick:q,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Turn off pairing",arrow:!0,children:e.jsx(be,{path:Ar,size:"22px"})})})]})]}),e.jsx(wt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(un,{value:h.qrPairingCode,size:256,level:"M",fgColor:"var(--div-text-color)",bgColor:"var(--div-bg-color)",style:{margin:"20px"}}),e.jsxs(St,{style:{justifyContent:"space-between"},children:[e.jsxs(ft,{style:{fontWeight:"normal",color:"var(--div-text-color)"},children:["Manual pairing code: ",Pn(h.manualPairingCode)]}),e.jsx(it,{children:e.jsx(E,{title:"Copy manual pairing code",arrow:!0,children:e.jsx(X,{"aria-label":"copy manual pairing code",size:"small",onClick:f,sx:vo,children:e.jsx(be,{path:Vr,size:.85})})})})]})]})):h.commissioned&&h.fabricInformations&&h.sessionInformations?(r&&console.log("QRDiv rendering commissioned state"),e.jsxs(Ie,{style:we&&P?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px",overflow:"hidden"},children:[e.jsxs(Te,{children:[e.jsx(Pe,{children:"Paired fabrics"}),e.jsxs(it,{children:[e.jsx(X,{"aria-label":"send advertising",size:"small",onClick:Y,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Send again the mDNS advertisement",arrow:!0,children:e.jsx(be,{path:ho,size:"22px"})})}),e.jsx(X,{"aria-label":"start pairing",size:"small",onClick:z,sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},children:e.jsx(E,{title:"Turn on pairing",arrow:!0,children:e.jsx(be,{path:mo,size:"22px"})})})]})]}),e.jsx(wt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(Ve,{style:{flexDirection:"column",justifyContent:"flex-start",flex:"1 1 auto",overflow:"auto",padding:"0px 0px 10px 0px",gap:"0px"},children:h.fabricInformations.map((p,u)=>e.jsxs("div",{style:{margin:"0px",padding:"10px",gap:"0px",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",textAlign:"left",fontSize:"14px"},children:[e.jsxs("div",{style:{marginLeft:"20px",marginBottom:"10px",display:"flex",flexDirection:"row",justifyContent:"space-between",gap:"20px",alignItems:"center"},children:[e.jsxs("p",{className:"status-blue",style:{margin:"0px",padding:"3px 10px",width:"200px",fontSize:"14px",color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},children:["Fabric: ",p.fabricIndex]}),e.jsx(E,{title:"Remove the fabric. You will also need to remove it from the controller.",arrow:!0,children:e.jsx(X,{"aria-label":"remove the fabric",size:"small",onClick:()=>S("Remove fabric","Are you sure you want to remove this fabric? You will also need to remove it from the controller.","RemoveFabric",()=>U(p.fabricIndex),()=>{}),sx:{...vo,padding:"2px"},children:e.jsx(be,{path:Ur,size:1})})})]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Vendor: ",p.rootVendorId," ",p.rootVendorName]}),p.label!==""&&e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Label: ",p.label]}),e.jsxs("p",{style:{margin:"0px 20px 0px 20px",color:"var(--div-text-color)"},children:["Sessions: ",h.sessionInformations?h.sessionInformations.filter(M=>M.fabric?.fabricIndex===p.fabricIndex&&M.isPeerActive===!0).length:"0"," ","subscriptions: ",h.sessionInformations?h.sessionInformations.filter(M=>M.fabric?.fabricIndex===p.fabricIndex&&M.isPeerActive===!0&&M.numberOfActiveSubscriptions>0).length:"0"]})]},u))}),e.jsx(St,{style:{justifyContent:"center"},children:e.jsxs(ft,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]})):!h.commissioned&&!h.advertising?(r&&console.log("QRDiv rendering not commissioned and not advertising state"),e.jsxs(Ie,{style:we&&P?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(Te,{children:e.jsx(Pe,{children:"QR pairing code"})}),e.jsx(wt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(ge,{onClick:z,endIcon:e.jsx(be,{path:mo,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(St,{style:{justifyContent:"center"},children:e.jsxs(ft,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]})):(r&&console.log("QRDiv rendering unknown state"),null):(r&&console.log("QRDiv rendering offline state"),e.jsxs(Ie,{style:we&&P?{flex:"1 1 300px",alignItems:"center"}:{alignItems:"center",width:"302px",minWidth:"302px"},children:[e.jsx(Te,{style:{height:"30px",justifyContent:"space-between"},children:e.jsx(Pe,{children:"Server node"})}),e.jsx(wt,{style:{maxWidth:"280px",fontWeight:"bold",color:"var(--secondary-color)"},children:t.current}),e.jsx(wt,{style:{fontWeight:"bold"},children:"Server offline"}),e.jsx(St,{style:{justifyContent:"center"},children:e.jsxs(ft,{style:{fontWeight:"normal"},children:["Serial number: ",h.serialNumber]})})]}))}const yo=o.memo(Ln);function $n({title:n,children:a}){const l=o.useRef(null),[i,s]=o.useState(!1),g=()=>{const t=l.current;if(!t){s(!1);return}s(t.scrollWidth>t.clientWidth)},h=()=>{s(!1)},x={display:"inline-block",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};return e.jsx(E,{title:n,open:i,disableHoverListener:!0,disableFocusListener:!0,disableTouchListener:!0,slotProps:{tooltip:{sx:{fontSize:"14px",fontWeight:"normal",color:"#ffffff",backgroundColor:"var(--primary-color)"}}},children:e.jsx("span",{ref:l,onMouseEnter:g,onMouseLeave:h,style:x,children:a})})}function Wn(n,a,l){const i=n?.[l],s=a?.[l];return i==null&&s==null?0:i==null?-1:s==null?1:typeof i=="boolean"&&typeof s=="boolean"?i===s?0:i?1:-1:typeof i=="number"&&typeof s=="number"?i-s:String(i).localeCompare(String(s))}function Tn({name:n,title:a,columns:l,rows:i,getRowKey:s,footerLeft:g,footerRight:h,onRowClick:x}){const t=o.useRef(new WeakMap),$=o.useRef(1),k=c=>{if(typeof s=="string"&&c&&c[s]!=null)return c[s];if(typeof s=="function"){const b=s(c);if(b!=null)return b}const v=l?.[0]?.id;if(v&&c&&c[v]!=null)return c[v];console.warn(`MbfTable(${n}): using fallback stable row key; consider providing getRowKey prop for better React performance`);let C=t.current.get(c);return C||(C=`rk_${$.current++}`,t.current.set(c,C)),C},[P,S]=o.useState(localStorage.getItem(`${n}_table_order_by`)||null),[z,q]=o.useState(localStorage.getItem(`${n}_table_order`)||null),[Y,U]=o.useState(!1),[f,p]=o.useState(()=>{try{const c=localStorage.getItem(`${n}_column_visibility`);if(c)return JSON.parse(c)}catch{}return{}}),u=o.useMemo(()=>{const c={};for(const v of l)v.hidden||(c[v.id]=v.required?!0:f[v.id]!==!1);return c},[l,f]),M=o.useMemo(()=>{if(!P||!z)return i;const c=l.find(C=>C.id===P);if(!c||c.noSort)return i;const v=i.map((C,b)=>({el:C,index:b}));return v.sort((C,b)=>{let B;return typeof c.comparator=="function"?B=c.comparator(C.el,b.el):B=Wn(C.el,b.el,P),B!==0?z==="asc"?B:-B:C.index-b.index}),v.map(C=>C.el)},[i,P,z,l]),I=c=>{if(P!==c||!P){S(c),q("asc"),localStorage.setItem(`${n}_table_order_by`,c),localStorage.setItem(`${n}_table_order`,"asc");return}if(z==="asc"){q("desc"),localStorage.setItem(`${n}_table_order`,"desc");return}S(null),q(null),localStorage.removeItem(`${n}_table_order_by`),localStorage.removeItem(`${n}_table_order`)},W=()=>{U(!Y)},te=c=>{p(v=>{const C=l.find(ee=>ee.id===c);if(C&&C.required)return v;const b=u[c]!==!1,B={...v};b?B[c]=!1:delete B[c];try{localStorage.setItem(`${n}_column_visibility`,JSON.stringify(B))}catch{}return B})},le=()=>{p({});try{localStorage.removeItem(`${n}_column_visibility`)}catch{}U(!1)},[j,d]=o.useState(!1);return j?null:(r&&console.log(`Rendering table ${n}${P&&z?` ordered by ${P}:${z}`:""}`),e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",margin:"0",padding:"0",gap:"0",width:"100%",height:"100%",overflow:"hidden"},children:[e.jsxs(qe,{open:Y,onClose:(c,v)=>{v==="backdropClick"||v==="escapeKeyDown"||W()},disableEscapeKeyDown:!0,disableRestoreFocus:!0,children:[e.jsx(Be,{gap:"20px",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"20px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"32px",width:"32px"}}),e.jsx("h4",{style:{margin:0},children:`Configure ${n} columns`})]})}),e.jsx(Qe,{children:e.jsx(or,{children:l.filter(c=>!c.hidden).map(c=>e.jsx(st,{control:e.jsx(Ze,{disabled:!!c.required,checked:c.required?!0:u[c.id]!==!1,onChange:()=>te(c.id)}),label:c.label},c.id))})}),e.jsxs(Ye,{children:[e.jsx(ge,{onClick:le,children:"Reset"}),e.jsx(ge,{variant:"contained",onClick:c=>{if(c?.currentTarget&&typeof c.currentTarget.blur=="function")try{c.currentTarget.blur()}catch{}const v=document.activeElement;if(v&&v instanceof HTMLElement&&typeof v.blur=="function")try{v.blur()}catch{}W()},children:"Close"})]})]}),e.jsxs(Te,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",borderBottom:"none"},children:[e.jsx(Pe,{children:n}),a&&e.jsx(Pe,{children:a}),e.jsx(it,{close:()=>d(!0),children:e.jsx(X,{size:"small",sx:{color:"var(--header-text-color)",margin:"0px",padding:"0px"},onClick:c=>{if(c?.currentTarget?.blur)try{c.currentTarget.blur()}catch{}W()},"aria-label":"Configure Columns",children:e.jsx(E,{title:`Configure ${n} columns`,children:e.jsx(be,{path:zr,size:"20px",color:"var(--header-text-color)"})})})})]}),e.jsx(Ve,{style:{flex:"1 1 auto",display:"flex",flexDirection:"column",minHeight:0,width:"100%",overflow:"auto",margin:"0px",padding:"0px",gap:"0"},children:e.jsxs("table",{"aria-label":`${n} table`,style:{width:"100%",borderCollapse:"collapse"},children:[e.jsx("thead",{style:{position:"sticky",top:0,zIndex:10,border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color"},children:e.jsx("tr",{style:{height:"30px",minHeight:"30px"},children:l.map(c=>{if(c.hidden||!c.required&&u[c.id]===!1)return null;const v=!c.noSort,C=v&&P===c.id&&!!z;return e.jsxs("th",{onClick:v?()=>I(c.id):void 0,style:{margin:"0",padding:"5px 10px",position:"sticky",top:0,minWidth:c.minWidth,maxWidth:c.maxWidth,textAlign:c.align||"left",cursor:v?"pointer":"default",border:"none",color:"var(--header-text-color)",backgroundColor:"var(--header-bg-color)",whiteSpace:c.maxWidth?"nowrap":void 0,overflow:c.maxWidth?"hidden":void 0,textOverflow:c.maxWidth?"ellipsis":void 0},"aria-sort":v?C?z==="asc"?"ascending":"descending":"none":void 0,children:[c.label,C&&e.jsxs("span",{style:{marginLeft:6},children:[z==="asc"&&e.jsx(be,{path:qr,size:"15px"}),z==="desc"&&e.jsx(be,{path:Br,size:"15px"})]})]},c.id)})})}),e.jsx("tbody",{children:M.map((c,v)=>{const C=k(c);return e.jsx("tr",{className:v%2===0?"table-content-even":"table-content-odd",onClick:x?b=>x(c,C,b):void 0,style:{height:"30px",minHeight:"30px",border:"none",borderCollapse:"collapse",cursor:x?"pointer":void 0},children:l.map(b=>{if(b.hidden||!b.required&&u[b.id]===!1)return null;const B=c[b.id],ee=typeof b.render=="function"?b.render(B,C,c,b):typeof B=="boolean"?e.jsx(Ze,{checked:B,disabled:!0,size:"small",sx:{m:0,p:0,color:"var(--table-text-color)","&.Mui-disabled":{color:"var(--table-text-color)",opacity:.7}}}):b.format&&typeof B=="number"?b.format(B):B!=null?String(B):null,F=!!b.tooltip&&b.maxWidth!==void 0&&b.maxWidth!==null&&B!==void 0&&B!==null&&ee!==null?e.jsx($n,{title:String(B),children:ee}):ee;return e.jsx("td",{style:{border:"none",borderCollapse:"collapse",textAlign:b.align||"left",padding:"5px 10px",margin:"0",maxWidth:b.maxWidth,whiteSpace:b.maxWidth?"nowrap":void 0,overflow:b.maxWidth?"hidden":void 0,textOverflow:b.maxWidth?"ellipsis":void 0},children:F},b.id)})},C)})})]})}),(g||h)&&e.jsxs(St,{style:{height:"30px",minHeight:"30px",justifyContent:"space-between",border:"none"},children:[e.jsx(ft,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:g}),e.jsx(ft,{style:{fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)"},children:h})]})]}))}function Fn(n){return o.memo(n)}const It=Fn(Tn),_o=n=>n.replace("git+","").replace(".git","").trim(),Nn=n=>{let a=_o(n);return a.startsWith("git://")&&(a=`https://${a.slice(6)}`),a.startsWith("ssh://git@github.com/")&&(a=`https://github.com/${a.slice(21)}`),a.startsWith("git@github.com:")&&(a=`https://github.com/${a.slice(15).replace(":","/")}`),a},Rn=n=>{if(typeof n=="string")return n.trim()||null;if(!n||typeof n!="object")return null;const a=n.url;return typeof a=="string"&&a.trim()||null},On=()=>{try{const n=window.localStorage.getItem(oe.searchPluginsTotal);if(!n)return{};const a=JSON.parse(n);if(!a||typeof a!="object")return{};const l={};for(const[i,s]of Object.entries(a)){if(!i||!s||typeof s!="object")continue;const g=s;typeof g.total=="number"&&typeof g.asOf=="string"&&(l[i]={total:g.total,asOf:g.asOf})}return l}catch{return{}}},_n=n=>{try{window.localStorage.setItem(oe.searchPluginsTotal,JSON.stringify(n))}catch{}},Hn=()=>{try{const n=window.localStorage.getItem(oe.searchPluginsMeta);if(!n)return{};const a=JSON.parse(n);if(!a||typeof a!="object")return{};const l={};for(const[i,s]of Object.entries(a)){if(!i||!s||typeof s!="object")continue;const g=s;if(typeof g.asOf!="string")continue;const h=typeof g.homepage=="string"?g.homepage:null,x=typeof g.help=="string"?g.help:null,t=typeof g.changelog=="string"?g.changelog:null;l[i]={homepage:h,help:x,changelog:t,asOf:g.asOf}}return l}catch{return{}}},En=n=>{try{window.localStorage.setItem(oe.searchPluginsMeta,JSON.stringify(n))}catch{}},An=({open:n,onClose:a,onSelect:l,onInstall:i,onAdd:s})=>{const[g,h]=o.useState(""),x=o.useRef(""),t=o.useRef(!1),[$,k]=o.useState([]),[P,S]=o.useState(!1),[z,q]=o.useState(!1),[Y,U]=o.useState({done:0,total:0}),[f,p]=o.useState(null),u=()=>{const b=document.activeElement;b&&b instanceof HTMLElement&&b.blur()},M=b=>new Intl.NumberFormat().format(b),I=[{label:"Name",id:"name",required:!0,maxWidth:230,tooltip:!0},{label:"Version",id:"version",required:!0,maxWidth:110,tooltip:!0},{label:"Monthly",id:"downloads",align:"right",maxWidth:120,render:b=>typeof b=="number"?M(b):""},{label:"Total",id:"total",align:"right",maxWidth:120,render:b=>typeof b=="number"?M(b):"",noSort:!0},{label:"Description",id:"description",required:!0,maxWidth:300,tooltip:!0},{label:"Author",id:"author",maxWidth:140,tooltip:!0},{label:"Action",id:"action",align:"center",maxWidth:100,noSort:!0,required:!0,render:(b,B,ee,Me)=>e.jsxs("div",{style:{margin:"0",padding:"0",gap:"4px",display:"flex",flexDirection:"row",justifyContent:"center"},children:[e.jsx(E,{title:ee.homepage?"Open the plugin homepage":"No homepage available",children:e.jsx("span",{children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!ee.homepage,onClick:F=>{if(F.stopPropagation(),!!ee.homepage)try{const V=new URL(ee.homepage);(V.protocol==="http:"||V.protocol==="https:")&&window.open(V.toString(),"_blank")}catch{}},size:"small",children:e.jsx(Do,{})})})}),e.jsx(E,{title:ee.help?"Open the plugin help":"No help available",children:e.jsx("span",{children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!ee.help,onClick:F=>{if(F.stopPropagation(),!!ee.help)try{const V=new URL(ee.help);(V.protocol==="http:"||V.protocol==="https:")&&window.open(V.toString(),"_blank")}catch{}},size:"small",children:e.jsx(no,{})})})}),e.jsx(E,{title:ee.changelog?"Open the plugin changelog":"No changelog available",children:e.jsx("span",{children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"var(--main-icon-color)"},disabled:!ee.changelog,onClick:F=>{if(F.stopPropagation(),!!ee.changelog)try{const V=new URL(ee.changelog);(V.protocol==="http:"||V.protocol==="https:")&&window.open(V.toString(),"_blank")}catch{}},size:"small",children:e.jsx(Bt,{})})})})]})}];o.useEffect(()=>{if(!n){t.current=!1,x.current="",k([]),S(!1),q(!1),U({done:0,total:0}),p(null),h("");return}if(t.current)return;t.current=!0;const b=new AbortController;return(async()=>{const B="matterbridge-",Me=`https://registry.npmjs.org/-/v1/search?text=${encodeURIComponent(B)}&size=250`,F=H=>new Promise(L=>setTimeout(L,H)),V=H=>{const L=H.getFullYear().toString(),pe=(H.getMonth()+1).toString().padStart(2,"0"),Se=H.getDate().toString().padStart(2,"0");return`${L}-${pe}-${Se}`},O=H=>{if(!Array.isArray(H.downloads))return null;let L=0,pe=!1;for(const Se of H.downloads)typeof Se?.downloads=="number"&&(L+=Se.downloads,pe=!0);return pe?L:null};try{S(!0),p(null);const H=await fetch(Me,{signal:b.signal});if(!H.ok)throw new Error(`npm registry request failed: ${H.status} ${H.statusText}`);const L=await H.json(),pe="luligu",Se=Z=>Z.publisher?.username?.toLowerCase()===pe||(Z.maintainers??[]).some(_=>_.username?.toLowerCase()===pe),w=(L.objects??[]).filter(Z=>!!Z?.package&&typeof Z.package.name=="string").filter(Z=>Z.package?.name?.startsWith(B)).filter(Z=>!ro.includes(Z.package?.name??"")).sort((Z,_)=>{const ue=Se(Z.package??{}),me=Se(_.package??{});return ue!==me?ue?-1:1:(Z.package?.name??"").localeCompare(_.package?.name??"")}).map(Z=>{const _=Z.package,ue=_.name??"",me=(_.publisher?.username??_.maintainers?.[0]?.username??"").trim(),xe=typeof Z.downloads?.monthly=="number"?Z.downloads.monthly:null,He=(_.links?.npm??"").trim(),at=((_.links?.homepage??"").trim()||He||(ue?`https://www.npmjs.com/package/${encodeURIComponent(ue)}`:"")).trim()||null;return{name:ue,version:_.version??"",downloads:xe,total:null,description:_.description??"",author:me,official:Se(_),homepage:at,help:null,changelog:null}}),D=V(new Date),A=On(),Q=Hn(),m=w.map(Z=>{const _=A[Z.name];return!_||typeof _.total!="number"?Z:(r&&console.log(`[SearchPluginsDialog] total downloads loaded from cache for ${Z.name} (asOf=${_.asOf}):`,_.total),{...Z,total:_.total})}).map(Z=>{const _=Q[Z.name];if(!_||_.asOf!==D)return Z;const ue=_.homepage??Z.homepage,me=_.help,xe=_.changelog;return r&&(me||xe||ue&&ue!==Z.homepage)&&console.log(`[SearchPluginsDialog] metadata loaded from cache for ${Z.name} (asOf=${_.asOf}):`,{homepage:ue,help:me,changelog:xe}),{...Z,homepage:ue,help:me,changelog:xe}});k(m);const ce=w.map(Z=>Z.name).filter(Z=>{const _=Q[Z],ue=!!_&&_.asOf===D,me=!!_&&!!_.help&&!!_.changelog,xe=!ue||!me;return!xe&&r&&console.log(`[SearchPluginsDialog] metadata fetch skipped (cache fresh+complete) for ${Z} (asOf=${_.asOf}).`),ue&&!me&&r&&console.log(`[SearchPluginsDialog] metadata fetch forced (cache incomplete) for ${Z} (asOf=${_.asOf}).`),xe}),G=new Set(ce),N=async(Z,_)=>{const ue=`https://registry.npmjs.org/${encodeURIComponent(Z)}/latest`;try{const me=await fetch(ue,{signal:b.signal});if(!me.ok)return null;const xe=await me.json(),He=typeof xe.homepage=="string"&&xe.homepage.includes("http")?_o(xe.homepage):null,lt=typeof xe.help=="string"&&xe.help.startsWith("http")?xe.help.trim():null,at=typeof xe.changelog=="string"&&xe.changelog.startsWith("http")?xe.changelog.trim():null,Dt=Rn(xe.repository),bt=Dt?Nn(Dt):null,ot=bt&&bt.includes("http")?bt:null,vt=He||ot||_||null,Gt=lt||(ot?`${ot}/blob/main/README.md`:null)||vt||null,Ue=at||(ot?`${ot}/blob/main/CHANGELOG.md`:null)||vt||null;return{homepage:vt,help:Gt,changelog:Ue}}catch(me){return me instanceof DOMException&&me.name==="AbortError",null}},fe=1,de=250;let De=0;const Oe=async()=>{for(;De<ce.length;){if(b.signal.aborted)return;const Z=De;De+=1;const _=ce[Z];if(!_||!G.has(_))continue;G.delete(_);const ue=w.find(xe=>xe.name===_)?.homepage??null,me=await N(_,ue);if(b.signal.aborted)return;me&&(k(xe=>xe.map(He=>He.name===_?{...He,homepage:me.homepage??He.homepage,help:me.help,changelog:me.changelog}:He)),Q[_]={homepage:me.homepage,help:me.help,changelog:me.changelog,asOf:D},En(Q)),b.signal.aborted||await F(de)}};Promise.all(Array.from({length:Math.min(fe,w.length)},()=>Oe()));const ve="2020-01-01",se=w.map(Z=>Z.name).filter(Z=>{const _=A[Z],ue=!_||_.asOf!==D;return ue||r&&console.log(`[SearchPluginsDialog] total downloads fetch skipped (cache fresh) for ${Z} (asOf=${_.asOf}).`),ue}),ae=new Set(se),Fe=se.length;U({done:0,total:Fe}),q(Fe>0);const _e=async Z=>{const _=`https://api.npmjs.org/downloads/range/${ve}:${D}/${encodeURIComponent(Z)}`;for(let ue=0;ue<3;ue+=1){const me=await fetch(_,{signal:b.signal});if(me.ok){const xe=await me.json();return O(xe)}if(me.status===404)return null;if(me.status===429){const xe=me.headers.get("retry-after"),He=xe?Number(xe):NaN,lt=Number.isFinite(He)?He*1e3:2e3*(ue+1);await F(lt);continue}return null}return null},tt=1,y=500;let re=0,Le=0;const Ke=async()=>{for(;re<se.length;){if(b.signal.aborted)return;const Z=re;re+=1;const _=se[Z];if(_&&ae.has(_)){ae.delete(_);try{r&&console.log(`[SearchPluginsDialog] fetching total downloads for ${_} (range ${ve}:${D})...`);const ue=await _e(_);if(b.signal.aborted)return;r&&console.log(`[SearchPluginsDialog] total downloads fetched for ${_}:`,ue),k(me=>me.map(xe=>xe.name===_?{...xe,total:ue}:xe)),typeof ue=="number"&&(A[_]={total:ue,asOf:D},_n(A),r&&console.log(`[SearchPluginsDialog] total downloads saved to localStorage for ${_} (asOf=${D}):`,ue))}catch(ue){if(ue instanceof DOMException&&ue.name==="AbortError")return}finally{Le+=1,U({done:Le,total:Fe}),b.signal.aborted||await F(y)}}}};Promise.all(Array.from({length:Math.min(tt,w.length)},()=>Ke())).finally(()=>{b.signal.aborted||q(!1)}),r&&console.log(`[SearchPluginsDialog] npm packages starting with "${B}" (filtered/sorted):`,w)}catch(H){if(H instanceof DOMException&&H.name==="AbortError")return;console.error("[SearchPluginsDialog] npm registry fetch error:",H),p(H instanceof Error?H.message:String(H))}finally{S(!1)}})(),()=>b.abort()},[n]);const W=()=>{u();const b=x.current||g;l(b)},te=()=>{u();const b=x.current||g;i(b)},le=()=>{u();const b=x.current||g;s(b)},j=()=>{u(),a()},d=$.reduce((b,B)=>b+(typeof B.downloads=="number"?B.downloads:0),0),c=$.reduce((b,B)=>(typeof B.total=="number"&&(b.total+=B.total,b.hasAny=!0),b),{total:0,hasAny:!1}),v=z?` Totals: ${Y.done.toString()}/${Y.total.toString()} fetched`:"",C=c.hasAny?M(c.total):"...";return e.jsxs(qe,{open:n,onClose:()=>{u(),a()},maxWidth:!1,fullWidth:!0,slotProps:{paper:{sx:{width:"75vw",height:"75vh",maxWidth:"75vw",maxHeight:"75vh",display:"flex",flexDirection:"column"}}},children:[e.jsx(Be,{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:"Search Plugins"})]})}),e.jsx(Qe,{dividers:!0,sx:{padding:0,flex:"1 1 auto",minHeight:0},children:e.jsx("div",{style:{height:"100%",width:"100%",display:"flex",flexDirection:"column",minHeight:0},children:P?e.jsx("div",{style:{padding:"20px"},children:"Loading npm registry..."}):f?e.jsx("div",{style:{padding:"20px"},children:f}):e.jsx(It,{name:"Search plugins",rows:$,columns:I,getRowKey:"name",onRowClick:(b,B,ee)=>{x.current=b.name,h(b.name),ee.detail===2&&l(b.name)},footerLeft:`Total packages: ${$.length.toString()} Total downloads: ${M(d)} / ${C}${v}`,footerRight:g?`Selected: ${g}`:""})})}),e.jsxs(Ye,{sx:{justifyContent:"center",gap:1.5,flexWrap:"wrap"},children:[e.jsx(ge,{variant:"contained",onClick:W,disabled:!(x.current||g),children:"Select"}),e.jsx(ge,{variant:"contained",onClick:te,disabled:!(x.current||g),children:"Install"}),e.jsx(ge,{variant:"contained",onClick:le,disabled:!(x.current||g),children:"Add"}),e.jsx(ge,{onClick:j,children:"Cancel"})]})]})},ro=["matterbridge-","matterbridge-plugin-template","matterbridge-dyson","matterbridge-irobot","matterbridge-tuya","matterbridge-mqtt","matterbridge-matter","matterbridge-security","matterbridge-automations","matterbridge-securitysystem","matterbridge-adapter"];function Vn(){const{mobile:n,showSnackbarMessage:a}=o.useContext(Re),{logMessage:l,sendMessage:i,getUniqueId:s}=o.useContext(ke),[g,h]=o.useState("matterbridge-"),[x,t]=o.useState(!1),$=o.useRef(s()),k=C=>{C.preventDefault(),t(!0)},P=()=>{t(!1)},S=C=>{C.preventDefault(),t(!1);const b=C.dataTransfer.files[0];if(b){l("Plugins",`Installing package ${b.name}. Please wait...`);const B=new FormData;B.append("file",b),B.append("filename",b.name),fetch("./api/uploadpackage",{method:"POST",body:B}).then(ee=>ee.text()).then(ee=>{l("Plugins",`Server response: ${ee}`)}).catch(ee=>{console.error("Error uploading plugin file:",ee),l("Plugins",`Error installing package ${ee}`)})}},z=C=>{const b=C.target.files&&C.target.files[0];if(b){l("Plugins",`Uploading package ${b.name}`);const B=new FormData;B.append("file",b),B.append("filename",b.name),fetch("./api/uploadpackage",{method:"POST",body:B}).then(ee=>ee.text()).then(ee=>{l("Plugins",`Server response: ${ee}`)}).catch(ee=>{console.error("Error uploading plugin file:",ee),l("Plugins",`Error uploading package ${ee}`)})}},q=()=>{if(ro.includes(g.split("@")[0])){a(`Installation of plugin "${g}" is blocked by the ignore list.`);return}i({id:$.current,sender:"InstallPlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:g,restart:!1}})},Y=()=>{i({id:$.current,sender:"InstallPlugins",method:"/api/uninstall",src:"Frontend",dst:"Matterbridge",params:{packageName:g}})},U=()=>{document.getElementById("file-upload")?.click()},f=()=>{if(ro.includes(g.split("@")[0])){a(`Addition of plugin "${g}" is blocked by the ignore list.`);return}i({id:$.current,sender:"InstallPlugins",method:"/api/addplugin",src:"Frontend",dst:"Matterbridge",params:{pluginNameOrPath:g}})},p=C=>{C.preventDefault(),console.log("Right-clicked Upload button")},u=C=>{C.preventDefault(),console.log("Right-clicked Add button")},[M,I]=o.useState(!1),W=()=>{I(!0),console.log("Dialog opened for selection")},te=()=>{h("matterbridge-"),I(!1),console.log("Dialog closed without selection")},le=C=>{h(C),I(!1),console.log("Select plugin:",C)},j=C=>{h(C),I(!1),q(),console.log("Install plugin:",C)},d=C=>{h(C),I(!1),f(),console.log("Add plugin:",C)},[c,v]=o.useState(!1);return r&&console.log("HomeInstallAddPlugins rendering..."),c?null:e.jsxs(Ie,{children:[e.jsxs(Te,{children:[e.jsx(Pe,{children:"Install plugins"}),e.jsx(it,{close:()=>v(!0)})]}),e.jsxs(Ve,{onDragOver:k,onDragLeave:P,onDrop:S,style:we&&n?{flexWrap:"wrap",alignItems:"center",gap:"10px"}:{flexWrap:"wrap",alignItems:"center",gap:"20px"},children:[e.jsx(An,{open:M,onClose:te,onSelect:le,onInstall:j,onAdd:d}),e.jsxs("div",{style:{flex:"1 1 auto",display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(E,{title:"Provide the npm name or the local path of the plugin to install, uninstall, or add",children:e.jsx(Ce,{value:g,onChange:C=>{h(C.target.value)},size:"small",id:"plugin-name",label:"Plugin name or plugin path",variant:"outlined",fullWidth:!0})}),e.jsx(E,{title:"Search on npm the plugin to install",children:e.jsx(X,{size:"large",onClick:W,children:e.jsx(rr,{fontSize:"inherit"})})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(E,{title:"Install or update a plugin from npm",children:e.jsxs(ge,{onClick:q,endIcon:e.jsx(Ae,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Install"]})}),e.jsx(E,{title:"Uninstall and remove a plugin",children:e.jsxs(ge,{onClick:Y,endIcon:e.jsx(Po,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Uninstall"]})}),e.jsx(E,{title:"Upload and install a plugin from a tarball",children:e.jsxs(ge,{onClick:U,onContextMenu:p,endIcon:e.jsx(nr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px",minWidth:"90px"},children:[" ","Upload"]})}),e.jsx(E,{title:"Add an already installed plugin or a plugin from a local path",children:e.jsxs(ge,{onClick:f,onContextMenu:u,endIcon:e.jsx(At,{}),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:z})]})]})]})}const Un=o.memo(Vn);function dt({status:n,enabledText:a="Enabled",disabledText:l=void 0,tooltipText:i=void 0,onClick:s}){if(n===void 0)return null;{const g=e.jsx("div",{className:n?"status-enabled":"status-disabled",style:{cursor:"default"},onClick:s,children:n?a:l??a});return i!==void 0?e.jsx(E,{title:i,children:g}):g}}function jo(n){return n.id!==0&&n.src==="Matterbridge"&&n.dst==="Frontend"}const pt={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},Rt={fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},wo={fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},zn={fontSize:"14px",fontWeight:"normal",color:"var(--secondary-color)",backgroundColor:"var(--div-bg-color)"},qn={fontSize:"16px",fontWeight:"bold",backgroundColor:"var(--div-bg-color)"},Je={padding:"0px",margin:"0px"},Bn="5px 10px 5px 10px",Ot={},$e={},_t={},Ht={};let ut=[],Zt=[];function Xt(n,a){const l=n?.properties;if(!l||typeof l!="object")return!1;const i=l[a];return!i||typeof i!="object"?!1:typeof i.type=="string"}function gt(n){const a=n.items;return a!==void 0&&typeof a=="object"&&!Array.isArray(a)}const Qn=({open:n,onClose:a,plugin:l})=>{const{sendMessage:i,addListener:s,removeListener:g,getUniqueId:h}=o.useContext(ke),x=o.useRef(h()),t=o.useRef({}),$=o.useRef({}),[k,P]=o.useState(l.configJson),[S,z]=o.useState(l.schemaJson),[q,Y]=o.useState({"ui:submitButtonOptions":{submitText:"Confirm"},"ui:globalOptions":{orderable:!0}}),[U,f]=o.useState("");let p={};o.useEffect(()=>{const T=w=>{w.src==="Matterbridge"&&w.dst==="Frontend"&&(jo(w)&&w.id===x.current&&w.method==="/api/select/devices"&&w.response&&(r&&console.log(`ConfigPluginDialog (id: ${w.id}) received ${w.response.length} /api/select/devices:`,w.response),ut=w.response),jo(w)&&w.id===x.current&&w.method==="/api/select/entities"&&w.response&&(r&&console.log(`ConfigPluginDialog (id: ${w.id}) received ${w.response.length} /api/select/entities:`,w.response),Zt=w.response))};if(s(T,x.current),r&&console.log("ConfigPluginDialog added WebSocket listener id:",x.current),k&&S&&S.properties){const w=(D,A,Q=[])=>{!D||typeof D!="object"||(D.properties&&Object.keys(D.properties).forEach(J=>{const m=D.properties?.[J],ce=[...Q,J];Object.keys(m).forEach(G=>{if(G.startsWith("ui:")){let N=A;ce.forEach(fe=>{N[fe]||(N[fe]={}),N=N[fe]}),N[G]=m[G],delete m[G]}}),w(m,A,ce)}),["oneOf","anyOf","allOf"].forEach(J=>{Array.isArray(D[J])&&D[J].forEach(m=>{w(m,A,Q)})}),D.items&&typeof D.items=="object"&&w(D.items,A,Q))};w(S,q),Y(q),t.current=S,$.current=q}return l.name&&l.configJson&&l.schemaJson&&(P(l.configJson),z(l.schemaJson),i({id:x.current,sender:"ConfigPlugin",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),i({id:x.current,sender:"ConfigPlugin",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name}}),r&&console.log('HomePlugins sent "/api/select/devices" and "/api/select/entities" for plugin:',l.name)),()=>{g(T),r&&console.log("ConfigPluginDialog removed WebSocket listener")}},[s,k,l,g,S,i,q]);const u=(T,w)=>{p=T.formData},M=T=>{r&&console.log("ConfigPluginDialog handleSaveChanges:",T.formData),P(T.formData),l.configJson=T.formData,l.restartRequired=!0,i({id:x.current,sender:"ConfigPlugin",method:"/api/savepluginconfig",src:"Frontend",dst:"Matterbridge",params:{pluginName:T.formData.name,formData:T.formData}}),a()};function I(T){const{id:w,label:D,onKeyChange:A,onDropPropertyClick:Q,disabled:J,schema:m,children:ce,registry:G,readonly:N,required:fe}=T,{templates:de}=G,{RemoveButton:De}=de.ButtonTemplates;if(!(yn in m))return e.jsx(he,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:ce});const ve=({target:se})=>A(se&&se.value);return e.jsxs(he,{sx:{display:"flex",flexDirection:"row",flexGrow:1,padding:0,margin:0,border:"none"},children:[e.jsx(Ce,{id:`${w}-key`,name:`${w}-key`,required:fe,disabled:J||N,defaultValue:D,onBlur:N?void 0:ve,type:"text",variant:"outlined",sx:{width:"250px",minWidth:"250px",maxWidth:"250px",marginRight:"20px"}}),e.jsx(he,{sx:{flex:1},children:ce}),e.jsx(De,{disabled:J||N,onClick:Q(D),registry:G})]})}function W(T){const{children:w,description:D,displayLabel:A,errors:Q,help:J,hidden:m,registry:ce,uiSchema:G}=T,N=bn(G),fe=vn("WrapIfAdditionalTemplate",ce,N);return m?e.jsx("div",{style:{display:"none"},children:w}):e.jsx(he,{sx:{display:"flex",flexDirection:"column",flexGrow:1,padding:0,margin:0,border:"none"},children:e.jsxs(fe,{...T,children:[A===!0&&D,w,Q,J]})})}function te(T){const{description:w}=T;return w?e.jsx(ye,{sx:Rt,children:w}):null}function le(T){const{required:w,title:D}=T;return D?e.jsx(he,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsxs(ye,{sx:pt,children:["Title ",D," ",w&&e.jsx("mark",{children:"***"})]})}):null}function j(T){const{help:w}=T;return w?e.jsx(he,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:e.jsx(ye,{sx:zn,children:w})}):null}function d(T){const{errors:w}=T;return w?e.jsxs(he,{sx:{padding:"10px",margin:"10px",border:"1px solid grey"},children:[e.jsx(ye,{color:"error",sx:qn,children:"Please fix the following errors:"}),e.jsx(yt,{children:w.map((D,A)=>e.jsxs(ir,{children:[e.jsx(K,{children:e.jsx(sr,{color:"error"})}),e.jsx(ie,{primary:D.stack})]},A))})]}):null}function c(T){const{errors:w}=T;return w?e.jsx(he,{sx:{padding:"0px",margin:"0px",marginTop:"5px"},children:w.map((D,A)=>e.jsxs(ye,{color:"error",variant:"body2",sx:{marginLeft:1},children:["This field ",D]},A))}):null}function v(T){const{id:w,name:D,_schema:A,_uiSchema:Q,value:J,options:m,label:ce,type:G,placeholder:N,required:fe,disabled:de,readonly:De,autofocus:Oe,onChange:ve,onChangeOverride:se,onBlur:ae,onFocus:Fe,_rawErrors:_e,_hideError:tt,_registry:y,_formContext:re}=T,Le=({target:{value:_}})=>ve(_===""?m.emptyValue:_),Ke=({target:_})=>ae(w,_&&_.value),Z=({target:_})=>Fe(w,_&&_.value);return e.jsx(he,{sx:{padding:"0px",margin:"0px"},children:e.jsx(Ce,{id:w,name:w,label:N&&N!==""?ce:void 0,variant:"outlined",placeholder:N&&N!==""?N:ce,required:fe,disabled:de||De,autoFocus:Oe,value:J||J===0?J:"",type:G,autoComplete:G==="password"?"current-password":D,onChange:se||Le,onBlur:Ke,onFocus:Z,fullWidth:!0})})}function C(T){return console.log("ArrayFieldTitleTemplate:",T),null}function b(T){return console.log("ArrayFieldDescriptionTemplate:",T),null}function B(T){return console.log("ArrayFieldItemTemplate:",T),null}function ee(T){const{canAdd:w,onAddClick:D,schema:A,title:Q}=T,[J,m]=o.useState(!1),[ce,G]=o.useState(!1),[N,fe]=o.useState(!1),[de,De]=o.useState(""),Oe=y=>{De(y.target.value)},ve=()=>{r&&console.log("ArrayFieldTemplate: handleDialogDeviceToggle filter:",de,"selectDevices:",ut),m(!J)},se=()=>{r&&console.log("ArrayFieldTemplate: handleDialogEntityToggle filter:",de,"selectEntities:",Zt),G(!ce)},ae=()=>{r&&console.log("ArrayFieldTemplate: handleDialogDeviceEntityToggle filter:",de,"selectDevices:",ut),fe(!N)},Fe=y=>{m(!1),A.selectFrom==="serial"&>(A)?A.items.default=y.serial:A.selectFrom==="name"&>(A)&&(A.items.default=y.name),D()},_e=y=>{G(!1),A.selectEntityFrom==="name"&>(A)?A.items.default=y.name:A.selectEntityFrom==="description"&>(A)&&(A.items.default=y.description),D()},tt=y=>{fe(!1),A.selectDeviceEntityFrom==="name"&>(A)?A.items.default=y.name:A.selectDeviceEntityFrom==="description"&>(A)&&(A.items.default=y.description),D()};return e.jsxs(he,{sx:{margin:"0px",padding:"5px 10px 5px 10px",border:"1px solid grey"},children:[Q&&e.jsxs(he,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[Q&&e.jsx(ye,{sx:pt,children:Q}),w&&e.jsxs(he,{sx:{margin:"0px",padding:"0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[A.selectFrom&&e.jsx(E,{title:"Add a device from the list",children:e.jsx(X,{onClick:ve,size:"small",color:"primary",sx:Je,children:e.jsx(Lt,{})})}),A.selectEntityFrom&&e.jsx(E,{title:"Add an entity from the list",children:e.jsx(X,{onClick:se,size:"small",color:"primary",sx:Je,children:e.jsx(Lt,{})})}),A.selectDeviceEntityFrom&&e.jsx(E,{title:"Add a device entity from the list",children:e.jsx(X,{onClick:ae,size:"small",color:"primary",sx:Je,children:e.jsx(Lt,{})})}),e.jsx(E,{title:"Add a new item",children:e.jsx(X,{onClick:D,size:"small",color:"primary",sx:Je,children:e.jsx(At,{})})})]})]}),A.description&&e.jsx(ye,{sx:Rt,children:A.description}),T.items.map(y=>e.jsxs(he,{sx:{margin:"2px 0px",padding:"0px",display:"flex",alignItems:"center"},children:[e.jsx(he,{sx:{flexGrow:1,marginRight:"10px"},children:y.children}),e.jsx(X,{disabled:!y.hasMoveUp,onClick:y.onReorderClick(y.index,y.index-1),size:"small",color:"primary",sx:Je,children:e.jsx(ao,{})}),e.jsx(X,{disabled:!y.hasMoveDown,onClick:y.onReorderClick(y.index,y.index+1),size:"small",color:"primary",sx:Je,children:e.jsx(lo,{})}),e.jsx(X,{onClick:y.onDropIndexClick(y.index),size:"small",color:"primary",sx:Je,children:e.jsx(oo,{})})]},y.index)),e.jsxs(qe,{open:J,onClose:ve,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Be,{children:"Select a device"}),e.jsxs(Qe,{children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ye,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(Ce,{fullWidth:!0,variant:"outlined",value:de,onChange:Oe,placeholder:"Enter serial or name"})]}),e.jsx(yt,{dense:!0,children:ut.filter(y=>y.serial.toLowerCase().includes(de.toLowerCase())||y.name.toLowerCase().includes(de.toLowerCase())).map((y,re)=>e.jsxs($t,{onClick:()=>Fe(y),sx:Ot,children:[y.icon==="wifi"&&e.jsx(K,{children:e.jsx(Ct,{style:$e})}),y.icon==="ble"&&e.jsx(K,{children:e.jsx(Wt,{style:$e})}),y.icon==="hub"&&e.jsx(K,{children:e.jsx(Tt,{style:$e})}),e.jsx(ie,{primary:y.name,secondary:y.serial,primaryTypographyProps:{style:_t},secondaryTypographyProps:{style:Ht}})]},re))})]}),e.jsx(Ye,{children:e.jsx(ge,{onClick:ve,children:"Close"})})]}),e.jsxs(qe,{open:ce,onClose:se,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Be,{children:"Select an entity"}),e.jsxs(Qe,{children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ye,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(Ce,{fullWidth:!0,variant:"outlined",value:de,onChange:Oe,placeholder:"Enter name or description"})]}),e.jsx(yt,{dense:!0,children:Zt.filter(y=>y.name.toLowerCase().includes(de.toLowerCase())||y.description.toLowerCase().includes(de.toLowerCase())).map((y,re)=>e.jsxs($t,{onClick:()=>_e(y),sx:Ot,children:[y.icon==="wifi"&&e.jsx(K,{children:e.jsx(Ct,{style:$e})}),y.icon==="ble"&&e.jsx(K,{children:e.jsx(Wt,{style:$e})}),y.icon==="hub"&&e.jsx(K,{children:e.jsx(Tt,{style:$e})}),y.icon==="component"&&e.jsx(K,{children:e.jsx(co,{style:$e})}),y.icon==="matter"&&e.jsx(K,{children:e.jsx(po,{style:$e})}),e.jsx(ie,{primary:y.name,secondary:y.description,primaryTypographyProps:{style:_t},secondaryTypographyProps:{style:Ht}})]},re))})]}),e.jsx(Ye,{children:e.jsx(ge,{onClick:se,children:"Close"})})]}),e.jsxs(qe,{open:N,onClose:ae,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsxs(Be,{children:["Select an entity for ",Q]}),e.jsx(Qe,{children:e.jsx(yt,{dense:!0,children:ut.filter(y=>y.serial===Q||y.name===Q).map(y=>y.entities?.map((re,Le)=>e.jsxs($t,{onClick:()=>tt(re),sx:Ot,children:[re.icon==="wifi"&&e.jsx(K,{children:e.jsx(Ct,{style:$e})}),re.icon==="ble"&&e.jsx(K,{children:e.jsx(Wt,{style:$e})}),re.icon==="hub"&&e.jsx(K,{children:e.jsx(Tt,{style:$e})}),re.icon==="component"&&e.jsx(K,{children:e.jsx(co,{style:$e})}),re.icon==="matter"&&e.jsx(K,{children:e.jsx(po,{style:$e})}),e.jsx(ie,{primary:re.name,secondary:re.description,primaryTypographyProps:{style:_t},secondaryTypographyProps:{style:Ht}})]},Le)))})}),e.jsx(Ye,{children:e.jsx(ge,{onClick:ae,children:"Close"})})]})]})}function Me(T){const{onAddClick:w,schema:D,properties:A,title:Q,description:J}=T,[m,ce]=o.useState(!1),[G,N]=o.useState(""),fe=se=>{N(se.target.value)},de=()=>{ce(!m)},De=se=>{r&&console.log(`ObjectFieldTemplate: handleSelectValue value "${se.serial}" for schema "${D.selectFrom}"`),ce(!1);let ae="";D.selectFrom==="serial"?ae=se.serial:D.selectFrom==="name"&&(ae=se.name),f(ae),r&&console.log(`ObjectFieldTemplate: handleSelectValue newkey "${ae}"`),w(D)()},Oe=()=>{w(D)()},ve=!D.additionalProperties;return r&&console.log(`ObjectFieldTemplate: isRoot ${ve} newkey "${U}"`),!ve&&U!==""&&(r&&console.log("ObjectFieldTemplate: newkey",U,"properties",A),A.forEach(se=>{if(se.name==="newKey"&&se.content.key==="newKey"&&se.content.props.name==="newKey"&&se.content.props.onKeyChange&&U!==""){r&&console.log("ObjectFieldTemplate: newkey onKeyChange",U);const ae=U;f(""),se.content.props.onKeyChange(ae)}})),e.jsxs(he,{sx:{margin:"0px",padding:ve?"10px":"5px 10px 0px 10px",border:ve?"none":"1px solid grey"},children:[D.title&&ve&&e.jsx(he,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ye,{sx:pt,children:D.title})}),Q&&!ve&&e.jsxs(he,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[e.jsx(ye,{sx:pt,children:Q}),e.jsxs(he,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"0px",margin:"0px"},children:[D.selectFrom&&e.jsx(E,{title:"Add a device from the list",children:e.jsx(X,{onClick:de,size:"small",color:"primary",sx:Je,children:e.jsx(Lt,{})})}),e.jsx(E,{title:"Add a new item",children:e.jsx(X,{onClick:Oe,size:"small",color:"primary",sx:Je,children:e.jsx(At,{})})})]})]}),D.description&&e.jsx(he,{sx:{padding:"0px",margin:"0px",marginBottom:"10px"},children:e.jsx(ye,{sx:Rt,children:D.description})}),A.map(({content:se,name:ae,hidden:Fe})=>!Fe&&e.jsxs(he,{sx:{margin:"0px",marginBottom:"10px",padding:Xt(D,ae)&&["object","array"].includes(D.properties[ae].type)?"0px":Bn,border:Xt(D,ae)&&["object","array"].includes(D.properties[ae].type)?"none":"1px solid grey"},children:[Xt(D,ae)&&!["object","array","boolean"].includes(D.properties[ae].type)&&e.jsx(ye,{sx:pt,children:D.properties[ae].title||ae}),e.jsx(he,{sx:{flexGrow:1,padding:"0px",margin:"0px"},children:se})]},ae)),e.jsxs(qe,{open:m,onClose:de,PaperProps:{sx:{maxHeight:"50vh",maxWidth:"50vw",overflow:"auto"}},children:[e.jsx(Be,{children:"Select a device"}),e.jsxs(Qe,{children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[e.jsx(ye,{variant:"subtitle1",sx:{whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(Ce,{fullWidth:!0,variant:"outlined",value:G,onChange:fe,placeholder:"Enter serial or name"})]}),e.jsx(yt,{dense:!0,children:ut.filter(se=>se.serial.toLowerCase().includes(G.toLowerCase())||se.name.toLowerCase().includes(G.toLowerCase())).map((se,ae)=>e.jsxs($t,{onClick:()=>De(se),sx:Ot,children:[se.icon==="wifi"&&e.jsx(K,{children:e.jsx(Ct,{style:$e})}),se.icon==="ble"&&e.jsx(K,{children:e.jsx(Wt,{style:$e})}),se.icon==="hub"&&e.jsx(K,{children:e.jsx(Tt,{style:$e})}),e.jsx(ie,{primary:se.name,secondary:se.serial,primaryTypographyProps:{style:_t},secondaryTypographyProps:{style:Ht}})]},ae))})]}),e.jsx(Ye,{children:e.jsx(ge,{onClick:de,children:"Close"})})]})]})}function F(T){const{uiSchema:w}=T,{submitText:D,norender:A}=xn(w);return A?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",margin:"10px",padding:"0px",gap:"20px"},children:[e.jsx(ge,{type:"submit",variant:"contained",color:"primary",children:D}),e.jsx(ge,{variant:"contained",color:"primary",onClick:a,children:"Cancel"})]})}function V(T){const{className:w,disabled:D,onClick:A,registry:Q,style:J,uiSchema:m,...ce}=T;return e.jsx(E,{title:"Remove the item",children:e.jsx(X,{disabled:D,size:"small",color:"primary",onClick:A,children:e.jsx(oo,{})})})}function O(T){const{className:w,disabled:D,onClick:A,registry:Q,uiSchema:J,...m}=T;return e.jsx(E,{title:"Add an item",children:e.jsx(X,{size:"small",color:"primary",onClick:A,children:e.jsx(At,{})})})}function H(T){const{disabled:w,onClick:D,registry:A,style:Q,uiSchema:J,...m}=T;return e.jsx(E,{title:"Move up the item",children:e.jsx(X,{size:"small",color:"primary",onClick:D,children:e.jsx(ao,{})})})}function L(T){const{disabled:w,onClick:D,registry:A,style:Q,uiSchema:J,...m}=T;return e.jsx(E,{title:"Move down the item",children:e.jsx(X,{size:"small",color:"primary",onClick:D,children:e.jsx(lo,{})})})}function pe(T){const{id:w,name:D,value:A,schema:Q,readonly:J,onChange:m}=T,[ce,G]=o.useState(),N=de=>{r&&console.log(`CheckboxWidget ${D} onChangeField:`,de),G(de&&de!==""?de:void 0)},fe=()=>{r&&console.log(`CheckboxWidget onClick plugin="${l.name}" action="${D}" value="${ce}"`),i({id:x.current,sender:"ConfigPlugin",method:"/api/action",src:"Frontend",dst:"Matterbridge",params:{plugin:l.name,action:D,value:ce,formData:p,id:w}}),Q.buttonClose===!0?a():Q.buttonSave===!0&&M({formData:k})};return Q.buttonText&&(Q.title||Q.description)?e.jsxs(he,{sx:{margin:"0px",padding:"5px 0px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ye,{sx:wo,children:Q.title||Q.description}),e.jsx(ge,{variant:"contained",color:"primary",onClick:()=>fe(),children:Q.buttonText})]}):Q.buttonField&&(Q.title||Q.description)?e.jsxs(he,{sx:{margin:"0px",padding:"5px 0px",gap:"20px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsx(ye,{sx:wo,children:Q.title||Q.description}),e.jsx(Ce,{id:D+"-input",name:D,label:Q.textLabel,placeholder:Q.textPlaceholder,onChange:de=>N(de.target.value),sx:{width:"250px",minWidth:"250px",maxWidth:"250px"}}),e.jsx(ge,{id:D+"-button",variant:"contained",color:"primary",disabled:ce===void 0,onClick:()=>fe(),children:Q.buttonField})]}):e.jsxs(he,{sx:{margin:"0px",padding:"0px"},children:[D&&e.jsxs(he,{sx:{margin:"0px",padding:"0px",gap:"10px",display:"flex",justifyContent:"flex-start",alignItems:"center"},children:[e.jsx(ye,{sx:pt,children:Q.title||D}),e.jsx(Ze,{checked:A,readOnly:J,onChange:()=>m(!A),sx:{padding:"0px",margin:"0px"}})]}),Q.description&&e.jsx(ye,{sx:Rt,children:Q.description})]})}function Se({schema:T,id:w,name:D,options:A,label:Q,hideLabel:J,required:m,disabled:ce,placeholder:G,readonly:N,value:fe,multiple:de,autofocus:De,onChange:Oe,onBlur:ve,onFocus:se,errorSchema:ae,rawErrors:Fe=[],registry:_e,uiSchema:tt,hideError:y,formContext:re,...Le}){const{enumOptions:Ke,enumDisabled:Z,emptyValue:_}=A;de=typeof de>"u"?!1:!!de;const ue=de?[]:"",me=typeof fe>"u"||de&&fe.length<1||!de&&fe===ue,xe=({target:{value:Ue}})=>Oe(Yt(Ue,Ke,_)),He=({target:Ue})=>ve(w,Yt(Ue&&Ue.value,Ke,_)),lt=({target:Ue})=>se(w,Yt(Ue&&Ue.value,Ke,_)),at=mn(fe,Ke,de),{InputLabelProps:Dt,SelectProps:bt,autocomplete:ot,...vt}=Le,Gt=!de&&T.default===void 0;return e.jsxs(Ce,{id:w,name:w,value:!me&&typeof at<"u"?at:ue,required:m,disabled:ce||N,autoFocus:De,autoComplete:ot,placeholder:G,error:Fe.length>0,onChange:xe,onBlur:He,onFocus:lt,...vt,select:!0,InputLabelProps:{...Dt,shrink:!me},SelectProps:{...bt,multiple:de},"aria-describedby":fn(w),children:[Gt&&e.jsx(R,{value:"",children:G}),Array.isArray(Ke)&&Ke.map(({value:Ue,label:Uo},so)=>{const zo=Array.isArray(Z)&&Z.indexOf(Ue)!==-1;return e.jsx(R,{value:String(so),disabled:zo,children:Uo},so)})]})}return r&&console.log("ConfigPluginDialog rendering..."),!n||!S||!k?null:e.jsxs(qe,{open:n,onClose:a,slotProps:{paper:{sx:{maxWidth:"800px"}}},children:[e.jsx(Be,{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(Qe,{style:{padding:"0px",margin:"0px",width:"800px",height:"600px",overflow:"auto"},children:e.jsx(gn,{schema:S,formData:k,uiSchema:q,validator:hn,templates:{FieldTemplate:W,BaseInputTemplate:v,TitleFieldTemplate:le,DescriptionFieldTemplate:te,FieldHelpTemplate:j,FieldErrorTemplate:c,ErrorListTemplate:d,WrapIfAdditionalTemplate:I,ArrayFieldTitleTemplate:C,ArrayFieldDescriptionTemplate:b,ArrayFieldItemTemplate:B,ArrayFieldTemplate:ee,ObjectFieldTemplate:Me,ButtonTemplates:{SubmitButton:F,RemoveButton:V,AddButton:O,MoveUpButton:H,MoveDownButton:L}},widgets:{CheckboxWidget:pe,SelectWidget:Se},onChange:u,onSubmit:M})})]})};function Ho(n){if(r&&console.log(`getQRColor (id: ${n?.id}) received matter:`,n??"undefined"),n===void 0||!n.online||!n.qrPairingCode&&!n.manualPairingCode&&!n.fabricInformations&&!n.sessionInformations)return"red";if(n.commissioned===!1&&n.qrPairingCode&&n.manualPairingCode)return"var(--primary-color)";let a=0,l=0;for(const i of n.sessionInformations??[])i.fabric&&i.isPeerActive===!0&&a++,i.numberOfActiveSubscriptions>0&&(l+=i.numberOfActiveSubscriptions);return n.commissioned===!0&&n.fabricInformations&&n.sessionInformations&&(a===0||l===0)?"var(--secondary-color)":"var(--div-text-color)"}function Gn({storeId:n,setStoreId:a}){const{online:l,sendMessage:i,addListener:s,removeListener:g,getUniqueId:h}=o.useContext(ke),{showConfirmCancelDialog:x}=o.useContext(Re),t=o.useRef(h()),[$,k]=o.useState(null),[P,S]=o.useState(null),[z,q]=o.useState([]),Y=[{label:"Name",id:"name",required:!0,render:(O,H,L,pe)=>e.jsx(E,{title:`Plugin path ${L.path}`,children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>j(L),children:L.name})})},{label:"Description",id:"description",render:(O,H,L,pe)=>e.jsx(E,{title:"Open the plugin homepage",children:e.jsx("span",{style:{cursor:"pointer"},onClick:()=>j(L),children:L.description})})},{label:"Version",id:"version",render:(O,H,L,pe)=>e.jsx(e.Fragment,{children:e.jsx(E,{title:`Plugin v.${L.version}`,children:e.jsx("span",{children:L.version.split("-")[0]+(L.version.includes("-dev-")?"@dev":"")+(L.version.includes("-git-")?"@git":"")})})})},{label:"Author",id:"author",render:(O,H,L,pe)=>e.jsx(e.Fragment,{children:L.author?L.author.replace("https://github.com/",""):"Unknown"})},{label:"Type",id:"type",render:(O,H,L,pe)=>e.jsx(e.Fragment,{children:L.type?L.type.replace("Platform",""):"Unknown"})},{label:"Devices",id:"registeredDevices"},{label:"Actions",id:"actions",required:!0,noSort:!0,render:(O,H,L,pe)=>e.jsxs("div",{style:{margin:"0px",padding:"0px",gap:"4px",display:"flex",flexDirection:"row"},children:[P&&P.bridgeMode==="childbridge"&&!L.error&&L.enabled&&e.jsx(E,{title:"Shows the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:Ho(L.matter)},onClick:()=>{L.matter?.id&&a(L.matter?.id)},size:"small",children:e.jsx(Lo,{})})}),P&&P.bridgeMode==="childbridge"&&!L.error&&L.enabled&&e.jsx(E,{title:"Restart the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px"},onClick:()=>te(L),size:"small",children:e.jsx(Vt,{})})}),e.jsx(E,{title:"Plugin config",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{disabled:L.restartRequired===!0,style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>Me(L),size:"small",children:e.jsx(lr,{})})}),P&&!P.readOnly&&e.jsx(E,{title:"Remove the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{f("Remove plugin","Are you sure? This will also remove all devices and configuration from the controller.","remove",L)},size:"small",children:e.jsx(Po,{})})}),L.enabled?e.jsx(E,{title:"Disable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>{f("Disable plugin","Are you sure? This will also remove all devices and configuration from the controller.","disable",L)},size:"small",children:e.jsx(ar,{})})}):e.jsx(e.Fragment,{}),L.enabled?e.jsx(e.Fragment,{}):e.jsx(E,{title:"Enable the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0px",padding:"0px",width:"19px",height:"19px"},onClick:()=>le(L),size:"small",children:e.jsx(cr,{})})}),e.jsx(E,{title:"Open the plugin help",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>c(L),size:"small",children:e.jsx(no,{})})}),e.jsx(E,{title:"Open the plugin version history",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>v(L),size:"small",children:e.jsx(Bt,{})})}),L.latestVersion!==void 0&&L.latestVersion!==L.version&&P&&!P.readOnly&&e.jsx(E,{title:"Update the plugin to the latest version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{color:"var(--primary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>M(L),size:"small",children:e.jsx(ze,{})})}),(L.version.includes("-dev-")||L.version.includes("-git-"))&&L.devVersion!==void 0&&L.devVersion!==L.version&&P&&!P.readOnly&&e.jsx(E,{title:"Update the plugin to the latest dev version",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{color:"var(--secondary-color)",margin:"0px 2px",padding:"0px",width:"19px",height:"19px"},onClick:()=>I(L),size:"small",children:e.jsx(ze,{})})}),P&&!P.readOnly&&e.jsx(E,{title:"Sponsor the plugin",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{style:{margin:"0",padding:"0",width:"19px",height:"19px",color:"#b6409c"},onClick:()=>d(L),size:"small",children:e.jsx(io,{})})})]})},{label:"Status",id:"status",required:!0,noSort:!0,render:(O,H,L,pe)=>e.jsx("div",{style:{display:"flex",flexDirection:"row",flex:"1 1 auto",margin:"0",padding:"0",gap:"5px",width:"auto",maxWidth:"max-content"},children:L.error?e.jsx(e.Fragment,{children:e.jsx(dt,{status:!1,enabledText:"Error",disabledText:"Error",tooltipText:"The plugin is in error state. Check the log!"})}):e.jsx(e.Fragment,{children:L.enabled===!1?e.jsx(e.Fragment,{children:e.jsx(dt,{status:L.enabled,enabledText:"Enabled",disabledText:"Disabled",tooltipText:"Whether the plugin is enable or disabled"})}):e.jsx(e.Fragment,{children:L.loaded&&L.started&&L.configured?e.jsx(e.Fragment,{children:e.jsx(dt,{status:L.loaded,enabledText:"Running",tooltipText:"Whether the plugin is running"})}):e.jsxs(e.Fragment,{children:[e.jsx(dt,{status:L.loaded,enabledText:"Loaded",tooltipText:"Whether the plugin has been loaded"}),e.jsx(dt,{status:L.started,enabledText:"Started",tooltipText:"Whether the plugin started"}),e.jsx(dt,{status:L.configured,enabledText:"Configured",tooltipText:"Whether the plugin has been configured"})]})})})})}];o.useEffect(()=>{const O=H=>{r&&console.log("HomePlugins received WebSocket Message:",H),H.method==="refresh_required"&&H.response.changed==="plugins"?(r&&console.log(`HomePlugins received refresh_required: changed=${H.response.changed} and sending /api/plugins request`),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):H.method==="refresh_required"&&H.response.changed==="matter"?(r&&console.log(`HomePlugins received refresh_required: changed=${H.response.changed} and setting matter id ${H.response.matter?.id}`),q(L=>{const pe=L.findIndex(T=>T.matter?.id===H.response.matter?.id);if(pe<0)return r&&console.log(`HomePlugins received refresh_required: changed=${H.response.changed} and matter id ${H.response.matter?.id} not found`),L;r&&console.log(`HomePlugins received refresh_required: changed=${H.response.changed} set matter id ${H.response.matter?.id}`);const Se=[...L];return Se[pe]={...Se[pe],matter:H.response.matter},Se})):H.method==="refresh_required"&&H.response.changed==="settings"&&(r&&console.log(`HomePlugins received refresh_required: changed=${H.response.changed} and sending /api/settings request`),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})),H.id===t.current&&H.method==="/api/settings"?(r&&console.log(`HomePlugins (id: ${H.id}) received settings:`,H.response),k(H.response.systemInformation),S(H.response.matterbridgeInformation)):H.id===t.current&&H.method==="/api/plugins"&&(r&&console.log(`HomePlugins (id: ${H.id}) received ${H.response.length} plugins:`,H.response),q(H.response))};return s(O,t.current),r&&console.log("HomePlugins added WebSocket listener id:",t.current),()=>{g(O),r&&console.log("HomePlugins removed WebSocket listener")}},[s,g,i]),o.useEffect(()=>{l&&(r&&console.log("HomePlugins sending api requests"),i({id:t.current,sender:"HomePlugins",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:t.current,sender:"HomePlugins",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const U=o.useRef(null),f=(O,H,L,pe)=>{r&&console.log(`handleActionWithConfirmCancel ${L} ${pe.name}`),U.current=pe,x(O,H,L,p,u)},p=O=>{r&&console.log(`handleConfirm action confirmed ${O} ${U.current?.name}`),O==="remove"&&U.current?W(U.current):O==="disable"&&U.current&&le(U.current),U.current=null},u=O=>{r&&console.log(`handleCancel action canceled ${O} ${U.current?.name}`),U.current=null},M=O=>{r&&console.log("handleUpdatePlugin plugin:",O.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:O.name,restart:!1}})},I=O=>{r&&console.log("handleUpdateDevPlugin plugin:",O.name),i({id:t.current,sender:"HomePlugins",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:O.name+"@dev",restart:!1}})},W=O=>{r&&console.log("handleRemovePlugin plugin:",O.name),i({id:t.current,sender:"HomePlugins",method:"/api/removeplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:O.name}})},te=O=>{r&&console.log("handleRestartPlugin plugin:",O.name),i({id:t.current,sender:"HomePlugins",method:"/api/restartplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:O.name}})},le=O=>{r&&console.log("handleEnableDisablePlugin plugin:",O.name,"enabled:",O.enabled),O.enabled===!0?(O.enabled=!1,i({id:t.current,sender:"HomePlugins",method:"/api/disableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:O.name}})):(O.enabled=!0,i({id:t.current,sender:"HomePlugins",method:"/api/enableplugin",src:"Frontend",dst:"Matterbridge",params:{pluginName:O.name}}))},j=O=>{r&&console.log(`handleHomepagePlugin plugin: ${O.name} homepage: ${O.homepage}`),O.homepage&&window.open(O.homepage,"_blank")},d=O=>{r&&console.log("handleSponsorPlugin plugin:",O.name,"funding:",O.funding),O.funding&&window.open(O.funding,"_blank")},c=O=>{r&&console.log("handleHelpPlugin plugin:",O.name,"help:",O.help),O.help&&window.open(O.help,"_blank")},v=O=>{r&&console.log("handleChangelogPlugin plugin:",O.name,"changelog:",O.changelog),O.changelog&&window.open(O.changelog,"_blank")},[C,b]=o.useState(),[B,ee]=o.useState(!1),Me=O=>{r&&console.log("handleConfigPlugin plugin:",O.name),i({id:t.current,sender:"HomePlugins",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:O.name}}),i({id:t.current,sender:"HomePlugins",method:"/api/select/entities",src:"Frontend",dst:"Matterbridge",params:{plugin:O.name}}),b(O),F()},F=()=>{ee(!0)},V=()=>{ee(!1)};return r&&console.log("HomePlugins rendering..."),l?e.jsxs(Ie,{children:[C&&e.jsx(Qn,{open:B,onClose:V,plugin:C}),e.jsx(It,{name:"Plugins",columns:Y,rows:z,footerRight:"",footerLeft:""})]}):e.jsx(Ge,{})}const Kn=o.memo(Gn),Jn=n=>`${n.pluginName}::${n.serial}`;function Yn({storeId:n,setStoreId:a}){const{online:l,sendMessage:i,addListener:s,removeListener:g,getUniqueId:h}=o.useContext(ke),[x,t]=o.useState(!1),[$,k]=o.useState(!0),[P,S]=o.useState(null),[z,q]=o.useState([]),[Y,U]=o.useState([]),[f,p]=o.useState([]),[u,M]=o.useState([]),I=o.useRef(h()),W=[{label:"Plugin",id:"pluginName"},{label:"Name",id:"name",required:!0},{label:"Serial",id:"serial"},{label:"Availability",id:"availability",render:(j,d,c,v)=>c.reachable===!0?"Online":c.reachable===!1?e.jsx("span",{style:{color:"red"},children:"Offline"}):"",comparator:(j,d)=>{const c=j.reachable===!0?1:j.reachable===!1?0:-1,v=d.reachable===!0?1:d.reachable===!1?0:-1;return c-v}},{label:"Power",id:"powerSource",render:(j,d,c,v)=>c.powerSource==="ac"||c.powerSource==="dc"?e.jsx($o,{fontSize:"small",sx:{color:"var(--primary-color)"}}):c.powerSource==="ok"?c.batteryLevel?e.jsx(E,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(rt,{fontSize:"small",sx:{color:"green"}})}):e.jsx(rt,{fontSize:"small",sx:{color:"gray"}}):c.powerSource==="warning"?c.batteryLevel?e.jsx(E,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(rt,{fontSize:"small",sx:{color:"yellow"}})}):e.jsx(rt,{fontSize:"small",sx:{color:"yellow"}}):c.powerSource==="critical"?c.batteryLevel?e.jsx(E,{title:`Battery level: ${c.batteryLevel}%`,children:e.jsx(rt,{fontSize:"small",sx:{color:"red"}})}):e.jsx(rt,{fontSize:"small",sx:{color:"red"}}):e.jsx("span",{})},{label:"Actions",id:"selected",required:!0,render:(j,d,c,v)=>e.jsxs("div",{style:{display:"flex",flexDirection:"row"},children:[c.matter!==void 0?e.jsx(E,{title:"Show the QRCode or the fabrics",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{onClick:()=>a(n===c.matter?.id?P?.matterbridgeInformation.bridgeMode==="bridge"?"Matterbridge":null:c.matter?.id||null),"aria-label":"Show the QRCode",sx:{margin:0,padding:0,color:Ho(c.matter)},children:e.jsx(Lo,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),c.configUrl?e.jsx(E,{title:"Open the configuration page",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(X,{onClick:()=>window.open(c.configUrl,"_blank"),"aria-label":"Open config url",sx:{margin:0,padding:0},children:e.jsx(Wo,{fontSize:"small"})})}):e.jsx("div",{style:{width:"20px",height:"20px"}}),c.selected!==void 0?e.jsx(E,{title:"Select/unselect the device",slotProps:{popper:{modifiers:[{name:"offset",options:{offset:[30,15]}}]}},children:e.jsx(Ze,{checked:c.selected,onChange:C=>le(C,c),sx:{margin:"0",marginLeft:"8px",padding:"0"},size:"small"})}):e.jsx("div",{style:{width:"20px",height:"20px"}})]})}],te=o.useCallback(j=>{j.selected=void 0;const d=z.find(C=>C.name===j.pluginName);if(!d)return console.error(`HomeDevices isSelected: plugin ${j.pluginName} not found for device ${j.name} `),j.selected;const c=d.schemaJson?.properties?.whiteList?.selectFrom;let v=d.configJson.postfix;return v===""&&(v=void 0),d.hasWhiteList===!0&&d.hasBlackList===!0&&c&&(j.selected=!0,c==="serial"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&d.configJson.whiteList.includes(v?j.serial.replace("-"+v,""):j.serial)&&(j.selected=!0),c==="serial"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&!d.configJson.whiteList.includes(v?j.serial.replace("-"+v,""):j.serial)&&(j.selected=!1),c==="serial"&&d.configJson.blackList&&d.configJson.blackList.length>0&&d.configJson.blackList.includes(v?j.serial.replace("-"+v,""):j.serial)&&(j.selected=!1),c==="name"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&d.configJson.whiteList.includes(j.name)&&(j.selected=!0),c==="name"&&d.configJson.whiteList&&d.configJson.whiteList.length>0&&!d.configJson.whiteList.includes(j.name)&&(j.selected=!1),c==="name"&&d.configJson.blackList&&d.configJson.blackList.length>0&&d.configJson.blackList.includes(j.name)&&(j.selected=!1)),j.selected},[z]);o.useEffect(()=>{const j=d=>{if(r&&console.log("HomeDevices received WebSocket Message:",d),d.method==="refresh_required"&&d.response.changed!=="matter"?(r&&console.log(`HomeDevices received refresh_required: changed=${d.response.changed} and sending /api/plugins request`),i({id:I.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})):d.method==="refresh_required"&&d.response.changed==="matter"?(r&&console.log(`HomeDevices received refresh_required: changed=${d.response.changed} and setting matter id ${d.response.matter?.id}`),M(c=>{const v=c.findIndex(b=>b.name.replaceAll(" ","")===d.response.matter?.id);if(v<0)return r&&console.debug(`HomeDevices: matter id ${d.response.matter?.id} not found`),c;const C=[...c];return C[v]={...C[v],matter:d.response.matter},r&&console.log(`HomeDevices received refresh_required: changed=${d.response.changed} and set matter id ${d.response.matter?.id}`),C})):d.method==="restart_required"?(r&&console.log("HomeDevices received restart_required"),t(!0)):d.method==="restart_not_required"?(r&&console.log("HomeDevices received restart_not_required"),t(!1)):d.method==="state_update"&&d.response.plugin&&d.response.serialNumber&&d.response.cluster.includes("BasicInformation")&&d.response.attribute==="reachable"&&(r&&console.log(`HomeDevices updating device reachability for plugin ${d.response.plugin} serial ${d.response.serialNumber} value ${d.response.value}`),U(c=>{const v=c.findIndex(C=>C.pluginName===d.response.plugin&&C.serial===d.response.serialNumber);return v<0?(r&&console.warn(`HomeDevices: device to update not found for plugin ${d.response.plugin} serial ${d.response.serialNumber}`),c):(c[v]={...c[v],reachable:d.response.value},[...c])})),d.id===I.current&&d.method==="/api/settings")r&&console.log(`HomeDevices (id: ${d.id}) received settings:`,d.response),S(d.response),t(d.response.matterbridgeInformation.restartRequired||d.response.matterbridgeInformation.fixedRestartRequired);else if(d.id===I.current&&d.method==="/api/plugins"){if(r&&console.log(`HomeDevices (id: ${d.id}) received ${d.response?.length} plugins:`,d.response),d.response){let c=!0;for(const v of d.response)v.enabled===!0&&(v.loaded!==!0||v.started!==!0||v.error===!0)&&(c=!1);if(!c)return;r&&console.log("HomeDevices reset plugins, devices and selectDevices"),k(!1),q(d.response),U([]),p([]),i({id:I.current,sender:"HomeDevices",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}),r&&console.log("HomeDevices sent /api/devices");for(const v of d.response)v.enabled===!0&&v.loaded===!0&&v.started===!0&&v.error!==!0&&(i({id:I.current,sender:"HomeDevices",method:"/api/select/devices",src:"Frontend",dst:"Matterbridge",params:{plugin:v.name}}),r&&console.log(`HomeDevices sent /api/select/devices for plugin: ${v.name}`))}}else if(d.id===I.current&&d.method==="/api/devices"){if(r&&console.log(`HomeDevices (id: ${d.id}) received ${d.response?.length} devices:`,d.response),d.response){for(const c of d.response)c.selected=te(c);U(d.response)}}else d.id===I.current&&d.method==="/api/select/devices"&&(r&&console.log(`HomeDevices (id: ${d.id}) received ${d.response?.length} selectDevices for plugin ${d.response&&d.response.length>0?d.response[0].pluginName:"without select devices"}:`,d.response),d.response&&d.response.length>0&&p(c=>{const v=c.filter(b=>b.pluginName!==d.response[0].pluginName),C=d.response.map(b=>({...b,selected:te(b)}));return[...v,...C]}))};return s(j,I.current),r&&console.log(`HomeDevices added WebSocket listener id ${I.current}`),()=>{g(j),r&&console.log("HomeDevices removed WebSocket listener")}},[z,s,g,i,te]),o.useEffect(()=>{if(Y.length===0&&f.length===0){M([]);return}r&&console.log(`HomeDevices mixing devices (${Y.length}) and selectDevices (${f.length})`);const j=[];for(const d of Y)j.push(d);for(const d of f)Y.find(c=>c.pluginName===d.pluginName&&c.serial.includes(d.serial))||j.push(d);j.length>0&&(M(j),r&&console.log(`HomeDevices mixed ${j.length} devices and selectDevices`))},[z,Y,f,M]),o.useEffect(()=>{l&&(r&&console.log("HomeDevices sending /api/settings and /api/plugins requests"),i({id:I.current,sender:"HomeDevices",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),i({id:I.current,sender:"HomeDevices",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[l,i]);const le=(j,d)=>{r&&console.log(`handleCheckboxChange: checkbox changed to ${j.target.checked} for device ${d.name} serial ${d.serial}`),Y.findIndex(c=>c.pluginName===d.pluginName&&c.serial===d.serial)<0?(r&&console.warn(`handleCheckboxChange: device ${d.name} serial ${d.serial} not found in devices, trying in mixedDevices`),M(c=>{const v=c.findIndex(C=>C.pluginName===d.pluginName&&C.serial===d.serial);return v<0?(console.error(`handleCheckboxChange: device ${d.name} serial ${d.serial} not found in mixedDevices`),c):(c[v]={...c[v],selected:j.target.checked},[...c])})):U(c=>{const v=c.findIndex(C=>C.pluginName===d.pluginName&&C.serial===d.serial);return v<0?(console.error(`handleCheckboxChange: device ${d.name} serial ${d.serial} not found in devices`),c):(c[v]={...c[v],selected:j.target.checked},[...c])}),j.target.checked?i({id:I.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"selectdevice",plugin:d.pluginName,serial:d.serial,name:d.name}}):i({id:I.current,sender:"HomeDevices",method:"/api/command",src:"Frontend",dst:"Matterbridge",params:{command:"unselectdevice",plugin:d.pluginName,serial:d.serial,name:d.name}})};return r&&console.log("HomeDevices rendering..."),l?e.jsx(Ie,{style:{flex:"1 1 auto"},children:e.jsx(It,{name:"Devices",getRowKey:Jn,rows:u,columns:W,footerLeft:$?"Waiting for the plugins to fully load...":`Registered devices: ${Y.length.toString()}/${u.length.toString()}`,footerRight:x?"Restart required":""})}):e.jsx(Ge,{})}const Zn=o.memo(Yn);function Mt({children:n,style:a,name:l}){const{setCurrentPage:i}=o.useContext(Re);i(l),r&&console.log(`MbfPage: current page set to ${l}`);const s={display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"20px"};return e.jsx("div",{style:{...s,...a},children:n})}const Xn=()=>"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 ei(){const{messages:n,logAutoScroll:a}=o.useContext(Ro),[l,i]=o.useState(!1),s=o.useRef(null),g=o.useRef(0),h=o.useRef(null),x=o.useMemo(()=>Xn(),[]),t=S=>i(!0),$=S=>i(!1);o.useEffect(()=>{if(r&&console.log(`WebSocketLogs logAutoScroll: ${a.current} isHovering: ${l}`),a.current&&!l&&!x){const S=Date.now();S-g.current>=500?(r&&console.log("WebSocketLogs auto-scroll to bottom"),g.current=S,s.current?.scrollIntoView({behavior:"smooth",block:"end"})):(r&&console.log("WebSocketLogs auto-scroll skipped to avoid flicker"),h.current&&clearTimeout(h.current),h.current=setTimeout(()=>{s.current?.scrollIntoView({behavior:"smooth"}),g.current=Date.now()},1e3))}},[n,a,l,x]);const k=S=>{switch(S.toLowerCase()){case"debug":return"gray";case"info":return"#267fb7";case"notice":return"green";case"warn":return"#e9db18";case"error":return"red";case"fatal":return"#ff0000";case"spawn":return"#ff00d0";default:return"#5c0e91"}},P=S=>S.toLowerCase()==="warn"?"black":"white";return e.jsx("div",{style:{margin:"0px",padding:"0px"},children:e.jsxs("ul",{style:{margin:"0px",padding:"0px"},onMouseEnter:t,onMouseLeave:$,children:[n.map((S,z)=>e.jsxs("li",{style:{wordWrap:"break-word",maxHeight:"200px",overflow:"hidden"},children:[e.jsx("span",{style:{marginRight:"5px",padding:"1px 5px",backgroundColor:k(S.level),color:P(S.level),fontSize:"12px",borderRadius:"3px",textAlign:"center"},children:S.level}),S.time&&e.jsx("span",{style:{marginRight:"3px",color:"#505050"},children:"["+S.time+"]"}),S.name&&e.jsx("span",{style:{marginRight:"3px",color:"#09516d"},children:"["+S.name+"]"}),e.jsx("span",{style:{color:"var(--main-log-color)"},children:S.message})]},z)),e.jsx("div",{ref:s})]})})}const Eo=o.memo(ei);function ti(){const[n,a]=o.useState(localStorage.getItem(oe.logFilterLevel)??"info"),[l,i]=o.useState(localStorage.getItem(oe.logFilterSearch)??"*"),{online:s,logAutoScroll:g}=o.useContext(ke);return r&&console.log("HomeLogs rendering..."),s?e.jsxs(Ie,{style:{flex:"1 1 auto"},children:[e.jsxs(Te,{children:[e.jsx(Pe,{children:"Logs"}),e.jsxs(Pe,{style:{fontWeight:"normal",fontSize:"12px",marginTop:"2px"},children:['Filter: logger level "',n,'" and search "',l===""?"*":l,'" Scroll: ',g.current?"auto":"manual"]})]}),e.jsx(Ve,{style:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"10px",alignItems:"start"},children:e.jsx(Eo,{})})]}):e.jsx(Ge,{})}const oi=o.memo(ti);function ri(){const{online:n}=o.useContext(ke);return r&&console.log("HomeBrowserRefresh rendering..."),n?e.jsxs(Ie,{children:[e.jsx(Te,{children:e.jsx(Pe,{children:"Frontend Update"})}),e.jsxs(Ve,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},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(ge,{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:"Refresh"})})]})]}):e.jsx(Ge,{})}const ni=o.memo(ri);function ii({changelog:n}){const{online:a}=o.useContext(ke);return r&&console.log("HomeShowChangelog rendering..."),a?e.jsxs(Ie,{children:[e.jsx(Te,{children:e.jsx(Pe,{children:"Matterbridge Update"})}),e.jsxs(Ve,{style:{flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center"},children:[e.jsx("h4",{style:{margin:0},children:"Matterbridge has been updated."}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(ge,{onClick:()=>window.open("https://github.com/Luligu/matterbridge","_blank"),endIcon:e.jsx(To,{style:{color:"#FFD700"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Star"}),e.jsx(ge,{onClick:()=>window.open("https://www.buymeacoffee.com/luligugithub","_blank"),endIcon:e.jsx(io,{style:{color:"#b6409c"}}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Sponsor"}),e.jsx(ge,{onClick:()=>window.open(n,"_blank"),endIcon:e.jsx(Bt,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Changelog"}),e.jsx(ge,{onClick:()=>window.location.reload(),endIcon:e.jsx(pr,{}),style:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)",height:"30px"},children:"Close"})]})]})]}):e.jsx(Ge,{})}const si=o.memo(ii);function li({matterbridgeInfo:n}){const{mobile:a}=o.useContext(Re);r&&console.log("MatterbridgeInfoTable:",n);const l=["matterbridgeLatestVersion","matterbridgeDevVersion","--matterFileLogger","--fileLogger","--matterLoggerLevel","--loggerLevel","--virtualMode","--bridgeMode","--restartMode","--restartRequired","fixedRestartRequired","--updateRequired","matterMdnsInterface","matterIpv4Address","matterIpv6Address","readOnly","shellyBoard","shellySysUpdate","shellyMainUpdate","matterPort","matterDiscriminator","matterPasscode"],[i,s]=o.useState(!1);return!n||i?null:(r&&console.log("MatterbridgeInfoTable rendering..."),e.jsxs(Ie,{style:we&&a?{flex:"1 1 300px"}:{flex:"0 1 auto",width:"302px",minWidth:"302px"},children:[e.jsxs(Te,{children:[e.jsx(Pe,{children:"Matterbridge info"}),e.jsx(it,{close:()=>s(!0)})]}),e.jsx(Ve,{style:we&&a?{flex:"1 1 auto",margin:"0px",padding:"0px",gap:"0px"}:{flex:"1 1 auto",overflow:"auto",margin:"0px",padding:"0px",gap:"0px"},children:e.jsxs("table",{style:{border:"none",borderCollapse:"collapse",tableLayout:"fixed"},children:[e.jsxs("colgroup",{children:[e.jsx("col",{style:{width:"40%"}}),e.jsx("col",{style:{width:"60%"}})]}),e.jsx("tbody",{style:{border:"none",borderCollapse:"collapse"},children:Object.entries(n).filter(([g,h])=>!l.includes(g)&&h!==null&&h!==void 0&&h!=="").map(([g,h],x)=>e.jsxs("tr",{className:x%2===0?"table-content-even":"table-content-odd",style:{border:"none",borderCollapse:"collapse"},children:[e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap"},children:g.replace("matterbridgeVersion","Matterbridge version").replace("matterbridgeLatestVersion","Matterbridge latest v.").replace("matterbridgeDevVersion","Matterbridge dev v.").replace("frontendVersion","Frontend version").replace("homeDirectory","Home").replace("rootDirectory","Root").replace("matterbridgeDirectory","Storage").replace("matterbridgeCertDirectory","Cert").replace("matterbridgePluginDirectory","Plugins").replace("globalModulesDirectory","Modules").replace("bridgeMode","Bridge mode").replace("restartMode","Restart mode").replace("virtualMode","Virtual mode").replace("profile","Profile").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("loggerLevel","Logger level").replace("fileLogger","File logger").replace("matterLoggerLevel","Matter logger level").replace("matterFileLogger","Matter file logger").replace("restartRequired","Restart required").replace("updateRequired","Update required")}),e.jsx("td",{style:{border:"none",borderCollapse:"collapse",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:we&&a?typeof h!="string"?h.toString():h:e.jsx(Oo,{value:typeof h!="string"?h.toString():h,maxChars:24})})]},g))})]})})]}))}const ai=o.memo(li);function ci(){const[n,a]=o.useState(null),[l,i]=o.useState(null),[s,g]=o.useState([]),[h]=o.useState(localStorage.getItem(oe.homePagePlugins)!=="false"),[x,t]=o.useState(localStorage.getItem(oe.homePageMode)??"devices"),[$,k]=o.useState(""),[P,S]=o.useState(!1),[z,q]=o.useState(!1),[Y,U]=o.useState(null),{mobile:f}=o.useContext(Re),{addListener:p,removeListener:u,online:M,sendMessage:I,getUniqueId:W}=o.useContext(ke),te=o.useRef(W());return o.useEffect(()=>{const le=j=>{r&&console.log("Home received WebSocket Message:",j),j.method==="refresh_required"&&j.response.changed==="settings"&&(r&&console.log(`Home received refresh_required: changed=${j.response.changed} and sending /api/settings request`),U(null),g([]),I({id:te.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),I({id:te.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}})),j.method==="/api/settings"&&j.id===te.current&&(r&&console.log("Home received settings:",j.response),a(j.response.systemInformation),i(j.response.matterbridgeInformation),j.response.matterbridgeInformation.matterbridgeVersion&&k(`https://github.com/Luligu/matterbridge/blob/${j.response.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"dev":"main"}/CHANGELOG.md`),localStorage.getItem(oe.frontendVersion)===null&&j.response.matterbridgeInformation.frontendVersion?localStorage.setItem(oe.frontendVersion,j.response.matterbridgeInformation.frontendVersion):j.response.matterbridgeInformation.frontendVersion!==localStorage.getItem(oe.frontendVersion)&&j.response.matterbridgeInformation.frontendVersion&&(localStorage.setItem(oe.frontendVersion,j.response.matterbridgeInformation.frontendVersion),q(!0)),localStorage.getItem(oe.matterbridgeVersion)===null?localStorage.setItem(oe.matterbridgeVersion,j.response.matterbridgeInformation.matterbridgeVersion):j.response.matterbridgeInformation.matterbridgeVersion!==localStorage.getItem(oe.matterbridgeVersion)&&(localStorage.setItem(oe.matterbridgeVersion,j.response.matterbridgeInformation.matterbridgeVersion),S(!0)),j.response.matterbridgeInformation.shellyBoard&&(localStorage.getItem(oe.homePageMode)||(localStorage.setItem(oe.homePageMode,"devices"),t("devices")))),j.method==="/api/plugins"&&j.id===te.current&&(r&&console.log("Home received plugins:",j.response),g(j.response))};return p(le,te.current),r&&console.log(`Home added WebSocket listener id ${te.current}`),()=>{u(le),r&&console.log("Home removed WebSocket listener")}},[p,u,I]),o.useEffect(()=>{if(r&&console.log(`Home storeId effect with storeId ${Y}`),l?.bridgeMode==="bridge"&&!Y&&(r&&console.log("Home storeId effect set storeId to Matterbridge"),U("Matterbridge")),l?.bridgeMode==="childbridge"&&!Y&&s){for(const le of s)if(le.matter?.id){r&&console.log(`Home storeId effect set storeId to ${le.matter.id}`),U(le.matter.id);break}}},[l,s,Y]),o.useEffect(()=>{M&&(r&&console.log("Home online effect, sending /api/settings and /api/plugins requests"),I({id:te.current,sender:"Home",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),I({id:te.current,sender:"Home",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}))},[M,I]),r&&console.log("Home rendering..."),!M||!n||!l?e.jsx(Ge,{}):e.jsxs(Mt,{name:"Home",style:we&&f?{alignItems:"center",gap:"10px"}:{flexDirection:"row"},children:[(we&&!f||!we)&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"302px",minWidth:"302px",gap:"20px"},children:[e.jsx(yo,{id:Y}),e.jsx(bo,{systemInfo:n,compact:!0})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",gap:we&&f?"10px":"20px"},children:[z&&e.jsx(ni,{}),P&&e.jsx(si,{changelog:$}),we&&f&&e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:"10px"},children:[e.jsx(yo,{id:Y}),e.jsx(bo,{systemInfo:n,compact:!0}),e.jsx(ai,{matterbridgeInfo:l})]}),h&&!l.readOnly&&e.jsx(Un,{}),h&&e.jsx(Kn,{storeId:Y,setStoreId:U}),x==="devices"&&e.jsx(Zn,{storeId:Y,setStoreId:U}),x==="logs"&&e.jsx(oi,{})]})]})}const di=o.memo(ci),Et=!1,Co={display:"flex",gap:"2px",justifyContent:"space-evenly",width:"100%",height:"40px"},pi={margin:"0",padding:"0",fontSize:"36px",fontWeight:"medium",color:"var(--primary-color)"},ui={margin:"0",padding:"0",fontSize:"20px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},So={margin:"0",padding:"0",paddingBottom:"2px",fontSize:"16px",fontWeight:"medium",color:"var(--div-text-color)",textAlign:"center"},gi={display:"flex",gap:"2px",justifyContent:"center",width:"100%",height:"18px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},hi={margin:"0",padding:"0",fontSize:"12px",fontWeight:"normal",color:"var(--div-text-color)"},mi={display:"flex",justifyContent:"center",width:"100%",height:"52px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},fi={margin:"0",padding:"0",fontSize:"14px",fontWeight:"bold",color:"var(--div-text-color)"},xi={display:"flex",gap:"4px",justifyContent:"center",width:"100%",height:"15px",margin:"0",padding:"0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"normal"},eo={margin:"0",padding:"0px 4px",borderRadius:"5px",textAlign:"center",fontSize:"12px",fontWeight:"normal",color:"var(--secondary-color)"},bi=[256,257,268,269],vi=[266,267],yi=[259,260,261,271,272],ji=[256,257,268,269,266,267,259,260,261,272];function ne({icon:n,iconColor:a,cluster:l,value:i,unit:s,prefix:g}){return r&&console.log(`Render cluster "${l.clusterName}.${l.attributeName}" value(${typeof i}-${isNaN(i)}) "${i}" unit "${s}"`),g=g??!1,e.jsxs(he,{sx:Co,children:[n&&o.cloneElement(n,{key:`${l.clusterId}-${l.attributeId}-icon`,sx:{...pi,color:a??"var(--primary-color)"}}),e.jsxs(he,{sx:{...Co,gap:"4px",alignContent:"center",alignItems:"end",justifyContent:"center"},children:[s&&g===!0&&e.jsx(ye,{sx:So,children:s},`${l.clusterId}-${l.attributeId}-unit`),e.jsx(ye,{sx:ui,children:i==null||typeof i=="number"&&isNaN(i)||i==="NaN"?"---":i},`${l.clusterId}-${l.attributeId}-value`),s&&g===!1&&e.jsx(ye,{sx:So,children:s},`${l.clusterId}-${l.attributeId}-unit`)]},`${l.clusterId}-${l.attributeId}-valueunitbox`)]},`${l.clusterId}-${l.attributeId}-box`)}function wi({device:n,endpoint:a,id:l,deviceType:i,clusters:s}){const g=["Unknown","Good","Fair","Moderate","Poor","VeryPoor","Ext.Poor"];let h="";r&&console.log(`Device "${n.name}" endpoint "${a}" id "${l}" deviceType "0x${i.toString(16).padStart(4,"0")}" clusters (${s?.length})`);const x=s.find(t=>t.clusterName==="Descriptor"&&t.attributeName==="tagList")?.attributeLocalValue;if(x){let t="";x.map($=>{$.label&&(t+=$.label+" ")}),h=t.trim()}if(i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batVoltage").map(t=>h=`${t.attributeLocalValue} mV`),ji.includes(i)&&s.filter(t=>t.clusterName==="LevelControl"&&t.attributeName==="currentLevel").map(t=>h=`Level ${t.attributeValue}`),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>h=`Position ${t.attributeLocalValue/100}%`),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedHeatingSetpoint").map(t=>h=`Heat ${t.attributeLocalValue/100}°C `),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="occupiedCoolingSetpoint").map(t=>h=h+`Cool ${t.attributeLocalValue/100}°C`),i===118&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>h=`${t.attributeLocalValue===0?"No CO detected":"CO alarm!"}`),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="voltage").map(t=>h=`${t.attributeLocalValue/1e3} V, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activeCurrent").map(t=>h=h+`${t.attributeLocalValue/1e3} A, `),i===1296&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="activePower").map(t=>h=h+`${t.attributeLocalValue/1e3} W`),i===39){const t=s.find(k=>k.clusterName==="ModeSelect"&&k.attributeName==="currentMode")?.attributeLocalValue;h=s.find(k=>k.clusterName==="ModeSelect"&&k.attributeName==="supportedModes")?.attributeLocalValue?.find(k=>k.mode===t)?.label||"Unknown"}if(i===116){const t=s.find(k=>k.clusterName==="RvcRunMode"&&k.attributeName==="currentMode")?.attributeLocalValue;h=s.find(k=>k.clusterName==="RvcRunMode"&&k.attributeName==="supportedModes")?.attributeLocalValue?.find(k=>k.mode===t)?.label||"Unknown"}return e.jsxs(Ie,{style:{margin:"0px",padding:"5px",width:"150px",height:"150px",borderColor:"var(--div-bg-color)",borderRadius:"5px",justifyContent:"space-between"},children:[i===19&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(ne,{icon:t.attributeLocalValue===!0?e.jsx(Ct,{}):e.jsx(ur,{}),iconColor:t.attributeLocalValue===!0?"green":"red",cluster:t,value:t.attributeLocalValue===!0?"Online":"Offline"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="batPercentRemaining").map(t=>e.jsx(ne,{icon:e.jsx(rt,{}),cluster:t,value:t.attributeLocalValue/2,unit:"%"})),i===17&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="wiredCurrentType").map(t=>e.jsx(ne,{icon:e.jsx($o,{}),cluster:t,value:t.attributeLocalValue===0?"AC":"DC"})),i===1293&&s.filter(t=>t.clusterName==="DeviceEnergyManagement"&&t.attributeName==="esaState").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:Qr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Offline":"Online"})),bi.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(ne,{icon:e.jsx(gr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),vi.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:Gr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),yi.includes(i)&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:Kr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===115&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:Jr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===124&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:Yr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===117&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:Zr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===123&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(ne,{icon:e.jsx(uo,{}),cluster:t,value:"Oven"})),i===112&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(ne,{icon:e.jsx(hr,{}),cluster:t,value:"Fridge"})),i===113&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:Xr,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===121&&s.filter(t=>t.clusterName==="OperationalState"&&t.attributeName==="operationalState").map(t=>e.jsx(ne,{icon:e.jsx(uo,{}),cluster:t,value:t.attributeLocalValue===0?"Normal":"Error"})),i===122&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="fanMode").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:en,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===120&&s.filter(t=>t.clusterName==="BridgedDeviceBasicInformation"&&t.attributeName==="reachable").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Cooktop"})),i===119&&s.filter(t=>t.clusterName==="TemperatureControl"&&t.attributeName==="selectedTemperatureLevel").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:fo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue,unit:"mode",prefix:!0})),i===514&&s.filter(t=>t.clusterName==="WindowCovering"&&t.attributeName==="currentPositionLiftPercent100ths").map(t=>e.jsx(ne,{icon:e.jsx(mr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===769&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:tn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===10&&s.filter(t=>t.clusterName==="DoorLock"&&t.attributeName==="lockState").map(t=>e.jsx(ne,{icon:t.attributeValue==="1"?e.jsx(fr,{}):e.jsx(xr,{}),cluster:t,value:t.attributeValue==="1"?"Locked":"Unlocked"})),i===43&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(ne,{icon:e.jsx(br,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===15&&s.filter(t=>t.clusterName==="Switch"&&t.attributeName==="currentPosition").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:on,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"pos",prefix:!0})),i===39&&s.filter(t=>t.clusterName==="ModeSelect"&&t.attributeName==="currentMode").map(t=>e.jsx(ne,{icon:e.jsx(vr,{}),cluster:t,value:t.attributeValue,unit:"Mode",prefix:!0})),i===771&&s.filter(t=>t.clusterName==="OnOff"&&t.attributeName==="onOff").map(t=>e.jsx(ne,{icon:e.jsx(yr,{}),cluster:t,value:t.attributeLocalValue===!0?"On":"Off"})),i===45&&s.filter(t=>t.clusterName==="FanControl"&&t.attributeName==="percentCurrent").map(t=>e.jsx(ne,{icon:e.jsx(go,{}),cluster:t,value:t.attributeValue,unit:"%"})),i===114&&s.filter(t=>t.clusterName==="Thermostat"&&t.attributeName==="localTemperature").map(t=>e.jsx(ne,{icon:e.jsx(go,{}),cluster:t,value:(t.attributeLocalValue??0)/100,unit:"°C"})),i===67&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(ne,{icon:e.jsx(jr,{}),cluster:t,value:t.attributeLocalValue===!0?"Leak":"No leak"})),i===65&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(ne,{icon:e.jsx(wr,{}),cluster:t,value:t.attributeLocalValue===!0?"Freeze":"No freeze"})),i===68&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(ne,{icon:e.jsx(Cr,{}),cluster:t,value:t.attributeLocalValue===!0?"Rain":"No rain"})),i===116&&s.filter(t=>t.clusterName==="RvcRunMode"&&t.attributeName==="currentMode").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:rn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeValue,unit:"Run mode",prefix:!0})),i===1292&&s.filter(t=>t.clusterName==="EnergyEvse"&&t.attributeName==="state").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:nn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"Free":"In use"})),i===1295&&s.filter(t=>t.clusterName==="WaterHeaterManagement"&&t.attributeName==="tankPercentage").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:sn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Tank "+(t.attributeLocalValue??0)+"%"})),i===777&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:ln,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"HeatPump"})),i===23&&s.filter(t=>t.clusterName==="PowerSource"&&t.attributeName==="featureMap").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:an,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Solar"})),i===24&&s.filter(t=>t.clusterName==="ElectricalPowerMeasurement"&&t.attributeName==="featureMap").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:cn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:"Inverter"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!0)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="smokeState").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No smoke":"Smoke!"})),i===118&&s.find(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="featureMap"&&t.attributeLocalValue.smokeAlarm===!1)&&s.filter(t=>t.clusterName==="SmokeCoAlarm"&&t.attributeName==="coState").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:xo,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue===0?"No Co":"Co!"})),i===66&&s.filter(t=>t.clusterName==="ValveConfigurationAndControl"&&t.attributeName==="currentState").map(t=>e.jsx(ne,{icon:e.jsx(Sr,{}),cluster:t,value:t.attributeLocalValue===0?"Closed":"Opened"})),i===44&&s.filter(t=>t.clusterName==="AirQuality"&&t.attributeName==="airQuality").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:dn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:g[t.attributeLocalValue??0]})),i===770&&s.filter(t=>t.clusterName==="TemperatureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(ne,{icon:e.jsx(kr,{}),cluster:t,value:t.attributeLocalValue/100,unit:"°C"})),i===775&&s.filter(t=>t.clusterName==="RelativeHumidityMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(ne,{icon:e.jsx(be,{path:pn,size:"40px",color:"var(--primary-color)"}),cluster:t,value:t.attributeLocalValue/100,unit:"%"})),i===774&&s.filter(t=>t.clusterName==="FlowMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(ne,{icon:e.jsx(Ir,{}),cluster:t,value:t.attributeLocalValue,unit:"l/h"})),i===773&&s.filter(t=>t.clusterName==="PressureMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(ne,{icon:e.jsx(Mr,{}),cluster:t,value:t.attributeLocalValue,unit:"hPa"})),i===21&&s.filter(t=>t.clusterName==="BooleanState"&&t.attributeName==="stateValue").map(t=>e.jsx(ne,{icon:t.attributeValue==="true"?e.jsx(Dr,{}):e.jsx(Pr,{}),cluster:t,value:t.attributeValue==="true"?"Closed":"Opened"})),i===263&&s.filter(t=>t.clusterName==="OccupancySensing"&&t.attributeName==="occupancy").map(t=>e.jsx(ne,{icon:t.attributeValue==="{ occupied: true }"?e.jsx(Lr,{}):e.jsx($r,{}),cluster:t,value:t.attributeValue==="{ occupied: true }"?"Occupied":"Unocc."})),i===262&&s.filter(t=>t.clusterName==="IlluminanceMeasurement"&&t.attributeName==="measuredValue").map(t=>e.jsx(ne,{icon:e.jsx(Wr,{}),cluster:t,value:Math.round(Math.pow(10,t.attributeLocalValue/1e4)),unit:"lx"})),i===1296&&s.filter(t=>t.clusterName==="ElectricalEnergyMeasurement"&&t.attributeName==="cumulativeEnergyImported").map(t=>e.jsx(ne,{icon:e.jsx(Tr,{}),cluster:t,value:Math.round(t.attributeLocalValue?.energy/1e6),unit:"kwh"})),e.jsx(he,{sx:gi,children:e.jsx(ye,{sx:hi,children:h})}),e.jsx(he,{sx:mi,children:e.jsx(ye,{sx:fi,children:n.name})}),e.jsxs(he,{sx:xi,children:[r&&e.jsx(ye,{sx:eo,children:a}),e.jsx(ye,{sx:eo,children:l}),r&&e.jsxs(ye,{sx:eo,children:["0x",i.toString(16).padStart(4,"0")]})]})]})}function Ci({filter:n}){const{online:a,sendMessage:l,addListener:i,removeListener:s,getUniqueId:g}=o.useContext(ke),[h,x]=o.useState([]),[t,$]=o.useState({}),[k,P]=o.useState({}),[S,z]=o.useState({}),q=o.useRef(g()),Y=o.useCallback(p=>{(r||Et)&&console.log(`DevicesIcons received state_update "${p.response.cluster}.${p.response.attribute}" for "${p.response.id}:${p.response.number}": "${p.response.value}"`,p.response);const u=h.find(I=>I.pluginName===p.response.plugin&&I.serial===p.response.serialNumber);if(!u){(r||Et)&&console.warn(`DevicesIcons updater device of plugin "${p.response.plugin}" serial "${p.response.serialNumber}" number "${p.response.number}" id "${p.response.id}" not found in devices(${h.length})`);return}const M=S[u.serial]?.find(I=>I.endpoint===p.response.number.toString()&&I.clusterName===p.response.cluster&&I.attributeName===p.response.attribute);if(!M){(r||Et)&&console.warn(`DevicesIcons updater device "${u.name}" serial "${u.serial}" cluster "${p.response.cluster}" attribute "${p.response.attribute}" not found in clusters(${S[u.serial]?.length})`);return}M.attributeValue=String(p.response.value),M.attributeLocalValue=p.response.value,z({...S}),(r||Et)&&console.log(`DevicesIcons updated "${M.clusterName}.${M.attributeName}" for device "${u.name}" serial "${u.serial}" to "${M.attributeValue}"`)},[S,h]),U=o.useCallback(p=>{if(r&&console.log(`DevicesIcons received for device "${p.response.deviceName}" serial "${p.response.serialNumber}" deviceTypes (${p.response.deviceTypes.length}) "${p.response.deviceTypes.join(",")}" clusters (${p.response.clusters.length}):`,p.response),p.response.clusters.length===0)return;const u=p.response.serialNumber;t[u]=[],k[u]=p.response.deviceTypes,S[u]=[];for(const M of p.response.clusters)t[u].find(I=>I.endpoint===M.endpoint)||t[u].push({endpoint:M.endpoint,id:M.id,deviceTypes:M.deviceTypes}),!["FixedLabel","Identify","Groups","PowerTopology"].includes(M.clusterName)&&S[u].push(M);$({...t}),P({...k}),z({...S}),r&&console.log(`DevicesIcons endpoints for "${u}":`,t[u]),r&&console.log(`DevicesIcons deviceTypes for "${u}":`,k[u]),r&&console.log(`DevicesIcons clusters for "${u}":`,S[u])},[S,k,t]);o.useEffect(()=>{const p=u=>{if(r&&console.log("DevicesIcons received WebSocket Message:",u),u.method==="refresh_required")r&&console.log(`DevicesIcons received refresh_required: changed=${u.response.changed} and sending api requests`),l({id:q.current,sender:"DevicesIcons",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(u.method==="state_update"&&u.response)Y(u);else if(u.method==="/api/devices"&&u.response){r&&console.log(`DevicesIcons received ${u.response.length} devices:`,u.response),x(u.response),$({}),P({}),z({});for(const M of u.response)r&&console.log("DevicesIcons sending /api/clusters"),l({id:q.current,sender:"DevicesIcons",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:M.pluginName,endpoint:M.endpoint||0}})}else u.method==="/api/clusters"&&u.response&&U(u)};return i(p,q.current),r&&console.log("DevicesIcons WebSocket effect mounted"),()=>{s(p),r&&console.log("DevicesIcons WebSocket effect unmounted")}},[h]),o.useEffect(()=>(r&&console.log("DevicesIcons useEffect online mounting"),a&&(r&&console.log("DevicesIcons useEffect online sending api requests"),l({id:q.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")}),[a,l]);const f=o.memo(wi);return r&&console.log("DevicesIcons rendering..."),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",paddingBottom:"5px",gap:"20px",width:"100%",overflow:"auto"},children:h.filter(p=>p.name.toLowerCase().includes(n)||p.serial.toLowerCase().includes(n)).map(p=>t[p.serial]&&t[p.serial].map(u=>u.deviceTypes.map(M=>e.jsx(f,{device:p,endpoint:u.endpoint,id:u.id,deviceType:M,clusters:S[p.serial].filter(I=>I.endpoint===u.endpoint)},`${p.pluginName}-${p.uniqueId}-${u.endpoint}-${u.id}-${M.toString()}`))))})}const Si=o.memo(Ci),ki=[{label:"Plugin name",id:"pluginName",required:!0},{label:"Device type",id:"type"},{label:"Endpoint",id:"endpoint",align:"right"},{label:"Name",id:"name",required:!0},{label:"Serial number",id:"serial"},{label:"Unique ID",id:"uniqueId"},{label:"Url",id:"configUrl"},{label:"Config",id:"configButton",noSort:!0,render:(n,a,l,i)=>l.configUrl?e.jsx(X,{onClick:()=>window.open(l.configUrl,"_blank"),"aria-label":"Open Config",sx:{margin:0,padding:0},children:e.jsx(Wo,{fontSize:"small"})}):null},{label:"Cluster",id:"cluster"}],Ii=[{label:"Endpoint",id:"endpoint",required:!0},{label:"Id",id:"id"},{label:"Device Types",id:"deviceTypes",render:(n,a,l,i)=>Array.isArray(n)?e.jsx(e.Fragment,{children:n.map(s=>`0x${s.toString(16).padStart(4,"0")}`).join(", ")}):e.jsx(e.Fragment,{children:n})},{label:"Cluster Name",id:"clusterName",required:!0},{label:"Cluster ID",id:"clusterId"},{label:"Attribute Name",id:"attributeName",required:!0},{label:"Attribute ID",id:"attributeId"},{label:"Attribute Value",id:"attributeValue",required:!0,maxWidth:350,tooltip:!0}],Mi=n=>`${n.pluginName}::${n.uniqueId}`,Di=n=>`${n.endpoint}::${n.clusterName}::${n.attributeName}`;function Pi({filter:n}){const{online:a,sendMessage:l,addListener:i,removeListener:s,getUniqueId:g}=o.useContext(ke),[h,x]=o.useState([]),[t,$]=o.useState(h),[k,P]=o.useState([]),[S,z]=o.useState(0),[q,Y]=o.useState(null),[U,f]=o.useState(null),[p,u]=o.useState(null),[M,I]=o.useState(null),W=o.useRef(g()),te=o.useRef(t),le=o.useCallback(d=>{r&&console.log(`DevicesTable received state_update "${d.response.cluster}.${d.response.attribute}" for "${d.response.id}:${d.response.number}": "${d.response.value}"`,d.response);const c=te.current.find(v=>v.pluginName===d.response.plugin&&v.uniqueId===d.response.uniqueId);if(!c){r&&console.warn(`DevicesTable updater device of plugin "${d.response.plugin}" serial "${d.response.serialNumber}" not found in filteredDevicesRef.current`);return}if(q&&U&&c.pluginName===q&&c.uniqueId===M&&d.response.number.toString()===U){const v=k.find(C=>C.endpoint===d.response.number.toString()&&C.clusterName===d.response.cluster&&C.attributeName===d.response.attribute);if(!v){r&&console.warn(`DevicesTable updater cluster ${d.response.cluster}.${d.response.attribute} for device "${c.name}" serial "${c.serial}" not found in clusters`);return}v.attributeValue=typeof d.response.value=="object"?JSON.stringify(d.response.value,void 0,1).replaceAll('"',""):String(d.response.value),v.attributeLocalValue=d.response.value,P([...k]),r&&console.log(`DevicesTable updated attribute ${v.clusterName}.${v.attributeName} for device "${c.name}" serial "${c.serial}" to "${v.attributeValue}"`)}},[k,U,q,M]);o.useEffect(()=>{const d=c=>{if(r&&console.log("DevicesTable received WebSocket Message:",c),c.method==="refresh_required"&&c.response.changed==="devices")r&&console.log(`DevicesTable received refresh_required: changed=${c.response.changed} and sending /api/devices request`),l({id:W.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}});else if(c.method==="state_update"&&c.response)le(c);else if(c.method==="/api/devices")r&&console.log(`DevicesTable received ${c.response.length} devices:`,c.response),x(c.response);else if(c.method==="/api/clusters"){r&&console.log(`DevicesTable received ${c.response.clusters.length} clusters for plugin ${c.response.plugin}:`,c.response),P(c.response.clusters);const v={};for(const C of c.response.clusters)r&&console.log("Cluster:",C.endpoint),v[C.endpoint]?v[C.endpoint]++:v[C.endpoint]=1;z(Object.keys(v).length)}};return i(d,W.current),r&&console.log("DevicesTable added WebSocket listener"),()=>{s(d),r&&console.log("DevicesTable removed WebSocket listener")}},[l,i,s,le]),o.useEffect(()=>{a&&(r&&console.log("DevicesTable sending api requests with id ",W.current),l({id:W.current,sender:"DevicesTable",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:W.current,sender:"DevicesTable",method:"/api/plugins",src:"Frontend",dst:"Matterbridge",params:{}}),l({id:W.current,sender:"DevicesTable",method:"/api/devices",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,l]),o.useEffect(()=>{q&&U&&(r&&console.log("DevicesTable sending /api/clusters"),l({id:W.current,sender:"DevicesTable",method:"/api/clusters",src:"Frontend",dst:"Matterbridge",params:{plugin:q,endpoint:Number(U)}}))},[q,U,l]),o.useEffect(()=>{if(n===""){$(h),te.current=h;return}const d=h.filter(c=>c.name.toLowerCase().includes(n)||c.serial.toLowerCase().includes(n));$(d),te.current=d},[h,n]);const j=d=>{if(d.uniqueId===M){I(null),Y(null),f(null),u(null);return}I(d.uniqueId),Y(d.pluginName),f(d.endpoint?d.endpoint.toString():null),u(d.name)};return r&&console.log("DevicesTable rendering..."),a?e.jsxs("div",{style:{display:"flex",flexDirection:"column",margin:"0px",padding:"0px",gap:"20px",width:"100%",overflow:"hidden"},children:[e.jsx(Ie,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",maxHeight:`${q&&U?"30%":"100%"}`,flex:"1 1 auto",overflow:"hidden"},children:e.jsx(It,{name:"Registered devices",getRowKey:Mi,onRowClick:j,rows:t,columns:ki,footerLeft:`Total devices: ${t.length.toString()}`})}),q&&U&&e.jsx(Ie,{style:{margin:"0px",padding:"0px",gap:"0px",width:"100%",height:"70%",maxHeight:"70%",flex:"1 1 auto",overflow:"hidden"},children:e.jsx(It,{name:"Clusters",title:p||"",getRowKey:Di,rows:k,columns:Ii,footerLeft:`Total child endpoints: ${S-1}`})})]}):e.jsx(Ge,{})}const Li=o.memo(Pi);function $i(){const{online:n}=o.useContext(ke),[a,l]=o.useState(""),[i,s]=o.useState("icon");o.useEffect(()=>{const x=localStorage.getItem(oe.devicesFilter);x&&l(x)},[]),o.useEffect(()=>{const x=localStorage.getItem(oe.devicesViewMode);x&&s(x)},[]);const g=x=>{l(x.target.value.toLowerCase()),localStorage.setItem(oe.devicesFilter,x.target.value.toLowerCase())},h=x=>{s(x),localStorage.setItem(oe.devicesViewMode,x)};return r&&console.log("Devices rendering..."),n?e.jsxs(Mt,{name:"Devices",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",padding:0,margin:0,gap:"20px",width:"100%"},children:[e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ye,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"Filter by:"}),e.jsx(Ce,{variant:"outlined",value:a,onChange:g,placeholder:"Enter the device name or serial",sx:{width:"260px"},InputProps:{style:{backgroundColor:"var(--main-bg-color)"}}})]}),e.jsxs(he,{sx:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(ye,{sx:{fontSize:"16px",fontWeight:"normal",color:"var(--div-text-color)",marginLeft:"5px",whiteSpace:"nowrap"},children:"View mode:"}),e.jsx(X,{onClick:()=>h("table"),"aria-label":"Table View",disabled:i==="table",children:e.jsx(E,{title:"Table View",children:e.jsx(Fr,{style:{color:i==="table"?"var(--main-icon-color)":"var(--primary-color)"}})})}),e.jsx(X,{onClick:()=>h("icon"),"aria-label":"Icon View",disabled:i==="icon",children:e.jsx(E,{title:"Icon View (beta)",children:e.jsx(Nr,{style:{color:i==="icon"?"var(--main-icon-color)":"var(--primary-color)"}})})})]})]}),i==="table"&&e.jsx(Li,{filter:a}),i==="icon"&&e.jsx(Si,{filter:a})]}):e.jsx(Ge,{})}const Wi=o.memo($i);function Ti(){const{logLength:n,logAutoScroll:a,setMessages:l,setLogFilterLevel:i,setLogFilterSearch:s,online:g,filterLogMessages:h}=o.useContext(ke),[x,t]=o.useState(localStorage.getItem(oe.logFilterLevel)??"info"),[$,k]=o.useState(localStorage.getItem(oe.logFilterSearch)??"*"),[P,S]=o.useState(n.current.toString()),[z,q]=o.useState(a.current),Y=M=>{const I=M.target.value;t(I),i(I),h(I,$),localStorage.setItem(oe.logFilterLevel,I),r&&console.log("handleLogFilterLevelChange called with value:",I)},U=M=>{const I=M.target.value;k(I),s(I),h(x,I),localStorage.setItem(oe.logFilterSearch,I),r&&console.log("handleLogFilterSearchChange called with value:",I)},f=M=>{const I=M.target.checked;q(I),a.current=I,h(x,$),localStorage.setItem(oe.logAutoScroll,I?"true":"false"),r&&console.log("handleAutoScrollChange called with value:",I)},p=M=>{const I=M.target.value;S(I),n.current=Number(I),localStorage.setItem(oe.logLength,I),r&&console.log("handleLogLengthChange called with value:",I)},u=()=>{r&&console.log("handleClearLogsClick called"),l([])};return r&&console.log("Logs rendering..."),g?e.jsxs(Mt,{name:"Logs",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",margin:"0px",padding:"0px",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx(Kt,{id:"select-level",style:{color:"var(--div-text-color)"},children:"Filter log by level:"}),e.jsxs(nt,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-level",id:"debug-level",value:x,onChange:Y,children:[e.jsx(R,{value:"debug",children:"Debug"}),e.jsx(R,{value:"info",children:"Info"}),e.jsx(R,{value:"notice",children:"Notice"}),e.jsx(R,{value:"warn",children:"Warn"}),e.jsx(R,{value:"error",children:"Error"}),e.jsx(R,{value:"fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"5px"},children:[e.jsx(Kt,{id:"search",style:{color:"var(--div-text-color)"},children:"Filter log by text:"}),e.jsx(E,{title:"Use /text/ for case-insensitive regex search",children:e.jsx(Ce,{style:{width:"210px"},size:"small",id:"logsearch",variant:"outlined",value:$,onChange:U,slotProps:{input:{style:{height:"30px",padding:"0 0px",backgroundColor:"var(--main-bg-color)"}}}})})]}),e.jsx(st,{control:e.jsx(Ze,{checked:z,onChange:f}),label:"Auto scroll",style:{color:"var(--div-text-color)"}})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsx(Kt,{id:"select-size-label",style:{color:"var(--div-text-color)"},children:"Log length:"}),e.jsxs(nt,{style:{height:"30px",backgroundColor:"var(--main-bg-color)"},labelId:"select-size-label",id:"select-size",value:P,onChange:p,children:[e.jsx(R,{value:100,children:"100"}),e.jsx(R,{value:200,children:"200"}),e.jsx(R,{value:500,children:"500"}),e.jsx(R,{value:1e3,children:"1000"})]}),e.jsx(E,{title:"Clear the logs",children:e.jsx(ge,{onClick:u,endIcon:e.jsx(oo,{}),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(Eo,{})})]}):e.jsx(Ge,{})}const Fi=o.memo(Ti),Ni=({open:n,ip:a,onClose:l,onSave:i})=>{const s=a?a.split(".").slice(0,3).join(".")+".1":"",[g,h]=o.useState("dhcp"),[x,t]=o.useState({ip:a??"",subnet:"255.255.255.0",gateway:s,dns:s}),$=S=>z=>{t({...x,[S]:z.target.value})},k=()=>{l()},P=()=>{i({type:g,...x}),l()};return e.jsxs(qe,{open:n,onClose:(S,z)=>{z==="backdropClick"||z==="escapeKeyDown"||l()},maxWidth:"sm",style:{maxWidth:"550px",margin:"auto"},children:[e.jsx(Be,{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(Qe,{dividers:!0,children:[e.jsxs(Fo,{component:"fieldset",fullWidth:!0,children:[e.jsx(We,{component:"legend",children:"Select IP Configuration"}),e.jsxs(No,{row:!0,value:g,onChange:S=>h(S.target.value),children:[e.jsx(st,{value:"dhcp",control:e.jsx(qt,{}),label:"DHCP"}),e.jsx(st,{value:"static",control:e.jsx(qt,{}),label:"Static"})]})]}),g==="static"&&e.jsxs(et,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(et,{size:6,children:e.jsx(Ce,{label:"IP Address",fullWidth:!0,value:x.ip,onChange:$("ip")})}),e.jsx(et,{size:6,children:e.jsx(Ce,{label:"Subnet Mask",fullWidth:!0,value:x.subnet,onChange:$("subnet")})}),e.jsx(et,{size:6,children:e.jsx(Ce,{label:"Gateway",fullWidth:!0,value:x.gateway,onChange:$("gateway")})}),e.jsx(et,{size:6,children:e.jsx(Ce,{label:"DNS Server",fullWidth:!0,value:x.dns,onChange:$("dns")})})]})]}),e.jsxs(Ye,{children:[e.jsx(ge,{onClick:k,children:"Cancel"}),e.jsx(ge,{variant:"contained",onClick:P,children:"Save"})]})]})},Ri=({open:n,onClose:a,onSave:l})=>{const[i,s]=o.useState(""),[g,h]=o.useState(""),x=z=>{s(z.target.value)},t=z=>{h(z.target.value)},$=i.length>0&&i===g,k=()=>{a()},P=()=>{$&&(l(i),a())},S=()=>{l(""),a()};return e.jsxs(qe,{open:n,onClose:(z,q)=>{q==="backdropClick"||q==="escapeKeyDown"||a()},maxWidth:"sm",style:{maxWidth:"500px",margin:"auto"},disableEscapeKeyDown:!0,children:[e.jsx(Be,{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(Qe,{dividers:!0,children:e.jsx(Fo,{component:"fieldset",fullWidth:!0,sx:{margin:0,padding:0,gap:"20px"},children:e.jsxs(et,{container:!0,spacing:2,sx:{mt:2},children:[e.jsx(et,{size:12,children:e.jsx(Ce,{type:"password",autoComplete:"new-password",label:"New Password",size:"small",variant:"outlined",fullWidth:!0,value:i,onChange:x})}),e.jsx(et,{size:12,children:e.jsx(Ce,{type:"password",autoComplete:"new-password",label:"Confirm Password",size:"small",variant:"outlined",fullWidth:!0,value:g,onChange:t,error:g!==""&&i!==g,helperText:g!==""&&i!==g?"Passwords do not match":""})})]})})}),e.jsxs(Ye,{children:[e.jsx(ge,{onClick:k,children:"Cancel"}),e.jsx(ge,{variant:"contained",onClick:P,disabled:!$,children:"Change"}),e.jsx(ge,{variant:"contained",onClick:S,children:"Reset"})]})]})};function ht(n=1e3){let a=null;const l=(i=>{a!==null&&window.clearTimeout(a),a=window.setTimeout(()=>{i(),a=null},n)});return l.cancel=()=>{a!==null&&(window.clearTimeout(a),a=null)},l}const Qt=330;function Oi(){const{mobile:n}=o.useContext(Re),{online:a,addListener:l,removeListener:i,sendMessage:s,getUniqueId:g}=o.useContext(ke),[h,x]=o.useState(null),[t,$]=o.useState(null),k=o.useRef(g());return o.useEffect(()=>{const P=S=>{r&&console.log("Settings received WebSocket Message:",S),S.method==="refresh_required"&&S.response.changed==="settings"?(r&&console.log(`Settings received refresh_required: changed=${S.response.changed} and sending /api/settings request`),s({id:k.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):S.method==="/api/settings"&&(r&&console.log("Settings received /api/settings:",S.response),x(S.response.matterbridgeInformation),$(S.response.systemInformation))};return l(P,k.current),r&&console.log("Settings added WebSocket listener"),()=>{i(P),r&&console.log("Settings removed WebSocket listener")}},[l,i,s]),o.useEffect(()=>{a&&(r&&console.log("Settings received online"),s({id:k.current,sender:"Settings",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}))},[a,s]),r&&console.log("Settings rendering..."),!a||!h||!t?e.jsx(Ge,{}):e.jsx(Mt,{name:"Settings",children:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",gap:we&&n?"10px":"20px"},children:[e.jsx(_i,{matterbridgeInfo:h,systemInfo:t}),e.jsx(Hi,{matterbridgeInfo:h}),e.jsx(Ei,{matterbridgeInfo:h}),e.jsx(Ai,{systemInfo:t})]})})}function _i({matterbridgeInfo:n,systemInfo:a}){const{sendMessage:l,getUniqueId:i}=o.useContext(ke),[s,g]=o.useState("bridge"),[h,x]=o.useState("Info"),[t,$]=o.useState(!1),[k,P]=o.useState("dark"),[S,z]=o.useState(localStorage.getItem(oe.homePagePlugins)!=="false"),[q,Y]=o.useState(localStorage.getItem(oe.homePageMode)??"devices"),[U,f]=o.useState(localStorage.getItem(oe.virtualMode)??"outlet"),p=o.useRef(i()),[u,M]=o.useState(!1),I=()=>M(!1),W=F=>{r&&console.log("handleSaveNetConfig called with config:",F),l({id:p.current,sender:"Settings",method:"/api/shellynetconfig",src:"Frontend",dst:"Matterbridge",params:F})},[te,le]=o.useState(!1),j=()=>le(!1),d=F=>{r&&console.log("handleSaveChangePassword called with password:",F),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setpassword",value:F}}),Xi(F)};o.useEffect(()=>{n&&(g(n.bridgeMode==="bridge"?"bridge":"childbridge"),x(n.loggerLevel.charAt(0).toUpperCase()+n.loggerLevel.slice(1)),$(n.fileLogger),f(n.virtualMode))},[n]),o.useEffect(()=>{const F=localStorage.getItem(oe.frontendTheme);F&&P(F)},[]);const c=F=>{r&&console.log("handleChangeBridgeMode called with value:",F.target.value),g(F.target.value),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setbridgemode",value:F.target.value}})},v=F=>{r&&console.log("handleChangeMbLoggerLevel called with value:",F.target.value),x(F.target.value),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmbloglevel",value:F.target.value}})},C=F=>{r&&console.log("handleLogOnFileMbChange called with value:",F.target.checked),$(F.target.checked),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmblogfile",value:F.target.checked}})},b=F=>{const V=F.target.value;r&&console.log("handleChangeTheme called with value:",V),P(V),localStorage.setItem(oe.frontendTheme,V),document.body.setAttribute("frontend-theme",V)},B=F=>{const V=F.target.checked;r&&console.log("handleChangeHomePagePlugins called with value:",V),z(V),localStorage.setItem(oe.homePagePlugins,V?"true":"false")},ee=F=>{const V=F.target.value;r&&console.log("handleChangeHomePageMode called with value:",V),Y(V),localStorage.setItem(oe.homePageMode,V)},Me=F=>{const V=F.target.value;r&&console.log("handleChangeVirtualMode called with value:",V),f(V),localStorage.setItem(oe.virtualMode,V),l({id:p.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setvirtualmode",value:V}})};return!n||!a?null:e.jsxs(Ie,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Te,{children:e.jsx(Pe,{children:"Matterbridge settings"})}),e.jsx(Ni,{open:u,ip:a.ipv4Address,onClose:I,onSave:W}),e.jsx(Ri,{open:te,onClose:j,onSave:d}),e.jsxs(Ve,{style:{flexDirection:"column",padding:"10px",gap:"0px",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:"Mode:"}),e.jsxs(No,{row:!0,name:"mode-buttons-group",value:s,onChange:c,children:[e.jsx(st,{value:"bridge",control:e.jsx(qt,{}),label:"Bridge",disabled:n.readOnly===!0}),e.jsx(st,{value:"childbridge",control:e.jsx(qt,{}),label:"Childbridge",disabled:n.readOnly===!0})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mblogger-level-label",children:"Logger level:"}),e.jsxs(nt,{style:{height:"30px"},labelId:"mblogger-level-label",id:"mblogger-level",value:h,onChange:v,children:[e.jsx(R,{value:"Debug",children:"Debug"}),e.jsx(R,{value:"Info",children:"Info"}),e.jsx(R,{value:"Notice",children:"Notice"}),e.jsx(R,{value:"Warn",children:"Warn"}),e.jsx(R,{value:"Error",children:"Error"}),e.jsx(R,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mblogger-file-label",children:"Log on file:"}),e.jsx(Ze,{checked:t,onChange:C,id:"mblogger-file",name:"logOnFileMb"})]}),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(nt,{style:{height:"30px"},labelId:"frontend-theme-label",id:"frontend-theme",value:k,onChange:b,children:[e.jsx(R,{value:"classic",children:"Classic"}),e.jsx(R,{value:"light",children:"Light"}),e.jsx(R,{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(Ze,{checked:S,onChange:B,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(nt,{style:{height:"30px"},labelId:"frontend-home-label",id:"frontend-home",value:q,onChange:ee,children:[e.jsx(R,{value:"logs",children:"Logs"}),e.jsx(R,{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(nt,{style:{height:"30px"},labelId:"frontend-virtual-label",id:"frontend-virtual",value:U,onChange:Me,children:[e.jsx(R,{value:"disabled",children:"Disabled"}),e.jsx(R,{value:"outlet",children:"Outlet"}),e.jsx(R,{value:"light",children:"Light"}),e.jsx(R,{value:"switch",children:"Switch"}),e.jsx(R,{value:"mounted_switch",children:"Mounted Switch"})]})]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ge,{variant:"contained",color:"primary",onClick:()=>le(!0),children:"Change password"})}),n.shellyBoard&&e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"15px",marginTop:"20px"},children:e.jsx(ge,{variant:"contained",color:"primary",onClick:()=>M(!0),children:"Configure IP"})})]})]})}function Hi({matterbridgeInfo:n}){const{sendMessage:a,getUniqueId:l}=o.useContext(ke),[i,s]=o.useState("Info"),[g,h]=o.useState(!1),[x,t]=o.useState(""),[$,k]=o.useState(""),[P,S]=o.useState(""),[z,q]=o.useState(""),[Y,U]=o.useState(""),[f,p]=o.useState(""),u=o.useRef(l()),M=o.useMemo(()=>ht(1e3),[]),I=o.useMemo(()=>ht(1e3),[]),W=o.useMemo(()=>ht(1e3),[]),te=o.useMemo(()=>ht(1e3),[]),le=o.useMemo(()=>ht(1e3),[]),j=o.useMemo(()=>ht(1e3),[]);o.useEffect(()=>{n&&(s(["Debug","Info","Notice","Warn","Error","Fatal"][n.matterLoggerLevel]),h(n.matterFileLogger),t(n.matterMdnsInterface||""),k(n.matterIpv4Address||""),S(n.matterIpv6Address||""),q(n.matterPort?n.matterPort.toString():""),U(n.matterDiscriminator?n.matterDiscriminator.toString():""),p(n.matterPasscode?n.matterPasscode.toString():""))},[n]),o.useEffect(()=>()=>M.cancel(),[M]),o.useEffect(()=>()=>I.cancel(),[I]),o.useEffect(()=>()=>W.cancel(),[W]),o.useEffect(()=>()=>te.cancel(),[te]),o.useEffect(()=>()=>le.cancel(),[le]),o.useEffect(()=>()=>j.cancel(),[j]);const d=F=>{r&&console.log("handleChangeMjLoggerLevel called with value:",F.target.value),s(F.target.value),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjloglevel",value:F.target.value}})},c=F=>{r&&console.log("handleLogOnFileMjChange called with value:",F.target.checked),h(F.target.checked),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmjlogfile",value:F.target.checked}})},v=F=>{r&&console.log("handleChangeMdnsInterface called with value:",F.target.value);const V=F.target.value;t(V),M(()=>{r&&console.log("debounced sendMessage setmdnsinterface with value:",V),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmdnsinterface",value:V}})})},C=F=>{r&&console.log("handleChangeIpv4Address called with value:",F.target.value);const V=F.target.value;k(V),I(()=>{r&&console.log("debounced sendMessage setipv4address with value:",V),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv4address",value:V}})})},b=F=>{r&&console.log("handleChangeIpv6Address called with value:",F.target.value);const V=F.target.value;S(V),W(()=>{r&&console.log("debounced sendMessage setipv6address with value:",V),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setipv6address",value:V}})})},B=F=>{r&&console.log("handleChangeMatterPort called with value:",F.target.value);const V=F.target.value;q(V),te(()=>{r&&console.log("debounced sendMessage setmatterport with value:",V),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterport",value:V}})})},ee=F=>{r&&console.log("handleChangeMatterDiscriminator called with value:",F.target.value);const V=F.target.value;U(V),le(()=>{r&&console.log("debounced sendMessage setmatterdiscriminator with value:",V),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterdiscriminator",value:V}})})},Me=F=>{r&&console.log("handleChangemMatterPasscode called with value:",F.target.value);const V=F.target.value;p(V),j(()=>{r&&console.log("debounced sendMessage setmatterpasscode with value:",V),a({id:u.current,sender:"Settings",method:"/api/config",src:"Frontend",dst:"Matterbridge",params:{name:"setmatterpasscode",value:V}})})};return n?e.jsxs(Ie,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Te,{children:e.jsx(Pe,{children:"Matter settings"})}),e.jsxs(Ve,{style:{flexDirection:"column",padding:"10px",gap:"0px",backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mjlogger-level-label",children:"Logger level:"}),e.jsxs(nt,{style:{height:"30px"},labelId:"mjlogger-level-label",id:"mjlogger-level",value:i,onChange:d,children:[e.jsx(R,{value:"Debug",children:"Debug"}),e.jsx(R,{value:"Info",children:"Info"}),e.jsx(R,{value:"Notice",children:"Notice"}),e.jsx(R,{value:"Warn",children:"Warn"}),e.jsx(R,{value:"Error",children:"Error"}),e.jsx(R,{value:"Fatal",children:"Fatal"})]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",marginBottom:"5px",gap:"10px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px"},id:"mjlogger-file-label",children:"Log on file:"}),e.jsx(Ze,{checked:g,onChange:c,id:"mjlogger-file",name:"logOnFileMj"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Mdns interface:"}),e.jsx(Ce,{value:x,onChange:v,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv4 address:"}),e.jsx(Ce,{value:$,onChange:C,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Ipv6 address:"}),e.jsx(Ce,{value:P,onChange:b,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning port:"}),e.jsx(Ce,{value:z,onChange:B,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning discriminator:"}),e.jsx(Ce,{value:Y,onChange:ee,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",width:"100%",marginBottom:"10px",gap:"15px"},children:[e.jsx(We,{style:{padding:"0px",margin:"0px",textWrap:"nowrap"},children:"Commissioning passcode:"}),e.jsx(Ce,{value:f,onChange:Me,size:"small",variant:"outlined",style:{height:"30px",flexGrow:1},InputProps:{readOnly:n.readOnly===!0,style:{height:"30px",padding:"0"}}})]})]})]}):null}function Ei({matterbridgeInfo:n}){return n?e.jsxs(Ie,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Te,{children:e.jsx(Pe,{children:"Matterbridge info"})}),e.jsxs(Ve,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Ne,{value:n.matterbridgeVersion,label:"Current Version"}),e.jsx(Ne,{value:n.matterbridgeLatestVersion,label:"Latest Version"}),e.jsx(Ne,{value:n.rootDirectory,label:"Root Directory"}),e.jsx(Ne,{value:n.homeDirectory,label:"Home Directory"}),e.jsx(Ne,{value:n.matterbridgeDirectory,label:"Matterbridge Storage Directory"}),e.jsx(Ne,{value:n.matterbridgePluginDirectory,label:"Matterbridge Plugin Directory"}),e.jsx(Ne,{value:n.globalModulesDirectory,label:"Global Module Directory"})]})]}):null}function Ai({systemInfo:n}){return n?e.jsxs(Ie,{style:{flex:`1 1 ${Qt}px`},children:[e.jsx(Te,{children:e.jsx(Pe,{children:"System info"})}),e.jsxs(Ve,{style:{flexDirection:"column",padding:"10px",gap:"5px"},children:[e.jsx(Ne,{value:n.interfaceName,label:"Interface name"}),e.jsx(Ne,{value:n.macAddress,label:"MAC Address"}),e.jsx(Ne,{value:n.ipv4Address,label:"IPv4 Address"}),e.jsx(Ne,{value:n.ipv6Address,label:"IPv6 Address"}),e.jsx(Ne,{value:n.nodeVersion,label:"Node Version"}),e.jsx(Ne,{value:n.hostname,label:"Hostname"}),e.jsx(Ne,{value:n.user,label:"User"})]})]}):null}function Ne({value:n,label:a,width:l}){return e.jsx(Ce,{focused:!0,value:n,size:"small",label:a,variant:"standard",sx:{width:l?`${l-20}px`:"100%","& .MuiInput-underline:before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline:hover:not(.Mui-disabled):before":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5},"& .MuiInput-underline.Mui-focused:after":{borderBottomColor:"var(--main-label-color)",borderBottomWidth:"1px",opacity:.5}},slotProps:{input:{readOnly:!0,sx:{color:"var(--div-text-color)","&:before":{borderBottomColor:"var(--main-label-color)"},"&:after":{borderBottomColor:"var(--main-label-color)"}}},inputLabel:{sx:{marginTop:"3px",color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}}})}const Vi=o.memo(Oi);function Ui(){const{online:n,sendMessage:a,addListener:l,removeListener:i,getUniqueId:s}=o.useContext(ke),{showSnackbarMessage:g}=o.useContext(Re),[h,x]=o.useState(null),[t,$]=o.useState([]),[k,P]=o.useState([]),[S,z]=o.useState(null),[q,Y]=o.useState({cpuUsage:0}),[U,f]=o.useState({totalMemory:"",freeMemory:"",heapTotal:"",heapUsed:"",external:"",arrayBuffers:"",rss:""}),[p,u]=o.useState({systemUptime:"",processUptime:""}),M=o.useRef(s());return r&&console.log("Test uniqueId:",M),o.useEffect(()=>{r&&console.log("Test useEffect WebSocketMessage mounting");const I=W=>{if(W.method==="restart_required")r&&console.log("Test received restart_required"),g("Restart required",0);else if(W.method==="refresh_required")r&&console.log(`Test received refresh_required: changed=${W.response.changed} and sending api requests`),g("Refresh required",0),a({id:M.current,method:"/api/settings",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:M.current,method:"/api/plugins",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}}),a({id:M.current,method:"/api/devices",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{}});else if(W.method==="memory_update")r&&console.log("Test received memory_update",W),f(W.response);else if(W.method==="cpu_update")r&&console.log("Test received cpu_update",W),Y(W.response);else if(W.method==="uptime_update")r&&console.log("Test received uptime_update",W),u(W.response);else if(W.method==="/api/settings"&&W.response)r&&console.log("Test received /api/settings:",W.response),g("Test received /api/settings",0),x(W.response);else if(W.method==="/api/plugins"&&W.response)r&&console.log(`Test received ${W.response.length} plugins:`,W.response),g("Test received /api/plugins",0),$(W.response);else if(W.method==="/api/devices"&&W.response){r&&console.log(`Test received ${W.response.length} devices:`,W.response),g("Test received /api/devices",0),P(W.response);for(const te of W.response)r&&console.log("Test sending /api/clusters for device:",te.pluginName,te.name,te.endpoint),a({id:M.current,method:"/api/clusters",sender:"Test",src:"Frontend",dst:"Matterbridge",params:{plugin:te.pluginName,endpoint:te.endpoint||0}})}else W.method==="/api/clusters"&&W.response&&(r&&console.log(`Test received ${W.response.clusters.length} clusters for device ${W.response.deviceName} endpoint ${W.response.id}:${W.response.number}:`,W),g(`Test received /api/clusters for ${W.response.plugin}::${W.response.deviceName}`,0),z(W.response))};return l(I,M.current),r&&console.log("Test useEffect WebSocketMessage mounted"),()=>{r&&console.log("Test useEffect WebSocketMessage unmounting"),i(I),r&&console.log("Test useEffect WebSocketMessage unmounted")}},[l,i,a,g]),o.useEffect(()=>(r&&console.log("Test useEffect online mounting"),n&&r&&console.log("Test useEffect online received online"),r&&console.log("Test useEffect online mounted"),()=>{r&&console.log("Test useEffect online unmounted")}),[n,a,g]),r&&console.log("Test rendering..."),n?e.jsx(Mt,{name:"Test",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",alignContent:"center",gap:"20px",height:"100vh",width:"100vw"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"256px",width:"256px",margin:"10px"}}),e.jsx("p",{children:"Welcome to the Test page of the Matterbridge frontend"})]})}):e.jsx(Ge,{})}const zi=o.memo(Ui);function qi(n,a){r&&console.log("getCssVariable:",n,"defaultValue",a);const l=getComputedStyle(document.body).getPropertyValue(n).trim();return l||console.error("getCssVariable: undefined",l),l||a}function Bi(n){return Rr({palette:{primary:{main:n},action:{disabled:"var(--main-label-color)"},text:{disabled:"var(--main-label-color)"}},typography:{fontFamily:"Roboto, Helvetica, Arial, sans-serif"},components:{MuiDialog:{styleOverrides:{paper:{color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)",border:"2px solid var(--div-border-color)",borderRadius:"var(--div-border-radius)",boxShadow:"2px 2px 5px var(--div-shadow-color)"}}},MuiTooltip:{defaultProps:{placement:"top-start",arrow:!0}},MuiButton:{styleOverrides:{root:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)","&:hover":{backgroundColor:"var(--main-button-bg-color)"},"&.Mui-disabled":{color:"var(--main-button-color)",backgroundColor:"var(--main-grey-color)"}},contained:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},outlined:{color:"var(--main-button-color)",backgroundColor:"var(--main-button-bg-color)"},text:{color:"var(--main-button-color)"}},defaultProps:{variant:"contained",size:"small"}},MuiIconButton:{styleOverrides:{root:{color:"var(--main-icon-color)","&:hover .MuiSvgIcon-root":{color:"var(--primary-color)"}}}},MuiCheckbox:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiTextField:{defaultProps:{size:"small",variant:"outlined",fullWidth:!0}},MuiOutlinedInput:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)","& .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-label-color)"},"&:hover .MuiOutlinedInput-notchedOutline":{borderColor:"var(--main-text-color)"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{borderColor:"var(--primary-color)"},padding:"0px"},input:{color:"var(--div-text-color)",padding:"4px 8px"}}},MuiInputLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--primary-color)"}}}},MuiFormLabel:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-focused":{color:"var(--main-label-color)"}}}},MuiFormControl:{styleOverrides:{root:{color:"var(--main-grey-color)"}}},MuiRadio:{styleOverrides:{root:{color:"var(--main-label-color)","&.Mui-checked":{color:"var(--primary-color)"}}}},MuiSelect:{styleOverrides:{root:{backgroundColor:"var(--div-bg-color)",color:"var(--div-text-color)",height:"30px","&:hover":{borderColor:"var(--main-text-color)"},"&.Mui-focused":{borderColor:"var(--primary-color)"}}}},MuiMenu:{styleOverrides:{paper:{backgroundColor:"var(--main-menu-bg-color)",padding:"0px",margin:"0px"},list:{padding:"0px"}}},MuiMenuItem:{styleOverrides:{root:{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)","&:hover":{backgroundColor:"var(--main-menu-hover-color)"},"&.Mui-selected":{color:"var(--main-menu-color)",backgroundColor:"var(--main-menu-bg-color)"},"&.Mui-selected:hover":{backgroundColor:"var(--main-menu-hover-color)"}}}},MuiListItemButton:{styleOverrides:{root:{cursor:"pointer","&:hover":{backgroundColor:"var(--main-bg-color)"}}}},MuiListItemIcon:{styleOverrides:{root:{color:"var(--div-text-color)"}}},MuiListItemText:{styleOverrides:{primary:{fontSize:"16px",fontWeight:"bold",color:"var(--div-text-color)"},secondary:{fontSize:"14px",fontWeight:"normal",color:"var(--div-text-color)"}}}}})}function Qi(){const{mobile:n,showSnackbarMessage:a,showConfirmCancelDialog:l}=o.useContext(Re),{online:i,sendMessage:s,logMessage:g,addListener:h,removeListener:x,getUniqueId:t}=o.useContext(ke),[$,k]=o.useState(!1),[P,S]=o.useState(!1),[z,q]=o.useState(!1),[Y,U]=o.useState(!1),[f,p]=o.useState(null),u=o.useRef(t()),[M,I]=o.useState(null),[W,te]=o.useState(null),[le,j]=o.useState(null),[d,c]=o.useState(null),[v,C]=o.useState(null),b=qo(),B=()=>{window.open("https://www.buymeacoffee.com/luligugithub","_blank")},ee=()=>{window.open("https://matterbridge.io/")},Me=()=>{window.open("https://matterbridge.io/README.html")},F=()=>{window.open("https://matterbridge.io/CHANGELOG.html")},V=()=>{window.open("https://discord.gg/QX58CDe6hd","_blank")},O=()=>{window.open("https://github.com/Luligu/matterbridge","_blank")},H=()=>{s({id:u.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge",restart:!0}}),q(!1)},L=()=>{s({id:u.current,sender:"Header",method:"/api/install",src:"Frontend",dst:"Matterbridge",params:{packageName:"matterbridge@dev",restart:!0}}),U(!1)},pe=()=>{s({id:u.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}})},Se=()=>{r&&console.log("Header: handleShellySystemUpdateClick"),g("Matterbridge","Installing system updates..."),s({id:u.current,sender:"Header",method:"/api/shellysysupdate",src:"Frontend",dst:"Matterbridge",params:{}})},T=()=>{r&&console.log("Header: handleShellyMainUpdateClick"),g("Matterbridge","Installing software updates..."),s({id:u.current,sender:"Header",method:"/api/shellymainupdate",src:"Frontend",dst:"Matterbridge",params:{}})},w=()=>{r&&console.log("Header: handleShellyCreateSystemLog"),s({id:u.current,sender:"Header",method:"/api/shellycreatesystemlog",src:"Frontend",dst:"Matterbridge",params:{}})},D=()=>{r&&console.log("Header: handleShellyDownloadSystemLog"),g("Matterbridge","Downloading Shelly system log..."),a("Downloading Shelly system log...",5),window.location.href="./api/shellydownloadsystemlog"},A=()=>{f?.matterbridgeInformation.restartMode===""?s({id:u.current,sender:"Header",method:"/api/restart",src:"Frontend",dst:"Matterbridge",params:{}}):s({id:u.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},Q=()=>{s({id:u.current,sender:"Header",method:"/api/shutdown",src:"Frontend",dst:"Matterbridge",params:{}})},J=()=>{s({id:u.current,sender:"Header",method:"/api/reboot",src:"Frontend",dst:"Matterbridge",params:{}})},m=()=>{s({id:u.current,sender:"Header",method:"/api/softreset",src:"Frontend",dst:"Matterbridge",params:{}})},ce=()=>{s({id:u.current,sender:"Header",method:"/api/hardreset",src:"Frontend",dst:"Matterbridge",params:{}})},G=y=>{I(y.currentTarget)},N=y=>{r&&console.log("Header: handleMenuClose",y),I(null),y==="/"||y==="/devices"||y==="/log"||y==="/settings"?b(y):y==="reset_frontend"?(g("Matterbridge","Resetting frontend UI..."),a("Resetting frontend UI...",5),Cn(),window.location.reload()):y==="download-mblog"?(g("Matterbridge","Downloading matterbridge log..."),a("Downloading matterbridge log...",5),window.location.href="./api/download-mblog"):y==="download-mjlog"?(g("Matterbridge","Downloading matter log..."),a("Downloading matter log...",5),window.location.href="./api/download-mjlog"):y==="view-mblog"?(g("Matterbridge","Loading matterbridge log..."),a("Loading matterbridge log...",5),window.open("./api/view-mblog","_blank","noopener,noreferrer")):y==="view-mjlog"?(g("Matterbridge","Loading matter log..."),a("Loading matter log...",5),window.open("./api/view-mjlog","_blank","noopener,noreferrer")):y==="view-diagnostic"?(g("Matterbridge","Loading diagnostic log..."),a("Loading diagnostic log...",5),window.open("./api/view-diagnostic","_blank","noopener,noreferrer")):y==="download-diagnostic"?(g("Matterbridge","Downloading diagnostic log..."),a("Downloading diagnostic log...",5),window.location.href="./api/download-diagnostic"):y==="view-history"?s({id:u.current,sender:"Header",method:"/api/viewhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):y==="download-history"?s({id:u.current,sender:"Header",method:"/api/downloadhistorypage",src:"Frontend",dst:"Matterbridge",params:{}}):y==="view-shellylog"?(g("Matterbridge","Loading shelly system log..."),a("Loading shelly system log...",5),window.location.href="./api/shellyviewsystemlog"):y==="download-mbstorage"?(g("Matterbridge","Downloading matterbridge storage..."),a("Downloading matterbridge storage...",5),window.location.href="./api/download-mbstorage"):y==="download-pluginstorage"?(g("Matterbridge","Downloading matterbridge plugins storage..."),a("Downloading matterbridge plugins storage...",5),window.location.href="./api/download-pluginstorage"):y==="download-pluginconfig"?(g("Matterbridge","Downloading matterbridge plugins config..."),a("Downloading matterbridge plugins config...",5),window.location.href="./api/download-pluginconfig"):y==="download-mjstorage"?(g("Matterbridge","Downloading matter storage..."),a("Downloading matter storage...",5),window.location.href="./api/download-mjstorage"):y==="download-backup"?(g("Matterbridge","Downloading backup..."),a("Downloading backup...",10),window.location.href="./api/download-backup"):y==="update"?H():y==="updatedev"?L():y==="updatecheck"?pe():y==="shelly-sys-update"?Se():y==="shelly-main-update"?T():y==="shelly-create-system-log"?w():y==="shelly-download-system-log"?D():y==="softreset"?m():y==="hardreset"?ce():y==="restart"?A():y==="shutdown"?Q():y==="reboot"?J():y==="create-backup"?s({id:u.current,sender:"Header",method:"/api/create-backup",src:"Frontend",dst:"Matterbridge",params:{}}):y==="unregister"?s({id:u.current,sender:"Header",method:"/api/unregister",src:"Frontend",dst:"Matterbridge",params:{}}):y==="reset"?s({id:u.current,sender:"Header",method:"/api/reset",src:"Frontend",dst:"Matterbridge",params:{}}):y==="factoryreset"&&s({id:u.current,sender:"Header",method:"/api/factoryreset",src:"Frontend",dst:"Matterbridge",params:{}})},fe=y=>{r&&console.log("Header: handleMenuCloseCancel:",y),I(null)},de=y=>{te(y.currentTarget)},De=()=>{te(null)},Oe=y=>{j(y.currentTarget)},ve=()=>{j(null)},se=y=>{c(y.currentTarget)},ae=()=>{c(null)},Fe=y=>{C(y.currentTarget)},_e=()=>{C(null)},tt=()=>{Ki(),r&&console.log("Matterbridge logo clicked: debug is now",r)};return o.useEffect(()=>{const y=re=>{r&&console.log("Header received WebSocket Message:",re),re.method==="/api/settings"&&re.id===u.current?(r&&console.log("Header received settings:",re.response),p(re.response),k(re.response.matterbridgeInformation.restartRequired||re.response.matterbridgeInformation.fixedRestartRequired),S(re.response.matterbridgeInformation.fixedRestartRequired),q(re.response.matterbridgeInformation.updateRequired)):re.method==="refresh_required"&&re.response.changed==="settings"?(r&&console.log(`Header received refresh_required: changed=${re.response.changed} and sending /api/settings request`),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):re.method==="restart_required"?(r&&console.log(`Header received restart_required with fixed: ${re.response.fixed}`),k(!0),re.response.fixed===!0&&S(!0)):re.method==="restart_not_required"?(r&&console.log("Header received restart_not_required"),k(!1)):re.method==="update_required"?(r&&console.log("Header received update_required"),re.response.devVersion===!0?U(!0):q(!0),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}})):re.method==="shelly_sys_update"?(r&&console.log("Header received WS_ID_SHELLY_SYS_UPDATE:"),p(Le=>Le?{matterbridgeInformation:{...Le.matterbridgeInformation,shellySysUpdate:re.response.available},systemInformation:Le.systemInformation}:null)):re.method==="shelly_main_update"?(r&&console.log("Header received WS_ID_SHELLY_MAIN_UPDATE:"),p(Le=>Le?{matterbridgeInformation:{...Le.matterbridgeInformation,shellyMainUpdate:re.response.available},systemInformation:Le.systemInformation}:null)):re.method==="/api/viewhistorypage"&&re.id===u.current&&re.success===!0?(r&&console.log("Header received /api/viewhistorypage success"),window.open("./api/viewhistory","_blank","noopener,noreferrer")):re.method==="/api/downloadhistorypage"&&re.id===u.current&&re.success===!0&&(r&&console.log("Header received /api/downloadhistorypage success"),window.location.href="./api/downloadhistory")};return h(y,u.current),r&&console.log(`Header added WebSocket listener id ${u.current}`),()=>{x(y),r&&console.log("Header removed WebSocket listener")}},[h,x,s,a]),o.useEffect(()=>{i&&(r&&console.log("Header sending /api/settings and /api/checkupdates requests"),s({id:u.current,sender:"Header",method:"/api/settings",src:"Frontend",dst:"Matterbridge",params:{}}),s({id:u.current,sender:"Header",method:"/api/checkupdates",src:"Frontend",dst:"Matterbridge",params:{}}))},[i,s]),r&&console.log("Header rendering... mobile %s",n),!i||!f?null:e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"space-between",alignItems:"center",width:"100%",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:[e.jsx("img",{src:"matterbridge.svg",alt:"Matterbridge Logo",style:{height:"30px"},onClick:tt}),e.jsx("h2",{style:{fontSize:"22px",color:"var(--main-icon-color)",margin:"0px"},children:"Matterbridge"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"10px"},children:e.jsxs("nav",{children:[e.jsx(Pt,{to:"/",className:"nav-link",children:"Home"}),e.jsx(Pt,{to:"/devices",className:"nav-link",children:"Devices"}),e.jsx(Pt,{to:"/log",className:"nav-link",children:"Logs"}),e.jsx(Pt,{to:"/settings",className:"nav-link",children:"Settings"})]})})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"10px"},children:[!f.matterbridgeInformation.readOnly&&e.jsx(E,{title:`Matterbridge v.${f.matterbridgeInformation.matterbridgeVersion}`,children:e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:["v.",f.matterbridgeInformation.matterbridgeVersion.split("-")[0]+(f.matterbridgeInformation.matterbridgeVersion.includes("-dev-")?"@dev":"")+(f.matterbridgeInformation.matterbridgeVersion.includes("-git-")?"@git":"")]})}),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(E,{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(E,{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(E,{title:"Current profile",children:e.jsx("span",{className:"status-information",style:{cursor:"default"},children:f.matterbridgeInformation.profile})}):null,r&&e.jsxs("span",{className:"status-information",style:{cursor:"default"},children:[n?"Mobile ":"Desktop ",`${Ut}x${zt}`,` enabled ${localStorage.getItem(oe.enableMobile)!=="false"}`]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",flexWrap:"wrap",alignItems:"center",gap:"5px"},children:[f.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Matterbridge discord group",children:e.jsx("img",{src:"discord.svg",alt:"Discord Logo",style:{cursor:"pointer",height:"25px"},onClick:V})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Give a star to Matterbridge",children:e.jsx(X,{style:{color:"#FFD700",margin:"0",padding:"0"},onClick:O,children:e.jsx(To,{})})}):null,f.matterbridgeInformation.readOnly===!1?e.jsx(E,{title:"Sponsor Matterbridge",children:e.jsx(X,{style:{color:"#b6409c",margin:"0",padding:"0"},onClick:B,children:e.jsx(io,{})})}):null,e.jsx(E,{title:"Matterbridge homepage",children:e.jsx(X,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:ee,children:e.jsx(Do,{})})}),e.jsx(E,{title:"Matterbridge help",children:e.jsx(X,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:Me,children:e.jsx(no,{})})}),e.jsx(E,{title:"Matterbridge changelog",children:e.jsx(X,{style:{color:"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:F,children:e.jsx(Bt,{})})}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&z&&e.jsx(E,{title:`Update matterbridge to latest version v.${f.matterbridgeInformation.matterbridgeLatestVersion}`,children:e.jsx(X,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:H,children:e.jsx(ze,{})})}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&Y&&e.jsx(E,{title:`Update matterbridge to latest dev version v.${f.matterbridgeInformation.matterbridgeDevVersion}`,children:e.jsx(X,{style:{color:"var(--secondary-color)",margin:"0",marginLeft:"5px",padding:"0"},onClick:L,children:e.jsx(ze,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsx(E,{title:"Shelly system update",children:e.jsx(X,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Se,children:e.jsx(ze,{})})}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsx(E,{title:"Shelly software update",children:e.jsx(X,{style:{color:"var(--primary-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:T,children:e.jsx(ze,{})})}),e.jsx(E,{title:"Restart matterbridge",children:e.jsx(X,{style:{color:$||P?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:A,children:e.jsx(Vt,{})})}),f.matterbridgeInformation.restartMode===""?e.jsx(E,{title:"Shut down matterbridge",children:e.jsx(X,{style:{color:$||P?"var(--primary-color)":"var(--main-icon-color)",margin:"0",marginLeft:"5px",padding:"0px"},onClick:Q,children:e.jsx(Xe,{})})}):null,e.jsx(E,{title:"Download, backup and more",children:e.jsx(X,{onClick:G,children:e.jsx(Or,{style:{color:"var(--main-icon-color)"}})})}),e.jsxs(jt,{id:"command-menu",anchorEl:M,keepMounted:!0,open:!!M,onClose:()=>N(""),children:[we&&n&&e.jsxs(R,{onClick:()=>N("/"),children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Home page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),we&&n&&e.jsxs(R,{onClick:()=>N("/devices"),children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Devices page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),we&&n&&e.jsxs(R,{onClick:()=>N("/log"),children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Logs page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),we&&n&&e.jsxs(R,{onClick:()=>N("/settings"),children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Settings page",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(R,{onClick:()=>N("update"),children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Install latest stable",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(R,{onClick:()=>N("updatedev"),children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Install latest dev",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&!f.matterbridgeInformation.readOnly&&e.jsxs(R,{onClick:()=>N("updatecheck"),children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Check for updates",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellySysUpdate&&e.jsxs(R,{onClick:()=>N("shelly-sys-update"),children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Shelly system update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&f.matterbridgeInformation.shellyMainUpdate&&e.jsxs(R,{onClick:()=>N("shelly-main-update"),children:[e.jsx(K,{children:e.jsx(ze,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Shelly software update",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>N("restart"),children:[e.jsx(K,{children:e.jsx(Vt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Restart",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation.restartMode===""?e.jsxs(R,{onClick:()=>N("shutdown"),children:[e.jsx(K,{children:e.jsx(Xe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Shutdown",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}):null,f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(R,{onClick:()=>{l("Reboot","Are you sure you want to reboot the Shelly board?","reboot",N,fe)},children:[e.jsx(K,{children:e.jsx(Vt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Reboot...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsx(Ft,{}),e.jsxs(R,{onClick:Oe,children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"View",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(jt,{id:"sub-menu-view",anchorEl:le,keepMounted:!0,open:!!le,onClose:ve,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(R,{onClick:()=>{Zi(),ve(),fe(""),window.open("/home","_self")},children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Desktop site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{Yi(),ve(),fe(""),window.open("/home","_self")},children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Mobile site",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("view-mblog"),ve()},children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("view-mjlog"),ve()},children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("view-diagnostic"),ve()},children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("view-history"),ve()},children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(R,{onClick:()=>{N("view-shellylog"),ve()},children:[e.jsx(K,{children:e.jsx(Ee,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Ft,{}),e.jsxs(R,{onClick:se,children:[e.jsx(K,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Download",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(jt,{id:"sub-menu-download",anchorEl:d,keepMounted:!0,open:!!d,onClose:ae,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(R,{onClick:()=>{N("download-mbstorage"),ae()},children:[e.jsx(K,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matterbridge storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("download-pluginstorage"),ae()},children:[e.jsx(K,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matterbridge plugins storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("download-pluginconfig"),ae()},children:[e.jsx(K,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matterbridge plugins config",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("download-mblog"),ae()},children:[e.jsx(K,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matterbridge log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("download-mjstorage"),ae()},children:[e.jsx(K,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matter storage",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("download-mjlog"),ae()},children:[e.jsx(K,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matter log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("download-diagnostic"),ae()},children:[e.jsx(K,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matterbridge diagnostic log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("download-history"),ae()},children:[e.jsx(K,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Matterbridge system history",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(R,{onClick:()=>{N("shelly-create-system-log"),ae()},children:[e.jsx(K,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Create Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(R,{onClick:()=>{N("shelly-download-system-log"),ae()},children:[e.jsx(K,{children:e.jsx(Ae,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Download Shelly system log",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Ft,{}),e.jsxs(R,{onClick:de,children:[e.jsx(K,{children:e.jsx(Jt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(jt,{id:"sub-menu-backup",anchorEl:W,keepMounted:!0,open:!!W,onClose:De,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(R,{onClick:()=>{N("create-backup"),De()},children:[e.jsx(K,{children:e.jsx(Jt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Create backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{N("download-backup"),De()},children:[e.jsx(K,{children:e.jsx(Jt,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Download backup",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]}),e.jsx(Ft,{}),e.jsxs(R,{onClick:Fe,children:[e.jsx(K,{children:e.jsx(_r,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Reset",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(jt,{id:"sub-menu-reset",anchorEl:v,keepMounted:!0,open:!!v,onClose:_e,sx:{"& .MuiPaper-root":{backgroundColor:"#e2e2e2"}},children:[e.jsxs(R,{onClick:()=>{_e(),l("Reset the frontend UI","Are you sure you want to reset the frontend UI? This will reset all local settings and reload the page.","reset_frontend",N,fe)},children:[e.jsx(K,{children:e.jsx(Xe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Reset the frontend UI...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{_e(),l("Reset all devices and shutdown","Are you sure you want to unregister all devices? This will temporarily remove all devices from the controller and you may loose the controller configuration.","unregister",N,fe)},children:[e.jsx(K,{children:e.jsx(Xe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Reset all devices...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),e.jsxs(R,{onClick:()=>{_e(),l("Reset commissioning and shutdown","Are you sure you want to reset the commissioning? You will have to manually remove Matterbridge from the controller.","reset",N,fe)},children:[e.jsx(K,{children:e.jsx(Xe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Reset commissioning...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),!f.matterbridgeInformation.readOnly&&e.jsxs(R,{onClick:()=>{_e(),l("Factory reset and shutdown","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","factoryreset",N,fe)},children:[e.jsx(K,{children:e.jsx(Xe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(R,{onClick:()=>{_e(),l("Network reset","Are you sure you want to factory reset the network parameters?","softreset",N,fe)},children:[e.jsx(K,{children:e.jsx(Xe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Reset network...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]}),f.matterbridgeInformation&&f.matterbridgeInformation.shellyBoard&&e.jsxs(R,{onClick:()=>{_e(),l("Factory reset","Are you sure you want to factory reset Matterbridge? You will have to manually remove Matterbridge from the controller.","hardreset",N,fe)},children:[e.jsx(K,{children:e.jsx(Xe,{style:{color:"var(--main-icon-color)"}})}),e.jsx(ie,{primary:"Factory reset...",primaryTypographyProps:{style:{fontWeight:"normal",color:"var(--main-icon-color)"}}})]})]})]})]})]})}const ko=o.memo(Qi),Ao=1200,Vo=900;let Ut,zt;function Io(){if(typeof window<"u"){Ut=Math.floor(window.visualViewport?.width??window.innerWidth),zt=Math.floor(window.visualViewport?.height??window.innerHeight);const n=Ut<Ao||zt<Vo;return r&&console.log("Visual viewport (%s) width %i height %i mobile %s",window.visualViewport!==void 0,Ut,zt,n),n}return!1}function Gi({children:n}){const{mobile:a,setMobile:l}=o.useContext(Re),{logAutoScroll:i}=o.useContext(ke);return o.useEffect(()=>{function s(){const g=Io();g&&(i.current=!1,localStorage.setItem(oe.logAutoScroll,"false")),l(g)}return window.addEventListener("resize",s),l(Io()),()=>window.removeEventListener("resize",s)},[i,l]),r&&console.log("MbfScreen rendering... mobile %s",a),we&&a?e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"visible",margin:"0px",padding:"10px",gap:"10px"},children:[e.jsx(ko,{}),e.jsx("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",margin:"0px",padding:"0px",gap:"10px"},children:n})]}):e.jsxs("div",{style:{display:"flex",flexDirection:"column",overflow:"hidden",width:a?`${Ao}px`:"calc(100vw - 40px)",height:a?`${Vo}px`:"calc(100vh - 40px)",margin:"0px",padding:"20px",gap:"20px"},children:[e.jsx(ko,{}),e.jsx("div",{style:{display:"flex",flexDirection:"row",width:"100%",height:"calc(100% - 60px)",margin:"0px",padding:"0px",gap:"20px"},children:n})]})}let r=!1;const Ki=()=>{r=!r},Ji=!1;let we=localStorage.getItem(oe.enableMobile)!=="false";const Yi=()=>{we=!0,localStorage.setItem(oe.enableMobile,"true")},Zi=()=>{we=!1,localStorage.setItem(oe.enableMobile,"false")};let xt;const Xi=n=>{xt=n};let kt=!1,Mo="/",mt="/",to="/";function es({setLoggedIn:n}){const[a,l]=o.useState(""),[i,s]=o.useState(""),g={display:"flex",justifyContent:"center",alignItems:"center",height:"100vh",backgroundColor:"var(--main-bg-color)"},h={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)"},x={margin:"10px 0",padding:"3px 3px",fontSize:"14px",width:"230px",border:"1px solid var(--main-label-color)",color:"var(--div-text-color)",backgroundColor:"var(--div-bg-color)"},t=async k=>{try{const P=await fetch("./api/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:k})});if(P.ok){const{valid:S}=await P.json();S?(n(!0),k!==""&&(xt=k)):k!==""&&s("Incorrect password!")}else console.error("Failed to log in:",P.statusText)}catch(P){console.error("Failed to log in:",P)}},$=k=>{k.preventDefault(),t(a)};return t(""),e.jsx("div",{style:g,children:e.jsxs("form",{onSubmit:$,style:h,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",{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:a,onChange:k=>l(k.target.value),style:x,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 ts(){const[n,a]=o.useState(!1),l=localStorage.getItem(oe.frontendTheme)||"dark";r&&console.log('Setting frontend theme "%s"',l),document.body.setAttribute("frontend-theme",l);const i=qi("--primary-color","#1976d2");r&&console.log('Primary color from CSS "%s"',i);const s=Bi(i);return Mo=window.location.href,mt=window.location.pathname,to=mt.includes("/matterbridge/")?"/matterbridge/":mt.includes("/api/hassio_ingress/")?mt:"/",kt=mt.includes("/api/hassio_ingress/"),console.log("Loading App..."),console.log(`- href = "${Mo}"`),console.log(`- pathname = "${mt}"`),console.log(`- baseName = "${to}"`),console.log(`- isIngress = "${kt}"`),n?e.jsx(Hr,{theme:s,children:e.jsx(Zo,{dense:!0,maxSnack:10,preventDuplicate:!0,anchorOrigin:{vertical:"bottom",horizontal:"right"},children:e.jsx(kn,{children:e.jsx(In,{children:e.jsx(Bo,{basename:to,children:e.jsx(Gi,{children:e.jsxs(Qo,{children:[e.jsx(ct,{path:"/",element:e.jsx(di,{})}),e.jsx(ct,{path:"/devices",element:e.jsx(Wi,{})}),e.jsx(ct,{path:"/log",element:e.jsx(Fi,{})}),e.jsx(ct,{path:"/settings",element:e.jsx(Vi,{})}),e.jsx(ct,{path:"/test",element:e.jsx(zi,{})}),e.jsx(ct,{path:"*",element:e.jsx(Go,{to:"/"})})]})})})})})})}):e.jsx(es,{setLoggedIn:a})}Ko.createRoot(document.getElementById("root")).render(e.jsx(Jo.StrictMode,{children:e.jsx(ts,{})}));
|